taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
91 lines (90 loc) • 3.35 kB
JavaScript
import { O as J, u as O, ak as Y } from "./JBrowsePanel-BNE3gNW1.js";
import { d as K, f as a, g as L, a as N } from "./drawPhased-CAb_z73L.js";
async function x({ ctx: n, canvasWidth: w, canvasHeight: F, renderArgs: q }) {
const { renderingMode: G, minorAlleleFrequencyFilter: Q, sources: d, features: U, stopToken: C, lengthCutoffFilter: V } = q, { statusCallback: I = () => {
} } = q, u = F / d.length;
J.checkStopToken(C);
const g = await O.updateStatus("Calculating stats", I, () => Y({
stopToken: C,
features: U.values(),
minorAlleleFrequencyFilter: Q,
lengthCutoffFilter: V
}));
J.checkStopToken(C);
const z = [], X = g.length, p = w / X;
return await O.updateStatus("Drawing variant matrix", I, () => {
const T = {};
O.forEachWithStopTokenCheck(g, C, ({ feature: v, mostFrequentAlt: B }, H) => {
var b, A, E;
const M = [];
if ((b = v.get("FORMAT")) === null || b === void 0 ? void 0 : b.includes("PS")) {
const R = v.get("samples"), i = H / g.length * w, m = d.length;
for (let t = 0; t < m; t++) {
const c = t / m * F, { name: _, HP: j } = d[t], e = R[_];
if (e) {
const s = (A = e.GT) === null || A === void 0 ? void 0 : A[0];
if (s) {
M.push(s);
const o = s.includes("|");
if (G === "phased")
if (o) {
const l = (E = e.PS) === null || E === void 0 ? void 0 : E[0], f = s.split("|");
K(f, n, i, c, p, u, j, l);
} else
n.fillStyle = "black", n.fillRect(i - a, c - a, p + a, u + a);
else {
let l = T[s];
if (l === void 0) {
let f = 0, k = 0, S = 0, P = 0;
const y = s.split(/[/|]/), h = y.length;
for (let r = 0; r < h; r++) {
const D = y[r];
D === B ? f++ : D === "0" ? P++ : D === "." ? k++ : S++;
}
l = L(P, f, S, k, h, !0), T[s] = l;
}
l && N(l, n, i, c, p, u);
}
}
}
}
} else {
const R = v.get("genotypes"), i = H / g.length * w, m = d.length;
for (let t = 0; t < m; t++) {
const c = t / m * F, { name: _, HP: j } = d[t], e = R[_];
if (e) {
M.push(e);
const s = e.includes("|");
if (G === "phased")
if (s) {
const o = e.split("|");
K(o, n, i, c, p, u, j);
} else
n.fillStyle = "black", n.fillRect(i - a, c - a, p + a, u + a);
else {
let o = T[e];
if (o === void 0) {
let l = 0, f = 0, k = 0, S = 0;
const P = e.split(/[/|]/), y = P.length;
for (let h = 0; h < y; h++) {
const r = P[h];
r === B ? l++ : r === "0" ? S++ : r === "." ? f++ : k++;
}
o = L(S, l, k, f, y, !0), T[e] = o;
}
o && N(o, n, i, c, p, u);
}
}
}
}
z.push(M);
});
}), {
mafs: g,
arr: z
};
}
export {
x as makeImageData
};
//# sourceMappingURL=makeImageData-aRwKAGbW.js.map