Published
Edited
Feb 23, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
width = 800
Insert cell
{
const context = DOM.context2d(width, height);

coords.forEach((point, i) => {
context.beginPath(),
context.arc(point[0] * width, point[1] * height, 4, 0, 2 * Math.PI),
(context.fillStyle = `rgba(${ rate_data[i].Filename.substr (0,4)=="FBgn" ? 255 : 0},${0},${ rate_data[i].Filename.substr (0,4)=="FBgn" ? 0 : 128},0.2)`),
context.fill();
});

return context.canvas;
}
Insert cell
_ = require ("lodash")
Insert cell
entropy = (d)=> {
let h = 0;
const l2 = 1./Math.log (2);
for (let i = 0; i < d.length; i++) {
h += d[i] * Math.log (d[i]);
}
let h_max = Math.log (1/d.length);
return h / h_max;
}
Insert cell
renormalize = (d)=> {
let r = _.reduce (d, (s,r)=>s*Math.min (5,Math.max (1e-4,+r)),1);
r = Math.pow (r,1/(d.length + 1));
let rr = _.clone (d);
rr.push (1);
return _.map (rr, (d)=>Math.min (5,Math.max(+d,1e-4))/r);
//return r;
//const s = d3.sum (d) + 1;
//r.push (1);
//return _.map (r, (ri)=>ri/s);
}
Insert cell
rates = _.map (rate_data, (d)=>renormalize(_.map (rate_keys, (k)=>+d[k])))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more