Public
Edited
Feb 6, 2023
Insert cell
Insert cell
pyodide = {
const pyodide = await require("https://cdn.jsdelivr.net/pyodide/dev/full/pyodide.js");
return pyodide.loadPyodide({
indexURL: "https://cdn.jsdelivr.net/pyodide/dev/full/"
})
}
Insert cell
make_treeseq_svg = async () => {
await pyodide.loadPackage("msprime");
const msprime = await pyodide.pyimport("msprime");
const ts = msprime.sim_ancestry.callKwargs({samples: 5, recombination_rate: 1e-7, sequence_length:1e6, random_seed:6667, record_full_arg: true});
// [A, B] is a tuple in JS, so don't confuse this for a list.
const ts_svg = ts.draw_svg.callKwargs({size: [600, 400]});
return html`${ts_svg}`
}
Insert cell
make_treeseq_svg()
Insert cell
treeseq_total_times = async () => {
await pyodide.loadPackage("msprime");
const msprime = await pyodide.pyimport("msprime");
let ttimes = [];
const ts = msprime.sim_ancestry.callKwargs({samples: 5, recombination_rate: 1e-7, sequence_length:1e6, random_seed:6667});
for (const tree of ts.trees.call()) {
ttimes.push(tree.total_branch_length);
}
return ttimes
}
Insert cell
treeseq_total_times()
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