Public
Edited
Feb 24, 2021
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
vl.markPoint()
.width(400).height(400)
.data(aes)
.encode(
vl.x().fieldQ('placebo_n'),
vl.y().fieldQ('gdnf_n'),
vl.tooltip().fieldN('adverse_events'),
vl.color().fieldQ('surprisal_bits').scale({scheme: 'turbo'}),
vl.size().fieldQ('seq').legend(false)
)
.render()
Insert cell
Insert cell
Insert cell
printTable(aes)
Insert cell
md`## *I<sub>q</sub>* via Fisher's *F* distribution`
Insert cell
function F(k, n, p) {
let odds = p/(1-p);
let x = (1/odds) * (k+1)/(n-k);
let df1 = 2*(n-k); // NB: Fails (appropriately) when k==n
let df2 = 2*(k+1);
return stdlib.stats.base.dists.f.cdf(x, df1, df2)
}
Insert cell
function S(x, y, odds) {
let p = odds/(odds+1)
let n = x+y
let tailprob = ( x/n < p ? F(x, n, p) : F(y, n, 1-p));
return -Math.log2(tailprob)
}
Insert cell
Insert cell
probtab = {
let N = 51;
var ptab = [];
for (var j = 1; j < N; ++j) {
for (var i = 1; i < N; ++i) {
let x = 10.0*i/N;
let y = 10.0*j/N;
ptab.push({ x : i, y : -j, S_bits : S(x,y,21/20) });
}
}
return ptab;
}
Insert cell
vl.markRect({tooltip: {"content": "data"}, clip: true})
.width(400).height(400)
.data(probtab)
.encode(
vl.y().fieldO('y').axis({labels:false}),
vl.x().fieldO('x').axis({labels:false}),
vl.color().fieldQ('S_bits').scale({ scheme: "turbo", reverse: false }),
)
.render()
Insert cell
Insert cell
Insert cell
md`## Data`
Insert cell
Insert cell
aes = {
const tableA8 = d3.tsvParse(rawData, d3.autoType);
const [, ...raw] = tableA8; // TODO: Remove 0th row, which is a precalculated margin
const aes = raw.map(r => Object.assign(r, { surprisal_bits : S(r.placebo_n,r.gdnf_n,r.placebo_N/r.gdnf_N) }));
var j = 3;
var aes2 = [Object.assign(aes[0], { seq : j*j })];
for (var i = 1; i < aes.length; ++i) {
if (aes[i].gdnf_n == aes[i-1].gdnf_n && aes[i].placebo_n == aes[i-1].placebo_n){
--j;
} else {
j = 3;
}
aes2.push(Object.assign(aes[i], { seq: j*j }));
}
return aes2;
}
Insert cell
Insert cell
d3 = require('d3@6')
Insert cell
stdlib = require('@stdlib/dist-tree')
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
import {printTable} from '@uwdata/data-utilities'
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more