diff --git a/CLAUDE.md b/CLAUDE.md index c25147b..e5d4a2a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -695,6 +695,16 @@ they can't tell you: `check:splitby-perf`) are stages of `scripts/gate.sh` of their own, and the boundary suite is in `npm test`. `npm run report:coverage` — the unit suites' coverage (CI shows it on the reports job). + **Every view kind's output is pinned** by `test/view-snapshots.test.ts` (in `npm test`, no + database): one gallery example per kind runs through the whole engine against warehouse answers + recorded in `test/snapshots/answers/`, and its compiled SQL and queries, computed result, figure + and results text are compared with `test/snapshots/.{sql,json,svg,txt}`. A diff there is a + change to review, not noise: `UPDATE_SNAPSHOTS=1` accepts output changes, and a changed query + needs `RECORD_SNAPSHOTS=1` with `.env.local` (public warehouse only; the answers hold public + studies' patient-level rows). A new view kind adds its case there. Each case also runs with its + answers delivered in reverse, and must not change: a runner combines what it asked for after + every answer is in, in the view's order (`askEachSite` in `lib/views/shared.ts`), never inside + the callback as each one lands. Secrets come from `.env.local` at runtime; never hardcode them anywhere, including tests. - Lint: `npm run lint` (~2 min, the gate's first stage) — see "Code standards" above for what it holds code to. While iterating, `npx eslint ` is enough. diff --git a/lib/ch.ts b/lib/ch.ts index c64b03a..12b7f00 100644 --- a/lib/ch.ts +++ b/lib/ch.ts @@ -226,10 +226,19 @@ export function directConnections(): ChConn[] { return connections().filter((c) => c.id !== peer?.id); } +/** One statement as the database would receive it: its text, and the tables that ride along with it. */ +export interface ChStatement { conn: ChConn; format: string; query: string; externals: { name: string; structure: string; blob: Blob }[] } +/** + * Answers statements instead of the database, or watches them on their way to it (`send`, which + * takes extra ClickHouse settings for that statement, e.g. "max_threads=1"). Only + * test/view-snapshots.test.ts sets one: it records the warehouse's answers, then replays them. + */ +export type ChTransport = (st: ChStatement, send: (settings?: string) => Promise) => Promise; +let transport: ChTransport | null = null; +export function setChTransport(t: ChTransport | null): void { transport = t; } + async function post(sql: string, conn: ChConn, format: string): Promise { assertNotLoopbackDirect(sql, conn); - if (!conn.url || !conn.user || !conn.password || !conn.db) - throw new Error("ClickHouse instance '" + conn.id + "' is missing configuration (url/password/db)"); const ctx = ctxStore.getStore(); const query = sql + "\nFORMAT " + format; // uploaded custom data and stored id sets ride along only with a statement that names them @@ -237,10 +246,17 @@ async function post(sql: string, conn: ChConn, format: string): Promise const externals = [...externalsFor(query), ...[...customExternalsFor(query, conn.id), ...idSetExternalsFor(query, conn.id)] .map((e) => ({ name: e.name, structure: e.structure, blob: new Blob([e.data]) }))]; + if (transport) return transport({ conn, format, query, externals }, (settings) => postToDatabase(conn, query, externals, ctx, settings)); + return postToDatabase(conn, query, externals, ctx); +} + +async function postToDatabase(conn: ChConn, query: string, externals: ChStatement["externals"], ctx: ChCtx | undefined, settings?: string): Promise { + if (!conn.url || !conn.user || !conn.password || !conn.db) + throw new Error("ClickHouse instance '" + conn.id + "' is missing configuration (url/password/db)"); // Tell ClickHouse to stop a query whose client has gone away. Without it an abandoned // request keeps its share of the database until it finishes, which is most of what an // abandoned request costs. - const url = conn.url.replace(/\/+$/, "") + "/?cancel_http_readonly_queries_on_client_close=1"; + const url = conn.url.replace(/\/+$/, "") + "/?cancel_http_readonly_queries_on_client_close=1" + (settings ? "&" + settings : ""); const send = async (): Promise => { const auth = "Basic " + Buffer.from(conn.user + ":" + conn.password).toString("base64"); let init: RequestInit; diff --git a/lib/views/assays.ts b/lib/views/assays.ts index d38ec0c..d6cbc01 100644 --- a/lib/views/assays.ts +++ b/lib/views/assays.ts @@ -4,7 +4,7 @@ import { assayProfileSql, assayMomentsSql, assayValueCountsSql, assayEntityNames import { chiSquareTest, benjaminiHochberg, welchT, welchAnovaTest, varianceFromMoments } from "../stats.ts"; import { assaysMethod } from "../method.ts"; import type { ViewRun } from "./run.ts"; -import { overLimit, answering, refuse, niceCeil, PROFILE_NAME } from "./shared.ts"; +import { overLimit, answering, refuse, niceCeil, PROFILE_NAME, askEachSite } from "./shared.ts"; const ASSAY_ROWS = 300; /** past this many entities a profile is refused rather than compared: the per-cohort answer @@ -54,35 +54,35 @@ export async function runAssays(view: AssaysView, ctx: ViewRun): Promise(); let missing = 0; const perSite: { cohort: string; study: string; rows: number }[] = []; - await Promise.all([ - ...holders.map(async (st) => { - for (const r of await ok[st].viewMeta("assays:names", (s, d) => assayEntityNamesSql(s, d, pt))) if (!names.has(String(r.entity))) names.set(String(r.entity), String(r.name)); - }), - ...vNames.flatMap((n) => cohorts[n].studies.filter((st) => holders.includes(st)).map(async (st) => { - const def = doc.cohorts[n]; - if (isCat) { - const rows = await ok[st].viewAggregate("assays:values:" + n, def, (c, s, d) => assayValueCountsSql(c, s, d, pt)); - for (const r of rows) { - const v = String(r.value ?? "").trim(), c = Number(r.n); - if (MISSING_VALUES.has(v)) { missing += c; continue; } - const k = n + "\t" + r.entity; - entities.add(String(r.entity)); - const m = counts.get(k) || new Map(); - m.set(v, (m.get(v) || 0) + c); counts.set(k, m); - } - perSite.push({ cohort: n, study: st, rows: rows.length }); - } else { - const rows = await ok[st].viewAggregate("assays:moments:" + n, def, (c, s, d) => assayMomentsSql(c, s, d, pt)); - for (const r of rows) { - const k = n + "\t" + r.entity, cur = mom.get(k) || { n: 0, sx: 0, sxx: 0 }; - cur.n += Number(r.n); cur.sx += Number(r.sx); cur.sxx += Number(r.sxx); mom.set(k, cur); - missing += Number(r.other); - entities.add(String(r.entity)); - } - perSite.push({ cohort: n, study: st, rows: rows.length }); - } - })) + const holding = Object.fromEntries(holders.map((st) => [st, ok[st]])); + const [nameRows, answers] = await Promise.all([ + Promise.all(holders.map((st) => ok[st].viewMeta("assays:names", (s, d) => assayEntityNamesSql(s, d, pt)))), + askEachSite(ctx, holding, (n, _st, r) => isCat + ? r.viewAggregate("assays:values:" + n, doc.cohorts[n], (c, s, d) => assayValueCountsSql(c, s, d, pt)) + : r.viewAggregate("assays:moments:" + n, doc.cohorts[n], (c, s, d) => assayMomentsSql(c, s, d, pt))) ]); + // the first study (in the view's order) to name an entity names it + for (const rows of nameRows) for (const r of rows) if (!names.has(String(r.entity))) names.set(String(r.entity), String(r.name)); + for (const { cohort: n, study: st, answer: rows } of answers) { + if (isCat) { + for (const r of rows) { + const v = String(r.value ?? "").trim(), c = Number(r.n); + if (MISSING_VALUES.has(v)) { missing += c; continue; } + const k = n + "\t" + r.entity; + entities.add(String(r.entity)); + const m = counts.get(k) || new Map(); + m.set(v, (m.get(v) || 0) + c); counts.set(k, m); + } + } else { + for (const r of rows) { + const k = n + "\t" + r.entity, cur = mom.get(k) || { n: 0, sx: 0, sxx: 0 }; + cur.n += Number(r.n); cur.sx += Number(r.sx); cur.sxx += Number(r.sxx); mom.set(k, cur); + missing += Number(r.other); + entities.add(String(r.entity)); + } + } + perSite.push({ cohort: n, study: st, rows: rows.length }); + } if (!entities.size) return refuse("assays", ctx, "none of these cohorts' " + unit + " has a value in “" + pt + "”"); if (entities.size > ASSAY_MAX_ENTITIES) return refuse("assays", ctx, "“" + pt + "” has " + entities.size.toLocaleString("en-US") + " entities with values here; an assays view compares at most " + ASSAY_MAX_ENTITIES.toLocaleString("en-US")); diff --git a/lib/views/diffexpr.ts b/lib/views/diffexpr.ts index 94b2271..67f92b0 100644 --- a/lib/views/diffexpr.ts +++ b/lib/views/diffexpr.ts @@ -4,7 +4,7 @@ import { profileMomentsAllSql, genesetMembersSql } from "../federation-views.ts" import { benjaminiHochberg, varianceFromMoments, welchT, preRankedGsea } from "../stats.ts"; import { diffexprMethod } from "../method.ts"; import type { ViewRun } from "./run.ts"; -import { overLimit, answering, refuse, niceCeil } from "./shared.ts"; +import { overLimit, answering, refuse, niceCeil, askEachSite } from "./shared.ts"; const DE_MIN_N = 3, DE_POINT_CAP = 1500, DE_PERMUTATIONS = 1000; const SET_NAME = /^[A-Z0-9_]{3,120}$/; @@ -51,15 +51,15 @@ export async function runDiffexpr(view: DiffexprView, ctx: ViewRun): Promise(); // cohort|gene - await Promise.all(vNames.flatMap((n) => cohorts[n].studies.filter((st) => ok[st]).map(async (st) => { - const rows = await ok[st].viewAggregate("diffexpr:moments:" + n, doc.cohorts[n], - (c, s, d) => profileMomentsAllSql(c, s, d, profileType, log2)); + const answers = await askEachSite(ctx, ok, (n, _st, r) => r.viewAggregate("diffexpr:moments:" + n, doc.cohorts[n], + (c, s, d) => profileMomentsAllSql(c, s, d, profileType, log2))); + for (const { cohort: n, answer: rows } of answers) { for (const r of rows) { const k = n + "|" + String(r.gene), cur = moments.get(k) || { n: 0, sx: 0, sxx: 0 }; cur.n += Number(r.n); cur.sx += Number(r.sx); cur.sxx += Number(r.sxx); moments.set(k, cur); } - }))); + } const [A, B] = vNames; const genes = [...new Set([...moments.keys()].map((k) => k.slice(k.indexOf("|") + 1)))]; const tested: DiffexprGene[] = []; diff --git a/lib/views/enrichment.ts b/lib/views/enrichment.ts index df3349b..3bfa6f8 100644 --- a/lib/views/enrichment.ts +++ b/lib/views/enrichment.ts @@ -4,7 +4,7 @@ import { enrichAlteredSql, enrichPanelProfiledSql, enrichWesSql, type EnrichAlte import { fisherExact, chiSquareTest, benjaminiHochberg } from "../stats.ts"; import { enrichmentMethod } from "../method.ts"; import type { ViewRun } from "./run.ts"; -import { overLimit, cytobands, answering, refuse, niceCeil } from "./shared.ts"; +import { overLimit, cytobands, answering, refuse, niceCeil, askEachSite } from "./shared.ts"; const ENRICH_ROWS = 300; const ALTERATION_WORD: Record = { @@ -32,19 +32,18 @@ export async function runEnrichment(view: EnrichmentView, ctx: ViewRun): Promise const altered = new Map(), panel = new Map(), wes = new Map(); const genes = new Set(); const perSite: { cohort: string; study: string; genes: number; wes: number }[] = []; - await Promise.all(vNames.flatMap((n) => cohorts[n].studies.filter((st) => ok[st]).map(async (st) => { - const def = doc.cohorts[n]; - const [a, pr, w] = await Promise.all([ - ok[st].viewAggregate("enrichment:altered:" + n, def, (c, s, d) => enrichAlteredSql(c, s, d, alteration, pin, measure === "driver")), - ok[st].viewAggregate("enrichment:panels:" + n, def, (c, s, d) => enrichPanelProfiledSql(c, s, d, alteration)), - ok[st].viewAggregate("enrichment:wes:" + n, def, (c, s, d) => enrichWesSql(c, s, d, alteration)) - ]); + const answers = await askEachSite(ctx, ok, (n, st, r) => Promise.all([ + r.viewAggregate("enrichment:altered:" + n, doc.cohorts[n], (c, s, d) => enrichAlteredSql(c, s, d, alteration, pin, measure === "driver")), + r.viewAggregate("enrichment:panels:" + n, doc.cohorts[n], (c, s, d) => enrichPanelProfiledSql(c, s, d, alteration)), + r.viewAggregate("enrichment:wes:" + n, doc.cohorts[n], (c, s, d) => enrichWesSql(c, s, d, alteration)) + ])); + for (const { cohort: n, study: st, answer: [a, pr, w] } of answers) { for (const r of a) { const k = n + "\t" + r.gene; altered.set(k, (altered.get(k) || 0) + Number(r.altered)); genes.add(String(r.gene)); } for (const r of pr) { const k = n + "\t" + r.gene; panel.set(k, (panel.get(k) || 0) + Number(r.profiled)); } const wn = Number(w[0]?.n || 0); wes.set(n, (wes.get(n) || 0) + wn); perSite.push({ cohort: n, study: st, genes: a.length, wes: wn }); - }))); + } const two = vNames.length === 2; const tested: EnrichmentGene[] = []; let untested = 0; diff --git a/lib/views/shared.ts b/lib/views/shared.ts index 0aba84f..715b4d4 100644 --- a/lib/views/shared.ts +++ b/lib/views/shared.ts @@ -67,3 +67,16 @@ export async function cytobands(ok: Record, genes: string[ export async function studyCatalogs(c: ViewRun, studies: string[]): Promise { return Promise.all(studies.map(async (st) => ({ study: st, catalog: (await c.studyProfiles(st)).catalog || [] }))); } + +/** + * Asks every (cohort, study) the view draws that `resolvers` holds, concurrently, and returns the + * answers in the view's order (its cohorts, then each cohort's studies), never in the order they + * finish. Combine them after this returns: combining inside `ask` as each answer lands makes the + * result depend on which query finished first (test/view-snapshots.test.ts checks for that). + */ +export async function askEachSite(ctx: ViewRun, resolvers: Record, + ask: (cohort: string, study: string, r: R) => Promise): Promise<{ cohort: string; study: string; answer: T }[]> { + const sites = ctx.vNames.flatMap((cohort) => ctx.cohorts[cohort].studies.filter((st) => resolvers[st]).map((study) => ({ cohort, study }))); + const answers = await Promise.all(sites.map((s) => ask(s.cohort, s.study, resolvers[s.study]))); + return sites.map((s, i) => ({ ...s, answer: answers[i] })); +} diff --git a/lib/views/survival.ts b/lib/views/survival.ts index 72e81f8..73e9229 100644 --- a/lib/views/survival.ts +++ b/lib/views/survival.ts @@ -5,6 +5,7 @@ import type { ViewResult, LogRank, LogRankK, SurvivalView } from "../types.ts"; import { expandSurvivalCounts, type SurvivalCount, type EndpointColumns } from "../federation.ts"; import { survivalMethod } from "../method.ts"; import { untimed, type Untimed, type ViewRun, type DocView } from "./run.ts"; +import { askEachSite } from "./shared.ts"; export async function runSurvival(view: DocView, c: ViewRun): Promise { const { doc, cohorts, resolvers, vNames, vStudies, participationFor } = c; @@ -60,10 +61,8 @@ export async function runSurvival(view: DocView, c: ViewRun): Promise>(); // cohort -> study -> triples for (const n of vNames) perSite.set(n, new Map()); - await Promise.all(vNames.flatMap((n) => - cohorts[n].studies.map(async (st) => { - perSite.get(n)!.set(st, await resolvers[st].survivalCounts(doc.cohorts[n], endpoint, anchor, columns)); - }))); + for (const { cohort: n, study: st, answer } of await askEachSite(c, resolvers, (n, _st, r) => r.survivalCounts(doc.cohorts[n], endpoint, anchor, columns))) + perSite.get(n)!.set(st, answer); // An EMPTY COHORT also yields no rows, and must not be reported as a // missing endpoint — that sends the reader (or a model) off to conclude the // study lacks OS when it does not. Separate the two causes before blaming diff --git a/test/snapshots/alterations.json b/test/snapshots/alterations.json new file mode 100644 index 0000000..17a1c46 --- /dev/null +++ b/test/snapshots/alterations.json @@ -0,0 +1,1003 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Prostate": { + "count": 3211, + "text": "CANCER_TYPE in [Prostate Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "alterations", + "cohorts": [ + "Prostate" + ], + "alterations": { + "columns": [ + { + "id": "patient", + "name": "Patient ID", + "numeric": false + }, + { + "id": "source", + "name": "Source", + "numeric": false + }, + { + "id": "samples", + "name": "Samples", + "numeric": true + }, + { + "id": "mutations", + "name": "Mutations", + "numeric": true + }, + { + "id": "cna", + "name": "CNAs", + "numeric": true + }, + { + "id": "sv", + "name": "Structural Variants", + "numeric": true + } + ], + "shown": [ + "patient", + "source", + "samples", + "mutations", + "cna", + "sv" + ], + "defaults": [ + "patient", + "source", + "samples", + "mutations", + "cna", + "sv" + ], + "query": { + "sort": { + "column": "sv", + "desc": true + } + }, + "rows": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0030872", + "sample": "", + "values": [ + "P-0030872", + "this portal (primary)", + 1, + 4, + 0, + 5 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0000631", + "sample": "", + "values": [ + "P-0000631", + "this portal (primary)", + 1, + 3, + 4, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0013729", + "sample": "", + "values": [ + "P-0013729", + "this portal (primary)", + 1, + 0, + 7, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0017262", + "sample": "", + "values": [ + "P-0017262", + "this portal (primary)", + 1, + 2, + 1, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0020078", + "sample": "", + "values": [ + "P-0020078", + "this portal (primary)", + 1, + 5, + 7, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0025988", + "sample": "", + "values": [ + "P-0025988", + "this portal (primary)", + 1, + 5, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0030109", + "sample": "", + "values": [ + "P-0030109", + "this portal (primary)", + 1, + 2, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0037022", + "sample": "", + "values": [ + "P-0037022", + "this portal (primary)", + 1, + 3, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0038349", + "sample": "", + "values": [ + "P-0038349", + "this portal (primary)", + 1, + 3, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0043336", + "sample": "", + "values": [ + "P-0043336", + "this portal (primary)", + 1, + 26, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0046943", + "sample": "", + "values": [ + "P-0046943", + "this portal (primary)", + 1, + 2, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0049524", + "sample": "", + "values": [ + "P-0049524", + "this portal (primary)", + 1, + 2, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0069200", + "sample": "", + "values": [ + "P-0069200", + "this portal (primary)", + 1, + 9, + 0, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0081157", + "sample": "", + "values": [ + "P-0081157", + "this portal (primary)", + 1, + 3, + 4, + 4 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0003511", + "sample": "", + "values": [ + "P-0003511", + "this portal (primary)", + 1, + 3, + 4, + 3 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0004946", + "sample": "", + "values": [ + "P-0004946", + "this portal (primary)", + 2, + 7, + 0, + 3 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0006689", + "sample": "", + "values": [ + "P-0006689", + "this portal (primary)", + 1, + 0, + 0, + 3 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0008960", + "sample": "", + "values": [ + "P-0008960", + "this portal (primary)", + 1, + 0, + 3, + 3 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0012605", + "sample": "", + "values": [ + "P-0012605", + "this portal (primary)", + 1, + 2, + 0, + 3 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0017882", + "sample": "", + "values": [ + "P-0017882", + "this portal (primary)", + 1, + 3, + 9, + 3 + ] + }, + { + "…": "5 more", + "sha256": "5a1562f61b57960e" + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "total": 3211, + "all": 3211 + } + ], + "total": 3211, + "all": 3211, + "patient": { + "study": "msk_chord_2024", + "id": "P-0024249", + "samples": [ + { + "id": "P-0024249-T01-IM6", + "type": "Primary" + }, + { + "id": "P-0024249-T02-IM7", + "type": "Primary" + } + ] + }, + "position": { + "index": 21, + "prev": { + "study": "msk_chord_2024", + "id": "P-0019663" + }, + "next": { + "study": "msk_chord_2024", + "id": "P-0024679" + } + }, + "tables": { + "mutations": { + "columns": [ + { + "id": "samples", + "name": "Samples", + "numeric": false + }, + { + "id": "gene", + "name": "Gene", + "numeric": false + }, + { + "id": "proteinChange", + "name": "Protein Change", + "numeric": false + }, + { + "id": "annotation", + "name": "Annotation (OncoKB)", + "numeric": false + }, + { + "id": "mutationType", + "name": "Mutation Type", + "numeric": false + }, + { + "id": "copy", + "name": "Copy #", + "numeric": false + }, + { + "id": "freq", + "name": "Cohort %", + "numeric": true + }, + { + "id": "vaf", + "name": "Allele Freq", + "numeric": true + }, + { + "id": "altCount", + "name": "Variant Reads", + "numeric": true + }, + { + "id": "refCount", + "name": "Ref Reads", + "numeric": true + }, + { + "id": "variantType", + "name": "Variant Type", + "numeric": false + }, + { + "id": "chr", + "name": "Chromosome", + "numeric": false + }, + { + "id": "start", + "name": "Start Pos", + "numeric": true + }, + { + "id": "end", + "name": "End Pos", + "numeric": true + }, + { + "id": "ref", + "name": "Ref", + "numeric": false + }, + { + "id": "var", + "name": "Var", + "numeric": false + }, + { + "id": "status", + "name": "MS", + "numeric": false + } + ], + "shown": [ + "samples", + "gene", + "proteinChange", + "annotation", + "mutationType", + "copy", + "freq", + "vaf" + ], + "defaults": [ + "samples", + "gene", + "proteinChange", + "annotation", + "mutationType", + "copy", + "freq", + "vaf" + ], + "query": { + "filters": { + "annotation": { + "op": "contains", + "value": "Oncogenic" + } + } + }, + "rows": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T02-IM7", + "values": [ + "P-0024249-T02-IM7", + "KRAS", + "G12V", + "Oncogenic · Level 1", + "Missense_Mutation", + "", + 28.5, + 0.076, + 42, + 512, + "SNP", + "12", + 25398284, + 25398284, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "PTEN", + "G127V", + "Likely Oncogenic · Level 1", + "Missense_Mutation", + "", + 4.8, + 0.619, + 262, + 161, + "SNP", + "10", + 89692896, + 89692896, + "G", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "TP53", + "P151R", + "Likely Oncogenic", + "Missense_Mutation", + "", + 52.4, + 0.761, + 761, + 239, + "SNP", + "17", + 7578478, + 7578478, + "G", + "C", + "SOMATIC" + ] + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "total": 3, + "all": 7 + } + ], + "total": 3, + "all": 7 + }, + "cna": { + "columns": [ + { + "id": "samples", + "name": "Samples", + "numeric": false + }, + { + "id": "gene", + "name": "Gene", + "numeric": false + }, + { + "id": "cna", + "name": "CNA", + "numeric": false + }, + { + "id": "annotation", + "name": "Annotation (OncoKB)", + "numeric": false + }, + { + "id": "cytoband", + "name": "Cytoband", + "numeric": false + }, + { + "id": "freq", + "name": "Cohort %", + "numeric": true + } + ], + "shown": [ + "samples", + "gene", + "cna", + "annotation", + "cytoband", + "freq" + ], + "defaults": [ + "samples", + "gene", + "cna", + "annotation", + "cytoband", + "freq" + ], + "query": {}, + "rows": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "MAP3K1", + "HOMDEL", + "Likely Oncogenic", + "5q11.2", + 0.3 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "RAD51B", + "HOMDEL", + "Likely Oncogenic · Level 1", + "14q24.1", + 0.1 + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "PLK2", + "HOMDEL", + "Unknown", + "5q11.2", + 0.2 + ] + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "total": 3, + "all": 3 + } + ], + "total": 3, + "all": 3 + }, + "sv": { + "columns": [ + { + "id": "samples", + "name": "Samples", + "numeric": false + }, + { + "id": "gene1", + "name": "Gene 1", + "numeric": false + }, + { + "id": "gene2", + "name": "Gene 2", + "numeric": false + }, + { + "id": "class", + "name": "Variant Class", + "numeric": false + }, + { + "id": "eventInfo", + "name": "Event Info", + "numeric": false + }, + { + "id": "breakpointType", + "name": "Breakpoint Type", + "numeric": false + }, + { + "id": "connectionType", + "name": "Connection Type", + "numeric": false + }, + { + "id": "frame", + "name": "Effect on Frame", + "numeric": false + }, + { + "id": "site1", + "name": "Site 1 Description", + "numeric": false + }, + { + "id": "site2", + "name": "Site 2 Description", + "numeric": false + }, + { + "id": "pos1", + "name": "Site 1 Position", + "numeric": false + }, + { + "id": "pos2", + "name": "Site 2 Position", + "numeric": false + }, + { + "id": "length", + "name": "Length", + "numeric": true + }, + { + "id": "tumorVariantCount", + "name": "Tumor Variant Count", + "numeric": true + }, + { + "id": "tumorReadCount", + "name": "Tumor Read Count", + "numeric": true + }, + { + "id": "dnaSupport", + "name": "DNA Support", + "numeric": false + }, + { + "id": "rnaSupport", + "name": "RNA Support", + "numeric": false + }, + { + "id": "status", + "name": "Status", + "numeric": false + }, + { + "id": "svAnnotation", + "name": "Study Annotation", + "numeric": false + }, + { + "id": "comments", + "name": "Comments", + "numeric": false + } + ], + "shown": [ + "samples", + "gene1", + "gene2", + "class", + "eventInfo", + "breakpointType", + "connectionType" + ], + "defaults": [ + "samples", + "gene1", + "gene2", + "class", + "eventInfo", + "breakpointType", + "connectionType" + ], + "query": {}, + "rows": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "IRS2", + "CHMP1A", + "TRANSLOCATION", + "Protein Fusion: mid-exon {IRS2:CHMP1A}", + "IMPPRECISE", + "3to5", + "NA", + "Intron of CHMP1A(-):1Kb before exon 2", + "Exon 1 of IRS2(-)", + "16:89721445", + "13:110437384", + 0, + 10, + 0, + "NA", + "NA", + "SOMATIC", + "IRS2 (NM_003749) - CHMP1A (NM_002768) rearrangement: t(13;16)(q34;q24.3)(chr13:g.110437384::chr16:g.89721445)", + "NA" + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "TCF7L2", + "", + "DELETION", + "TCF7L2-intragenic", + "PRECISE", + "3to5", + "NA", + "Intron of TCF7L2(+):23bp after exon 12", + "IGR: 296Kb before HABP2(+)", + "10:114917851", + "10:115014274", + 96423, + 23, + 4714, + "NA", + "NA", + "SOMATIC", + "TCF7L2 (NM_001146274) rearrangement: c.1318+23_chr10:g.115014274del", + "NA" + ] + }, + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "patient": "P-0024249", + "sample": "P-0024249-T01-IM6", + "values": [ + "P-0024249-T01-IM6", + "TMPRSS2", + "ERG", + "DELETION", + "Protein Fusion: out of frame {TMPRSS2:ERG}", + "IMPPRECISE", + "3to5", + "NA", + "Intron of ERG(-):57Kb after exon 3", + "Intron of TMPRSS2(-):608bp before exon 2", + "21:39890681", + "21:42870724", + 2980043, + 105, + 41084, + "NA", + "NA", + "SOMATIC", + "TMPRSS2 (NM_001135099) - ERG (NM_004449) fusion ( TMPRSS2 exon 1 fused to ERG exons 4 -11): c.56-608:TMPRSS2_c.39+56905:ERGdel", + "NA" + ] + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Prostate", + "study": "msk_chord_2024", + "total": 3, + "all": 3 + } + ], + "total": 3, + "all": 3 + } + }, + "oncokbPin": "v7.5" + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "P-0024249 — Mutations: 3 of 7 rows (rows Annotation (OncoKB) contains “Oncogenic”); Copy Number Alterations: 3 rows; Structural Variants: 3 rows. Each table lists a variant, a gene's call or an event once however many of the patient's samples carry it (Samples names them); allele frequency and read counts are the highest among those samples. Copy number is the deep calls only (AMP, HOMDEL), as the portal's patient view lists them; Copy # on a mutation is the gene's deep calls anywhere in the patient. Cohort % is the share of the study's samples profiled for the gene by their panel with a mutation in it, or with the same copy-number call. Annotation is OncoKB v7.5 (oncogenicity and its highest sensitivity level); structural variants carry the study's own annotation, not OncoKB's. The patient list: 3,211 patients. Sorted by Structural Variants (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count the patients per cohort and study", + "detail": "The alterations:counts query above: every patient of each cohort, with their sample count and how many rows each of the three tables lists for them (a mutation, a gene's deep copy-number call, a structural variant — each counted once however many samples carry it).", + "params": [ + [ + "Prostate · msk_chord_2024", + "3,211" + ] + ] + }, + { + "kind": "fetch", + "title": "Sort them together and take one page", + "detail": "The alterations:rows query above: the patients of every cohort and study combined in one query, sorted by Structural Variants descending with missing values last, then patient id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset." + }, + { + "kind": "fetch", + "title": "Read P-0024249's three tables", + "detail": "The alterations:mutations, alterations:cna and alterations:sv queries above, each paged, searched, filtered and sorted in the database like any table view. Mutations: every called mutation of the patient's samples (uncalled calls left out), one row per variant with the samples carrying it, the highest allele frequency among them (variant / (variant + reference) reads) with that sample's reads, and the gene's deep copy-number calls in the patient (Copy #). Copy-number alterations: the deep calls (AMP, HOMDEL), one row per gene and call. Structural variants: one row per event (both genes and breakpoints, class, event info), the highest read counts among its samples. Cohort % is the share of the study's samples profiled for the gene (by their gene panel) with any mutation in it, or with the same copy-number call; the annotation is the OncoKB v7.5 call for the protein change, or for AMPLIFICATION / DELETION.", + "params": [ + [ + "Mutations", + "3 of 7 rows (kept: rows Annotation (OncoKB) contains “Oncogenic”)" + ], + [ + "Copy Number Alterations", + "3 rows" + ], + [ + "Structural Variants", + "3 rows" + ] + ] + } + ], + "implementation": { + "functions": [ + "runAlterations", + "alterationPatientRowSource", + "patientMutationsSource", + "patientCnaSource", + "patientSvSource", + "pageSql", + "countsSql", + "rankSql" + ], + "file": "lib/views/alterations.ts, lib/patient-alterations.ts, lib/table-query.ts", + "commit": null + }, + "verification": "A listing: no statistic is computed, so there is no script — the queries are the numbers." + } + } + ] +} diff --git a/test/snapshots/alterations.sql b/test/snapshots/alterations.sql new file mode 100644 index 0000000..9549ade --- /dev/null +++ b/test/snapshots/alterations.sql @@ -0,0 +1,382 @@ +-- cohort Prostate +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) + +-- view 0 alterations: alterations:cna:counts · msk_chord_2024 +WITH c AS ( + SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, hugo_gene_symbol AS gene, cna_alteration AS alt, cna_cytoband AS cytoband + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0024249' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 +), +g AS (SELECT gene, alt, any(cytoband) AS cytoband, arrayStringConcat(arraySort(x -> if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid))) AS so FROM c GROUP BY gene, alt), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'CNA' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +fa AS (SELECT hugo_gene_symbol AS gene, cna_alteration AS alt, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alt), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'COPY_NUMBER_ALTERATION' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, if(g.alt > 0, 'AMP', 'HOMDEL') AS cna, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.cytoband AS cytoband, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = if(g.alt > 0, 'AMPLIFICATION', 'DELETION') + LEFT JOIN fa ON fa.gene = g.gene AND fa.alt = g.alt LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 alterations: alterations:cna:rows · msk_chord_2024 +WITH c AS ( + SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, hugo_gene_symbol AS gene, cna_alteration AS alt, cna_cytoband AS cytoband + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0024249' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 +), +g AS (SELECT gene, alt, any(cytoband) AS cytoband, arrayStringConcat(arraySort(x -> if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid))) AS so FROM c GROUP BY gene, alt), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'CNA' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +fa AS (SELECT hugo_gene_symbol AS gene, cna_alteration AS alt, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alt), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'COPY_NUMBER_ALTERATION' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, if(g.alt > 0, 'AMP', 'HOMDEL') AS cna, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.cytoband AS cytoband, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = if(g.alt > 0, 'AMPLIFICATION', 'DELETION') + LEFT JOIN fa ON fa.gene = g.gene AND fa.alt = g.alt LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT *, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY gdrv DESC, gene, so, gene, cna +LIMIT 25 OFFSET 0 + +-- view 0 alterations: alterations:counts · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 alterations: alterations:mutations:counts · msk_chord_2024 +WITH m AS ( + SELECT sampleId AS sid, `GENE.hugoGeneSymbol` AS gene, proteinChange, mutationType, variantType, chr, startPosition AS start, endPosition AS end, + referenceAllele AS ref, tumorSeqAllele AS var, tumorAltCount AS ac, tumorRefCount AS rc, mutationStatus AS ms, proteinPosStart AS codon, + if(tumorAltCount + tumorRefCount > 0, tumorAltCount / (tumorAltCount + tumorRefCount), NULL) AS f + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND patientId = 'P-0024249' AND molecularProfileId NOT LIKE '%uncalled%' +), +g AS ( + SELECT gene, proteinChange, mutationType, variantType, chr, start, end, ref, var, any(ms) AS status, min(codon) AS pos, arrayStringConcat(arraySort(x -> if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid))) AS so, + max(f) AS vaf, argMax(ac, ifNull(f, -1)) AS altCount, argMax(rc, ifNull(f, -1)) AS refCount + FROM m GROUP BY gene, proteinChange, mutationType, variantType, chr, start, end, ref, var +), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'MUTATION' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +cn AS (SELECT hugo_gene_symbol AS gene, arrayStringConcat(arraySort(groupUniqArray(if(cna_alteration > 0, 'AMP', 'HOMDEL'))), ', ') AS copy + FROM snapshot_db.genomic_event_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0024249' + AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fa AS (SELECT hugo_gene_symbol AS gene, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'mutation' AND genetic_profile_stable_id NOT LIKE '%uncalled%' + AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, g.proteinChange AS proteinChange, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.mutationType AS mutationType, ifNull(cn.copy, '') AS copy, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq, + g.vaf AS vaf, g.altCount AS altCount, g.refCount AS refCount, g.variantType AS variantType, g.chr AS chr, g.start AS start, g.end AS end, + g.ref AS ref, g.var AS var, g.status AS status, g.pos AS pos + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = g.proteinChange + LEFT JOIN cn ON cn.gene = g.gene LEFT JOIN fa ON fa.gene = g.gene LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT cohort, study, countIf((positionCaseInsensitiveUTF8(if(oncogenicity = '', '', concat(oncogenicity, if(level = '', '', concat(' · ', replaceOne(level, 'LEVEL_', 'Level '))))), 'Oncogenic') > 0)) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 alterations: alterations:mutations:rows · msk_chord_2024 +WITH m AS ( + SELECT sampleId AS sid, `GENE.hugoGeneSymbol` AS gene, proteinChange, mutationType, variantType, chr, startPosition AS start, endPosition AS end, + referenceAllele AS ref, tumorSeqAllele AS var, tumorAltCount AS ac, tumorRefCount AS rc, mutationStatus AS ms, proteinPosStart AS codon, + if(tumorAltCount + tumorRefCount > 0, tumorAltCount / (tumorAltCount + tumorRefCount), NULL) AS f + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND patientId = 'P-0024249' AND molecularProfileId NOT LIKE '%uncalled%' +), +g AS ( + SELECT gene, proteinChange, mutationType, variantType, chr, start, end, ref, var, any(ms) AS status, min(codon) AS pos, arrayStringConcat(arraySort(x -> if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid))) AS so, + max(f) AS vaf, argMax(ac, ifNull(f, -1)) AS altCount, argMax(rc, ifNull(f, -1)) AS refCount + FROM m GROUP BY gene, proteinChange, mutationType, variantType, chr, start, end, ref, var +), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'MUTATION' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +cn AS (SELECT hugo_gene_symbol AS gene, arrayStringConcat(arraySort(groupUniqArray(if(cna_alteration > 0, 'AMP', 'HOMDEL'))), ', ') AS copy + FROM snapshot_db.genomic_event_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0024249' + AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fa AS (SELECT hugo_gene_symbol AS gene, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'mutation' AND genetic_profile_stable_id NOT LIKE '%uncalled%' + AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, g.proteinChange AS proteinChange, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.mutationType AS mutationType, ifNull(cn.copy, '') AS copy, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq, + g.vaf AS vaf, g.altCount AS altCount, g.refCount AS refCount, g.variantType AS variantType, g.chr AS chr, g.start AS start, g.end AS end, + g.ref AS ref, g.var AS var, g.status AS status, g.pos AS pos + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = g.proteinChange + LEFT JOIN cn ON cn.gene = g.gene LEFT JOIN fa ON fa.gene = g.gene LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT *, count() OVER () AS total FROM rows +WHERE (positionCaseInsensitiveUTF8(if(oncogenicity = '', '', concat(oncogenicity, if(level = '', '', concat(' · ', replaceOne(level, 'LEVEL_', 'Level '))))), 'Oncogenic') > 0) +ORDER BY gdrv DESC, gene, so, pos ASC NULLS LAST, gene, chr, start, end, ref, var, proteinChange, mutationType +LIMIT 25 OFFSET 0 + +-- view 0 alterations: alterations:rank · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT idx FROM (SELECT study, patient, row_number() OVER (ORDER BY CAST(sv AS Nullable(Float64)) DESC NULLS LAST, patient, ord) - 1 AS idx FROM rows +WHERE 1) +WHERE study = 'msk_chord_2024' AND patient = 'P-0024249' LIMIT 1 + +-- view 0 alterations: alterations:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT cohort, study, patient, sample, source, samples, mutations, cna, sv, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY CAST(sv AS Nullable(Float64)) DESC NULLS LAST, patient, ord +LIMIT 25 OFFSET 0 + +-- view 0 alterations: alterations:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT cohort, study, patient, sample, source, samples, mutations, cna, sv, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY CAST(sv AS Nullable(Float64)) DESC NULLS LAST, patient, ord +LIMIT 3 OFFSET 20 + +-- view 0 alterations: alterations:samples:counts · msk_chord_2024 +WITH s AS (SELECT replaceOne(s.sample_unique_id, 'msk_chord_2024_', '') AS id, any(c.attribute_value) AS type +FROM snapshot_db.sample_derived s +LEFT JOIN snapshot_db.clinical_data_derived c ON c.sample_unique_id = s.sample_unique_id AND c.type = 'sample' + AND c.cancer_study_identifier = 'msk_chord_2024' AND c.attribute_name = 'SAMPLE_TYPE' +WHERE s.cancer_study_identifier = 'msk_chord_2024' AND s.patient_unique_id = 'msk_chord_2024_P-0024249' +GROUP BY id ORDER BY id), +rows AS (SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, s.id AS sid, ifNull(s.type, '') AS type FROM s) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 alterations: alterations:samples:rows · msk_chord_2024 +WITH s AS (SELECT replaceOne(s.sample_unique_id, 'msk_chord_2024_', '') AS id, any(c.attribute_value) AS type +FROM snapshot_db.sample_derived s +LEFT JOIN snapshot_db.clinical_data_derived c ON c.sample_unique_id = s.sample_unique_id AND c.type = 'sample' + AND c.cancer_study_identifier = 'msk_chord_2024' AND c.attribute_name = 'SAMPLE_TYPE' +WHERE s.cancer_study_identifier = 'msk_chord_2024' AND s.patient_unique_id = 'msk_chord_2024_P-0024249' +GROUP BY id ORDER BY id), +rows AS (SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, s.id AS sid, ifNull(s.type, '') AS type FROM s) +SELECT *, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY sid, sid +LIMIT 1000 OFFSET 0 + +-- view 0 alterations: alterations:sv:counts · msk_chord_2024 +WITH s AS ( + SELECT smp.stable_id AS sid, ifNull(g1.hugo_gene_symbol, '') AS gene1, ifNull(g2.hugo_gene_symbol, '') AS gene2, + ifNull(sv.class, '') AS class, ifNull(sv.event_info, '') AS eventInfo, sv.breakpoint_type AS breakpointType, sv.connection_type AS connectionType, + sv.site2_effect_on_frame AS frame, sv.site1_description AS site1, sv.site2_description AS site2, + if(sv.site1_position IS NULL, '', concat(ifNull(sv.site1_chromosome, ''), ':', toString(sv.site1_position))) AS pos1, + if(sv.site2_position IS NULL, '', concat(ifNull(sv.site2_chromosome, ''), ':', toString(sv.site2_position))) AS pos2, + sv.length AS length, sv.tumor_variant_count AS tumorVariantCount, sv.tumor_read_count AS tumorReadCount, + sv.dna_support AS dnaSupport, sv.rna_support AS rnaSupport, sv.sv_status AS status, sv.annotation AS svAnnotation, sv.comments AS comments + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample smp ON smp.internal_id = sv.sample_id + LEFT JOIN snapshot_db.gene g1 ON g1.entrez_gene_id = sv.site1_entrez_gene_id + LEFT JOIN snapshot_db.gene g2 ON g2.entrez_gene_id = sv.site2_entrez_gene_id + WHERE sv.sample_id IN (SELECT s.internal_id FROM snapshot_db.sample s JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id = 'P-0024249') +), +g AS ( + SELECT gene1, gene2, class, eventInfo, pos1, pos2, arrayStringConcat(arraySort(x -> if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid))) AS so, + any(breakpointType) AS breakpointType, any(connectionType) AS connectionType, any(frame) AS frame, any(site1) AS site1, any(site2) AS site2, + any(length) AS length, max(tumorVariantCount) AS tumorVariantCount, max(tumorReadCount) AS tumorReadCount, + any(dnaSupport) AS dnaSupport, any(rnaSupport) AS rnaSupport, any(status) AS status, any(svAnnotation) AS svAnnotation, any(comments) AS comments + FROM s GROUP BY gene1, gene2, class, eventInfo, pos1, pos2 +), +rows AS (SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, splitByString(', ', g.samples)[1] AS sid, g.* FROM g) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 alterations: alterations:sv:rows · msk_chord_2024 +WITH s AS ( + SELECT smp.stable_id AS sid, ifNull(g1.hugo_gene_symbol, '') AS gene1, ifNull(g2.hugo_gene_symbol, '') AS gene2, + ifNull(sv.class, '') AS class, ifNull(sv.event_info, '') AS eventInfo, sv.breakpoint_type AS breakpointType, sv.connection_type AS connectionType, + sv.site2_effect_on_frame AS frame, sv.site1_description AS site1, sv.site2_description AS site2, + if(sv.site1_position IS NULL, '', concat(ifNull(sv.site1_chromosome, ''), ':', toString(sv.site1_position))) AS pos1, + if(sv.site2_position IS NULL, '', concat(ifNull(sv.site2_chromosome, ''), ':', toString(sv.site2_position))) AS pos2, + sv.length AS length, sv.tumor_variant_count AS tumorVariantCount, sv.tumor_read_count AS tumorReadCount, + sv.dna_support AS dnaSupport, sv.rna_support AS rnaSupport, sv.sv_status AS status, sv.annotation AS svAnnotation, sv.comments AS comments + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample smp ON smp.internal_id = sv.sample_id + LEFT JOIN snapshot_db.gene g1 ON g1.entrez_gene_id = sv.site1_entrez_gene_id + LEFT JOIN snapshot_db.gene g2 ON g2.entrez_gene_id = sv.site2_entrez_gene_id + WHERE sv.sample_id IN (SELECT s.internal_id FROM snapshot_db.sample s JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id = 'P-0024249') +), +g AS ( + SELECT gene1, gene2, class, eventInfo, pos1, pos2, arrayStringConcat(arraySort(x -> if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid) = 0, 1000000, indexOf(['P-0024249-T01-IM6', 'P-0024249-T02-IM7'], sid))) AS so, + any(breakpointType) AS breakpointType, any(connectionType) AS connectionType, any(frame) AS frame, any(site1) AS site1, any(site2) AS site2, + any(length) AS length, max(tumorVariantCount) AS tumorVariantCount, max(tumorReadCount) AS tumorReadCount, + any(dnaSupport) AS dnaSupport, any(rnaSupport) AS rnaSupport, any(status) AS status, any(svAnnotation) AS svAnnotation, any(comments) AS comments + FROM s GROUP BY gene1, gene2, class, eventInfo, pos1, pos2 +), +rows AS (SELECT 'Prostate' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0024249' AS patient, splitByString(', ', g.samples)[1] AS sid, g.* FROM g) +SELECT *, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY gene1, so, gene2, gene1, gene2, pos1, pos2, class, eventInfo +LIMIT 25 OFFSET 0 diff --git a/test/snapshots/alterations.svg b/test/snapshots/alterations.svg new file mode 100644 index 0000000..b6a3852 --- /dev/null +++ b/test/snapshots/alterations.svg @@ -0,0 +1,2 @@ + +(no figure) diff --git a/test/snapshots/alterations.txt b/test/snapshots/alterations.txt new file mode 100644 index 0000000..5c04e0a --- /dev/null +++ b/test/snapshots/alterations.txt @@ -0,0 +1,59 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Prostate: 3,211 patients — CANCER_TYPE in [Prostate Cancer] (any sample) + +Patient alterations — patients to choose from: 3,211; the first 25, tab-separated (the web app's view pages and downloads every row, with every column): + cohort patient source samples mutations cna sv + Prostate P-0030872 this portal (primary) 1 4 0 5 + Prostate P-0000631 this portal (primary) 1 3 4 4 + Prostate P-0013729 this portal (primary) 1 0 7 4 + Prostate P-0017262 this portal (primary) 1 2 1 4 + Prostate P-0020078 this portal (primary) 1 5 7 4 + Prostate P-0025988 this portal (primary) 1 5 0 4 + Prostate P-0030109 this portal (primary) 1 2 0 4 + Prostate P-0037022 this portal (primary) 1 3 0 4 + Prostate P-0038349 this portal (primary) 1 3 0 4 + Prostate P-0043336 this portal (primary) 1 26 0 4 + Prostate P-0046943 this portal (primary) 1 2 0 4 + Prostate P-0049524 this portal (primary) 1 2 0 4 + Prostate P-0069200 this portal (primary) 1 9 0 4 + Prostate P-0081157 this portal (primary) 1 3 4 4 + Prostate P-0003511 this portal (primary) 1 3 4 3 + Prostate P-0004946 this portal (primary) 2 7 0 3 + Prostate P-0006689 this portal (primary) 1 0 0 3 + Prostate P-0008960 this portal (primary) 1 0 3 3 + Prostate P-0012605 this portal (primary) 1 2 0 3 + Prostate P-0017882 this portal (primary) 1 3 9 3 + Prostate P-0019663 this portal (primary) 1 0 0 3 + Prostate P-0024249 this portal (primary) 2 7 3 3 + Prostate P-0024679 this portal (primary) 1 1 0 3 + Prostate P-0025139 this portal (primary) 1 3 4 3 + Prostate P-0025823 this portal (primary) 1 2 17 3 + … 3,186 more rows +P-0024249 (msk_chord_2024); samples: P-0024249-T01-IM6 (Primary), P-0024249-T02-IM7 (Primary) +Mutations: 3 of 7 rows kept by the query; the first 3, tab-separated (the web app's view pages and downloads every row, with every column): + cohort samples gene proteinChange annotation mutationType copy freq vaf + Prostate P-0024249-T02-IM7 KRAS G12V Oncogenic · Level 1 Missense_Mutation 28.5 0.076 + Prostate P-0024249-T01-IM6 PTEN G127V Likely Oncogenic · Level 1 Missense_Mutation 4.8 0.619 + Prostate P-0024249-T01-IM6 TP53 P151R Likely Oncogenic Missense_Mutation 52.4 0.761 +Copy Number Alterations: 3 rows; the first 3, tab-separated (the web app's view pages and downloads every row, with every column): + cohort samples gene cna annotation cytoband freq + Prostate P-0024249-T01-IM6 MAP3K1 HOMDEL Likely Oncogenic 5q11.2 0.3 + Prostate P-0024249-T01-IM6 RAD51B HOMDEL Likely Oncogenic · Level 1 14q24.1 0.1 + Prostate P-0024249-T01-IM6 PLK2 HOMDEL Unknown 5q11.2 0.2 +Structural Variants: 3 rows; the first 3, tab-separated (the web app's view pages and downloads every row, with every column): + cohort samples gene1 gene2 class eventInfo breakpointType connectionType + Prostate P-0024249-T01-IM6 IRS2 CHMP1A TRANSLOCATION Protein Fusion: mid-exon {IRS2:CHMP1A} IMPPRECISE 3to5 + Prostate P-0024249-T01-IM6 TCF7L2 DELETION TCF7L2-intragenic PRECISE 3to5 + Prostate P-0024249-T01-IM6 TMPRSS2 ERG DELETION Protein Fusion: out of frame {TMPRSS2:ERG} IMPPRECISE 3to5 + CAVEAT (tell the user): P-0024249 — Mutations: 3 of 7 rows (rows Annotation (OncoKB) contains “Oncogenic”); Copy Number Alterations: 3 rows; Structural Variants: 3 rows. Each table lists a variant, a gene's call or an event once however many of the patient's samples carry it (Samples names them); allele frequency and read counts are the highest among those samples. Copy number is the deep calls only (AMP, HOMDEL), as the portal's patient view lists them; Copy # on a mutation is the gene's deep calls anywhere in the patient. Cohort % is the share of the study's samples profiled for the gene by their panel with a mutation in it, or with the same copy-number call. Annotation is OncoKB v7.5 (oncogenicity and its highest sensitivity level); structural variants carry the study's own annotation, not OncoKB's. The patient list: 3,211 patients. Sorted by Structural Variants (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. + METHOD: + - Count the patients per cohort and study: The alterations:counts query above: every patient of each cohort, with their sample count and how many rows each of the three tables lists for them (a mutation, a gene's deep copy-number call, a structural variant — each counted once however many samples carry it). + Prostate · msk_chord_2024: 3,211 + - Sort them together and take one page: The alterations:rows query above: the patients of every cohort and study combined in one query, sorted by Structural Variants descending with missing values last, then patient id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset. + - Read P-0024249's three tables: The alterations:mutations, alterations:cna and alterations:sv queries above, each paged, searched, filtered and sorted in the database like any table view. Mutations: every called mutation of the patient's samples (uncalled calls left out), one row per variant with the samples carrying it, the highest allele frequency among them (variant / (variant + reference) reads) with that sample's reads, and the gene's deep copy-number calls in the patient (Copy #). Copy-number alterations: the deep calls (AMP, HOMDEL), one row per gene and call. Structural variants: one row per event (both genes and breakpoints, class, event info), the highest read counts among its samples. Cohort % is the share of the study's samples profiled for the gene (by their gene panel) with any mutation in it, or with the same copy-number call; the annotation is the OncoKB v7.5 call for the protein change, or for AMPLIFICATION / DELETION. + Mutations: 3 of 7 rows (kept: rows Annotation (OncoKB) contains “Oncogenic”) + Copy Number Alterations: 3 rows + Structural Variants: 3 rows + A listing: no statistic is computed, so there is no script — the queries are the numbers. diff --git a/test/snapshots/answers/alterations.json.gz b/test/snapshots/answers/alterations.json.gz new file mode 100644 index 0000000..0d88d3e Binary files /dev/null and b/test/snapshots/answers/alterations.json.gz differ diff --git a/test/snapshots/answers/assays.json.gz b/test/snapshots/answers/assays.json.gz new file mode 100644 index 0000000..549c03b Binary files /dev/null and b/test/snapshots/answers/assays.json.gz differ diff --git a/test/snapshots/answers/attrition.json.gz b/test/snapshots/answers/attrition.json.gz new file mode 100644 index 0000000..f2b96f5 Binary files /dev/null and b/test/snapshots/answers/attrition.json.gz differ diff --git a/test/snapshots/answers/cancertypes.json.gz b/test/snapshots/answers/cancertypes.json.gz new file mode 100644 index 0000000..ccdd6c5 Binary files /dev/null and b/test/snapshots/answers/cancertypes.json.gz differ diff --git a/test/snapshots/answers/clinical.json.gz b/test/snapshots/answers/clinical.json.gz new file mode 100644 index 0000000..9cfb148 Binary files /dev/null and b/test/snapshots/answers/clinical.json.gz differ diff --git a/test/snapshots/answers/clonality.json.gz b/test/snapshots/answers/clonality.json.gz new file mode 100644 index 0000000..f90751d Binary files /dev/null and b/test/snapshots/answers/clonality.json.gz differ diff --git a/test/snapshots/answers/coexpression.json.gz b/test/snapshots/answers/coexpression.json.gz new file mode 100644 index 0000000..7dd1430 Binary files /dev/null and b/test/snapshots/answers/coexpression.json.gz differ diff --git a/test/snapshots/answers/compare.json.gz b/test/snapshots/answers/compare.json.gz new file mode 100644 index 0000000..b0aa258 Binary files /dev/null and b/test/snapshots/answers/compare.json.gz differ diff --git a/test/snapshots/answers/composition.json.gz b/test/snapshots/answers/composition.json.gz new file mode 100644 index 0000000..eef55c2 Binary files /dev/null and b/test/snapshots/answers/composition.json.gz differ diff --git a/test/snapshots/answers/cooccurrence.json.gz b/test/snapshots/answers/cooccurrence.json.gz new file mode 100644 index 0000000..e2cf941 Binary files /dev/null and b/test/snapshots/answers/cooccurrence.json.gz differ diff --git a/test/snapshots/answers/correlates.json.gz b/test/snapshots/answers/correlates.json.gz new file mode 100644 index 0000000..4a3800a Binary files /dev/null and b/test/snapshots/answers/correlates.json.gz differ diff --git a/test/snapshots/answers/course.json.gz b/test/snapshots/answers/course.json.gz new file mode 100644 index 0000000..c35c9dc Binary files /dev/null and b/test/snapshots/answers/course.json.gz differ diff --git a/test/snapshots/answers/cox.json.gz b/test/snapshots/answers/cox.json.gz new file mode 100644 index 0000000..43b1d00 Binary files /dev/null and b/test/snapshots/answers/cox.json.gz differ diff --git a/test/snapshots/answers/diffexpr.json.gz b/test/snapshots/answers/diffexpr.json.gz new file mode 100644 index 0000000..8f09079 Binary files /dev/null and b/test/snapshots/answers/diffexpr.json.gz differ diff --git a/test/snapshots/answers/enrichment.json.gz b/test/snapshots/answers/enrichment.json.gz new file mode 100644 index 0000000..e42ce34 Binary files /dev/null and b/test/snapshots/answers/enrichment.json.gz differ diff --git a/test/snapshots/answers/genome.json.gz b/test/snapshots/answers/genome.json.gz new file mode 100644 index 0000000..706d96a Binary files /dev/null and b/test/snapshots/answers/genome.json.gz differ diff --git a/test/snapshots/answers/hotspots.json.gz b/test/snapshots/answers/hotspots.json.gz new file mode 100644 index 0000000..ba6f16a Binary files /dev/null and b/test/snapshots/answers/hotspots.json.gz differ diff --git a/test/snapshots/answers/incidence.json.gz b/test/snapshots/answers/incidence.json.gz new file mode 100644 index 0000000..5f6fb6b Binary files /dev/null and b/test/snapshots/answers/incidence.json.gz differ diff --git a/test/snapshots/answers/labs.json.gz b/test/snapshots/answers/labs.json.gz new file mode 100644 index 0000000..a4a033f Binary files /dev/null and b/test/snapshots/answers/labs.json.gz differ diff --git a/test/snapshots/answers/logistic.json.gz b/test/snapshots/answers/logistic.json.gz new file mode 100644 index 0000000..514b145 Binary files /dev/null and b/test/snapshots/answers/logistic.json.gz differ diff --git a/test/snapshots/answers/mutations.json.gz b/test/snapshots/answers/mutations.json.gz new file mode 100644 index 0000000..5c42db7 Binary files /dev/null and b/test/snapshots/answers/mutations.json.gz differ diff --git a/test/snapshots/answers/overlap.json.gz b/test/snapshots/answers/overlap.json.gz new file mode 100644 index 0000000..dae34c5 Binary files /dev/null and b/test/snapshots/answers/overlap.json.gz differ diff --git a/test/snapshots/answers/paired.json.gz b/test/snapshots/answers/paired.json.gz new file mode 100644 index 0000000..4d1def6 Binary files /dev/null and b/test/snapshots/answers/paired.json.gz differ diff --git a/test/snapshots/answers/pathways.json.gz b/test/snapshots/answers/pathways.json.gz new file mode 100644 index 0000000..9517656 Binary files /dev/null and b/test/snapshots/answers/pathways.json.gz differ diff --git a/test/snapshots/answers/plot.json.gz b/test/snapshots/answers/plot.json.gz new file mode 100644 index 0000000..65cd59c Binary files /dev/null and b/test/snapshots/answers/plot.json.gz differ diff --git a/test/snapshots/answers/pooled-paired.json.gz b/test/snapshots/answers/pooled-paired.json.gz new file mode 100644 index 0000000..53a611a Binary files /dev/null and b/test/snapshots/answers/pooled-paired.json.gz differ diff --git a/test/snapshots/answers/riskmodel.json.gz b/test/snapshots/answers/riskmodel.json.gz new file mode 100644 index 0000000..3bad873 Binary files /dev/null and b/test/snapshots/answers/riskmodel.json.gz differ diff --git a/test/snapshots/answers/sequence.json.gz b/test/snapshots/answers/sequence.json.gz new file mode 100644 index 0000000..fc86537 Binary files /dev/null and b/test/snapshots/answers/sequence.json.gz differ diff --git a/test/snapshots/answers/survival.json.gz b/test/snapshots/answers/survival.json.gz new file mode 100644 index 0000000..93fdd3c Binary files /dev/null and b/test/snapshots/answers/survival.json.gz differ diff --git a/test/snapshots/answers/table.json.gz b/test/snapshots/answers/table.json.gz new file mode 100644 index 0000000..6d7aefd Binary files /dev/null and b/test/snapshots/answers/table.json.gz differ diff --git a/test/snapshots/answers/timeline.json.gz b/test/snapshots/answers/timeline.json.gz new file mode 100644 index 0000000..b0726c2 Binary files /dev/null and b/test/snapshots/answers/timeline.json.gz differ diff --git a/test/snapshots/answers/two-studies-four-views.json.gz b/test/snapshots/answers/two-studies-four-views.json.gz new file mode 100644 index 0000000..e87557c Binary files /dev/null and b/test/snapshots/answers/two-studies-four-views.json.gz differ diff --git a/test/snapshots/answers/two-studies-plot.json.gz b/test/snapshots/answers/two-studies-plot.json.gz new file mode 100644 index 0000000..8c83155 Binary files /dev/null and b/test/snapshots/answers/two-studies-plot.json.gz differ diff --git a/test/snapshots/answers/two-studies-survival.json.gz b/test/snapshots/answers/two-studies-survival.json.gz new file mode 100644 index 0000000..e33ddba Binary files /dev/null and b/test/snapshots/answers/two-studies-survival.json.gz differ diff --git a/test/snapshots/assays.json b/test/snapshots/assays.json new file mode 100644 index 0000000..098b664 --- /dev/null +++ b/test/snapshots/assays.json @@ -0,0 +1,697 @@ +{ + "study": "msk_impact_50k_2026", + "cohorts": { + "Melanoma": { + "count": 1706, + "text": "CANCER_TYPE in [Melanoma] (any sample)", + "studies": [ + "msk_impact_50k_2026" + ] + }, + "Non-small cell lung": { + "count": 6633, + "text": "CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample)", + "studies": [ + "msk_impact_50k_2026" + ] + } + }, + "views": [ + { + "kind": "assays", + "cohorts": [ + "Melanoma", + "Non-small cell lung" + ], + "assays": { + "profileType": "mutational_signatures_contribution_v2", + "profileName": "Mutational Signature Contribution Scores (COSMIC v2)", + "assayType": "MUTATIONAL_SIGNATURE", + "datatype": "numeric", + "unit": "samples", + "groups": [ + "Melanoma", + "Non-small cell lung" + ], + "tested": 30, + "untested": 0, + "significant": 26, + "minN": 3, + "test": "Welch's t-test", + "missing": 0, + "rows": [ + { + "entity": "mutational_signatures_contribution_v2_Signature4", + "name": "Signature4 (Smoking)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.010298716665451143, + "sd": 0.058030565429624245 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.16622830059170146, + "sd": 0.2429434174798955 + } + ], + "diff": -0.1559295839262503, + "statistic": -51.5445, + "p": 0, + "q": 0, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature7", + "name": "Signature7 (UV)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.5187993341391373, + "sd": 0.38449006711437517 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.023843506796059934, + "sd": 0.08326193650974895 + } + ], + "diff": 0.4949558273430773, + "statistic": 55.2198, + "p": 0, + "q": 0, + "higherIn": "Melanoma" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature24", + "name": "Signature24 (Aflatoxin)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.009138891998722847, + "sd": 0.057083701696028374 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.06971042637090322, + "sd": 0.14364314155913735 + } + ], + "diff": -0.060571534372180366, + "statistic": -29.1484, + "p": 4.257392752150982e-177, + "q": 4.257392752150982e-176, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature13", + "name": "Signature13 (APOBEC)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.00956848138721051, + "sd": 0.049038566059724766 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.05888704485121312, + "sd": 0.12005389818751065 + } + ], + "diff": -0.04931856346400261, + "statistic": -28.0766, + "p": 7.819767583291453e-165, + "q": 5.86482568746859e-164, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature18", + "name": "Signature18 (Unknown)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.008721388163558217, + "sd": 0.05475951701062739 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.03888048199856076, + "sd": 0.10851084936848984 + } + ], + "diff": -0.030159093835002544, + "statistic": -17.1941, + "p": 1.2383597382494074e-64, + "q": 7.430158429496444e-64, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature29", + "name": "Signature29 (Tobacco)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.0075951464783650165, + "sd": 0.05997980259981962 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.036515687120827596, + "sd": 0.11050042911728776 + } + ], + "diff": -0.028920540642462578, + "statistic": -15.5638, + "p": 2.0399699792092248e-53, + "q": 9.140126119414008e-53, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature2", + "name": "Signature2 (APOBEC)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.01574707484289951, + "sd": 0.07207156259435718 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.04828051007857093, + "sd": 0.11181289363691815 + } + ], + "diff": -0.032533435235671426, + "statistic": -15.6028, + "p": 2.132696094529935e-53, + "q": 9.140126119414008e-53, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature20", + "name": "Signature20 (MMR)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.012741072656891395, + "sd": 0.06996952278802417 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.03148789629481505, + "sd": 0.10402448882076575 + } + ], + "diff": -0.018746823637923654, + "statistic": -9.3993, + "p": 8.978520304776075e-21, + "q": 3.366945114291028e-20, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature16", + "name": "Signature16 (Unknown)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.007451000313366118, + "sd": 0.04686758323534038 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.018510648716710272, + "sd": 0.07452376696028855 + } + ], + "diff": -0.011059648403344155, + "statistic": -8.0839, + "p": 8.068458736467697e-16, + "q": 2.6894862454892323e-15, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature8", + "name": "Signature8 (Unknown)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.006187496702424302, + "sd": 0.047053354018776014 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.016258978835554536, + "sd": 0.07034220328342541 + } + ], + "diff": -0.010071482133130234, + "statistic": -7.4949, + "p": 8.113222960127824e-14, + "q": 2.433966888038347e-13, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature3", + "name": "Signature3 (HRD)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.033382070490749524, + "sd": 0.10985459784098602 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.050057430234104486, + "sd": 0.12366731742703801 + } + ], + "diff": -0.01667535974335496, + "statistic": -5.7568, + "p": 9.422091209324467e-9, + "q": 2.5696612389066728e-8, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature15", + "name": "Signature15 (MMR)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.008898449962132352, + "sd": 0.05376045204068322 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.017503401319110528, + "sd": 0.0751290088094514 + } + ], + "diff": -0.008604951356978176, + "statistic": -5.7291, + "p": 1.089058255916334e-8, + "q": 2.722645639790835e-8, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature14", + "name": "Signature14 (MMR)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.003375244796579444, + "sd": 0.032469849908769825 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.008217846958261008, + "sd": 0.04910702349579657 + } + ], + "diff": -0.004842602161681564, + "statistic": -5.2015, + "p": 2.0737585057441852e-7, + "q": 4.78559655171735e-7, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature11", + "name": "Signature11 (TMZ)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.025012240905447253, + "sd": 0.08301104223943147 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.014629153004696164, + "sd": 0.07381865739502905 + } + ], + "diff": 0.01038308790075109, + "statistic": 4.9598, + "p": 7.514323940558246e-7, + "q": 0.000001610212272976767, + "higherIn": "Melanoma" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature22", + "name": "Signature22 (Aristolochic acid)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.030421841758504636, + "sd": 0.12065985491117996 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.0174121127144547, + "sd": 0.0701378460140468 + } + ], + "diff": 0.013009729044049935, + "statistic": 4.4784, + "p": 0.000007914499451777197, + "q": 0.000015828998903554394, + "higherIn": "Melanoma" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature26", + "name": "Signature26 (MMR)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.005959323302291891, + "sd": 0.043912441051391006 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.011484670137244484, + "sd": 0.06572043429115658 + } + ], + "diff": -0.005525346834952593, + "statistic": -4.4042, + "p": 0.000010893049287469575, + "q": 0.000020424467414005453, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature6", + "name": "Signature6 (MMR)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.015807337209066928, + "sd": 0.0817667918971231 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.023866173976835513, + "sd": 0.09133133211610106 + } + ], + "diff": -0.008058836767768585, + "statistic": -3.7444, + "p": 0.00018415566527705678, + "q": 0.00032498058578304137, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature1", + "name": "Signature1 (Aging)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.04333237406593814, + "sd": 0.1312946832832878 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.05599605732477383, + "sd": 0.13541974869028547 + } + ], + "diff": -0.012663683258835691, + "statistic": -3.7264, + "p": 0.00019799745329043342, + "q": 0.0003299957554840557, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature19", + "name": "Signature19 (Unknown)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.004369047392522002, + "sd": 0.03509725788077581 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.00757593414630822, + "sd": 0.04613297579534556 + } + ], + "diff": -0.0032068867537862183, + "statistic": -3.3308, + "p": 0.0008748917823274928, + "q": 0.001381408077359199, + "higherIn": "Non-small cell lung" + }, + { + "entity": "mutational_signatures_contribution_v2_Signature9", + "name": "Signature9 (IGHV)", + "cells": [ + { + "cohort": "Melanoma", + "n": 1860, + "mean": 0.006908302333128928, + "sd": 0.04331609198242078 + }, + { + "cohort": "Non-small cell lung", + "n": 8040, + "mean": 0.010629742521844341, + "sd": 0.056740018863434244 + } + ], + "diff": -0.0037214401887154134, + "statistic": -3.1349, + "p": 0.00173320076233686, + "q": 0.002543008405928216, + "higherIn": "Non-small cell lung" + }, + { + "…": "10 more", + "sha256": "7e4e84a5665d9825" + } + ], + "grid": { + "xMax": 0.5, + "yMax": 500, + "nx": 80, + "ny": 50, + "cells": [] + }, + "labels": [ + "mutational_signatures_contribution_v2_Signature4", + "mutational_signatures_contribution_v2_Signature7", + "mutational_signatures_contribution_v2_Signature24", + "mutational_signatures_contribution_v2_Signature13", + "mutational_signatures_contribution_v2_Signature18", + "mutational_signatures_contribution_v2_Signature29", + "mutational_signatures_contribution_v2_Signature2", + "mutational_signatures_contribution_v2_Signature20", + "mutational_signatures_contribution_v2_Signature16", + "mutational_signatures_contribution_v2_Signature8", + "mutational_signatures_contribution_v2_Signature3", + "mutational_signatures_contribution_v2_Signature15" + ] + }, + "participation": { + "studies": [ + { + "study": "msk_impact_50k_2026", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Every entity of “Mutational Signature Contribution Scores (COSMIC v2)” (mutational_signatures_contribution_v2) compared across the cohorts, one value per sample as the study recorded it, from every sample of each cohort's patients. Values that are not numbers (a limit such as \">8\", or NA) are left out (0 of them). Each entity is tested with Welch's t-test from each cohort's n, mean and variance; with thousands of samples a tiny difference is significant, so read the means too. 30 entities tested; q is Benjamini–Hochberg across all of them. 0 were not tested: fewer than 3 samples with a value in some cohort, or no spread. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Sum each entity's values", + "detail": "The assays:moments query above, on “mutational_signatures_contribution_v2”: per entity, over the cohort's samples, n, Σv and Σv² of the values that read as numbers, and how many did not. No individual value leaves the database.", + "scope": "Melanoma · msk_impact_50k_2026", + "rowsOut": 30 + }, + { + "kind": "fetch", + "title": "Sum each entity's values", + "detail": "The assays:moments query above, on “mutational_signatures_contribution_v2”: per entity, over the cohort's samples, n, Σv and Σv² of the values that read as numbers, and how many did not. No individual value leaves the database.", + "scope": "Non-small cell lung · msk_impact_50k_2026", + "rowsOut": 30 + }, + { + "kind": "transform", + "title": "Leave out what cannot be tested", + "detail": "Values that are not numbers: 0 left out. An entity with fewer than 3 samples with a value in any cohort, or no spread in any cohort (variance ≤ 1e-12 · (1 + mean²)), is not tested.", + "params": [ + [ + "tested", + "30" + ], + [ + "not tested", + "0" + ] + ] + }, + { + "kind": "statistic", + "title": "Welch's t-test per entity, then Benjamini–Hochberg", + "detail": "Unequal-variance t from each cohort's n, mean and variance (Σv² − (Σv)²/n)/(n − 1), Welch–Satterthwaite df, two-sided. q across every entity tested, one value per sample." + } + ], + "implementation": { + "functions": [ + "welchT", + "varianceFromMoments", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Welch's t and ANOVA from moments match scipy 1.18.1 ttest_ind(equal_var=False) and statsmodels 0.15.0 anova_generic(use_var=\"unequal\") and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts, test/tables-golden.test.ts).", + "check": { + "assays:tested": { + "v": 30 + }, + "assays:mutational_signatures_contribution_v2_Signature4:p": { + "v": 0, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature4:q": { + "v": 0, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature7:p": { + "v": 0, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature7:q": { + "v": 0, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature24:p": { + "v": 4.257392752150982e-177, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature24:q": { + "v": 4.257392752150982e-176, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature13:p": { + "v": 7.819767583291453e-165, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature13:q": { + "v": 5.86482568746859e-164, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature18:p": { + "v": 1.2383597382494074e-64, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature18:q": { + "v": 7.430158429496444e-64, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature29:p": { + "v": 2.0399699792092248e-53, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature29:q": { + "v": 9.140126119414008e-53, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature2:p": { + "v": 2.132696094529935e-53, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature2:q": { + "v": 9.140126119414008e-53, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature20:p": { + "v": 8.978520304776075e-21, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature20:q": { + "v": 3.366945114291028e-20, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature16:p": { + "v": 8.068458736467697e-16, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature16:q": { + "v": 2.6894862454892323e-15, + "rel": 0.000001, + "abs": 1e-300 + }, + "assays:mutational_signatures_contribution_v2_Signature8:p": { + "v": 8.113222960127824e-14, + "rel": 0.000001, + "abs": 1e-300 + }, + "…": { + "more": 41, + "sha256": "89b71828088bd533" + } + } + } + } + ] +} diff --git a/test/snapshots/assays.sql b/test/snapshots/assays.sql new file mode 100644 index 0000000..a70ec43 --- /dev/null +++ b/test/snapshots/assays.sql @@ -0,0 +1,60 @@ +-- cohort Melanoma +-- msk_impact_50k_2026 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Melanoma')))) + +-- cohort Non-small cell lung +-- msk_impact_50k_2026 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer')))) + +-- view 0 assays: assays:moments:Melanoma · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Melanoma'))))), +rows AS ( + SELECT entity_stable_id AS entity, value FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'mutational_signatures_contribution_v2' + AND profile_stable_id = 'msk_impact_50k_2026_mutational_signatures_contribution_v2' + AND patient_unique_id IN (SELECT concat('msk_impact_50k_2026_', pid) FROM cohort) +) +SELECT entity, countIf(isFinite(toFloat64OrNull(value))) AS n, + sumIf(toFloat64OrNull(value), isFinite(toFloat64OrNull(value))) AS sx, + sumIf(pow(toFloat64OrNull(value), 2), isFinite(toFloat64OrNull(value))) AS sxx, + countIf(NOT isFinite(ifNull(toFloat64OrNull(value), nan))) AS other +FROM rows GROUP BY entity + +-- view 0 assays: assays:moments:Non-small cell lung · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer'))))), +rows AS ( + SELECT entity_stable_id AS entity, value FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'mutational_signatures_contribution_v2' + AND profile_stable_id = 'msk_impact_50k_2026_mutational_signatures_contribution_v2' + AND patient_unique_id IN (SELECT concat('msk_impact_50k_2026_', pid) FROM cohort) +) +SELECT entity, countIf(isFinite(toFloat64OrNull(value))) AS n, + sumIf(toFloat64OrNull(value), isFinite(toFloat64OrNull(value))) AS sx, + sumIf(pow(toFloat64OrNull(value), 2), isFinite(toFloat64OrNull(value))) AS sxx, + countIf(NOT isFinite(ifNull(toFloat64OrNull(value), nan))) AS other +FROM rows GROUP BY entity + +-- view 0 assays: assays:names · msk_impact_50k_2026 +WITH named AS ( + SELECT ge.stable_id AS entity, p.value AS name FROM snapshot_db.generic_entity_properties p + JOIN snapshot_db.genetic_entity ge ON ge.id = p.genetic_entity_id + WHERE p.name = 'NAME' AND ge.stable_id IN (SELECT DISTINCT entity_stable_id FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'mutational_signatures_contribution_v2' AND profile_stable_id = 'msk_impact_50k_2026_mutational_signatures_contribution_v2') +) +SELECT entity, name FROM named + +-- view 0 assays: assays:profile · msk_impact_50k_2026 +SELECT datatype, generic_assay_type, ifNull(patient_level, 0) AS patient_level, name FROM snapshot_db.genetic_profile +WHERE stable_id = 'msk_impact_50k_2026_mutational_signatures_contribution_v2' AND genetic_alteration_type = 'GENERIC_ASSAY' diff --git a/test/snapshots/assays.svg b/test/snapshots/assays.svg new file mode 100644 index 0000000..8e8187e --- /dev/null +++ b/test/snapshots/assays.svg @@ -0,0 +1,2 @@ + +Generic assays — Mutational Signature Contribution Scores (COSMIC v2) — Melanoma vs Non-small cell lung30 Mutational Signature Contribution Scores (COSMIC v2) entities tested (Welch's t-test) · 26 at q < 0.050100200300400500−log₁₀ p−0.4−0.20.00.20.4difference in mean (Melanoma − Non-small cell lung)Signature4 (Smoking): −0.156 · q <1e-300Signature7 (UV): 0.495 · q <1e-300Signature24 (Aflatoxin): −0.0606 · q 4.3e-176Signature13 (APOBEC): −0.0493 · q 5.9e-164Signature18 (Unknown): −0.0302 · q 7.4e-64Signature29 (Tobacco): −0.0289 · q 9.1e-53Signature2 (APOBEC): −0.0325 · q 9.1e-53Signature20 (MMR): −0.0187 · q 3.4e-20Signature16 (Unknown): −0.0111 · q 2.7e-15Signature8 (Unknown): −0.0101 · q 2.4e-13Signature3 (HRD): −0.0167 · q 2.6e-8Signature15 (MMR): −0.0086 · q 2.7e-8Signature14 (MMR): −0.00484 · q 4.8e-7Signature11 (TMZ): 0.0104 · q 1.6e-6Signature22 (Aristolochic acid): 0.013 · q 1.6e-5Signature26 (MMR): −0.00553 · q 2e-5Signature6 (MMR): −0.00806 · q 3.2e-4Signature1 (Aging): −0.0127 · q 3.3e-4Signature19 (Unknown): −0.00321 · q 0.0014Signature9 (IGHV): −0.00372 · q 0.0025Signature10 (POLE): −0.00458 · q 0.0025Signature17 (Unknown): −0.00285 · q 0.027Signature30 (Unknown): −0.00392 · q 0.03Signature21 (MMR): −0.00382 · q 0.03Signature12 (Unknown): −0.00346 · q 0.032Signature5 (Unknown): −0.00126 · q 0.043Signature27 (Unknown): −0.00159 · q 0.064Signature25 (Unknown): −0.000981 · q 0.45Signature28 (Unknown): 0.00164 · q 0.45Signature23 (Unknown): −0.000289 · q 0.90Signature4 (Smoking)Signature7 (UV)Signature24 (Aflatoxin)Signature13 (APOBEC)Signature18 (Unknown)Signature29 (Tobacco)Signature2 (APOBEC)Signature20 (MMR)Signature16 (Unknown)Signature8 (Unknown)Signature3 (HRD)← higher in Non-small cell lunghigher in Melanoma →1 of 12 entities named on this volcano could not be labelled without overprinting anotherlabel or point and is left unlabelled: Signature15 (MMR).entity · meanMelanomaNon-small cell lungqSignature4 (Smoking)0.01030.166<1e-300Signature7 (UV)0.5190.0238<1e-300Signature24 (Aflatoxin)0.009140.06974.3e-176Signature13 (APOBEC)0.009570.05895.9e-164Signature18 (Unknown)0.008720.03897.4e-64Signature29 (Tobacco)0.00760.03659.1e-53Signature2 (APOBEC)0.01570.04839.1e-53Signature20 (MMR)0.01270.03153.4e-20Signature16 (Unknown)0.007450.01852.7e-15Signature8 (Unknown)0.006190.01632.4e-13Signature3 (HRD)0.03340.05012.6e-8Signature15 (MMR)0.00890.01752.7e-8Signature14 (MMR)0.003380.008224.8e-7Signature11 (TMZ)0.0250.01461.6e-6Signature22 (Aristolochic acid)0.03040.01741.6e-5Signature26 (MMR)0.005960.01152e-5Signature6 (MMR)0.01580.02393.2e-4Signature1 (Aging)0.04330.0563.3e-4+12 more entities tested (the full table is in the result and the MCP text)Every entity of “Mutational Signature Contribution Scores (COSMIC v2)” (mutational_signatures_contribution_v2) compared across the cohorts, one value per sample asthe study recorded it, from every sample of each cohort's patients. Values that are not numbers (a limit such as ">8", or NA) are left out (0 of them). Each entity is testedwith Welch's t-test from each cohort's n, mean and variance; with thousands of samples a tiny difference is significant, so read the means too. 30 entities tested; q isBenjamini–Hochberg across all of them. 0 were not tested: fewer than 3 samples with a value in some cohort, or no spread. diff --git a/test/snapshots/assays.txt b/test/snapshots/assays.txt new file mode 100644 index 0000000..2b1349e --- /dev/null +++ b/test/snapshots/assays.txt @@ -0,0 +1,46 @@ +Analysis over msk_impact_50k_2026 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Melanoma: 1,706 patients — CANCER_TYPE in [Melanoma] (any sample) +- Non-small cell lung: 6,633 patients — CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample) + +Generic-assay comparison, Mutational Signature Contribution Scores (COSMIC v2) (mutational_signatures_contribution_v2; numeric, per sample; Welch's t-test, BH q over 30 entities; 26 at q<0.05): + Signature4 (Smoking): Melanoma mean 0.0103 (n=1860) | Non-small cell lung mean 0.166 (n=8040), difference -0.156, q=<1e-300, higher in Non-small cell lung + Signature7 (UV): Melanoma mean 0.519 (n=1860) | Non-small cell lung mean 0.0238 (n=8040), difference 0.495, q=<1e-300, higher in Melanoma + Signature24 (Aflatoxin): Melanoma mean 0.00914 (n=1860) | Non-small cell lung mean 0.0697 (n=8040), difference -0.0606, q=4.3e-176, higher in Non-small cell lung + Signature13 (APOBEC): Melanoma mean 0.00957 (n=1860) | Non-small cell lung mean 0.0589 (n=8040), difference -0.0493, q=5.9e-164, higher in Non-small cell lung + Signature18 (Unknown): Melanoma mean 0.00872 (n=1860) | Non-small cell lung mean 0.0389 (n=8040), difference -0.0302, q=7.4e-64, higher in Non-small cell lung + Signature29 (Tobacco): Melanoma mean 0.00760 (n=1860) | Non-small cell lung mean 0.0365 (n=8040), difference -0.0289, q=9.1e-53, higher in Non-small cell lung + Signature2 (APOBEC): Melanoma mean 0.0157 (n=1860) | Non-small cell lung mean 0.0483 (n=8040), difference -0.0325, q=9.1e-53, higher in Non-small cell lung + Signature20 (MMR): Melanoma mean 0.0127 (n=1860) | Non-small cell lung mean 0.0315 (n=8040), difference -0.0187, q=3.4e-20, higher in Non-small cell lung + Signature16 (Unknown): Melanoma mean 0.00745 (n=1860) | Non-small cell lung mean 0.0185 (n=8040), difference -0.0111, q=2.7e-15, higher in Non-small cell lung + Signature8 (Unknown): Melanoma mean 0.00619 (n=1860) | Non-small cell lung mean 0.0163 (n=8040), difference -0.0101, q=2.4e-13, higher in Non-small cell lung + Signature3 (HRD): Melanoma mean 0.0334 (n=1860) | Non-small cell lung mean 0.0501 (n=8040), difference -0.0167, q=2.6e-8, higher in Non-small cell lung + Signature15 (MMR): Melanoma mean 0.00890 (n=1860) | Non-small cell lung mean 0.0175 (n=8040), difference -0.00860, q=2.7e-8, higher in Non-small cell lung + Signature14 (MMR): Melanoma mean 0.00338 (n=1860) | Non-small cell lung mean 0.00822 (n=8040), difference -0.00484, q=4.8e-7, higher in Non-small cell lung + Signature11 (TMZ): Melanoma mean 0.0250 (n=1860) | Non-small cell lung mean 0.0146 (n=8040), difference 0.0104, q=1.6e-6, higher in Melanoma + Signature22 (Aristolochic acid): Melanoma mean 0.0304 (n=1860) | Non-small cell lung mean 0.0174 (n=8040), difference 0.0130, q=1.6e-5, higher in Melanoma + Signature26 (MMR): Melanoma mean 0.00596 (n=1860) | Non-small cell lung mean 0.0115 (n=8040), difference -0.00553, q=2.0e-5, higher in Non-small cell lung + Signature6 (MMR): Melanoma mean 0.0158 (n=1860) | Non-small cell lung mean 0.0239 (n=8040), difference -0.00806, q=0.0003, higher in Non-small cell lung + Signature1 (Aging): Melanoma mean 0.0433 (n=1860) | Non-small cell lung mean 0.0560 (n=8040), difference -0.0127, q=0.0003, higher in Non-small cell lung + Signature19 (Unknown): Melanoma mean 0.00437 (n=1860) | Non-small cell lung mean 0.00758 (n=8040), difference -0.00321, q=0.0014, higher in Non-small cell lung + Signature9 (IGHV): Melanoma mean 0.00691 (n=1860) | Non-small cell lung mean 0.0106 (n=8040), difference -0.00372, q=0.0025, higher in Non-small cell lung + Signature10 (POLE): Melanoma mean 0.00837 (n=1860) | Non-small cell lung mean 0.0129 (n=8040), difference -0.00458, q=0.0025, higher in Non-small cell lung + Signature17 (Unknown): Melanoma mean 0.00671 (n=1860) | Non-small cell lung mean 0.00956 (n=8040), difference -0.00285, q=0.0269, higher in Non-small cell lung + Signature30 (Unknown): Melanoma mean 0.0122 (n=1860) | Non-small cell lung mean 0.0162 (n=8040), difference -0.00392, q=0.0298, higher in Non-small cell lung + Signature21 (MMR): Melanoma mean 0.0145 (n=1860) | Non-small cell lung mean 0.0183 (n=8040), difference -0.00382, q=0.0305, higher in Non-small cell lung + Signature12 (Unknown): Melanoma mean 0.0105 (n=1860) | Non-small cell lung mean 0.0140 (n=8040), difference -0.00346, q=0.0320, higher in Non-small cell lung + Signature5 (Unknown): Melanoma mean 0.00172 (n=1860) | Non-small cell lung mean 0.00298 (n=8040), difference -0.00126, q=0.0431, higher in Non-small cell lung + Signature27 (Unknown): Melanoma mean 0.00413 (n=1860) | Non-small cell lung mean 0.00572 (n=8040), difference -0.00159, q=0.0635, higher in Non-small cell lung + Signature25 (Unknown): Melanoma mean 0.00715 (n=1860) | Non-small cell lung mean 0.00813 (n=8040), difference -0.000981, q=0.4548, higher in Non-small cell lung + Signature28 (Unknown): Melanoma mean 0.0148 (n=1860) | Non-small cell lung mean 0.0132 (n=8040), difference 0.00164, q=0.4548, higher in Melanoma + Signature23 (Unknown): Melanoma mean 0.0218 (n=1860) | Non-small cell lung mean 0.0221 (n=8040), difference -0.000289, q=0.8979, higher in Non-small cell lung + CAVEAT (tell the user): Every entity of “Mutational Signature Contribution Scores (COSMIC v2)” (mutational_signatures_contribution_v2) compared across the cohorts, one value per sample as the study recorded it, from every sample of each cohort's patients. Values that are not numbers (a limit such as ">8", or NA) are left out (0 of them). Each entity is tested with Welch's t-test from each cohort's n, mean and variance; with thousands of samples a tiny difference is significant, so read the means too. 30 entities tested; q is Benjamini–Hochberg across all of them. 0 were not tested: fewer than 3 samples with a value in some cohort, or no spread. + METHOD: + - Sum each entity's values [Melanoma · msk_impact_50k_2026]: The assays:moments query above, on “mutational_signatures_contribution_v2”: per entity, over the cohort's samples, n, Σv and Σv² of the values that read as numbers, and how many did not. No individual value leaves the database. + - Sum each entity's values [Non-small cell lung · msk_impact_50k_2026]: The assays:moments query above, on “mutational_signatures_contribution_v2”: per entity, over the cohort's samples, n, Σv and Σv² of the values that read as numbers, and how many did not. No individual value leaves the database. + - Leave out what cannot be tested: Values that are not numbers: 0 left out. An entity with fewer than 3 samples with a value in any cohort, or no spread in any cohort (variance ≤ 1e-12 · (1 + mean²)), is not tested. + tested: 30 + not tested: 0 + - Welch's t-test per entity, then Benjamini–Hochberg: Unequal-variance t from each cohort's n, mean and variance (Σv² − (Σv)²/n)/(n − 1), Welch–Satterthwaite df, two-sided. q across every entity tested, one value per sample. + Welch's t and ANOVA from moments match scipy 1.18.1 ttest_ind(equal_var=False) and statsmodels 0.15.0 anova_generic(use_var="unequal") and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts, test/tables-golden.test.ts). diff --git a/test/snapshots/attrition.json b/test/snapshots/attrition.json new file mode 100644 index 0000000..229858a --- /dev/null +++ b/test/snapshots/attrition.json @@ -0,0 +1,154 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "LUAD KRAS G12C, immunotherapy": { + "count": 279, + "text": "CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample) AND OQL[KRAS: G12C] AND has Immuno treatment AND followupMonths ≥ 6 months", + "studies": [ + "msk_chord_2024" + ] + }, + "LUAD KRAS wild-type": { + "count": 3976, + "text": "CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample) AND NOT OQL[KRAS]", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "attrition", + "cohorts": [ + "LUAD KRAS G12C, immunotherapy", + "LUAD KRAS wild-type" + ], + "attrition": [ + { + "cohort": "LUAD KRAS G12C, immunotherapy", + "base": 24950, + "steps": [ + { + "label": "CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample)", + "n": 5957, + "excluded": 18993, + "pctOfBase": 23.9 + }, + { + "label": "OQL[KRAS: G12C]", + "n": 793, + "excluded": 5164, + "pctOfBase": 3.2 + }, + { + "label": "has Immuno treatment", + "n": 357, + "excluded": 436, + "pctOfBase": 1.4 + }, + { + "label": "followupMonths ≥ 6 months", + "n": 279, + "excluded": 78, + "pctOfBase": 1.1 + } + ], + "studies": [ + "msk_chord_2024" + ] + }, + { + "cohort": "LUAD KRAS wild-type", + "base": 24950, + "steps": [ + { + "label": "CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample)", + "n": 5957, + "excluded": 18993, + "pctOfBase": 23.9 + }, + { + "label": "NOT OQL[KRAS]", + "n": 3976, + "excluded": 1981, + "pctOfBase": 15.9 + } + ], + "studies": [ + "msk_chord_2024" + ] + } + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Each step counts the patients left after ANDing that clause onto every clause above it, in the order the cohort lists them. The order changes the path, never the final count: reorder the clauses to see a different attrition sequence. Each view further drops patients who lack its own data (survival without follow-up, genes never profiled), and says how many in its own caption.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count the cohort clause by clause", + "detail": "One attrition query per step above, per study: the patients left after ANDing that clause onto every clause before it, in the order the cohort lists them, summed across msk_chord_2024. Nothing is computed from these counts beyond the differences between steps.", + "scope": "LUAD KRAS G12C, immunotherapy", + "params": [ + [ + "every patient", + "24,950" + ], + [ + "CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample)", + "5,957 (−18,993)" + ], + [ + "OQL[KRAS: G12C]", + "793 (−5,164)" + ], + [ + "has Immuno treatment", + "357 (−436)" + ], + [ + "followupMonths ≥ 6 months", + "279 (−78)" + ] + ] + }, + { + "kind": "fetch", + "title": "Count the cohort clause by clause", + "detail": "One attrition query per step above, per study: the patients left after ANDing that clause onto every clause before it, in the order the cohort lists them, summed across msk_chord_2024. Nothing is computed from these counts beyond the differences between steps.", + "scope": "LUAD KRAS wild-type", + "params": [ + [ + "every patient", + "24,950" + ], + [ + "CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample)", + "5,957 (−18,993)" + ], + [ + "NOT OQL[KRAS]", + "3,976 (−1,981)" + ] + ] + } + ], + "implementation": { + "functions": [], + "file": "lib/views/attrition.ts", + "commit": null + } + } + } + ] +} diff --git a/test/snapshots/attrition.sql b/test/snapshots/attrition.sql new file mode 100644 index 0000000..573a8c2 --- /dev/null +++ b/test/snapshots/attrition.sql @@ -0,0 +1,176 @@ +-- cohort LUAD KRAS G12C, immunotherapy +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation' AND g.mutation_variant = 'G12C')) +INTERSECT DISTINCT +(WITH +study_patients AS ( + SELECT p.internal_id FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' +), +sel_a AS ( +SELECT ce.patient_id, ce.start_date, ce.stop_date + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.clinical_event_data a0 ON a0.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(a0.key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(a0.value)) = lowerUTF8(trimBoth('Immuno')) + WHERE lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.patient_id IN (SELECT internal_id FROM study_patients) +) +SELECT DISTINCT p.stable_id AS pid +FROM sel_a + JOIN snapshot_db.patient p ON p.internal_id = sel_a.patient_id +WHERE 1 +ORDER BY pid LIMIT 1000000) +INTERSECT DISTINCT +(SELECT pid FROM ( +SELECT p.stable_id AS pid, max(ce.start_date) / 30.4375 AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + GROUP BY pid +) + WHERE v >= 6) + +-- cohort LUAD KRAS wild-type +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) + +-- view 0 attrition: attrition:LUAD KRAS G12C, immunotherapy:step 0 · msk_chord_2024 +SELECT count() AS n FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') + +-- view 0 attrition: attrition:LUAD KRAS G12C, immunotherapy:step 1 · msk_chord_2024 +SELECT count() AS n FROM ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma'))))) + +-- view 0 attrition: attrition:LUAD KRAS G12C, immunotherapy:step 2 · msk_chord_2024 +SELECT count() AS n FROM ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation' AND g.mutation_variant = 'G12C'))) + +-- view 0 attrition: attrition:LUAD KRAS G12C, immunotherapy:step 3 · msk_chord_2024 +SELECT count() AS n FROM ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation' AND g.mutation_variant = 'G12C')) +INTERSECT DISTINCT +(WITH +study_patients AS ( + SELECT p.internal_id FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' +), +sel_a AS ( +SELECT ce.patient_id, ce.start_date, ce.stop_date + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.clinical_event_data a0 ON a0.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(a0.key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(a0.value)) = lowerUTF8(trimBoth('Immuno')) + WHERE lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.patient_id IN (SELECT internal_id FROM study_patients) +) +SELECT DISTINCT p.stable_id AS pid +FROM sel_a + JOIN snapshot_db.patient p ON p.internal_id = sel_a.patient_id +WHERE 1 +ORDER BY pid LIMIT 1000000)) + +-- view 0 attrition: attrition:LUAD KRAS G12C, immunotherapy:step 4 · msk_chord_2024 +SELECT count() AS n FROM ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation' AND g.mutation_variant = 'G12C')) +INTERSECT DISTINCT +(WITH +study_patients AS ( + SELECT p.internal_id FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' +), +sel_a AS ( +SELECT ce.patient_id, ce.start_date, ce.stop_date + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.clinical_event_data a0 ON a0.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(a0.key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(a0.value)) = lowerUTF8(trimBoth('Immuno')) + WHERE lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.patient_id IN (SELECT internal_id FROM study_patients) +) +SELECT DISTINCT p.stable_id AS pid +FROM sel_a + JOIN snapshot_db.patient p ON p.internal_id = sel_a.patient_id +WHERE 1 +ORDER BY pid LIMIT 1000000) +INTERSECT DISTINCT +(SELECT pid FROM ( +SELECT p.stable_id AS pid, max(ce.start_date) / 30.4375 AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + GROUP BY pid +) + WHERE v >= 6)) + +-- view 0 attrition: attrition:LUAD KRAS wild-type:step 0 · msk_chord_2024 +SELECT count() AS n FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') + +-- view 0 attrition: attrition:LUAD KRAS wild-type:step 1 · msk_chord_2024 +SELECT count() AS n FROM ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma'))))) + +-- view 0 attrition: attrition:LUAD KRAS wild-type:step 2 · msk_chord_2024 +SELECT count() AS n FROM ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Lung Adenocarcinoma')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2))))) diff --git a/test/snapshots/attrition.svg b/test/snapshots/attrition.svg new file mode 100644 index 0000000..4c732e0 --- /dev/null +++ b/test/snapshots/attrition.svg @@ -0,0 +1,2 @@ + +Cohort attrition — LUAD KRAS G12C, immunotherapy, LUAD KRAS wild-typeLUAD KRAS G12C, immunotherapyEvery patient in msk_chord_202424,950patients−18,993 excludedCANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (anysample)5,957(23.9% of base)−5,164 excludedOQL[KRAS: G12C]793(3.2% of base)−436 excludedhas Immuno treatment357(1.4% of base)−78 excludedfollowupMonths ≥ 6 months279(1.1% of base)LUAD KRAS wild-typeEvery patient in msk_chord_202424,950patients−18,993 excludedCANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (anysample)5,957(23.9% of base)−1,981 excludedNOT OQL[KRAS]3,976(15.9% of base)Each step counts the patients left after ANDing that clause onto every clause above it, in the order the cohort lists them. The order changes the path, never the finalcount: reorder the clauses to see a different attrition sequence. Each view further drops patients who lack its own data (survival without follow-up, genes neverprofiled), and says how many in its own caption. diff --git a/test/snapshots/attrition.txt b/test/snapshots/attrition.txt new file mode 100644 index 0000000..aec3dc4 --- /dev/null +++ b/test/snapshots/attrition.txt @@ -0,0 +1,27 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- LUAD KRAS G12C, immunotherapy: 279 patients — CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample) AND OQL[KRAS: G12C] AND has Immuno treatment AND followupMonths ≥ 6 months +- LUAD KRAS wild-type: 3,976 patients — CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample) AND NOT OQL[KRAS] + +Cohort attrition (patients left after each clause, in order): + LUAD KRAS G12C, immunotherapy: study base 24,950 + → CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample): 5,957 (−18,993) + → OQL[KRAS: G12C]: 793 (−5,164) + → has Immuno treatment: 357 (−436) + → followupMonths ≥ 6 months: 279 (−78) + LUAD KRAS wild-type: study base 24,950 + → CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample): 5,957 (−18,993) + → NOT OQL[KRAS]: 3,976 (−1,981) + CAVEAT (tell the user): Each step counts the patients left after ANDing that clause onto every clause above it, in the order the cohort lists them. The order changes the path, never the final count: reorder the clauses to see a different attrition sequence. Each view further drops patients who lack its own data (survival without follow-up, genes never profiled), and says how many in its own caption. + METHOD: + - Count the cohort clause by clause [LUAD KRAS G12C, immunotherapy]: One attrition query per step above, per study: the patients left after ANDing that clause onto every clause before it, in the order the cohort lists them, summed across msk_chord_2024. Nothing is computed from these counts beyond the differences between steps. + every patient: 24,950 + CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample): 5,957 (−18,993) + OQL[KRAS: G12C]: 793 (−5,164) + has Immuno treatment: 357 (−436) + followupMonths ≥ 6 months: 279 (−78) + - Count the cohort clause by clause [LUAD KRAS wild-type]: One attrition query per step above, per study: the patients left after ANDing that clause onto every clause before it, in the order the cohort lists them, summed across msk_chord_2024. Nothing is computed from these counts beyond the differences between steps. + every patient: 24,950 + CANCER_TYPE_DETAILED in [Lung Adenocarcinoma] (any sample): 5,957 (−18,993) + NOT OQL[KRAS]: 3,976 (−1,981) diff --git a/test/snapshots/cancertypes.json b/test/snapshots/cancertypes.json new file mode 100644 index 0000000..5ccdd93 --- /dev/null +++ b/test/snapshots/cancertypes.json @@ -0,0 +1,1562 @@ +{ + "study": "msk_impact_50k_2026", + "cohorts": { + "all patients": { + "count": 48179, + "text": "all patients in the study", + "studies": [ + "msk_impact_50k_2026" + ] + } + }, + "views": [ + { + "kind": "cancertypes", + "cohorts": [ + "all patients" + ], + "cancertypes": { + "groupBy": "CANCER_TYPE", + "measure": "any", + "genes": [ + "KRAS", + "NRAS", + "HRAS" + ], + "minSamples": 200, + "show": "frequency", + "unit": "patient", + "panels": [ + { + "cohort": "all patients", + "samples": 48179, + "profiled": 48179, + "altered": 10796, + "groups": [ + { + "key": "pancreatic cancer", + "label": "Pancreatic Cancer", + "samples": 2729, + "profiled": 2729, + "altered": 2263, + "mutation": 2211, + "amp": 3, + "homdel": 0, + "sv": 0, + "multiple": 49, + "profiledFor": { + "mutation": 2729, + "cna": 2729, + "sv": 2729 + } + }, + { + "key": "appendiceal cancer", + "label": "Appendiceal Cancer", + "samples": 269, + "profiled": 269, + "altered": 163, + "mutation": 163, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 269, + "cna": 269, + "sv": 269 + } + }, + { + "key": "colorectal cancer", + "label": "Colorectal Cancer", + "samples": 4993, + "profiled": 4993, + "altered": 2450, + "mutation": 2383, + "amp": 48, + "homdel": 4, + "sv": 1, + "multiple": 14, + "profiledFor": { + "mutation": 4993, + "cna": 4993, + "sv": 4993 + } + }, + { + "key": "non-small cell lung cancer", + "label": "Non-Small Cell Lung Cancer", + "samples": 6633, + "profiled": 6633, + "altered": 2103, + "mutation": 1943, + "amp": 71, + "homdel": 20, + "sv": 1, + "multiple": 68, + "profiledFor": { + "mutation": 6633, + "cna": 6633, + "sv": 6633 + } + }, + { + "key": "germ cell tumor", + "label": "Germ Cell Tumor", + "samples": 663, + "profiled": 663, + "altered": 208, + "mutation": 78, + "amp": 114, + "homdel": 0, + "sv": 0, + "multiple": 16, + "profiledFor": { + "mutation": 663, + "cna": 663, + "sv": 663 + } + }, + { + "key": "melanoma", + "label": "Melanoma", + "samples": 1706, + "profiled": 1706, + "altered": 506, + "mutation": 452, + "amp": 17, + "homdel": 4, + "sv": 0, + "multiple": 33, + "profiledFor": { + "mutation": 1706, + "cna": 1706, + "sv": 1706 + } + }, + { + "key": "cancer of unknown primary", + "label": "Cancer of Unknown Primary", + "samples": 1535, + "profiled": 1535, + "altered": 395, + "mutation": 348, + "amp": 25, + "homdel": 7, + "sv": 1, + "multiple": 14, + "profiledFor": { + "mutation": 1535, + "cna": 1535, + "sv": 1535 + } + }, + { + "key": "endometrial cancer", + "label": "Endometrial Cancer", + "samples": 2373, + "profiled": 2373, + "altered": 570, + "mutation": 541, + "amp": 19, + "homdel": 6, + "sv": 0, + "multiple": 4, + "profiledFor": { + "mutation": 2373, + "cna": 2373, + "sv": 2373 + } + }, + { + "key": "thyroid cancer", + "label": "Thyroid Cancer", + "samples": 803, + "profiled": 803, + "altered": 172, + "mutation": 164, + "amp": 2, + "homdel": 1, + "sv": 0, + "multiple": 5, + "profiledFor": { + "mutation": 803, + "cna": 803, + "sv": 803 + } + }, + { + "key": "esophagogastric cancer", + "label": "Esophagogastric Cancer", + "samples": 1671, + "profiled": 1671, + "altered": 311, + "mutation": 134, + "amp": 169, + "homdel": 3, + "sv": 0, + "multiple": 5, + "profiledFor": { + "mutation": 1671, + "cna": 1671, + "sv": 1671 + } + }, + { + "key": "ovarian cancer", + "label": "Ovarian Cancer", + "samples": 2075, + "profiled": 2075, + "altered": 297, + "mutation": 199, + "amp": 75, + "homdel": 13, + "sv": 1, + "multiple": 9, + "profiledFor": { + "mutation": 2075, + "cna": 2075, + "sv": 2075 + } + }, + { + "key": "hepatobiliary cancer", + "label": "Hepatobiliary Cancer", + "samples": 1353, + "profiled": 1353, + "altered": 191, + "mutation": 173, + "amp": 16, + "homdel": 0, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 1353, + "cna": 1353, + "sv": 1353 + } + }, + { + "key": "cervical cancer", + "label": "Cervical Cancer", + "samples": 326, + "profiled": 326, + "altered": 44, + "mutation": 40, + "amp": 0, + "homdel": 2, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 326, + "cna": 326, + "sv": 326 + } + }, + { + "key": "bladder cancer", + "label": "Bladder Cancer", + "samples": 2046, + "profiled": 2046, + "altered": 259, + "mutation": 215, + "amp": 27, + "homdel": 13, + "sv": 1, + "multiple": 3, + "profiledFor": { + "mutation": 2046, + "cna": 2046, + "sv": 2046 + } + }, + { + "key": "skin cancer, non-melanoma", + "label": "Skin Cancer, Non-Melanoma", + "samples": 429, + "profiled": 429, + "altered": 40, + "mutation": 38, + "amp": 0, + "homdel": 2, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 429, + "cna": 429, + "sv": 429 + } + }, + { + "key": "salivary gland cancer", + "label": "Salivary Gland Cancer", + "samples": 352, + "profiled": 352, + "altered": 29, + "mutation": 24, + "amp": 3, + "homdel": 0, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 352, + "cna": 352, + "sv": 352 + } + }, + { + "key": "head and neck cancer", + "label": "Head and Neck Cancer", + "samples": 610, + "profiled": 610, + "altered": 47, + "mutation": 39, + "amp": 8, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 610, + "cna": 610, + "sv": 610 + } + }, + { + "key": "small cell lung cancer", + "label": "Small Cell Lung Cancer", + "samples": 442, + "profiled": 442, + "altered": 27, + "mutation": 17, + "amp": 4, + "homdel": 6, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 442, + "cna": 442, + "sv": 442 + } + }, + { + "key": "soft tissue sarcoma", + "label": "Soft Tissue Sarcoma", + "samples": 2128, + "profiled": 2128, + "altered": 103, + "mutation": 63, + "amp": 17, + "homdel": 15, + "sv": 1, + "multiple": 7, + "profiledFor": { + "mutation": 2128, + "cna": 2128, + "sv": 2128 + } + }, + { + "key": "uterine sarcoma", + "label": "Uterine Sarcoma", + "samples": 337, + "profiled": 337, + "altered": 15, + "mutation": 7, + "amp": 4, + "homdel": 3, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 337, + "cna": 337, + "sv": 337 + } + }, + { + "…": "8 more", + "sha256": "a8285816abe66c3d" + } + ], + "pooled": { + "key": "__pooled__", + "label": "38 smaller groups", + "samples": 1842, + "profiled": 1842, + "altered": 250, + "mutation": 231, + "amp": 8, + "homdel": 8, + "sv": 0, + "multiple": 3, + "profiledFor": { + "mutation": 1842, + "cna": 1842, + "sv": 1842 + }, + "count": 38 + }, + "perGene": [ + { + "gene": "KRAS", + "groups": [ + { + "key": "pancreatic cancer", + "label": "Pancreatic Cancer", + "samples": 2729, + "profiled": 2729, + "altered": 2249, + "mutation": 2199, + "amp": 2, + "homdel": 0, + "sv": 0, + "multiple": 48, + "profiledFor": { + "mutation": 2729, + "cna": 2729, + "sv": 2729 + } + }, + { + "key": "appendiceal cancer", + "label": "Appendiceal Cancer", + "samples": 269, + "profiled": 269, + "altered": 157, + "mutation": 157, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 269, + "cna": 269, + "sv": 269 + } + }, + { + "key": "colorectal cancer", + "label": "Colorectal Cancer", + "samples": 4993, + "profiled": 4993, + "altered": 2233, + "mutation": 2181, + "amp": 41, + "homdel": 0, + "sv": 1, + "multiple": 10, + "profiledFor": { + "mutation": 4993, + "cna": 4993, + "sv": 4993 + } + }, + { + "key": "non-small cell lung cancer", + "label": "Non-Small Cell Lung Cancer", + "samples": 6633, + "profiled": 6633, + "altered": 2004, + "mutation": 1872, + "amp": 65, + "homdel": 6, + "sv": 0, + "multiple": 61, + "profiledFor": { + "mutation": 6633, + "cna": 6633, + "sv": 6633 + } + }, + { + "key": "germ cell tumor", + "label": "Germ Cell Tumor", + "samples": 663, + "profiled": 663, + "altered": 189, + "mutation": 60, + "amp": 113, + "homdel": 0, + "sv": 0, + "multiple": 16, + "profiledFor": { + "mutation": 663, + "cna": 663, + "sv": 663 + } + }, + { + "key": "cancer of unknown primary", + "label": "Cancer of Unknown Primary", + "samples": 1535, + "profiled": 1535, + "altered": 336, + "mutation": 306, + "amp": 19, + "homdel": 0, + "sv": 1, + "multiple": 10, + "profiledFor": { + "mutation": 1535, + "cna": 1535, + "sv": 1535 + } + }, + { + "key": "endometrial cancer", + "label": "Endometrial Cancer", + "samples": 2373, + "profiled": 2373, + "altered": 484, + "mutation": 466, + "amp": 16, + "homdel": 1, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 2373, + "cna": 2373, + "sv": 2373 + } + }, + { + "key": "esophagogastric cancer", + "label": "Esophagogastric Cancer", + "samples": 1671, + "profiled": 1671, + "altered": 283, + "mutation": 122, + "amp": 158, + "homdel": 0, + "sv": 0, + "multiple": 3, + "profiledFor": { + "mutation": 1671, + "cna": 1671, + "sv": 1671 + } + }, + { + "key": "hepatobiliary cancer", + "label": "Hepatobiliary Cancer", + "samples": 1353, + "profiled": 1353, + "altered": 160, + "mutation": 144, + "amp": 15, + "homdel": 0, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 1353, + "cna": 1353, + "sv": 1353 + } + }, + { + "key": "ovarian cancer", + "label": "Ovarian Cancer", + "samples": 2075, + "profiled": 2075, + "altered": 243, + "mutation": 166, + "amp": 70, + "homdel": 0, + "sv": 1, + "multiple": 6, + "profiledFor": { + "mutation": 2075, + "cna": 2075, + "sv": 2075 + } + }, + { + "key": "cervical cancer", + "label": "Cervical Cancer", + "samples": 326, + "profiled": 326, + "altered": 38, + "mutation": 35, + "amp": 1, + "homdel": 1, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 326, + "cna": 326, + "sv": 326 + } + }, + { + "key": "bladder cancer", + "label": "Bladder Cancer", + "samples": 2046, + "profiled": 2046, + "altered": 134, + "mutation": 113, + "amp": 18, + "homdel": 1, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 2046, + "cna": 2046, + "sv": 2046 + } + }, + { + "key": "head and neck cancer", + "label": "Head and Neck Cancer", + "samples": 610, + "profiled": 610, + "altered": 18, + "mutation": 11, + "amp": 7, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 610, + "cna": 610, + "sv": 610 + } + }, + { + "key": "small cell lung cancer", + "label": "Small Cell Lung Cancer", + "samples": 442, + "profiled": 442, + "altered": 13, + "mutation": 10, + "amp": 3, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 442, + "cna": 442, + "sv": 442 + } + }, + { + "key": "melanoma", + "label": "Melanoma", + "samples": 1706, + "profiled": 1706, + "altered": 49, + "mutation": 29, + "amp": 14, + "homdel": 0, + "sv": 0, + "multiple": 6, + "profiledFor": { + "mutation": 1706, + "cna": 1706, + "sv": 1706 + } + }, + { + "key": "bone cancer", + "label": "Bone Cancer", + "samples": 506, + "profiled": 506, + "altered": 14, + "mutation": 6, + "amp": 7, + "homdel": 1, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 506, + "cna": 506, + "sv": 506 + } + }, + { + "key": "thyroid cancer", + "label": "Thyroid Cancer", + "samples": 803, + "profiled": 803, + "altered": 20, + "mutation": 20, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 803, + "cna": 803, + "sv": 803 + } + }, + { + "key": "peripheral nervous system", + "label": "Peripheral Nervous System", + "samples": 324, + "profiled": 324, + "altered": 7, + "mutation": 5, + "amp": 2, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 324, + "cna": 324, + "sv": 324 + } + }, + { + "key": "skin cancer, non-melanoma", + "label": "Skin Cancer, Non-Melanoma", + "samples": 429, + "profiled": 429, + "altered": 9, + "mutation": 9, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 429, + "cna": 429, + "sv": 429 + } + }, + { + "key": "breast cancer", + "label": "Breast Cancer", + "samples": 5803, + "profiled": 5803, + "altered": 120, + "mutation": 53, + "amp": 61, + "homdel": 4, + "sv": 1, + "multiple": 1, + "profiledFor": { + "mutation": 5803, + "cna": 5803, + "sv": 5803 + } + }, + { + "…": "8 more", + "sha256": "67690ccb247396a1" + } + ], + "pooled": { + "key": "__pooled__", + "label": "38 smaller groups", + "samples": 1842, + "profiled": 1842, + "altered": 213, + "mutation": 203, + "amp": 8, + "homdel": 0, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 1842, + "cna": 1842, + "sv": 1842 + }, + "count": 38 + } + }, + { + "gene": "NRAS", + "groups": [ + { + "key": "melanoma", + "label": "Melanoma", + "samples": 1706, + "profiled": 1706, + "altered": 416, + "mutation": 388, + "amp": 3, + "homdel": 2, + "sv": 0, + "multiple": 23, + "profiledFor": { + "mutation": 1706, + "cna": 1706, + "sv": 1706 + } + }, + { + "key": "thyroid cancer", + "label": "Thyroid Cancer", + "samples": 803, + "profiled": 803, + "altered": 119, + "mutation": 117, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 803, + "cna": 803, + "sv": 803 + } + }, + { + "key": "colorectal cancer", + "label": "Colorectal Cancer", + "samples": 4993, + "profiled": 4993, + "altered": 218, + "mutation": 206, + "amp": 6, + "homdel": 6, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 4993, + "cna": 4993, + "sv": 4993 + } + }, + { + "key": "germ cell tumor", + "label": "Germ Cell Tumor", + "samples": 663, + "profiled": 663, + "altered": 21, + "mutation": 20, + "amp": 1, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 663, + "cna": 663, + "sv": 663 + } + }, + { + "key": "endometrial cancer", + "label": "Endometrial Cancer", + "samples": 2373, + "profiled": 2373, + "altered": 71, + "mutation": 70, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 2373, + "cna": 2373, + "sv": 2373 + } + }, + { + "key": "cancer of unknown primary", + "label": "Cancer of Unknown Primary", + "samples": 1535, + "profiled": 1535, + "altered": 44, + "mutation": 34, + "amp": 6, + "homdel": 3, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 1535, + "cna": 1535, + "sv": 1535 + } + }, + { + "key": "appendiceal cancer", + "label": "Appendiceal Cancer", + "samples": 269, + "profiled": 269, + "altered": 6, + "mutation": 6, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 269, + "cna": 269, + "sv": 269 + } + }, + { + "key": "hepatobiliary cancer", + "label": "Hepatobiliary Cancer", + "samples": 1353, + "profiled": 1353, + "altered": 30, + "mutation": 29, + "amp": 1, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 1353, + "cna": 1353, + "sv": 1353 + } + }, + { + "key": "skin cancer, non-melanoma", + "label": "Skin Cancer, Non-Melanoma", + "samples": 429, + "profiled": 429, + "altered": 9, + "mutation": 7, + "amp": 0, + "homdel": 2, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 429, + "cna": 429, + "sv": 429 + } + }, + { + "key": "bladder cancer", + "label": "Bladder Cancer", + "samples": 2046, + "profiled": 2046, + "altered": 39, + "mutation": 27, + "amp": 10, + "homdel": 1, + "sv": 1, + "multiple": 0, + "profiledFor": { + "mutation": 2046, + "cna": 2046, + "sv": 2046 + } + }, + { + "key": "ovarian cancer", + "label": "Ovarian Cancer", + "samples": 2075, + "profiled": 2075, + "altered": 39, + "mutation": 32, + "amp": 6, + "homdel": 0, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 2075, + "cna": 2075, + "sv": 2075 + } + }, + { + "key": "mesothelioma", + "label": "Mesothelioma", + "samples": 382, + "profiled": 382, + "altered": 6, + "mutation": 5, + "amp": 0, + "homdel": 1, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 382, + "cna": 382, + "sv": 382 + } + }, + { + "key": "soft tissue sarcoma", + "label": "Soft Tissue Sarcoma", + "samples": 2128, + "profiled": 2128, + "altered": 33, + "mutation": 28, + "amp": 3, + "homdel": 1, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 2128, + "cna": 2128, + "sv": 2128 + } + }, + { + "key": "cervical cancer", + "label": "Cervical Cancer", + "samples": 326, + "profiled": 326, + "altered": 5, + "mutation": 5, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 326, + "cna": 326, + "sv": 326 + } + }, + { + "key": "uterine sarcoma", + "label": "Uterine Sarcoma", + "samples": 337, + "profiled": 337, + "altered": 5, + "mutation": 3, + "amp": 2, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 337, + "cna": 337, + "sv": 337 + } + }, + { + "key": "esophagogastric cancer", + "label": "Esophagogastric Cancer", + "samples": 1671, + "profiled": 1671, + "altered": 24, + "mutation": 10, + "amp": 10, + "homdel": 3, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 1671, + "cna": 1671, + "sv": 1671 + } + }, + { + "key": "peripheral nervous system", + "label": "Peripheral Nervous System", + "samples": 324, + "profiled": 324, + "altered": 4, + "mutation": 3, + "amp": 1, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 324, + "cna": 324, + "sv": 324 + } + }, + { + "key": "non-small cell lung cancer", + "label": "Non-Small Cell Lung Cancer", + "samples": 6633, + "profiled": 6633, + "altered": 80, + "mutation": 67, + "amp": 5, + "homdel": 6, + "sv": 1, + "multiple": 1, + "profiledFor": { + "mutation": 6633, + "cna": 6633, + "sv": 6633 + } + }, + { + "key": "head and neck cancer", + "label": "Head and Neck Cancer", + "samples": 610, + "profiled": 610, + "altered": 6, + "mutation": 6, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 610, + "cna": 610, + "sv": 610 + } + }, + { + "key": "small cell lung cancer", + "label": "Small Cell Lung Cancer", + "samples": 442, + "profiled": 442, + "altered": 4, + "mutation": 3, + "amp": 0, + "homdel": 1, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 442, + "cna": 442, + "sv": 442 + } + }, + { + "…": "8 more", + "sha256": "98fc00fd9877bd84" + } + ], + "pooled": { + "key": "__pooled__", + "label": "38 smaller groups", + "samples": 1842, + "profiled": 1842, + "altered": 17, + "mutation": 16, + "amp": 0, + "homdel": 1, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 1842, + "cna": 1842, + "sv": 1842 + }, + "count": 38 + } + }, + { + "gene": "HRAS", + "groups": [ + { + "key": "salivary gland cancer", + "label": "Salivary Gland Cancer", + "samples": 352, + "profiled": 352, + "altered": 24, + "mutation": 22, + "amp": 1, + "homdel": 0, + "sv": 0, + "multiple": 1, + "profiledFor": { + "mutation": 352, + "cna": 352, + "sv": 352 + } + }, + { + "key": "skin cancer, non-melanoma", + "label": "Skin Cancer, Non-Melanoma", + "samples": 429, + "profiled": 429, + "altered": 23, + "mutation": 23, + "amp": 0, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 429, + "cna": 429, + "sv": 429 + } + }, + { + "key": "bladder cancer", + "label": "Bladder Cancer", + "samples": 2046, + "profiled": 2046, + "altered": 99, + "mutation": 88, + "amp": 0, + "homdel": 11, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 2046, + "cna": 2046, + "sv": 2046 + } + }, + { + "key": "thyroid cancer", + "label": "Thyroid Cancer", + "samples": 803, + "profiled": 803, + "altered": 34, + "mutation": 28, + "amp": 2, + "homdel": 1, + "sv": 0, + "multiple": 3, + "profiledFor": { + "mutation": 803, + "cna": 803, + "sv": 803 + } + }, + { + "key": "head and neck cancer", + "label": "Head and Neck Cancer", + "samples": 610, + "profiled": 610, + "altered": 23, + "mutation": 22, + "amp": 1, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 610, + "cna": 610, + "sv": 610 + } + }, + { + "key": "melanoma", + "label": "Melanoma", + "samples": 1706, + "profiled": 1706, + "altered": 48, + "mutation": 42, + "amp": 1, + "homdel": 2, + "sv": 0, + "multiple": 3, + "profiledFor": { + "mutation": 1706, + "cna": 1706, + "sv": 1706 + } + }, + { + "key": "small cell lung cancer", + "label": "Small Cell Lung Cancer", + "samples": 442, + "profiled": 442, + "altered": 10, + "mutation": 4, + "amp": 1, + "homdel": 5, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 442, + "cna": 442, + "sv": 442 + } + }, + { + "key": "soft tissue sarcoma", + "label": "Soft Tissue Sarcoma", + "samples": 2128, + "profiled": 2128, + "altered": 33, + "mutation": 11, + "amp": 9, + "homdel": 13, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 2128, + "cna": 2128, + "sv": 2128 + } + }, + { + "key": "prostate cancer", + "label": "Prostate Cancer", + "samples": 2893, + "profiled": 2893, + "altered": 44, + "mutation": 35, + "amp": 1, + "homdel": 7, + "sv": 1, + "multiple": 0, + "profiledFor": { + "mutation": 2893, + "cna": 2893, + "sv": 2893 + } + }, + { + "key": "uterine sarcoma", + "label": "Uterine Sarcoma", + "samples": 337, + "profiled": 337, + "altered": 5, + "mutation": 0, + "amp": 2, + "homdel": 3, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 337, + "cna": 337, + "sv": 337 + } + }, + { + "key": "cancer of unknown primary", + "label": "Cancer of Unknown Primary", + "samples": 1535, + "profiled": 1535, + "altered": 19, + "mutation": 12, + "amp": 2, + "homdel": 5, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 1535, + "cna": 1535, + "sv": 1535 + } + }, + { + "key": "cervical cancer", + "label": "Cervical Cancer", + "samples": 326, + "profiled": 326, + "altered": 4, + "mutation": 3, + "amp": 0, + "homdel": 1, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 326, + "cna": 326, + "sv": 326 + } + }, + { + "key": "endometrial cancer", + "label": "Endometrial Cancer", + "samples": 2373, + "profiled": 2373, + "altered": 29, + "mutation": 19, + "amp": 4, + "homdel": 6, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 2373, + "cna": 2373, + "sv": 2373 + } + }, + { + "key": "glioma", + "label": "Glioma", + "samples": 2042, + "profiled": 2042, + "altered": 20, + "mutation": 7, + "amp": 2, + "homdel": 11, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 2042, + "cna": 2042, + "sv": 2042 + } + }, + { + "key": "ovarian cancer", + "label": "Ovarian Cancer", + "samples": 2075, + "profiled": 2075, + "altered": 20, + "mutation": 5, + "amp": 2, + "homdel": 13, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 2075, + "cna": 2075, + "sv": 2075 + } + }, + { + "key": "peripheral nervous system", + "label": "Peripheral Nervous System", + "samples": 324, + "profiled": 324, + "altered": 3, + "mutation": 2, + "amp": 0, + "homdel": 1, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 324, + "cna": 324, + "sv": 324 + } + }, + { + "key": "breast cancer", + "label": "Breast Cancer", + "samples": 5803, + "profiled": 5803, + "altered": 49, + "mutation": 20, + "amp": 2, + "homdel": 27, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 5803, + "cna": 5803, + "sv": 5803 + } + }, + { + "key": "gastrointestinal stromal tumor", + "label": "Gastrointestinal Stromal Tumor", + "samples": 520, + "profiled": 520, + "altered": 4, + "mutation": 0, + "amp": 0, + "homdel": 4, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 520, + "cna": 520, + "sv": 520 + } + }, + { + "key": "colorectal cancer", + "label": "Colorectal Cancer", + "samples": 4993, + "profiled": 4993, + "altered": 37, + "mutation": 33, + "amp": 4, + "homdel": 0, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 4993, + "cna": 4993, + "sv": 4993 + } + }, + { + "key": "non-small cell lung cancer", + "label": "Non-Small Cell Lung Cancer", + "samples": 6633, + "profiled": 6633, + "altered": 39, + "mutation": 24, + "amp": 3, + "homdel": 10, + "sv": 0, + "multiple": 2, + "profiledFor": { + "mutation": 6633, + "cna": 6633, + "sv": 6633 + } + }, + { + "…": "8 more", + "sha256": "2397ab07fdd60ed9" + } + ], + "pooled": { + "key": "__pooled__", + "label": "38 smaller groups", + "samples": 1842, + "profiled": 1842, + "altered": 21, + "mutation": 12, + "amp": 1, + "homdel": 8, + "sv": 0, + "multiple": 0, + "profiledFor": { + "mutation": 1842, + "cna": 1842, + "sv": 1842 + }, + "count": 38 + } + } + ] + } + ] + }, + "participation": { + "studies": [ + { + "study": "msk_impact_50k_2026", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Patients altered in at least one of 3 genes per CANCER_TYPE group, over the patients profiled for at least one of them (the union of their panels, as an oncoprint's merged row counts it). Any mutation, high-level copy-number change (amplification, deep deletion) or structural variant counts; low-level gains and losses do not. A patient with more than one kind of alteration across the genes counts once, under \"multiple\". A patient counts in every group one of their samples falls in, profiled if any of those samples is, altered if any is. CANCER_TYPE is read per sample and folded on case and whitespace; samples with no value form their own group. Groups with fewer than 200 profiled patients are pooled into one bar rather than dropped. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients per CANCER_TYPE group", + "detail": "The cancertypes queries above. Per group, for the genes together and for each gene: the patients profiled for it, and of those the patients with any mutation, amplification, deep deletion or structural variant, split by kind (one kind only, or more than one); and the whole cohort's, each patient once. A patient counts in each group one of their samples is in, profiled if any of those samples is, altered if any is. Per group too, how many were profiled for mutations, copy number and structural variants at all. Counts only.", + "scope": "all patients · msk_impact_50k_2026", + "rowsOut": 67, + "params": [ + [ + "genes", + "KRAS, NRAS, HRAS" + ], + [ + "profiled patients", + "48,892" + ] + ] + }, + { + "kind": "transform", + "title": "Pool the small groups", + "scope": "all patients", + "detail": "38 groups with fewer than 200 profiled patients drawn as one pooled bar; 28 drawn on their own.", + "params": [ + [ + "profiled", + "48,179" + ], + [ + "altered", + "10,796" + ] + ] + } + ], + "implementation": { + "functions": [], + "file": "lib/views/cancertypes.ts", + "commit": null + } + } + } + ] +} diff --git a/test/snapshots/cancertypes.sql b/test/snapshots/cancertypes.sql new file mode 100644 index 0000000..417d119 --- /dev/null +++ b/test/snapshots/cancertypes.sql @@ -0,0 +1,78 @@ +-- cohort all patients +-- msk_impact_50k_2026 +SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' + +-- view 0 cancertypes: cancertypes:all patients · msk_impact_50k_2026 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026'), +samp AS ( + SELECT sample_unique_id AS suid, patient_unique_id AS puid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +grp AS ( + SELECT sample_unique_id AS suid, any(lowerUTF8(trimBoth(attribute_value))) AS g, any(attribute_value) AS label FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'CANCER_TYPE' + AND sample_unique_id IN (SELECT suid FROM samp) GROUP BY suid +), +alt AS ( + SELECT g.sample_unique_id AS suid, g.hugo_gene_symbol AS gene, + multiIf(g.variant_type = 'mutation', 'mutation', g.variant_type = 'cna' AND g.cna_alteration >= 2, 'amp', + g.variant_type = 'cna', 'homdel', 'sv') AS t + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_impact_50k_2026' AND g.hugo_gene_symbol IN ('KRAS','NRAS','HRAS') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM samp) + GROUP BY suid, gene, t +), +cov AS ( + SELECT DISTINCT sp.sample_unique_id AS suid, pg.gene AS gene FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('KRAS','NRAS','HRAS') + WHERE sp.cancer_study_identifier = 'msk_impact_50k_2026' AND sp.sample_unique_id IN (SELECT suid FROM samp) + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + UNION DISTINCT SELECT DISTINCT suid, gene FROM alt +), +sg AS ( + SELECT cov.suid AS suid, cov.gene AS gene, groupUniqArrayIf(alt.t, alt.t != '') AS types + FROM cov LEFT JOIN alt ON alt.suid = cov.suid AND alt.gene = cov.gene GROUP BY suid, gene +), +sg2 AS (SELECT suid, gene, types FROM sg UNION ALL SELECT suid, '*' AS gene, arrayDistinct(arrayFlatten(groupArray(types))) AS types FROM sg GROUP BY suid), +u AS ( + SELECT samp.puid AS k, ifNull(grp.g, '') AS g, any(ifNull(grp.label, '')) AS label, sg2.gene AS gene, + arrayDistinct(arrayFlatten(groupArray(sg2.types))) AS types + FROM sg2 JOIN samp ON samp.suid = sg2.suid LEFT JOIN grp ON grp.suid = sg2.suid + GROUP BY k, g, gene +), +uall AS (SELECT k, '\x01all' AS g, '' AS label, gene, arrayDistinct(arrayFlatten(groupArray(types))) AS types FROM u GROUP BY k, gene), +uu AS (SELECT k, g, label, gene, types FROM u UNION ALL SELECT k, g, label, gene, types FROM uall) +SELECT g AS grp, gene, any(label) AS label, count() AS profiled, + countIf(length(types) > 0) AS altered, + countIf(types = ['mutation']) AS mutation, countIf(types = ['amp']) AS amp, + countIf(types = ['homdel']) AS homdel, countIf(types = ['sv']) AS sv, + countIf(length(types) > 1) AS multiple +FROM uu GROUP BY grp, gene + +-- view 0 cancertypes: cancertypes:samples:all patients · msk_impact_50k_2026 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026'), +samp AS ( + SELECT sample_unique_id AS suid, patient_unique_id AS puid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +prof AS ( + SELECT sample_unique_id AS suid, groupUniqArray(alteration_type) AS types FROM snapshot_db.sample_to_gene_panel_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND sample_unique_id IN (SELECT suid FROM samp) GROUP BY suid +) +SELECT ifNull(grp.g, '') AS grp, uniqExact(samp.puid) AS samples, + uniqExactIf(samp.puid, has(prof.types, 'MUTATION_EXTENDED')) AS mut, + uniqExactIf(samp.puid, has(prof.types, 'COPY_NUMBER_ALTERATION')) AS cna, + uniqExactIf(samp.puid, has(prof.types, 'STRUCTURAL_VARIANT')) AS sv +FROM samp LEFT JOIN prof ON prof.suid = samp.suid +LEFT JOIN ( + SELECT sample_unique_id AS suid, any(lowerUTF8(trimBoth(attribute_value))) AS g FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'CANCER_TYPE' + AND sample_unique_id IN (SELECT suid FROM samp) GROUP BY suid +) grp ON grp.suid = samp.suid +GROUP BY grp +UNION ALL SELECT '\x01all' AS grp, uniqExact(samp.puid), uniqExactIf(samp.puid, has(prof.types, 'MUTATION_EXTENDED')), + uniqExactIf(samp.puid, has(prof.types, 'COPY_NUMBER_ALTERATION')), uniqExactIf(samp.puid, has(prof.types, 'STRUCTURAL_VARIANT')) +FROM samp LEFT JOIN prof ON prof.suid = samp.suid diff --git a/test/snapshots/cancertypes.svg b/test/snapshots/cancertypes.svg new file mode 100644 index 0000000..4f673da --- /dev/null +++ b/test/snapshots/cancertypes.svg @@ -0,0 +1,2 @@ + +Cancer types summary — KRAS, NRAS, HRASall patients10,796 of 48,179 profiled patients altered (22.4%)0%20%40%60%80%100%Alteration FrequencyPancreatic Cancer — Mutation: 2,211 of 2,729 profiled patientsPancreatic Cancer — Amplification: 3 of 2,729 profiled patientsPancreatic Cancer — Multiple Alterations: 49 of 2,729 profiled patientsPancreatic Cancer: 82.9% (2,263 / 2,729 patients)Appendiceal Cancer — Mutation: 163 of 269 profiled patientsAppendiceal Cancer: 60.6% (163 / 269 patients)Colorectal Cancer — Mutation: 2,383 of 4,993 profiled patientsColorectal Cancer — Amplification: 48 of 4,993 profiled patientsColorectal Cancer — Deep Deletion: 4 of 4,993 profiled patientsColorectal Cancer — Structural Variant: 1 of 4,993 profiled patientsColorectal Cancer — Multiple Alterations: 14 of 4,993 profiled patientsColorectal Cancer: 49.1% (2,450 / 4,993 patients)Non-Small Cell Lung Cancer — Mutation: 1,943 of 6,633 profiled patientsNon-Small Cell Lung Cancer — Amplification: 71 of 6,633 profiled patientsNon-Small Cell Lung Cancer — Deep Deletion: 20 of 6,633 profiled patientsNon-Small Cell Lung Cancer — Structural Variant: 1 of 6,633 profiled patientsNon-Small Cell Lung Cancer — Multiple Alterations: 68 of 6,633 profiled patientsNon-Small Cell Lung Cancer: 31.7% (2,103 / 6,633 patients)Germ Cell Tumor — Mutation: 78 of 663 profiled patientsGerm Cell Tumor — Amplification: 114 of 663 profiled patientsGerm Cell Tumor — Multiple Alterations: 16 of 663 profiled patientsGerm Cell Tumor: 31.4% (208 / 663 patients)Melanoma — Mutation: 452 of 1,706 profiled patientsMelanoma — Amplification: 17 of 1,706 profiled patientsMelanoma — Deep Deletion: 4 of 1,706 profiled patientsMelanoma — Multiple Alterations: 33 of 1,706 profiled patientsMelanoma: 29.7% (506 / 1,706 patients)Cancer of Unknown Primary — Mutation: 348 of 1,535 profiled patientsCancer of Unknown Primary — Amplification: 25 of 1,535 profiled patientsCancer of Unknown Primary — Deep Deletion: 7 of 1,535 profiled patientsCancer of Unknown Primary — Structural Variant: 1 of 1,535 profiled patientsCancer of Unknown Primary — Multiple Alterations: 14 of 1,535 profiled patientsCancer of Unknown Primary: 25.7% (395 / 1,535 patients)Endometrial Cancer — Mutation: 541 of 2,373 profiled patientsEndometrial Cancer — Amplification: 19 of 2,373 profiled patientsEndometrial Cancer — Deep Deletion: 6 of 2,373 profiled patientsEndometrial Cancer — Multiple Alterations: 4 of 2,373 profiled patientsEndometrial Cancer: 24.0% (570 / 2,373 patients)Thyroid Cancer — Mutation: 164 of 803 profiled patientsThyroid Cancer — Amplification: 2 of 803 profiled patientsThyroid Cancer — Deep Deletion: 1 of 803 profiled patientsThyroid Cancer — Multiple Alterations: 5 of 803 profiled patientsThyroid Cancer: 21.4% (172 / 803 patients)Esophagogastric Cancer — Mutation: 134 of 1,671 profiled patientsEsophagogastric Cancer — Amplification: 169 of 1,671 profiled patientsEsophagogastric Cancer — Deep Deletion: 3 of 1,671 profiled patientsEsophagogastric Cancer — Multiple Alterations: 5 of 1,671 profiled patientsEsophagogastric Cancer: 18.6% (311 / 1,671 patients)Ovarian Cancer — Mutation: 199 of 2,075 profiled patientsOvarian Cancer — Amplification: 75 of 2,075 profiled patientsOvarian Cancer — Deep Deletion: 13 of 2,075 profiled patientsOvarian Cancer — Structural Variant: 1 of 2,075 profiled patientsOvarian Cancer — Multiple Alterations: 9 of 2,075 profiled patientsOvarian Cancer: 14.3% (297 / 2,075 patients)Hepatobiliary Cancer — Mutation: 173 of 1,353 profiled patientsHepatobiliary Cancer — Amplification: 16 of 1,353 profiled patientsHepatobiliary Cancer — Multiple Alterations: 2 of 1,353 profiled patientsHepatobiliary Cancer: 14.1% (191 / 1,353 patients)Cervical Cancer — Mutation: 40 of 326 profiled patientsCervical Cancer — Deep Deletion: 2 of 326 profiled patientsCervical Cancer — Multiple Alterations: 2 of 326 profiled patientsCervical Cancer: 13.5% (44 / 326 patients)Bladder Cancer — Mutation: 215 of 2,046 profiled patientsBladder Cancer — Amplification: 27 of 2,046 profiled patientsBladder Cancer — Deep Deletion: 13 of 2,046 profiled patientsBladder Cancer — Structural Variant: 1 of 2,046 profiled patientsBladder Cancer — Multiple Alterations: 3 of 2,046 profiled patientsBladder Cancer: 12.7% (259 / 2,046 patients)Skin Cancer, Non-Melanoma — Mutation: 38 of 429 profiled patientsSkin Cancer, Non-Melanoma — Deep Deletion: 2 of 429 profiled patientsSkin Cancer, Non-Melanoma: 9.3% (40 / 429 patients)Salivary Gland Cancer — Mutation: 24 of 352 profiled patientsSalivary Gland Cancer — Amplification: 3 of 352 profiled patientsSalivary Gland Cancer — Multiple Alterations: 2 of 352 profiled patientsSalivary Gland Cancer: 8.2% (29 / 352 patients)Head and Neck Cancer — Mutation: 39 of 610 profiled patientsHead and Neck Cancer — Amplification: 8 of 610 profiled patientsHead and Neck Cancer: 7.7% (47 / 610 patients)Small Cell Lung Cancer — Mutation: 17 of 442 profiled patientsSmall Cell Lung Cancer — Amplification: 4 of 442 profiled patientsSmall Cell Lung Cancer — Deep Deletion: 6 of 442 profiled patientsSmall Cell Lung Cancer: 6.1% (27 / 442 patients)Soft Tissue Sarcoma — Mutation: 63 of 2,128 profiled patientsSoft Tissue Sarcoma — Amplification: 17 of 2,128 profiled patientsSoft Tissue Sarcoma — Deep Deletion: 15 of 2,128 profiled patientsSoft Tissue Sarcoma — Structural Variant: 1 of 2,128 profiled patientsSoft Tissue Sarcoma — Multiple Alterations: 7 of 2,128 profiled patientsSoft Tissue Sarcoma: 4.8% (103 / 2,128 patients)Uterine Sarcoma — Mutation: 7 of 337 profiled patientsUterine Sarcoma — Amplification: 4 of 337 profiled patientsUterine Sarcoma — Deep Deletion: 3 of 337 profiled patientsUterine Sarcoma — Multiple Alterations: 1 of 337 profiled patientsUterine Sarcoma: 4.5% (15 / 337 patients)Peripheral Nervous System — Mutation: 10 of 324 profiled patientsPeripheral Nervous System — Amplification: 2 of 324 profiled patientsPeripheral Nervous System — Deep Deletion: 1 of 324 profiled patientsPeripheral Nervous System: 4.0% (13 / 324 patients)Glioma — Mutation: 40 of 2,042 profiled patientsGlioma — Amplification: 21 of 2,042 profiled patientsGlioma — Deep Deletion: 11 of 2,042 profiled patientsGlioma — Structural Variant: 1 of 2,042 profiled patientsGlioma — Multiple Alterations: 4 of 2,042 profiled patientsGlioma: 3.8% (77 / 2,042 patients)Bone Cancer — Mutation: 8 of 506 profiled patientsBone Cancer — Amplification: 8 of 506 profiled patientsBone Cancer — Deep Deletion: 2 of 506 profiled patientsBone Cancer: 3.6% (18 / 506 patients)Breast Cancer — Mutation: 80 of 5,803 profiled patientsBreast Cancer — Amplification: 78 of 5,803 profiled patientsBreast Cancer — Deep Deletion: 33 of 5,803 profiled patientsBreast Cancer — Structural Variant: 1 of 5,803 profiled patientsBreast Cancer — Multiple Alterations: 3 of 5,803 profiled patientsBreast Cancer: 3.4% (195 / 5,803 patients)Prostate Cancer — Mutation: 62 of 2,893 profiled patientsProstate Cancer — Amplification: 11 of 2,893 profiled patientsProstate Cancer — Deep Deletion: 12 of 2,893 profiled patientsProstate Cancer — Structural Variant: 1 of 2,893 profiled patientsProstate Cancer: 3.0% (86 / 2,893 patients)Mesothelioma — Mutation: 5 of 382 profiled patientsMesothelioma — Deep Deletion: 2 of 382 profiled patientsMesothelioma — Multiple Alterations: 1 of 382 profiled patientsMesothelioma: 2.1% (8 / 382 patients)Gastrointestinal Stromal Tumor — Mutation: 2 of 520 profiled patientsGastrointestinal Stromal Tumor — Deep Deletion: 6 of 520 profiled patientsGastrointestinal Stromal Tumor — Multiple Alterations: 1 of 520 profiled patientsGastrointestinal Stromal Tumor: 1.7% (9 / 520 patients)Renal Cell Carcinoma — Mutation: 17 of 1,107 profiled patientsRenal Cell Carcinoma — Multiple Alterations: 1 of 1,107 profiled patientsRenal Cell Carcinoma: 1.6% (18 / 1,107 patients)38 smaller groups — Mutation: 231 of 1,842 profiled patients38 smaller groups — Amplification: 8 of 1,842 profiled patients38 smaller groups — Deep Deletion: 8 of 1,842 profiled patients38 smaller groups — Multiple Alterations: 3 of 1,842 profiled patients38 smaller groups: 13.6% (250 / 1,842 patients)Pancreatic CancerAppendiceal CancerColorectal CancerNon-Small Cell Lung CancerGerm Cell TumorMelanomaCancer of Unknown PrimaryEndometrial CancerThyroid CancerEsophagogastric CancerOvarian CancerHepatobiliary CancerCervical CancerBladder CancerSkin Cancer, Non-MelanomaSalivary Gland CancerHead and Neck CancerSmall Cell Lung CancerSoft Tissue SarcomaUterine SarcomaPeripheral Nervous SystemGliomaBone CancerBreast CancerProstate CancerMesotheliomaGastrointestinal Stromal TumorRenal Cell Carcinoma38 smaller groupsMutationAmplificationDeep DeletionStructural VariantMultiple AlterationsEvery group was profiled for mutation, CNA and structural variant data.Patients altered in at least one of 3 genes per CANCER_TYPE group, over the patients profiled for at least one of them (the union of their panels, as an oncoprint's mergedrow counts it). Any mutation, high-level copy-number change (amplification, deep deletion) or structural variant counts; low-level gains and losses do not. A patient withmore than one kind of alteration across the genes counts once, under "multiple". A patient counts in every group one of their samples falls in, profiled if any of thosesamples is, altered if any is. CANCER_TYPE is read per sample and folded on case and whitespace; samples with no value form their own group. Groups with fewer than200 profiled patients are pooled into one bar rather than dropped. diff --git a/test/snapshots/cancertypes.txt b/test/snapshots/cancertypes.txt new file mode 100644 index 0000000..1202dbc --- /dev/null +++ b/test/snapshots/cancertypes.txt @@ -0,0 +1,44 @@ +Analysis over msk_impact_50k_2026 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- all patients: 48,179 patients — all patients in the study + +Cancer types summary: KRAS, NRAS, HRAS by CANCER_TYPE (any alteration; samples profiled for at least one gene): + all patients: 10,796 of 48,179 profiled samples altered + Pancreatic Cancer: 82.9% (2263/2729; mutation 2211, amp 3, deep del 0, SV 0, multiple 49) + Appendiceal Cancer: 60.6% (163/269; mutation 163, amp 0, deep del 0, SV 0, multiple 0) + Colorectal Cancer: 49.1% (2450/4993; mutation 2383, amp 48, deep del 4, SV 1, multiple 14) + Non-Small Cell Lung Cancer: 31.7% (2103/6633; mutation 1943, amp 71, deep del 20, SV 1, multiple 68) + Germ Cell Tumor: 31.4% (208/663; mutation 78, amp 114, deep del 0, SV 0, multiple 16) + Melanoma: 29.7% (506/1706; mutation 452, amp 17, deep del 4, SV 0, multiple 33) + Cancer of Unknown Primary: 25.7% (395/1535; mutation 348, amp 25, deep del 7, SV 1, multiple 14) + Endometrial Cancer: 24.0% (570/2373; mutation 541, amp 19, deep del 6, SV 0, multiple 4) + Thyroid Cancer: 21.4% (172/803; mutation 164, amp 2, deep del 1, SV 0, multiple 5) + Esophagogastric Cancer: 18.6% (311/1671; mutation 134, amp 169, deep del 3, SV 0, multiple 5) + Ovarian Cancer: 14.3% (297/2075; mutation 199, amp 75, deep del 13, SV 1, multiple 9) + Hepatobiliary Cancer: 14.1% (191/1353; mutation 173, amp 16, deep del 0, SV 0, multiple 2) + Cervical Cancer: 13.5% (44/326; mutation 40, amp 0, deep del 2, SV 0, multiple 2) + Bladder Cancer: 12.7% (259/2046; mutation 215, amp 27, deep del 13, SV 1, multiple 3) + Skin Cancer, Non-Melanoma: 9.3% (40/429; mutation 38, amp 0, deep del 2, SV 0, multiple 0) + Salivary Gland Cancer: 8.2% (29/352; mutation 24, amp 3, deep del 0, SV 0, multiple 2) + Head and Neck Cancer: 7.7% (47/610; mutation 39, amp 8, deep del 0, SV 0, multiple 0) + Small Cell Lung Cancer: 6.1% (27/442; mutation 17, amp 4, deep del 6, SV 0, multiple 0) + Soft Tissue Sarcoma: 4.8% (103/2128; mutation 63, amp 17, deep del 15, SV 1, multiple 7) + Uterine Sarcoma: 4.5% (15/337; mutation 7, amp 4, deep del 3, SV 0, multiple 1) + Peripheral Nervous System: 4.0% (13/324; mutation 10, amp 2, deep del 1, SV 0, multiple 0) + Glioma: 3.8% (77/2042; mutation 40, amp 21, deep del 11, SV 1, multiple 4) + Bone Cancer: 3.6% (18/506; mutation 8, amp 8, deep del 2, SV 0, multiple 0) + Breast Cancer: 3.4% (195/5803; mutation 80, amp 78, deep del 33, SV 1, multiple 3) + Prostate Cancer: 3.0% (86/2893; mutation 62, amp 11, deep del 12, SV 1, multiple 0) + Mesothelioma: 2.1% (8/382; mutation 5, amp 0, deep del 2, SV 0, multiple 1) + Gastrointestinal Stromal Tumor: 1.7% (9/520; mutation 2, amp 0, deep del 6, SV 0, multiple 1) + Renal Cell Carcinoma: 1.6% (18/1107; mutation 17, amp 0, deep del 0, SV 0, multiple 1) + 38 smaller groups: 13.6% (250/1842; mutation 231, amp 8, deep del 8, SV 0, multiple 3) + CAVEAT (tell the user): Patients altered in at least one of 3 genes per CANCER_TYPE group, over the patients profiled for at least one of them (the union of their panels, as an oncoprint's merged row counts it). Any mutation, high-level copy-number change (amplification, deep deletion) or structural variant counts; low-level gains and losses do not. A patient with more than one kind of alteration across the genes counts once, under "multiple". A patient counts in every group one of their samples falls in, profiled if any of those samples is, altered if any is. CANCER_TYPE is read per sample and folded on case and whitespace; samples with no value form their own group. Groups with fewer than 200 profiled patients are pooled into one bar rather than dropped. + METHOD: + - Count patients per CANCER_TYPE group [all patients · msk_impact_50k_2026]: The cancertypes queries above. Per group, for the genes together and for each gene: the patients profiled for it, and of those the patients with any mutation, amplification, deep deletion or structural variant, split by kind (one kind only, or more than one); and the whole cohort's, each patient once. A patient counts in each group one of their samples is in, profiled if any of those samples is, altered if any is. Per group too, how many were profiled for mutations, copy number and structural variants at all. Counts only. + genes: KRAS, NRAS, HRAS + profiled patients: 48,892 + - Pool the small groups [all patients]: 38 groups with fewer than 200 profiled patients drawn as one pooled bar; 28 drawn on their own. + profiled: 48,179 + altered: 10,796 diff --git a/test/snapshots/clinical.json b/test/snapshots/clinical.json new file mode 100644 index 0000000..b8a6db6 --- /dev/null +++ b/test/snapshots/clinical.json @@ -0,0 +1,254 @@ +{ + "study": "crc_apc_impact_2020", + "cohorts": { + "liver mets": { + "count": 227, + "text": "OQL[APC: MUT] AND METASTASIS_LIVER in [Yes]", + "studies": [ + "crc_apc_impact_2020" + ] + }, + "no liver mets": { + "count": 98, + "text": "OQL[APC: MUT] AND METASTASIS_LIVER in [No]", + "studies": [ + "crc_apc_impact_2020" + ] + } + }, + "views": [ + { + "kind": "clinical", + "cohorts": [ + "liver mets", + "no liver mets" + ], + "clinical": [ + { + "attribute": "MSI_SCORE", + "per": "sample", + "kind": "num", + "q": 0.06716509090323068, + "cells": [ + { + "cohort": "liver mets", + "n": 227, + "mean": 1.09, + "sd": 2.264, + "min": -1, + "max": 21.96, + "median": 0.6, + "q1": 0.26, + "q3": 1.29, + "histogramTruncated": false + }, + { + "cohort": "no liver mets", + "n": 98, + "mean": 2.892, + "sd": 8.147, + "min": 0, + "max": 48.45, + "median": 0.595, + "q1": 0.205, + "q3": 1.248, + "histogramTruncated": false + } + ], + "test": "Welch t", + "statistic": -2.1537, + "df": 103.52, + "p": 0.03358254545161534, + "rankStatistic": 10602, + "rankP": 0.5029628540374218 + }, + { + "attribute": "AGE_AT_MET", + "per": "patient", + "kind": "num", + "q": 0.7656913780960357, + "cells": [ + { + "cohort": "liver mets", + "n": 227, + "mean": 58.952, + "sd": 13.101, + "min": 23, + "max": 93, + "median": 59, + "q1": 51, + "q3": 68, + "histogramTruncated": false + }, + { + "cohort": "no liver mets", + "n": 98, + "mean": 59.439, + "sd": 13.677, + "min": 24, + "max": 95, + "median": 58.5, + "q1": 50.25, + "q3": 68.75, + "histogramTruncated": false + } + ], + "test": "Welch t", + "statistic": -0.2985, + "df": 177.14, + "p": 0.7656913780960357, + "rankStatistic": 11113.5, + "rankP": 0.9907597366429025 + } + ], + "studies": [ + "crc_apc_impact_2020" + ], + "participation": { + "studies": [ + { + "study": "crc_apc_impact_2020", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "Categorical attributes are compared with a Pearson chi-squared over the full value vocabulary; numeric ones with Welch's unequal-variance t-test (2 cohorts) or Welch's ANOVA (3+) computed from (n, Σx, Σx²) per cohort — those totals are ADDITIVE across sites, so the pooled mean and variance are exact from per-site aggregates and no individual value is ever transmitted. Counting unit follows the attribute: patients for patient-level, samples for sample-level. q-values are Benjamini–Hochberg across the 2 tested attributes. Numeric attributes also show median/IQR and a rank-based test alongside the moment-based one — a Mann-Whitney U for 2 cohorts, Kruskal-Wallis for 3+ (neither itself part of the q-value correction) — computed from the attribute's complete value distribution, which is only exact and only requested because this view is confined to a single study.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Describe each attribute", + "detail": "The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies), plus its complete value distribution as (value, count) pairs for the median, IQR and rank tests. Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database except as a count of how many share it.", + "scope": "liver mets · crc_apc_impact_2020", + "rowsIn": 227 + }, + { + "kind": "fetch", + "title": "Describe each attribute", + "detail": "The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies), plus its complete value distribution as (value, count) pairs for the median, IQR and rank tests. Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database except as a count of how many share it.", + "scope": "no liver mets · crc_apc_impact_2020", + "rowsIn": 98 + }, + { + "kind": "statistic", + "title": "Welch's t-test for each numeric attribute", + "detail": "Unequal-variance t from each cohort's n, mean and variance, with Welch–Satterthwaite degrees of freedom; two-sided. Mean and variance are from the summed moments: variance = (Σx² − (Σx)²/n) / (n − 1).", + "params": [ + [ + "MSI_SCORE", + "t -2.1537 on 103.52 df · p 0.0336" + ], + [ + "AGE_AT_MET", + "t -0.2985 on 177.14 df · p 0.766" + ] + ] + }, + { + "kind": "statistic", + "title": "Mann–Whitney U alongside", + "detail": "From each cohort's complete value distribution: ranks averaged within tied values, the variance tie-corrected, the normal approximation with a 0.5 continuity correction; two-sided. Medians and quartiles from the same distribution, interpolating linearly between ranks. A check against skew and outliers — not part of the q-value correction.", + "params": [ + [ + "MSI_SCORE", + "U 10602 · p 0.503" + ], + [ + "AGE_AT_MET", + "U 11113.5 · p 0.991" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across attributes", + "detail": "q-values over the 2 tested attributes, from the χ² and Welch p-values together." + } + ], + "implementation": { + "functions": [ + "welchT", + "mannWhitneyU", + "quantilesFromHistogram", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "χ² matches scipy 1.18.1 chi2_contingency; Welch's t scipy ttest_ind(equal_var=False) and Welch's ANOVA statsmodels 0.15.0 anova_generic from the same moments; Mann–Whitney, Kruskal–Wallis and quantiles scipy/numpy on the expanded distribution; Benjamini–Hochberg statsmodels multipletests — all to a relative 1e-6 (test/tables-golden.test.ts, test/moments-golden.test.ts).", + "check": { + "clinical:MSI_SCORE:p": { + "v": 0.03358254545161534 + }, + "clinical:MSI_SCORE:q": { + "v": 0.06716509090323068 + }, + "clinical:MSI_SCORE:rank_p": { + "v": 0.5029628540374218 + }, + "clinical:AGE_AT_MET:p": { + "v": 0.7656913780960357 + }, + "clinical:AGE_AT_MET:q": { + "v": 0.7656913780960357 + }, + "clinical:AGE_AT_MET:rank_p": { + "v": 0.9907597366429025 + }, + "clinical:MSI_SCORE:liver mets:median": { + "v": 0.6, + "abs": 0.000500001 + }, + "clinical:MSI_SCORE:liver mets:q1": { + "v": 0.26, + "abs": 0.000500001 + }, + "clinical:MSI_SCORE:liver mets:q3": { + "v": 1.29, + "abs": 0.000500001 + }, + "clinical:MSI_SCORE:no liver mets:median": { + "v": 0.595, + "abs": 0.000500001 + }, + "clinical:MSI_SCORE:no liver mets:q1": { + "v": 0.205, + "abs": 0.000500001 + }, + "clinical:MSI_SCORE:no liver mets:q3": { + "v": 1.248, + "abs": 0.000500001 + }, + "clinical:AGE_AT_MET:liver mets:median": { + "v": 59, + "abs": 0.000500001 + }, + "clinical:AGE_AT_MET:liver mets:q1": { + "v": 51, + "abs": 0.000500001 + }, + "clinical:AGE_AT_MET:liver mets:q3": { + "v": 68, + "abs": 0.000500001 + }, + "clinical:AGE_AT_MET:no liver mets:median": { + "v": 58.5, + "abs": 0.000500001 + }, + "clinical:AGE_AT_MET:no liver mets:q1": { + "v": 50.25, + "abs": 0.000500001 + }, + "clinical:AGE_AT_MET:no liver mets:q3": { + "v": 68.75, + "abs": 0.000500001 + } + } + } + } + ] +} diff --git a/test/snapshots/clinical.sql b/test/snapshots/clinical.sql new file mode 100644 index 0000000..0ececcc --- /dev/null +++ b/test/snapshots/clinical.sql @@ -0,0 +1,123 @@ +-- cohort liver mets +-- crc_apc_impact_2020 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'crc_apc_impact_2020' + AND g.hugo_gene_symbol = 'APC' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type = 'patient' + AND attribute_name = 'METASTASIS_LIVER' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Yes')))) + +-- cohort no liver mets +-- crc_apc_impact_2020 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'crc_apc_impact_2020' + AND g.hugo_gene_symbol = 'APC' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type = 'patient' + AND attribute_name = 'METASTASIS_LIVER' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('No')))) + +-- view 0 clinical: clinicalHistogram · crc_apc_impact_2020 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'crc_apc_impact_2020' + AND g.hugo_gene_symbol = 'APC' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type = 'patient' + AND attribute_name = 'METASTASIS_LIVER' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('No'))))), + raw AS ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' + AND attribute_name IN ('MSI_SCORE','AGE_AT_MET') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) + ) +SELECT a, per, x, count() AS n +FROM raw +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per, x +ORDER BY n DESC +LIMIT 20001 BY a, per + +-- view 0 clinical: clinicalHistogram · crc_apc_impact_2020 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'crc_apc_impact_2020' + AND g.hugo_gene_symbol = 'APC' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type = 'patient' + AND attribute_name = 'METASTASIS_LIVER' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Yes'))))), + raw AS ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' + AND attribute_name IN ('MSI_SCORE','AGE_AT_MET') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) + ) +SELECT a, per, x, count() AS n +FROM raw +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per, x +ORDER BY n DESC +LIMIT 20001 BY a, per + +-- view 0 clinical: clinicalMoments · crc_apc_impact_2020 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'crc_apc_impact_2020' + AND g.hugo_gene_symbol = 'APC' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type = 'patient' + AND attribute_name = 'METASTASIS_LIVER' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('No'))))) +SELECT a, per, count() AS n, sum(x) AS sx, sum(x * x) AS sxx, min(x) AS mn, max(x) AS mx +FROM ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' + AND attribute_name IN ('MSI_SCORE','AGE_AT_MET') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +) +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per + +-- view 0 clinical: clinicalMoments · crc_apc_impact_2020 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'crc_apc_impact_2020' + AND g.hugo_gene_symbol = 'APC' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type = 'patient' + AND attribute_name = 'METASTASIS_LIVER' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Yes'))))) +SELECT a, per, count() AS n, sum(x) AS sx, sum(x * x) AS sxx, min(x) AS mn, max(x) AS mx +FROM ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' + AND attribute_name IN ('MSI_SCORE','AGE_AT_MET') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +) +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per diff --git a/test/snapshots/clinical.svg b/test/snapshots/clinical.svg new file mode 100644 index 0000000..acea42c --- /dev/null +++ b/test/snapshots/clinical.svg @@ -0,0 +1,2 @@ + +Clinical comparison — −log₁₀ qClinical comparison — −log₁₀ qq < 0.05not significantMSI_SCOREWelch t · q = 0.067AGE_AT_METWelch t · q = 0.77q = 0.050.00.51.01.52.0−log₁₀ q (Benjamini–Hochberg) — longer is stronger evidence of a differenceCategorical attributes are compared with a Pearson chi-squared over the full value vocabulary; numeric ones with Welch's unequal-variance t-test (2cohorts) or Welch's ANOVA (3+) computed from (n, Σx, Σx²) per cohort — those totals are ADDITIVE across sites, so the pooled mean and variance are exactfrom per-site aggregates and no individual value is ever transmitted. Counting unit follows the attribute: patients for patient-level, samples for sample-level.q-values are Benjamini–Hochberg across the 2 tested attributes. Numeric attributes also show median/IQR and a rank-based test alongside themoment-based one — a Mann-Whitney U for 2 cohorts, Kruskal-Wallis for 3+ (neither itself part of the q-value correction) — computed from the attribute'scomplete value distribution, which is only exact and only requested because this view is confined to a single study. diff --git a/test/snapshots/clinical.txt b/test/snapshots/clinical.txt new file mode 100644 index 0000000..db1a95a --- /dev/null +++ b/test/snapshots/clinical.txt @@ -0,0 +1,21 @@ +Analysis over crc_apc_impact_2020 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- liver mets: 227 patients — OQL[APC: MUT] AND METASTASIS_LIVER in [Yes] +- no liver mets: 98 patients — OQL[APC: MUT] AND METASTASIS_LIVER in [No] + +Clinical comparison across cohorts: + MSI_SCORE [sample, num]: liver mets mean 1.09 sd 2.26 (n=227) | no liver mets mean 2.89 sd 8.15 (n=98) Welch t p=0.0336 q=0.0672 + AGE_AT_MET [patient, num]: liver mets mean 58.95 sd 13.10 (n=227) | no liver mets mean 59.44 sd 13.68 (n=98) Welch t p=0.7657 q=0.7657 + Categorical attributes are compared with a Pearson chi-squared over the full value vocabulary; numeric ones with Welch's unequal-variance t-test (2 cohorts) or Welch's ANOVA (3+) computed from (n, Σx, Σx²) per cohort — those totals are ADDITIVE across sites, so the pooled mean and variance are exact from per-site aggregates and no individual value is ever transmitted. Counting unit follows the attribute: patients for patient-level, samples for sample-level. q-values are Benjamini–Hochberg across the 2 tested attributes. Numeric attributes also show median/IQR and a rank-based test alongside the moment-based one — a Mann-Whitney U for 2 cohorts, Kruskal-Wallis for 3+ (neither itself part of the q-value correction) — computed from the attribute's complete value distribution, which is only exact and only requested because this view is confined to a single study. + METHOD: + - Describe each attribute [liver mets · crc_apc_impact_2020]: The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies), plus its complete value distribution as (value, count) pairs for the median, IQR and rank tests. Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database except as a count of how many share it. + - Describe each attribute [no liver mets · crc_apc_impact_2020]: The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies), plus its complete value distribution as (value, count) pairs for the median, IQR and rank tests. Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database except as a count of how many share it. + - Welch's t-test for each numeric attribute: Unequal-variance t from each cohort's n, mean and variance, with Welch–Satterthwaite degrees of freedom; two-sided. Mean and variance are from the summed moments: variance = (Σx² − (Σx)²/n) / (n − 1). + MSI_SCORE: t -2.1537 on 103.52 df · p 0.0336 + AGE_AT_MET: t -0.2985 on 177.14 df · p 0.766 + - Mann–Whitney U alongside: From each cohort's complete value distribution: ranks averaged within tied values, the variance tie-corrected, the normal approximation with a 0.5 continuity correction; two-sided. Medians and quartiles from the same distribution, interpolating linearly between ranks. A check against skew and outliers — not part of the q-value correction. + MSI_SCORE: U 10602 · p 0.503 + AGE_AT_MET: U 11113.5 · p 0.991 + - Benjamini–Hochberg across attributes: q-values over the 2 tested attributes, from the χ² and Welch p-values together. + χ² matches scipy 1.18.1 chi2_contingency; Welch's t scipy ttest_ind(equal_var=False) and Welch's ANOVA statsmodels 0.15.0 anova_generic from the same moments; Mann–Whitney, Kruskal–Wallis and quantiles scipy/numpy on the expanded distribution; Benjamini–Hochberg statsmodels multipletests — all to a relative 1e-6 (test/tables-golden.test.ts, test/moments-golden.test.ts). diff --git a/test/snapshots/clonality.json b/test/snapshots/clonality.json new file mode 100644 index 0000000..e9fcb27 --- /dev/null +++ b/test/snapshots/clonality.json @@ -0,0 +1,731 @@ +{ + "study": "msk_impact_50k_2026", + "cohorts": { + "Colorectal": { + "count": 4993, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample)", + "studies": [ + "msk_impact_50k_2026" + ] + }, + "Breast": { + "count": 5803, + "text": "CANCER_TYPE in [Breast Cancer] (any sample)", + "studies": [ + "msk_impact_50k_2026" + ] + } + }, + "views": [ + { + "kind": "clonality", + "cohorts": [ + "Colorectal", + "Breast" + ], + "clonality": { + "measure": "driver", + "qc": true, + "panels": [ + { + "cohort": "Colorectal", + "samples": 5395, + "ascnSamples": 5379, + "qcPass": 4912, + "qcFail": 451, + "wgd": { + "yes": 1749, + "no": 3163 + }, + "purity": [ + 0, + 1, + 114, + 171, + 335, + 503, + 522, + 410, + 514, + 453, + 459, + 454, + 295, + 269, + 135, + 117, + 79, + 51, + 27, + 3 + ], + "ploidy": [ + 0, + 0, + 1, + 1, + 1, + 6, + 98, + 328, + 1622, + 647, + 609, + 339, + 471, + 254, + 265, + 96, + 77, + 34, + 41, + 6, + { + "…": "12 more", + "sha256": "92b15c3938b83399" + } + ], + "genes": [ + { + "gene": "TP53", + "calls": 3839, + "samples": 3571, + "clonal": 3160, + "subclonal": 420, + "indeterminate": 255, + "uncalled": 4, + "loh": 2803, + "lohKnown": 3650, + "ccf": [ + 10, + 34, + 42, + 45, + 46, + 50, + 62, + 177, + 488, + 2879 + ], + "p": 0.5947092735836579, + "q": 0.5947092735836579 + }, + { + "gene": "KRAS", + "calls": 2145, + "samples": 2099, + "clonal": 1508, + "subclonal": 290, + "indeterminate": 346, + "uncalled": 1, + "loh": 423, + "lohKnown": 1973, + "ccf": [ + 2, + 18, + 18, + 22, + 30, + 48, + 66, + 185, + 446, + 1305 + ], + "p": 0.1286939990837484, + "q": 0.22521449839655971 + }, + { + "gene": "APC", + "calls": 5344, + "samples": 3577, + "clonal": 3889, + "subclonal": 897, + "indeterminate": 554, + "uncalled": 4, + "loh": 1748, + "lohKnown": 5217, + "ccf": [ + 0, + 9, + 28, + 100, + 121, + 139, + 267, + 577, + 1083, + 3011 + ], + "p": 0.5160703794843146, + "q": 0.5947092735836579 + }, + { + "gene": "PIK3CA", + "calls": 1018, + "samples": 917, + "clonal": 634, + "subclonal": 302, + "indeterminate": 82, + "uncalled": 0, + "loh": 117, + "lohKnown": 1010, + "ccf": [ + 10, + 42, + 35, + 25, + 41, + 45, + 52, + 97, + 134, + 537 + ], + "p": 4.394795388579005e-24, + "q": 3.076356772005303e-23 + }, + { + "gene": "SMAD4", + "calls": 673, + "samples": 621, + "clonal": 494, + "subclonal": 164, + "indeterminate": 15, + "uncalled": 0, + "loh": 526, + "lohKnown": 664, + "ccf": [ + 3, + 17, + 16, + 24, + 16, + 16, + 31, + 55, + 113, + 382 + ], + "p": 0.00601102198333149, + "q": 0.01402571796110681 + }, + { + "gene": "CDH1", + "calls": 62, + "samples": 55, + "clonal": 42, + "subclonal": 17, + "indeterminate": 3, + "uncalled": 0, + "loh": 10, + "lohKnown": 61, + "ccf": [ + 1, + 1, + 3, + 2, + 2, + 4, + 4, + 3, + 9, + 33 + ], + "p": 0.0028190005173689085, + "q": 0.00986650181079118 + }, + { + "gene": "GATA3", + "calls": 42, + "samples": 41, + "clonal": 28, + "subclonal": 12, + "indeterminate": 2, + "uncalled": 0, + "loh": 3, + "lohKnown": 42, + "ccf": [ + 0, + 0, + 1, + 2, + 3, + 2, + 3, + 3, + 12, + 16 + ], + "p": 0.23422973174670686, + "q": 0.32792162444538964 + } + ] + }, + { + "cohort": "Breast", + "samples": 6907, + "ascnSamples": 6703, + "qcPass": 6204, + "qcFail": 671, + "wgd": { + "yes": 2159, + "no": 4045 + }, + "purity": [ + 0, + 2, + 95, + 160, + 385, + 548, + 545, + 450, + 529, + 552, + 502, + 576, + 363, + 497, + 277, + 299, + 202, + 135, + 63, + 23 + ], + "ploidy": [ + 0, + 0, + 1, + 1, + 6, + 21, + 330, + 875, + 2071, + 548, + 565, + 352, + 508, + 300, + 295, + 120, + 104, + 38, + 35, + 11, + { + "…": "12 more", + "sha256": "8b7b77625894c711" + } + ], + "genes": [ + { + "gene": "TP53", + "calls": 2672, + "samples": 2615, + "clonal": 2188, + "subclonal": 278, + "indeterminate": 195, + "uncalled": 11, + "loh": 2198, + "lohKnown": 2467, + "ccf": [ + 25, + 23, + 29, + 20, + 17, + 39, + 31, + 129, + 395, + 1951 + ], + "p": 0.5947092735836579, + "q": 0.5947092735836579 + }, + { + "gene": "KRAS", + "calls": 59, + "samples": 59, + "clonal": 40, + "subclonal": 13, + "indeterminate": 6, + "uncalled": 0, + "loh": 9, + "lohKnown": 52, + "ccf": [ + 1, + 1, + 3, + 2, + 1, + 2, + 2, + 4, + 13, + 30 + ], + "p": 0.1286939990837484, + "q": 0.22521449839655971 + }, + { + "gene": "APC", + "calls": 39, + "samples": 35, + "clonal": 27, + "subclonal": 8, + "indeterminate": 4, + "uncalled": 0, + "loh": 16, + "lohKnown": 36, + "ccf": [ + 0, + 0, + 1, + 1, + 1, + 0, + 2, + 5, + 6, + 23 + ], + "p": 0.5160703794843146, + "q": 0.5947092735836579 + }, + { + "gene": "PIK3CA", + "calls": 2350, + "samples": 2130, + "clonal": 1793, + "subclonal": 334, + "indeterminate": 221, + "uncalled": 2, + "loh": 294, + "lohKnown": 2224, + "ccf": [ + 4, + 35, + 37, + 36, + 56, + 65, + 62, + 129, + 344, + 1579 + ], + "p": 4.394795388579005e-24, + "q": 3.076356772005303e-23 + }, + { + "gene": "SMAD4", + "calls": 79, + "samples": 75, + "clonal": 46, + "subclonal": 31, + "indeterminate": 2, + "uncalled": 0, + "loh": 72, + "lohKnown": 78, + "ccf": [ + 2, + 3, + 4, + 3, + 6, + 4, + 6, + 7, + 12, + 32 + ], + "p": 0.00601102198333149, + "q": 0.01402571796110681 + }, + { + "gene": "CDH1", + "calls": 773, + "samples": 769, + "clonal": 639, + "subclonal": 96, + "indeterminate": 36, + "uncalled": 2, + "loh": 711, + "lohKnown": 750, + "ccf": [ + 0, + 4, + 4, + 12, + 12, + 14, + 20, + 46, + 84, + 573 + ], + "p": 0.0028190005173689085, + "q": 0.00986650181079118 + }, + { + "gene": "GATA3", + "calls": 847, + "samples": 836, + "clonal": 566, + "subclonal": 152, + "indeterminate": 123, + "uncalled": 6, + "loh": 58, + "lohKnown": 765, + "ccf": [ + 0, + 0, + 13, + 15, + 19, + 31, + 38, + 79, + 144, + 499 + ], + "p": 0.23422973174670686, + "q": 0.32792162444538964 + } + ] + } + ], + "wgdP": 0.37889995587930314 + }, + "participation": { + "studies": [ + { + "study": "msk_impact_50k_2026", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "FACETS allele-specific copy number: each OncoKB driver (v7.5) mutation call — one mutation in one sample — is clonal, subclonal or indeterminate as FACETS called it from its cancer-cell fraction; uncalled calls have an estimate but no call. LOH at the locus is a minor copy number of 0 where one was estimated. Only samples whose FACETS_QC is Pass are used (Colorectal: 4,912 pass, 451 fail; Breast: 6,204 pass, 671 fail); qc: false uses every sample. Whole-genome doubling, purity and ploidy are FACETS's own per-sample calls. Clonality is only as good as the purity estimate behind it: a low-purity sample's clonal mutation can be called subclonal, and a panel's handful of mutations per sample makes each estimate coarse. Two cohorts: Fisher on clonal against subclonal calls per gene (BH across genes) and on WGD.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count FACETS's calls per gene", + "detail": "The clonality:summary, clonality:purity-ploidy and clonality:genes queries above. Per gene, each an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in one sample is one call, which FACETS labels clonal, subclonal or indeterminate from its cancer-cell fraction (or leaves uncalled); loss of heterozygosity is a minor copy number of 0 where one was estimated. Per sample: whole-genome doubling, purity and ploidy as FACETS called them. Counts only.", + "scope": "Colorectal · msk_impact_50k_2026", + "rowsIn": 4993 + }, + { + "kind": "fetch", + "title": "Count FACETS's calls per gene", + "detail": "The clonality:summary, clonality:purity-ploidy and clonality:genes queries above. Per gene, each an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in one sample is one call, which FACETS labels clonal, subclonal or indeterminate from its cancer-cell fraction (or leaves uncalled); loss of heterozygosity is a minor copy number of 0 where one was estimated. Per sample: whole-genome doubling, purity and ploidy as FACETS called them. Counts only.", + "scope": "Breast · msk_impact_50k_2026", + "rowsIn": 5803 + }, + { + "kind": "transform", + "title": "Keep samples that pass FACETS QC", + "detail": "Only samples whose FACETS_QC is Pass (matched ignoring case) contribute calls, WGD, purity and ploidy.", + "params": [ + [ + "Colorectal", + "4,912 pass, 451 fail, of 5,379 samples with allele-specific copy number" + ], + [ + "Breast", + "6,204 pass, 671 fail, of 6,703 samples with allele-specific copy number" + ] + ] + }, + { + "kind": "statistic", + "title": "Fisher's exact test per gene, and on WGD", + "detail": "Two-sided, on clonal against subclonal calls between the two cohorts, for each gene with at least one such call in both; indeterminate and uncalled calls do not enter. And on whole-genome doubled against not, per sample." + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across genes", + "detail": "q-values over the genes tested." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "clonality:Colorectal:TP53:clonal": { + "v": 3160, + "abs": 0 + }, + "clonality:Colorectal:TP53:subclonal": { + "v": 420, + "abs": 0 + }, + "clonality:Colorectal:KRAS:clonal": { + "v": 1508, + "abs": 0 + }, + "clonality:Colorectal:KRAS:subclonal": { + "v": 290, + "abs": 0 + }, + "clonality:Colorectal:APC:clonal": { + "v": 3889, + "abs": 0 + }, + "clonality:Colorectal:APC:subclonal": { + "v": 897, + "abs": 0 + }, + "clonality:Colorectal:PIK3CA:clonal": { + "v": 634, + "abs": 0 + }, + "clonality:Colorectal:PIK3CA:subclonal": { + "v": 302, + "abs": 0 + }, + "clonality:Colorectal:SMAD4:clonal": { + "v": 494, + "abs": 0 + }, + "clonality:Colorectal:SMAD4:subclonal": { + "v": 164, + "abs": 0 + }, + "clonality:Colorectal:CDH1:clonal": { + "v": 42, + "abs": 0 + }, + "clonality:Colorectal:CDH1:subclonal": { + "v": 17, + "abs": 0 + }, + "clonality:Colorectal:GATA3:clonal": { + "v": 28, + "abs": 0 + }, + "clonality:Colorectal:GATA3:subclonal": { + "v": 12, + "abs": 0 + }, + "clonality:Breast:TP53:clonal": { + "v": 2188, + "abs": 0 + }, + "clonality:Breast:TP53:subclonal": { + "v": 278, + "abs": 0 + }, + "clonality:Breast:KRAS:clonal": { + "v": 40, + "abs": 0 + }, + "clonality:Breast:KRAS:subclonal": { + "v": 13, + "abs": 0 + }, + "clonality:Breast:APC:clonal": { + "v": 27, + "abs": 0 + }, + "clonality:Breast:APC:subclonal": { + "v": 8, + "abs": 0 + }, + "clonality:Breast:PIK3CA:clonal": { + "v": 1793, + "abs": 0 + }, + "clonality:Breast:PIK3CA:subclonal": { + "v": 334, + "abs": 0 + }, + "clonality:Breast:SMAD4:clonal": { + "v": 46, + "abs": 0 + }, + "clonality:Breast:SMAD4:subclonal": { + "v": 31, + "abs": 0 + }, + "clonality:Breast:CDH1:clonal": { + "v": 639, + "abs": 0 + }, + "clonality:Breast:CDH1:subclonal": { + "v": 96, + "abs": 0 + }, + "clonality:Breast:GATA3:clonal": { + "v": 566, + "abs": 0 + }, + "clonality:Breast:GATA3:subclonal": { + "v": 152, + "abs": 0 + }, + "clonality:TP53:p": { + "v": 0.5947092735836579 + }, + "clonality:TP53:q": { + "v": 0.5947092735836579 + }, + "clonality:KRAS:p": { + "v": 0.1286939990837484 + }, + "clonality:KRAS:q": { + "v": 0.22521449839655971 + }, + "clonality:APC:p": { + "v": 0.5160703794843146 + }, + "clonality:APC:q": { + "v": 0.5947092735836579 + }, + "clonality:PIK3CA:p": { + "v": 4.394795388579005e-24 + }, + "clonality:PIK3CA:q": { + "v": 3.076356772005303e-23 + }, + "clonality:SMAD4:p": { + "v": 0.00601102198333149 + }, + "clonality:SMAD4:q": { + "v": 0.01402571796110681 + }, + "clonality:CDH1:p": { + "v": 0.0028190005173689085 + }, + "clonality:CDH1:q": { + "v": 0.00986650181079118 + }, + "clonality:GATA3:p": { + "v": 0.23422973174670686 + }, + "clonality:GATA3:q": { + "v": 0.32792162444538964 + }, + "clonality:wgd:p": { + "v": 0.37889995587930314 + } + } + } + } + ] +} diff --git a/test/snapshots/clonality.sql b/test/snapshots/clonality.sql new file mode 100644 index 0000000..9f2f872 --- /dev/null +++ b/test/snapshots/clonality.sql @@ -0,0 +1,198 @@ +-- cohort Colorectal +-- msk_impact_50k_2026 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) + +-- cohort Breast +-- msk_impact_50k_2026 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer')))) + +-- view 0 clonality: clonality:ascn-studies · msk_impact_50k_2026 +SELECT DISTINCT cs.cancer_study_identifier AS study FROM snapshot_db.allele_specific_copy_number a +JOIN snapshot_db.genetic_profile gp ON gp.genetic_profile_id = a.genetic_profile_id +JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = gp.cancer_study_id ORDER BY study + +-- view 0 clonality: clonality:genes:Breast · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +samp AS ( + SELECT internal_id AS sid, sample_unique_id AS suid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) + AND sample_unique_id IN (SELECT sample_unique_id FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_QC' + AND lowerUTF8(trimBoth(attribute_value)) = 'pass') +), +prof AS ( + SELECT gp.genetic_profile_id AS id FROM snapshot_db.genetic_profile gp + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = gp.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_impact_50k_2026' AND gp.genetic_alteration_type = 'MUTATION_EXTENDED' +), +calls AS ( + SELECT g.hugo_gene_symbol AS gene, a.sample_id AS sid, a.clonal AS call_state, a.ccf_expected_copies AS ccf, a.minor_copy_number AS minor + FROM snapshot_db.allele_specific_copy_number a + JOIN snapshot_db.mutation_event me ON me.mutation_event_id = a.mutation_event_id + JOIN snapshot_db.gene g ON g.entrez_gene_id = me.entrez_gene_id + INNER JOIN oncokb_annotation.variant_annotation ann ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol AND ann.alteration_type = 'MUTATION' AND ann.alteration = me.protein_change + WHERE a.genetic_profile_id IN (SELECT id FROM prof) AND a.sample_id IN (SELECT sid FROM samp) + AND g.hugo_gene_symbol IN ('TP53','KRAS','APC','PIK3CA','SMAD4','CDH1','GATA3') +) +SELECT gene, count() AS calls, uniqExact(sid) AS samples, + countIf(call_state = 'CLONAL') AS clonal, countIf(call_state = 'SUBCLONAL') AS subclonal, + countIf(call_state = 'INDETERMINATE') AS indeterminate, + countIf(minor = 0) AS loh, countIf(minor IS NOT NULL) AS loh_known, + countIf(ccf >= 0 AND ccf < 0.1) AS ccf0, + countIf(ccf >= 0.1 AND ccf < 0.2) AS ccf1, + countIf(ccf >= 0.2 AND ccf < 0.3) AS ccf2, + countIf(ccf >= 0.3 AND ccf < 0.4) AS ccf3, + countIf(ccf >= 0.4 AND ccf < 0.5) AS ccf4, + countIf(ccf >= 0.5 AND ccf < 0.6) AS ccf5, + countIf(ccf >= 0.6 AND ccf < 0.7) AS ccf6, + countIf(ccf >= 0.7 AND ccf < 0.8) AS ccf7, + countIf(ccf >= 0.8 AND ccf < 0.9) AS ccf8, + countIf(ccf >= 0.9) AS ccf9 +FROM calls GROUP BY gene + +-- view 0 clonality: clonality:genes:Colorectal · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +samp AS ( + SELECT internal_id AS sid, sample_unique_id AS suid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) + AND sample_unique_id IN (SELECT sample_unique_id FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_QC' + AND lowerUTF8(trimBoth(attribute_value)) = 'pass') +), +prof AS ( + SELECT gp.genetic_profile_id AS id FROM snapshot_db.genetic_profile gp + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = gp.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_impact_50k_2026' AND gp.genetic_alteration_type = 'MUTATION_EXTENDED' +), +calls AS ( + SELECT g.hugo_gene_symbol AS gene, a.sample_id AS sid, a.clonal AS call_state, a.ccf_expected_copies AS ccf, a.minor_copy_number AS minor + FROM snapshot_db.allele_specific_copy_number a + JOIN snapshot_db.mutation_event me ON me.mutation_event_id = a.mutation_event_id + JOIN snapshot_db.gene g ON g.entrez_gene_id = me.entrez_gene_id + INNER JOIN oncokb_annotation.variant_annotation ann ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol AND ann.alteration_type = 'MUTATION' AND ann.alteration = me.protein_change + WHERE a.genetic_profile_id IN (SELECT id FROM prof) AND a.sample_id IN (SELECT sid FROM samp) + AND g.hugo_gene_symbol IN ('TP53','KRAS','APC','PIK3CA','SMAD4','CDH1','GATA3') +) +SELECT gene, count() AS calls, uniqExact(sid) AS samples, + countIf(call_state = 'CLONAL') AS clonal, countIf(call_state = 'SUBCLONAL') AS subclonal, + countIf(call_state = 'INDETERMINATE') AS indeterminate, + countIf(minor = 0) AS loh, countIf(minor IS NOT NULL) AS loh_known, + countIf(ccf >= 0 AND ccf < 0.1) AS ccf0, + countIf(ccf >= 0.1 AND ccf < 0.2) AS ccf1, + countIf(ccf >= 0.2 AND ccf < 0.3) AS ccf2, + countIf(ccf >= 0.3 AND ccf < 0.4) AS ccf3, + countIf(ccf >= 0.4 AND ccf < 0.5) AS ccf4, + countIf(ccf >= 0.5 AND ccf < 0.6) AS ccf5, + countIf(ccf >= 0.6 AND ccf < 0.7) AS ccf6, + countIf(ccf >= 0.7 AND ccf < 0.8) AS ccf7, + countIf(ccf >= 0.8 AND ccf < 0.9) AS ccf8, + countIf(ccf >= 0.9) AS ccf9 +FROM calls GROUP BY gene + +-- view 0 clonality: clonality:purity-ploidy:Breast · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +samp AS ( + SELECT internal_id AS sid, sample_unique_id AS suid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) + AND sample_unique_id IN (SELECT sample_unique_id FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_QC' + AND lowerUTF8(trimBoth(attribute_value)) = 'pass') +) +SELECT attribute_name AS attr, + toInt32(floor(least(if(attribute_name = 'FACETS_PURITY', 0.9999, 7.9999), greatest(0, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL))) / + if(attribute_name = 'FACETS_PURITY', 0.05, 0.25))) AS bin, + count() AS n +FROM snapshot_db.clinical_data_derived +WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name IN ('FACETS_PURITY', 'FACETS_PLOIDY') + AND sample_unique_id IN (SELECT suid FROM samp) AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL +GROUP BY attr, bin ORDER BY attr, bin + +-- view 0 clonality: clonality:purity-ploidy:Colorectal · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +samp AS ( + SELECT internal_id AS sid, sample_unique_id AS suid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) + AND sample_unique_id IN (SELECT sample_unique_id FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_QC' + AND lowerUTF8(trimBoth(attribute_value)) = 'pass') +) +SELECT attribute_name AS attr, + toInt32(floor(least(if(attribute_name = 'FACETS_PURITY', 0.9999, 7.9999), greatest(0, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL))) / + if(attribute_name = 'FACETS_PURITY', 0.05, 0.25))) AS bin, + count() AS n +FROM snapshot_db.clinical_data_derived +WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name IN ('FACETS_PURITY', 'FACETS_PLOIDY') + AND sample_unique_id IN (SELECT suid FROM samp) AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL +GROUP BY attr, bin ORDER BY attr, bin + +-- view 0 clonality: clonality:summary:Breast · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +samp AS ( + SELECT internal_id AS sid, sample_unique_id AS suid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +prof AS ( + SELECT gp.genetic_profile_id AS id FROM snapshot_db.genetic_profile gp + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = gp.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_impact_50k_2026' AND gp.genetic_alteration_type = 'MUTATION_EXTENDED' +), +wgd AS (SELECT sample_unique_id AS suid, lowerUTF8(trimBoth(attribute_value)) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_WGD'), +qcv AS (SELECT sample_unique_id AS suid, lowerUTF8(trimBoth(attribute_value)) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_QC') +SELECT count() AS samples, + countIf(sid IN (SELECT DISTINCT sample_id FROM snapshot_db.allele_specific_copy_number WHERE genetic_profile_id IN (SELECT id FROM prof))) AS ascn_samples, + countIf(suid IN (SELECT suid FROM qcv WHERE v = 'pass')) AS qc_pass, + countIf(suid IN (SELECT suid FROM qcv WHERE v = 'fail')) AS qc_fail, + countIf(suid IN (SELECT suid FROM wgd WHERE v = 'true') AND suid IN (SELECT suid FROM qcv WHERE v = 'pass')) AS wgd_true, + countIf(suid IN (SELECT suid FROM wgd WHERE v = 'false') AND suid IN (SELECT suid FROM qcv WHERE v = 'pass')) AS wgd_false +FROM samp + +-- view 0 clonality: clonality:summary:Colorectal · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +samp AS ( + SELECT internal_id AS sid, sample_unique_id AS suid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +prof AS ( + SELECT gp.genetic_profile_id AS id FROM snapshot_db.genetic_profile gp + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = gp.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_impact_50k_2026' AND gp.genetic_alteration_type = 'MUTATION_EXTENDED' +), +wgd AS (SELECT sample_unique_id AS suid, lowerUTF8(trimBoth(attribute_value)) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_WGD'), +qcv AS (SELECT sample_unique_id AS suid, lowerUTF8(trimBoth(attribute_value)) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'FACETS_QC') +SELECT count() AS samples, + countIf(sid IN (SELECT DISTINCT sample_id FROM snapshot_db.allele_specific_copy_number WHERE genetic_profile_id IN (SELECT id FROM prof))) AS ascn_samples, + countIf(suid IN (SELECT suid FROM qcv WHERE v = 'pass')) AS qc_pass, + countIf(suid IN (SELECT suid FROM qcv WHERE v = 'fail')) AS qc_fail, + countIf(suid IN (SELECT suid FROM wgd WHERE v = 'true') AND suid IN (SELECT suid FROM qcv WHERE v = 'pass')) AS wgd_true, + countIf(suid IN (SELECT suid FROM wgd WHERE v = 'false') AND suid IN (SELECT suid FROM qcv WHERE v = 'pass')) AS wgd_false +FROM samp diff --git a/test/snapshots/clonality.svg b/test/snapshots/clonality.svg new file mode 100644 index 0000000..253fe7d --- /dev/null +++ b/test/snapshots/clonality.svg @@ -0,0 +1,2 @@ + +Clonality (FACETS) — Colorectal, Breastcohorts:ColorectalBreastdriver mutation calls:clonalsubclonal (paler)indeterminateclonal share differsTP5388.3% clonalLOH 76.8%3,839 callsq 0.5988.7% clonalLOH 89.1%2,672 callsKRAS83.9% clonalLOH 21.4%2,145 callsq 0.2375.5% clonalLOH 17.3%59 callsAPC81.3% clonalLOH 33.5%5,344 callsq 0.5977.1% clonalLOH 44.4%39 callsPIK3CA67.7% clonalLOH 11.6%1,018 callsq 3.1e-2384.3% clonalLOH 13.2%2,350 callsSMAD475.1% clonalLOH 79.2%673 callsq 0.01459.7% clonalLOH 92.3%79 callsCDH171.2% clonalLOH 16.4%62 callsq 0.009986.9% clonalLOH 94.8%773 callsGATA370.0% clonalLOH 7.1%42 callsq 0.3378.8% clonalLOH 7.6%847 calls0%20%40%60%80%100%share of the gene's callsper sample (FACETS)Colorectalwhole-genome doubled: 35.6% of 4,912 samples02004006000.00.40.8purity01,0002,00002468ploidy5,379 of 5,395 samples have FACETS estimates; 4,912 pass QCBreastwhole-genome doubled: 34.8% of 6,204 samples02004006000.00.40.8purity02,0004,00002468ploidy6,703 of 6,907 samples have FACETS estimates; 6,204 pass QCWGD differs: Fisher p = 0.38FACETS allele-specific copy number: each OncoKB driver (v7.5) mutation call — one mutation in one sample — is clonal, subclonal or indeterminate as FACETS called itfrom its cancer-cell fraction; uncalled calls have an estimate but no call. LOH at the locus is a minor copy number of 0 where one was estimated. Only samples whoseFACETS_QC is Pass are used (Colorectal: 4,912 pass, 451 fail; Breast: 6,204 pass, 671 fail); qc: false uses every sample. Whole-genome doubling, purity and ploidy areFACETS's own per-sample calls. Clonality is only as good as the purity estimate behind it: a low-purity sample's clonal mutation can be called subclonal, and a panel'shandful of mutations per sample makes each estimate coarse. Two cohorts: Fisher on clonal against subclonal calls per gene (BH across genes) and on WGD. diff --git a/test/snapshots/clonality.txt b/test/snapshots/clonality.txt new file mode 100644 index 0000000..399f595 --- /dev/null +++ b/test/snapshots/clonality.txt @@ -0,0 +1,34 @@ +Analysis over msk_impact_50k_2026 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Colorectal: 4,993 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) +- Breast: 5,803 patients — CANCER_TYPE in [Breast Cancer] (any sample) + +Clonality (FACETS; driver mutation calls, QC-passing samples): + Colorectal: WGD 35.6% of 4,912 samples + TP53: 3839 calls, 88% clonal (3160 clonal, 420 subclonal, 255 indeterminate), LOH 77%, q=0.5947 + KRAS: 2145 calls, 84% clonal (1508 clonal, 290 subclonal, 346 indeterminate), LOH 21%, q=0.2252 + APC: 5344 calls, 81% clonal (3889 clonal, 897 subclonal, 554 indeterminate), LOH 34%, q=0.5947 + PIK3CA: 1018 calls, 68% clonal (634 clonal, 302 subclonal, 82 indeterminate), LOH 12%, q=3.1e-23 + SMAD4: 673 calls, 75% clonal (494 clonal, 164 subclonal, 15 indeterminate), LOH 79%, q=0.0140 + CDH1: 62 calls, 71% clonal (42 clonal, 17 subclonal, 3 indeterminate), LOH 16%, q=0.0099 + GATA3: 42 calls, 70% clonal (28 clonal, 12 subclonal, 2 indeterminate), LOH 7%, q=0.3279 + Breast: WGD 34.8% of 6,204 samples + TP53: 2672 calls, 89% clonal (2188 clonal, 278 subclonal, 195 indeterminate), LOH 89%, q=0.5947 + KRAS: 59 calls, 75% clonal (40 clonal, 13 subclonal, 6 indeterminate), LOH 17%, q=0.2252 + APC: 39 calls, 77% clonal (27 clonal, 8 subclonal, 4 indeterminate), LOH 44%, q=0.5947 + PIK3CA: 2350 calls, 84% clonal (1793 clonal, 334 subclonal, 221 indeterminate), LOH 13%, q=3.1e-23 + SMAD4: 79 calls, 60% clonal (46 clonal, 31 subclonal, 2 indeterminate), LOH 92%, q=0.0140 + CDH1: 773 calls, 87% clonal (639 clonal, 96 subclonal, 36 indeterminate), LOH 95%, q=0.0099 + GATA3: 847 calls, 79% clonal (566 clonal, 152 subclonal, 123 indeterminate), LOH 8%, q=0.3279 + WGD difference: Fisher p=0.3789 + CAVEAT (tell the user): FACETS allele-specific copy number: each OncoKB driver (v7.5) mutation call — one mutation in one sample — is clonal, subclonal or indeterminate as FACETS called it from its cancer-cell fraction; uncalled calls have an estimate but no call. LOH at the locus is a minor copy number of 0 where one was estimated. Only samples whose FACETS_QC is Pass are used (Colorectal: 4,912 pass, 451 fail; Breast: 6,204 pass, 671 fail); qc: false uses every sample. Whole-genome doubling, purity and ploidy are FACETS's own per-sample calls. Clonality is only as good as the purity estimate behind it: a low-purity sample's clonal mutation can be called subclonal, and a panel's handful of mutations per sample makes each estimate coarse. Two cohorts: Fisher on clonal against subclonal calls per gene (BH across genes) and on WGD. + METHOD: + - Count FACETS's calls per gene [Colorectal · msk_impact_50k_2026]: The clonality:summary, clonality:purity-ploidy and clonality:genes queries above. Per gene, each an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in one sample is one call, which FACETS labels clonal, subclonal or indeterminate from its cancer-cell fraction (or leaves uncalled); loss of heterozygosity is a minor copy number of 0 where one was estimated. Per sample: whole-genome doubling, purity and ploidy as FACETS called them. Counts only. + - Count FACETS's calls per gene [Breast · msk_impact_50k_2026]: The clonality:summary, clonality:purity-ploidy and clonality:genes queries above. Per gene, each an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in one sample is one call, which FACETS labels clonal, subclonal or indeterminate from its cancer-cell fraction (or leaves uncalled); loss of heterozygosity is a minor copy number of 0 where one was estimated. Per sample: whole-genome doubling, purity and ploidy as FACETS called them. Counts only. + - Keep samples that pass FACETS QC: Only samples whose FACETS_QC is Pass (matched ignoring case) contribute calls, WGD, purity and ploidy. + Colorectal: 4,912 pass, 451 fail, of 5,379 samples with allele-specific copy number + Breast: 6,204 pass, 671 fail, of 6,703 samples with allele-specific copy number + - Fisher's exact test per gene, and on WGD: Two-sided, on clonal against subclonal calls between the two cohorts, for each gene with at least one such call in both; indeterminate and uncalled calls do not enter. And on whole-genome doubled against not, per sample. + - Benjamini–Hochberg across genes: q-values over the genes tested. + Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/coexpression.json b/test/snapshots/coexpression.json new file mode 100644 index 0000000..20a366c --- /dev/null +++ b/test/snapshots/coexpression.json @@ -0,0 +1,256 @@ +{ + "study": "brca_tcga_pan_can_atlas_2018", + "cohorts": { + "BRCA": { + "count": 1066, + "text": "profiled for MUTATION", + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ] + } + }, + "views": [ + { + "kind": "coexpression", + "cohorts": [ + "BRCA" + ], + "coexpression": [ + { + "a": "ERBB2", + "b": "GRB7", + "r": 0.8713, + "n": 1064, + "p": 0, + "q": 0 + }, + { + "a": "ESR1", + "b": "MKI67", + "r": -0.2334, + "n": 1064, + "p": 1.2418853229945448e-14, + "q": 6.209426614972723e-14 + }, + { + "a": "ESR1", + "b": "PGR", + "r": 0.2263, + "n": 1064, + "p": 8.025146361684293e-14, + "q": 2.6750487872280976e-13 + }, + { + "a": "PGR", + "b": "MKI67", + "r": -0.1839, + "n": 1064, + "p": 1.5183862366308729e-9, + "q": 3.7959655915771825e-9 + }, + { + "a": "GRB7", + "b": "ESR1", + "r": -0.1723, + "n": 1064, + "p": 1.560101548391098e-8, + "q": 3.120203096782196e-8 + }, + { + "a": "ERBB2", + "b": "ESR1", + "r": -0.1651, + "n": 1064, + "p": 6.030449902721193e-8, + "q": 1.0050749837868655e-7 + }, + { + "a": "ERBB2", + "b": "PGR", + "r": -0.127, + "n": 1064, + "p": 0.00003249163546036962, + "q": 0.00004641662208624231 + }, + { + "a": "GRB7", + "b": "PGR", + "r": -0.1185, + "n": 1064, + "p": 0.0001071034933253945, + "q": 0.00013387936665674313 + }, + { + "a": "GRB7", + "b": "MKI67", + "r": 0.0457, + "n": 1064, + "p": 0.13671251169317, + "q": 0.1425531010179386 + }, + { + "a": "ERBB2", + "b": "MKI67", + "r": 0.045, + "n": 1064, + "p": 0.1425531010179386, + "q": 0.1425531010179386 + } + ], + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ], + "participation": { + "studies": [ + { + "study": "brca_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "Pearson correlation on “rna_seq_v2_mrna_median_Zscores” within “BRCA”, over the patients with BOTH values (values averaged per patient, matching the heatmap convention). Each site reports six sums — n, Σx, Σy, Σxy, Σx², Σy² — and nothing else; those sums are additive, so the pooled correlation is EXACT rather than an approximation of a centralized one. q-values are Benjamini–Hochberg across the 10 pairs with a defined correlation.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Sum each gene pair's values", + "detail": "The pairMoments query above, on “rna_seq_v2_mrna_median_Zscores”. Per pair, over the patients with a value for both genes (a patient with several samples contributes their average): n, Σx, Σy, Σxy, Σx² and Σy² — six sums, no individual value.", + "scope": "BRCA · brca_tcga_pan_can_atlas_2018", + "rowsIn": 1066, + "params": [ + [ + "pairs", + "10" + ] + ] + }, + { + "kind": "statistic", + "title": "Pearson correlation per pair", + "detail": "r = (nΣxy − ΣxΣy) / √((nΣx² − (Σx)²)(nΣy² − (Σy)²)); t = r√((n − 2)/(1 − r²)), two-sided p on n − 2 df. Undefined for n < 3 or a constant series." + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across pairs", + "detail": "q-values over the 10 pairs with a defined correlation, from the Pearson p-values." + } + ], + "implementation": { + "functions": [ + "pearsonFromMoments", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Pearson's r and p from the six sums match scipy 1.18.1 pearsonr on the underlying values, to a relative 1e-6 (test/moments-golden.test.ts).", + "check": { + "coexpression:ERBB2/GRB7:r": { + "v": 0.8713, + "abs": 0.000050000001000000005 + }, + "coexpression:ERBB2/GRB7:p": { + "v": 0 + }, + "coexpression:ERBB2/GRB7:q": { + "v": 0 + }, + "coexpression:ESR1/MKI67:r": { + "v": -0.2334, + "abs": 0.000050000001000000005 + }, + "coexpression:ESR1/MKI67:p": { + "v": 1.2418853229945448e-14 + }, + "coexpression:ESR1/MKI67:q": { + "v": 6.209426614972723e-14 + }, + "coexpression:ESR1/PGR:r": { + "v": 0.2263, + "abs": 0.000050000001000000005 + }, + "coexpression:ESR1/PGR:p": { + "v": 8.025146361684293e-14 + }, + "coexpression:ESR1/PGR:q": { + "v": 2.6750487872280976e-13 + }, + "coexpression:PGR/MKI67:r": { + "v": -0.1839, + "abs": 0.000050000001000000005 + }, + "coexpression:PGR/MKI67:p": { + "v": 1.5183862366308729e-9 + }, + "coexpression:PGR/MKI67:q": { + "v": 3.7959655915771825e-9 + }, + "coexpression:GRB7/ESR1:r": { + "v": -0.1723, + "abs": 0.000050000001000000005 + }, + "coexpression:GRB7/ESR1:p": { + "v": 1.560101548391098e-8 + }, + "coexpression:GRB7/ESR1:q": { + "v": 3.120203096782196e-8 + }, + "coexpression:ERBB2/ESR1:r": { + "v": -0.1651, + "abs": 0.000050000001000000005 + }, + "coexpression:ERBB2/ESR1:p": { + "v": 6.030449902721193e-8 + }, + "coexpression:ERBB2/ESR1:q": { + "v": 1.0050749837868655e-7 + }, + "coexpression:ERBB2/PGR:r": { + "v": -0.127, + "abs": 0.000050000001000000005 + }, + "coexpression:ERBB2/PGR:p": { + "v": 0.00003249163546036962 + }, + "coexpression:ERBB2/PGR:q": { + "v": 0.00004641662208624231 + }, + "coexpression:GRB7/PGR:r": { + "v": -0.1185, + "abs": 0.000050000001000000005 + }, + "coexpression:GRB7/PGR:p": { + "v": 0.0001071034933253945 + }, + "coexpression:GRB7/PGR:q": { + "v": 0.00013387936665674313 + }, + "coexpression:GRB7/MKI67:r": { + "v": 0.0457, + "abs": 0.000050000001000000005 + }, + "coexpression:GRB7/MKI67:p": { + "v": 0.13671251169317 + }, + "coexpression:GRB7/MKI67:q": { + "v": 0.1425531010179386 + }, + "coexpression:ERBB2/MKI67:r": { + "v": 0.045, + "abs": 0.000050000001000000005 + }, + "coexpression:ERBB2/MKI67:p": { + "v": 0.1425531010179386 + }, + "coexpression:ERBB2/MKI67:q": { + "v": 0.1425531010179386 + } + } + } + } + ] +} diff --git a/test/snapshots/coexpression.sql b/test/snapshots/coexpression.sql new file mode 100644 index 0000000..500ee61 --- /dev/null +++ b/test/snapshots/coexpression.sql @@ -0,0 +1,35 @@ +-- cohort BRCA +-- brca_tcga_pan_can_atlas_2018 +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND sp.alteration_type = 'MUTATION_EXTENDED') + +-- view 0 coexpression: pairMoments · brca_tcga_pan_can_atlas_2018 +WITH cohort AS ((SELECT DISTINCT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND sp.alteration_type = 'MUTATION_EXTENDED')), +vals AS ( + SELECT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid, ga.hugo_gene_symbol AS gene, + avg(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) AS v + FROM snapshot_db.genetic_alteration_derived ga + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id + WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_Zscores' + AND ga.hugo_gene_symbol IN ('ERBB2','GRB7','ESR1','PGR','MKI67') + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL + AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid, gene +), +pp AS (SELECT pid, groupArray(gene) AS gs, groupArray(v) AS vs FROM vals GROUP BY pid) +SELECT ga, gb, countIf(ok) AS n, + sumIf(x, ok) AS sx, sumIf(y, ok) AS sy, + sumIf(x * y, ok) AS sxy, sumIf(x * x, ok) AS sxx, sumIf(y * y, ok) AS syy +FROM ( + SELECT ga, gb, indexOf(gs, ga) AS ia, indexOf(gs, gb) AS ib, + (ia > 0 AND ib > 0) AS ok, + if(ok, vs[ia], 0) AS x, if(ok, vs[ib], 0) AS y + FROM pp + ARRAY JOIN ['ERBB2','ERBB2','ERBB2','ERBB2','GRB7','GRB7','GRB7','ESR1','ESR1','PGR'] AS ga, ['GRB7','ESR1','PGR','MKI67','ESR1','PGR','MKI67','PGR','MKI67','MKI67'] AS gb +) +GROUP BY ga, gb diff --git a/test/snapshots/coexpression.svg b/test/snapshots/coexpression.svg new file mode 100644 index 0000000..294fcd9 --- /dev/null +++ b/test/snapshots/coexpression.svg @@ -0,0 +1,2 @@ + +Co-expression — Pearson rCo-expression — Pearson rpositive, q < 0.05negative, q < 0.05not significantERBB2 / GRB7ERBB2 / GRB7r = 0.87 · n = 1,064 · q < 1e-300ESR1 / MKI67ESR1 / MKI67r = −0.23 · n = 1,064 · q = 6.2e-14ESR1 / PGRESR1 / PGRr = 0.23 · n = 1,064 · q = 2.7e-13PGR / MKI67PGR / MKI67r = −0.18 · n = 1,064 · q = 3.8e-9GRB7 / ESR1GRB7 / ESR1r = −0.17 · n = 1,064 · q = 3.1e-8ERBB2 / ESR1ERBB2 / ESR1r = −0.17 · n = 1,064 · q = 1e-7ERBB2 / PGRERBB2 / PGRr = −0.13 · n = 1,064 · q = 4.6e-5GRB7 / PGRGRB7 / PGRr = −0.12 · n = 1,064 · q = 1.3e-4GRB7 / MKI67GRB7 / MKI67r = 0.046 · n = 1,064 · q = 0.14ERBB2 / MKI67ERBB2 / MKI67r = 0.045 · n = 1,064 · q = 0.14−1.0−0.50.00.51.0Pearson r — left: anti-correlated, right: correlatedPearson correlation on “rna_seq_v2_mrna_median_Zscores” within “BRCA”, over the patients with BOTH values (values averaged per patient, matching theheatmap convention). Each site reports six sums — n, Σx, Σy, Σxy, Σx², Σy² — and nothing else; those sums are additive, so the pooled correlation is EXACTrather than an approximation of a centralized one. q-values are Benjamini–Hochberg across the 10 pairs with a defined correlation. diff --git a/test/snapshots/coexpression.txt b/test/snapshots/coexpression.txt new file mode 100644 index 0000000..629b89d --- /dev/null +++ b/test/snapshots/coexpression.txt @@ -0,0 +1,23 @@ +Analysis over brca_tcga_pan_can_atlas_2018 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- BRCA: 1,066 patients — profiled for MUTATION + +Co-expression (Pearson r, computed from six per-site sums so the pooled value is exact): + ERBB2/GRB7: r=0.871 (n=1,064) p=<1e-300 q=<1e-300 + ESR1/MKI67: r=-0.233 (n=1,064) p=1.2e-14 q=6.2e-14 + ESR1/PGR: r=0.226 (n=1,064) p=8.0e-14 q=2.7e-13 + PGR/MKI67: r=-0.184 (n=1,064) p=1.5e-9 q=3.8e-9 + GRB7/ESR1: r=-0.172 (n=1,064) p=1.6e-8 q=3.1e-8 + ERBB2/ESR1: r=-0.165 (n=1,064) p=6.0e-8 q=1.0e-7 + ERBB2/PGR: r=-0.127 (n=1,064) p=3.2e-5 q=4.6e-5 + GRB7/PGR: r=-0.118 (n=1,064) p=0.0001 q=0.0001 + GRB7/MKI67: r=0.046 (n=1,064) p=0.1367 q=0.1426 + ERBB2/MKI67: r=0.045 (n=1,064) p=0.1426 q=0.1426 + Pearson correlation on “rna_seq_v2_mrna_median_Zscores” within “BRCA”, over the patients with BOTH values (values averaged per patient, matching the heatmap convention). Each site reports six sums — n, Σx, Σy, Σxy, Σx², Σy² — and nothing else; those sums are additive, so the pooled correlation is EXACT rather than an approximation of a centralized one. q-values are Benjamini–Hochberg across the 10 pairs with a defined correlation. + METHOD: + - Sum each gene pair's values [BRCA · brca_tcga_pan_can_atlas_2018]: The pairMoments query above, on “rna_seq_v2_mrna_median_Zscores”. Per pair, over the patients with a value for both genes (a patient with several samples contributes their average): n, Σx, Σy, Σxy, Σx² and Σy² — six sums, no individual value. + pairs: 10 + - Pearson correlation per pair: r = (nΣxy − ΣxΣy) / √((nΣx² − (Σx)²)(nΣy² − (Σy)²)); t = r√((n − 2)/(1 − r²)), two-sided p on n − 2 df. Undefined for n < 3 or a constant series. + - Benjamini–Hochberg across pairs: q-values over the 10 pairs with a defined correlation, from the Pearson p-values. + Pearson's r and p from the six sums match scipy 1.18.1 pearsonr on the underlying values, to a relative 1e-6 (test/moments-golden.test.ts). diff --git a/test/snapshots/compare.json b/test/snapshots/compare.json new file mode 100644 index 0000000..12fd0ed --- /dev/null +++ b/test/snapshots/compare.json @@ -0,0 +1,143 @@ +{ + "study": "sarcoma_msk_2022", + "cohorts": { + "Well-diff liposarcoma": { + "count": 444, + "text": "CANCER_TYPE_DETAILED in [Well-Differentiated Liposarcoma] (any sample)", + "studies": [ + "sarcoma_msk_2022" + ] + } + }, + "views": [ + { + "kind": "compare", + "cohorts": [ + "Well-diff liposarcoma" + ], + "annotation": "OncoKB v7.5 (pinned)", + "rows": [ + { + "gene": "MDM2", + "cells": [ + { + "cohort": "Well-diff liposarcoma", + "profiled": 444, + "any": 0, + "driver": 0, + "anyPct": 0, + "driverPct": 0, + "byType": { + "mutation": { + "profiled": 444, + "altered": 0 + }, + "cna": { + "profiled": 0, + "altered": 0 + }, + "structuralVariant": { + "profiled": 444, + "altered": 0 + } + } + } + ] + }, + { + "gene": "TP53", + "cells": [ + { + "cohort": "Well-diff liposarcoma", + "profiled": 444, + "any": 17, + "driver": 7, + "anyPct": 3.8, + "driverPct": 1.6, + "byType": { + "mutation": { + "profiled": 444, + "altered": 11 + }, + "cna": { + "profiled": 0, + "altered": 0 + }, + "structuralVariant": { + "profiled": 444, + "altered": 6 + } + } + } + ] + } + ], + "participation": { + "studies": [ + { + "study": "sarcoma_msk_2022", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "no copy-number data exists for sarcoma_msk_2022 — altered% reflects only mutation/structural-variant status, not a real negative for the missing type(s)", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count profiled and altered patients per gene", + "detail": "The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only.", + "scope": "Well-diff liposarcoma · sarcoma_msk_2022", + "rowsIn": 444, + "params": [ + [ + "genes", + "2" + ] + ] + }, + { + "kind": "statistic", + "title": "No test", + "detail": "One cohort: frequencies only, nothing to compare against." + } + ], + "implementation": { + "functions": [], + "file": "lib/stats.ts", + "commit": null + }, + "check": { + "compare:MDM2:Well-diff liposarcoma:profiled": { + "v": 444, + "abs": 0 + }, + "compare:MDM2:Well-diff liposarcoma:altered": { + "v": 0, + "abs": 0 + }, + "compare:MDM2:Well-diff liposarcoma:driver": { + "v": 0, + "abs": 0 + }, + "compare:TP53:Well-diff liposarcoma:profiled": { + "v": 444, + "abs": 0 + }, + "compare:TP53:Well-diff liposarcoma:altered": { + "v": 17, + "abs": 0 + }, + "compare:TP53:Well-diff liposarcoma:driver": { + "v": 7, + "abs": 0 + } + } + } + } + ] +} diff --git a/test/snapshots/compare.sql b/test/snapshots/compare.sql new file mode 100644 index 0000000..dec20f5 --- /dev/null +++ b/test/snapshots/compare.sql @@ -0,0 +1,58 @@ +-- cohort Well-diff liposarcoma +-- sarcoma_msk_2022 +(SELECT DISTINCT replaceOne(patient_unique_id, 'sarcoma_msk_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'sarcoma_msk_2022' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Well-Differentiated Liposarcoma')))) + +-- view 0 compare: geneCounts · sarcoma_msk_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'sarcoma_msk_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'sarcoma_msk_2022' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE_DETAILED' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Well-Differentiated Liposarcoma'))))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'sarcoma_msk_2022_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'sarcoma_msk_2022' + AND g.hugo_gene_symbol IN ('MDM2','TP53') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'sarcoma_msk_2022_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'sarcoma_msk_2022_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('MDM2','TP53') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'sarcoma_msk_2022' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'sarcoma_msk_2022_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene diff --git a/test/snapshots/compare.svg b/test/snapshots/compare.svg new file mode 100644 index 0000000..88f06c5 --- /dev/null +++ b/test/snapshots/compare.svg @@ -0,0 +1,2 @@ + +Altered %, by cohort — Well-diff liposarcomaAltered %, by cohortWell-diff liposarcomaMDM2Well-diff liposarcoma — MDM2: 0% (0 of 444 profiled)0%TP53Well-diff liposarcoma — TP53: 3.8% (17 of 444 profiled)3.8%0%1%2%3%4%altered, % of profiledno copy-number data exists for sarcoma_msk_2022 — altered% reflects only mutation/structural-variant status, not a real negative for the missing type(s) diff --git a/test/snapshots/compare.txt b/test/snapshots/compare.txt new file mode 100644 index 0000000..71e9851 --- /dev/null +++ b/test/snapshots/compare.txt @@ -0,0 +1,13 @@ +Analysis over sarcoma_msk_2022 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Well-diff liposarcoma: 444 patients — CANCER_TYPE_DETAILED in [Well-Differentiated Liposarcoma] (any sample) + +Compare (driver%/any%, panel-aware denominators; annotation OncoKB v7.5 (pinned)): + MDM2: Well-diff liposarcoma 0%/0% + TP53: Well-diff liposarcoma 1.6%/3.8% + no copy-number data exists for sarcoma_msk_2022 — altered% reflects only mutation/structural-variant status, not a real negative for the missing type(s) + METHOD: + - Count profiled and altered patients per gene [Well-diff liposarcoma · sarcoma_msk_2022]: The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only. + genes: 2 + - No test: One cohort: frequencies only, nothing to compare against. diff --git a/test/snapshots/composition.json b/test/snapshots/composition.json new file mode 100644 index 0000000..15a352b --- /dev/null +++ b/test/snapshots/composition.json @@ -0,0 +1,1944 @@ +{ + "study": "msk_spectrum_tme_2022", + "cohorts": { + "HRD-Dup": { + "count": 16, + "text": "CONSENSUS_SIGNATURE in [HRD-Dup]", + "studies": [ + "msk_spectrum_tme_2022" + ] + }, + "HRD-Del": { + "count": 6, + "text": "CONSENSUS_SIGNATURE in [HRD-Del]", + "studies": [ + "msk_spectrum_tme_2022" + ] + }, + "FBI": { + "count": 14, + "text": "CONSENSUS_SIGNATURE in [FBI]", + "studies": [ + "msk_spectrum_tme_2022" + ] + } + }, + "views": [ + { + "kind": "composition", + "cohorts": [ + "HRD-Dup", + "HRD-Del", + "FBI" + ], + "composition": { + "source": "clinical", + "sourceName": "clinical attributes", + "unit": "patients", + "normalize": true, + "sort": "custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13", + "parts": [ + { + "id": "custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13", + "name": "CD4 T CXCL13" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_CD4_T_naive", + "name": "CD4 T naive" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_CD4_T_reg", + "name": "CD4 T reg" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13", + "name": "CD8 T CXCL13" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_CD8_T_ISG", + "name": "CD8 T ISG" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic", + "name": "CD8 T cytotoxic" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_Cycling_T_NK", + "name": "Cycling T NK" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_ILC", + "name": "ILC" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_NK_CD56", + "name": "NK CD56" + }, + { + "id": "custom:spectrum-sc-tnk/TNK_NK_cytotoxic", + "name": "NK cytotoxic" + } + ], + "groups": [ + { + "cohort": "HRD-Dup", + "n": 16, + "incomplete": 0, + "invalid": 0, + "entropy": { + "mean": 2.069917619184448, + "sd": 0.05895794661892703 + }, + "cases": [ + [ + 0.130197265857417, + 0.07582840760344031, + 0.10169786434484875, + 0.14629692776451694, + 0.09990790193405938, + 0.18469612138145097, + 0.13559715245979834, + 0.008920812662934078, + 0.09009810793973326, + 0.02675943805180091 + ], + [ + 0.05761455154957243, + 0.1174092753327513, + 0.18111430803033443, + 0.11110877759342991, + 0.12320973356895197, + 0.1869147662665351, + 0.12430982047581761, + 0.00902171271530451, + 0.046443669049854946, + 0.04285338541744799 + ], + [ + 0.03921078421568431, + 0.12440248804976098, + 0.08335166703334065, + 0.10280205604112082, + 0.06207124142482849, + 0.24800496009920195, + 0.06677133542670853, + 0.015680313606272124, + 0.2037040740814816, + 0.05400108002160043 + ], + [ + 0.04767904641907161, + 0.18099638007239852, + 0.09190816183676326, + 0.09413811723765524, + 0.08845823083538328, + 0.2835943281134377, + 0.05497890042199156, + 0.011769764604707904, + 0.09108817823643527, + 0.05538889222215555 + ], + [ + 0.025248535584936078, + 0.08725493921352563, + 0.13829197906521423, + 0.08690495951234829, + 0.14549156148943362, + 0.33338066392149257, + 0.10149411334142622, + 0.005667671275066047, + 0.04637731011601327, + 0.029888266480544132 + ], + [ + 0.031410628212564254, + 0.18170363407268145, + 0.11400228004560092, + 0.0744614892297846, + 0.05741114822296446, + 0.28810576211524236, + 0.0498809976199524, + 0.01988039760795216, + 0.13620272405448108, + 0.04694093881877638 + ], + [ + 0.028438578071096444, + 0.15049247537623117, + 0.14269286535673215, + 0.07050647467626618, + 0.0918854057297135, + 0.23558822058897053, + 0.07707614619269035, + 0.014299285035748212, + 0.1413929303534823, + 0.04762761861906904 + ], + [ + 0.0657773689052438, + 0.2243910243590256, + 0.10219591216351345, + 0.0684572617095316, + 0.10639574417023318, + 0.20239190432382703, + 0.0624375024999, + 0.013359465621375145, + 0.06833726650933962, + 0.08625654973801047 + ], + [ + 0.017880894044702236, + 0.144007200360018, + 0.0791839591979599, + 0.06545327266363317, + 0.11810590529526475, + 0.2912145607280364, + 0.05556277813890694, + 0.04119205960298015, + 0.12130606530326517, + 0.06609330466523326 + ], + [ + 0.03911117333520005, + 0.1413042391271738, + 0.12070362110863324, + 0.05698170945128354, + 0.053071592147764426, + 0.16200486014580437, + 0.11450343510305308, + 0.02905087152614578, + 0.22460673820214602, + 0.05866175985279557 + ], + [ + 0.05322106442128843, + 0.2346046920938419, + 0.11400228004560094, + 0.05033100662013241, + 0.0742214844296886, + 0.2194043880877618, + 0.06988139762795256, + 0.01340026800536011, + 0.12640252805056104, + 0.04453089061781236 + ], + [ + 0.0673239408453239, + 0.1409873111419972, + 0.20898119169274762, + 0.04683578477936985, + 0.1199892009719125, + 0.16368526832585067, + 0.0828525432711056, + 0.020488156065954062, + 0.11688947994680478, + 0.03196712295893369 + ], + [ + 0.028089157325280244, + 0.10429687109386719, + 0.10319690409287721, + 0.04528864134075977, + 0.09859704208873733, + 0.22409327720168395, + 0.10979670609881703, + 0.020349389518314453, + 0.20209393718188456, + 0.06419807405777826 + ], + [ + 0.010300515025751288, + 0.19240962048102406, + 0.06885344267213361, + 0.03539176958847943, + 0.032181609080454025, + 0.10170508525426272, + 0.06113305665283265, + 0.025101255062753142, + 0.26961348067403373, + 0.20331016550827544 + ], + [ + 0.01223828663987042, + 0.0906373107764913, + 0.11948327234187216, + 0.0313056172135901, + 0.1090847281380607, + 0.13158157857899896, + 0.12908192853000583, + 0.03156558081868539, + 0.29805827184194217, + 0.04696342512048314 + ], + [ + 0.01449188394491284, + 0.2397311650514567, + 0.08776140898316781, + 0.02843369638052947, + 0.08858151559702762, + 0.16812185584125938, + 0.07929030774000621, + 0.06342824567193736, + 0.15552021762829168, + 0.074639703161411 + ] + ] + }, + { + "cohort": "HRD-Del", + "n": 6, + "incomplete": 0, + "invalid": 0, + "entropy": { + "mean": 1.96274443194148, + "sd": 0.05433303341805096 + }, + "cases": [ + [ + 0.05524944750552494, + 0.17329826701732984, + 0.0816991830081699, + 0.11769882301176987, + 0.06915930840691592, + 0.3138968610313897, + 0.06312936870631294, + 0.013129868701312985, + 0.04999950000499995, + 0.06273937260627394 + ], + [ + 0.013371069685574846, + 0.07930634450756059, + 0.06073485878870309, + 0.04972397791823346, + 0.09172733818705496, + 0.1754140331226498, + 0.06482518601488119, + 0.015261220897671813, + 0.3428274261940955, + 0.10680854468357469 + ], + [ + 0.032586741325867405, + 0.13078692130786918, + 0.276972302769723, + 0.044805519448055185, + 0.054984501549845, + 0.26437356264373557, + 0.06964303569643035, + 0.018738126187381257, + 0.06353364663533645, + 0.043575642435756415 + ], + [ + 0.03941921161576768, + 0.20619587608247836, + 0.23469530609387815, + 0.03148937021259575, + 0.041229175416491674, + 0.19389612207755846, + 0.04893902121957561, + 0.021749565008699828, + 0.14069718605627887, + 0.04168916621667567 + ], + [ + 0.027150271502715033, + 0.20540205402054024, + 0.19300193001930024, + 0.03081030810308104, + 0.07483074830748308, + 0.2597025970259703, + 0.06236062360623607, + 0.019080190801908023, + 0.07190071900719008, + 0.055760557605576064 + ], + [ + 0.026708397496150234, + 0.3831770093794372, + 0.09193448393096414, + 0.020538767673939563, + 0.05238685678859269, + 0.17668939863608185, + 0.0328680279183249, + 0.019518828870267783, + 0.1134931904085755, + 0.08268503889766614 + ] + ] + }, + { + "cohort": "FBI", + "n": 14, + "incomplete": 0, + "invalid": 0, + "entropy": { + "mean": 1.9822756783103324, + "sd": 0.07138785458820697 + }, + "cases": [ + [ + 0.06246312315615781, + 0.11890594529726486, + 0.07680384019200959, + 0.1032051602580129, + 0.06569328466423321, + 0.2825141257062853, + 0.14050702535126758, + 0.011530576528826442, + 0.11010550527526376, + 0.028271413570678534 + ], + [ + 0.07063141262825258, + 0.1614032280645613, + 0.15530310606212125, + 0.08632172643452869, + 0.051011020220404414, + 0.26400528010560215, + 0.06558131162623253, + 0.020180403608072165, + 0.05886117722354448, + 0.06670133402668053 + ], + [ + 0.019409029548522576, + 0.24428778561071948, + 0.144192790360482, + 0.06427678616069198, + 0.05293735313234339, + 0.20668966551672419, + 0.055457227138643074, + 0.024958752062396884, + 0.08998550072496377, + 0.09780510974451279 + ], + [ + 0.019100764030561223, + 0.11630465218608745, + 0.11720468818752751, + 0.04861194447777911, + 0.07552302092083683, + 0.35501420056802274, + 0.04340173606944278, + 0.026911076443057725, + 0.1467058682347294, + 0.05122204888195528 + ], + [ + 0.017629118544072793, + 0.18009099545022747, + 0.10909454527273635, + 0.03620818959052047, + 0.05621718914054297, + 0.3439828008599569, + 0.0447777611119444, + 0.014289285535723213, + 0.07241637918104094, + 0.12529373531323432 + ], + [ + 0.020888955552222387, + 0.15869206539673014, + 0.08010599470026498, + 0.03566821658917054, + 0.13979301034948252, + 0.24498775061246936, + 0.048437578121093935, + 0.014439278036098194, + 0.14879256037198138, + 0.10819459027048647 + ], + [ + 0.02567, + 0.3113, + 0.05495, + 0.03369, + 0.04934, + 0.2595, + 0.0349, + 0.02166, + 0.06699, + 0.142 + ], + [ + 0.01993, + 0.152, + 0.162, + 0.03322, + 0.03821, + 0.343, + 0.04485, + 0.02492, + 0.1121, + 0.06977 + ], + [ + 0.015809209539523028, + 0.18909054547272638, + 0.08299585020748963, + 0.032938353082345884, + 0.10079496025198742, + 0.19239038048097595, + 0.04215789210539474, + 0.044137793110344485, + 0.10669466526673668, + 0.1929903504824759 + ], + [ + 0.02324046480929618, + 0.2183043660873217, + 0.11200224004480087, + 0.029330586611732226, + 0.05676113522270444, + 0.31350627012540244, + 0.04495089901798035, + 0.017140342806856133, + 0.11200224004480087, + 0.07276145522910457 + ], + [ + 0.022280000000000005, + 0.24420000000000006, + 0.08586000000000002, + 0.028350000000000007, + 0.09923000000000003, + 0.23370000000000005, + 0.05468000000000001, + 0.016200000000000003, + 0.10210000000000002, + 0.11340000000000003 + ], + [ + 0.018110362207244143, + 0.3264065281305626, + 0.04383087661753235, + 0.027710554211084218, + 0.042380847616952336, + 0.1893037860757215, + 0.05705114102282045, + 0.0382207644152883, + 0.1762035240704814, + 0.08078161563231265 + ], + [ + 0.057245724572457246, + 0.28132813281328134, + 0.11621162116211621, + 0.025762576257625763, + 0.13551355135513551, + 0.23682368236823684, + 0.039213921392139216, + 0.01617161716171617, + 0.06339633963396339, + 0.028332833283328335 + ], + [ + 0.012, + 0.108, + 0.056, + 0.024, + 0.032, + 0.108, + 0.076, + 0.032, + 0.252, + 0.3 + ] + ] + } + ], + "cells": [ + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13", + "n": 16, + "mean": 0.041764604649869704, + "sd": 0.029890750202192062, + "log2": 0.46672649022575663, + "p": 0.1746038985447137, + "q": 0.3269279431247544 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_CD4_T_naive", + "n": 16, + "mean": 0.15190356463785532, + "sd": 0.052543072466273086, + "log2": -0.39043349341761374, + "p": 0.039443948769039554, + "q": 0.2036386575363233 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_CD4_T_reg", + "n": 16, + "mean": 0.11608881987570877, + "sd": 0.0371644270301851, + "log2": -0.008487341666750163, + "p": 0.9671721726016329, + "q": 0.9878261597675358 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13", + "n": 16, + "mean": 0.06966859761265197, + "sd": 0.03227313715347496, + "log2": 0.6126131061782081, + "p": 0.021817016905044912, + "q": 0.2036386575363233 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_CD8_T_ISG", + "n": 16, + "mean": 0.09179150282027985, + "sd": 0.029923115933599146, + "log2": 0.4069229426617545, + "p": 0.030829201866788468, + "q": 0.2036386575363233 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic", + "n": 16, + "mean": 0.21403047506086356, + "sd": 0.06365124309364646, + "log2": -0.210848443304061, + "p": 0.1275575199120057, + "q": 0.2733375426685836 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_Cycling_T_NK", + "n": 16, + "mean": 0.08591550760006032, + "sd": 0.02890586894559702, + "log2": 0.5913776781983662, + "p": 0.002655302826240493, + "q": 0.0796590847872148 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_ILC", + "n": 16, + "mean": 0.021448453087593165, + "sd": 0.01460333448033079, + "log2": -0.0040707993931252545, + "p": 0.9878261597675358, + "q": 0.9878261597675358 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_NK_CD56", + "n": 16, + "mean": 0.1461334361981094, + "sd": 0.07532778513387708, + "log2": 0.2816380097994642, + "p": 0.29803578500595473, + "q": 0.40641243409902916 + }, + { + "cohort": "HRD-Dup", + "part": "custom:spectrum-sc-tnk/TNK_NK_cytotoxic", + "n": 16, + "mean": 0.06125503845700797, + "sd": 0.04111324353302321, + "log2": -0.6027211448315541, + "p": 0.07449052937945012, + "q": 0.24584475786942672 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13", + "n": 6, + "mean": 0.032414189855266694, + "sd": 0.014095775427366751, + "log2": -0.13746894811195204, + "p": 0.661095488316624, + "q": 0.7628024865191816 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_CD4_T_naive", + "n": 6, + "mean": 0.19636107871920258, + "sd": 0.1035493395702611, + "log2": 0.16778591812770258, + "p": 0.6400516889324472, + "q": 0.7628024865191816 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_CD4_T_reg", + "n": 6, + "mean": 0.15650634410178976, + "sd": 0.09043815858643856, + "log2": 0.5249285616065666, + "p": 0.2534726696454602, + "q": 0.3806240487137471 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13", + "n": 6, + "mean": 0.04917779439461248, + "sd": 0.035170968771482645, + "log2": -0.2205584211008788, + "p": 0.6090900232297681, + "q": 0.7613625290372101 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_CD8_T_ISG", + "n": 6, + "mean": 0.06405298810939723, + "sd": 0.01815140087378887, + "log2": -0.3538518882978392, + "p": 0.08194825262314225, + "q": 0.24584475786942672 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic", + "n": 6, + "mean": 0.23066209575623095, + "sd": 0.056964861351264835, + "log2": -0.01611028894512429, + "p": 0.9239098664105446, + "q": 0.9878261597675358 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_Cycling_T_NK", + "n": 6, + "mean": 0.05696087719362684, + "sd": 0.013672655966268555, + "log2": -0.337167943092236, + "p": 0.07190710474036444, + "q": 0.24584475786942672 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_ILC", + "n": 6, + "mean": 0.017912966744540283, + "sd": 0.0031385143759783602, + "log2": -0.2946146664905708, + "p": 0.10824155718624162, + "q": 0.27060389296560405 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_NK_CD56", + "n": 6, + "mean": 0.13040861138441273, + "sd": 0.10943015918307013, + "log2": -0.016096272627213606, + "p": 0.9756652213476557, + "q": 0.9878261597675358 + }, + { + "cohort": "HRD-Del", + "part": "custom:spectrum-sc-tnk/TNK_NK_cytotoxic", + "n": 6, + "mean": 0.0655430537409205, + "sd": 0.025107056242677013, + "log2": -0.3174350004719713, + "p": 0.29131287416539386, + "q": 0.40641243409902916 + }, + { + "…": "10 more", + "sha256": "73773123f6f4625a" + } + ], + "tested": 30, + "significant": 0 + }, + "participation": { + "studies": [ + { + "study": "msk_spectrum_tme_2022", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Each patient's 10 parts (clinical attributes), divided by their sum so every bar is a whole; cases ordered by CD8 T CXCL13, highest first. Each cohort is compared with the view's other cohorts pooled, part by part: log2 of the ratio of means (each + 0.001), Welch's t from the cohorts' n, mean and variance, Benjamini–Hochberg across the 30 comparisons. Parts of a whole are not independent — one part's rise is the others' fall — and a case in two cohorts counts in both. Entropy is Shannon's (natural log) over each case's shares. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Sum each part over the cohort's patients", + "detail": "The composition:moments query above: each patient's 10 parts read and put in part order inside the database; a patient with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those patients n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query.", + "scope": "HRD-Dup · msk_spectrum_tme_2022", + "rowsOut": 16 + }, + { + "kind": "fetch", + "title": "Sum each part over the cohort's patients", + "detail": "The composition:moments query above: each patient's 10 parts read and put in part order inside the database; a patient with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those patients n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query.", + "scope": "HRD-Del · msk_spectrum_tme_2022", + "rowsOut": 6 + }, + { + "kind": "fetch", + "title": "Sum each part over the cohort's patients", + "detail": "The composition:moments query above: each patient's 10 parts read and put in part order inside the database; a patient with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those patients n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query.", + "scope": "FBI · msk_spectrum_tme_2022", + "rowsOut": 14 + }, + { + "kind": "statistic", + "title": "Each cohort against the others pooled, per part; then Benjamini–Hochberg", + "detail": "The other cohorts' sums are added into one group. Effect: log2((mean + 0.001) / (others' mean + 0.001)). Test: Welch's unequal-variance t from each side's n, mean and variance (Σp² − (Σp)²/n)/(n − 1), two-sided; not tested when either side has under 2 patients or neither has any spread. q across every comparison tested.", + "params": [ + [ + "comparisons", + "30" + ] + ] + } + ], + "implementation": { + "functions": [ + "welchT", + "varianceFromMoments", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Welch's t from moments matches scipy 1.18.1 ttest_ind(equal_var=False) and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts).", + "check": { + "composition:tested": { + "v": 30 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13:mean": { + "v": 0.041764604649869704, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13:log2": { + "v": 0.46672649022575663, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13:p": { + "v": 0.1746038985447137, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13:q": { + "v": 0.3269279431247544, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_naive:mean": { + "v": 0.15190356463785532, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_naive:log2": { + "v": -0.39043349341761374, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_naive:p": { + "v": 0.039443948769039554, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_naive:q": { + "v": 0.2036386575363233, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_reg:mean": { + "v": 0.11608881987570877, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_reg:log2": { + "v": -0.008487341666750163, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_reg:p": { + "v": 0.9671721726016329, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD4_T_reg:q": { + "v": 0.9878261597675358, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13:mean": { + "v": 0.06966859761265197, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13:log2": { + "v": 0.6126131061782081, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13:p": { + "v": 0.021817016905044912, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13:q": { + "v": 0.2036386575363233, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_ISG:mean": { + "v": 0.09179150282027985, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_ISG:log2": { + "v": 0.4069229426617545, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|custom:spectrum-sc-tnk/TNK_CD8_T_ISG:p": { + "v": 0.030829201866788468, + "rel": 0.000001, + "abs": 1e-300 + }, + "…": { + "more": 101, + "sha256": "268bc7a39d63fe8c" + } + } + } + }, + { + "kind": "composition", + "cohorts": [ + "HRD-Dup", + "HRD-Del", + "FBI" + ], + "composition": { + "source": "genericAssay", + "sourceName": "Cell Type Relative Fractions", + "unit": "samples", + "normalize": true, + "sort": "T_cell", + "parts": [ + { + "id": "B_cell", + "name": "B_cell" + }, + { + "id": "Dendritic_cell", + "name": "Dendritic_cell" + }, + { + "id": "Endothelial_cell", + "name": "Endothelial_cell" + }, + { + "id": "Fibroblast", + "name": "Fibroblast" + }, + { + "id": "Mast_cell", + "name": "Mast_cell" + }, + { + "id": "Monocyte", + "name": "Monocyte" + }, + { + "id": "Other", + "name": "Other" + }, + { + "id": "Ovarian_cancer_cell", + "name": "Ovarian_cancer_cell" + }, + { + "id": "Plasma_cell", + "name": "Plasma_cell" + }, + { + "id": "T_cell", + "name": "T_cell" + } + ], + "groups": [ + { + "cohort": "HRD-Dup", + "n": 19, + "incomplete": 0, + "invalid": 0, + "entropy": { + "mean": 1.3339457808644424, + "sd": 0.2553770359998915 + }, + "cases": [ + [ + 0.18227264, + 0.007498558, + 0.053835801, + 0.014035762, + 0.000769083, + 0.021918862, + 0, + 0.060373005, + 0.040953663, + 0.618342626 + ], + [ + 0.018712916000000003, + 0.010497490000000002, + 0.00022820600000000003, + 0.0018256500000000003, + 0.0022820630000000004, + 0.27339114600000003, + 0, + 0.009584665000000001, + 0.14491100000000004, + 0.5385668640000001 + ], + [ + 0.004245993995754006, + 0.006574441993425557, + 0.0015066429984933569, + 0.03136556596863443, + 0.000273934999726065, + 0.010820435989179563, + 0, + 0.45938912454061087, + 0.01287494898712505, + 0.47294891052705107 + ], + [ + 0.024976584024976586, + 0.0049953170049953175, + 0.001248829001248829, + 0.00811739000811739, + 0.0009366220009366221, + 0.25850764925850767, + 0, + 0.2613175152613175, + 0.1270683731270684, + 0.31283172031283174 + ], + [ + 0.10108530999999997, + 0.005047955999999999, + 0.056789499999999986, + 0.26438667299999996, + 0.003912165999999999, + 0.07407874799999999, + 0, + 0.16468955099999996, + 0.04151943499999999, + 0.2884906609999999 + ], + [ + 0.011037527988962471, + 0.0037357789962642204, + 0.0035659699964340295, + 0.21344880278655118, + 0.00033961599966038396, + 0.34844625565155374, + 0, + 0.13618610986381388, + 0.0062828999937171, + 0.27695703872304295 + ], + [ + 0.064893954, + 0.005539728, + 0.082621083, + 0.430674264, + 0.000474834, + 0.061411839, + 0, + 0.070750237, + 0.031180753, + 0.252453308 + ], + [ + 0.010852862021705724, + 0.003937764007875527, + 0.021705724043411447, + 0.386189013772378, + 0.0017287740034575478, + 0.17719938535439875, + 0, + 0.09268152118536303, + 0.05407222410814445, + 0.2516327315032654 + ], + [ + 0.04217791404217791, + 0.003834356003834356, + 0.004601227004601227, + 0.003834356003834356, + 0.001533742001533742, + 0.08435582808435582, + 0, + 0.6165644176165643, + 0.03757668703757668, + 0.20552147220552147 + ], + [ + 0.0022002200022002206, + 0, + 0.013201320013201323, + 0.14008067514008068, + 0.0003667030003667031, + 0.4158415844158416, + 0, + 0.22295562922295567, + 0.003667033003667034, + 0.20168683520168687 + ], + [ + 0.00188603, + 0.001616597, + 0.003367911, + 0.223763977, + 0.000134716, + 0.273878486, + 0, + 0.298262158, + 0.000269433, + 0.196820692 + ], + [ + 0.008910558, + 0.002858104, + 0.051950235, + 0.341795562, + 0.002521856, + 0.116677875, + 0, + 0.237222596, + 0.048924008, + 0.189139206 + ], + [ + 0.00009940000129220002, + 0, + 0.019087384248135993, + 0.0306193463980515, + 0.00019882700258475102, + 0.4255890305326574, + 0, + 0.34705239551168116, + 0.00019882700258475102, + 0.17715478930301226 + ], + [ + 0.004828227, + 0, + 0.044939647, + 0.324605385, + 0.000185701, + 0.136490251, + 0, + 0.306406685, + 0.013370474, + 0.16917363 + ], + [ + 0.0007987220000000001, + 0.00015974400000000002, + 0.006070288000000001, + 0.011501597000000002, + 0, + 0.4757188500000001, + 0, + 0.36980830700000006, + 0.00031948900000000006, + 0.13562300300000002 + ], + [ + 0.002427184, + 0.006067961, + 0.000485437, + 0.000485437, + 0, + 0.437257282, + 0, + 0.411165049, + 0.013713592, + 0.128398058 + ], + [ + 0.0011016859988983141, + 0.00033050599966949403, + 0.03404208396595792, + 0.4076236635923764, + 0.00033050599966949403, + 0.3522088796477912, + 0, + 0.08934669991065332, + 0.00033050599966949403, + 0.11468546888531454 + ], + [ + 0.000658182999341817, + 0.00043878899956121094, + 0.012066695987933303, + 0.27270732772729267, + 0.00043878899956121094, + 0.12000877587999122, + 0, + 0.276437033723563, + 0.30846862669153136, + 0.008775778991224219 + ], + [ + 0, + 0, + 0.018883086, + 0.35435918, + 0, + 0, + 0, + 0.626355966, + 0, + 0.000401768 + ] + ] + }, + { + "cohort": "HRD-Del", + "n": 8, + "incomplete": 0, + "invalid": 0, + "entropy": { + "mean": 1.2045546234438649, + "sd": 0.25155597847895567 + }, + "cases": [ + [ + 0.02209551, + 0.007127584, + 0, + 0.000712758, + 0, + 0.055595153, + 0, + 0.000712758, + 0.096935139, + 0.816821098 + ], + [ + 0.0040672950040672945, + 0.005546312005546311, + 0, + 0.03697541103697541, + 0.00018487700018487697, + 0.17729709717729705, + 0, + 0.36772046636772043, + 0.0012941390012941388, + 0.40691440240691434 + ], + [ + 0.0017403919982596078, + 0.005366206994633792, + 0.006671500993328498, + 0.35242929664757067, + 0.0007251629992748369, + 0.09006526490993473, + 0, + 0.16026105883973893, + 0.003915880996084119, + 0.37882523562117476 + ], + [ + 0.074731627, + 0.000825764, + 0.018786127, + 0.066473988, + 0.003715937, + 0.154211396, + 0, + 0.451692816, + 0.00433526, + 0.225227085 + ], + [ + 0.008707931017415863, + 0.0016474460032948918, + 0.00682513501365027, + 0.10402447620804896, + 0.000235349000470698, + 0.3652624157305248, + 0, + 0.33749117467498235, + 0.001882796003765592, + 0.17392327634784652 + ], + [ + 0.0007794229992205769, + 0.0010021159989978838, + 0.007014808992985191, + 0.26723082073276916, + 0.000334038999665961, + 0.42133392657866603, + 0, + 0.22391715777608284, + 0.0017815389982184608, + 0.07660616892339382 + ], + [ + 0, + 0, + 0.016211604, + 0.335110922, + 0, + 0.476109215, + 0, + 0.118387372, + 0, + 0.054180887 + ], + [ + 0.001766784, + 0.001124317, + 0.022486348, + 0.043366527, + 0.00048185, + 0.212977835, + 0, + 0.663186637, + 0.005782204, + 0.048827498 + ] + ] + }, + { + "cohort": "FBI", + "n": 19, + "incomplete": 0, + "invalid": 0, + "entropy": { + "mean": 1.17549687627788, + "sd": 0.42712055515170233 + }, + "cases": [ + [ + 0.015200869, + 0.01194354, + 0, + 0.000361925, + 0.005790807, + 0.086862106, + 0, + 0.001809627, + 0.015200869, + 0.862830257 + ], + [ + 0.009783575, + 0.016305959, + 0.001778832, + 0.001778832, + 0.005040024, + 0.36169582, + 0, + 0.010080047, + 0.014823599, + 0.578713312 + ], + [ + 0.016471033983528963, + 0.009087466990912533, + 0.023286633976713364, + 0.1268458918731541, + 0.0011359329988640669, + 0.08065126791934872, + 0, + 0.15032184784967814, + 0.03407800096592199, + 0.558121923441878 + ], + [ + 0.03427977803427978, + 0.004847645004847645, + 0.001558172001558172, + 0.026662050026662047, + 0.002077562002077562, + 0.09106648209106648, + 0, + 0.2929362882929363, + 0.023545706023545707, + 0.5230263165230263 + ], + [ + 0.02960640902960641, + 0.00359921000359921, + 0.021711367021711368, + 0.12469522812469525, + 0.001509346001509346, + 0.10948566110948567, + 0, + 0.1596424011596424, + 0.06629513506629514, + 0.4834552424834553 + ], + [ + 0.05380927, + 0.000532765, + 0.044219499, + 0.059136921, + 0.00106553, + 0.096785651, + 0, + 0.269756704, + 0.018824365, + 0.455869295 + ], + [ + 0.0033774659966225346, + 0.0029721699970278307, + 0.020940285979059715, + 0.17765468782234534, + 0.001080788998919211, + 0.14293434185706566, + 0, + 0.21169954078830047, + 0.022831666977168336, + 0.416509051583491 + ], + [ + 0.057545508, + 0.029066353, + 0, + 0.005578391, + 0.000440399, + 0.252789196, + 0, + 0.29374633, + 0.007780388, + 0.353053435 + ], + [ + 0.03912543196087458, + 0.011507479988492521, + 0.07479861892520138, + 0.1432681238567319, + 0.012082853987917148, + 0.066168008933832, + 0, + 0.2779056387220944, + 0.024165707975834297, + 0.3509781356490219 + ], + [ + 0.03026004703026005, + 0.0029944840029944844, + 0.029156816029156818, + 0.5855003945855004, + 0.0007880220007880221, + 0.070921986070922, + 0, + 0.011032309011032311, + 0.0031520880031520883, + 0.2661938532661939 + ], + [ + 0.006566738, + 0.003568879, + 0.003283369, + 0.137615989, + 0.001713062, + 0.271663098, + 0, + 0.317915774, + 0.010563883, + 0.247109208 + ], + [ + 0.0026122650052245303, + 0.00024878700049757403, + 0.03321308606642618, + 0.08010946616021895, + 0, + 0.294564000589128, + 0, + 0.35477049470954103, + 0.0007463610014927221, + 0.2337355394674711 + ], + [ + 0.033402922966597075, + 0.003131523996868476, + 0, + 0.0020876829979123166, + 0, + 0.7505219202494781, + 0, + 0, + 0, + 0.21085594978914401 + ], + [ + 0.00953911, + 0.000401647, + 0.036851089, + 0.088864344, + 0.002911939, + 0.152826589, + 0, + 0.495431268, + 0.012953108, + 0.200220906 + ], + [ + 0.0023255810023255813, + 0.002790698002790698, + 0.0227906980227907, + 0.050465116050465116, + 0.0023255810023255813, + 0.08720930208720931, + 0, + 0.6516279076516279, + 0.004883721004883721, + 0.1755813951755814 + ], + [ + 0.001278445001278445, + 0.001022756001022756, + 0.0350294040350294, + 0.2608028642608029, + 0.0007670670007670669, + 0.3469700843469701, + 0, + 0.19202250119202252, + 0.004602403004602402, + 0.1575044751575045 + ], + [ + 0.0006273529987452939, + 0.0007841909984316178, + 0.03387703893224592, + 0.03685696392628607, + 0.004548305990903388, + 0.39883939720232114, + 0, + 0.45467377609065235, + 0.006116687987766624, + 0.06367628587264741 + ], + [ + 0, + 0, + 0.015049585585338955, + 0.013593174722241577, + 0, + 0.07850751762029334, + 0.00006939999347640062, + 0.879395159336855, + 0.00006939999347640062, + 0.013315762748318302 + ], + [ + 0, + 0, + 0.007498027, + 0.011444357, + 0, + 0, + 0, + 0.981057616, + 0, + 0 + ] + ] + } + ], + "cells": [ + { + "cohort": "HRD-Dup", + "part": "B_cell", + "n": 19, + "mean": 0.025429784846068906, + "sd": 0.04624565364041044, + "log2": 0.552089045579386, + "p": 0.4653273526789026, + "q": 0.7304459576478041 + }, + { + "cohort": "HRD-Dup", + "part": "Dendritic_cell", + "n": 19, + "mean": 0.0033227942634539835, + "sd": 0.0031009695668730453, + "log2": -0.4041004900557177, + "p": 0.3325952043539977, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Dup", + "part": "Endothelial_cell", + "n": 19, + "mean": 0.02264195111891671, + "sd": 0.0243635188415156, + "log2": 0.3237036404485407, + "p": 0.4732090127512971, + "q": 0.7304459576478041 + }, + { + "cohort": "HRD-Dup", + "part": "Fibroblast", + "n": 19, + "mean": 0.18217998044196398, + "sd": 0.16326511446014325, + "log2": 0.6432653766744568, + "p": 0.16053870710566653, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Dup", + "part": "Mast_cell", + "n": 19, + "mean": 0.0008646280530261326, + "sd": 0.0010651704894020463, + "log2": -0.5932869405889261, + "p": 0.10013306419957604, + "q": 0.5468396604484965 + }, + { + "cohort": "HRD-Dup", + "part": "Monocyte", + "n": 19, + "mean": 0.21388427177969882, + "sd": 0.1597621891751261, + "log2": 0.02042477070176719, + "p": 0.9513639571298499, + "q": 0.9841696108239827 + }, + { + "cohort": "HRD-Dup", + "part": "Other", + "n": 19, + "mean": 0, + "sd": 0, + "log2": -0.003703502588202256, + "p": 0.32652702226038766, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Dup", + "part": "Ovarian_cancer_cell", + "n": 19, + "mean": 0.26613414030718535, + "sd": 0.17772788884911003, + "log2": -0.21232232827407022, + "p": 0.5113121703534629, + "q": 0.7304459576478041 + }, + { + "cohort": "HRD-Dup", + "part": "Plasma_cell", + "n": 19, + "mean": 0.04661589331321497, + "sd": 0.07553483117623482, + "log2": 1.6363057856456773, + "p": 0.0850285624798534, + "q": 0.5468396604484965 + }, + { + "cohort": "HRD-Dup", + "part": "T_cell", + "n": 19, + "mean": 0.23892655587647113, + "sd": 0.16018040518697382, + "log2": -0.3677912208672915, + "p": 0.2303815203829579, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Del", + "part": "B_cell", + "n": 8, + "mean": 0.014236120252370416, + "sd": 0.025497393757524595, + "log2": -0.5824999124824833, + "p": 0.489103098450543, + "q": 0.7304459576478041 + }, + { + "cohort": "HRD-Del", + "part": "Dendritic_cell", + "n": 8, + "mean": 0.00282996825030911, + "sd": 0.0027243540617528247, + "log2": -0.5008108321447018, + "p": 0.2458786181535516, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Del", + "part": "Endothelial_cell", + "n": 8, + "mean": 0.009749440499995495, + "sd": 0.008462157243137017, + "log2": -1.09611655633518, + "p": 0.013115587848377927, + "q": 0.3934676354513378 + }, + { + "cohort": "HRD-Del", + "part": "Fibroblast", + "n": 8, + "mean": 0.15079052495317052, + "sd": 0.14367822125640115, + "log2": 0.08640061267496936, + "p": 0.8790826326904027, + "q": 0.9767584807671141 + }, + { + "cohort": "HRD-Del", + "part": "Mast_cell", + "n": 8, + "mean": 0.0007096518749495466, + "sd": 0.0012385782764091585, + "log2": -0.5887326598564296, + "p": 0.15039694782588586, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Del", + "part": "Monocyte", + "n": 8, + "mean": 0.24410653792455284, + "sd": 0.1570679681287984, + "log2": 0.248138250958632, + "p": 0.544092629753131, + "q": 0.7336598320628585 + }, + { + "cohort": "HRD-Del", + "part": "Other", + "n": 8, + "mean": 0, + "sd": 0, + "log2": -0.0026324134070575805, + "p": 0.3238058723549804, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Del", + "part": "Ovarian_cancer_cell", + "n": 8, + "mean": 0.29042118008231554, + "sd": 0.20977689971127533, + "log2": -0.0034312141155976145, + "p": 0.9934914540071049, + "q": 0.9934914540071049 + }, + { + "cohort": "HRD-Del", + "part": "Plasma_cell", + "n": 8, + "mean": 0.014490869749920289, + "sd": 0.033364854922862064, + "log2": -1.0207181605388869, + "p": 0.30046544517387885, + "q": 0.5869327135658783 + }, + { + "cohort": "HRD-Del", + "part": "T_cell", + "n": 8, + "mean": 0.27266570641241616, + "sd": 0.2601309122641955, + "log2": -0.044942886340446825, + "p": 0.9310404335598147, + "q": 0.9841696108239827 + }, + { + "…": "10 more", + "sha256": "90a2e673431b212c" + } + ], + "tested": 30, + "significant": 0 + }, + "participation": { + "studies": [ + { + "study": "msk_spectrum_tme_2022", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Each sample's 10 parts (entities of “Cell Type Relative Fractions”), divided by their sum so every bar is a whole; cases ordered by T_cell, highest first. Each cohort is compared with the view's other cohorts pooled, part by part: log2 of the ratio of means (each + 0.001), Welch's t from the cohorts' n, mean and variance, Benjamini–Hochberg across the 30 comparisons. Parts of a whole are not independent — one part's rise is the others' fall — and a case in two cohorts counts in both. Entropy is Shannon's (natural log) over each case's shares. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Sum each part over the cohort's samples", + "detail": "The composition:moments query above: each sample's 10 parts read and put in part order inside the database; a sample with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those samples n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query.", + "scope": "HRD-Dup · msk_spectrum_tme_2022", + "rowsOut": 19 + }, + { + "kind": "fetch", + "title": "Sum each part over the cohort's samples", + "detail": "The composition:moments query above: each sample's 10 parts read and put in part order inside the database; a sample with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those samples n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query.", + "scope": "HRD-Del · msk_spectrum_tme_2022", + "rowsOut": 8 + }, + { + "kind": "fetch", + "title": "Sum each part over the cohort's samples", + "detail": "The composition:moments query above: each sample's 10 parts read and put in part order inside the database; a sample with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those samples n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query.", + "scope": "FBI · msk_spectrum_tme_2022", + "rowsOut": 19 + }, + { + "kind": "statistic", + "title": "Each cohort against the others pooled, per part; then Benjamini–Hochberg", + "detail": "The other cohorts' sums are added into one group. Effect: log2((mean + 0.001) / (others' mean + 0.001)). Test: Welch's unequal-variance t from each side's n, mean and variance (Σp² − (Σp)²/n)/(n − 1), two-sided; not tested when either side has under 2 samples or neither has any spread. q across every comparison tested.", + "params": [ + [ + "comparisons", + "30" + ] + ] + } + ], + "implementation": { + "functions": [ + "welchT", + "varianceFromMoments", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Welch's t from moments matches scipy 1.18.1 ttest_ind(equal_var=False) and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts).", + "check": { + "composition:tested": { + "v": 30 + }, + "composition:HRD-Dup|B_cell:mean": { + "v": 0.025429784846068906, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|B_cell:log2": { + "v": 0.552089045579386, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|B_cell:p": { + "v": 0.4653273526789026, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|B_cell:q": { + "v": 0.7304459576478041, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Dendritic_cell:mean": { + "v": 0.0033227942634539835, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Dendritic_cell:log2": { + "v": -0.4041004900557177, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Dendritic_cell:p": { + "v": 0.3325952043539977, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Dendritic_cell:q": { + "v": 0.5869327135658783, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Endothelial_cell:mean": { + "v": 0.02264195111891671, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Endothelial_cell:log2": { + "v": 0.3237036404485407, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Endothelial_cell:p": { + "v": 0.4732090127512971, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Endothelial_cell:q": { + "v": 0.7304459576478041, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Fibroblast:mean": { + "v": 0.18217998044196398, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Fibroblast:log2": { + "v": 0.6432653766744568, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Fibroblast:p": { + "v": 0.16053870710566653, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Fibroblast:q": { + "v": 0.5869327135658783, + "rel": 0.000001, + "abs": 1e-300 + }, + "composition:HRD-Dup|Mast_cell:mean": { + "v": 0.0008646280530261326, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Mast_cell:log2": { + "v": -0.5932869405889261, + "rel": 0.000001, + "abs": 1e-9 + }, + "composition:HRD-Dup|Mast_cell:p": { + "v": 0.10013306419957604, + "rel": 0.000001, + "abs": 1e-300 + }, + "…": { + "more": 101, + "sha256": "bc3bde605013f805" + } + } + } + } + ] +} diff --git a/test/snapshots/composition.sql b/test/snapshots/composition.sql new file mode 100644 index 0000000..c40cbe7 --- /dev/null +++ b/test/snapshots/composition.sql @@ -0,0 +1,1642 @@ +-- cohort HRD-Dup +-- msk_spectrum_tme_2022 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Dup')))) + +-- cohort HRD-Del +-- msk_spectrum_tme_2022 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Del')))) + +-- cohort FBI +-- msk_spectrum_tme_2022 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('FBI')))) + +-- view 0 composition: composition:cases:FBI · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('FBI'))))), +parts AS ( +SELECT id, toUInt16(0) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(1) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(2) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(3) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(4) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(5) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(6) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(7) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(8) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(9) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT ps, h FROM cases ORDER BY ps[4] DESC, cityHash64(id) +LIMIT 2001 + +-- view 0 composition: composition:cases:HRD-Del · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Del'))))), +parts AS ( +SELECT id, toUInt16(0) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(1) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(2) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(3) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(4) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(5) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(6) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(7) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(8) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(9) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT ps, h FROM cases ORDER BY ps[4] DESC, cityHash64(id) +LIMIT 2001 + +-- view 0 composition: composition:cases:HRD-Dup · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Dup'))))), +parts AS ( +SELECT id, toUInt16(0) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(1) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(2) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(3) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(4) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(5) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(6) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(7) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(8) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(9) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT ps, h FROM cases ORDER BY ps[4] DESC, cityHash64(id) +LIMIT 2001 + +-- view 0 composition: composition:moments:FBI · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('FBI'))))), +parts AS ( +SELECT id, toUInt16(0) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(1) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(2) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(3) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(4) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(5) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(6) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(7) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(8) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(9) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT count() AS n, sumForEach(ps) AS sx, sumForEach(arrayMap(x -> x * x, ps)) AS sxx, sum(h) AS hx, sum(h * h) AS hxx, + (SELECT countIf(k < 10) FROM raw) AS incomplete, + (SELECT countIf(k = 10 AND NOT (lo >= 0 AND tot > 0)) FROM raw) AS invalid +FROM cases + +-- view 0 composition: composition:moments:HRD-Del · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Del'))))), +parts AS ( +SELECT id, toUInt16(0) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(1) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(2) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(3) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(4) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(5) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(6) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(7) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(8) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(9) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT count() AS n, sumForEach(ps) AS sx, sumForEach(arrayMap(x -> x * x, ps)) AS sxx, sum(h) AS hx, sum(h * h) AS hxx, + (SELECT countIf(k < 10) FROM raw) AS incomplete, + (SELECT countIf(k = 10 AND NOT (lo >= 0 AND tot > 0)) FROM raw) AS invalid +FROM cases + +-- view 0 composition: composition:moments:HRD-Dup · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Dup'))))), +parts AS ( +SELECT id, toUInt16(0) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_c69fe134) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(1) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e449dcfd) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_naive' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(2) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_f23281fa) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD4_T_reg' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(3) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d53efc38) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_CXCL13' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(4) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_36ce14b9) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_ISG' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(5) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e42f954c) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_CD8_T_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(6) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_e52f52c7) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_Cycling_T_NK' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(7) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_d3243663) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_ILC' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(8) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_33a1d461) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_CD56' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +UNION ALL +SELECT id, toUInt16(9) AS c, toFloat64(assumeNotNull(av)) AS v FROM (SELECT id, v AS av FROM ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM (SELECT internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM snapshot_db.clinical_data_derived + UNION ALL + SELECT toInt32(0) AS internal_id, sample_unique_id, patient_unique_id, attribute_name, attribute_value, cancer_study_identifier, type + FROM _custom_clinical_a671983f) + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND attribute_name = 'custom:spectrum-sc-tnk/TNK_NK_cytotoxic' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +)) WHERE isFinite(ifNull(av, nan)) +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT count() AS n, sumForEach(ps) AS sx, sumForEach(arrayMap(x -> x * x, ps)) AS sxx, sum(h) AS hx, sum(h * h) AS hxx, + (SELECT countIf(k < 10) FROM raw) AS incomplete, + (SELECT countIf(k = 10 AND NOT (lo >= 0 AND tot > 0)) FROM raw) AS invalid +FROM cases + +-- view 1 composition: composition:cases:FBI · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('FBI'))))), +parts AS ( +SELECT id, c, assumeNotNull(avg(val)) AS v FROM ( + SELECT sample_unique_id AS id, toUInt16(indexOf(['B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell'], entity_stable_id) - 1) AS c, + if(isFinite(ifNull(toFloat64OrNull(value), nan)), toFloat64OrNull(value), NULL) AS val + FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' + AND entity_stable_id IN ('B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell') + AND patient_unique_id IN (SELECT concat('msk_spectrum_tme_2022_', pid) FROM cohort) +) WHERE isFinite(ifNull(val, nan)) GROUP BY id, c +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT ps, h FROM cases ORDER BY ps[10] DESC, cityHash64(id) +LIMIT 2001 + +-- view 1 composition: composition:cases:HRD-Del · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Del'))))), +parts AS ( +SELECT id, c, assumeNotNull(avg(val)) AS v FROM ( + SELECT sample_unique_id AS id, toUInt16(indexOf(['B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell'], entity_stable_id) - 1) AS c, + if(isFinite(ifNull(toFloat64OrNull(value), nan)), toFloat64OrNull(value), NULL) AS val + FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' + AND entity_stable_id IN ('B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell') + AND patient_unique_id IN (SELECT concat('msk_spectrum_tme_2022_', pid) FROM cohort) +) WHERE isFinite(ifNull(val, nan)) GROUP BY id, c +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT ps, h FROM cases ORDER BY ps[10] DESC, cityHash64(id) +LIMIT 2001 + +-- view 1 composition: composition:cases:HRD-Dup · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Dup'))))), +parts AS ( +SELECT id, c, assumeNotNull(avg(val)) AS v FROM ( + SELECT sample_unique_id AS id, toUInt16(indexOf(['B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell'], entity_stable_id) - 1) AS c, + if(isFinite(ifNull(toFloat64OrNull(value), nan)), toFloat64OrNull(value), NULL) AS val + FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' + AND entity_stable_id IN ('B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell') + AND patient_unique_id IN (SELECT concat('msk_spectrum_tme_2022_', pid) FROM cohort) +) WHERE isFinite(ifNull(val, nan)) GROUP BY id, c +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT ps, h FROM cases ORDER BY ps[10] DESC, cityHash64(id) +LIMIT 2001 + +-- view 1 composition: composition:entities · msk_spectrum_tme_2022 +WITH entities AS ( + SELECT DISTINCT entity_stable_id AS entity FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' +) +SELECT entity FROM entities ORDER BY entity + +-- view 1 composition: composition:moments:FBI · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('FBI'))))), +parts AS ( +SELECT id, c, assumeNotNull(avg(val)) AS v FROM ( + SELECT sample_unique_id AS id, toUInt16(indexOf(['B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell'], entity_stable_id) - 1) AS c, + if(isFinite(ifNull(toFloat64OrNull(value), nan)), toFloat64OrNull(value), NULL) AS val + FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' + AND entity_stable_id IN ('B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell') + AND patient_unique_id IN (SELECT concat('msk_spectrum_tme_2022_', pid) FROM cohort) +) WHERE isFinite(ifNull(val, nan)) GROUP BY id, c +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT count() AS n, sumForEach(ps) AS sx, sumForEach(arrayMap(x -> x * x, ps)) AS sxx, sum(h) AS hx, sum(h * h) AS hxx, + (SELECT countIf(k < 10) FROM raw) AS incomplete, + (SELECT countIf(k = 10 AND NOT (lo >= 0 AND tot > 0)) FROM raw) AS invalid +FROM cases + +-- view 1 composition: composition:moments:HRD-Del · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Del'))))), +parts AS ( +SELECT id, c, assumeNotNull(avg(val)) AS v FROM ( + SELECT sample_unique_id AS id, toUInt16(indexOf(['B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell'], entity_stable_id) - 1) AS c, + if(isFinite(ifNull(toFloat64OrNull(value), nan)), toFloat64OrNull(value), NULL) AS val + FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' + AND entity_stable_id IN ('B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell') + AND patient_unique_id IN (SELECT concat('msk_spectrum_tme_2022_', pid) FROM cohort) +) WHERE isFinite(ifNull(val, nan)) GROUP BY id, c +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT count() AS n, sumForEach(ps) AS sx, sumForEach(arrayMap(x -> x * x, ps)) AS sxx, sum(h) AS hx, sum(h * h) AS hxx, + (SELECT countIf(k < 10) FROM raw) AS incomplete, + (SELECT countIf(k = 10 AND NOT (lo >= 0 AND tot > 0)) FROM raw) AS invalid +FROM cases + +-- view 1 composition: composition:moments:HRD-Dup · msk_spectrum_tme_2022 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_spectrum_tme_2022_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_spectrum_tme_2022' AND type = 'patient' + AND attribute_name = 'CONSENSUS_SIGNATURE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('HRD-Dup'))))), +parts AS ( +SELECT id, c, assumeNotNull(avg(val)) AS v FROM ( + SELECT sample_unique_id AS id, toUInt16(indexOf(['B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell'], entity_stable_id) - 1) AS c, + if(isFinite(ifNull(toFloat64OrNull(value), nan)), toFloat64OrNull(value), NULL) AS val + FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' + AND entity_stable_id IN ('B_cell','Dendritic_cell','Endothelial_cell','Fibroblast','Mast_cell','Monocyte','Other','Ovarian_cancer_cell','Plasma_cell','T_cell') + AND patient_unique_id IN (SELECT concat('msk_spectrum_tme_2022_', pid) FROM cohort) +) WHERE isFinite(ifNull(val, nan)) GROUP BY id, c +), +raw AS ( + SELECT id, count() AS k, sum(v) AS tot, min(v) AS lo, arrayMap(x -> x.2, arraySort(x -> x.1, groupArray((c, v)))) AS vs + FROM parts GROUP BY id +), +cases AS ( + SELECT id, arrayMap(x -> x / tot, vs) AS ps, arrayMap(x -> x / tot, vs) AS sh, + arraySum(arrayMap(x -> if(x > 0, -x * log(x), 0), sh)) AS h + FROM raw WHERE k = 10 AND lo >= 0 AND tot > 0 +) +SELECT count() AS n, sumForEach(ps) AS sx, sumForEach(arrayMap(x -> x * x, ps)) AS sxx, sum(h) AS hx, sum(h * h) AS hxx, + (SELECT countIf(k < 10) FROM raw) AS incomplete, + (SELECT countIf(k = 10 AND NOT (lo >= 0 AND tot > 0)) FROM raw) AS invalid +FROM cases + +-- view 1 composition: composition:names · msk_spectrum_tme_2022 +WITH named AS ( + SELECT ge.stable_id AS entity, p.value AS name FROM snapshot_db.generic_entity_properties p + JOIN snapshot_db.genetic_entity ge ON ge.id = p.genetic_entity_id + WHERE p.name = 'NAME' AND ge.stable_id IN (SELECT DISTINCT entity_stable_id FROM snapshot_db.generic_assay_data_derived + WHERE profile_type = 'cell_type_relative_counts' AND profile_stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts') +) +SELECT entity, name FROM named + +-- view 1 composition: composition:profile · msk_spectrum_tme_2022 +SELECT datatype, generic_assay_type, ifNull(patient_level, 0) AS patient_level, name FROM snapshot_db.genetic_profile +WHERE stable_id = 'msk_spectrum_tme_2022_cell_type_relative_counts' AND genetic_alteration_type = 'GENERIC_ASSAY' diff --git a/test/snapshots/composition.svg b/test/snapshots/composition.svg new file mode 100644 index 0000000..2edeb22 --- /dev/null +++ b/test/snapshots/composition.svg @@ -0,0 +1,4 @@ + +Composition — clinical attributes by HRD-Dup, HRD-Del, FBICD4 T CXCL13CD4 T naiveCD4 T regCD8 T CXCL13CD8 T ISGCD8 T cytotoxicCycling T NKILCNK CD56NK cytotoxic0%20%40%60%80%100%share of patientHRD-Dup16 patients · entropy 2.07HRD-Dup · CD4 T CXCL13: mean 4.2%HRD-Dup · CD4 T naive: mean 15.2%HRD-Dup · CD4 T reg: mean 11.6%HRD-Dup · CD8 T CXCL13: mean 7.0%HRD-Dup · CD8 T ISG: mean 9.2%HRD-Dup · CD8 T cytotoxic: mean 21.4%HRD-Dup · Cycling T NK: mean 8.6%HRD-Dup · ILC: mean 2.1%HRD-Dup · NK CD56: mean 14.6%HRD-Dup · NK cytotoxic: mean 6.1%meanHRD-Del6 patients · entropy 1.96HRD-Del · CD4 T CXCL13: mean 3.2%HRD-Del · CD4 T naive: mean 19.6%HRD-Del · CD4 T reg: mean 15.7%HRD-Del · CD8 T CXCL13: mean 4.9%HRD-Del · CD8 T ISG: mean 6.4%HRD-Del · CD8 T cytotoxic: mean 23.1%HRD-Del · Cycling T NK: mean 5.7%HRD-Del · ILC: mean 1.8%HRD-Del · NK CD56: mean 13.0%HRD-Del · NK cytotoxic: mean 6.6%meanFBI14 patients · entropy 1.98FBI · CD4 T CXCL13: mean 2.9%FBI · CD4 T naive: mean 20.1%FBI · CD4 T reg: mean 10.0%FBI · CD8 T CXCL13: mean 4.4%FBI · CD8 T ISG: mean 7.1%FBI · CD8 T cytotoxic: mean 25.5%FBI · Cycling T NK: mean 5.7%FBI · ILC: mean 2.3%FBI · NK CD56: mean 11.6%FBI · NK cytotoxic: mean 10.6%meanEach cohort against the others, per partHRD-DupHRD-DelFBICD4 T CXCL134.2%HRD-Dup · CD4 T CXCL13: mean 4.2%, log2 vs others 0.47, p = 0.17, q = 0.333.2%HRD-Del · CD4 T CXCL13: mean 3.2%, log2 vs others −0.14, p = 0.66, q = 0.762.9%FBI · CD4 T CXCL13: mean 2.9%, log2 vs others −0.43, p = 0.19, q = 0.33CD4 T naive15.2%HRD-Dup · CD4 T naive: mean 15.2%, log2 vs others −0.39, p = 0.039, q = 0.2019.6%HRD-Del · CD4 T naive: mean 19.6%, log2 vs others 0.17, p = 0.64, q = 0.7620.1%FBI · CD4 T naive: mean 20.1%, log2 vs others 0.29, p = 0.14, q = 0.29CD4 T reg11.6%HRD-Dup · CD4 T reg: mean 11.6%, log2 vs others −0.0085, p = 0.97, q = 0.9915.7%HRD-Del · CD4 T reg: mean 15.7%, log2 vs others 0.52, p = 0.25, q = 0.3810.0%FBI · CD4 T reg: mean 10.0%, log2 vs others −0.35, p = 0.092, q = 0.25CD8 T CXCL137.0%HRD-Dup · CD8 T CXCL13: mean 7.0%, log2 vs others 0.61, p = 0.022, q = 0.204.9%HRD-Del · CD8 T CXCL13: mean 4.9%, log2 vs others −0.22, p = 0.61, q = 0.764.4%FBI · CD8 T CXCL13: mean 4.4%, log2 vs others −0.55, p = 0.041, q = 0.20CD8 T ISG9.2%HRD-Dup · CD8 T ISG: mean 9.2%, log2 vs others 0.41, p = 0.031, q = 0.206.4%HRD-Del · CD8 T ISG: mean 6.4%, log2 vs others −0.35, p = 0.082, q = 0.257.1%FBI · CD8 T ISG: mean 7.1%, log2 vs others −0.24, p = 0.25, q = 0.38CD8 T cytotoxic21.4%HRD-Dup · CD8 T cytotoxic: mean 21.4%, log2 vs others −0.21, p = 0.13, q = 0.2723.1%HRD-Del · CD8 T cytotoxic: mean 23.1%, log2 vs others −0.016, p = 0.92, q = 0.9925.5%FBI · CD8 T cytotoxic: mean 25.5%, log2 vs others 0.22, p = 0.12, q = 0.27Cycling T NK8.6%HRD-Dup · Cycling T NK: mean 8.6%, log2 vs others 0.59, p = 0.0027, q = 0.085.7%HRD-Del · Cycling T NK: mean 5.7%, log2 vs others −0.34, p = 0.072, q = 0.255.7%FBI · Cycling T NK: mean 5.7%, log2 vs others −0.46, p = 0.029, q = 0.20ILC2.1%HRD-Dup · ILC: mean 2.1%, log2 vs others −0.0041, p = 0.99, q = 0.991.8%HRD-Del · ILC: mean 1.8%, log2 vs others −0.29, p = 0.11, q = 0.272.3%FBI · ILC: mean 2.3%, log2 vs others 0.16, p = 0.49, q = 0.64NK CD5614.6%HRD-Dup · NK CD56: mean 14.6%, log2 vs others 0.28, p = 0.30, q = 0.4113.0%HRD-Del · NK CD56: mean 13.0%, log2 vs others −0.016, p = 0.98, q = 0.9911.6%FBI · NK CD56: mean 11.6%, log2 vs others −0.29, p = 0.25, q = 0.38NK cytotoxic6.1%HRD-Dup · NK cytotoxic: mean 6.1%, log2 vs others −0.6, p = 0.074, q = 0.256.6%HRD-Del · NK cytotoxic: mean 6.6%, log2 vs others −0.32, p = 0.29, q = 0.4110.6%FBI · NK cytotoxic: mean 10.6%, log2 vs others 0.75, p = 0.052, q = 0.22Each cell: the cohort's mean share, and a dot whose colour is log2 of it over the other cohorts' mean (blue lower, red higher, clamped at ±2), size −log10 q, outlinedwhen q < 0.05. 30 comparisons tested, 0 at q < 0.05.Each patient's 10 parts (clinical attributes), divided by their sum so every bar is a whole; cases ordered by CD8 T CXCL13, highest first. Each cohort is compared withthe view's other cohorts pooled, part by part: log2 of the ratio of means (each + 0.001), Welch's t from the cohorts' n, mean and variance, Benjamini–Hochberg acrossthe 30 comparisons. Parts of a whole are not independent — one part's rise is the others' fall — and a case in two cohorts counts in both. Entropy is Shannon's (naturallog) over each case's shares. + +Composition — Cell Type Relative Fractions by HRD-Dup, HRD-Del, FBIB_cellDendritic_cellEndothelial_cellFibroblastMast_cellMonocyteOtherOvarian_cancer_cellPlasma_cellT_cell0%20%40%60%80%100%share of sampleHRD-Dup19 samples · entropy 1.33HRD-Dup · B_cell: mean 2.5%HRD-Dup · Dendritic_cell: mean 0.3%HRD-Dup · Endothelial_cell: mean 2.3%HRD-Dup · Fibroblast: mean 18.2%HRD-Dup · Mast_cell: mean <0.1%HRD-Dup · Monocyte: mean 21.4%HRD-Dup · Ovarian_cancer_cell: mean 26.6%HRD-Dup · Plasma_cell: mean 4.7%HRD-Dup · T_cell: mean 23.9%meanHRD-Del8 samples · entropy 1.2HRD-Del · B_cell: mean 1.4%HRD-Del · Dendritic_cell: mean 0.3%HRD-Del · Endothelial_cell: mean 1.0%HRD-Del · Fibroblast: mean 15.1%HRD-Del · Mast_cell: mean <0.1%HRD-Del · Monocyte: mean 24.4%HRD-Del · Ovarian_cancer_cell: mean 29.0%HRD-Del · Plasma_cell: mean 1.4%HRD-Del · T_cell: mean 27.3%meanFBI19 samples · entropy 1.18FBI · B_cell: mean 1.8%FBI · Dendritic_cell: mean 0.6%FBI · Endothelial_cell: mean 2.1%FBI · Fibroblast: mean 10.2%FBI · Mast_cell: mean 0.2%FBI · Monocyte: mean 19.7%FBI · Other: mean <0.1%FBI · Ovarian_cancer_cell: mean 31.6%FBI · Plasma_cell: mean 1.4%FBI · T_cell: mean 32.4%meanEach cohort against the others, per partHRD-DupHRD-DelFBIB_cell2.5%HRD-Dup · B_cell: mean 2.5%, log2 vs others 0.55, p = 0.47, q = 0.731.4%HRD-Del · B_cell: mean 1.4%, log2 vs others −0.58, p = 0.49, q = 0.731.8%FBI · B_cell: mean 1.8%, log2 vs others −0.27, p = 0.67, q = 0.79Dendritic_cell0.3%HRD-Dup · Dendritic_cell: mean 0.3%, log2 vs others −0.4, p = 0.33, q = 0.590.3%HRD-Del · Dendritic_cell: mean 0.3%, log2 vs others −0.5, p = 0.25, q = 0.590.6%FBI · Dendritic_cell: mean 0.6%, log2 vs others 0.64, p = 0.20, q = 0.59Endothelial_cell2.3%HRD-Dup · Endothelial_cell: mean 2.3%, log2 vs others 0.32, p = 0.47, q = 0.731.0%HRD-Del · Endothelial_cell: mean 1.0%, log2 vs others −1.1, p = 0.013, q = 0.392.1%FBI · Endothelial_cell: mean 2.1%, log2 vs others 0.17, p = 0.69, q = 0.79Fibroblast18.2%HRD-Dup · Fibroblast: mean 18.2%, log2 vs others 0.64, p = 0.16, q = 0.5915.1%HRD-Del · Fibroblast: mean 15.1%, log2 vs others 0.086, p = 0.88, q = 0.9810.2%FBI · Fibroblast: mean 10.2%, log2 vs others −0.76, p = 0.11, q = 0.55Mast_cell<0.1%HRD-Dup · Mast_cell: mean <0.1%, log2 vs others −0.59, p = 0.10, q = 0.55<0.1%HRD-Del · Mast_cell: mean <0.1%, log2 vs others −0.59, p = 0.15, q = 0.590.2%FBI · Mast_cell: mean 0.2%, log2 vs others 0.85, p = 0.051, q = 0.55Monocyte21.4%HRD-Dup · Monocyte: mean 21.4%, log2 vs others 0.02, p = 0.95, q = 0.9824.4%HRD-Del · Monocyte: mean 24.4%, log2 vs others 0.25, p = 0.54, q = 0.7319.7%FBI · Monocyte: mean 19.7%, log2 vs others −0.18, p = 0.61, q = 0.77Other0%HRD-Dup · Other: mean 0%, log2 vs others −0.0037, p = 0.33, q = 0.590%HRD-Del · Other: mean 0%, log2 vs others −0.0026, p = 0.32, q = 0.59<0.1%FBI · Other: mean <0.1%, log2 vs others 0.0053, p = 0.33, q = 0.59Ovarian_cancer_cell26.6%HRD-Dup · Ovarian_cancer_cell: mean 26.6%, log2 vs others −0.21, p = 0.51, q = 0.7329.0%HRD-Del · Ovarian_cancer_cell: mean 29.0%, log2 vs others −0.0034, p = 0.99, q = 0.9931.6%FBI · Ovarian_cancer_cell: mean 31.6%, log2 vs others 0.21, p = 0.56, q = 0.73Plasma_cell4.7%HRD-Dup · Plasma_cell: mean 4.7%, log2 vs others 1.6, p = 0.085, q = 0.551.4%HRD-Del · Plasma_cell: mean 1.4%, log2 vs others −1, p = 0.30, q = 0.591.4%FBI · Plasma_cell: mean 1.4%, log2 vs others −1.3, p = 0.098, q = 0.55T_cell23.9%HRD-Dup · T_cell: mean 23.9%, log2 vs others −0.37, p = 0.23, q = 0.5927.3%HRD-Del · T_cell: mean 27.3%, log2 vs others −0.045, p = 0.93, q = 0.9832.4%FBI · T_cell: mean 32.4%, log2 vs others 0.38, p = 0.24, q = 0.59Each cell: the cohort's mean share, and a dot whose colour is log2 of it over the other cohorts' mean (blue lower, red higher, clamped at ±2), size −log10 q, outlinedwhen q < 0.05. 30 comparisons tested, 0 at q < 0.05.Each sample's 10 parts (entities of “Cell Type Relative Fractions”), divided by their sum so every bar is a whole; cases ordered by T_cell, highest first. Each cohort iscompared with the view's other cohorts pooled, part by part: log2 of the ratio of means (each + 0.001), Welch's t from the cohorts' n, mean and variance,Benjamini–Hochberg across the 30 comparisons. Parts of a whole are not independent — one part's rise is the others' fall — and a case in two cohorts counts in both.Entropy is Shannon's (natural log) over each case's shares. diff --git a/test/snapshots/composition.txt b/test/snapshots/composition.txt new file mode 100644 index 0000000..3a59dbe --- /dev/null +++ b/test/snapshots/composition.txt @@ -0,0 +1,32 @@ +Analysis over msk_spectrum_tme_2022 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- HRD-Dup: 16 patients — CONSENSUS_SIGNATURE in [HRD-Dup] +- HRD-Del: 6 patients — CONSENSUS_SIGNATURE in [HRD-Del] +- FBI: 14 patients — CONSENSUS_SIGNATURE in [FBI] + +Composition of clinical attributes (10 parts, shares of each patient's total; each cohort against the others by Welch's t, BH q over 30 comparisons; 0 at q<0.05): + HRD-Dup (n=16, entropy 2.07): CD4 T CXCL13 4.2% (log2 0.47, q=0.3269), CD4 T naive 15.2% (log2 -0.39, q=0.2036), CD4 T reg 11.6% (log2 -0.01, q=0.9878), CD8 T CXCL13 7.0% (log2 0.61, q=0.2036), CD8 T ISG 9.2% (log2 0.41, q=0.2036), CD8 T cytotoxic 21.4% (log2 -0.21, q=0.2733), Cycling T NK 8.6% (log2 0.59, q=0.0797), ILC 2.1% (log2 -0.00, q=0.9878), NK CD56 14.6% (log2 0.28, q=0.4064), NK cytotoxic 6.1% (log2 -0.60, q=0.2458) + HRD-Del (n=6, entropy 1.96): CD4 T CXCL13 3.2% (log2 -0.14, q=0.7628), CD4 T naive 19.6% (log2 0.17, q=0.7628), CD4 T reg 15.7% (log2 0.52, q=0.3806), CD8 T CXCL13 4.9% (log2 -0.22, q=0.7614), CD8 T ISG 6.4% (log2 -0.35, q=0.2458), CD8 T cytotoxic 23.1% (log2 -0.02, q=0.9878), Cycling T NK 5.7% (log2 -0.34, q=0.2458), ILC 1.8% (log2 -0.29, q=0.2706), NK CD56 13.0% (log2 -0.02, q=0.9878), NK cytotoxic 6.6% (log2 -0.32, q=0.4064) + FBI (n=14, entropy 1.98): CD4 T CXCL13 2.9% (log2 -0.43, q=0.3269), CD4 T naive 20.1% (log2 0.29, q=0.2870), CD4 T reg 10.0% (log2 -0.35, q=0.2505), CD8 T CXCL13 4.4% (log2 -0.55, q=0.2036), CD8 T ISG 7.1% (log2 -0.24, q=0.3806), CD8 T cytotoxic 25.5% (log2 0.22, q=0.2733), Cycling T NK 5.7% (log2 -0.46, q=0.2036), ILC 2.3% (log2 0.16, q=0.6431), NK CD56 11.6% (log2 -0.29, q=0.3806), NK cytotoxic 10.6% (log2 0.75, q=0.2237) + CAVEAT (tell the user): Each patient's 10 parts (clinical attributes), divided by their sum so every bar is a whole; cases ordered by CD8 T CXCL13, highest first. Each cohort is compared with the view's other cohorts pooled, part by part: log2 of the ratio of means (each + 0.001), Welch's t from the cohorts' n, mean and variance, Benjamini–Hochberg across the 30 comparisons. Parts of a whole are not independent — one part's rise is the others' fall — and a case in two cohorts counts in both. Entropy is Shannon's (natural log) over each case's shares. + METHOD: + - Sum each part over the cohort's patients [HRD-Dup · msk_spectrum_tme_2022]: The composition:moments query above: each patient's 10 parts read and put in part order inside the database; a patient with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those patients n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query. + - Sum each part over the cohort's patients [HRD-Del · msk_spectrum_tme_2022]: The composition:moments query above: each patient's 10 parts read and put in part order inside the database; a patient with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those patients n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query. + - Sum each part over the cohort's patients [FBI · msk_spectrum_tme_2022]: The composition:moments query above: each patient's 10 parts read and put in part order inside the database; a patient with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those patients n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query. + - Each cohort against the others pooled, per part; then Benjamini–Hochberg: The other cohorts' sums are added into one group. Effect: log2((mean + 0.001) / (others' mean + 0.001)). Test: Welch's unequal-variance t from each side's n, mean and variance (Σp² − (Σp)²/n)/(n − 1), two-sided; not tested when either side has under 2 patients or neither has any spread. q across every comparison tested. + comparisons: 30 + Welch's t from moments matches scipy 1.18.1 ttest_ind(equal_var=False) and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts). + +Composition of Cell Type Relative Fractions (10 parts, shares of each sample's total; each cohort against the others by Welch's t, BH q over 30 comparisons; 0 at q<0.05): + HRD-Dup (n=19, entropy 1.33): B_cell 2.5% (log2 0.55, q=0.7304), Dendritic_cell 0.3% (log2 -0.40, q=0.5869), Endothelial_cell 2.3% (log2 0.32, q=0.7304), Fibroblast 18.2% (log2 0.64, q=0.5869), Mast_cell 0.1% (log2 -0.59, q=0.5468), Monocyte 21.4% (log2 0.02, q=0.9842), Other 0.0% (log2 -0.00, q=0.5869), Ovarian_cancer_cell 26.6% (log2 -0.21, q=0.7304), Plasma_cell 4.7% (log2 1.64, q=0.5468), T_cell 23.9% (log2 -0.37, q=0.5869) + HRD-Del (n=8, entropy 1.20): B_cell 1.4% (log2 -0.58, q=0.7304), Dendritic_cell 0.3% (log2 -0.50, q=0.5869), Endothelial_cell 1.0% (log2 -1.10, q=0.3935), Fibroblast 15.1% (log2 0.09, q=0.9768), Mast_cell 0.1% (log2 -0.59, q=0.5869), Monocyte 24.4% (log2 0.25, q=0.7337), Other 0.0% (log2 -0.00, q=0.5869), Ovarian_cancer_cell 29.0% (log2 -0.00, q=0.9935), Plasma_cell 1.4% (log2 -1.02, q=0.5869), T_cell 27.3% (log2 -0.04, q=0.9842) + FBI (n=19, entropy 1.18): B_cell 1.8% (log2 -0.27, q=0.7905), Dendritic_cell 0.6% (log2 0.64, q=0.5869), Endothelial_cell 2.1% (log2 0.17, q=0.7905), Fibroblast 10.2% (log2 -0.76, q=0.5468), Mast_cell 0.2% (log2 0.85, q=0.5468), Monocyte 19.7% (log2 -0.18, q=0.7655), Other 0.0% (log2 0.01, q=0.5869), Ovarian_cancer_cell 31.6% (log2 0.21, q=0.7337), Plasma_cell 1.4% (log2 -1.32, q=0.5468), T_cell 32.4% (log2 0.38, q=0.5869) + CAVEAT (tell the user): Each sample's 10 parts (entities of “Cell Type Relative Fractions”), divided by their sum so every bar is a whole; cases ordered by T_cell, highest first. Each cohort is compared with the view's other cohorts pooled, part by part: log2 of the ratio of means (each + 0.001), Welch's t from the cohorts' n, mean and variance, Benjamini–Hochberg across the 30 comparisons. Parts of a whole are not independent — one part's rise is the others' fall — and a case in two cohorts counts in both. Entropy is Shannon's (natural log) over each case's shares. + METHOD: + - Sum each part over the cohort's samples [HRD-Dup · msk_spectrum_tme_2022]: The composition:moments query above: each sample's 10 parts read and put in part order inside the database; a sample with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those samples n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query. + - Sum each part over the cohort's samples [HRD-Del · msk_spectrum_tme_2022]: The composition:moments query above: each sample's 10 parts read and put in part order inside the database; a sample with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those samples n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query. + - Sum each part over the cohort's samples [FBI · msk_spectrum_tme_2022]: The composition:moments query above: each sample's 10 parts read and put in part order inside the database; a sample with every part, none below zero and a sum above zero is kept, its parts divided by their sum; then over those samples n, Σp and Σp² per part, and Σ and Σ² of each one's Shannon entropy. No case's values leave the database in this query. + - Each cohort against the others pooled, per part; then Benjamini–Hochberg: The other cohorts' sums are added into one group. Effect: log2((mean + 0.001) / (others' mean + 0.001)). Test: Welch's unequal-variance t from each side's n, mean and variance (Σp² − (Σp)²/n)/(n − 1), two-sided; not tested when either side has under 2 samples or neither has any spread. q across every comparison tested. + comparisons: 30 + Welch's t from moments matches scipy 1.18.1 ttest_ind(equal_var=False) and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts). diff --git a/test/snapshots/cooccurrence.json b/test/snapshots/cooccurrence.json new file mode 100644 index 0000000..0b21ee0 --- /dev/null +++ b/test/snapshots/cooccurrence.json @@ -0,0 +1,367 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "NSCLC": { + "count": 7809, + "text": "CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "cooccurrence", + "cohorts": [ + "NSCLC" + ], + "pairs": [ + { + "a": "STK11", + "b": "KEAP1", + "both": 572, + "onlyA": 537, + "onlyB": 512, + "neither": 6188, + "profiled": 7809, + "log2Odds": 3.686, + "p": 3.396549365554813e-249, + "q": 5.094824048332219e-248, + "tendency": "co-occurrence" + }, + { + "a": "EGFR", + "b": "KRAS", + "both": 75, + "onlyA": 1947, + "onlyB": 2194, + "neither": 3593, + "profiled": 7809, + "log2Odds": -3.987, + "p": 1.5080466769626828e-238, + "q": 1.1310350077220122e-237, + "tendency": "mutual exclusivity" + }, + { + "a": "EGFR", + "b": "STK11", + "both": 52, + "onlyA": 1970, + "onlyB": 1057, + "neither": 4730, + "profiled": 7809, + "log2Odds": -3.082, + "p": 8.910206347433695e-88, + "q": 4.4551031737168476e-87, + "tendency": "mutual exclusivity" + }, + { + "a": "KRAS", + "b": "STK11", + "both": 598, + "onlyA": 1671, + "onlyB": 511, + "neither": 5029, + "profiled": 7809, + "log2Odds": 1.816, + "p": 4.9400796448155687e-79, + "q": 1.8525298668058381e-78, + "tendency": "co-occurrence" + }, + { + "a": "EGFR", + "b": "KEAP1", + "both": 66, + "onlyA": 1956, + "onlyB": 1018, + "neither": 4769, + "profiled": 7809, + "log2Odds": -2.661, + "p": 1.503888597094316e-72, + "q": 4.511665791282948e-72, + "tendency": "mutual exclusivity" + }, + { + "a": "KRAS", + "b": "TP53", + "both": 873, + "onlyA": 1396, + "onlyB": 3215, + "neither": 2325, + "profiled": 7809, + "log2Odds": -1.145, + "p": 1.0558783450158271e-55, + "q": 2.6396958625395677e-55, + "tendency": "mutual exclusivity" + }, + { + "a": "EGFR", + "b": "ALK", + "both": 49, + "onlyA": 1973, + "onlyB": 503, + "neither": 5284, + "profiled": 7809, + "log2Odds": -1.938, + "p": 3.1984865484044725e-25, + "q": 6.853899746581012e-25, + "tendency": "mutual exclusivity" + }, + { + "a": "KRAS", + "b": "KEAP1", + "both": 456, + "onlyA": 1813, + "onlyB": 628, + "neither": 4912, + "profiled": 7809, + "log2Odds": 0.976, + "p": 5.47635802660293e-23, + "q": 1.0268171299880494e-22, + "tendency": "co-occurrence" + }, + { + "a": "TP53", + "b": "STK11", + "both": 453, + "onlyA": 3635, + "onlyB": 656, + "neither": 3065, + "profiled": 7809, + "log2Odds": -0.78, + "p": 1.3052910427261104e-16, + "q": 2.175485071210184e-16, + "tendency": "mutual exclusivity" + }, + { + "a": "EGFR", + "b": "TP53", + "both": 1174, + "onlyA": 848, + "onlyB": 2914, + "neither": 2873, + "profiled": 7809, + "log2Odds": 0.449, + "p": 2.2614400356737777e-9, + "q": 3.3921600535106666e-9, + "tendency": "co-occurrence" + }, + { + "a": "KRAS", + "b": "ALK", + "both": 118, + "onlyA": 2151, + "onlyB": 434, + "neither": 5106, + "profiled": 7809, + "log2Odds": -0.632, + "p": 0.000027654786501243727, + "q": 0.00003771107250169599, + "tendency": "mutual exclusivity" + }, + { + "a": "STK11", + "b": "ALK", + "both": 66, + "onlyA": 1043, + "onlyB": 486, + "neither": 6214, + "profiled": 7809, + "log2Odds": -0.306, + "p": 0.12879997517049538, + "q": 0.16099996896311922, + "tendency": "mutual exclusivity" + }, + { + "a": "TP53", + "b": "ALK", + "both": 303, + "onlyA": 3785, + "onlyB": 249, + "neither": 3472, + "profiled": 7809, + "log2Odds": 0.159, + "p": 0.21623930193910998, + "q": 0.24172078956410842, + "tendency": "co-occurrence" + }, + { + "a": "TP53", + "b": "KEAP1", + "both": 586, + "onlyA": 3502, + "onlyB": 498, + "neither": 3223, + "profiled": 7809, + "log2Odds": 0.115, + "p": 0.2256060702598345, + "q": 0.24172078956410842, + "tendency": "co-occurrence" + }, + { + "a": "KEAP1", + "b": "ALK", + "both": 72, + "onlyA": 1012, + "onlyB": 480, + "neither": 6245, + "profiled": 7809, + "log2Odds": -0.111, + "p": 0.6094218694938038, + "q": 0.6094218694938038, + "tendency": "mutual exclusivity" + } + ], + "studies": [ + "msk_chord_2024" + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "Pairwise co-occurrence within “NSCLC”. Denominators are the patients profiled for BOTH genes, computed per study against that study's own panels — a pair is never scored on patients whose panel could not have detected it. Two-sided Fisher exact test. q-values are Benjamini–Hochberg across the 15 assessable pairs. Every site returns four counts per pair and nothing else.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count each gene pair's 2×2 table", + "detail": "The pairCounts query above. Of the patients with a sample on a mutation panel covering both genes: how many are altered in both, only the first, only the second, or neither (altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion)). Four counts per pair, nothing else.", + "scope": "NSCLC · msk_chord_2024", + "rowsIn": 7809, + "params": [ + [ + "pairs", + "15" + ] + ] + }, + { + "kind": "statistic", + "title": "Log₂ odds ratio per pair", + "detail": "log₂((both · neither) / (only first · only second)) on the counts summed across studies, with 0.5 added to every cell when any cell is 0." + }, + { + "kind": "statistic", + "title": "Fisher's exact test per pair", + "detail": "Two-sided, on the pair's 2×2 table." + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across pairs", + "detail": "q-values over the 15 assessable pairs, from the Fisher p-values." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "log2OddsRatio", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels 0.15.0 multipletests(method=\"fdr_bh\"), to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "cooccurrence:STK11/KEAP1:p": { + "v": 3.396549365554813e-249 + }, + "cooccurrence:STK11/KEAP1:q": { + "v": 5.094824048332219e-248 + }, + "cooccurrence:EGFR/KRAS:p": { + "v": 1.5080466769626828e-238 + }, + "cooccurrence:EGFR/KRAS:q": { + "v": 1.1310350077220122e-237 + }, + "cooccurrence:EGFR/STK11:p": { + "v": 8.910206347433695e-88 + }, + "cooccurrence:EGFR/STK11:q": { + "v": 4.4551031737168476e-87 + }, + "cooccurrence:KRAS/STK11:p": { + "v": 4.9400796448155687e-79 + }, + "cooccurrence:KRAS/STK11:q": { + "v": 1.8525298668058381e-78 + }, + "cooccurrence:EGFR/KEAP1:p": { + "v": 1.503888597094316e-72 + }, + "cooccurrence:EGFR/KEAP1:q": { + "v": 4.511665791282948e-72 + }, + "cooccurrence:KRAS/TP53:p": { + "v": 1.0558783450158271e-55 + }, + "cooccurrence:KRAS/TP53:q": { + "v": 2.6396958625395677e-55 + }, + "cooccurrence:EGFR/ALK:p": { + "v": 3.1984865484044725e-25 + }, + "cooccurrence:EGFR/ALK:q": { + "v": 6.853899746581012e-25 + }, + "cooccurrence:KRAS/KEAP1:p": { + "v": 5.47635802660293e-23 + }, + "cooccurrence:KRAS/KEAP1:q": { + "v": 1.0268171299880494e-22 + }, + "cooccurrence:TP53/STK11:p": { + "v": 1.3052910427261104e-16 + }, + "cooccurrence:TP53/STK11:q": { + "v": 2.175485071210184e-16 + }, + "cooccurrence:EGFR/TP53:p": { + "v": 2.2614400356737777e-9 + }, + "cooccurrence:EGFR/TP53:q": { + "v": 3.3921600535106666e-9 + }, + "cooccurrence:KRAS/ALK:p": { + "v": 0.000027654786501243727 + }, + "cooccurrence:KRAS/ALK:q": { + "v": 0.00003771107250169599 + }, + "cooccurrence:STK11/ALK:p": { + "v": 0.12879997517049538 + }, + "cooccurrence:STK11/ALK:q": { + "v": 0.16099996896311922 + }, + "cooccurrence:TP53/ALK:p": { + "v": 0.21623930193910998 + }, + "cooccurrence:TP53/ALK:q": { + "v": 0.24172078956410842 + }, + "cooccurrence:TP53/KEAP1:p": { + "v": 0.2256060702598345 + }, + "cooccurrence:TP53/KEAP1:q": { + "v": 0.24172078956410842 + }, + "cooccurrence:KEAP1/ALK:p": { + "v": 0.6094218694938038 + }, + "cooccurrence:KEAP1/ALK:q": { + "v": 0.6094218694938038 + } + } + } + } + ] +} diff --git a/test/snapshots/cooccurrence.sql b/test/snapshots/cooccurrence.sql new file mode 100644 index 0000000..3851b9c --- /dev/null +++ b/test/snapshots/cooccurrence.sql @@ -0,0 +1,42 @@ +-- cohort NSCLC +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer')))) + +-- view 0 cooccurrence: pairCounts · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer'))))), +altered AS ( + SELECT DISTINCT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('EGFR','KRAS','TP53','STK11','KEAP1','ALK') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('EGFR','KRAS','TP53','STK11','KEAP1','ALK') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +pp AS ( + SELECT pid, + groupUniqArrayIf(gene, k = 1) AS alt, + groupUniqArrayIf(gene, k = 0) AS cov + FROM (SELECT gene, pid, 1 AS k FROM altered UNION ALL SELECT gene, pid, 0 AS k FROM covered) + GROUP BY pid +) +SELECT ga, gb, + countIf(has(cov, ga) AND has(cov, gb)) AS profiled, + countIf(has(cov, ga) AND has(cov, gb) AND has(alt, ga) AND has(alt, gb)) AS both, + countIf(has(cov, ga) AND has(cov, gb) AND has(alt, ga) AND NOT has(alt, gb)) AS only_a, + countIf(has(cov, ga) AND has(cov, gb) AND NOT has(alt, ga) AND has(alt, gb)) AS only_b +FROM pp +ARRAY JOIN ['EGFR','EGFR','EGFR','EGFR','EGFR','KRAS','KRAS','KRAS','KRAS','TP53','TP53','TP53','STK11','STK11','KEAP1'] AS ga, ['KRAS','TP53','STK11','KEAP1','ALK','TP53','STK11','KEAP1','ALK','STK11','KEAP1','ALK','KEAP1','ALK','ALK'] AS gb +GROUP BY ga, gb diff --git a/test/snapshots/cooccurrence.svg b/test/snapshots/cooccurrence.svg new file mode 100644 index 0000000..ad1bf67 --- /dev/null +++ b/test/snapshots/cooccurrence.svg @@ -0,0 +1,2 @@ + +Co-occurrence — log₂ odds ratioCo-occurrence — log₂ odds ratioco-occur, q < 0.05mutually exclusive, q < 0.05not significantSTK11 / KEAP1STK11 / KEAP1: both 572, STK11 only 537, KEAP1 only 512, neither 6,188 · p = 3.4e-2493.69 · q = 5.1e-248EGFR / KRASEGFR / KRAS: both 75, EGFR only 1,947, KRAS only 2,194, neither 3,593 · p = 1.5e-238−3.99 · q = 1.1e-237EGFR / STK11EGFR / STK11: both 52, EGFR only 1,970, STK11 only 1,057, neither 4,730 · p = 8.9e-88−3.08 · q = 4.5e-87KRAS / STK11KRAS / STK11: both 598, KRAS only 1,671, STK11 only 511, neither 5,029 · p = 4.9e-791.82 · q = 1.9e-78EGFR / KEAP1EGFR / KEAP1: both 66, EGFR only 1,956, KEAP1 only 1,018, neither 4,769 · p = 1.5e-72−2.66 · q = 4.5e-72KRAS / TP53KRAS / TP53: both 873, KRAS only 1,396, TP53 only 3,215, neither 2,325 · p = 1.1e-55−1.15 · q = 2.6e-55EGFR / ALKEGFR / ALK: both 49, EGFR only 1,973, ALK only 503, neither 5,284 · p = 3.2e-25−1.94 · q = 6.9e-25KRAS / KEAP1KRAS / KEAP1: both 456, KRAS only 1,813, KEAP1 only 628, neither 4,912 · p = 5.5e-230.976 · q = 1e-22TP53 / STK11TP53 / STK11: both 453, TP53 only 3,635, STK11 only 656, neither 3,065 · p = 1.3e-16−0.78 · q = 2.2e-16EGFR / TP53EGFR / TP53: both 1,174, EGFR only 848, TP53 only 2,914, neither 2,873 · p = 2.3e-90.449 · q = 3.4e-9KRAS / ALKKRAS / ALK: both 118, KRAS only 2,151, ALK only 434, neither 5,106 · p = 2.8e-5−0.632 · q = 3.8e-5STK11 / ALKSTK11 / ALK: both 66, STK11 only 1,043, ALK only 486, neither 6,214 · p = 0.13−0.306 · q = 0.16TP53 / ALKTP53 / ALK: both 303, TP53 only 3,785, ALK only 249, neither 3,472 · p = 0.220.159 · q = 0.24TP53 / KEAP1TP53 / KEAP1: both 586, TP53 only 3,502, KEAP1 only 498, neither 3,223 · p = 0.230.115 · q = 0.24KEAP1 / ALKKEAP1 / ALK: both 72, KEAP1 only 1,012, ALK only 480, neither 6,245 · p = 0.61−0.111 · q = 0.61−4−2024log₂ odds ratio — left: mutually exclusive, right: co-occurringPairwise co-occurrence within “NSCLC”. Denominators are the patients profiled for BOTH genes, computed per study against that study's own panels — apair is never scored on patients whose panel could not have detected it. Two-sided Fisher exact test. q-values are Benjamini–Hochberg across the 15assessable pairs. Every site returns four counts per pair and nothing else. diff --git a/test/snapshots/cooccurrence.txt b/test/snapshots/cooccurrence.txt new file mode 100644 index 0000000..c314c89 --- /dev/null +++ b/test/snapshots/cooccurrence.txt @@ -0,0 +1,29 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- NSCLC: 7,809 patients — CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample) + +Co-occurrence (2x2 per pair, among patients profiled for BOTH genes): + STK11/KEAP1: both 572, STK11 only 537, KEAP1 only 512, neither 6,188 (of 7,809 profiled) log2OR=3.69 (co-occur) p=3.4e-249 q=5.1e-248 + EGFR/KRAS: both 75, EGFR only 1,947, KRAS only 2,194, neither 3,593 (of 7,809 profiled) log2OR=-3.99 (mutually exclusive) p=1.5e-238 q=1.1e-237 + EGFR/STK11: both 52, EGFR only 1,970, STK11 only 1,057, neither 4,730 (of 7,809 profiled) log2OR=-3.08 (mutually exclusive) p=8.9e-88 q=4.5e-87 + KRAS/STK11: both 598, KRAS only 1,671, STK11 only 511, neither 5,029 (of 7,809 profiled) log2OR=1.82 (co-occur) p=4.9e-79 q=1.9e-78 + EGFR/KEAP1: both 66, EGFR only 1,956, KEAP1 only 1,018, neither 4,769 (of 7,809 profiled) log2OR=-2.66 (mutually exclusive) p=1.5e-72 q=4.5e-72 + KRAS/TP53: both 873, KRAS only 1,396, TP53 only 3,215, neither 2,325 (of 7,809 profiled) log2OR=-1.15 (mutually exclusive) p=1.1e-55 q=2.6e-55 + EGFR/ALK: both 49, EGFR only 1,973, ALK only 503, neither 5,284 (of 7,809 profiled) log2OR=-1.94 (mutually exclusive) p=3.2e-25 q=6.9e-25 + KRAS/KEAP1: both 456, KRAS only 1,813, KEAP1 only 628, neither 4,912 (of 7,809 profiled) log2OR=0.98 (co-occur) p=5.5e-23 q=1.0e-22 + TP53/STK11: both 453, TP53 only 3,635, STK11 only 656, neither 3,065 (of 7,809 profiled) log2OR=-0.78 (mutually exclusive) p=1.3e-16 q=2.2e-16 + EGFR/TP53: both 1,174, EGFR only 848, TP53 only 2,914, neither 2,873 (of 7,809 profiled) log2OR=0.45 (co-occur) p=2.3e-9 q=3.4e-9 + KRAS/ALK: both 118, KRAS only 2,151, ALK only 434, neither 5,106 (of 7,809 profiled) log2OR=-0.63 (mutually exclusive) p=2.8e-5 q=3.8e-5 + STK11/ALK: both 66, STK11 only 1,043, ALK only 486, neither 6,214 (of 7,809 profiled) log2OR=-0.31 (mutually exclusive) p=0.1288 q=0.1610 + TP53/ALK: both 303, TP53 only 3,785, ALK only 249, neither 3,472 (of 7,809 profiled) log2OR=0.16 (co-occur) p=0.2162 q=0.2417 + TP53/KEAP1: both 586, TP53 only 3,502, KEAP1 only 498, neither 3,223 (of 7,809 profiled) log2OR=0.12 (co-occur) p=0.2256 q=0.2417 + KEAP1/ALK: both 72, KEAP1 only 1,012, ALK only 480, neither 6,245 (of 7,809 profiled) log2OR=-0.11 (mutually exclusive) p=0.6094 q=0.6094 + Pairwise co-occurrence within “NSCLC”. Denominators are the patients profiled for BOTH genes, computed per study against that study's own panels — a pair is never scored on patients whose panel could not have detected it. Two-sided Fisher exact test. q-values are Benjamini–Hochberg across the 15 assessable pairs. Every site returns four counts per pair and nothing else. + METHOD: + - Count each gene pair's 2×2 table [NSCLC · msk_chord_2024]: The pairCounts query above. Of the patients with a sample on a mutation panel covering both genes: how many are altered in both, only the first, only the second, or neither (altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion)). Four counts per pair, nothing else. + pairs: 15 + - Log₂ odds ratio per pair: log₂((both · neither) / (only first · only second)) on the counts summed across studies, with 0.5 added to every cell when any cell is 0. + - Fisher's exact test per pair: Two-sided, on the pair's 2×2 table. + - Benjamini–Hochberg across pairs: q-values over the 15 assessable pairs, from the Fisher p-values. + Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels 0.15.0 multipletests(method="fdr_bh"), to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/correlates.json b/test/snapshots/correlates.json new file mode 100644 index 0000000..57218f2 --- /dev/null +++ b/test/snapshots/correlates.json @@ -0,0 +1,679 @@ +{ + "study": "brca_tcga_pan_can_atlas_2018", + "cohorts": { + "all patients": { + "count": 1084, + "text": "all patients in the study", + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ] + } + }, + "views": [ + { + "kind": "correlates", + "cohorts": [ + "all patients" + ], + "correlates": { + "gene": "ESR1", + "profileType": "rna_seq_v2_mrna", + "otherProfile": "rna_seq_v2_mrna", + "cohort": "all patients", + "tested": 20057, + "untested": 280, + "significant": 15572, + "minN": 10, + "rhoFrom": "rank", + "positive": [ + { + "gene": "CCDC170", + "n": 1082, + "rho": 0.7917, + "rhoP": 2.2249983400385912e-233, + "q": 4.4626791706154024e-229, + "r": 0.6675, + "p": 1.86618036574955e-140, + "cytoband": "6q25.1" + }, + { + "gene": "DCPH1", + "n": 1082, + "rho": 0.7841, + "rhoP": 5.089149809464745e-226, + "q": 5.103653886421719e-222, + "r": 0.5652, + "p": 2.3489389556771624e-92, + "cytoband": "6q25.1" + }, + { + "gene": "THSD4", + "n": 1082, + "rho": 0.7776, + "rhoP": 6.808597091162043e-220, + "q": 4.55200106191457e-216, + "r": 0.6439, + "p": 1.0524911370004154e-127, + "cytoband": "15q23" + }, + { + "gene": "FOXA1", + "n": 1082, + "rho": 0.7478, + "rhoP": 2.5074740593460398e-194, + "q": 1.257310180207588e-190, + "r": 0.686, + "p": 2.481862600299769e-151, + "cytoband": "14q21.1" + }, + { + "gene": "TBC1D9", + "n": 1082, + "rho": 0.746, + "rhoP": 6.233807186705536e-193, + "q": 2.500629414875059e-189, + "r": 0.5514, + "p": 4.160301459187909e-87, + "cytoband": "4q31.21" + }, + { + "gene": "RABEP1", + "n": 1082, + "rho": 0.7283, + "rhoP": 1.7768277814040784e-179, + "q": 5.9396391352702666e-176, + "r": 0.6183, + "p": 3.9827630128370835e-115, + "cytoband": "17p13.2" + }, + { + "gene": "SLC39A6", + "n": 1082, + "rho": 0.7217, + "rhoP": 9.308705660658694e-175, + "q": 2.667210134797592e-171, + "r": 0.45, + "p": 4.487562761959699e-55, + "cytoband": "18q12.2" + }, + { + "gene": "GATA3", + "n": 1082, + "rho": 0.7201, + "rhoP": 1.3729095344785626e-173, + "q": 3.442055816629566e-170, + "r": 0.5603, + "p": 1.9260821179739106e-90, + "cytoband": "10p14" + }, + { + "gene": "CA12", + "n": 1082, + "rho": 0.6942, + "rhoP": 2.226749523984242e-156, + "q": 4.962435022505771e-153, + "r": 0.516, + "p": 1.2021766685492872e-74, + "cytoband": "15q22.2" + }, + { + "gene": "CT62", + "n": 1082, + "rho": 0.6938, + "rhoP": 3.645402252874833e-156, + "q": 7.311583298591052e-153, + "r": 0.43, + "p": 6.425429292514996e-50, + "cytoband": "15q23" + }, + { + "gene": "MYB", + "n": 1082, + "rho": 0.6935, + "rhoP": 5.955304524673328e-156, + "q": 1.0858685713761177e-152, + "r": 0.5738, + "p": 9.00390029063427e-96, + "cytoband": "6q23.3" + }, + { + "gene": "PARD6B", + "n": 1082, + "rho": 0.6921, + "rhoP": 4.213572617077861e-155, + "q": 7.042635498394222e-152, + "r": 0.4221, + "p": 5.4130701455257253e-48, + "cytoband": "20q13.13" + }, + { + "gene": "AGR3", + "n": 1082, + "rho": 0.6917, + "rhoP": 7.300702914027078e-155, + "q": 1.1263861411280085e-151, + "r": 0.4529, + "p": 7.611917342990354e-56, + "cytoband": "7p21.1" + }, + { + "gene": "RERG", + "n": 1082, + "rho": 0.6865, + "rhoP": 1.1766729896737167e-151, + "q": 1.685752153848981e-148, + "r": 0.4489, + "p": 9.237499849486198e-55, + "cytoband": "12p12.3" + }, + { + "gene": "RUNDC1", + "n": 1082, + "rho": 0.6862, + "rhoP": 1.9659693783158502e-151, + "q": 2.628763188058734e-148, + "r": 0.5386, + "p": 2.0039803628690585e-82, + "cytoband": "17q21.31" + }, + { + "gene": "ARSG", + "n": 1082, + "rho": 0.6832, + "rhoP": 1.2219847393427153e-149, + "q": 1.5318342448123024e-146, + "r": 0.4884, + "p": 6.0880783498218e-66, + "cytoband": "17q24.2" + }, + { + "gene": "XBP1", + "n": 1082, + "rho": 0.6777, + "rhoP": 2.1462031656658728e-146, + "q": 2.2655998365137056e-143, + "r": 0.5701, + "p": 2.7960784409340003e-94, + "cytoband": "22q12.1" + }, + { + "gene": "C5AR2", + "n": 1082, + "rho": 0.6746, + "rhoP": 1.4869993093025757e-144, + "q": 1.4202259593657982e-141, + "r": 0.4487, + "p": 9.969062428953839e-55, + "cytoband": "19q13.32" + }, + { + "gene": "ACADSB", + "n": 1082, + "rho": 0.6692, + "rhoP": 1.8245900918985383e-141, + "q": 1.591121890139521e-138, + "r": 0.4641, + "p": 6.801311968497827e-59, + "cytoband": "10q26.13" + }, + { + "gene": "AFF3", + "n": 1082, + "rho": 0.6632, + "rhoP": 4.3889664583171614e-138, + "q": 3.6678958439361377e-135, + "r": 0.508, + "p": 4.629622349829199e-72, + "cytoband": "2q11.2" + }, + { + "…": "80 more", + "sha256": "17a1ad5b7d8a703b" + } + ], + "negative": [ + { + "gene": "HAPLN3", + "n": 1082, + "rho": -0.6795, + "rhoP": 1.9286476519055978e-147, + "q": 2.275463879662975e-144, + "r": -0.3676, + "p": 6.0141506017266405e-36, + "cytoband": "15q26.1" + }, + { + "gene": "YBX1", + "n": 1082, + "rho": -0.6785, + "rhoP": 7.249101982610627e-147, + "q": 8.077513248067853e-144, + "r": -0.4242, + "p": 1.6918694343193526e-48, + "cytoband": "1p34.2" + }, + { + "gene": "SMCO4", + "n": 1082, + "rho": -0.6755, + "rhoP": 4.707889999738897e-145, + "q": 4.721307486238153e-142, + "r": -0.4643, + "p": 5.852839975162891e-59, + "cytoband": "11q21" + }, + { + "gene": "PSAT1", + "n": 1082, + "rho": -0.6732, + "rhoP": 9.879824634187141e-144, + "q": 9.007256485813249e-141, + "r": -0.3561, + "p": 1.0668131141943748e-33, + "cytoband": "9q21.2" + }, + { + "gene": "ACOT9", + "n": 1082, + "rho": -0.6513, + "rhoP": 1.3528541471059772e-131, + "q": 9.044731876168195e-129, + "r": -0.4689, + "p": 3.0756367010551174e-60, + "cytoband": "Xp22.11" + }, + { + "gene": "PPP1R14C", + "n": 1082, + "rho": -0.6399, + "rhoP": 1.0858639930576848e-125, + "q": 5.925766056574825e-123, + "r": -0.301, + "p": 4.21053493663196e-24, + "cytoband": "6q25.1" + }, + { + "gene": "PADI2", + "n": 1082, + "rho": -0.6378, + "rhoP": 1.3108638940870085e-124, + "q": 6.572999280925782e-122, + "r": -0.3904, + "p": 1.049149496850871e-40, + "cytoband": "1p36.13" + }, + { + "gene": "NCK2", + "n": 1082, + "rho": -0.6349, + "rhoP": 3.795969997926965e-123, + "q": 1.7971046075302762e-120, + "r": -0.4534, + "p": 5.539379416243532e-56, + "cytoband": "2q12.2" + }, + { + "gene": "UBE2E3", + "n": 1082, + "rho": -0.6301, + "rhoP": 8.703162966833193e-121, + "q": 3.6366529088702784e-118, + "r": -0.5035, + "p": 1.2643614072929785e-70, + "cytoband": "2q31.3" + }, + { + "gene": "BCL11A", + "n": 1082, + "rho": -0.6297, + "rhoP": 1.4616886426408042e-120, + "q": 5.983079409274818e-118, + "r": -0.3608, + "p": 1.3078776903970973e-34, + "cytoband": "2p16.1" + }, + { + "gene": "CCDC71L", + "n": 1082, + "rho": -0.6296, + "rhoP": 1.5073665335434951e-120, + "q": 6.046650112656376e-118, + "r": -0.4197, + "p": 2.0824439735859627e-47, + "cytoband": "7q22.3" + }, + { + "gene": "MSANTD3", + "n": 1082, + "rho": -0.6261, + "rhoP": 8.199876471874299e-119, + "q": 3.162786969161208e-116, + "r": -0.4676, + "p": 7.098801694277027e-60, + "cytoband": "9q31.1" + }, + { + "gene": "NXN", + "n": 1082, + "rho": -0.6239, + "rhoP": 9.456765471161885e-118, + "q": 3.448624455547162e-115, + "r": -0.4446, + "p": 1.2405501727205802e-53, + "cytoband": "17p13.3" + }, + { + "gene": "GLIPR2", + "n": 1082, + "rho": -0.6231, + "rhoP": 2.1299986841621278e-117, + "q": 7.628818501471392e-115, + "r": -0.387, + "p": 5.444979798636671e-40, + "cytoband": "9p13.3" + }, + { + "gene": "MTHFD1L", + "n": 1082, + "rho": -0.6194, + "rhoP": 1.2583543296204185e-115, + "q": 4.2777648795248705e-113, + "r": -0.404, + "p": 9.667661724659982e-44, + "cytoband": "6q25.1" + }, + { + "gene": "USB1", + "n": 1082, + "rho": -0.619, + "rhoP": 2.014366286114203e-115, + "q": 6.733690766765428e-113, + "r": -0.4453, + "p": 7.932625194451654e-54, + "cytoband": "16q21" + }, + { + "gene": "MSL3", + "n": 1082, + "rho": -0.6177, + "rhoP": 8.090272347188528e-115, + "q": 2.6172031043154886e-112, + "r": -0.4725, + "p": 2.957035824955362e-61, + "cytoband": "Xp22.2" + }, + { + "gene": "VGLL1", + "n": 1082, + "rho": -0.6137, + "rhoP": 6.022559869204369e-113, + "q": 1.7013307506567892e-110, + "r": -0.2137, + "p": 1.219860470145793e-12, + "cytoband": "Xq26.3" + }, + { + "gene": "CSRP2", + "n": 1082, + "rho": -0.609, + "rhoP": 8.507424395223815e-111, + "q": 2.245176461776369e-108, + "r": -0.3422, + "p": 4.421146331412537e-31, + "cytoband": "12q21.2" + }, + { + "gene": "KCNN4", + "n": 1082, + "rho": -0.6088, + "rhoP": 1.061542169475088e-110, + "q": 2.729660422200236e-108, + "r": -0.3303, + "p": 5.937877932918649e-29, + "cytoband": "19q13.31" + }, + { + "…": "80 more", + "sha256": "a9c884cfa869dfcb" + } + ], + "histogram": [ + [ + -1, + 0 + ], + [ + -0.95, + 0 + ], + [ + -0.9, + 0 + ], + [ + -0.85, + 0 + ], + [ + -0.8, + 0 + ], + [ + -0.75, + 0 + ], + [ + -0.7, + 5 + ], + [ + -0.65, + 23 + ], + [ + -0.6, + 66 + ], + [ + -0.55, + 147 + ], + [ + -0.5, + 281 + ], + [ + -0.45, + 427 + ], + [ + -0.4, + 638 + ], + [ + -0.35, + 786 + ], + [ + -0.3, + 1094 + ], + [ + -0.25, + 1253 + ], + [ + -0.2, + 1401 + ], + [ + -0.15, + 1448 + ], + [ + -0.1, + 1762 + ], + [ + -0.05, + 1943 + ], + { + "…": "20 more", + "sha256": "ddc5ef42075ece16" + } + ] + }, + "participation": { + "studies": [ + { + "study": "brca_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "ESR1 on “rna_seq_v2_mrna” against every gene on “rna_seq_v2_mrna”, over the patients in “all patients” with both values (a patient's samples averaged, as the heatmap takes them). Ranked by Spearman's ρ, as the portal ranks, with Pearson's r beside it; q is Benjamini–Hochberg over ρ's p across all 20,057 genes tested. A correlation is not a regulatory link: genes that rise together across a cohort often both track a third thing — a subtype, the tumour's purity, proliferation. 280 genes were not tested: fewer than 10 patients with both values, or no spread.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Sum every gene's values and ranks against ESR1's", + "detail": "The correlates:moments query above. Per patient, ESR1 on “rna_seq_v2_mrna” and every gene on “rna_seq_v2_mrna” (a patient's samples averaged); per gene, over the patients with both: n, Σx, Σy, Σxy, Σx², Σy², and the same six over each value's average rank among those patients (ties share the mean of their ranks). Sums only.", + "scope": "all patients · brca_tcga_pan_can_atlas_2018", + "rowsIn": 1084, + "rowsOut": 20338 + }, + { + "kind": "statistic", + "title": "Pearson's r and Spearman's ρ per gene", + "detail": "r from the sums: (nΣxy − ΣxΣy) / √((nΣx² − (Σx)²)(nΣy² − (Σy)²)); ρ is the same formula on the rank sums. Each p from t = r√((n − 2)/(1 − r²)) on n − 2 df, as scipy's pearsonr and spearmanr compute it. ESR1 against itself is left out. A gene with fewer than 10 patients, or no spread, is not tested.", + "params": [ + [ + "tested", + "20,057" + ], + [ + "not tested", + "280" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg over ρ", + "detail": "q-values over every gene tested, from ρ's p." + } + ], + "implementation": { + "functions": [ + "pearsonFromMoments", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Pearson's r from sums matches scipy 1.18.1 pearsonr (test/moments-golden.test.ts); ρ is the same formula on average ranks, which is how scipy's spearmanr defines it — checked against spearmanr on raw values for TCGA breast cancer ESR1 (FOXA1 ρ 0.7478, PSAT1 −0.6732). Benjamini–Hochberg matches statsmodels multipletests (test/tables-golden.test.ts).", + "check": { + "correlates:tested": { + "v": 20057 + }, + "correlates:CCDC170:rho": { + "v": 0.7917, + "abs": 0.000050000001000000005 + }, + "correlates:CCDC170:rho_p": { + "v": 2.2249983400385912e-233, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:CCDC170:q": { + "v": 4.4626791706154024e-229, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:CCDC170:r": { + "v": 0.6675, + "abs": 0.000050000001000000005 + }, + "correlates:CCDC170:p": { + "v": 1.86618036574955e-140, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:DCPH1:rho": { + "v": 0.7841, + "abs": 0.000050000001000000005 + }, + "correlates:DCPH1:rho_p": { + "v": 5.089149809464745e-226, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:DCPH1:q": { + "v": 5.103653886421719e-222, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:DCPH1:r": { + "v": 0.5652, + "abs": 0.000050000001000000005 + }, + "correlates:DCPH1:p": { + "v": 2.3489389556771624e-92, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:THSD4:rho": { + "v": 0.7776, + "abs": 0.000050000001000000005 + }, + "correlates:THSD4:rho_p": { + "v": 6.808597091162043e-220, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:THSD4:q": { + "v": 4.55200106191457e-216, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:THSD4:r": { + "v": 0.6439, + "abs": 0.000050000001000000005 + }, + "correlates:THSD4:p": { + "v": 1.0524911370004154e-127, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:FOXA1:rho": { + "v": 0.7478, + "abs": 0.000050000001000000005 + }, + "correlates:FOXA1:rho_p": { + "v": 2.5074740593460398e-194, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:FOXA1:q": { + "v": 1.257310180207588e-190, + "rel": 0.000001, + "abs": 1e-300 + }, + "correlates:FOXA1:r": { + "v": 0.686, + "abs": 0.000050000001000000005 + }, + "…": { + "more": 381, + "sha256": "af5ded2c86034ab3" + } + } + } + } + ] +} diff --git a/test/snapshots/correlates.sql b/test/snapshots/correlates.sql new file mode 100644 index 0000000..be011cc --- /dev/null +++ b/test/snapshots/correlates.sql @@ -0,0 +1,43 @@ +-- cohort all patients +-- brca_tcga_pan_can_atlas_2018 +SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' + +-- view 0 correlates: correlates:moments · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), +q AS ( + SELECT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid, ga.hugo_gene_symbol AS gene, avg(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) AS v + FROM snapshot_db.genetic_alteration_derived ga + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id + WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna' AND ga.hugo_gene_symbol = 'ESR1' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND isFinite(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) + AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid, gene +), +o AS ( + SELECT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid, ga.hugo_gene_symbol AS gene, avg(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) AS v + FROM snapshot_db.genetic_alteration_derived ga + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id + WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND isFinite(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) + AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid, gene +), +paired AS (SELECT o.gene AS gene, q.v AS x, o.v AS y FROM o INNER JOIN q ON q.pid = o.pid), +ranked AS ( + SELECT gene, x, y, + rank() OVER (PARTITION BY gene ORDER BY x) + (count() OVER (PARTITION BY gene, x) - 1) / 2 AS rx, + rank() OVER (PARTITION BY gene ORDER BY y) + (count() OVER (PARTITION BY gene, y) - 1) / 2 AS ry + FROM paired +) +SELECT gene, count() AS n, sum(x) AS sx, sum(y) AS sy, sum(x * y) AS sxy, sum(x * x) AS sxx, sum(y * y) AS syy, + sum(rx) AS rsx, sum(ry) AS rsy, sum(rx * ry) AS rsxy, sum(rx * rx) AS rsxx, sum(ry * ry) AS rsyy +FROM ranked GROUP BY gene + +-- view 0 correlates: cytobands · brca_tcga_pan_can_atlas_2018 +SELECT g.hugo_gene_symbol AS gene, any(rgg.cytoband) AS cytoband FROM snapshot_db.gene g +JOIN snapshot_db.reference_genome_gene rgg ON rgg.entrez_gene_id = g.entrez_gene_id +WHERE rgg.reference_genome_id = (SELECT reference_genome_id FROM snapshot_db.cancer_study WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018') + AND g.hugo_gene_symbol IN ('CCDC170','DCPH1','THSD4','FOXA1','TBC1D9','RABEP1','SLC39A6','GATA3','CA12','CT62','MYB','PARD6B','AGR3','RERG','RUNDC1','ARSG','XBP1','C5AR2','ACADSB','AFF3','NUDT12','CACNA2D2','ANKRA2','WWP1','RETREG1','ZNF552','TLE3','DNAL1','SLC22A5','GFRA1','DCTN4','GATA3-AS1','FAM234B','ERBB4','SLC16A6','APH1B','MINDY1','ZNF396','DACH1','RALGPS2','APBB2','CYP2B7P','IGF1R','SPEF2','MRTFB','TCEAL1','TSPAN13','BCL2','GIN1','CLSTN2','SCUBE2','BTRC','CELSR1','RGS22','TMEM144','LONRF2','MAPT','ANXA9','TMBIM6','CCDC125','CST9','FNIP1','KDM4B','TMPRSS6','TAPT1','SERPINA11','FRS2','ELP2','ABAT','TTC8','PCBD2','CMBL','NAT1','WDR19','SLC46A1','FSIP1','ZNF587','QNG1','PLA2G12A','SKP1','MLPH','DNAJC12','KCTD6','ETFBKMT','LRBA','REPS2','TPSG1','TMC4','NDFIP1','RMND1','SYTL4','MACIR','SAMD15','BBS1','SEPSECS','TMEM161B','EXOC6','FBXL5','PREX1','RAB30','HAPLN3','YBX1','SMCO4','PSAT1','ACOT9','PPP1R14C','PADI2','NCK2','UBE2E3','BCL11A','CCDC71L','MSANTD3','NXN','GLIPR2','MTHFD1L','USB1','MSL3','VGLL1','CSRP2','KCNN4','RARRES1','TTC7A','B3GNT5','FSCN1','CCDC82','NT5DC2','ENO1','CPNE2','MID1','YBX3','ITM2C','PRKX','CDC42EP1','ARHGEF4','ARL4C','PALS2','FZD9','SRD5A1','MRAS','FOXC1','EPHB6','STAC','KRT16','RGMA','FAM171A1','SLC43A3','RASAL1','RBM38','CLCN4','TUBB6','NCS1','A2ML1','RSU1','PLOD1','SLC15A1','RAP2B','MFGE8','MCF2L2','UPP1','CIB2','ST8SIA1','CXCL1','ACE2','WNT6','RNF145','IFRD1','PFKP','ART3','PTK7','EN1','CHST2','UNC13D','DSC2','KCNG1','CDCA7','ATP6V1C2','NFIL3','CDH3','FMNL2','GSTP1','CHST3','LMO4','ESYT3','INTS6L','JOSD1','INAVA','MICALL1','TTLL4','APBA2','TTYH3','BTG3','ANKS6','IL12RB2','RIN3','SCPEP1','SH2D2A','SRSF12','PDSS1','FABP7','GAL') +GROUP BY gene diff --git a/test/snapshots/correlates.svg b/test/snapshots/correlates.svg new file mode 100644 index 0000000..8b72e95 --- /dev/null +++ b/test/snapshots/correlates.svg @@ -0,0 +1,2 @@ + +Co-expression — ESR1 against every gene — all patients20,057 genes against ESR1 · 15,572 at q < 0.05 · Spearman ρ05001,0001,5002,000genesρ −0.70 to −0.65: 5 genesρ −0.65 to −0.60: 23 genesρ −0.60 to −0.55: 66 genesρ −0.55 to −0.50: 147 genesρ −0.50 to −0.45: 281 genesρ −0.45 to −0.40: 427 genesρ −0.40 to −0.35: 638 genesρ −0.35 to −0.30: 786 genesρ −0.30 to −0.25: 1,094 genesρ −0.25 to −0.20: 1,253 genesρ −0.20 to −0.15: 1,401 genesρ −0.15 to −0.10: 1,448 genesρ −0.10 to −0.05: 1,762 genesρ −0.05 to 0.00: 1,943 genesρ 0.00 to 0.05: 1,742 genesρ 0.05 to 0.10: 1,293 genesρ 0.10 to 0.15: 1,155 genesρ 0.15 to 0.20: 944 genesρ 0.20 to 0.25: 828 genesρ 0.25 to 0.30: 687 genesρ 0.30 to 0.35: 647 genesρ 0.35 to 0.40: 482 genesρ 0.40 to 0.45: 378 genesρ 0.45 to 0.50: 275 genesρ 0.50 to 0.55: 183 genesρ 0.55 to 0.60: 102 genesρ 0.60 to 0.65: 41 genesρ 0.65 to 0.70: 18 genesρ 0.70 to 0.75: 5 genesρ 0.75 to 0.80: 3 genes−1.0−0.50.00.51.0Spearman ρ with ESR1rise with ESR1ρrqCCDC1700.790.674.5e-229DCPH10.780.575.1e-222THSD40.780.644.6e-216FOXA10.750.691.3e-190TBC1D90.750.552.5e-189RABEP10.730.625.9e-176SLC39A60.720.452.7e-171GATA30.720.563.4e-170CA120.690.525e-153CT620.690.437.3e-153MYB0.690.571.1e-152PARD6B0.690.427e-152AGR30.690.451.1e-151RERG0.690.451.7e-148RUNDC10.690.542.6e-148ARSG0.680.491.5e-146XBP10.680.572.3e-143C5AR20.670.451.4e-141ACADSB0.670.461.6e-138AFF30.660.513.7e-135NUDT120.660.555e-134CACNA2D20.660.411.5e-132ANKRA20.660.544.5e-131WWP10.660.418.5e-131RETREG10.650.466.3e-130fall as ESR1 risesρrqHAPLN3−0.68−0.372.3e-144YBX1−0.68−0.428.1e-144SMCO4−0.68−0.464.7e-142PSAT1−0.67−0.369e-141ACOT9−0.65−0.479e-129PPP1R14C−0.64−0.305.9e-123PADI2−0.64−0.396.6e-122NCK2−0.63−0.451.8e-120UBE2E3−0.63−0.503.6e-118BCL11A−0.63−0.366e-118CCDC71L−0.63−0.426e-118MSANTD3−0.63−0.473.2e-116NXN−0.62−0.443.4e-115GLIPR2−0.62−0.397.6e-115MTHFD1L−0.62−0.404.3e-113USB1−0.62−0.456.7e-113MSL3−0.62−0.472.6e-112VGLL1−0.61−0.211.7e-110CSRP2−0.61−0.342.2e-108KCNN4−0.61−0.332.7e-108RARRES1−0.61−0.207.4e-108TTC7A−0.61−0.432.1e-107B3GNT5−0.61−0.404.1e-107FSCN1−0.60−0.321.9e-106CCDC82−0.60−0.456.6e-106+150 more listed in the result and the MCP text; every one of the 20,057 genes is in the histogramESR1 on “rna_seq_v2_mrna” against every gene on “rna_seq_v2_mrna”, over the patients in “all patients” with both values (a patient's samples averaged, as theheatmap takes them). Ranked by Spearman's ρ, as the portal ranks, with Pearson's r beside it; q is Benjamini–Hochberg over ρ's p across all 20,057 genes tested. Acorrelation is not a regulatory link: genes that rise together across a cohort often both track a third thing — a subtype, the tumour's purity, proliferation. 280 genes werenot tested: fewer than 10 patients with both values, or no spread. diff --git a/test/snapshots/correlates.txt b/test/snapshots/correlates.txt new file mode 100644 index 0000000..b28772b --- /dev/null +++ b/test/snapshots/correlates.txt @@ -0,0 +1,216 @@ +Analysis over brca_tcga_pan_can_atlas_2018 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- all patients: 1,084 patients — all patients in the study + +Genes co-expressed with ESR1 (rna_seq_v2_mrna) in all patients; Spearman ρ, BH q over 20,057 genes; 15,572 at q<0.05: + most positively correlated: + CCDC170: ρ 0.7917 (q=4.5e-229), r 0.6675, n=1082 + DCPH1: ρ 0.7841 (q=5.1e-222), r 0.5652, n=1082 + THSD4: ρ 0.7776 (q=4.6e-216), r 0.6439, n=1082 + FOXA1: ρ 0.7478 (q=1.3e-190), r 0.686, n=1082 + TBC1D9: ρ 0.746 (q=2.5e-189), r 0.5514, n=1082 + RABEP1: ρ 0.7283 (q=5.9e-176), r 0.6183, n=1082 + SLC39A6: ρ 0.7217 (q=2.7e-171), r 0.45, n=1082 + GATA3: ρ 0.7201 (q=3.4e-170), r 0.5603, n=1082 + CA12: ρ 0.6942 (q=5.0e-153), r 0.516, n=1082 + CT62: ρ 0.6938 (q=7.3e-153), r 0.43, n=1082 + MYB: ρ 0.6935 (q=1.1e-152), r 0.5738, n=1082 + PARD6B: ρ 0.6921 (q=7.0e-152), r 0.4221, n=1082 + AGR3: ρ 0.6917 (q=1.1e-151), r 0.4529, n=1082 + RERG: ρ 0.6865 (q=1.7e-148), r 0.4489, n=1082 + RUNDC1: ρ 0.6862 (q=2.6e-148), r 0.5386, n=1082 + ARSG: ρ 0.6832 (q=1.5e-146), r 0.4884, n=1082 + XBP1: ρ 0.6777 (q=2.3e-143), r 0.5701, n=1082 + C5AR2: ρ 0.6746 (q=1.4e-141), r 0.4487, n=1082 + ACADSB: ρ 0.6692 (q=1.6e-138), r 0.4641, n=1082 + AFF3: ρ 0.6632 (q=3.7e-135), r 0.508, n=1082 + NUDT12: ρ 0.6611 (q=5.0e-134), r 0.551, n=1082 + CACNA2D2: ρ 0.6584 (q=1.5e-132), r 0.4085, n=1082 + ANKRA2: ρ 0.6557 (q=4.5e-131), r 0.536, n=1082 + WWP1: ρ 0.6551 (q=8.5e-131), r 0.4141, n=1082 + RETREG1: ρ 0.6535 (q=6.3e-130), r 0.4608, n=1082 + ZNF552: ρ 0.6509 (q=1.4e-128), r 0.4146, n=1082 + TLE3: ρ 0.6496 (q=6.2e-128), r 0.5597, n=1082 + DNAL1: ρ 0.6476 (q=7.0e-127), r 0.5518, n=1082 + SLC22A5: ρ 0.6456 (q=7.3e-126), r 0.4794, n=1082 + GFRA1: ρ 0.6442 (q=4.0e-125), r 0.4822, n=1082 + DCTN4: ρ 0.6399 (q=5.9e-123), r 0.5774, n=1082 + GATA3-AS1: ρ 0.6396 (q=8.3e-123), r 0.3017, n=1082 + FAM234B: ρ 0.6393 (q=1.1e-122), r 0.2777, n=1082 + ERBB4: ρ 0.6361 (q=4.8e-121), r 0.4517, n=1082 + SLC16A6: ρ 0.6349 (q=1.8e-120), r 0.2774, n=1082 + APH1B: ρ 0.634 (q=4.5e-120), r 0.528, n=1082 + MINDY1: ρ 0.6339 (q=5.4e-120), r 0.473, n=1082 + ZNF396: ρ 0.6337 (q=6.3e-120), r 0.4807, n=1082 + DACH1: ρ 0.6314 (q=8.4e-119), r 0.4958, n=1082 + RALGPS2: ρ 0.6273 (q=7.8e-117), r 0.4589, n=1082 + APBB2: ρ 0.6252 (q=8.3e-116), r 0.4555, n=1082 + CYP2B7P: ρ 0.6248 (q=1.3e-115), r 0.3341, n=1082 + IGF1R: ρ 0.6218 (q=3.3e-114), r 0.1326, n=1082 + SPEF2: ρ 0.6204 (q=1.5e-113), r 0.4583, n=1082 + MRTFB: ρ 0.6178 (q=2.4e-112), r 0.4556, n=1082 + TCEAL1: ρ 0.6171 (q=4.6e-112), r 0.3587, n=1082 + TSPAN13: ρ 0.6171 (q=4.6e-112), r 0.4134, n=1082 + BCL2: ρ 0.6165 (q=9.2e-112), r 0.4689, n=1082 + GIN1: ρ 0.6165 (q=8.8e-112), r 0.5233, n=1082 + CLSTN2: ρ 0.616 (q=1.5e-111), r 0.3511, n=1082 + SCUBE2: ρ 0.616 (q=1.5e-111), r 0.3649, n=1082 + BTRC: ρ 0.6154 (q=2.6e-111), r 0.4736, n=1082 + CELSR1: ρ 0.6146 (q=6.2e-111), r 0.4595, n=1082 + RGS22: ρ 0.613 (q=3.4e-110), r 0.3173, n=1082 + TMEM144: ρ 0.6111 (q=2.5e-109), r 0.5146, n=1082 + LONRF2: ρ 0.6106 (q=4.3e-109), r 0.37, n=1082 + MAPT: ρ 0.6106 (q=4.3e-109), r 0.4031, n=1082 + ANXA9: ρ 0.609 (q=2.3e-108), r 0.3709, n=1082 + TMBIM6: ρ 0.6082 (q=4.6e-108), r 0.4915, n=1082 + CCDC125: ρ 0.6068 (q=2.0e-107), r 0.5104, n=1082 + CST9: ρ 0.6057 (q=6.0e-107), r 0.2638, n=1082 + FNIP1: ρ 0.6046 (q=1.9e-106), r 0.4927, n=1082 + KDM4B: ρ 0.604 (q=3.5e-106), r 0.4094, n=1082 + TMPRSS6: ρ 0.603 (q=9.7e-106), r 0.3263, n=1082 + TAPT1: ρ 0.6025 (q=1.5e-105), r 0.4741, n=1082 + SERPINA11: ρ 0.6006 (q=9.9e-105), r 0.3158, n=1082 + FRS2: ρ 0.6004 (q=1.2e-104), r 0.2337, n=1082 + ELP2: ρ 0.599 (q=5.2e-104), r 0.4214, n=1082 + ABAT: ρ 0.5987 (q=6.9e-104), r 0.3787, n=1082 + TTC8: ρ 0.5981 (q=1.2e-103), r 0.4767, n=1082 + PCBD2: ρ 0.5972 (q=3.0e-103), r 0.4669, n=1082 + CMBL: ρ 0.5965 (q=5.9e-103), r 0.4366, n=1082 + NAT1: ρ 0.5965 (q=5.9e-103), r 0.2747, n=1082 + WDR19: ρ 0.5958 (q=1.1e-102), r 0.4586, n=1082 + SLC46A1: ρ 0.595 (q=2.4e-102), r 0.4347, n=1082 + FSIP1: ρ 0.5938 (q=8.1e-102), r 0.3055, n=1082 + ZNF587: ρ 0.5934 (q=1.2e-101), r 0.3584, n=1082 + QNG1: ρ 0.5933 (q=1.3e-101), r 0.4653, n=1082 + PLA2G12A: ρ 0.5925 (q=2.8e-101), r 0.5422, n=1082 + SKP1: ρ 0.5923 (q=3.3e-101), r 0.48, n=1082 + MLPH: ρ 0.5912 (q=1.0e-100), r 0.3597, n=1082 + DNAJC12: ρ 0.5896 (q=4.8e-100), r 0.312, n=1082 + KCTD6: ρ 0.5885 (q=1.3e-99), r 0.3478, n=1082 + ETFBKMT: ρ 0.5878 (q=2.7e-99), r 0.4548, n=1082 + LRBA: ρ 0.5874 (q=4.0e-99), r 0.5031, n=1082 + REPS2: ρ 0.5839 (q=1.1e-97), r 0.3902, n=1082 + TPSG1: ρ 0.5839 (q=1.1e-97), r 0.2078, n=1082 + TMC4: ρ 0.5836 (q=1.5e-97), r 0.4209, n=1082 + NDFIP1: ρ 0.5826 (q=3.7e-97), r 0.4907, n=1082 + RMND1: ρ 0.5819 (q=7.4e-97), r 0.4186, n=1082 + SYTL4: ρ 0.5818 (q=7.4e-97), r 0.3617, n=1082 + MACIR: ρ 0.5816 (q=9.5e-97), r 0.3356, n=1082 + SAMD15: ρ 0.5815 (q=1.0e-96), r 0.3968, n=1082 + BBS1: ρ 0.5787 (q=1.4e-95), r 0.4129, n=1082 + SEPSECS: ρ 0.5787 (q=1.4e-95), r 0.467, n=1082 + TMEM161B: ρ 0.5779 (q=3.0e-95), r 0.4767, n=1082 + EXOC6: ρ 0.5776 (q=3.7e-95), r 0.4399, n=1082 + FBXL5: ρ 0.577 (q=6.4e-95), r 0.4875, n=1082 + PREX1: ρ 0.5769 (q=7.4e-95), r 0.3452, n=1082 + RAB30: ρ 0.5761 (q=1.5e-94), r 0.4224, n=1082 + most negatively correlated: + HAPLN3: ρ -0.6795 (q=2.3e-144), r -0.3676, n=1082 + YBX1: ρ -0.6785 (q=8.1e-144), r -0.4242, n=1082 + SMCO4: ρ -0.6755 (q=4.7e-142), r -0.4643, n=1082 + PSAT1: ρ -0.6732 (q=9.0e-141), r -0.3561, n=1082 + ACOT9: ρ -0.6513 (q=9.0e-129), r -0.4689, n=1082 + PPP1R14C: ρ -0.6399 (q=5.9e-123), r -0.301, n=1082 + PADI2: ρ -0.6378 (q=6.6e-122), r -0.3904, n=1082 + NCK2: ρ -0.6349 (q=1.8e-120), r -0.4534, n=1082 + UBE2E3: ρ -0.6301 (q=3.6e-118), r -0.5035, n=1082 + BCL11A: ρ -0.6297 (q=6.0e-118), r -0.3608, n=1082 + CCDC71L: ρ -0.6296 (q=6.0e-118), r -0.4197, n=1082 + MSANTD3: ρ -0.6261 (q=3.2e-116), r -0.4676, n=1082 + NXN: ρ -0.6239 (q=3.4e-115), r -0.4446, n=1082 + GLIPR2: ρ -0.6231 (q=7.6e-115), r -0.387, n=1082 + MTHFD1L: ρ -0.6194 (q=4.3e-113), r -0.404, n=1082 + USB1: ρ -0.619 (q=6.7e-113), r -0.4453, n=1082 + MSL3: ρ -0.6177 (q=2.6e-112), r -0.4725, n=1082 + VGLL1: ρ -0.6137 (q=1.7e-110), r -0.2137, n=1082 + CSRP2: ρ -0.609 (q=2.2e-108), r -0.3422, n=1082 + KCNN4: ρ -0.6088 (q=2.7e-108), r -0.3303, n=1082 + RARRES1: ρ -0.6078 (q=7.4e-108), r -0.2045, n=1082 + TTC7A: ρ -0.6068 (q=2.1e-107), r -0.4252, n=1082 + B3GNT5: ρ -0.6061 (q=4.1e-107), r -0.3966, n=1082 + FSCN1: ρ -0.6046 (q=1.9e-106), r -0.3211, n=1082 + CCDC82: ρ -0.6033 (q=6.6e-106), r -0.4511, n=1082 + NT5DC2: ρ -0.6024 (q=1.7e-105), r -0.388, n=1082 + ENO1: ρ -0.6024 (q=1.7e-105), r -0.4196, n=1082 + CPNE2: ρ -0.6017 (q=3.2e-105), r -0.4652, n=1082 + MID1: ρ -0.5989 (q=5.8e-104), r -0.3967, n=1082 + YBX3: ρ -0.5986 (q=7.5e-104), r -0.3926, n=1082 + ITM2C: ρ -0.5974 (q=2.3e-103), r -0.3885, n=1082 + PRKX: ρ -0.597 (q=3.4e-103), r -0.402, n=1082 + CDC42EP1: ρ -0.5966 (q=5.2e-103), r -0.4207, n=1082 + ARHGEF4: ρ -0.5954 (q=1.6e-102), r -0.3243, n=1082 + ARL4C: ρ -0.5945 (q=3.9e-102), r -0.4274, n=1082 + PALS2: ρ -0.5944 (q=4.6e-102), r -0.3824, n=1082 + FZD9: ρ -0.5921 (q=3.9e-101), r -0.2214, n=1082 + SRD5A1: ρ -0.5902 (q=2.6e-100), r -0.2853, n=1082 + MRAS: ρ -0.5849 (q=4.3e-98), r -0.3858, n=1082 + FOXC1: ρ -0.5849 (q=4.2e-98), r -0.3386, n=1082 + EPHB6: ρ -0.5821 (q=6.1e-97), r -0.2295, n=1082 + STAC: ρ -0.5814 (q=1.1e-96), r -0.2815, n=1082 + KRT16: ρ -0.5809 (q=1.8e-96), r -0.1838, n=1082 + RGMA: ρ -0.5798 (q=4.8e-96), r -0.394, n=1082 + FAM171A1: ρ -0.5786 (q=1.6e-95), r -0.3924, n=1082 + SLC43A3: ρ -0.5785 (q=1.7e-95), r -0.1708, n=1082 + RASAL1: ρ -0.5783 (q=1.9e-95), r -0.3489, n=1082 + RBM38: ρ -0.5776 (q=3.7e-95), r -0.3661, n=1082 + CLCN4: ρ -0.5776 (q=3.6e-95), r -0.3326, n=1082 + TUBB6: ρ -0.5766 (q=9.6e-95), r -0.4434, n=1082 + NCS1: ρ -0.5757 (q=2.1e-94), r -0.4021, n=1082 + A2ML1: ρ -0.5742 (q=8.5e-94), r -0.1998, n=1082 + RSU1: ρ -0.5733 (q=1.9e-93), r -0.4027, n=1082 + PLOD1: ρ -0.5731 (q=2.1e-93), r -0.3407, n=1082 + SLC15A1: ρ -0.5723 (q=4.7e-93), r -0.1519, n=1082 + RAP2B: ρ -0.5721 (q=5.6e-93), r -0.4518, n=1082 + MFGE8: ρ -0.5697 (q=4.7e-92), r -0.2526, n=1082 + MCF2L2: ρ -0.5696 (q=5.3e-92), r -0.2589, n=1082 + UPP1: ρ -0.5694 (q=6.0e-92), r -0.3009, n=1082 + CIB2: ρ -0.569 (q=8.9e-92), r -0.3322, n=1082 + ST8SIA1: ρ -0.5688 (q=1.1e-91), r -0.37, n=1082 + CXCL1: ρ -0.568 (q=2.1e-91), r -0.1851, n=1082 + ACE2: ρ -0.568 (q=2.0e-91), r -0.0985, n=1082 + WNT6: ρ -0.566 (q=1.3e-90), r -0.2561, n=1082 + RNF145: ρ -0.5656 (q=1.8e-90), r -0.3563, n=1082 + IFRD1: ρ -0.5638 (q=8.4e-90), r -0.3738, n=1082 + PFKP: ρ -0.562 (q=4.3e-89), r -0.3957, n=1082 + ART3: ρ -0.5615 (q=6.7e-89), r -0.1669, n=1082 + PTK7: ρ -0.5608 (q=1.2e-88), r -0.4226, n=1082 + EN1: ρ -0.5597 (q=3.0e-88), r -0.2881, n=1082 + CHST2: ρ -0.559 (q=5.5e-88), r -0.2951, n=1082 + UNC13D: ρ -0.5584 (q=9.2e-88), r -0.3432, n=1082 + DSC2: ρ -0.558 (q=1.3e-87), r -0.3279, n=1082 + KCNG1: ρ -0.5566 (q=4.6e-87), r -0.1918, n=1082 + CDCA7: ρ -0.5559 (q=7.9e-87), r -0.363, n=1082 + ATP6V1C2: ρ -0.5559 (q=7.8e-87), r -0.2332, n=1082 + NFIL3: ρ -0.5555 (q=1.1e-86), r -0.4152, n=1082 + CDH3: ρ -0.5553 (q=1.4e-86), r -0.388, n=1082 + FMNL2: ρ -0.555 (q=1.7e-86), r -0.4073, n=1082 + GSTP1: ρ -0.5541 (q=3.7e-86), r -0.3257, n=1082 + CHST3: ρ -0.5541 (q=3.6e-86), r -0.3816, n=1082 + LMO4: ρ -0.554 (q=4.1e-86), r -0.3318, n=1082 + ESYT3: ρ -0.5535 (q=6.3e-86), r -0.3241, n=1082 + INTS6L: ρ -0.553 (q=9.1e-86), r -0.3954, n=1082 + JOSD1: ρ -0.5527 (q=1.2e-85), r -0.4366, n=1082 + INAVA: ρ -0.5524 (q=1.5e-85), r -0.3143, n=1082 + MICALL1: ρ -0.5523 (q=1.7e-85), r -0.3806, n=1082 + TTLL4: ρ -0.5519 (q=2.3e-85), r -0.3634, n=1082 + APBA2: ρ -0.5515 (q=3.3e-85), r -0.3666, n=1082 + TTYH3: ρ -0.5512 (q=4.2e-85), r -0.4035, n=1082 + BTG3: ρ -0.551 (q=4.9e-85), r -0.3397, n=1082 + ANKS6: ρ -0.5508 (q=5.6e-85), r -0.3766, n=1082 + IL12RB2: ρ -0.5505 (q=7.4e-85), r -0.2098, n=1082 + RIN3: ρ -0.55 (q=1.1e-84), r -0.4432, n=1082 + SCPEP1: ρ -0.548 (q=5.8e-84), r -0.3666, n=1082 + SH2D2A: ρ -0.5467 (q=1.8e-83), r -0.3763, n=1082 + SRSF12: ρ -0.5464 (q=2.3e-83), r -0.3222, n=1082 + PDSS1: ρ -0.5456 (q=4.2e-83), r -0.3721, n=1082 + FABP7: ρ -0.5454 (q=5.2e-83), r -0.084, n=1082 + GAL: ρ -0.5445 (q=1.1e-82), r -0.1888, n=1082 + CAVEAT (tell the user): ESR1 on “rna_seq_v2_mrna” against every gene on “rna_seq_v2_mrna”, over the patients in “all patients” with both values (a patient's samples averaged, as the heatmap takes them). Ranked by Spearman's ρ, as the portal ranks, with Pearson's r beside it; q is Benjamini–Hochberg over ρ's p across all 20,057 genes tested. A correlation is not a regulatory link: genes that rise together across a cohort often both track a third thing — a subtype, the tumour's purity, proliferation. 280 genes were not tested: fewer than 10 patients with both values, or no spread. + METHOD: + - Sum every gene's values and ranks against ESR1's [all patients · brca_tcga_pan_can_atlas_2018] (1,084 → 20,338 rows): The correlates:moments query above. Per patient, ESR1 on “rna_seq_v2_mrna” and every gene on “rna_seq_v2_mrna” (a patient's samples averaged); per gene, over the patients with both: n, Σx, Σy, Σxy, Σx², Σy², and the same six over each value's average rank among those patients (ties share the mean of their ranks). Sums only. + - Pearson's r and Spearman's ρ per gene: r from the sums: (nΣxy − ΣxΣy) / √((nΣx² − (Σx)²)(nΣy² − (Σy)²)); ρ is the same formula on the rank sums. Each p from t = r√((n − 2)/(1 − r²)) on n − 2 df, as scipy's pearsonr and spearmanr compute it. ESR1 against itself is left out. A gene with fewer than 10 patients, or no spread, is not tested. + tested: 20,057 + not tested: 280 + - Benjamini–Hochberg over ρ: q-values over every gene tested, from ρ's p. + Pearson's r from sums matches scipy 1.18.1 pearsonr (test/moments-golden.test.ts); ρ is the same formula on average ranks, which is how scipy's spearmanr defines it — checked against spearmanr on raw values for TCGA breast cancer ESR1 (FOXA1 ρ 0.7478, PSAT1 −0.6732). Benjamini–Hochberg matches statsmodels multipletests (test/tables-golden.test.ts). diff --git a/test/snapshots/course.json b/test/snapshots/course.json new file mode 100644 index 0000000..e12b69d --- /dev/null +++ b/test/snapshots/course.json @@ -0,0 +1,782 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "TP53 mut": { + "count": 13105, + "text": "OQL[TP53: MUT]", + "studies": [ + "msk_chord_2024" + ] + }, + "TP53 wt": { + "count": 11594, + "text": "NOT OQL[TP53:] AND profiled for TP53 MUTATION", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "course", + "cohorts": [ + "TP53 mut", + "TP53 wt" + ], + "studies": [ + "msk_chord_2024" + ], + "course": [ + { + "cohort": "TP53 mut", + "eventType": "Treatment", + "variants": [ + "Treatment" + ], + "isInterval": true, + "points": [ + { + "t": -12, + "atRisk": 2411, + "n": 0, + "pct": 0 + }, + { + "t": -9, + "atRisk": 2757, + "n": 0, + "pct": 0 + }, + { + "t": -6, + "atRisk": 3527, + "n": 0, + "pct": 0 + }, + { + "t": -3, + "atRisk": 12392, + "n": 0, + "pct": 0 + }, + { + "t": 0, + "atRisk": 12738, + "n": 12738, + "pct": 100 + }, + { + "t": 3, + "atRisk": 12222, + "n": 9368, + "pct": 76.6 + }, + { + "t": 6, + "atRisk": 11605, + "n": 7122, + "pct": 61.4 + }, + { + "t": 9, + "atRisk": 10910, + "n": 5792, + "pct": 53.1 + }, + { + "t": 12, + "atRisk": 10100, + "n": 5149, + "pct": 51 + }, + { + "t": 15, + "atRisk": 9355, + "n": 4587, + "pct": 49 + }, + { + "t": 18, + "atRisk": 8656, + "n": 4071, + "pct": 47 + }, + { + "t": 21, + "atRisk": 7990, + "n": 3676, + "pct": 46 + }, + { + "t": 24, + "atRisk": 7392, + "n": 3365, + "pct": 45.5 + }, + { + "t": 27, + "atRisk": 6811, + "n": 3025, + "pct": 44.4 + }, + { + "t": 30, + "atRisk": 6283, + "n": 2720, + "pct": 43.3 + }, + { + "t": 33, + "atRisk": 5832, + "n": 2490, + "pct": 42.7 + }, + { + "t": 36, + "atRisk": 5364, + "n": 2263, + "pct": 42.2 + }, + { + "t": 39, + "atRisk": 5018, + "n": 2137, + "pct": 42.6 + }, + { + "t": 42, + "atRisk": 4686, + "n": 1947, + "pct": 41.5 + }, + { + "t": 45, + "atRisk": 4343, + "n": 1813, + "pct": 41.7 + }, + { + "…": "5 more", + "sha256": "f2706579d3f82710" + } + ] + }, + { + "cohort": "TP53 mut", + "eventType": "Surgery", + "variants": [ + "Surgery" + ], + "isInterval": false, + "points": [ + { + "t": -12, + "atRisk": 2411, + "n": 42, + "pct": 1.7 + }, + { + "t": -9, + "atRisk": 2757, + "n": 78, + "pct": 2.8 + }, + { + "t": -6, + "atRisk": 3527, + "n": 115, + "pct": 3.3 + }, + { + "t": -3, + "atRisk": 12392, + "n": 3857, + "pct": 31.1 + }, + { + "t": 0, + "atRisk": 12738, + "n": 3725, + "pct": 29.2 + }, + { + "t": 3, + "atRisk": 12222, + "n": 2473, + "pct": 20.2 + }, + { + "t": 6, + "atRisk": 11605, + "n": 1933, + "pct": 16.7 + }, + { + "t": 9, + "atRisk": 10910, + "n": 1672, + "pct": 15.3 + }, + { + "t": 12, + "atRisk": 10100, + "n": 1384, + "pct": 13.7 + }, + { + "t": 15, + "atRisk": 9355, + "n": 1128, + "pct": 12.1 + }, + { + "t": 18, + "atRisk": 8656, + "n": 1070, + "pct": 12.4 + }, + { + "t": 21, + "atRisk": 7990, + "n": 871, + "pct": 10.9 + }, + { + "t": 24, + "atRisk": 7392, + "n": 824, + "pct": 11.1 + }, + { + "t": 27, + "atRisk": 6811, + "n": 703, + "pct": 10.3 + }, + { + "t": 30, + "atRisk": 6283, + "n": 614, + "pct": 9.8 + }, + { + "t": 33, + "atRisk": 5832, + "n": 573, + "pct": 9.8 + }, + { + "t": 36, + "atRisk": 5364, + "n": 483, + "pct": 9 + }, + { + "t": 39, + "atRisk": 5018, + "n": 430, + "pct": 8.6 + }, + { + "t": 42, + "atRisk": 4686, + "n": 459, + "pct": 9.8 + }, + { + "t": 45, + "atRisk": 4343, + "n": 399, + "pct": 9.2 + }, + { + "…": "5 more", + "sha256": "e8c841d738387602" + } + ] + }, + { + "cohort": "TP53 wt", + "eventType": "Treatment", + "variants": [ + "Treatment" + ], + "isInterval": true, + "points": [ + { + "t": -12, + "atRisk": 2781, + "n": 0, + "pct": 0 + }, + { + "t": -9, + "atRisk": 3088, + "n": 0, + "pct": 0 + }, + { + "t": -6, + "atRisk": 4019, + "n": 0, + "pct": 0 + }, + { + "t": -3, + "atRisk": 10608, + "n": 0, + "pct": 0 + }, + { + "t": 0, + "atRisk": 11044, + "n": 11044, + "pct": 100 + }, + { + "t": 3, + "atRisk": 10727, + "n": 7609, + "pct": 70.9 + }, + { + "t": 6, + "atRisk": 10417, + "n": 6317, + "pct": 60.6 + }, + { + "t": 9, + "atRisk": 10054, + "n": 5596, + "pct": 55.7 + }, + { + "t": 12, + "atRisk": 9629, + "n": 5149, + "pct": 53.5 + }, + { + "t": 15, + "atRisk": 9230, + "n": 4811, + "pct": 52.1 + }, + { + "t": 18, + "atRisk": 8779, + "n": 4481, + "pct": 51 + }, + { + "t": 21, + "atRisk": 8393, + "n": 4251, + "pct": 50.6 + }, + { + "t": 24, + "atRisk": 8010, + "n": 3965, + "pct": 49.5 + }, + { + "t": 27, + "atRisk": 7602, + "n": 3765, + "pct": 49.5 + }, + { + "t": 30, + "atRisk": 7245, + "n": 3528, + "pct": 48.7 + }, + { + "t": 33, + "atRisk": 6904, + "n": 3353, + "pct": 48.6 + }, + { + "t": 36, + "atRisk": 6568, + "n": 3150, + "pct": 48 + }, + { + "t": 39, + "atRisk": 6287, + "n": 3030, + "pct": 48.2 + }, + { + "t": 42, + "atRisk": 5995, + "n": 2894, + "pct": 48.3 + }, + { + "t": 45, + "atRisk": 5696, + "n": 2754, + "pct": 48.3 + }, + { + "…": "5 more", + "sha256": "c19851a088b9d5c8" + } + ] + }, + { + "cohort": "TP53 wt", + "eventType": "Surgery", + "variants": [ + "Surgery" + ], + "isInterval": false, + "points": [ + { + "t": -12, + "atRisk": 2781, + "n": 105, + "pct": 3.8 + }, + { + "t": -9, + "atRisk": 3088, + "n": 112, + "pct": 3.6 + }, + { + "t": -6, + "atRisk": 4019, + "n": 219, + "pct": 5.4 + }, + { + "t": -3, + "atRisk": 10608, + "n": 3584, + "pct": 33.8 + }, + { + "t": 0, + "atRisk": 11044, + "n": 3439, + "pct": 31.1 + }, + { + "t": 3, + "atRisk": 10727, + "n": 1695, + "pct": 15.8 + }, + { + "t": 6, + "atRisk": 10417, + "n": 1127, + "pct": 10.8 + }, + { + "t": 9, + "atRisk": 10054, + "n": 978, + "pct": 9.7 + }, + { + "t": 12, + "atRisk": 9629, + "n": 837, + "pct": 8.7 + }, + { + "t": 15, + "atRisk": 9230, + "n": 711, + "pct": 7.7 + }, + { + "t": 18, + "atRisk": 8779, + "n": 629, + "pct": 7.2 + }, + { + "t": 21, + "atRisk": 8393, + "n": 637, + "pct": 7.6 + }, + { + "t": 24, + "atRisk": 8010, + "n": 615, + "pct": 7.7 + }, + { + "t": 27, + "atRisk": 7602, + "n": 487, + "pct": 6.4 + }, + { + "t": 30, + "atRisk": 7245, + "n": 467, + "pct": 6.4 + }, + { + "t": 33, + "atRisk": 6904, + "n": 451, + "pct": 6.5 + }, + { + "t": 36, + "atRisk": 6568, + "n": 440, + "pct": 6.7 + }, + { + "t": 39, + "atRisk": 6287, + "n": 372, + "pct": 5.9 + }, + { + "t": 42, + "atRisk": 5995, + "n": 363, + "pct": 6.1 + }, + { + "t": 45, + "atRisk": 5696, + "n": 368, + "pct": 6.5 + }, + { + "…": "5 more", + "sha256": "8b83331b53b62db9" + } + ] + } + ], + "courseAxis": { + "binMonths": 3, + "from": -12, + "to": 60 + }, + "eventOptions": [ + { + "canonical": "sample acquisition", + "label": "Sample acquisition", + "patients": 13105, + "perPatient": 1, + "hasDurations": false + }, + { + "canonical": "sequencing", + "label": "Sequencing", + "patients": 13105, + "perPatient": 1, + "hasDurations": false + }, + { + "canonical": "diagnosis", + "label": "Diagnosis", + "patients": 13104, + "perPatient": 60.8, + "hasDurations": false + }, + { + "canonical": "treatment", + "label": "Treatment", + "patients": 12738, + "perPatient": 7.7, + "hasDurations": true + }, + { + "canonical": "surgery", + "label": "Surgery", + "patients": 11249, + "perPatient": 3.5, + "hasDurations": false + }, + { + "canonical": "lab_test", + "label": "Lab_Test", + "patients": 8996, + "perPatient": 24.8, + "hasDurations": false + }, + { + "canonical": "pathology", + "label": "Pathology", + "patients": 6687, + "perPatient": 1.3, + "hasDurations": false + } + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Aligned on first Treatment — time 0 is that event, so every patient is lined up on the same clinical landmark. Patients with no such event are absent from every bin. THE DENOMINATOR IS NOT THE WHOLE COHORT: each bin is over the patients still under observation in it, from their first recorded event to their last contact (the later of their last recorded event and their OS follow-up where the study declares one). Without that, a curve would fall simply because follow-up ran out. Follow-up ending at the last recorded event biases the tail upward — by construction a patient has an event on their last observed day. Bins are half-open [t, t+3mo). The figure stops each line where fewer than 10 patients remain observable; the numbers past that point are in the result but not drawn. Event types carrying real durations are drawn as a state the patient is IN during the bin; the rest as an event that HAPPENED in it. That is read off the data, not the event's name.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients per time bin", + "detail": "The timelineSpan and eventCourse queries above. Per 3-month bin: the cohort's patients observable in it, and of those the ones in each event's state (or with the event in it). Counts only.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105 + }, + { + "kind": "fetch", + "title": "Count patients per time bin", + "detail": "The timelineSpan and eventCourse queries above. Per 3-month bin: the cohort's patients observable in it, and of those the ones in each event's state (or with the event in it). Counts only.", + "scope": "TP53 wt · msk_chord_2024", + "rowsIn": 11594 + }, + { + "kind": "transform", + "title": "Match event types", + "detail": "Event types, keys and values match ignoring case and surrounding whitespace; nothing else is merged.", + "params": [ + [ + "Treatment", + "has durations: a state the patient is in during a bin" + ], + [ + "Surgery", + "no durations: an event that happened in a bin" + ] + ] + }, + { + "kind": "transform", + "title": "Align on first Treatment", + "detail": "Day 0 is each patient's first Treatment; a patient without one is in no bin. A patient is observable from their first recorded event to their last contact — the later of their last recorded event and their OS follow-up (OS_MONTHS × 30.4375 days, assuming it starts at the timeline's day 0).", + "params": [ + [ + "TP53 mut", + "13,105 in the cohort → 12,738 with the anchor event → 12,738 observable in the window" + ], + [ + "TP53 wt", + "11,594 in the cohort → 11,044 with the anchor event → 11,044 observable in the window" + ] + ] + }, + { + "kind": "statistic", + "title": "Share per bin", + "detail": "For each bin from month -12 to 63 (half-open [t, t+3)): patients in the state ÷ patients observable, as a percentage. The figure stops each line where fewer than 10 patients remain observable." + } + ], + "implementation": { + "functions": [], + "file": "lib/views/course.ts", + "commit": null + }, + "check": { + "course:TP53 mut:Treatment:-4:pct": { + "v": 0, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:-4:at_risk": { + "v": 2411, + "abs": 0 + }, + "course:TP53 mut:Treatment:-3:pct": { + "v": 0, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:-3:at_risk": { + "v": 2757, + "abs": 0 + }, + "course:TP53 mut:Treatment:-2:pct": { + "v": 0, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:-2:at_risk": { + "v": 3527, + "abs": 0 + }, + "course:TP53 mut:Treatment:-1:pct": { + "v": 0, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:-1:at_risk": { + "v": 12392, + "abs": 0 + }, + "course:TP53 mut:Treatment:0:pct": { + "v": 100, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:0:at_risk": { + "v": 12738, + "abs": 0 + }, + "course:TP53 mut:Treatment:1:pct": { + "v": 76.6, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:1:at_risk": { + "v": 12222, + "abs": 0 + }, + "course:TP53 mut:Treatment:2:pct": { + "v": 61.4, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:2:at_risk": { + "v": 11605, + "abs": 0 + }, + "course:TP53 mut:Treatment:3:pct": { + "v": 53.1, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:3:at_risk": { + "v": 10910, + "abs": 0 + }, + "course:TP53 mut:Treatment:4:pct": { + "v": 51, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:4:at_risk": { + "v": 10100, + "abs": 0 + }, + "course:TP53 mut:Treatment:5:pct": { + "v": 49, + "abs": 0.050000001 + }, + "course:TP53 mut:Treatment:5:at_risk": { + "v": 9355, + "abs": 0 + }, + "…": { + "more": 180, + "sha256": "504ee14ebe1d1b66" + } + } + } + } + ] +} diff --git a/test/snapshots/course.sql b/test/snapshots/course.sql new file mode 100644 index 0000000..84a7d60 --- /dev/null +++ b/test/snapshots/course.sql @@ -0,0 +1,187 @@ +-- cohort TP53 mut +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort TP53 wt +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))) + +-- view 0 course: eventCourse:@Treatment/3mo · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + GROUP BY pid +), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) * 30.4375 AS os_day + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' + AND attribute_name = 'OS_MONTHS' + GROUP BY pid +), +span AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS entry, + max(coalesce(ce.stop_date, ce.start_date)) AS last_ev + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +obs AS ( + SELECT sp.pid AS pid, toFloat64(sp.entry) AS entry, + greatest(toFloat64(sp.last_ev), coalesce(os.os_day, toFloat64(sp.last_ev))) AS last_day + FROM span sp LEFT JOIN os ON os.pid = sp.pid +), +denom AS ( + SELECT arrayJoin(range( + toInt32(greatest(floor((o.entry - a.day) / 91.3125), -4)), + toInt32(least(floor((o.last_day - a.day) / 91.3125), 20)) + 1)) AS bin, o.pid AS pid, '' AS et + FROM obs o JOIN anch a ON a.pid = o.pid +), +numer AS ( + SELECT arrayJoin(range( + toInt32(greatest(floor((ce.start_date - a.day) / 91.3125), -4)), + toInt32(least(floor((coalesce(ce.stop_date, ce.start_date) - a.day) / 91.3125), 20)) + 1)) AS bin, + p.stable_id AS pid, lowerUTF8(trimBoth(ce.event_type)) AS et + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN anch a ON a.pid = p.stable_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + AND lowerUTF8(trimBoth(ce.event_type)) IN (lowerUTF8(trimBoth('treatment')), lowerUTF8(trimBoth('surgery'))) +) +SELECT bin, et, n FROM ( + SELECT toInt32(bin) AS bin, et, uniqExact(pid) AS n + FROM (SELECT bin, pid, et FROM denom UNION ALL SELECT bin, pid, et FROM numer) + GROUP BY bin, et + UNION ALL SELECT toInt32(0) AS bin, '#anchored' AS et, uniqExact(pid) AS n FROM anch + UNION ALL SELECT toInt32(0) AS bin, '#observed' AS et, uniqExact(pid) AS n FROM denom +) ORDER BY bin, et + +-- view 0 course: eventCourse:@Treatment/3mo · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + GROUP BY pid +), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) * 30.4375 AS os_day + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' + AND attribute_name = 'OS_MONTHS' + GROUP BY pid +), +span AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS entry, + max(coalesce(ce.stop_date, ce.start_date)) AS last_ev + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +obs AS ( + SELECT sp.pid AS pid, toFloat64(sp.entry) AS entry, + greatest(toFloat64(sp.last_ev), coalesce(os.os_day, toFloat64(sp.last_ev))) AS last_day + FROM span sp LEFT JOIN os ON os.pid = sp.pid +), +denom AS ( + SELECT arrayJoin(range( + toInt32(greatest(floor((o.entry - a.day) / 91.3125), -4)), + toInt32(least(floor((o.last_day - a.day) / 91.3125), 20)) + 1)) AS bin, o.pid AS pid, '' AS et + FROM obs o JOIN anch a ON a.pid = o.pid +), +numer AS ( + SELECT arrayJoin(range( + toInt32(greatest(floor((ce.start_date - a.day) / 91.3125), -4)), + toInt32(least(floor((coalesce(ce.stop_date, ce.start_date) - a.day) / 91.3125), 20)) + 1)) AS bin, + p.stable_id AS pid, lowerUTF8(trimBoth(ce.event_type)) AS et + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN anch a ON a.pid = p.stable_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + AND lowerUTF8(trimBoth(ce.event_type)) IN (lowerUTF8(trimBoth('treatment')), lowerUTF8(trimBoth('surgery'))) +) +SELECT bin, et, n FROM ( + SELECT toInt32(bin) AS bin, et, uniqExact(pid) AS n + FROM (SELECT bin, pid, et FROM denom UNION ALL SELECT bin, pid, et FROM numer) + GROUP BY bin, et + UNION ALL SELECT toInt32(0) AS bin, '#anchored' AS et, uniqExact(pid) AS n FROM anch + UNION ALL SELECT toInt32(0) AS bin, '#observed' AS et, uniqExact(pid) AS n FROM denom +) ORDER BY bin, et + +-- view 0 course: timelineSpan · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))) +SELECT ce.event_type AS et, + uniqExact(p.stable_id) AS pts, + count() AS events, + uniqExact(ce.start_date) AS days, + min(ce.start_date) AS first_day, + max(ce.start_date) AS last_day, + countIf(ce.stop_date IS NOT NULL AND ce.stop_date != ce.start_date) AS interval_events +FROM snapshot_db.clinical_event ce +JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id +JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id +WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) +GROUP BY et ORDER BY pts DESC diff --git a/test/snapshots/course.svg b/test/snapshots/course.svg new file mode 100644 index 0000000..4759381 --- /dev/null +++ b/test/snapshots/course.svg @@ -0,0 +1,2 @@ + +Clinical course — Treatment, Surgery — TP53 mut, TP53 wtTreatment — % in this state0%50%100%Surgery — % with an event0%50%100%−1201224364860Months from the anchor eventpatients still observable2,41112,73810,1007,3925,3644,0052,8872,78111,0449,6298,0106,5685,3724,205TP53 mutTP53 wtAligned on first Treatment — time 0 is that event, so every patient is lined up on the same clinical landmark. Patients with no such event are absent fromevery bin. THE DENOMINATOR IS NOT THE WHOLE COHORT: each bin is over the patients still under observation in it, from their first recorded event to theirlast contact (the later of their last recorded event and their OS follow-up where the study declares one). Without that, a curve would fall simply becausefollow-up ran out. Follow-up ending at the last recorded event biases the tail upward — by construction a patient has an event on their last observed day.Bins are half-open [t, t+3mo). The figure stops each line where fewer than 10 patients remain observable; the numbers past that point are in the result butnot drawn. Event types carrying real durations are drawn as a state the patient is IN during the bin; the rest as an event that HAPPENED in it. That is read offthe data, not the event's name. diff --git a/test/snapshots/course.txt b/test/snapshots/course.txt new file mode 100644 index 0000000..67f6406 --- /dev/null +++ b/test/snapshots/course.txt @@ -0,0 +1,22 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- TP53 mut: 13,105 patients — OQL[TP53: MUT] +- TP53 wt: 11,594 patients — NOT OQL[TP53:] AND profiled for TP53 MUTATION + +Clinical course (3-month bins, -12 to +60mo relative to the anchor; DENOMINATOR IS THE PATIENTS STILL OBSERVABLE IN EACH BIN, not the cohort): + TP53 mut / Treatment [a state patients are IN]: 0mo 100% (n=12,738), 12mo 51% (n=10,100), 24mo 45.5% (n=7,392), 60mo 39.7% (n=2,887) + TP53 mut / Surgery [an event that HAPPENED]: 0mo 29.2% (n=12,738), 12mo 13.7% (n=10,100), 24mo 11.1% (n=7,392), 60mo 8.1% (n=2,887) + TP53 wt / Treatment [a state patients are IN]: 0mo 100% (n=11,044), 12mo 53.5% (n=9,629), 24mo 49.5% (n=8,010), 60mo 49.8% (n=4,205) + TP53 wt / Surgery [an event that HAPPENED]: 0mo 31.1% (n=11,044), 12mo 8.7% (n=9,629), 24mo 7.7% (n=8,010), 60mo 6.5% (n=4,205) + CAVEAT (tell the user): Aligned on first Treatment — time 0 is that event, so every patient is lined up on the same clinical landmark. Patients with no such event are absent from every bin. THE DENOMINATOR IS NOT THE WHOLE COHORT: each bin is over the patients still under observation in it, from their first recorded event to their last contact (the later of their last recorded event and their OS follow-up where the study declares one). Without that, a curve would fall simply because follow-up ran out. Follow-up ending at the last recorded event biases the tail upward — by construction a patient has an event on their last observed day. Bins are half-open [t, t+3mo). The figure stops each line where fewer than 10 patients remain observable; the numbers past that point are in the result but not drawn. Event types carrying real durations are drawn as a state the patient is IN during the bin; the rest as an event that HAPPENED in it. That is read off the data, not the event's name. + METHOD: + - Count patients per time bin [TP53 mut · msk_chord_2024]: The timelineSpan and eventCourse queries above. Per 3-month bin: the cohort's patients observable in it, and of those the ones in each event's state (or with the event in it). Counts only. + - Count patients per time bin [TP53 wt · msk_chord_2024]: The timelineSpan and eventCourse queries above. Per 3-month bin: the cohort's patients observable in it, and of those the ones in each event's state (or with the event in it). Counts only. + - Match event types: Event types, keys and values match ignoring case and surrounding whitespace; nothing else is merged. + Treatment: has durations: a state the patient is in during a bin + Surgery: no durations: an event that happened in a bin + - Align on first Treatment: Day 0 is each patient's first Treatment; a patient without one is in no bin. A patient is observable from their first recorded event to their last contact — the later of their last recorded event and their OS follow-up (OS_MONTHS × 30.4375 days, assuming it starts at the timeline's day 0). + TP53 mut: 13,105 in the cohort → 12,738 with the anchor event → 12,738 observable in the window + TP53 wt: 11,594 in the cohort → 11,044 with the anchor event → 11,044 observable in the window + - Share per bin: For each bin from month -12 to 63 (half-open [t, t+3)): patients in the state ÷ patients observable, as a percentage. The figure stops each line where fewer than 10 patients remain observable. diff --git a/test/snapshots/cox.json b/test/snapshots/cox.json new file mode 100644 index 0000000..511b3ab --- /dev/null +++ b/test/snapshots/cox.json @@ -0,0 +1,138 @@ +{ + "study": "crc_apc_impact_2020", + "cohorts": { + "all patients": { + "count": 471, + "text": "all patients in the study", + "studies": [ + "crc_apc_impact_2020" + ] + } + }, + "views": [ + { + "kind": "cox", + "cohorts": [ + "all patients" + ], + "endpoint": "OS", + "cox": { + "coefficients": [ + { + "label": "TP53/KRAS/PIK3CA (any) mutation status: Mutated", + "reference": "Not mutated", + "level": "Mutated", + "axisIndex": 0, + "beta": -0.3285283537241268, + "se": 0.21751119615856146, + "hr": 0.7199825137508375, + "ciLow": 0.47008466395358267, + "ciHigh": 1.1027265083426774, + "p": 0.1309420416160914 + } + ], + "n": 471, + "events": 311 + }, + "participation": { + "studies": [ + { + "study": "crc_apc_impact_2020", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Cox proportional-hazards regression (Efron ties) on 471 patients, 311 events, 1 term. Computed from real per-patient rows within each local study — not pooled aggregate counts across untrusted remote peers, unlike KM/log-rank.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Fetch one row per patient", + "detail": "The coxRows:OS query above. Patients with a OS_MONTHS value and a value for every covariate are kept. Event: OS_STATUS starting with “1” (e.g. “1:DECEASED”); any other value, including a missing one, is censored. Every cohort patient had a row.", + "scope": "crc_apc_impact_2020", + "rowsIn": 471, + "rowsOut": 471 + }, + { + "kind": "transform", + "title": "Code the covariates", + "detail": "Each numeric covariate is one term. Each categorical covariate becomes one 0/1 term per level, measured against a reference level that gets no term.", + "params": [ + [ + "TP53/KRAS/PIK3CA (any) mutation status: Mutated", + "1 if c0 = “Mutated”, else 0 · 440 of 471 patients · reference “Not mutated”: the fixed default for a mutated-vs-not axis" + ] + ] + }, + { + "kind": "statistic", + "title": "Fit a Cox proportional-hazards model", + "detail": "Maximum partial likelihood with Efron's method for tied event times, by Newton–Raphson with step-halving.", + "params": [ + [ + "patients / events", + "471 / 311" + ], + [ + "terms", + "1" + ], + [ + "baseline hazard", + "one, shared by every patient" + ], + [ + "standard errors", + "from the observed information at the estimate" + ], + [ + "95% interval", + "exp(β ± 1.959964·SE), Wald" + ], + [ + "p-value", + "Wald χ² on 1 df, (β/SE)²" + ], + [ + "fit", + "converged in 5 iterations" + ], + [ + "log partial likelihood", + "-1635.6078" + ] + ] + } + ], + "implementation": { + "functions": [ + "coxRegression" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Matches lifelines 0.30.3 CoxPHFitter (Efron ties) to a relative 1e-6 on coefficients, SEs, p-values and intervals (test/regression-golden.test.ts).", + "check": { + "cox::TP53/KRAS/PIK3CA (any) mutation status: Mutated:beta": { + "v": -0.3285283537241268, + "rel": 0.0001, + "abs": 0.000001 + }, + "cox::TP53/KRAS/PIK3CA (any) mutation status: Mutated:se": { + "v": 0.21751119615856146, + "rel": 0.0001 + }, + "cox::TP53/KRAS/PIK3CA (any) mutation status: Mutated:p": { + "v": 0.1309420416160914, + "rel": 0.001, + "abs": 1e-12 + } + } + } + } + ] +} diff --git a/test/snapshots/cox.sql b/test/snapshots/cox.sql new file mode 100644 index 0000000..e80dc7b --- /dev/null +++ b/test/snapshots/cox.sql @@ -0,0 +1,100 @@ +-- cohort all patients +-- crc_apc_impact_2020 +SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' + +-- view 0 cox: coxNotProfiled:OS · crc_apc_impact_2020 +SELECT countIf(c0 = 'Not profiled') AS n FROM ( +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020'), +os AS ( + SELECT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +c0 AS ( +SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))) AND alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'KRAS')))) AND alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'PIK3CA'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS alt_case, if(countIf(g.variant_type = 'mutation') > 0, 'Mutated', 'Not mutated') AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND hugo_gene_symbol IN ('TP53','KRAS','PIK3CA') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'crc_apc_impact_2020' AND replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case) +) +SELECT os.months AS m, if(os.status LIKE '1%', 1, 0) AS ev, c0.v AS c0 +FROM os + INNER JOIN c0 ON c0.id = os.pid +WHERE os.months IS NOT NULL +) + +-- view 0 cox: coxRows:OS · crc_apc_impact_2020 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020'), +os AS ( + SELECT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +c0 AS ( +SELECT id, v FROM ( +SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))) AND alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'KRAS')))) AND alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'PIK3CA'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS alt_case, if(countIf(g.variant_type = 'mutation') > 0, 'Mutated', 'Not mutated') AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND hugo_gene_symbol IN ('TP53','KRAS','PIK3CA') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'crc_apc_impact_2020' AND replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case) +) WHERE v != 'Not profiled' +) +SELECT os.months AS m, if(os.status LIKE '1%', 1, 0) AS ev, c0.v AS c0 +FROM os + INNER JOIN c0 ON c0.id = os.pid +WHERE os.months IS NOT NULL diff --git a/test/snapshots/cox.svg b/test/snapshots/cox.svg new file mode 100644 index 0000000..c45d80b --- /dev/null +++ b/test/snapshots/cox.svg @@ -0,0 +1,2 @@ + +Cox regression — hazard ratiosHR [95% CI]pTP53/KRAS/PIK3CA (any) mutation status: Mutated vs Not mutatedTP53/KRAS/PIK3CA (any) mutation status: Mutate…0.72 [0.47–1.10]0.13HR = 10.60.811.2HR (log scale) — left of 1 is lower, right is higherCox proportional-hazards regression (Efron ties) on 471 patients, 311 events, 1 term. Computed from real per-patient rows within each local study — not pooledaggregate counts across untrusted remote peers, unlike KM/log-rank. diff --git a/test/snapshots/cox.txt b/test/snapshots/cox.txt new file mode 100644 index 0000000..be0dd21 --- /dev/null +++ b/test/snapshots/cox.txt @@ -0,0 +1,22 @@ +Analysis over crc_apc_impact_2020 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- all patients: 471 patients — all patients in the study + +Cox regression (OS, n=471, 311 events): + TP53/KRAS/PIK3CA (any) mutation status: Mutated vs Not mutated: HR 0.72 (95% CI 0.47-1.10) p=0.1309 + CAVEAT (tell the user): Cox proportional-hazards regression (Efron ties) on 471 patients, 311 events, 1 term. Computed from real per-patient rows within each local study — not pooled aggregate counts across untrusted remote peers, unlike KM/log-rank. + METHOD: + - Fetch one row per patient [crc_apc_impact_2020] (471 → 471 rows): The coxRows:OS query above. Patients with a OS_MONTHS value and a value for every covariate are kept. Event: OS_STATUS starting with “1” (e.g. “1:DECEASED”); any other value, including a missing one, is censored. Every cohort patient had a row. + - Code the covariates: Each numeric covariate is one term. Each categorical covariate becomes one 0/1 term per level, measured against a reference level that gets no term. + TP53/KRAS/PIK3CA (any) mutation status: Mutated: 1 if c0 = “Mutated”, else 0 · 440 of 471 patients · reference “Not mutated”: the fixed default for a mutated-vs-not axis + - Fit a Cox proportional-hazards model: Maximum partial likelihood with Efron's method for tied event times, by Newton–Raphson with step-halving. + patients / events: 471 / 311 + terms: 1 + baseline hazard: one, shared by every patient + standard errors: from the observed information at the estimate + 95% interval: exp(β ± 1.959964·SE), Wald + p-value: Wald χ² on 1 df, (β/SE)² + fit: converged in 5 iterations + log partial likelihood: -1635.6078 + Matches lifelines 0.30.3 CoxPHFitter (Efron ties) to a relative 1e-6 on coefficients, SEs, p-values and intervals (test/regression-golden.test.ts). diff --git a/test/snapshots/diffexpr.json b/test/snapshots/diffexpr.json new file mode 100644 index 0000000..aaf97a5 --- /dev/null +++ b/test/snapshots/diffexpr.json @@ -0,0 +1,2865 @@ +{ + "study": "brca_tcga_pan_can_atlas_2018", + "cohorts": { + "Basal-like": { + "count": 171, + "text": "SUBTYPE in [BRCA_Basal]", + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ] + }, + "Luminal A": { + "count": 499, + "text": "SUBTYPE in [BRCA_LumA]", + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ] + } + }, + "views": [ + { + "kind": "diffexpr", + "cohorts": [ + "Basal-like", + "Luminal A" + ], + "diffexpr": { + "profileType": "rna_seq_v2_mrna_median_all_sample_Zscores", + "log2": false, + "effectLabel": "difference in mean z-score", + "groups": [ + "Basal-like", + "Luminal A" + ], + "tested": 20006, + "skipped": 14, + "up": 7563, + "down": 7698, + "points": [ + { + "gene": "TTC36", + "nA": 171, + "nB": 499, + "meanA": -1.7445479532163746, + "meanB": 0.40476012024048125, + "effect": -2.1493080734568557, + "t": -50.37553199579407, + "p": 8.091447449946383e-220, + "q": 1.6187749768362735e-215 + }, + { + "gene": "FSIP1", + "nA": 171, + "nB": 499, + "meanA": -1.5407900584795324, + "meanB": 0.4491647294589174, + "effect": -1.9899547879384498, + "t": -49.8817137530346, + "p": 2.3035779855199614e-204, + "q": 2.3042690589156173e-200 + }, + { + "gene": "SRARP", + "nA": 171, + "nB": 499, + "meanA": -2.0564456140350877, + "meanB": 0.3802805611222444, + "effect": -2.4367261751573324, + "t": -52.58970630846896, + "p": 2.5912634421936607e-200, + "q": 1.7280272141508793e-196 + }, + { + "gene": "DRAIC", + "nA": 171, + "nB": 499, + "meanA": -1.702163742690057, + "meanB": 0.3915296593186371, + "effect": -2.0936934020086944, + "t": -49.2851470509609, + "p": 5.510248672884023e-190, + "q": 2.755950873742944e-186 + }, + { + "gene": "NAT1", + "nA": 171, + "nB": 499, + "meanA": -1.3843912280701764, + "meanB": 0.5428809619238478, + "effect": -1.9272721899940244, + "t": -44.23467399694273, + "p": 2.7043279892748184e-182, + "q": 1.0820557150686404e-178 + }, + { + "gene": "MAPT-IT1", + "nA": 171, + "nB": 499, + "meanA": -1.6838713450292397, + "meanB": 0.20232264529058128, + "effect": -1.886193990319821, + "t": -39.81370583703942, + "p": 2.0129532020700296e-175, + "q": 6.711856960102169e-172 + }, + { + "gene": "CT62", + "nA": 171, + "nB": 499, + "meanA": -2.0318602339181275, + "meanB": 0.41401743486973996, + "effect": -2.4458776687878676, + "t": -49.396461591675944, + "p": 6.399560110459782e-157, + "q": 1.8289942795694058e-153 + }, + { + "gene": "SLC7A13", + "nA": 171, + "nB": 499, + "meanA": -1.9130122807017553, + "meanB": 0.004921242484969956, + "effect": -1.9179335231867254, + "t": -35.5911269176747, + "p": 3.892473730008788e-156, + "q": 9.734103680319477e-153 + }, + { + "gene": "CYP2B7P", + "nA": 171, + "nB": 499, + "meanA": -1.3962970760233921, + "meanB": 0.3789587174348692, + "effect": -1.7752557934582613, + "t": -37.209164655790794, + "p": 6.3502571936527e-150, + "q": 1.4115916157357323e-146 + }, + { + "gene": "TFF1", + "nA": 171, + "nB": 499, + "meanA": -1.8730280701754394, + "meanB": 0.3680098196392785, + "effect": -2.241037889814718, + "t": -43.07647717317015, + "p": 5.061562842349789e-149, + "q": 1.0126162622404987e-145 + }, + { + "gene": "NEK10", + "nA": 171, + "nB": 499, + "meanA": -1.2707538011695902, + "meanB": 0.5132166332665333, + "effect": -1.7839704344361236, + "t": -36.314048270969685, + "p": 8.116747273958295e-147, + "q": 1.4762149632982698e-143 + }, + { + "gene": "ABCC8", + "nA": 171, + "nB": 499, + "meanA": -1.9394450292397651, + "meanB": 0.3299863727454911, + "effect": -2.269431401985256, + "t": -40.45792875224126, + "p": 5.8722761644845026e-145, + "q": 9.790063078889746e-142 + }, + { + "gene": "MAPT-AS1", + "nA": 171, + "nB": 499, + "meanA": -1.6475619883040897, + "meanB": 0.08925931863727461, + "effect": -1.7368213069413643, + "t": -34.46869324253705, + "p": 2.7982416787569205e-144, + "q": 4.3062786942469967e-141 + }, + { + "gene": "ANKRD30A", + "nA": 171, + "nB": 499, + "meanA": -1.9812163742690037, + "meanB": 0.27829458917835675, + "effect": -2.2595109634473602, + "t": -39.37280226605274, + "p": 5.063304961997455e-144, + "q": 7.235462790694364e-141 + }, + { + "gene": "BCL11A", + "nA": 171, + "nB": 499, + "meanA": 1.4358286549707602, + "meanB": -0.2880046092184371, + "effect": 1.7238332641891974, + "t": 37.17100854249844, + "p": 2.016245097781077e-142, + "q": 2.6891332950805486e-139 + }, + { + "gene": "TPSG1", + "nA": 171, + "nB": 499, + "meanA": -1.373862573099413, + "meanB": 0.22565631262525054, + "effect": -1.5995188857246636, + "t": -33.611016475882394, + "p": 1.644677554818099e-141, + "q": 2.0564636976056803e-138 + }, + { + "gene": "PGR", + "nA": 171, + "nB": 499, + "meanA": -1.2939280701754385, + "meanB": 0.5647364729458908, + "effect": -1.8586645431213293, + "t": -38.20350861907161, + "p": 1.2738662408655656e-139, + "q": 1.499115765573912e-136 + }, + { + "gene": "CDCA7", + "nA": 171, + "nB": 499, + "meanA": 1.3095035087719302, + "meanB": -0.5064813627254511, + "effect": 1.8159848714973812, + "t": 37.3944937933237, + "p": 1.9378342114067875e-139, + "q": 2.1537950685224553e-136 + }, + { + "gene": "SERPINA11", + "nA": 171, + "nB": 499, + "meanA": -1.614418713450292, + "meanB": 0.43775290581162296, + "effect": -2.052171619261915, + "t": -37.83308873804711, + "p": 6.464638024473876e-138, + "q": 6.80692359566444e-135 + }, + { + "gene": "SLC39A6", + "nA": 171, + "nB": 499, + "meanA": -1.2425690058479535, + "meanB": 0.4289593186372745, + "effect": -1.671528324485228, + "t": -34.674209417030276, + "p": 2.069234735993648e-137, + "q": 2.069855506414446e-134 + }, + { + "…": "1480 more", + "sha256": "522f517d2b7aef2f" + } + ], + "grid": { + "xMax": 5, + "yMax": 250, + "nx": 90, + "ny": 60, + "cells": [ + [ + 46, + 0, + 410, + 1 + ], + [ + 49, + 2, + 108, + 1 + ], + [ + 39, + 1, + 101, + 2 + ], + [ + 50, + 3, + 59, + 1 + ], + [ + 36, + 7, + 39, + 2 + ], + [ + 43, + 0, + 721, + 0 + ], + [ + 45, + 0, + 1647, + 0 + ], + [ + 42, + 1, + 76, + 2 + ], + [ + 44, + 0, + 1549, + 0 + ], + [ + 51, + 4, + 52, + 1 + ], + [ + 54, + 3, + 21, + 1 + ], + [ + 35, + 5, + 100, + 2 + ], + [ + 51, + 2, + 290, + 1 + ], + [ + 44, + 0, + 102, + 2 + ], + [ + 40, + 1, + 635, + 2 + ], + [ + 42, + 0, + 915, + 2 + ], + [ + 57, + 5, + 2, + 1 + ], + [ + 36, + 5, + 210, + 2 + ], + [ + 37, + 4, + 263, + 2 + ], + [ + 37, + 6, + 34, + 2 + ], + { + "…": "148 more", + "sha256": "c1318f02f3b7bf13" + } + ] + }, + "pooledSignificant": 13761, + "labels": [ + "BCL11A", + "CDCA7", + "CDC20", + "KIF2C", + "CENPA", + "AURKB", + "TTC36", + "FSIP1", + "SRARP", + "DRAIC", + "NAT1", + "MAPT-IT1" + ], + "gsea": { + "ranking": "Welch t, Basal-like over Luminal A", + "permutations": 1000, + "sets": [ + { + "name": "HALLMARK_E2F_TARGETS", + "size": 200, + "setSize": 200, + "es": 0.7803, + "nes": 3.675, + "p": 0.0031645569620253164, + "leadingEdge": [ + "CDC20", + "CDCA8", + "KIF2C", + "AURKB", + "ORC6", + "CCNE1", + "PLK1", + "CTPS1", + "CDC25A", + "MELK", + "CCNB2", + "BIRC5", + "KIF18B", + "MYBL2", + "DEPDC1", + "DSCC1", + "CDCA3", + "DLGAP5", + "CHEK1", + "AURKA", + { + "…": "112 more", + "sha256": "b7cf5372acfab25b" + } + ], + "curve": [ + -0.0001, + 0.2222, + 0.3849, + 0.4663, + 0.5277, + 0.5731, + 0.6036, + 0.6494, + 0.6606, + 0.6869, + 0.6918, + 0.7154, + 0.7195, + 0.7278, + 0.7399, + 0.7475, + 0.7505, + 0.7613, + 0.7755, + 0.7742, + { + "…": "182 more", + "sha256": "10ba3324c9c9ccdd" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 4, + 7, + 8, + 10, + 12, + 13, + 15, + 16, + 25, + 27, + 32, + 39, + 40, + 42, + 46, + 48, + 53, + 63, + 65, + 72, + { + "…": "180 more", + "sha256": "299ed812a349463b" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_G2M_CHECKPOINT", + "size": 200, + "setSize": 200, + "es": 0.7321, + "nes": 3.421, + "p": 0.003205128205128205, + "leadingEdge": [ + "CDC20", + "CENPA", + "KIF2C", + "AURKB", + "ORC6", + "TTK", + "PLK1", + "TPX2", + "CDC25A", + "RAD54L", + "CCNB2", + "NDC80", + "BIRC5", + "MYBL2", + "CDC45", + "CCNA2", + "BUB1", + "EXO1", + "UBE2C", + "CHEK1", + { + "…": "99 more", + "sha256": "b04f538654e90e41" + } + ], + "curve": [ + -0.0001, + 0.2401, + 0.458, + 0.505, + 0.541, + 0.5947, + 0.6142, + 0.644, + 0.6501, + 0.6503, + 0.6506, + 0.6653, + 0.6794, + 0.6837, + 0.7008, + 0.7088, + 0.712, + 0.7192, + 0.7181, + 0.7169, + { + "…": "182 more", + "sha256": "c0ddd1ffef274287" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 4, + 6, + 8, + 10, + 12, + 14, + 15, + 20, + 25, + 29, + 32, + 33, + 39, + 42, + 43, + 47, + 50, + 61, + 64, + 65, + { + "…": "180 more", + "sha256": "a4a35f5c8f6adf03" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_MYC_TARGETS_V1", + "size": 200, + "setSize": 200, + "es": 0.6842, + "nes": 3.232, + "p": 0.003278688524590164, + "leadingEdge": [ + "CDC20", + "CTPS1", + "IFRD1", + "CDC45", + "CCNA2", + "SRPK1", + "MCM7", + "KPNA2", + "ODC1", + "PSMB2", + "MAD2L1", + "MCM2", + "MCM6", + "RFC4", + "KARS1", + "RANBP1", + "HDGF", + "DEK", + "SERBP1", + "MCM5", + { + "…": "111 more", + "sha256": "b23accc731fbda9c" + } + ], + "curve": [ + -0.0001, + 0.0748, + 0.1636, + 0.2557, + 0.3105, + 0.3335, + 0.3464, + 0.3833, + 0.4101, + 0.4436, + 0.4905, + 0.4854, + 0.4941, + 0.4957, + 0.5226, + 0.5488, + 0.5559, + 0.5685, + 0.5749, + 0.5811, + { + "…": "182 more", + "sha256": "afa0a160038d6f75" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 4, + 16, + 30, + 43, + 47, + 115, + 125, + 129, + 154, + 187, + 192, + 193, + 196, + 210, + 213, + 220, + 224, + 234, + 246, + 266, + { + "…": "180 more", + "sha256": "bdea484191da156f" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_ESTROGEN_RESPONSE_EARLY", + "size": 199, + "setSize": 200, + "es": -0.6317, + "nes": -2.758, + "p": 0.0014705882352941176, + "leadingEdge": [ + "P2RY2", + "CCN5", + "CXCL12", + "MSMB", + "BLVRB", + "OLFM1", + "OLFML3", + "DYNLT3", + "ASB13", + "NPY1R", + "KRT8", + "FLNB", + "AREG", + "ELF1", + "HSPB8", + "CELSR2", + "DEPTOR", + "GJA1", + "PLAAT3", + "MYOF", + { + "…": "79 more", + "sha256": "381a2d53f265302d" + } + ], + "curve": [ + 0.0146, + 0.0298, + 0.0248, + 0.0198, + 0.0147, + 0.0165, + 0.0249, + 0.0198, + 0.0207, + 0.0157, + 0.0106, + 0.0056, + 0.0005, + -0.0045, + -0.0096, + -0.0053, + -0.0103, + -0.0109, + -0.0116, + -0.0125, + { + "…": "182 more", + "sha256": "6a046271fab4d682" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 0, + 73, + 76, + 478, + 503, + 554, + 789, + 1410, + 1470, + 1601, + 1755, + 1860, + 1915, + 1977, + 2072, + 2081, + 2221, + 2231, + 2472, + 2612, + { + "…": "179 more", + "sha256": "a2143eba34074d27" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_MYC_TARGETS_V2", + "size": 58, + "setSize": 58, + "es": 0.6825, + "nes": 2.611, + "p": 0.0025188916876574307, + "leadingEdge": [ + "PLK1", + "NIP7", + "MCM5", + "NDUFAF4", + "BYSL", + "MCM4", + "WDR43", + "PLK4", + "NOP2", + "MPHOSPH10", + "TCOF1", + "HSPD1", + "TBRG4", + "SUPV3L1", + "MRTO4", + "SRM", + "NOP16", + "MYC", + "PPRC1", + "DUSP2", + { + "…": "19 more", + "sha256": "994c8e9c34fe69c3" + } + ], + "curve": [ + -0.0001, + 0.0475, + 0.0425, + 0.141, + 0.1984, + 0.2229, + 0.2746, + 0.2967, + 0.3175, + 0.3373, + 0.3559, + 0.3739, + 0.3689, + 0.4065, + 0.4222, + 0.4775, + 0.4918, + 0.5247, + 0.5566, + 0.5516, + { + "…": "182 more", + "sha256": "2b38cd79ca099b9b" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 15, + 227, + 266, + 290, + 390, + 391, + 482, + 526, + 580, + 652, + 758, + 856, + 988, + 1053, + 1237, + 1241, + 1326, + 1410, + 1412, + 1496, + { + "…": "38 more", + "sha256": "7475df70e3b4fa6b" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_MTORC1_SIGNALING", + "size": 200, + "setSize": 200, + "es": 0.526, + "nes": 2.454, + "p": 0.003215434083601286, + "leadingEdge": [ + "PSAT1", + "PLK1", + "CDC25A", + "IFRD1", + "BUB1", + "AURKA", + "SLC7A5", + "PHGDH", + "ENO1", + "GMPS", + "PSMG1", + "MCM2", + "NFIL3", + "SRD5A1", + "ASNS", + "PDK1", + "MCM4", + "POLR3G", + "PNO1", + "DDX39A", + { + "…": "85 more", + "sha256": "d0ea8e0a25b09a14" + } + ], + "curve": [ + -0.0001, + 0.1133, + 0.1541, + 0.1699, + 0.194, + 0.198, + 0.2275, + 0.2468, + 0.273, + 0.3209, + 0.3592, + 0.3681, + 0.3833, + 0.3973, + 0.3922, + 0.4054, + 0.4298, + 0.4362, + 0.4534, + 0.4647, + { + "…": "182 more", + "sha256": "6fca874014f54e5c" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 1, + 15, + 25, + 30, + 50, + 72, + 76, + 82, + 121, + 151, + 166, + 193, + 222, + 287, + 306, + 341, + 391, + 469, + 508, + 520, + { + "…": "180 more", + "sha256": "2e5a265d25fc9991" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_MITOTIC_SPINDLE", + "size": 199, + "setSize": 199, + "es": 0.4858, + "nes": 2.296, + "p": 0.0031645569620253164, + "leadingEdge": [ + "KIF2C", + "TTK", + "PLK1", + "TPX2", + "CCNB2", + "NDC80", + "BIRC5", + "BUB1", + "DLGAP5", + "AURKA", + "ANLN", + "KIF4A", + "PIF1", + "NCK2", + "KIF15", + "KIF23", + "CENPF", + "CENPE", + "MID1", + "CDK1", + { + "…": "47 more", + "sha256": "12dc9096b7419cc8" + } + ], + "curve": [ + -0.0001, + 0.1801, + 0.2677, + 0.3112, + 0.3279, + 0.3757, + 0.3802, + 0.4031, + 0.4069, + 0.4105, + 0.4055, + 0.4004, + 0.3954, + 0.3903, + 0.3853, + 0.3871, + 0.3887, + 0.3903, + 0.3916, + 0.4359, + { + "…": "182 more", + "sha256": "2e92005f5b88f246" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 8, + 14, + 15, + 20, + 32, + 33, + 39, + 50, + 63, + 72, + 79, + 105, + 108, + 146, + 150, + 159, + 177, + 199, + 209, + 219, + { + "…": "179 more", + "sha256": "f9c921ed6a7eb82a" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_ALLOGRAFT_REJECTION", + "size": 200, + "setSize": 200, + "es": 0.4851, + "nes": 2.279, + "p": 0.0031746031746031746, + "leadingEdge": [ + "RIPK2", + "IFNAR2", + "TAP2", + "HLA-DOB", + "CCL7", + "EGFR", + "LYN", + "NCK1", + "AARS1", + "EIF5A", + "MTIF2", + "CDKN2A", + "IL2RA", + "CSK", + "GZMB", + "MRPL3", + "CD47", + "CCL13", + "WARS1", + "TAP1", + { + "…": "104 more", + "sha256": "17296efd89d34d70" + } + ], + "curve": [ + -0.0001, + -0.0051, + 0.0096, + 0.0046, + -0.0005, + 0.0103, + 0.0053, + 0.0583, + 0.0809, + 0.0895, + 0.0844, + 0.0917, + 0.0867, + 0.116, + 0.122, + 0.1278, + 0.1543, + 0.1799, + 0.1748, + 0.1794, + { + "…": "182 more", + "sha256": "a2bef3070ea697c6" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 191, + 493, + 614, + 659, + 691, + 693, + 779, + 785, + 820, + 1070, + 1235, + 1246, + 1283, + 1387, + 1439, + 1519, + 1521, + 1586, + 1639, + 1650, + { + "…": "180 more", + "sha256": "eee5344360abc267" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_ESTROGEN_RESPONSE_LATE", + "size": 200, + "setSize": 200, + "es": -0.4944, + "nes": -2.162, + "p": 0.0014619883040935672, + "leadingEdge": [ + "SLC2A8", + "CALCR", + "GPER1", + "CCN5", + "DCXR", + "CXCL12", + "BATF", + "BLVRB", + "ASCL1", + "OLFM1", + "ST6GALNAC2", + "DYNLT3", + "LARGE1", + "PLAC1", + "NPY1R", + "FLNB", + "AREG", + "MOCS2", + "HSPB8", + "DLG5", + { + "…": "65 more", + "sha256": "ea997f7f6b73280a" + } + ], + "curve": [ + 0.015, + 0.0659, + 0.0799, + 0.0913, + 0.0939, + 0.0959, + 0.1113, + 0.1258, + 0.1269, + 0.1277, + 0.1284, + 0.1233, + 0.1183, + 0.1285, + 0.1235, + 0.1232, + 0.1181, + 0.1177, + 0.1171, + 0.1206, + { + "…": "182 more", + "sha256": "351f6bd6100ea548" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 0, + 4, + 73, + 75, + 76, + 89, + 103, + 142, + 243, + 268, + 375, + 478, + 526, + 554, + 563, + 617, + 618, + 631, + 789, + 896, + { + "…": "180 more", + "sha256": "01cf21f410ae0e0a" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_INTERFERON_GAMMA_RESPONSE", + "size": 200, + "setSize": 200, + "es": 0.426, + "nes": 2.004, + "p": 0.0029411764705882353, + "leadingEdge": [ + "NUP93", + "PSMB2", + "RIPK2", + "PELI1", + "PTPN2", + "PFKP", + "PIM1", + "IFNAR2", + "CCL7", + "PNP", + "PNPT1", + "NMI", + "UPP1", + "SOD2", + "MTHFD2", + "IDO1", + "PLSCR1", + "PLA2G4A", + "WARS1", + "TAP1", + { + "…": "78 more", + "sha256": "94d8b7b2f38ecbaa" + } + ], + "curve": [ + -0.0001, + 0.0165, + 0.0482, + 0.0431, + 0.0704, + 0.1109, + 0.1058, + 0.1274, + 0.1736, + 0.1812, + 0.1761, + 0.1711, + 0.166, + 0.161, + 0.1871, + 0.182, + 0.177, + 0.2097, + 0.2047, + 0.2175, + { + "…": "182 more", + "sha256": "edb8c7fbdf5b2789" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 84, + 187, + 191, + 311, + 383, + 416, + 423, + 493, + 691, + 696, + 772, + 782, + 793, + 794, + 821, + 1306, + 1339, + 1369, + 1639, + 1650, + { + "…": "180 more", + "sha256": "b37f57aafa7ec197" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_UNFOLDED_PROTEIN_RESPONSE", + "size": 113, + "setSize": 113, + "es": 0.4366, + "nes": 1.912, + "p": 0.0026954177897574125, + "leadingEdge": [ + "PSAT1", + "SLC7A5", + "CKS1B", + "CEBPB", + "DKC1", + "PDIA6", + "ASNS", + "CHAC1", + "CEBPG", + "CALR", + "MTHFD2", + "XPOT", + "EIF4EBP1", + "H2AX", + "NABP1", + "YWHAZ", + "HSP90B1", + "TARS1", + "EIF4G1", + "ATF4", + { + "…": "27 more", + "sha256": "76347f96c5f3eb76" + } + ], + "curve": [ + -0.0001, + 0.061, + 0.1292, + 0.1456, + 0.1814, + 0.1764, + 0.2065, + 0.2014, + 0.1964, + 0.207, + 0.2166, + 0.2256, + 0.2478, + 0.2822, + 0.3157, + 0.3231, + 0.3422, + 0.3372, + 0.3551, + 0.3501, + { + "…": "182 more", + "sha256": "ddc203480a32d8ee" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 1, + 76, + 106, + 126, + 163, + 261, + 306, + 332, + 552, + 566, + 821, + 999, + 1096, + 1166, + 1168, + 1221, + 1277, + 1291, + 1311, + 1316, + { + "…": "93 more", + "sha256": "9d0242af792461eb" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_GLYCOLYSIS", + "size": 200, + "setSize": 200, + "es": 0.3676, + "nes": 1.746, + "p": 0.0033444816053511705, + "leadingEdge": [ + "CENPA", + "DEPDC1", + "AURKA", + "KIF20A", + "STMN1", + "ENO1", + "DSC2", + "CDK1", + "NASP", + "PFKP", + "PLOD1", + "HMMR", + "SLC25A13", + "CHST2", + "TGFA", + "SOX9", + "RRAGD", + "TPI1", + "EGFR", + "MDH1", + { + "…": "46 more", + "sha256": "142b17c1c78c44a9" + } + ], + "curve": [ + -0.0001, + 0.0667, + 0.1071, + 0.1282, + 0.1232, + 0.1522, + 0.1893, + 0.2142, + 0.2385, + 0.2429, + 0.2561, + 0.2597, + 0.28, + 0.275, + 0.2855, + 0.2879, + 0.2975, + 0.2924, + 0.3013, + 0.303, + { + "…": "182 more", + "sha256": "cdaa1de41891b33b" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 6, + 46, + 72, + 89, + 102, + 121, + 122, + 219, + 279, + 416, + 426, + 481, + 558, + 569, + 583, + 592, + 678, + 684, + 693, + 724, + { + "…": "180 more", + "sha256": "a15990fe62c6ed0d" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_BILE_ACID_METABOLISM", + "size": 112, + "setSize": 112, + "es": -0.4191, + "nes": -1.68, + "p": 0.001519756838905775, + "leadingEdge": [ + "ALDH1A1", + "AGXT", + "RXRG", + "FDXR", + "APOA1", + "HSD17B11", + "HACL1", + "PEX1", + "TTR", + "PECR", + "CYP46A1", + "PAOX", + "ATXN1", + "HSD3B7", + "ABCA6", + "BCAR3", + "ISOC1", + "LONP2", + "DHCR24", + "SCP2", + { + "…": "28 more", + "sha256": "434eb760d313034a" + } + ], + "curve": [ + -0.0001, + -0.0051, + -0.0101, + -0.0151, + -0.0202, + -0.006, + -0.0111, + -0.0161, + -0.0211, + 0.0205, + 0.0155, + 0.0104, + 0.0054, + 0.0137, + 0.0217, + 0.0167, + 0.0363, + 0.0313, + 0.0263, + 0.0324, + { + "…": "182 more", + "sha256": "49eeb5a3c46f94c4" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 442, + 883, + 886, + 898, + 1286, + 1337, + 1543, + 1551, + 1898, + 1905, + 2301, + 2303, + 2394, + 2580, + 2803, + 2970, + 3183, + 3412, + 3422, + 3460, + { + "…": "92 more", + "sha256": "e5e307852bd97554" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_SPERMATOGENESIS", + "size": 134, + "setSize": 135, + "es": 0.3726, + "nes": 1.668, + "p": 0.002932551319648094, + "leadingEdge": [ + "KIF2C", + "TTK", + "CCNB2", + "BUB1", + "NCAPH", + "AURKA", + "IL12RB2", + "DBF4", + "EZH2", + "ART3", + "PSMG1", + "RFC4", + "CDK1", + "LPIN1", + "CDKN3", + "NEK2", + "CSNK2A2", + "RPL39L", + "DMRT1", + "ACRV1", + { + "…": "25 more", + "sha256": "2557db6fe09abaed" + } + ], + "curve": [ + -0.0001, + 0.1478, + 0.2428, + 0.275, + 0.304, + 0.3304, + 0.3254, + 0.3204, + 0.3153, + 0.3366, + 0.3316, + 0.3384, + 0.3334, + 0.3284, + 0.334, + 0.3497, + 0.3447, + 0.3397, + 0.3539, + 0.3489, + { + "…": "182 more", + "sha256": "90ff0b2a9fc2eb8b" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 8, + 14, + 32, + 50, + 62, + 72, + 135, + 137, + 141, + 148, + 166, + 210, + 219, + 319, + 345, + 433, + 452, + 801, + 823, + 1066, + { + "…": "114 more", + "sha256": "ea9457732d8f7e0e" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_INFLAMMATORY_RESPONSE", + "size": 200, + "setSize": 200, + "es": 0.3558, + "nes": 1.667, + "p": 0.003278688524590164, + "leadingEdge": [ + "PVR", + "RIPK2", + "MARCO", + "OPRK1", + "LAMP3", + "CHST2", + "CCL7", + "ITGB8", + "LYN", + "NMI", + "AQP9", + "PLAUR", + "ADORA2B", + "CCL20", + "SLC7A1", + "CD82", + "MET", + "MYC", + "CX3CL1", + "ADM", + { + "…": "73 more", + "sha256": "9e697d14cd34e6bc" + } + ], + "curve": [ + -0.0001, + 0.0148, + 0.0271, + 0.022, + 0.0318, + 0.0556, + 0.0639, + 0.0715, + 0.1031, + 0.1214, + 0.1396, + 0.1345, + 0.1295, + 0.1447, + 0.1496, + 0.1638, + 0.1772, + 0.1811, + 0.1849, + 0.1968, + { + "…": "182 more", + "sha256": "38db148efb26176d" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 95, + 191, + 394, + 404, + 479, + 569, + 691, + 743, + 779, + 782, + 883, + 894, + 904, + 920, + 1210, + 1253, + 1308, + 1410, + 1428, + 1527, + { + "…": "180 more", + "sha256": "f352e3ca07d6f798" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_UV_RESPONSE_UP", + "size": 158, + "setSize": 158, + "es": 0.3634, + "nes": 1.643, + "p": 0.003215434083601286, + "leadingEdge": [ + "CCNE1", + "BTG3", + "AMD1", + "CHRNA5", + "GGH", + "AGO2", + "RFC4", + "CTSV", + "GAL", + "ASNS", + "FEN1", + "BAK1", + "TYRO3", + "CEBPG", + "GLS", + "KLHDC3", + "RPN1", + "LYN", + "SOD2", + "BID", + { + "…": "40 more", + "sha256": "6e410c8f42b4bae4" + } + ], + "curve": [ + -0.0001, + 0.038, + 0.0851, + 0.1432, + 0.1819, + 0.1769, + 0.1975, + 0.1925, + 0.2451, + 0.2511, + 0.246, + 0.2618, + 0.2665, + 0.2708, + 0.275, + 0.279, + 0.2827, + 0.3114, + 0.3064, + 0.3013, + { + "…": "182 more", + "sha256": "9379052473e50451" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 13, + 75, + 111, + 130, + 182, + 208, + 210, + 221, + 268, + 306, + 312, + 367, + 501, + 552, + 728, + 740, + 742, + 779, + 794, + 873, + { + "…": "138 more", + "sha256": "2b7f4ef5093cbfe9" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_IL6_JAK_STAT3_SIGNALING", + "size": 87, + "setSize": 87, + "es": 0.3948, + "nes": 1.627, + "p": 0.002652519893899204, + "leadingEdge": [ + "BAK1", + "PTPN2", + "PIM1", + "TNFRSF21", + "CCL7", + "IL1R2", + "CXCL3", + "CXCL1", + "IL2RA", + "LTBR", + "CD38", + "CXCL10", + "SOCS1", + "TNF", + "IL15RA", + "CSF2", + "CXCL11", + "IL10RB", + "IL18R1", + "CCR1", + { + "…": "23 more", + "sha256": "f849bfbf5f4568af" + } + ], + "curve": [ + -0.0001, + -0.0051, + -0.0101, + -0.0151, + 0.0468, + 0.0742, + 0.1, + 0.123, + 0.118, + 0.1911, + 0.1861, + 0.1811, + 0.1761, + 0.1932, + 0.1882, + 0.1832, + 0.1984, + 0.1934, + 0.1884, + 0.2209, + { + "…": "182 more", + "sha256": "f4c1c70929fc4b5a" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 367, + 383, + 423, + 502, + 691, + 852, + 885, + 893, + 1283, + 1591, + 1882, + 1899, + 2244, + 2384, + 2387, + 2461, + 2535, + 2582, + 2974, + 2981, + { + "…": "67 more", + "sha256": "654fc45d6425b27f" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_TNFA_SIGNALING_VIA_NFKB", + "size": 200, + "setSize": 200, + "es": 0.3147, + "nes": 1.502, + "p": 0.0031446540880503146, + "leadingEdge": [ + "BTG3", + "CEBPB", + "RIPK2", + "NFIL3", + "PTX3", + "SOD2", + "PNRC1", + "CXCL3", + "CXCL1", + "PLAUR", + "YRDC", + "CCL20", + "FOSL1", + "NFKBIE", + "BCL2A1", + "FUT4", + "RCAN1", + "SLC2A6", + "MYC", + "DUSP2", + { + "…": "46 more", + "sha256": "4e54573e969409a4" + } + ], + "curve": [ + -0.0001, + 0.0137, + 0.0415, + 0.0517, + 0.0466, + 0.0416, + 0.0365, + 0.043, + 0.0489, + 0.0862, + 0.1122, + 0.117, + 0.112, + 0.116, + 0.1374, + 0.1496, + 0.1531, + 0.1561, + 0.159, + 0.1693, + { + "…": "182 more", + "sha256": "5e578b4171fc6c4a" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 75, + 126, + 191, + 222, + 675, + 794, + 869, + 885, + 893, + 894, + 905, + 920, + 997, + 1069, + 1263, + 1344, + 1378, + 1390, + 1410, + 1496, + { + "…": "180 more", + "sha256": "e7aa007d56403e39" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_DNA_REPAIR", + "size": 150, + "setSize": 150, + "es": 0.3203, + "nes": 1.468, + "p": 0.0030303030303030303, + "leadingEdge": [ + "RAD51", + "RFC4", + "TYMS", + "FEN1", + "ALYREF", + "SSRP1", + "POLR2D", + "SF3A3", + "POLR1C", + "POLR2F", + "PNP", + "RFC2", + "PCNA", + "POLD1", + "UPF3B", + "HPRT1", + "ZWINT", + "POLA2", + "RFC3", + "ADA", + { + "…": "33 more", + "sha256": "58c7faf616399479" + } + ], + "curve": [ + -0.0001, + -0.0051, + 0.0115, + 0.0432, + 0.0727, + 0.0994, + 0.0944, + 0.1468, + 0.1557, + 0.1771, + 0.1976, + 0.217, + 0.2237, + 0.2299, + 0.2358, + 0.2308, + 0.2257, + 0.2306, + 0.2452, + 0.2497, + { + "…": "182 more", + "sha256": "22aecb302d0c1238" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 104, + 210, + 299, + 312, + 362, + 437, + 483, + 605, + 632, + 646, + 696, + 721, + 845, + 855, + 925, + 964, + 1016, + 1085, + 1128, + 1270, + { + "…": "130 more", + "sha256": "76a93abb460fb448" + } + ], + "q": 0.008801267382503081 + }, + { + "name": "HALLMARK_UV_RESPONSE_DN", + "size": 144, + "setSize": 144, + "es": -0.358, + "nes": -1.498, + "p": 0.0043859649122807015, + "leadingEdge": [ + "FHL2", + "ITGB3", + "NR3C1", + "PIK3R3", + "EFEMP1", + "SCAF8", + "ATRN", + "DAB2", + "SFMBT1", + "NIPBL", + "PTPN21", + "SERPINE1", + "CAV1", + "PPARG", + "F3", + "ATP2B1", + "BCKDHB", + "PRKCE", + "TJP1", + "MGMT", + { + "…": "53 more", + "sha256": "c18e58cea5d470c0" + } + ], + "curve": [ + -0.0001, + -0.0051, + -0.0101, + -0.0152, + -0.0202, + -0.0252, + -0.0134, + -0.0184, + -0.0078, + 0.0017, + 0.0112, + 0.0062, + 0.0012, + 0.0089, + 0.0163, + 0.0233, + 0.0298, + 0.0248, + 0.0526, + 0.0476, + { + "…": "182 more", + "sha256": "6492e32f94cde5c7" + } + ], + "curveAt": [ + 0, + 100, + 200, + 300, + 400, + 500, + 600, + 700, + 800, + 900, + 1000, + 1100, + 1200, + 1300, + 1400, + 1500, + 1600, + 1700, + 1800, + 1900, + { + "…": "182 more", + "sha256": "c05d23c0bbd853eb" + } + ], + "hits": [ + 551, + 719, + 899, + 904, + 1210, + 1308, + 1410, + 1556, + 1718, + 1730, + 1795, + 2105, + 2583, + 2839, + 3203, + 3298, + 3573, + 3837, + 3928, + 3943, + { + "…": "124 more", + "sha256": "c1be36ad83bd7cdf" + } + ], + "q": 0.010964912280701754 + }, + { + "…": "30 more", + "sha256": "a1150be8c9c8746a" + } + ], + "skipped": [] + } + }, + "participation": { + "studies": [ + { + "study": "brca_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Welch's t-test per gene on rna_seq_v2_mrna_median_all_sample_Zscores as stored, Basal-like minus Luminal A, each patient contributing the mean of their samples; computed from three running totals per gene and cohort, so it is exact across sites. 20,006 genes tested, 14 left out (fewer than 3 patients with a value in a cohort, or no variance); q is Benjamini–Hochberg across every gene tested. The 1500 most significant genes are drawn as points, the rest as density. Z-scores are standardised within each study, so a difference is in study-specific units. A t-test on thousands of patients finds tiny differences significant — read the effect, not only the q. Enrichment is preranked GSEA on the unrounded t (Subramanian et al. 2005, weight 1), significance from 1000 random sets of the same size drawn from the same ranking, seeded by the set's name so a shared link reproduces it; p = (b+1)/(m+1) over the same-sign nulls, q is Benjamini–Hochberg across the sets tested (not GSEA's own NES-based FDR). Gene-set permutation ignores gene–gene correlation, so it is anti-conservative next to phenotype permutation, which needs patient-level values. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Sum every gene's values", + "detail": "The diffexpr:moments query above, on “rna_seq_v2_mrna_median_all_sample_Zscores” as stored. Per gene, over the cohort's patients with a value (a patient with several samples contributes their average): n, Σv and Σv². Every gene in the profile, no individual value.", + "scope": "Basal-like · brca_tcga_pan_can_atlas_2018", + "rowsIn": 171 + }, + { + "kind": "fetch", + "title": "Sum every gene's values", + "detail": "The diffexpr:moments query above, on “rna_seq_v2_mrna_median_all_sample_Zscores” as stored. Per gene, over the cohort's patients with a value (a patient with several samples contributes their average): n, Σv and Σv². Every gene in the profile, no individual value.", + "scope": "Luminal A · brca_tcga_pan_can_atlas_2018", + "rowsIn": 499 + }, + { + "kind": "transform", + "title": "Leave out genes that cannot be tested", + "detail": "A gene with fewer than 3 patients with a value in either cohort, or with no variance (Var A + Var B ≤ 1e-9 · (1 + mean A² + mean B²) — judged to a tolerance, since a constant gene's variance from the sums is rounding noise).", + "rowsIn": 20020, + "rowsOut": 20006 + }, + { + "kind": "statistic", + "title": "Welch's t-test per gene", + "detail": "Mean A − mean B (Basal-like minus Luminal A) with each cohort's variance (Σv² − (Σv)²/n)/(n − 1); unequal-variance t, Welch–Satterthwaite df, two-sided. With thousands of patients a tiny difference is significant: read the effect too.", + "params": [ + [ + "genes tested", + "20,006" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across genes", + "detail": "q-values over all 20,006 genes tested." + }, + { + "kind": "statistic", + "title": "Preranked gene-set enrichment (GSEA)", + "detail": "Genes ranked by the unrounded t, Basal-like over Luminal A first. Enrichment score as in Subramanian et al. 2005 with weight 1 (each member's step is |t| / Σ|t| of the members). Significance from 1000 random sets of the same size drawn from the same ranking, from a generator seeded by the set's name — so a shared link gives the same p — with p = (b + 1)/(m + 1) over the m null scores of the same sign and NES = ES / mean of those. Gene-set permutation ignores correlation between genes, so it is anti-conservative next to phenotype permutation. A set with fewer than 10 ranked members is not tested. q is Benjamini–Hochberg across the sets tested.", + "params": [ + [ + "sets tested", + "50" + ] + ] + } + ], + "implementation": { + "functions": [ + "welchT", + "benjaminiHochberg", + "preRankedGsea" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Welch's t from moments matches scipy 1.18.1 ttest_ind(equal_var=False) and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts, test/tables-golden.test.ts); enrichment scores match gseapy 1.3.1 prerank, and NES and p match the script's port of our seeded null exactly (test/gsea-golden.test.ts).", + "check": { + "diffexpr:tested": { + "v": 20006, + "abs": 0 + }, + "diffexpr:TTC36:p": { + "v": 8.091447449946383e-220, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:TTC36:q": { + "v": 1.6187749768362735e-215, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:FSIP1:p": { + "v": 2.3035779855199614e-204, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:FSIP1:q": { + "v": 2.3042690589156173e-200, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:SRARP:p": { + "v": 2.5912634421936607e-200, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:SRARP:q": { + "v": 1.7280272141508793e-196, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:DRAIC:p": { + "v": 5.510248672884023e-190, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:DRAIC:q": { + "v": 2.755950873742944e-186, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:NAT1:p": { + "v": 2.7043279892748184e-182, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:NAT1:q": { + "v": 1.0820557150686404e-178, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:MAPT-IT1:p": { + "v": 2.0129532020700296e-175, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:MAPT-IT1:q": { + "v": 6.711856960102169e-172, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:CT62:p": { + "v": 6.399560110459782e-157, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:CT62:q": { + "v": 1.8289942795694058e-153, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:SLC7A13:p": { + "v": 3.892473730008788e-156, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:SLC7A13:q": { + "v": 9.734103680319477e-153, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:CYP2B7P:p": { + "v": 6.3502571936527e-150, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:CYP2B7P:q": { + "v": 1.4115916157357323e-146, + "rel": 0.000001, + "abs": 1e-300 + }, + "diffexpr:TFF1:p": { + "v": 5.061562842349789e-149, + "rel": 0.000001, + "abs": 1e-300 + }, + "…": { + "more": 3131, + "sha256": "baa736b72024a2de" + } + } + } + } + ] +} diff --git a/test/snapshots/diffexpr.sql b/test/snapshots/diffexpr.sql new file mode 100644 index 0000000..e7f23c4 --- /dev/null +++ b/test/snapshots/diffexpr.sql @@ -0,0 +1,52 @@ +-- cohort Basal-like +-- brca_tcga_pan_can_atlas_2018 +(SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND type = 'patient' + AND attribute_name = 'SUBTYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('BRCA_Basal')))) + +-- cohort Luminal A +-- brca_tcga_pan_can_atlas_2018 +(SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND type = 'patient' + AND attribute_name = 'SUBTYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('BRCA_LumA')))) + +-- view 0 diffexpr: diffexpr:genesets · brca_tcga_pan_can_atlas_2018 +SELECT gs.external_id AS set_name, groupUniqArray(g.hugo_gene_symbol) AS genes +FROM snapshot_db.geneset gs +JOIN snapshot_db.geneset_gene gg ON gg.geneset_id = gs.id +JOIN snapshot_db.gene g ON g.entrez_gene_id = gg.entrez_gene_id +WHERE startsWith(gs.external_id, 'HALLMARK_') GROUP BY set_name ORDER BY set_name + +-- view 0 diffexpr: diffexpr:moments:Basal-like · brca_tcga_pan_can_atlas_2018 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND type = 'patient' + AND attribute_name = 'SUBTYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('BRCA_Basal'))))), +vals AS ( + SELECT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid, ga.hugo_gene_symbol AS gene, avg(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) AS v + FROM snapshot_db.genetic_alteration_derived ga + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id + WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_all_sample_Zscores' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND isFinite(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) + AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid, gene +) +SELECT gene, count() AS n, sum(v) AS sx, sum(v * v) AS sxx FROM vals GROUP BY gene + +-- view 0 diffexpr: diffexpr:moments:Luminal A · brca_tcga_pan_can_atlas_2018 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND type = 'patient' + AND attribute_name = 'SUBTYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('BRCA_LumA'))))), +vals AS ( + SELECT replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid, ga.hugo_gene_symbol AS gene, avg(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) AS v + FROM snapshot_db.genetic_alteration_derived ga + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id + WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_all_sample_Zscores' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND isFinite(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL)) + AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid, gene +) +SELECT gene, count() AS n, sum(v) AS sx, sum(v * v) AS sxx FROM vals GROUP BY gene diff --git a/test/snapshots/diffexpr.svg b/test/snapshots/diffexpr.svg new file mode 100644 index 0000000..f22f156 --- /dev/null +++ b/test/snapshots/diffexpr.svg @@ -0,0 +1,2 @@ + +Differential expression — rna_seq_v2_mrna_median_all_sample_Zscores — Basal-like vs Luminal A20,006 genes, q < 0.05:7,563 higher in Basal-like7,698 higher in Luminal Anot significant050100150200250−log₁₀ p−4−2024difference in mean z-score (Basal-like − Luminal A)TTC36: −2.15 · q = 1.6e-215FSIP1: −1.99 · q = 2.3e-200SRARP: −2.44 · q = 1.7e-196DRAIC: −2.09 · q = 2.8e-186NAT1: −1.93 · q = 1.1e-178MAPT-IT1: −1.89 · q = 6.7e-172CT62: −2.45 · q = 1.8e-153SLC7A13: −1.92 · q = 9.7e-153CYP2B7P: −1.78 · q = 1.4e-146TFF1: −2.24 · q = 1e-145NEK10: −1.78 · q = 1.5e-143ABCC8: −2.27 · q = 9.8e-142MAPT-AS1: −1.74 · q = 4.3e-141ANKRD30A: −2.26 · q = 7.2e-141BCL11A: 1.72 · q = 2.7e-139TPSG1: −1.6 · q = 2.1e-138PGR: −1.86 · q = 1.5e-136CDCA7: 1.82 · q = 2.2e-136SERPINA11: −2.05 · q = 6.8e-135SLC39A6: −1.67 · q = 2.1e-134TUBA3E: −1.59 · q = 1e-133NXNL2: −1.73 · q = 5.5e-132TMPRSS6: −1.62 · q = 9e-132CDC20: 1.9 · q = 3.2e-130RABEP1: −1.86 · q = 5.8e-128AGR3: −2.58 · q = 4.4e-127GRPR: −1.62 · q = 1.8e-126TUBA3D: −1.5 · q = 3.4e-126MCCC2: −1.76 · q = 1.4e-125CFAP57: −1.79 · q = 1.7e-125DCPH1: −1.54 · q = 1.2e-124TCEAL1: −1.69 · q = 1.6e-124SYT9: −1.81 · q = 1.3e-122GP2: −2.07 · q = 1.8e-121ZNF552: −2.06 · q = 1.8e-121TBC1D9: −2.18 · q = 5.3e-121CFAP61: −1.76 · q = 5.3e-121KIF2C: 1.8 · q = 4.7e-120CENPA: 1.86 · q = 3.2e-119KDM4B: −1.85 · q = 1.8e-118SCUBE2: −1.99 · q = 2.9e-117PGLYRP2: −1.7 · q = 9.8e-117RGS22: −1.72 · q = 4.8e-116CCDC170: −2.09 · q = 8.9e-116AURKB: 1.8 · q = 8.8e-115ORC6: 1.71 · q = 1.2e-114PLK1: 1.72 · q = 1.4e-114F7: −1.82 · q = 1.7e-114ANXA9: −2.03 · q = 8e-114IGFALS: −1.63 · q = 1.6e-112XBP1: −2.21 · q = 1.7e-112HPX: −1.67 · q = 1.7e-112PSAT1: 1.91 · q = 2.4e-112APOF: −1.51 · q = 3.5e-111CACNA2D2: −1.84 · q = 5.6e-111ATOSA: −1.93 · q = 2.2e-110PLAC9P1: −1.44 · q = 2.7e-110ABAT: −1.99 · q = 2.7e-110EVL: −1.61 · q = 4.6e-110PLEKHD1: −1.59 · q = 1e-109C5AR2: −2.04 · q = 1.9e-109TPRG1: −1.63 · q = 2.8e-109HJURP: 1.66 · q = 1.4e-108AKR7A3: −1.71 · q = 3.4e-108CST9: −1.39 · q = 7.1e-108RUNDC1: −1.83 · q = 1.4e-107LRRC31: −1.51 · q = 4.9e-107FOXC1: 2 · q = 6.1e-107PIMREG: 1.83 · q = 2.8e-106CDCA8: 1.91 · q = 4.6e-106CIB3: −1.45 · q = 8.3e-106CENPN: 1.85 · q = 1.5e-105SLC16A6: −1.72 · q = 2.9e-105CEP55: 1.71 · q = 3e-105TPX2: 1.68 · q = 4.9e-105KRT37: −1.44 · q = 7.5e-105CDC45: 1.58 · q = 1.1e-104PALS2: 1.64 · q = 3.4e-104MYBL2: 1.58 · q = 1.8e-103SPEF1: −1.78 · q = 1.8e-103TTK: 1.77 · q = 6.7e-103KIF18B: 1.63 · q = 1.7e-102ESR1: −2.11 · q = 2e-102CDCA5: 1.64 · q = 2.1e-102CA12: −2.17 · q = 3.6e-102CHAD: −1.72 · q = 5.1e-102B3GNT5: 1.86 · q = 6.2e-102CYP4Z2P: −1.92 · q = 1.4e-101ANKRD30B: −1.78 · q = 2.3e-101SLC4A8: −1.74 · q = 6.6e-101CCNB2: 1.66 · q = 7.2e-101BIRC5: 1.63 · q = 7.7e-101RAD54L: 1.73 · q = 9.3e-101TFF3: −2.19 · q = 1.3e-100CCDC125: −1.95 · q = 1.8e-100EFCC1: −1.76 · q = 2.5e-100MELK: 1.7 · q = 3.3e-100SYTL5: −1.94 · q = 3.6e-100LRRC46: −1.86 · q = 4.5e-100MAG: −1.6 · q = 1.3e-99TICRR: 1.75 · q = 2.6e-99NEK5: −1.79 · q = 4e-99EFCAB12: −1.77 · q = 8.1e-99SLC26A3: −1.34 · q = 2.4e-98DEPDC1: 1.63 · q = 6.1e-98FAM72B: 1.75 · q = 2.3e-97PDZK1: −1.37 · q = 2.9e-97CDC25A: 1.79 · q = 4.3e-97DNAJC12: −1.87 · q = 7.9e-97KCTD6: −1.4 · q = 1.2e-96FAM83D: 1.63 · q = 1.2e-96BUB1: 1.65 · q = 1.9e-96SKA1: 1.66 · q = 1.9e-96MCM10: 1.71 · q = 2.3e-96SPATA4: −1.51 · q = 3.5e-96KIFC1: 1.67 · q = 5.4e-96THPO: −1.45 · q = 5.9e-96CCNA2: 1.65 · q = 1.3e-95SLC7A8: −2.08 · q = 1.9e-95ORC1: 1.78 · q = 2.3e-95SNTN: −1.4 · q = 3.4e-95ATP1A4: −1.51 · q = 4.2e-95PRKX: 1.77 · q = 4.9e-95NDC80: 1.7 · q = 5e-95DLGAP5: 1.5 · q = 6.8e-95TRIM3: −1.75 · q = 7.8e-95FYB2: −1.69 · q = 7.9e-95PHGR1: −1.29 · q = 1.8e-94UBE2E3: 1.28 · q = 1.8e-94RARA: −1.74 · q = 2.1e-94ELOVL5: −1.62 · q = 3e-94BBOF1: −1.86 · q = 3.5e-94DEFB132: −1.7 · q = 5.3e-94ACADSB: −1.84 · q = 6.3e-94DNALI1: −2.09 · q = 7.5e-94ERGIC1: −1.75 · q = 4.4e-93BCAS1: −1.94 · q = 5.8e-93MTFR2: 1.69 · q = 6.3e-93MAPT: −1.98 · q = 9.4e-93DYNLRB2: −2.07 · q = 1.1e-92ROPN1L: −1.43 · q = 1.3e-92ATP7B: −1.75 · q = 1.7e-92SUSD3: −1.56 · q = 2.6e-92ZNF695: 1.75 · q = 3e-92STARD10: −1.62 · q = 7.3e-92EXO1: 1.59 · q = 8e-92CAPN8: −2.07 · q = 8.1e-92THSD4: −2.12 · q = 1.2e-91UBE2C: 1.57 · q = 1.3e-91DEGS2: −2.12 · q = 1.7e-91NCAPH: 1.54 · q = 2.2e-91IL20: −1.37 · q = 2.9e-91CTPS1: 1.97 · q = 3e-91STC2: −1.33 · q = 9e-91DACH1: −1.91 · q = 1.6e-90LINC00908: −1.47 · q = 2.4e-90NUF2: 1.57 · q = 4.5e-90SLC22A5: −1.97 · q = 8e-90NOSTRIN: −2.05 · q = 9.2e-90STK32B: −1.68 · q = 9.2e-90NCAPG: 1.53 · q = 1.3e-89ERBB4: −2.23 · q = 2.2e-89ZMYND10: −1.99 · q = 2.7e-89KCNJ3: −1.23 · q = 2.9e-89MTHFD1L: 1.81 · q = 5.7e-89GTSE1: 1.64 · q = 1.1e-88CDCA3: 1.75 · q = 1.8e-88DRC3: −1.77 · q = 2.2e-88CCNE1: 2.02 · q = 3.6e-88KIF20A: 1.47 · q = 6.8e-88FANCA: 1.76 · q = 1.6e-87AURKA: 1.46 · q = 1.7e-87SYTL2: −1.75 · q = 1.7e-87ARSG: −1.97 · q = 2.5e-87MAGED2: −1.78 · q = 3.9e-87FAM234B: −1.58 · q = 6e-87ABCC11: −1.71 · q = 1e-86HASPIN: 1.71 · q = 1.1e-86MS4A8: −1.27 · q = 3.2e-86CDCA2: 1.87 · q = 3.9e-86INPP5J: −1.93 · q = 4.7e-86PLA2G10: −1.42 · q = 4.9e-86CFAP69: −1.76 · q = 5e-86FOXM1: 1.81 · q = 5.4e-86ANKRA2: −1.86 · q = 8.1e-86LINC02913: −1.5 · q = 8.2e-86SH3BGRL: −1.32 · q = 8.2e-86PRR15: −2.19 · q = 9.7e-86LRTOMT: −1.79 · q = 1.1e-85TMEM26: −1.39 · q = 1.4e-85GATA3-AS1: −1.89 · q = 2e-85DSCC1: 1.7 · q = 3.5e-85BMERB1: −1.66 · q = 5.1e-85FAM47E: −2.08 · q = 5.8e-85GREB1: −1.74 · q = 5.9e-85KIAA0825: −1.98 · q = 6.3e-85IGDCC3: −1.33 · q = 1.4e-84KIF4A: 1.41 · q = 2.3e-84CLSTN2: −1.86 · q = 2.6e-84CXADRP3: −1.19 · q = 2.9e-84CBX2: 1.57 · q = 3.4e-84WFS1: −1.81 · q = 4.9e-84SLC7A2: −1.58 · q = 6e-84UGT2B15: −1.4 · q = 7.8e-84TTC8: −1.94 · q = 9.5e-84CFAP46: −1.58 · q = 1.6e-83SGO1: 1.45 · q = 1.7e-83IQUB: −1.37 · q = 2.3e-83RAD51: 1.42 · q = 2.5e-83AR: −2.11 · q = 5.4e-83HMGCS2: −1.44 · q = 6e-83GPC1-AS1: −1.45 · q = 6.1e-83KIF14: 1.49 · q = 6.6e-83SKA3: 1.57 · q = 7.4e-83YBX1: 1.96 · q = 9.6e-83KCNH1: −1.52 · q = 1.1e-82LRP8: 1.77 · q = 1.7e-82MLPH: −2.35 · q = 1.8e-82TSPAN1: −1.9 · q = 1.9e-82ANLN: 1.62 · q = 2.5e-82WWP1: −1.5 · q = 3.1e-82KCNE4: −1.4 · q = 6.1e-82CFAP184: −1.8 · q = 7.8e-82CHRD: −1.62 · q = 2e-81TROAP: 1.4 · q = 3.7e-81SLC7A5: 1.7 · q = 4.6e-81AGR2: −2.22 · q = 6.9e-81IFRD1: 2.01 · q = 6.9e-81FOXA1: −2.4 · q = 7.3e-81RASAL1: 1.53 · q = 1e-80UMOD: −1.33 · q = 1.2e-80KRT8P41: −1.44 · q = 1.7e-80SMCO4: 1.45 · q = 1.7e-80BPIFB2: −1.36 · q = 2.3e-80SMIM14: −1.92 · q = 2.6e-80PCP2: −1.67 · q = 3e-80LRIG1: −1.74 · q = 8.2e-80ASPM: 1.48 · q = 1.6e-79DNAI7: −1.92 · q = 1.7e-79BORCS7: −1.82 · q = 1.9e-79DNAH7: −1.84 · q = 2.3e-79SLC44A4: −2.23 · q = 3.1e-79BTG3: 1.59 · q = 3.2e-79AFF3: −1.9 · q = 3.4e-79DNAAF1: −1.7 · q = 3.7e-79TMBIM6: −1.75 · q = 4.8e-79KCNK15: −1.76 · q = 5.7e-79SUOX: −1.89 · q = 6.3e-79RGMA: 1.57 · q = 7.6e-79PM20D2: 1.48 · q = 9.9e-79PPP1R14C: 1.77 · q = 1.1e-78KCNJ11: −2.1 · q = 1.2e-78SHCBP1: 1.44 · q = 1.4e-78SAMD15: −1.76 · q = 1.5e-78HECTD2-AS1: −1.48 · q = 3.6e-78ACOX2: −1.58 · q = 7.6e-78TMBIM4: −1.83 · q = 2.1e-77FRMPD2: −1.27 · q = 2.3e-77AUNIP: 1.67 · q = 3.7e-77PCAT18: −1.43 · q = 4.9e-77FMO5: −1.62 · q = 9.1e-77PTPRT: −1.79 · q = 9.1e-77APH1B: −1.78 · q = 1.3e-76BBS1: −1.77 · q = 1.3e-76FGD3: −1.44 · q = 1.4e-76CENPO: 1.63 · q = 1.6e-76INPP4B: −1.99 · q = 1.7e-76ROPN1: 1.98 · q = 1.7e-76TMEM232: −1.41 · q = 1.8e-76CENPW: 1.97 · q = 1.8e-76LBR: 1.67 · q = 2.2e-76DNAL1: −1.78 · q = 2.5e-76CHEK1: 1.78 · q = 2.8e-76SRSF12: 1.92 · q = 3.8e-76ACOT4: −1.76 · q = 4.9e-76KCNK5: 1.73 · q = 6.2e-76PHGDH: 1.62 · q = 8.5e-76CYP4B1: −1.8 · q = 1.1e-75RAI2: −1.64 · q = 2e-75PREX1: −1.68 · q = 2e-75UGDH: −1.32 · q = 3.1e-75AK8: −1.87 · q = 3.1e-75SLC40A1: −1.56 · q = 3.6e-75GSTP1: 1.29 · q = 3.9e-75APBB2: −1.83 · q = 5.3e-75OIP5: 1.4 · q = 6.1e-75RHOB: −1.98 · q = 8.2e-75REEP5: −1.75 · q = 1e-74DRC2: −1.33 · q = 1e-74WDR93: −1.64 · q = 1.2e-74ESYT3: 1.75 · q = 1.4e-74AGTR1: −1.31 · q = 1.6e-74NUP93: 1.74 · q = 1.7e-74MOAP1: −1.63 · q = 1.8e-74CCDC82: 1.45 · q = 2e-74GFRA1: −1.79 · q = 2.4e-74DNAAF8: −1.67 · q = 2.5e-74ATP8B1: −1.72 · q = 2.7e-74SOWAHA: −1.34 · q = 2.8e-74NCAM2: −1.53 · q = 3.7e-74TSPAN13: −1.65 · q = 4.6e-74DNAAF19: −1.59 · q = 4.8e-74ZNF703: −1.73 · q = 4.8e-74SPMIP5: −1.32 · q = 4.9e-74TRIP13: 1.66 · q = 7.8e-74FAM171A1: 1.71 · q = 8.2e-74PIERCE1: −1.85 · q = 8.4e-74KIF13B: −1.57 · q = 8.7e-74CDT1: 1.55 · q = 1e-73GASK1B: −1.74 · q = 1.1e-73POLQ: 1.42 · q = 1.3e-73RAB30: −1.4 · q = 1.4e-73ZNF205-AS1: −1.7 · q = 1.6e-73CIRBP: −1.76 · q = 2.1e-73EMX1: −1.27 · q = 2.6e-73CASD1: −1.25 · q = 2.8e-73KPNA2: 1.42 · q = 3.1e-73CMC2: 1.66 · q = 4.2e-73UBXN10: −1.97 · q = 4.2e-73SCN7A: −1.6 · q = 4.7e-73PLCH1: 1.36 · q = 5.3e-73ADAMTS15: −1.75 · q = 7.7e-73KIF15: 1.44 · q = 9.3e-73AKR7L: −1.34 · q = 9.7e-73SIDT1: −2.03 · q = 1.5e-72TMEM144: −1.68 · q = 1.6e-72BBS4: −1.88 · q = 1.8e-72PVR: 1.71 · q = 2.2e-72REPS2: −1.36 · q = 2.2e-72KLHDC7A: −1.59 · q = 2.3e-72CHODL: 1.91 · q = 3.9e-72BUB1B: 1.4 · q = 6e-72STIL: 1.66 · q = 8.8e-72PRRT3: −1.66 · q = 1.7e-71PTTG1: 1.52 · q = 1.8e-71KIF16B: −1.61 · q = 2.2e-71DSC2: 1.59 · q = 2.3e-71BTG2: −1.57 · q = 3.6e-71KIF18A: 1.44 · q = 3.6e-71MND1: 1.5 · q = 3.7e-71PIF1: 1.66 · q = 5.5e-71CIP2A: 1.45 · q = 9.2e-71GGH: 1.34 · q = 1.6e-70SFT2D2: 1.87 · q = 1.8e-70CELSR1: −1.71 · q = 2e-70CHRNA5: 1.54 · q = 2.5e-70MKI67: 1.43 · q = 2.8e-70SYTL4: −1.78 · q = 4.2e-70ABTB2: 1.56 · q = 4.6e-70GIPR: −1.47 · q = 5.5e-70FAM174A: −1.78 · q = 6.5e-70CRIP1: −1.62 · q = 7.4e-70INAVA: 1.44 · q = 8.3e-70DEPDC1B: 1.42 · q = 9.8e-70STMN1: 1.7 · q = 1e-69BAIAP3: −1.53 · q = 1.1e-69HEXIM1: −1.65 · q = 1.2e-69ABLIM3: −1.77 · q = 1.2e-69PARD6B: −1.34 · q = 1.2e-69CEBPB: 1.58 · q = 1.3e-69GALNT7: −1.56 · q = 1.6e-69FZD9: 2.05 · q = 1.9e-69FAM161B: −1.58 · q = 2e-69CCNG2: −1.6 · q = 2.2e-69ASAH1: −1.45 · q = 2.3e-69FAM81B: −1.27 · q = 3.3e-69CCDC74A: −1.43 · q = 3.3e-69NHLRC4: −1.4 · q = 3.4e-69RNF103: −1.75 · q = 4e-69GATA3: −2.14 · q = 4.9e-69RCOR2: 1.57 · q = 5.2e-69ACSM1: −1.35 · q = 5.4e-69LDHB: 1.7 · q = 5.8e-69DALRD3: −1.69 · q = 8.1e-69ANKRD42: −1.71 · q = 1.7e-68CKS1B: 1.73 · q = 2.1e-68ZNF462: 1.35 · q = 2.1e-68KIF23: 1.5 · q = 2.4e-68SERPINA6: −1.04 · q = 2.5e-68HPDL: 1.7 · q = 2.7e-68NFIL3: 1.28 · q = 3.1e-68KLHDC2: −1.66 · q = 3.7e-68CNTD1: −1.38 · q = 4e-68LCMT2: −1.7 · q = 4.2e-68TTLL4: 1.99 · q = 4.4e-68TUBB: 1.67 · q = 7.5e-68YEATS2: 1.81 · q = 7.8e-68AMD1: 1.7 · q = 8.8e-68CENPF: 1.45 · q = 1.2e-67FAM72A: 1.45 · q = 1.3e-67USB1: 1.64 · q = 1.5e-67LDLRAD1: −1.07 · q = 1.7e-67ABCC13: −1.04 · q = 2.2e-67TCEAL3: −1.52 · q = 2.2e-67CYP4F8: −1.09 · q = 2.3e-67PLAAT1: 1.39 · q = 2.5e-67MAP3K21: 1.49 · q = 4e-67CLCN4: 1.63 · q = 4.3e-67MSANTD3: 1.68 · q = 5.4e-67PDSS1: 1.92 · q = 6.2e-67TCEAL4: −1.32 · q = 6.2e-67E2F1: 1.38 · q = 6.3e-67KIAA0232: −1.7 · q = 7.3e-67CPB1: −1.18 · q = 8.1e-67CPEB2: −1.69 · q = 9.4e-67FUT8: −1.61 · q = 1.1e-66FBP1: −2 · q = 1.4e-66BTRC: −1.43 · q = 1.4e-66TIGD6: −1.7 · q = 2.1e-66CENPE: 1.36 · q = 2.5e-66BLM: 1.58 · q = 3e-66CACNA1H: −1.25 · q = 3.4e-66A2ML1: 2.02 · q = 3.6e-66TP53INP1: −1.62 · q = 3.9e-66DIAPH3: 1.51 · q = 4.7e-66MCM7: 1.72 · q = 4.7e-66KRT222: −1.35 · q = 6.2e-66GALNT6: −1.47 · q = 6.5e-66VGLL1: 1.94 · q = 7.4e-66SEC16A: −1.54 · q = 1.1e-65NR2E3: −1.28 · q = 1.2e-65BEND3: 1.45 · q = 1.2e-65KCND3: −1.53 · q = 1.3e-65RNASE4: −1.67 · q = 1.4e-65SKP1: −1.65 · q = 1.4e-65HEPACAM2: −1.36 · q = 1.5e-65MEGF9: −1.53 · q = 1.7e-65DBF4: 1.6 · q = 1.7e-65SEC14L2: −1.17 · q = 1.8e-65SIAH2: −1.07 · q = 2.1e-65CHEK2: 1.59 · q = 2.4e-65MAP3K12: −1.68 · q = 2.6e-65CCDC183: −1.5 · q = 2.7e-65TLE3: −1.61 · q = 3.2e-65CDK1: 1.31 · q = 3.4e-65RSPH1: −1.75 · q = 3.6e-65ENO1: 1.71 · q = 4.3e-65RBM38: 1.58 · q = 4.8e-65ANP32E: 1.67 · q = 4.9e-65GNMT: −1.27 · q = 5.8e-65SLC30A8: −1.11 · q = 5.8e-65OTOR: −0.998 · q = 5.8e-65CROT: −1.63 · q = 6e-65CST5: −0.94 · q = 6e-65SPOPL: −1.57 · q = 6.1e-65KAT6B: −1.4 · q = 7.8e-65EZH2: 1.66 · q = 8.6e-65CYBRD1: −1.46 · q = 8.8e-65IQGAP3: 1.42 · q = 8.9e-65TMC3: −1.04 · q = 1e-64SH2D2A: 1.33 · q = 1.1e-64REEP6: −1.94 · q = 1.3e-64HMGA1: 1.74 · q = 1.4e-64KLHDC1: −1.67 · q = 1.4e-64AMER1: 1.79 · q = 1.4e-64ASTN2: −1.64 · q = 1.5e-64UCK2: 1.81 · q = 1.6e-64MAD2L1: 1.43 · q = 1.9e-64DHRS2: −1.29 · q = 2.7e-64NCK2: 1.62 · q = 3.2e-64GIN1: −1.68 · q = 4.2e-64TRH: −0.974 · q = 4.8e-64FANCE: 1.74 · q = 5.1e-64SUV39H2: 1.94 · q = 6.2e-64CYP4A11: −1.13 · q = 7.3e-64FBXO36: −1.72 · q = 7.3e-64PLCD4: −1.29 · q = 7.9e-64IMPA2: 1.64 · q = 7.9e-64HENMT1: 1.13 · q = 8.1e-64PCBD2: −1.62 · q = 9.7e-64NOVA1: −1.42 · q = 1.1e-63PKIB: −1.39 · q = 1.2e-63EXOC6: −1.72 · q = 1.2e-63CRY2: −1.63 · q = 1.3e-63PYY: −1.01 · q = 1.6e-63PCSK4: −1.78 · q = 1.6e-63QDPR: −1.13 · q = 1.8e-63PSRC1: 1.56 · q = 2.1e-63MID1: 1.36 · q = 2.8e-63FNIP1: −1.54 · q = 3.2e-63SRPK1: 1.84 · q = 3.3e-63IFT140: −1.54 · q = 4e-63E2F8: 1.27 · q = 4e-63TUBA1C: 1.57 · q = 4.6e-63FRS2: −1.31 · q = 4.8e-63CDK2AP1: 1.78 · q = 5e-63TACC3: 1.35 · q = 5.3e-63NLRP8: −0.94 · q = 5.7e-63SCGB1D2: −1.31 · q = 9.2e-63SHROOM1: −1.1 · q = 1e-62ST8SIA1: 1.42 · q = 1.1e-62FANCB: 1.63 · q = 1.2e-62MICALL1: 1.85 · q = 1.3e-62AMBP: −1.17 · q = 1.3e-62ELP2: −1.1 · q = 1.3e-62E2F2: 1.63 · q = 2.1e-62P4HTM: −1.76 · q = 2.2e-62BTD: −1.54 · q = 2.4e-62GUSBP2: −1.4 · q = 2.9e-62NEIL3: 1.33 · q = 3.2e-62CFAP43: −1.61 · q = 3.3e-62PRC1: 1.41 · q = 3.5e-62DCDC1: −1.39 · q = 3.7e-62FBXL5: −1.7 · q = 3.8e-62KCNN4: 1.48 · q = 4.3e-62IL12RB2: 1.79 · q = 4.5e-62SPDEF: −2.26 · q = 4.9e-62CCDC150: 1.57 · q = 5e-62ACMSD: −0.942 · q = 5.3e-62GINS1: 1.37 · q = 5.6e-62GALNT10: −1.67 · q = 6.3e-62RPH3AL: −1.66 · q = 8e-62E2F3: 1.71 · q = 1e-61PTDSS1: 1.53 · q = 1.2e-61NT5DC2: 1.58 · q = 1.3e-61GNA14: −1.36 · q = 1.3e-61ODC1: 1.61 · q = 1.3e-61ZBTB16: −1.37 · q = 1.5e-61PSMG1: 1.62 · q = 1.6e-61GPR160: −1.97 · q = 1.7e-61SLC49A3: −1.39 · q = 1.8e-61PDE7A: 1.63 · q = 1.8e-61SYT17: −1.61 · q = 2.4e-61TTC23L: −1.46 · q = 2.6e-61MRTFB: −1.56 · q = 3.4e-61CKAP2L: 1.34 · q = 3.8e-61WDR19: −1.69 · q = 4.1e-61ARHGAP11A: 1.36 · q = 4.1e-61PIP: −1.54 · q = 4.3e-61KCMF1: 1.86 · q = 5.4e-61RND1: −1.82 · q = 5.4e-61JRKL: 1.24 · q = 5.4e-61UBE2T: 1.34 · q = 5.7e-61FAM241A: −1.73 · q = 5.7e-61REEP1: −1.72 · q = 6.1e-61DNAH5: −1.71 · q = 6.9e-61INSYN2A: −1.11 · q = 7.3e-61RET: −1.45 · q = 7.9e-61DNAAF3: −1.69 · q = 1.2e-60DCTN4: −1.51 · q = 1.3e-60CCDC83: −0.965 · q = 1.4e-60MS4A2: −1.61 · q = 1.4e-60BCAM: −1.77 · q = 1.4e-60ZNF385A: −1.45 · q = 1.5e-60COLGALT1: 1.61 · q = 1.7e-60HAPLN3: 1.61 · q = 1.7e-60GLUL: −1.54 · q = 1.9e-60SLC39A9: −1.52 · q = 2.1e-60CAPSL: −1.15 · q = 2.1e-60ETFBKMT: −1.69 · q = 2.3e-60CACNA1F: −1.2 · q = 2.7e-60CCNB1: 1.31 · q = 2.8e-60RAD51AP1: 1.66 · q = 3e-60PTGER3: −1.52 · q = 3.1e-60TNS2: −1.68 · q = 3.4e-60CFAP20: 1.57 · q = 3.4e-60GLIPR1L2: −1.46 · q = 3.8e-60GPD1L: −1.72 · q = 4.5e-60GRIK3: −1.51 · q = 4.6e-60MCM2: 1.58 · q = 5.3e-60TUBA3C: −1.07 · q = 5.3e-60SPEF2: −1.78 · q = 8.9e-60GMPS: 1.68 · q = 9.4e-60PRIM2: 1.58 · q = 9.7e-60IVD: −1.79 · q = 9.7e-60TSPAN31: −1.49 · q = 1e-59LRBA: −1.52 · q = 1.1e-59CEACAM5: −1.39 · q = 1.1e-59CENPI: 1.3 · q = 1.1e-59GSTM3: −1.4 · q = 1.8e-59KIF11: 1.34 · q = 1.8e-59ZBTB42: −1.74 · q = 2.1e-59TTC7A: 1.56 · q = 2.1e-59CCDC74B: −1.45 · q = 2.2e-59CPLX1: −1.55 · q = 2.3e-59CACNA1D: −1.69 · q = 2.3e-59CXXC5: −1.81 · q = 2.4e-59NUMA1: −1.48 · q = 2.7e-59ZFYVE16: −1.62 · q = 2.8e-59KCTD3: −1.46 · q = 2.8e-59C9ORF40: 1.77 · q = 2.9e-59CST2: −1.52 · q = 3e-59EFCAB6: −1.81 · q = 3.7e-59KARS1: 1.59 · q = 3.8e-59CFAP90: −1.56 · q = 4.1e-59RAPGEF3: −1.54 · q = 4.2e-59SLC16A10: 1.45 · q = 4.9e-59KIF12: −1.51 · q = 5e-59ZBTB4: −1.52 · q = 5e-59LINC00593: −0.991 · q = 5.1e-59ARHGEF39: 1.45 · q = 5.1e-59ADCY1: −1.32 · q = 5.2e-59AOX2P: −1.03 · q = 5.4e-59ECE2: 1.66 · q = 5.6e-59PEBP4: −1.07 · q = 5.7e-59ITPR1: −1.57 · q = 6e-59CDC6: 1.05 · q = 6.1e-59AGO2: 1.58 · q = 7.8e-59CACNG1: −1.4 · q = 8e-59TADA2B: −1.71 · q = 9e-59TOM1L2: −1.43 · q = 9.1e-59LEO1: −1.32 · q = 9.1e-59KIF5C: −1.41 · q = 9.6e-59DTWD2: −1.54 · q = 9.8e-59NDFIP1: −1.47 · q = 9.9e-59TMEM25: −1.77 · q = 1e-58ANKMY1: −1.51 · q = 1e-58GRIK1-AS1: −1.1 · q = 1.2e-58DONSON: 1.63 · q = 1.2e-58CYB5D1: −1.4 · q = 1.3e-58CYB5D2: −1.54 · q = 1.4e-58UGT8: 1.78 · q = 1.4e-58LFNG: −1.45 · q = 1.4e-58STH: −1.08 · q = 1.5e-58FUT8-AS1: −1.38 · q = 1.7e-58PVALB: −0.982 · q = 2.3e-58ADGRG6: 1.21 · q = 2.5e-58WBP1L: −1.61 · q = 2.9e-58CYP21A2: −1.58 · q = 3.1e-58GABRP: 1.45 · q = 3.4e-58LZTFL1: −1.51 · q = 3.5e-58GUSBP3: −1.45 · q = 4e-58C9ORF152: −1.93 · q = 4.2e-58COMMD10: −1.52 · q = 4.2e-58ULBP3: 1.59 · q = 4.9e-58MINDY1: −1.56 · q = 5e-58SCGB2A2: −1.39 · q = 6e-58MCM6: 1.61 · q = 6.4e-58CREB3L4: −1.63 · q = 6.5e-58DNMBP: −1.48 · q = 6.5e-58DKC1: 1.77 · q = 7e-58SYNJ2BP: −1.55 · q = 8.3e-58SPC25: 1.23 · q = 8.7e-58SLC6A11: 1.6 · q = 9e-58TMC5: −1.74 · q = 9.8e-58UQCRHL: 1.62 · q = 9.9e-58LIN7A: −1.21 · q = 1e-57DUSP9: 1.72 · q = 1e-57CENPL: 1.48 · q = 1e-57CDKN3: 1.22 · q = 1.1e-57HNRNPH2: −1.46 · q = 1.1e-57TAPT1: −1.53 · q = 1.1e-57ESPL1: 1.18 · q = 1.3e-57CDC20B: −0.887 · q = 1.6e-57EAPP: −1.58 · q = 1.7e-57RAB6C: −1.33 · q = 1.7e-57C17ORF58: −1.18 · q = 1.9e-57FAM114A2: −1.67 · q = 2.1e-57GPSM2: 1.68 · q = 2.1e-57CDIN1: 1.42 · q = 2.2e-57TMEM45B: −1.52 · q = 2.2e-57FAM136A: 1.82 · q = 2.2e-57KNSTRN: 1.45 · q = 2.5e-57PSMB2: 1.72 · q = 2.5e-57FGF10: −1.12 · q = 2.8e-57CAPN9: −1.64 · q = 3e-57MED30: 1.62 · q = 3e-57RIPK2: 1.71 · q = 3.2e-57ZNF442: −1.63 · q = 3.4e-57CFAP70: −1.47 · q = 3.4e-57POLI: −1.45 · q = 4.3e-57ZNF587: −1.39 · q = 4.4e-57L3MBTL4: 1.49 · q = 4.4e-57CYP4Z1: −1.34 · q = 4.5e-57NUDT4: −1.35 · q = 4.5e-57ZIC1: 1.6 · q = 4.5e-57FMNL2: 1.46 · q = 4.6e-57WNK4: −1.57 · q = 4.6e-57NIP7: 1.65 · q = 5.5e-57LRRC26: −1.51 · q = 8.1e-57SLC19A2: −1.33 · q = 9.3e-57NBR1: −1.41 · q = 1.1e-56SEZ6L: −1.13 · q = 1.1e-56TGFB3: −1.68 · q = 1.3e-56CDH3: 1.37 · q = 1.4e-56MCCD1: −0.926 · q = 1.5e-56POLN: −1.48 · q = 1.5e-56RHBDF2: 1.58 · q = 1.6e-56HID1: −1.83 · q = 1.9e-56MEMO1: 1.7 · q = 2e-56SYT1: −1.14 · q = 2.1e-56PGGT1B: −1.56 · q = 2.2e-56VAV3: −1.74 · q = 2.4e-56CHAC1: 1.34 · q = 2.6e-56TCEAL6: −1.38 · q = 2.7e-56SPG11: −1.61 · q = 2.9e-56MSL3: 1.61 · q = 3.4e-56CCNH: −1.59 · q = 3.6e-56RP1: −1.16 · q = 3.8e-56ADCY9: −1.55 · q = 4.3e-56STAC: 1.63 · q = 5e-56TMEM65: 1.39 · q = 5e-56STK38: 1.73 · q = 5.7e-56NPAS1: −1.38 · q = 5.9e-56RAB5B: −1.57 · q = 6.3e-56CCDC30: −1.63 · q = 6.4e-56RANBP1: 1.65 · q = 6.5e-56SLC9A6: 1.29 · q = 6.8e-56EEIG1: −1.53 · q = 6.9e-56TBX19: 1.71 · q = 7.4e-56POP1: 1.66 · q = 7.7e-56KIAA0040: −1.74 · q = 7.8e-56BCL2: −1.61 · q = 9.1e-56UGCG: −1.38 · q = 9.2e-56MACIR: −1.62 · q = 1.1e-55CISH: −1.53 · q = 1.1e-55KRT16: 1.61 · q = 1.2e-55HDGF: 1.68 · q = 1.4e-55UTP4: 1.63 · q = 1.4e-55CDC7: 1.5 · q = 1.4e-55SLC46A1: −1.46 · q = 1.8e-55CTSV: 1.71 · q = 1.9e-55KCNC2: −0.895 · q = 2e-55COA7: 1.47 · q = 2.1e-55C4A: −1.71 · q = 2.5e-55FYCO1: −1.59 · q = 2.6e-55COQ7: −1.57 · q = 3.3e-55RNASEH1: 1.69 · q = 3.3e-55ERCC6L: 1.29 · q = 3.6e-55PELI1: 1.33 · q = 3.7e-55SLC27A2: −1.29 · q = 3.7e-55FEN1: 1.38 · q = 4.8e-55LINC00160: −1.39 · q = 4.9e-55DELE1: −1.64 · q = 5.5e-55PRAME: 1.34 · q = 5.7e-55IFT88: −1.56 · q = 6.2e-55YBX3: 1.3 · q = 6.3e-55SFRP1: 1.16 · q = 6.6e-55FBXL17: −1.6 · q = 7.6e-55GINS4: 1.48 · q = 8e-55LEMD1: 1.91 · q = 1.1e-54HACD3: −1.39 · q = 1.4e-54CLCN5: 1.51 · q = 1.4e-54SYBU: −1.69 · q = 1.5e-54CMBL: −1.96 · q = 1.6e-54RIBC1: −1.52 · q = 1.7e-54ASB16: −1.22 · q = 1.7e-54ARL9: 1.73 · q = 1.7e-54BTF3: −1.54 · q = 1.7e-54ART3: 1.98 · q = 1.8e-54BBS5: −1.57 · q = 2e-54NUSAP1: 1.21 · q = 2.1e-54TSPAN15: −1.66 · q = 2.3e-54CHAC2: 1.51 · q = 2.4e-54PAK1IP1: 1.71 · q = 2.4e-54PEX11A: −1.53 · q = 2.6e-54CCDC18: 1.51 · q = 2.6e-54FER1L5: −1.08 · q = 2.7e-54MTBP: 1.41 · q = 2.9e-54RFC4: 1.74 · q = 2.9e-54EPB41L5: −1.51 · q = 3.1e-54GJB3: 1.67 · q = 3.1e-54SPAG5: 1.12 · q = 3.3e-54NXPH3: −1.43 · q = 3.6e-54PSMD7: 1.37 · q = 3.6e-54CFAP157: −1.16 · q = 3.8e-54TYMS: 1.51 · q = 3.8e-54TSPAN33: 1.51 · q = 4e-54SLC18A2: −1.27 · q = 4.6e-54MCM5: 1.59 · q = 4.6e-54MFSD2B: 1.5 · q = 4.7e-54SF3B3: 1.49 · q = 4.7e-54CYB5R1: −1.52 · q = 4.9e-54FAM72D: 1.51 · q = 5e-54PEX12: −1.39 · q = 5.2e-54IGSF9B: −1.52 · q = 5.5e-54NPNT: −1.63 · q = 5.8e-54TPCN1: −1.55 · q = 5.9e-54NEK2: 1.15 · q = 7e-54PLIN5: −1.4 · q = 7.3e-54CERT1: −1.57 · q = 7.5e-54GPT2: 1.43 · q = 8.2e-54KRT18: −1.63 · q = 8.5e-54NUDT12: −1.8 · q = 9.3e-54TCF7L1: 1.36 · q = 9.4e-54HCAR1: −1.73 · q = 1e-53CPA3: −1.63 · q = 1.1e-53KCNG1: 1.66 · q = 1.1e-53ARFIP2: −1.44 · q = 1.1e-53TMEM62: −1.48 · q = 1.1e-53TCF19: 1.61 · q = 1.1e-53MEX3A: 1.44 · q = 1.2e-53SPATA6L: −1.42 · q = 1.2e-53CFAP210: −1.6 · q = 1.2e-53GABBR2: 1.89 · q = 1.2e-53POC5: −1.4 · q = 1.2e-53FAAH: −1.6 · q = 1.3e-53RBM28: 1.69 · q = 1.3e-53GPR19: 1.45 · q = 1.3e-53JOSD1: 1.56 · q = 1.4e-53DAZAP2: −1.54 · q = 1.5e-53UBXN2A: 1.83 · q = 1.5e-53SRD5A1: 1.53 · q = 1.6e-53DEK: 1.75 · q = 1.8e-53TBC1D1: 1.37 · q = 1.9e-53GAL: 1.7 · q = 2e-53C3ORF18: −1.45 · q = 2.1e-53NHSL1: 1.36 · q = 2.1e-53CYB5A: −1.58 · q = 2.1e-53RETREG1: −1.41 · q = 2.2e-53LONRF2: −1.76 · q = 2.4e-53RALGAPA1: −1.56 · q = 2.5e-53LYPD6: −1.32 · q = 2.6e-53NEK11: −1.57 · q = 2.6e-53NCS1: 1.46 · q = 2.7e-53HHAT: −1.76 · q = 2.7e-53PLEKHF2: −1.32 · q = 2.8e-53FAM120AOS: −1.55 · q = 3e-53RALGPS2: −1.82 · q = 3.3e-53ROPN1B: 1.79 · q = 3.5e-53TRIM23: −1.48 · q = 3.7e-53MAN2B2: −1.68 · q = 3.9e-53UQCRH: 1.64 · q = 3.9e-53GINS3: 1.36 · q = 4.1e-53FERMT1: 1.49 · q = 4.5e-53SNRPA1: 1.56 · q = 5e-53LINC03042: −0.941 · q = 5.3e-53LMNB1: 1.23 · q = 5.7e-53ZNF396: −1.58 · q = 6.1e-53ERICH3: −1.21 · q = 6.4e-53TEX10: 1.7 · q = 6.4e-53PRKAB1: −1.44 · q = 6.5e-53KATNIP: −1.46 · q = 7e-53CCDC159: −1.53 · q = 7e-53LSM2: 1.49 · q = 7.1e-53NUDCD1: 1.39 · q = 7.3e-53FANK1: −1.48 · q = 7.3e-53PPARA: 1.31 · q = 7.8e-53EMC8: 1.5 · q = 8.4e-53KCNQ4: 1.75 · q = 8.8e-53XPO5: 1.75 · q = 9e-53SCN2B: −1.29 · q = 9e-53SERBP1: 1.7 · q = 9.1e-53CAPN13: −2.14 · q = 9.2e-53ARHGEF38: −1.47 · q = 1.1e-52FRY: −1.62 · q = 1.1e-52IQCH: −1.5 · q = 1.2e-52MAP3K1: −1.38 · q = 1.3e-52MRPS30: −0.996 · q = 1.4e-52ACER2: −1.38 · q = 1.4e-52RIIAD1: −1.17 · q = 1.5e-52CST9L: −0.793 · q = 1.5e-52LRRC17: −1.65 · q = 1.6e-52ZDHHC18: 1.64 · q = 1.6e-52CEP126: −1.41 · q = 1.7e-52AMFR: −1.24 · q = 1.9e-52SLC2A10: −1.5 · q = 2e-52TOGARAM1: −1.52 · q = 2e-52ATG16L1: −1.25 · q = 2e-52AKR1E2: 1.43 · q = 2.1e-52TAF4B: 1.47 · q = 2.5e-52SLC43A3: 1.63 · q = 2.6e-52TTC39A: −1.76 · q = 2.6e-52JKAMP: −1.41 · q = 3.2e-52MREG: −1.56 · q = 3.6e-52PPP1R3C: −1.49 · q = 3.8e-52PDIA6: 1.72 · q = 3.8e-52TPRN: −1.47 · q = 3.9e-52FAF1: 1.7 · q = 4.2e-52ASNS: 1.54 · q = 4.3e-52ATP1A2: −1.4 · q = 4.4e-52NTN4: −1.34 · q = 4.7e-52RNF8: 1.71 · q = 5e-52GTPBP8: 1.59 · q = 5e-52LINC02995: −1.08 · q = 5.1e-52DESI2: 1.46 · q = 5.3e-52YPEL2: −1.41 · q = 5.4e-52ATL2: 1.75 · q = 5.6e-52NDUFAF4: 1.66 · q = 5.6e-52GDF15: −1.47 · q = 5.6e-52CYP2B6: −1.14 · q = 5.7e-52HAUS8: 1.42 · q = 6.1e-52CCDC191: −1.48 · q = 6.4e-52ULBP1: 1.49 · q = 6.9e-52DUBR: −1.21 · q = 7.2e-52PHOSPHO2: −1.55 · q = 7.7e-52NFE2L3: 1.47 · q = 7.9e-52SKP2: 1.65 · q = 8.1e-52CYP4F22: −1.27 · q = 9.9e-52ADIRF: −1.56 · q = 1.1e-51ATP6V1C2: 1.73 · q = 1.2e-51MTMR2: 1.39 · q = 1.3e-51SPTBN4: −1.43 · q = 1.3e-51CKS2: 1.38 · q = 1.3e-51GCSAML: −1.29 · q = 1.4e-51BAK1: 1.42 · q = 1.4e-51ALYREF: 1.42 · q = 1.5e-51ANKS6: 1.46 · q = 1.5e-51ATP6AP1L: −1.52 · q = 1.5e-51SLC25A19: 1.41 · q = 1.6e-51SEMA3F: −1.63 · q = 1.6e-51APPL2: −1.6 · q = 1.7e-51LRG1: −1.48 · q = 2e-51RIMS4: −1.29 · q = 2.1e-51NEK9: −1.7 · q = 2.2e-51BCDIN3D: −1.41 · q = 2.2e-51CRACDL: −1.69 · q = 2.2e-51GAMT: −1.72 · q = 2.4e-51RIOK1: 1.79 · q = 2.5e-51RD3: −1.26 · q = 2.5e-51ENPP1: −1.69 · q = 2.7e-51LMO4: 1.5 · q = 2.7e-51DRC10: −1.51 · q = 3.5e-51MYB: −1.87 · q = 3.6e-51UBE2S: 1.38 · q = 3.7e-51PDK1: 1.47 · q = 3.9e-51NT5C2: 1.48 · q = 4e-51ENTPD5: −1.12 · q = 4.1e-51ZCCHC10: −1.35 · q = 4.1e-51CHAF1B: 1.5 · q = 4.4e-51TIGD2: 1.59 · q = 4.6e-51LIMA1: −1.78 · q = 4.9e-51NASP: 1.66 · q = 5e-51PUM3: 1.78 · q = 5.1e-51SPATA20: −1.48 · q = 5.5e-51RPIA: 1.72 · q = 5.9e-51MYRIP: −1.66 · q = 6.2e-51CD46: −1.4 · q = 6.9e-51CDC25B: 1.47 · q = 6.9e-51ELOVL2: −1.25 · q = 7.1e-51FBXO15: −1.46 · q = 7.9e-51DNAJB11: 1.56 · q = 8.1e-51ZNF92: −1.12 · q = 8.4e-51GTPBP4: 1.82 · q = 9.1e-51POU5F1: 1.92 · q = 9.1e-51TTLL9: −1.12 · q = 9.9e-51TIMM8A: 1.55 · q = 1e-50LINC02872: 1.92 · q = 1e-50CASQ1: −1.12 · q = 1.1e-50SEPSECS: −1.54 · q = 1.2e-50ASB8: −1.42 · q = 1.2e-50NME5: −1.46 · q = 1.2e-50PDCD5: 1.65 · q = 1.3e-50PHYHD1: −1.47 · q = 1.4e-50TMCC2: 1.75 · q = 1.4e-50HORMAD1: 1.85 · q = 1.5e-50COQ6: −1.31 · q = 1.5e-50RAD54B: 1.18 · q = 1.6e-50ADAMTSL5: −1.48 · q = 1.6e-50IGFBP4: −1.56 · q = 1.7e-50TBC1D31: 1.2 · q = 1.8e-50TMEM63C: −1.82 · q = 1.9e-50RRP1B: 1.65 · q = 2e-50CCDC24: −1.42 · q = 2.2e-50PBK: 1.18 · q = 2.3e-50AGBL2: −1.34 · q = 2.3e-50RAB27B: −1.64 · q = 2.4e-50CDC25C: 1.04 · q = 2.5e-50CCDC40: −1.64 · q = 2.6e-50LYAR: 1.67 · q = 2.7e-50ZNF814: −1.39 · q = 2.8e-50SSH3: −1.52 · q = 3e-50ELF5: 1.49 · q = 3e-50CGRRF1: −1.56 · q = 3.8e-50BECN1: −1.37 · q = 4.2e-50PIH1D2: −1.38 · q = 4.4e-50NUBPL: −1.53 · q = 4.5e-50CYP2A6: −0.908 · q = 4.7e-50DDIAS: 1.33 · q = 4.8e-50B3GNT4: 1.5 · q = 5.1e-50PARPBP: 1.29 · q = 5.4e-50RGS11: −1.47 · q = 5.8e-50SMC1B: 1.53 · q = 5.9e-50C1QTNF7: −1.41 · q = 6.1e-50PTPRN2: −1.08 · q = 6.8e-50HTR7P1: −1.01 · q = 7.1e-50RAP2B: 1.43 · q = 7.8e-50GRIK4: −1.21 · q = 9.5e-50IGBP1: −1.57 · q = 1e-49NUS1: 1.34 · q = 1.1e-49PLIN2: 1.26 · q = 1.2e-49FOXP1: −1.65 · q = 1.3e-49GPR156: 1.71 · q = 1.3e-49HROB: 1.28 · q = 1.3e-49PAX2: −1.35 · q = 1.4e-49MYO10: 1.34 · q = 1.4e-49HMMR: 1.2 · q = 1.4e-49SREK1: −1.4 · q = 1.5e-49DDN: 1.79 · q = 1.6e-49LRP2BP: −1.41 · q = 1.7e-49ZNF446: −1.46 · q = 1.8e-49SLC26A1: −1.42 · q = 1.9e-49DUSP4: −1.32 · q = 1.9e-49FAM174B: −1.89 · q = 1.9e-49YBX3P1: 1.27 · q = 1.9e-49HOXB2: −1.21 · q = 1.9e-49KIF4B: 1.32 · q = 1.9e-49HRC: −1.32 · q = 2e-49MCM4: 1.38 · q = 2.2e-49PROM1: 1.22 · q = 2.2e-49IFT46: −1.43 · q = 2.4e-49ANKLE1: 1.66 · q = 2.5e-49SERHL2: −1.02 · q = 2.6e-49LAPTM4B: 1.1 · q = 3e-49MSX2: −1.69 · q = 3.2e-49CCDC196: −0.748 · q = 3.4e-49SPOP: −1.21 · q = 3.4e-49GPN1: 1.73 · q = 3.5e-49CMYA5: −1.56 · q = 3.5e-49NCAPD2: 1.82 · q = 3.9e-49CERS6: −1.37 · q = 3.9e-49SLC35G1: 1.2 · q = 4.1e-49BMPR1B: −1.06 · q = 4.2e-49TAF5: 1.63 · q = 4.3e-49PIM1: 1.38 · q = 4.3e-49LPIN1: 1.68 · q = 4.7e-49NHERF1: −1.23 · q = 5.2e-49HDC: −1.19 · q = 5.2e-49MARCO: 1.49 · q = 5.3e-49SPTLC2: −1.22 · q = 5.4e-49CYP39A1: 1.25 · q = 5.5e-49MEIS3P1: −1.51 · q = 5.6e-49TBX3: −1.51 · q = 6.7e-49CSNK2A2: 1.32 · q = 6.7e-49SH3BP1: 1.41 · q = 7.4e-49CLIC6: −1.06 · q = 7.6e-49NKAIN1: −1.26 · q = 7.6e-49FAH: −1.37 · q = 7.7e-49DUSP5: −1.41 · q = 8e-49SERPINA5: −1.36 · q = 8.7e-49DNMT3B: 1.43 · q = 8.7e-49NPM2: 1.51 · q = 1e-48CNGA3: −1.04 · q = 1.1e-48ILF2: 1.67 · q = 1.1e-48MRAS: 1.52 · q = 1.2e-48LMNB2: 1.54 · q = 1.3e-48INCENP: 1.46 · q = 1.5e-48CBFB: 1.31 · q = 1.5e-48PLAT: −1.31 · q = 1.7e-48ZFYVE1: −1.42 · q = 1.8e-48FAM151B: −1.53 · q = 1.9e-48NCOA7: 1.35 · q = 2.2e-48RMND1: −0.898 · q = 2.2e-48SPRYD3: −1.59 · q = 2.4e-48PRDX4: 1.47 · q = 2.9e-48CFAP77: −0.825 · q = 3e-48SMPD3: −1.33 · q = 3.5e-48DCAF13: 1.25 · q = 4.4e-48ARHGAP32: −1.31 · q = 4.7e-48CIB2: 1.28 · q = 4.9e-48CST4: −1.09 · q = 5e-48SOX11: 1.48 · q = 5.8e-48YARS1: 1.55 · q = 6.4e-48ZNF652: −1.16 · q = 6.4e-48PIGQ: −1.38 · q = 6.8e-48MAGOH: 1.61 · q = 7.2e-48TEX56P: −1.44 · q = 7.5e-48EN1: 1.77 · q = 7.5e-48ANKHD1-EIF4EBP3: −1.45 · q = 8.2e-48ST8SIA6: −1.38 · q = 8.2e-48ACOT2: −1.34 · q = 9.1e-48SEMA3B: −1.44 · q = 9.4e-48LINC00839: 1.6 · q = 9.8e-48OSCP1: −1.57 · q = 1e-47SOX9: 1.04 · q = 1.1e-47CLBA1: −1.41 · q = 1.1e-47KLF5: 1.28 · q = 1.1e-47RSU1: 1.52 · q = 1.2e-47PFKP: 1.37 · q = 1.2e-47TCTN1: −1.59 · q = 1.3e-47LAD1: 1.25 · q = 1.4e-47LCA5L: −1.42 · q = 1.4e-47WDR77: 1.53 · q = 1.5e-47PRNP: 1.18 · q = 1.5e-47RCC1: 1.37 · q = 1.5e-47SALL2: −1.53 · q = 1.5e-47CATIP: −0.935 · q = 1.6e-47TPSAB1: −1.51 · q = 1.7e-47GMNN: 1.37 · q = 1.7e-47CDK17: −1.37 · q = 1.8e-47RBM47: −1.68 · q = 2e-47RABL3: −1.36 · q = 2.1e-47GHDC: −1.41 · q = 2.2e-47ACBD4: −1.34 · q = 2.2e-47OCEL1: −1.46 · q = 2.3e-47INSYN1: −1.31 · q = 2.3e-47CSRP2: 1.42 · q = 2.5e-47EML4: 1.51 · q = 2.5e-47CDC123: 1.82 · q = 2.7e-47TPSB2: −1.48 · q = 2.7e-47PRSS23: −1.23 · q = 2.7e-47GMPR2: −1.59 · q = 2.7e-47PSME4: 1.53 · q = 2.8e-47MTERF3: 1.3 · q = 2.8e-47SPC24: 1.21 · q = 2.9e-47CSNK1A1: −1.46 · q = 3.5e-47GART: 1.47 · q = 3.5e-47CCDC71L: 1.42 · q = 4e-47FSCN1: 1.58 · q = 4.1e-47WDR62: 1.27 · q = 4.5e-47LMX1B: −1.87 · q = 5.2e-47FAM135A: 1.16 · q = 5.3e-47TMEM39B: 1.48 · q = 6.5e-47TRIM2: 1.35 · q = 6.6e-47PTPN2: 1.58 · q = 6.6e-47TYRO3: 1.24 · q = 6.8e-47CSAD: −1.33 · q = 7.1e-47EOLA1: −1.19 · q = 7.2e-47MMS22L: 1.34 · q = 7.5e-47SNRPD1: 1.4 · q = 8.2e-47TLE1: 1.01 · q = 8.3e-47ALDH6A1: −1.37 · q = 8.8e-47NUDT5: 1.67 · q = 9e-47AMY1A: 1.83 · q = 9e-47GPM6B: 1.3 · q = 9.6e-47RHBDL2: 1.38 · q = 9.8e-47TOP2A: 1 · q = 9.9e-47RMND5B: −1.47 · q = 1e-46CBLN4: −1.49 · q = 1e-46CHN2: −1.42 · q = 1.1e-46RASGEF1B: 1.31 · q = 1.1e-46PDGFD: −1.37 · q = 1.1e-46RBM17: 1.78 · q = 1.1e-46SMIM45: 1.57 · q = 1.2e-46MAPK4: 1.52 · q = 1.3e-46PLK4: 1.22 · q = 1.3e-46INTS6L: 1.18 · q = 1.4e-46DPH2: 1.58 · q = 1.5e-46TLCD3A: 1.32 · q = 1.7e-46PNPLA4: −1.7 · q = 1.7e-46KIAA0319L: −1.44 · q = 1.7e-46PRKD3: 1.22 · q = 1.7e-46ADGRB2: −1.48 · q = 1.7e-46NARF: 1.42 · q = 1.8e-46ACOT1: −1.32 · q = 1.8e-46SLC16A1: 1.38 · q = 1.9e-46GATA2: −1.32 · q = 2e-46GHRH: −0.75 · q = 2e-46SPDL1: 1.42 · q = 2e-46APBA2: 1.33 · q = 2.2e-46APLF: 1.03 · q = 2.2e-46BHLHE40: −1.6 · q = 2.2e-46QSOX2: 1.35 · q = 2.2e-46LAMP3: 1.34 · q = 2.4e-46CLDN25: −0.887 · q = 2.6e-46GLS2: −1.39 · q = 2.6e-46CHST3: 1.26 · q = 2.7e-46PHF5A: 1.5 · q = 2.8e-46CSNK1G3: −1.32 · q = 2.8e-46CCNDBP1: −1.4 · q = 2.9e-46RAB11FIP3: −1.41 · q = 3e-46LAMP5: −1.54 · q = 3.2e-46MRPL37: 1.53 · q = 3.7e-46CLGN: −1.43 · q = 3.9e-46BYSL: 1.66 · q = 4.4e-46HDAC2: 1.54 · q = 4.5e-46LINC00922: −1.41 · q = 4.7e-46TBC1D22B: 1.48 · q = 4.9e-46C1QL4: 1.79 · q = 5e-46TRIM66: −1.31 · q = 5e-46ASF1B: 1.17 · q = 5.6e-46AAGAB: −1.34 · q = 5.6e-46TONSL: 1.24 · q = 5.6e-46ATRIP: −1.23 · q = 5.8e-46RAB26: −1.47 · q = 5.8e-46CMTM7: 1.27 · q = 6e-46AGGF1: −1.42 · q = 6e-46CIPC: −1.38 · q = 6.1e-46SCNN1A: −1.75 · q = 6.2e-46LIN9: 1.37 · q = 6.3e-46CTC1: −1.33 · q = 6.6e-46FAM131C: 1.57 · q = 7e-46TAC1: −1.16 · q = 7e-46PGPEP1: −1.63 · q = 7.4e-46USP30: −1.46 · q = 7.6e-46BORA: 1.45 · q = 7.7e-46CYB561D2: −1.45 · q = 8e-46GLI3: −1.58 · q = 8.1e-46SEPHS1: 1.71 · q = 8.1e-46G6PC3: −1.28 · q = 8.4e-46SLC24A1: −1.44 · q = 9.6e-46ZNF467: −1.59 · q = 1.1e-45TMEM135: −1.28 · q = 1.2e-45PPP1CB: 1.41 · q = 1.2e-45SNED1: −1.49 · q = 1.3e-45EWSAT1: −1.3 · q = 1.3e-45KERA: −1.43 · q = 1.4e-45CA9: 1.49 · q = 1.4e-45TMEM171: 1.67 · q = 1.4e-45LINC03124: −1.19 · q = 1.5e-45WNT6: 1.61 · q = 1.5e-45HEMK1: −1.3 · q = 1.5e-45UBL3: −1.36 · q = 1.6e-45IL6ST: −1.34 · q = 1.6e-45CRAT: −1.24 · q = 1.6e-45TNFRSF21: 1.36 · q = 1.6e-45PTGR2: −1.35 · q = 1.7e-45USP6NL: 1.5 · q = 1.7e-45ORAI3: −1.51 · q = 1.7e-45IGIP: −1.52 · q = 1.7e-45CABP4: −1.15 · q = 1.8e-45HMGB3: 1.03 · q = 1.8e-45DPY19L2P4: −1.05 · q = 1.9e-45RAD17: −1.28 · q = 1.9e-45MAST4: −1.46 · q = 2e-45ADSL: 1.39 · q = 2.1e-45SLC26A9: 1.85 · q = 2.4e-45GPRIN2: 1.18 · q = 2.5e-45TMEM87B: −1.45 · q = 2.7e-45FBXO5: 1.39 · q = 3e-45ULK4: −1.45 · q = 3.2e-45DNAH9: −1.15 · q = 3.3e-45TSC22D3: −1.68 · q = 4e-45VSTM2A: −0.79 · q = 4e-45LGALS8: −1.34 · q = 4e-45SCAMP1: −1.34 · q = 4.1e-45MCF2L2: 1.4 · q = 4.1e-45HNMT: −1.45 · q = 4.4e-45NXPH1: −0.851 · q = 4.4e-45TAF11: 1.47 · q = 4.7e-45PDHA1: 1.61 · q = 5.1e-45IGF2BP2: 1.64 · q = 5.1e-45IQGAP2: −1.33 · q = 5.1e-45RBM24: −1.06 · q = 5.5e-45CYP4F30P: −0.757 · q = 6e-45SLC14A2: −1.05 · q = 6.3e-45CYP4X1: −1.32 · q = 6.4e-45ZBTB7A: −1.58 · q = 6.6e-45MRPL15: 1.51 · q = 7.3e-45RNF145: 1.23 · q = 7.5e-45GPR139: −0.745 · q = 7.5e-45ERICH5: 1.52 · q = 7.8e-45POU4F1: 1.66 · q = 9.6e-45CEP120: −1.43 · q = 1e-44MCCC1: 1.5 · q = 1e-44KIF3A: −1.24 · q = 1e-44RBM5: −1.2 · q = 1e-44FBXL7: −1.48 · q = 1e-44MCM3: 1.57 · q = 1.1e-44DNAJC2: 1.56 · q = 1.1e-44COG2: −1.32 · q = 1.1e-44PIR: 1.21 · q = 1.1e-44CCT4: 1.43 · q = 1.2e-44GCNT2: 1.12 · q = 1.2e-44TOB1: −1.24 · q = 1.2e-44RARRES1: 1.48 · q = 1.2e-44ABCA13: 1.64 · q = 1.3e-44MSN: 1.37 · q = 1.4e-44RHCG: 1.69 · q = 1.5e-44HR: 1.23 · q = 1.7e-44IFNAR2: 1.35 · q = 1.8e-44PWWP3B: −1.36 · q = 1.8e-44RHEB: 1.57 · q = 1.9e-44PTP4A2: −1.12 · q = 2e-44MPZL2: 1.15 · q = 2.1e-44SSRP1: 1.52 · q = 2.1e-44GOLGA1: −1.46 · q = 2.1e-44COG7: −1.35 · q = 2.2e-44CENPM: 1.13 · q = 2.3e-44PRLR: −1.58 · q = 2.3e-44TCAM1P: 1.65 · q = 2.5e-44GFRA3: 1.81 · q = 2.7e-44FCN2: −0.988 · q = 2.8e-44LRRC56: −1.54 · q = 2.9e-44ALAD: −1.49 · q = 3e-44PRR11: 1.22 · q = 3.3e-44PRICKLE2: −1.56 · q = 3.3e-44IGSF22: −1.22 · q = 3.4e-44TRIM29: 1.05 · q = 3.6e-44MS4A14: −1.05 · q = 4.2e-44BOP1: 1.2 · q = 4.3e-44NECAB3: −1.26 · q = 4.3e-44ANKRD24: −1.26 · q = 4.4e-44IRAK1: 1.6 · q = 4.5e-44GARS1: 1.43 · q = 4.7e-44WDR43: 1.5 · q = 5.3e-44OVGP1: −1.19 · q = 5.7e-44DDX39A: 1.4 · q = 5.9e-44TUT4: 1.04 · q = 6.1e-44SMOC1: 1.41 · q = 6.2e-44RFWD3: 1.4 · q = 6.4e-44G6PC2: −0.824 · q = 6.5e-44MSH2: 1.56 · q = 6.6e-44ELMOD2: −1.37 · q = 7.2e-44GCM1: −0.993 · q = 7.4e-44GSDMC: 1.5 · q = 7.4e-44PLOD1: 1.67 · q = 7.7e-44SMOC2: −1.43 · q = 7.9e-44ARL3: −1.36 · q = 7.9e-44PJA2: −1.38 · q = 7.9e-44PLAAT2: −1.38 · q = 8e-44CNKSR3: 0.965 · q = 8.3e-44PAPSS1: 1.61 · q = 8.3e-44C1ORF21: −1.37 · q = 8.5e-44SIGLEC17P: −1.27 · q = 8.7e-44PKMYT1: 1.06 · q = 8.9e-44CFAP53: −1.26 · q = 9.2e-44BMP4: −1.31 · q = 9.8e-44MYO5C: −1.64 · q = 1.1e-43MORN1: −1.36 · q = 1.1e-43TBPL1: 1.38 · q = 1.1e-43CCT5: 1.39 · q = 1.2e-43GDF5: 1.53 · q = 1.3e-43XPNPEP1: 1.38 · q = 1.3e-43TMEM9B: −1.4 · q = 1.4e-43SLC36A4: 1.31 · q = 1.5e-43SLC15A1: 1.66 · q = 1.5e-43CT83: 1.62 · q = 1.5e-43CIMIP6: −1.17 · q = 1.5e-43RCC2: 1.43 · q = 1.6e-43SLC22A10: −0.823 · q = 1.6e-43POLR2D: 1.49 · q = 1.7e-43SMOX: 1.25 · q = 1.7e-43POLR3G: 1.58 · q = 1.8e-43CALR: 1.32 · q = 1.8e-43SPPL2C: −0.857 · q = 1.9e-43ZIC4: 1.54 · q = 2e-43CDHR4: −0.78 · q = 2e-43TTC16: −1.22 · q = 2.1e-43SPINK4: −0.733 · q = 2.2e-43NOXRED1: −1.38 · q = 2.3e-43CERS4: −1.41 · q = 2.4e-43NAV3: −1.29 · q = 2.5e-43PNO1: 1.43 · q = 2.5e-43LETM2: −1.19 · q = 2.6e-43PDE11A: −1.42 · q = 2.6e-43SREBF1: −1.21 · q = 2.6e-43MDP1: −1.32 · q = 2.7e-43DGKD: −1.26 · q = 2.9e-43WDR25: −1.36 · q = 3.1e-43VIPR1: −1.63 · q = 3.2e-43TLCD3B: −1.14 · q = 3.2e-43MELTF: 1.54 · q = 3.5e-43NRIP1: −1.4 · q = 3.6e-43OPRK1: 1.72 · q = 3.6e-43PUS7: 1.49 · q = 3.8e-43ALKBH1: −1.24 · q = 3.9e-43ZSWIM5: −1.35 · q = 3.9e-43NRTN: 1.54 · q = 4.1e-43TXNL4B: 1.34 · q = 4.2e-43DCPS: 1.38 · q = 4.2e-43CREB3L1: −1.27 · q = 4.3e-43CMSS1: 1.48 · q = 4.4e-43DNAJC14: −1.32 · q = 4.5e-43AIF1L: 1.32 · q = 4.6e-43GLIPR2: 1.36 · q = 4.6e-43AHI1-DT: −1.16 · q = 5.1e-43IGF2BP3: 1.91 · q = 5.2e-43VPS39: −1.55 · q = 5.4e-43SERPINA4: −0.929 · q = 5.7e-43MYOZ3: −1.13 · q = 5.8e-43DNAI1: −1.09 · q = 5.8e-43RACGAP1: 1.09 · q = 6e-43CFAP44: −1.35 · q = 6e-43ENY2: 1.24 · q = 6.2e-43ATAD2: 1.15 · q = 6.3e-43MRPS5: 1.5 · q = 6.7e-43DNMBP-AS1: −1.15 · q = 6.8e-43LRFN2: −1.49 · q = 6.8e-43PIGH: −1.36 · q = 7e-43BPIFB1: −1.58 · q = 7.2e-43PNMA3: 1.52 · q = 7.3e-43ZC3H10: −1.3 · q = 7.6e-43ABRACL: 1.37 · q = 7.9e-43TRIT1: 1.41 · q = 8.1e-43FABP5: 1.39 · q = 8.2e-43MATN3: −1.5 · q = 8.4e-43EDDM3B: −0.669 · q = 8.8e-43HGD: −1.19 · q = 9.2e-43HOGA1: −1.21 · q = 9.7e-43NXN: 1.16 · q = 9.8e-43POLK: −1.28 · q = 1e-42NFATC4: −1.3 · q = 1.1e-42SH3D21: −1.12 · q = 1.1e-42SYNCRIP: 1.37 · q = 1.2e-42SLC25A37: 1.36 · q = 1.3e-42EFNA5: 1.08 · q = 1.4e-42TRDMT1: 1.29 · q = 1.4e-42TGFA: 1.29 · q = 1.5e-42GOLM2: −1.35 · q = 1.5e-42RAB17: −1.81 · q = 1.6e-42TTC13: 1.35 · q = 1.7e-42SLC25A13: 1.36 · q = 1.8e-42RBKS: −1.42 · q = 1.8e-42CLSPN: 1.21 · q = 1.9e-42SLC25A48: −1 · q = 2e-42FEM1C: −1.22 · q = 2.1e-42NECTIN2: −1.41 · q = 2.1e-42SCLT1: 1.37 · q = 2.2e-42SUGT1P3: −1.22 · q = 2.2e-42MS4A7: −1.19 · q = 2.2e-42RETREG3: −1.21 · q = 2.4e-42PBX1: −1.31 · q = 2.8e-42RAB19: −1.42 · q = 2.8e-42TMEM229B: −1.41 · q = 2.8e-42CCDC77: 1.71 · q = 2.8e-42GPR161: 1.42 · q = 3.1e-42CIT: 1.12 · q = 3.3e-42PHF12: −1.1 · q = 3.6e-42GLUD1: −1.31 · q = 3.8e-42SFXN2: −1.27 · q = 3.8e-42CSTB: 1.54 · q = 3.9e-42PGM1: 1.36 · q = 4.1e-42C16ORF87: 1.09 · q = 4.3e-42UGT2B11: −0.878 · q = 4.3e-42CCDC160: −1.37 · q = 4.3e-42UTP11: 1.6 · q = 4.3e-42MIDEAS: −1.24 · q = 4.4e-42EEF1A2: −1.36 · q = 4.4e-42TRIM8: −1.39 · q = 4.5e-42SERPINB5: 1.19 · q = 4.6e-42SLC22A4: −1.12 · q = 4.6e-42MASTL: 1.53 · q = 4.7e-42SMC4: 1.3 · q = 4.8e-42ACE2: 1.38 · q = 5.3e-42C5ORF34: 1.42 · q = 5.3e-42FAM98A: 1.37 · q = 5.4e-42SRMS: −1.7 · q = 5.4e-42TAT: −0.878 · q = 5.7e-42STAM2: −1.35 · q = 6e-42SYNPO2L: −0.831 · q = 6.2e-42ACTR3: 1.24 · q = 6.6e-42CORO1C: 1.24 · q = 6.8e-42TMEM123: 1.3 · q = 6.8e-42FRAT1: −1.44 · q = 6.8e-42EPB41L4A: −1.44 · q = 6.9e-42ZCCHC24: −1.42 · q = 7.1e-42ABCG1: −1.51 · q = 7.1e-42GALNTL6: −1.13 · q = 7.3e-42SCUBE1: −1.21 · q = 7.5e-42TK1: 1.15 · q = 7.8e-42KRT6B: 1.26 · q = 8.3e-42CLEC3A: −0.84 · q = 9.6e-42NBEA: −1.61 · q = 9.6e-42SLC12A2-DT: −1.33 · q = 9.8e-42FAM13B: −1.39 · q = 1e-41PADI2: 1.39 · q = 1e-41PRR29: −1.14 · q = 1e-41C1GALT1: 1.29 · q = 1.1e-41TMEM205: −1.39 · q = 1.1e-41HLA-DOB: 1.21 · q = 1.1e-41PCDHB9: 1.23 · q = 1.1e-41ATP1B3: 1.48 · q = 1.2e-41EBF4: −1.36 · q = 1.2e-41ZNF563: −1.33 · q = 1.2e-41SFXN5: −1.13 · q = 1.2e-41SARAF: −1.21 · q = 1.3e-41NAE1: 1.36 · q = 1.3e-41MOB3B: 1.23 · q = 1.3e-41ZNF799: −1.37 · q = 1.3e-41CACFD1: −1.41 · q = 1.4e-41CEACAM19: 1.47 · q = 1.4e-41RANBP3L: −1.21 · q = 1.5e-41OTX1: 1.43 · q = 1.5e-41EVA1B: −1.11 · q = 1.5e-41TMC4: −1.58 · q = 1.6e-41FGFBP1: 1.48 · q = 1.6e-41NMT2: 1.21 · q = 1.7e-41TMED7: −1.24 · q = 1.7e-41SLC38A11: −1.2 · q = 1.8e-41DNAJC1: −1.03 · q = 1.8e-41ITPK1: −1.23 · q = 1.8e-41CXCL5: 1.73 · q = 1.8e-41TEX30: 1.5 · q = 1.9e-41RPF2: 1.36 · q = 2e-41FDXACB1: −1.26 · q = 2e-41PPP1R14B: 1.26 · q = 2.1e-41RELT: 1.18 · q = 2.1e-41PLA2G12A: −1.33 · q = 2.2e-41FABP7: 1.42 · q = 2.2e-41LANCL3: 1.52 · q = 2.3e-41CPEB4: −1.28 · q = 2.4e-41ACVR1B: −1.44 · q = 2.5e-41MKRN3: 1.4 · q = 2.5e-41ITGB8: 0.975 · q = 2.5e-41ABCC12: −0.885 · q = 2.6e-41ADCY5: −1.14 · q = 2.7e-41GRM4: −1.08 · q = 2.8e-41CEBPG: 1.53 · q = 2.9e-41IKBKB: −1.2 · q = 3.2e-41RECQL4: 1.14 · q = 3.2e-41NUTF2: 1.33 · q = 3.3e-41KCNMA1: −1.26 · q = 3.4e-41CDCA4: 1.36 · q = 3.4e-41SIGLEC15: −1.17 · q = 3.5e-41ENTPD8: −1.33 · q = 3.5e-41SGO2: 1.22 · q = 3.8e-41SLC24A2: −1.27 · q = 3.8e-41HEMK2: −1.23 · q = 3.9e-41AURKAP1: 1.31 · q = 4e-41CYP4F29P: −1.13 · q = 4.1e-41DUSP28: −1.26 · q = 4.5e-41SLC29A3: −1.11 · q = 4.5e-41PACC1: 1.43 · q = 4.6e-41CFAP45: −1.15 · q = 4.6e-41ADAT2: 1.26 · q = 5.1e-41LSM6: 1.36 · q = 5.3e-41UBASH3B: 1.54 · q = 5.3e-41AP1G2: −1.4 · q = 5.5e-41NUDT16L1: −1.24 · q = 5.7e-41EFHC1: −1.38 · q = 5.8e-41AHNAK: −1.47 · q = 6.1e-41NCAPG2: 1.35 · q = 6.2e-41SPARCL1: −1.3 · q = 6.5e-41LINC02447: −1.3 · q = 6.6e-41TKFC: −1.28 · q = 6.8e-41ST3GAL6: 1.43 · q = 6.8e-41LYPD6B: −1.27 · q = 6.8e-41JADE2: −1.46 · q = 7.1e-41SCHIP1: 1.5 · q = 7.2e-41BCL11ACDCA7CDC20KIF2CCENPAAURKBTTC36FSIP1SRARPDRAICNAT1MAPT-IT1← higher in Luminal Ahigher in Basal-like →Gene-set enrichmentpreranked GSEA, 1,000 permutations · bars are q < 0.05 when solide2f targets3.7 · q = 0.0088g2m checkpoint3.4 · q = 0.0088myc targets v13.2 · q = 0.0088estrogen response early−2.8 · q = 0.0088myc targets v22.6 · q = 0.0088mtorc1 signaling2.5 · q = 0.0088mitotic spindle2.3 · q = 0.0088allograft rejection2.3 · q = 0.0088estrogen response late−2.2 · q = 0.0088interferon gamma response2 · q = 0.0088unfolded protein response1.9 · q = 0.0088glycolysis1.7 · q = 0.0088−4−2024NES← higher in Luminal Ahigher in Basal-like →+38 more sets tested (23 of 50 at q < 0.05) — every set is in the result and the MCP texte2f targets — ES 0.78, 132 leading-edge genes−0.20.00.20.40.60.8ES5,00010,00015,00020,000← higher in Basal-likegene rank, of 20,006higher in Luminal A →estrogen response early — ES −0.63, 99 leading-edge genes−0.8−0.6−0.4−0.20.00.2ES5,00010,00015,00020,000← higher in Basal-likegene rank, of 20,006higher in Luminal A →Welch's t-test per gene on rna_seq_v2_mrna_median_all_sample_Zscores as stored, Basal-like minus Luminal A, each patient contributing the mean of their samples;computed from three running totals per gene and cohort, so it is exact across sites. 20,006 genes tested, 14 left out (fewer than 3 patients with a value in a cohort, or novariance); q is Benjamini–Hochberg across every gene tested. The 1500 most significant genes are drawn as points, the rest as density. Z-scores are standardised withineach study, so a difference is in study-specific units. A t-test on thousands of patients finds tiny differences significant — read the effect, not only the q. Enrichment ispreranked GSEA on the unrounded t (Subramanian et al. 2005, weight 1), significance from 1000 random sets of the same size drawn from the same ranking, seeded bythe set's name so a shared link reproduces it; p = (b+1)/(m+1) over the same-sign nulls, q is Benjamini–Hochberg across the sets tested (not GSEA's own NES-basedFDR). Gene-set permutation ignores gene–gene correlation, so it is anti-conservative next to phenotype permutation, which needs patient-level values. diff --git a/test/snapshots/diffexpr.txt b/test/snapshots/diffexpr.txt new file mode 100644 index 0000000..49717b3 --- /dev/null +++ b/test/snapshots/diffexpr.txt @@ -0,0 +1,33 @@ +Analysis over brca_tcga_pan_can_atlas_2018 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Basal-like: 171 patients — SUBTYPE in [BRCA_Basal] +- Luminal A: 499 patients — SUBTYPE in [BRCA_LumA] + +Differential expression, Basal-like vs Luminal A on rna_seq_v2_mrna_median_all_sample_Zscores: 20,006 genes tested, 7,563 higher in Basal-like and 7,698 higher in Luminal A at q<0.05 (difference in mean z-score). + most significant, higher in Basal-like: BCL11A +1.72 (q=2.7e-139), CDCA7 +1.82 (q=2.2e-136), CDC20 +1.90 (q=3.2e-130), KIF2C +1.80 (q=4.7e-120), CENPA +1.86 (q=3.2e-119), AURKB +1.80 (q=8.8e-115), ORC6 +1.71 (q=1.2e-114), PLK1 +1.72 (q=1.4e-114), PSAT1 +1.91 (q=2.4e-112), HJURP +1.66 (q=1.4e-108), FOXC1 +2.00 (q=6.1e-107), PIMREG +1.83 (q=2.8e-106) + most significant, higher in Luminal A: TTC36 -2.15 (q=1.6e-215), FSIP1 -1.99 (q=2.3e-200), SRARP -2.44 (q=1.7e-196), DRAIC -2.09 (q=2.8e-186), NAT1 -1.93 (q=1.1e-178), MAPT-IT1 -1.89 (q=6.7e-172), CT62 -2.45 (q=1.8e-153), SLC7A13 -1.92 (q=9.7e-153), CYP2B7P -1.78 (q=1.4e-146), TFF1 -2.24 (q=1.0e-145), NEK10 -1.78 (q=1.5e-143), ABCC8 -2.27 (q=9.8e-142) + GSEA (Welch t, Basal-like over Luminal A; 1000 gene-set permutations): + HALLMARK_E2F_TARGETS: NES 3.67, q=0.0088, 200 genes, leading edge CDC20 CDCA8 KIF2C AURKB ORC6 CCNE1 PLK1 CTPS1 … + HALLMARK_G2M_CHECKPOINT: NES 3.42, q=0.0088, 200 genes, leading edge CDC20 CENPA KIF2C AURKB ORC6 TTK PLK1 TPX2 … + HALLMARK_MYC_TARGETS_V1: NES 3.23, q=0.0088, 200 genes, leading edge CDC20 CTPS1 IFRD1 CDC45 CCNA2 SRPK1 MCM7 KPNA2 … + HALLMARK_ESTROGEN_RESPONSE_EARLY: NES -2.76, q=0.0088, 199 genes, leading edge P2RY2 CCN5 CXCL12 MSMB BLVRB OLFM1 OLFML3 DYNLT3 … + HALLMARK_MYC_TARGETS_V2: NES 2.61, q=0.0088, 58 genes, leading edge PLK1 NIP7 MCM5 NDUFAF4 BYSL MCM4 WDR43 PLK4 … + HALLMARK_MTORC1_SIGNALING: NES 2.45, q=0.0088, 200 genes, leading edge PSAT1 PLK1 CDC25A IFRD1 BUB1 AURKA SLC7A5 PHGDH … + HALLMARK_MITOTIC_SPINDLE: NES 2.30, q=0.0088, 199 genes, leading edge KIF2C TTK PLK1 TPX2 CCNB2 NDC80 BIRC5 BUB1 … + HALLMARK_ALLOGRAFT_REJECTION: NES 2.28, q=0.0088, 200 genes, leading edge RIPK2 IFNAR2 TAP2 HLA-DOB CCL7 EGFR LYN NCK1 … + HALLMARK_ESTROGEN_RESPONSE_LATE: NES -2.16, q=0.0088, 200 genes, leading edge SLC2A8 CALCR GPER1 CCN5 DCXR CXCL12 BATF BLVRB … + HALLMARK_INTERFERON_GAMMA_RESPONSE: NES 2.00, q=0.0088, 200 genes, leading edge NUP93 PSMB2 RIPK2 PELI1 PTPN2 PFKP PIM1 IFNAR2 … + HALLMARK_UNFOLDED_PROTEIN_RESPONSE: NES 1.91, q=0.0088, 113 genes, leading edge PSAT1 SLC7A5 CKS1B CEBPB DKC1 PDIA6 ASNS CHAC1 … + HALLMARK_GLYCOLYSIS: NES 1.75, q=0.0088, 200 genes, leading edge CENPA DEPDC1 AURKA KIF20A STMN1 ENO1 DSC2 CDK1 … + CAVEAT (tell the user): Welch's t-test per gene on rna_seq_v2_mrna_median_all_sample_Zscores as stored, Basal-like minus Luminal A, each patient contributing the mean of their samples; computed from three running totals per gene and cohort, so it is exact across sites. 20,006 genes tested, 14 left out (fewer than 3 patients with a value in a cohort, or no variance); q is Benjamini–Hochberg across every gene tested. The 1500 most significant genes are drawn as points, the rest as density. Z-scores are standardised within each study, so a difference is in study-specific units. A t-test on thousands of patients finds tiny differences significant — read the effect, not only the q. Enrichment is preranked GSEA on the unrounded t (Subramanian et al. 2005, weight 1), significance from 1000 random sets of the same size drawn from the same ranking, seeded by the set's name so a shared link reproduces it; p = (b+1)/(m+1) over the same-sign nulls, q is Benjamini–Hochberg across the sets tested (not GSEA's own NES-based FDR). Gene-set permutation ignores gene–gene correlation, so it is anti-conservative next to phenotype permutation, which needs patient-level values. + METHOD: + - Sum every gene's values [Basal-like · brca_tcga_pan_can_atlas_2018]: The diffexpr:moments query above, on “rna_seq_v2_mrna_median_all_sample_Zscores” as stored. Per gene, over the cohort's patients with a value (a patient with several samples contributes their average): n, Σv and Σv². Every gene in the profile, no individual value. + - Sum every gene's values [Luminal A · brca_tcga_pan_can_atlas_2018]: The diffexpr:moments query above, on “rna_seq_v2_mrna_median_all_sample_Zscores” as stored. Per gene, over the cohort's patients with a value (a patient with several samples contributes their average): n, Σv and Σv². Every gene in the profile, no individual value. + - Leave out genes that cannot be tested (20,020 → 20,006 rows): A gene with fewer than 3 patients with a value in either cohort, or with no variance (Var A + Var B ≤ 1e-9 · (1 + mean A² + mean B²) — judged to a tolerance, since a constant gene's variance from the sums is rounding noise). + - Welch's t-test per gene: Mean A − mean B (Basal-like minus Luminal A) with each cohort's variance (Σv² − (Σv)²/n)/(n − 1); unequal-variance t, Welch–Satterthwaite df, two-sided. With thousands of patients a tiny difference is significant: read the effect too. + genes tested: 20,006 + - Benjamini–Hochberg across genes: q-values over all 20,006 genes tested. + - Preranked gene-set enrichment (GSEA): Genes ranked by the unrounded t, Basal-like over Luminal A first. Enrichment score as in Subramanian et al. 2005 with weight 1 (each member's step is |t| / Σ|t| of the members). Significance from 1000 random sets of the same size drawn from the same ranking, from a generator seeded by the set's name — so a shared link gives the same p — with p = (b + 1)/(m + 1) over the m null scores of the same sign and NES = ES / mean of those. Gene-set permutation ignores correlation between genes, so it is anti-conservative next to phenotype permutation. A set with fewer than 10 ranked members is not tested. q is Benjamini–Hochberg across the sets tested. + sets tested: 50 + Welch's t from moments matches scipy 1.18.1 ttest_ind(equal_var=False) and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/moments-golden.test.ts, test/tables-golden.test.ts); enrichment scores match gseapy 1.3.1 prerank, and NES and p match the script's port of our seeded null exactly (test/gsea-golden.test.ts). diff --git a/test/snapshots/enrichment.json b/test/snapshots/enrichment.json new file mode 100644 index 0000000..c769d37 --- /dev/null +++ b/test/snapshots/enrichment.json @@ -0,0 +1,737 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Colorectal, MSS": { + "count": 4957, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample) AND NOT MSI_TYPE in [Instable] (any sample)", + "studies": [ + "msk_chord_2024" + ] + }, + "Pancreatic, MSS": { + "count": 3095, + "text": "CANCER_TYPE in [Pancreatic Cancer] (any sample) AND NOT MSI_TYPE in [Instable] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "enrichment", + "cohorts": [ + "Colorectal, MSS", + "Pancreatic, MSS" + ], + "enrichment": { + "alteration": "mutation", + "measure": "any", + "groups": [ + "Colorectal, MSS", + "Pancreatic, MSS" + ], + "tested": 494, + "untested": 8, + "significant": 316, + "minAltered": 5, + "test": "two-sided Fisher's exact test", + "rows": [ + { + "gene": "APC", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 3815, + "profiled": 4986, + "pct": 76.5 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 45, + "profiled": 3117, + "pct": 1.4 + } + ], + "log2Ratio": 5.727889517526085, + "p": 0, + "q": 0, + "enrichedIn": "Colorectal, MSS", + "cytoband": "5q22.2" + }, + { + "gene": "KRAS", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 2178, + "profiled": 4986, + "pct": 43.7 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 2518, + "profiled": 3117, + "pct": 80.8 + } + ], + "log2Ratio": -0.8869990568682424, + "p": 1.5404597664259493e-250, + "q": 3.804935623072094e-248, + "enrichedIn": "Pancreatic, MSS", + "cytoband": "12p12.1" + }, + { + "gene": "CDKN2A", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 52, + "profiled": 4986, + "pct": 1 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 629, + "profiled": 3117, + "pct": 20.2 + } + ], + "log2Ratio": -4.27420121660433, + "p": 5.002627218146018e-211, + "q": 8.237659485880442e-209, + "enrichedIn": "Pancreatic, MSS", + "cytoband": "9p21.3" + }, + { + "gene": "TCF7L2", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 547, + "profiled": 4806, + "pct": 11.4 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 3, + "profiled": 3083, + "pct": 0.1 + } + ], + "log2Ratio": 6.869932763048709, + "p": 1.3769916760974181e-117, + "q": 1.7005847199803115e-115, + "enrichedIn": "Colorectal, MSS", + "cytoband": "10q25.2-q25.3" + }, + { + "gene": "PIK3CA", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 876, + "profiled": 4986, + "pct": 17.6 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 71, + "profiled": 3117, + "pct": 2.3 + } + ], + "log2Ratio": 2.9473152122303587, + "p": 1.9289791968532027e-117, + "q": 1.9058314464909642e-115, + "enrichedIn": "Colorectal, MSS", + "cytoband": "3q26.32" + }, + { + "gene": "FBXW7", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 635, + "profiled": 4986, + "pct": 12.7 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 34, + "profiled": 3117, + "pct": 1.1 + } + ], + "log2Ratio": 3.545425212543056, + "p": 1.7529225317192021e-97, + "q": 1.4432395511154764e-95, + "enrichedIn": "Colorectal, MSS", + "cytoband": "4q31.3" + }, + { + "gene": "SOX9", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 470, + "profiled": 4986, + "pct": 9.4 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 25, + "profiled": 3117, + "pct": 0.8 + } + ], + "log2Ratio": 3.554936028924142, + "p": 2.450019178878529e-71, + "q": 1.729013534808562e-69, + "enrichedIn": "Colorectal, MSS", + "cytoband": "17q24.3" + }, + { + "gene": "BRAF", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 373, + "profiled": 4986, + "pct": 7.5 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 41, + "profiled": 3117, + "pct": 1.3 + } + ], + "log2Ratio": 2.507755087771021, + "p": 6.782245235505447e-41, + "q": 4.188036432924613e-39, + "enrichedIn": "Colorectal, MSS", + "cytoband": "7q34" + }, + { + "gene": "AMER1", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 281, + "profiled": 4986, + "pct": 5.6 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 26, + "profiled": 3117, + "pct": 0.8 + } + ], + "log2Ratio": 2.7562618742137013, + "p": 5.62219558260204e-34, + "q": 3.085960686450453e-32, + "enrichedIn": "Colorectal, MSS", + "cytoband": "Xq11.2" + }, + { + "gene": "SMAD2", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 211, + "profiled": 4986, + "pct": 4.2 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 12, + "profiled": 3117, + "pct": 0.4 + } + ], + "log2Ratio": 3.4584119601198964, + "p": 2.540614676524035e-31, + "q": 1.2550636502028733e-29, + "enrichedIn": "Colorectal, MSS", + "cytoband": "18q21.1" + }, + { + "gene": "MEN1", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 25, + "profiled": 4986, + "pct": 0.5 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 128, + "profiled": 3117, + "pct": 4.1 + } + ], + "log2Ratio": -3.033868538091408, + "p": 6.645167976593638e-31, + "q": 2.9842845276702335e-29, + "enrichedIn": "Pancreatic, MSS", + "cytoband": "11q13" + }, + { + "gene": "TP53", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 3890, + "profiled": 4986, + "pct": 78 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 2077, + "profiled": 3117, + "pct": 66.6 + } + ], + "log2Ratio": 0.2275442111627738, + "p": 3.0091713010296207e-29, + "q": 1.2387755189238605e-27, + "enrichedIn": "Colorectal, MSS", + "cytoband": "17p13.1" + }, + { + "gene": "CTNNB1", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 269, + "profiled": 4986, + "pct": 5.4 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 34, + "profiled": 3117, + "pct": 1.1 + } + ], + "log2Ratio": 2.306274793440152, + "p": 5.607452607065859e-27, + "q": 2.1308319906850266e-25, + "enrichedIn": "Colorectal, MSS", + "cytoband": "3p22.1" + }, + { + "gene": "NRAS", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 196, + "profiled": 4986, + "pct": 3.9 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 16, + "profiled": 3117, + "pct": 0.5 + } + ], + "log2Ratio": 2.9369851162490757, + "p": 2.4892795700759333e-25, + "q": 8.783600768696509e-24, + "enrichedIn": "Colorectal, MSS", + "cytoband": "1p13.2" + }, + { + "gene": "PIK3R1", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 178, + "profiled": 4986, + "pct": 3.6 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 12, + "profiled": 3117, + "pct": 0.4 + } + ], + "log2Ratio": 3.213046202379109, + "p": 5.980441658811169e-25, + "q": 1.969558786301812e-23, + "enrichedIn": "Colorectal, MSS", + "cytoband": "5q13.1" + }, + { + "gene": "PTPRT", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 315, + "profiled": 4986, + "pct": 6.3 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 58, + "profiled": 3117, + "pct": 1.9 + } + ], + "log2Ratio": 1.763502295393574, + "p": 6.702501782682423e-23, + "q": 2.069397425403198e-21, + "enrichedIn": "Colorectal, MSS", + "cytoband": "20q12-q13.11" + }, + { + "gene": "PTPRS", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 261, + "profiled": 4986, + "pct": 5.2 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 49, + "profiled": 3117, + "pct": 1.6 + } + ], + "log2Ratio": 1.7354714245885434, + "p": 7.921758421211957e-19, + "q": 2.301969800046298e-17, + "enrichedIn": "Colorectal, MSS", + "cytoband": "19p13.3" + }, + { + "gene": "EPHA3", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 176, + "profiled": 4986, + "pct": 3.5 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 24, + "profiled": 3117, + "pct": 0.8 + } + ], + "log2Ratio": 2.196744390050008, + "p": 4.382324854638452e-17, + "q": 1.2027047101063309e-15, + "enrichedIn": "Colorectal, MSS", + "cytoband": "3p11.1" + }, + { + "gene": "CARD11", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 166, + "profiled": 4986, + "pct": 3.3 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 22, + "profiled": 3117, + "pct": 0.7 + } + ], + "log2Ratio": 2.2378830848434945, + "p": 2.1477477286643954e-16, + "q": 5.5841440945274275e-15, + "enrichedIn": "Colorectal, MSS", + "cytoband": "7p22.2" + }, + { + "gene": "GRIN2A", + "cells": [ + { + "cohort": "Colorectal, MSS", + "altered": 188, + "profiled": 4986, + "pct": 3.8 + }, + { + "cohort": "Pancreatic, MSS", + "altered": 30, + "profiled": 3117, + "pct": 1 + } + ], + "log2Ratio": 1.9699735282029862, + "p": 5.309858446960977e-16, + "q": 1.3115350363993611e-14, + "enrichedIn": "Colorectal, MSS", + "cytoband": "16p13.2" + }, + { + "…": "280 more", + "sha256": "5e8d6b42f8f2c356" + } + ], + "grid": { + "xMax": 10, + "yMax": 500, + "nx": 80, + "ny": 50, + "cells": [ + [ + 44, + 0, + 30 + ], + [ + 46, + 0, + 12 + ], + [ + 47, + 0, + 8 + ], + [ + 45, + 0, + 17 + ], + [ + 42, + 0, + 31 + ], + [ + 41, + 0, + 27 + ], + [ + 51, + 0, + 4 + ], + [ + 43, + 0, + 26 + ], + [ + 48, + 0, + 3 + ], + [ + 36, + 0, + 1 + ], + [ + 33, + 0, + 1 + ], + [ + 79, + 0, + 3 + ], + [ + 50, + 0, + 1 + ], + [ + 38, + 0, + 4 + ], + [ + 49, + 0, + 4 + ], + [ + 39, + 0, + 9 + ], + [ + 37, + 0, + 3 + ], + [ + 40, + 0, + 10 + ] + ] + }, + "labels": [ + "APC", + "KRAS", + "CDKN2A", + "TCF7L2", + "PIK3CA", + "FBXW7", + "SOX9", + "BRAF", + "AMER1", + "SMAD2", + "MEN1", + "TP53" + ] + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Every gene's mutation frequency in each cohort, counted in SAMPLES over the samples profiled for that gene (a panel that lists it, or whole-exome; a sample altered off-panel counts as measured), uncalled mutations excluded as the portal excludes them. 494 genes tested with a two-sided Fisher's exact test; q is Benjamini–Hochberg across all of them. 8 altered genes were not tested: fewer than 5 altered samples across the cohorts, or not profiled in one of them. The log ratio is log2 of the first cohort's altered share over the second's, undefined (drawn at the edge) when either is zero. A gene enriched here is more often altered, not necessarily more important: a cohort holding hypermutated tumours (MSI-high, POLE) is enriched for mutations in almost every gene at once — exclude them in the cohort definition to see past that. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count altered and profiled samples per gene", + "detail": "The enrichment queries above: per gene, samples with a mutation; per gene, samples on a panel listing it (counted per panel, then joined to its genes); and the whole-exome samples, profiled for every gene.", + "scope": "Colorectal, MSS · msk_chord_2024", + "rowsOut": 502, + "params": [ + [ + "whole-exome samples", + "0" + ] + ] + }, + { + "kind": "fetch", + "title": "Count altered and profiled samples per gene", + "detail": "The enrichment queries above: per gene, samples with a mutation; per gene, samples on a panel listing it (counted per panel, then joined to its genes); and the whole-exome samples, profiled for every gene.", + "scope": "Pancreatic, MSS · msk_chord_2024", + "rowsOut": 487, + "params": [ + [ + "whole-exome samples", + "0" + ] + ] + }, + { + "kind": "transform", + "title": "Profiled = panel samples + whole-exome samples, summed across studies", + "detail": "A sample altered in a gene its panel does not list still counts as measured. Genes with fewer than 5 altered samples across the cohorts, or not profiled in one of them, are not tested.", + "params": [ + [ + "tested", + "494" + ], + [ + "not tested", + "8" + ] + ] + }, + { + "kind": "statistic", + "title": "Fisher's exact test per gene, then Benjamini–Hochberg", + "detail": "A two-sided Fisher's exact test on altered vs not among the profiled, per gene; q across every gene tested." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "enrichment:tested": { + "v": 494 + }, + "enrichment:APC:p": { + "v": 0 + }, + "enrichment:APC:q": { + "v": 0 + }, + "enrichment:KRAS:p": { + "v": 1.5404597664259493e-250 + }, + "enrichment:KRAS:q": { + "v": 3.804935623072094e-248 + }, + "enrichment:CDKN2A:p": { + "v": 5.002627218146018e-211 + }, + "enrichment:CDKN2A:q": { + "v": 8.237659485880442e-209 + }, + "enrichment:TCF7L2:p": { + "v": 1.3769916760974181e-117 + }, + "enrichment:TCF7L2:q": { + "v": 1.7005847199803115e-115 + }, + "enrichment:PIK3CA:p": { + "v": 1.9289791968532027e-117 + }, + "enrichment:PIK3CA:q": { + "v": 1.9058314464909642e-115 + }, + "enrichment:FBXW7:p": { + "v": 1.7529225317192021e-97 + }, + "enrichment:FBXW7:q": { + "v": 1.4432395511154764e-95 + }, + "enrichment:SOX9:p": { + "v": 2.450019178878529e-71 + }, + "enrichment:SOX9:q": { + "v": 1.729013534808562e-69 + }, + "enrichment:BRAF:p": { + "v": 6.782245235505447e-41 + }, + "enrichment:BRAF:q": { + "v": 4.188036432924613e-39 + }, + "enrichment:AMER1:p": { + "v": 5.62219558260204e-34 + }, + "enrichment:AMER1:q": { + "v": 3.085960686450453e-32 + }, + "enrichment:SMAD2:p": { + "v": 2.540614676524035e-31 + }, + "…": { + "more": 61, + "sha256": "1b96d5efa60a3d06" + } + } + } + } + ] +} diff --git a/test/snapshots/enrichment.sql b/test/snapshots/enrichment.sql new file mode 100644 index 0000000..4287e64 --- /dev/null +++ b/test/snapshots/enrichment.sql @@ -0,0 +1,162 @@ +-- cohort Colorectal, MSS +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable'))))) + +-- cohort Pancreatic, MSS +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable'))))) + +-- view 0 enrichment: cytobands · msk_chord_2024 +SELECT g.hugo_gene_symbol AS gene, any(rgg.cytoband) AS cytoband FROM snapshot_db.gene g +JOIN snapshot_db.reference_genome_gene rgg ON rgg.entrez_gene_id = g.entrez_gene_id +WHERE rgg.reference_genome_id = (SELECT reference_genome_id FROM snapshot_db.cancer_study WHERE cancer_study_identifier = 'msk_chord_2024') + AND g.hugo_gene_symbol IN ('APC','KRAS','CDKN2A','TCF7L2','PIK3CA','FBXW7','SOX9','BRAF','AMER1','SMAD2','MEN1','TP53','CTNNB1','NRAS','PIK3R1','PTPRT','PTPRS','EPHA3','CARD11','GRIN2A','ASXL1','MTOR','PLCG2','KDR','ERBB2','NF1','EPHA5','PIK3CG','ERBB3','PDGFRA','PTEN','AR','ALK','ZFHX3','PIK3C2G','AXIN2','EPHA7','B2M','SOX17','KDM6A','SLX4','CREBBP','FAT1','NCOR1','NOTCH3','SMO','TP53BP1','INHBA','ATM','NOTCH4','TET1','EPHB1','IKZF1','ATR','MITF','SPEN','ROS1','IRS1','DAXX','MAP3K1','FOXP1','U2AF1','PREX2','TBX3','POLE','PTCH1','HGF','ERBB4','RASA1','TGFBR2','NSD1','KMT2A','FLT4','IGF1R','DICER1','ARID1B','MUTYH','SMAD3','SMAD4','TET2','KMT2B','TEK','PPP2R1A','AXL','DNMT3B','STAT3','PIK3CD','ESR1','AKT1','GATA3','MRE11','ANKRD11','FLT3','PMS1','NSD3','CDK8','BRIP1','CTCF','TP63','MGA','LATS2','STK11','DROSHA','BRD4','KDM5A','DNMT1','PRKN','ASXL2','NTRK3','RAF1','CSF3R','PTPRD','EP300','SMARCA2','MAP2K1','LZTR1','PRDM1','POLD1','FLCN','CYLD','BMPR1A','PAK5','GLI1','ERCC4','KIT','SESN1','FGFR1','ALB','MDC1','PGR','DDR2','ALOX12B','ETV1','PTPN11','MYOD1','CASP8','NOTCH2','BRCA1','CYSLTR2','INPP4B','TERT','BARD1','ARID5B','RET','RNF43','CIC','MSH2','PAX5','JAK3','DOT1L','ELF3','CHEK2','IRF4','ERCC5','TSHR','TCF3','NEGR1','HLA-B','INSR','WT1','PHOX2B','JAK1','RECQL4','MSH3','PRKD1','MED12','FGF3','PPP6C','MALT1','TNFAIP3','INPP4A','RRAGC','RB1','STAG2','PIK3R2','UPF1','IRS2','MPL','EZH2','HNF1A','PIK3CB','LATS1','DIS3','MST1','MSI1','WWTR1','NTRK2','RAD50','JUN','SH2B3','RAD21','KDM5C','TAP2','SHQ1','CDKN1B','IDH1','MET','FLT1','CDK6','EGFR','PPM1D','NUF2','RPS6KA4','CDKN2B','LMO1','NKX3-1','RIT1','MST1R','NTRK1','FGFR3','MYC','NOTCH1','ZNRF3','GAB1','ARAF','AGO2','SESN3','MAP3K13','ERCC2','NKX2-1','H3-5','MDM4','PMS2','RECQL','NCOA3','BLM','SOS1','NBN','GNAQ','GAB2','MYD88','TAP1','ABRAXAS1','RAD54L','CDH1','PALB2','TNFRSF14','KLF5','FANCA','RAB35','XPO1','SMARCB1','SHOC2','AURKA','FYN','IL7R','E2F3','FOXF1','TOP1','MLLT1','JAK2','ERG','PRDM14','ARID2','EIF4E','HOXB13','EGFL7','SUFU','USP8','CBL','GREM1','EIF4A2','ARID1A','CXCR4','MSH6','CHEK1','DCUN1D1','FGF4','GATA2','SDHA','CDC73','FGFR2','BCL10','H3C12','COP1','ACVR1','CBFB','EPCAM','ABL1','IGF1','RPS6KB2','FGFR4','KMT5A','PPP4R2','RRAS','RAD51C','SMARCD1','NSD2','STK40','ERCC3','SDHB','CSDE1','IFNGR1','RPTOR','TGFBR1','TSC1','MAP2K4','CDK12','HLA-A','BRCA2') +GROUP BY gene + +-- view 0 enrichment: enrichment:altered:Colorectal, MSS · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable')))))) +SELECT g.hugo_gene_symbol AS gene, uniqExact(g.sample_unique_id) AS altered +FROM snapshot_db.genomic_event_derived g +WHERE g.cancer_study_identifier = 'msk_chord_2024' AND g.variant_type = 'mutation' AND g.mutation_status != 'UNCALLED' + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +GROUP BY gene + +-- view 0 enrichment: enrichment:altered:Pancreatic, MSS · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable')))))) +SELECT g.hugo_gene_symbol AS gene, uniqExact(g.sample_unique_id) AS altered +FROM snapshot_db.genomic_event_derived g +WHERE g.cancer_study_identifier = 'msk_chord_2024' AND g.variant_type = 'mutation' AND g.mutation_status != 'UNCALLED' + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +GROUP BY gene + +-- view 0 enrichment: enrichment:panels:Colorectal, MSS · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable')))))), +pc AS ( + SELECT sp.gene_panel_id AS panel, uniqExact(sp.sample_unique_id) AS n + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND sp.gene_panel_id != 'WES' AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY panel +) +SELECT gptg.gene AS gene, sum(pc.n) AS profiled +FROM snapshot_db.gene_panel_to_gene_derived gptg INNER JOIN pc ON pc.panel = gptg.gene_panel_id +GROUP BY gene + +-- view 0 enrichment: enrichment:panels:Pancreatic, MSS · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable')))))), +pc AS ( + SELECT sp.gene_panel_id AS panel, uniqExact(sp.sample_unique_id) AS n + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND sp.gene_panel_id != 'WES' AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY panel +) +SELECT gptg.gene AS gene, sum(pc.n) AS profiled +FROM snapshot_db.gene_panel_to_gene_derived gptg INNER JOIN pc ON pc.panel = gptg.gene_panel_id +GROUP BY gene + +-- view 0 enrichment: enrichment:wes:Colorectal, MSS · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable')))))) +SELECT uniqExact(sp.sample_unique_id) AS n +FROM snapshot_db.sample_to_gene_panel_derived sp +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id +WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND sp.gene_panel_id = 'WES' AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + +-- view 0 enrichment: enrichment:wes:Pancreatic, MSS · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'MSI_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Instable')))))) +SELECT uniqExact(sp.sample_unique_id) AS n +FROM snapshot_db.sample_to_gene_panel_derived sp +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id +WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND sp.gene_panel_id = 'WES' AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) diff --git a/test/snapshots/enrichment.svg b/test/snapshots/enrichment.svg new file mode 100644 index 0000000..7819c30 --- /dev/null +++ b/test/snapshots/enrichment.svg @@ -0,0 +1,2 @@ + +Alteration enrichment — mutation — Colorectal, MSS vs Pancreatic, MSS494 genes tested for mutation · 316 at q < 0.05 · two-sided Fisher's exact test0100200300400500−log₁₀ p−10−50510Log2 RatioAPC: Colorectal, MSS 76.5% (3,815 / 4,986), Pancreatic, MSS 1.4% (45 / 3,117) · q <1e-300KRAS: Colorectal, MSS 43.7% (2,178 / 4,986), Pancreatic, MSS 80.8% (2,518 / 3,117) · q 3.8e-248CDKN2A: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 20.2% (629 / 3,117) · q 8.2e-209TCF7L2: Colorectal, MSS 11.4% (547 / 4,806), Pancreatic, MSS 0.1% (3 / 3,083) · q 1.7e-115PIK3CA: Colorectal, MSS 17.6% (876 / 4,986), Pancreatic, MSS 2.3% (71 / 3,117) · q 1.9e-115FBXW7: Colorectal, MSS 12.7% (635 / 4,986), Pancreatic, MSS 1.1% (34 / 3,117) · q 1.4e-95SOX9: Colorectal, MSS 9.4% (470 / 4,986), Pancreatic, MSS 0.8% (25 / 3,117) · q 1.7e-69BRAF: Colorectal, MSS 7.5% (373 / 4,986), Pancreatic, MSS 1.3% (41 / 3,117) · q 4.2e-39AMER1: Colorectal, MSS 5.6% (281 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 3.1e-32SMAD2: Colorectal, MSS 4.2% (211 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 1.3e-29MEN1: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 4.1% (128 / 3,117) · q 3e-29TP53: Colorectal, MSS 78.0% (3,890 / 4,986), Pancreatic, MSS 66.6% (2,077 / 3,117) · q 1.2e-27CTNNB1: Colorectal, MSS 5.4% (269 / 4,986), Pancreatic, MSS 1.1% (34 / 3,117) · q 2.1e-25NRAS: Colorectal, MSS 3.9% (196 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 8.8e-24PIK3R1: Colorectal, MSS 3.6% (178 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 2e-23PTPRT: Colorectal, MSS 6.3% (315 / 4,986), Pancreatic, MSS 1.9% (58 / 3,117) · q 2.1e-21PTPRS: Colorectal, MSS 5.2% (261 / 4,986), Pancreatic, MSS 1.6% (49 / 3,117) · q 2.3e-17EPHA3: Colorectal, MSS 3.5% (176 / 4,986), Pancreatic, MSS 0.8% (24 / 3,117) · q 1.2e-15CARD11: Colorectal, MSS 3.3% (166 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 5.6e-15GRIN2A: Colorectal, MSS 3.8% (188 / 4,986), Pancreatic, MSS 1.0% (30 / 3,117) · q 1.3e-14ASXL1: Colorectal, MSS 2.6% (128 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.7e-14MTOR: Colorectal, MSS 3.0% (150 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 1.5e-13PLCG2: Colorectal, MSS 2.6% (123 / 4,806), Pancreatic, MSS 0.4% (13 / 3,083) · q 2.2e-13KDR: Colorectal, MSS 3.0% (148 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 3.3e-13ERBB2: Colorectal, MSS 3.1% (155 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 6.2e-13NF1: Colorectal, MSS 3.3% (166 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 1e-12EPHA5: Colorectal, MSS 3.6% (181 / 4,986), Pancreatic, MSS 1.0% (32 / 3,117) · q 1e-12PIK3CG: Colorectal, MSS 3.1% (156 / 4,986), Pancreatic, MSS 0.8% (25 / 3,117) · q 3.3e-12ERBB3: Colorectal, MSS 3.2% (162 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 3.3e-12PDGFRA: Colorectal, MSS 2.2% (110 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 4.1e-12PTEN: Colorectal, MSS 3.9% (192 / 4,986), Pancreatic, MSS 1.2% (38 / 3,117) · q 5e-12AR: Colorectal, MSS 2.8% (140 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 3.5e-11ALK: Colorectal, MSS 3.1% (153 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 8.1e-11ZFHX3: Colorectal, MSS 3.8% (182 / 4,806), Pancreatic, MSS 1.3% (41 / 3,083) · q 2.7e-10PIK3C2G: Colorectal, MSS 2.4% (122 / 4,986), Pancreatic, MSS 0.6% (19 / 3,117) · q 8.8e-10AXIN2: Colorectal, MSS 2.8% (141 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 1.3e-9EPHA7: Colorectal, MSS 2.5% (118 / 4,806), Pancreatic, MSS 0.6% (19 / 3,083) · q 1.6e-9B2M: Colorectal, MSS 1.5% (76 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 1.8e-9SOX17: Colorectal, MSS 2.0% (101 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 1.9e-9KDM6A: Colorectal, MSS 1.5% (74 / 4,986), Pancreatic, MSS 3.7% (116 / 3,117) · q 2.5e-9SLX4: Colorectal, MSS 2.0% (80 / 4,059), Pancreatic, MSS 0.3% (8 / 2,588) · q 4e-9CREBBP: Colorectal, MSS 2.9% (146 / 4,986), Pancreatic, MSS 1.0% (30 / 3,117) · q 6.3e-9FAT1: Colorectal, MSS 3.4% (172 / 4,986), Pancreatic, MSS 1.3% (40 / 3,117) · q 7.8e-9NCOR1: Colorectal, MSS 2.3% (117 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 8.9e-9NOTCH3: Colorectal, MSS 3.3% (163 / 4,986), Pancreatic, MSS 1.2% (37 / 3,117) · q 1e-8SMO: Colorectal, MSS 1.5% (77 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 1.9e-8TP53BP1: Colorectal, MSS 2.2% (90 / 4,059), Pancreatic, MSS 0.5% (12 / 2,588) · q 1.9e-8INHBA: Colorectal, MSS 1.7% (82 / 4,806), Pancreatic, MSS 0.3% (10 / 3,083) · q 2.1e-8ATM: Colorectal, MSS 6.0% (298 / 4,986), Pancreatic, MSS 3.1% (97 / 3,117) · q 2.3e-8NOTCH4: Colorectal, MSS 2.3% (117 / 4,986), Pancreatic, MSS 0.7% (21 / 3,117) · q 2.6e-8TET1: Colorectal, MSS 2.1% (104 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 4e-8EPHB1: Colorectal, MSS 2.9% (144 / 4,986), Pancreatic, MSS 1.0% (32 / 3,117) · q 6e-8IKZF1: Colorectal, MSS 2.0% (102 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 9.1e-8ATR: Colorectal, MSS 2.4% (118 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 1.1e-7MITF: Colorectal, MSS 1.1% (57 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 1.4e-7SPEN: Colorectal, MSS 2.3% (116 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 1.6e-7ROS1: Colorectal, MSS 2.3% (117 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 1.6e-7IRS1: Colorectal, MSS 1.7% (87 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 1.7e-7DAXX: Colorectal, MSS 0.7% (34 / 4,986), Pancreatic, MSS 2.1% (67 / 3,117) · q 1.8e-7MAP3K1: Colorectal, MSS 1.9% (93 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 1.8e-7FOXP1: Colorectal, MSS 1.5% (75 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 1.8e-7U2AF1: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 1.7% (53 / 3,117) · q 2e-7PREX2: Colorectal, MSS 4.3% (175 / 4,059), Pancreatic, MSS 1.9% (49 / 2,588) · q 3.2e-7TBX3: Colorectal, MSS 1.9% (94 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 3.9e-7POLE: Colorectal, MSS 2.5% (123 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 4.6e-7PTCH1: Colorectal, MSS 1.7% (84 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 5.5e-7HGF: Colorectal, MSS 1.8% (90 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 5.7e-7ERBB4: Colorectal, MSS 3.7% (183 / 4,986), Pancreatic, MSS 1.7% (52 / 3,117) · q 6.1e-7RASA1: Colorectal, MSS 1.6% (82 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 8.1e-7TGFBR2: Colorectal, MSS 1.7% (86 / 4,986), Pancreatic, MSS 3.6% (112 / 3,117) · q 1.8e-6NSD1: Colorectal, MSS 1.7% (86 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 1.8e-6KMT2A: Colorectal, MSS 2.6% (130 / 4,986), Pancreatic, MSS 1.0% (32 / 3,117) · q 2.1e-6FLT4: Colorectal, MSS 2.9% (147 / 4,986), Pancreatic, MSS 1.3% (39 / 3,117) · q 2.4e-6IGF1R: Colorectal, MSS 1.6% (79 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 2.6e-6DICER1: Colorectal, MSS 1.6% (82 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.6e-6ARID1B: Colorectal, MSS 2.7% (133 / 4,986), Pancreatic, MSS 1.1% (34 / 3,117) · q 3.1e-6MUTYH: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0% (0 / 3,117) · q 3.5e-6SMAD3: Colorectal, MSS 3.7% (183 / 4,986), Pancreatic, MSS 1.8% (56 / 3,117) · q 4.4e-6SMAD4: Colorectal, MSS 15.1% (752 / 4,986), Pancreatic, MSS 19.3% (603 / 3,117) · q 4.4e-6TET2: Colorectal, MSS 1.8% (91 / 4,986), Pancreatic, MSS 0.6% (18 / 3,117) · q 4.7e-6KMT2B: Colorectal, MSS 2.9% (119 / 4,059), Pancreatic, MSS 1.2% (30 / 2,588) · q 5.7e-6TEK: Colorectal, MSS 1.7% (69 / 4,059), Pancreatic, MSS 0.4% (11 / 2,588) · q 7.5e-6PPP2R1A: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 7.5e-6AXL: Colorectal, MSS 1.6% (81 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 7.7e-6DNMT3B: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 7.7e-6STAT3: Colorectal, MSS 0.7% (33 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 7.7e-6PIK3CD: Colorectal, MSS 1.5% (75 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.7e-6ESR1: Colorectal, MSS 1.8% (91 / 4,986), Pancreatic, MSS 0.6% (19 / 3,117) · q 8.7e-6AKT1: Colorectal, MSS 1.1% (56 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 8.9e-6GATA3: Colorectal, MSS 1.1% (56 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 8.9e-6MRE11: Colorectal, MSS 1.0% (49 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 1e-5ANKRD11: Colorectal, MSS 2.5% (120 / 4,806), Pancreatic, MSS 1.0% (32 / 3,083) · q 1.1e-5FLT3: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 1.1e-5PMS1: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 1.2e-5NSD3: Colorectal, MSS 1.4% (55 / 4,059), Pancreatic, MSS 0.3% (7 / 2,588) · q 1.2e-5CDK8: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 1.3e-5BRIP1: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 1.5e-5CTCF: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 1.5e-5TP63: Colorectal, MSS 1.3% (67 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 1.6e-5MGA: Colorectal, MSS 3.1% (149 / 4,806), Pancreatic, MSS 1.5% (45 / 3,083) · q 1.6e-5LATS2: Colorectal, MSS 1.8% (89 / 4,986), Pancreatic, MSS 0.6% (19 / 3,117) · q 1.6e-5STK11: Colorectal, MSS 0.6% (30 / 4,986), Pancreatic, MSS 1.7% (53 / 3,117) · q 1.7e-5DROSHA: Colorectal, MSS 1.8% (73 / 4,059), Pancreatic, MSS 0.5% (14 / 2,588) · q 1.9e-5BRD4: Colorectal, MSS 1.5% (77 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 2e-5KDM5A: Colorectal, MSS 1.5% (74 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.1e-5DNMT1: Colorectal, MSS 1.5% (75 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.1e-5PRKN: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 2.2e-5ASXL2: Colorectal, MSS 1.6% (82 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 2.5e-5NTRK3: Colorectal, MSS 2.1% (107 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 2.7e-5RAF1: Colorectal, MSS 1.1% (53 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 2.8e-5CSF3R: Colorectal, MSS 1.2% (58 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 2.8e-5PTPRD: Colorectal, MSS 2.2% (112 / 4,986), Pancreatic, MSS 0.9% (29 / 3,117) · q 2.9e-5EP300: Colorectal, MSS 2.5% (125 / 4,986), Pancreatic, MSS 1.1% (35 / 3,117) · q 3.4e-5SMARCA2: Colorectal, MSS 2.8% (45 / 1,591), Pancreatic, MSS 0.5% (6 / 1,100) · q 3.6e-5MAP2K1: Colorectal, MSS 1.0% (49 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 3.8e-5LZTR1: Colorectal, MSS 1.9% (31 / 1,591), Pancreatic, MSS 0.2% (2 / 1,100) · q 3.8e-5PRDM1: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 4.2e-5POLD1: Colorectal, MSS 1.2% (57 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 4.2e-5FLCN: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 4.4e-5CYLD: Colorectal, MSS 1.1% (44 / 4,059), Pancreatic, MSS 0.2% (5 / 2,588) · q 4.5e-5BMPR1A: Colorectal, MSS 1.2% (58 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 4.5e-5PAK5: Colorectal, MSS 1.2% (61 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 4.6e-5GLI1: Colorectal, MSS 1.6% (77 / 4,806), Pancreatic, MSS 0.6% (17 / 3,083) · q 6.2e-5ERCC4: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 8.1e-5KIT: Colorectal, MSS 1.5% (73 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 8.1e-5SESN1: Colorectal, MSS 0.7% (28 / 4,059), Pancreatic, MSS 0% (1 / 2,588) · q 8.7e-5FGFR1: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 9.3e-5ALB: Colorectal, MSS 1.3% (20 / 1,591), Pancreatic, MSS 0% (0 / 1,100) · q 1.3e-4MDC1: Colorectal, MSS 1.4% (70 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 1.6e-4PGR: Colorectal, MSS 1.7% (81 / 4,806), Pancreatic, MSS 0.6% (20 / 3,083) · q 1.9e-4DDR2: Colorectal, MSS 1.2% (61 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 2e-4ALOX12B: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 2e-4ETV1: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 2e-4PTPN11: Colorectal, MSS 0.9% (47 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 2.1e-4MYOD1: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 2.1e-4CASP8: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.4e-4NOTCH2: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.4e-4BRCA1: Colorectal, MSS 1.5% (73 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 2.6e-4CYSLTR2: Colorectal, MSS 0.8% (32 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 2.9e-4INPP4B: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 3e-4TERT: Colorectal, MSS 2.5% (124 / 4,986), Pancreatic, MSS 1.3% (39 / 3,117) · q 3e-4BARD1: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 3.1e-4ARID5B: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 3.2e-4RET: Colorectal, MSS 1.9% (94 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 3.2e-4RNF43: Colorectal, MSS 3.7% (182 / 4,986), Pancreatic, MSS 5.5% (171 / 3,117) · q 3.7e-4CIC: Colorectal, MSS 1.7% (84 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 3.9e-4MSH2: Colorectal, MSS 1.0% (50 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 4.4e-4PAX5: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 4.7e-4JAK3: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 5e-4DOT1L: Colorectal, MSS 1.7% (83 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 5.3e-4ELF3: Colorectal, MSS 2.6% (104 / 4,059), Pancreatic, MSS 1.2% (32 / 2,588) · q 5.5e-4CHEK2: Colorectal, MSS 0.7% (37 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 6.2e-4IRF4: Colorectal, MSS 0.9% (46 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 6.6e-4ERCC5: Colorectal, MSS 1.2% (59 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.1e-4TSHR: Colorectal, MSS 1.2% (59 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.1e-4TCF3: Colorectal, MSS 1.0% (47 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 8.8e-4NEGR1: Colorectal, MSS 0.9% (44 / 4,806), Pancreatic, MSS 0.3% (8 / 3,083) · q 9e-4HLA-B: Colorectal, MSS 1.0% (41 / 4,059), Pancreatic, MSS 0.3% (7 / 2,588) · q 9.2e-4INSR: Colorectal, MSS 1.0% (48 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 9.2e-4WT1: Colorectal, MSS 1.0% (48 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 9.2e-4PHOX2B: Colorectal, MSS 0.8% (42 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 9.6e-4JAK1: Colorectal, MSS 1.2% (58 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 9.8e-4RECQL4: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.001MSH3: Colorectal, MSS 1.2% (49 / 4,059), Pancreatic, MSS 0.4% (10 / 2,588) · q 0.0012PRKD1: Colorectal, MSS 2.2% (91 / 4,059), Pancreatic, MSS 1.1% (28 / 2,588) · q 0.0012MED12: Colorectal, MSS 2.2% (111 / 4,986), Pancreatic, MSS 1.2% (36 / 3,117) · q 0.0012FGF3: Colorectal, MSS 0.9% (46 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0013PPP6C: Colorectal, MSS 0.5% (24 / 4,806), Pancreatic, MSS 0.1% (2 / 3,083) · q 0.0014MALT1: Colorectal, MSS 0.5% (25 / 4,806), Pancreatic, MSS 0.1% (2 / 3,083) · q 0.0014TNFAIP3: Colorectal, MSS 0.8% (38 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.0014INPP4A: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.0015RRAGC: Colorectal, MSS 0.5% (20 / 4,059), Pancreatic, MSS 0% (1 / 2,588) · q 0.0016RB1: Colorectal, MSS 1.4% (70 / 4,986), Pancreatic, MSS 2.5% (77 / 3,117) · q 0.0017STAG2: Colorectal, MSS 1.2% (59 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0017PIK3R2: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0018UPF1: Colorectal, MSS 1.0% (42 / 4,059), Pancreatic, MSS 0.3% (8 / 2,588) · q 0.0018IRS2: Colorectal, MSS 1.6% (79 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 0.0019MPL: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0019EZH2: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 0.002HNF1A: Colorectal, MSS 0.8% (40 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.002PIK3CB: Colorectal, MSS 1.1% (53 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.002LATS1: Colorectal, MSS 1.4% (72 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0021DIS3: Colorectal, MSS 1.0% (50 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.0022MST1: Colorectal, MSS 0.5% (26 / 4,806), Pancreatic, MSS 0.1% (3 / 3,083) · q 0.0025MSI1: Colorectal, MSS 0.6% (26 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0025WWTR1: Colorectal, MSS 0.6% (26 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0025NTRK2: Colorectal, MSS 1.2% (62 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.0025RAD50: Colorectal, MSS 1.2% (62 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.0025JUN: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 0.0025SH2B3: Colorectal, MSS 1.1% (51 / 4,806), Pancreatic, MSS 0.4% (12 / 3,083) · q 0.0027RAD21: Colorectal, MSS 0.8% (38 / 4,806), Pancreatic, MSS 0.2% (7 / 3,083) · q 0.0027KDM5C: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0027TAP2: Colorectal, MSS 0.8% (32 / 4,059), Pancreatic, MSS 0.2% (5 / 2,588) · q 0.0027SHQ1: Colorectal, MSS 0.6% (30 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0028CDKN1B: Colorectal, MSS 0.6% (29 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0028IDH1: Colorectal, MSS 0.7% (33 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.0029MET: Colorectal, MSS 1.2% (60 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.0033FLT1: Colorectal, MSS 1.8% (92 / 4,986), Pancreatic, MSS 1.0% (30 / 3,117) · q 0.0034CDK6: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 0.1% (2 / 3,117) · q 0.0034EGFR: Colorectal, MSS 1.4% (69 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0035PPM1D: Colorectal, MSS 0.8% (39 / 4,806), Pancreatic, MSS 0.3% (8 / 3,083) · q 0.0036NUF2: Colorectal, MSS 0.6% (25 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0037RPS6KA4: Colorectal, MSS 0.8% (40 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 0.0037CDKN2B: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0039LMO1: Colorectal, MSS 0.4% (18 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0039NKX3-1: Colorectal, MSS 0.4% (18 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0039RIT1: Colorectal, MSS 0.4% (18 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0039MST1R: Colorectal, MSS 1.0% (47 / 4,806), Pancreatic, MSS 0.4% (11 / 3,083) · q 0.0039NTRK1: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.7% (21 / 3,117) · q 0.004FGFR3: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.0041MYC: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.0041NOTCH1: Colorectal, MSS 2.0% (102 / 4,986), Pancreatic, MSS 1.1% (35 / 3,117) · q 0.0043ZNRF3: Colorectal, MSS 1.4% (23 / 1,591), Pancreatic, MSS 0.3% (3 / 1,100) · q 0.0046GAB1: Colorectal, MSS 1.0% (16 / 1,591), Pancreatic, MSS 0.1% (1 / 1,100) · q 0.0051ARAF: Colorectal, MSS 0.8% (39 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 0.0052AGO2: Colorectal, MSS 1.1% (45 / 4,059), Pancreatic, MSS 0.4% (11 / 2,588) · q 0.0054SESN3: Colorectal, MSS 0.6% (24 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0054MAP3K13: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0054ERCC2: Colorectal, MSS 0.9% (46 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.0055NKX2-1: Colorectal, MSS 0.7% (36 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.0055H3-5: Colorectal, MSS 0.5% (24 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0056MDM4: Colorectal, MSS 0.5% (24 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0056PMS2: Colorectal, MSS 0.7% (33 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.0057RECQL: Colorectal, MSS 0.7% (30 / 4,059), Pancreatic, MSS 0.2% (5 / 2,588) · q 0.0057NCOA3: Colorectal, MSS 1.0% (50 / 4,806), Pancreatic, MSS 0.4% (13 / 3,083) · q 0.0057BLM: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.0063SOS1: Colorectal, MSS 1.2% (47 / 4,059), Pancreatic, MSS 0.5% (12 / 2,588) · q 0.0064NBN: Colorectal, MSS 0.8% (40 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0066GNAQ: Colorectal, MSS 0.4% (20 / 4,986), Pancreatic, MSS 0.1% (2 / 3,117) · q 0.0076GAB2: Colorectal, MSS 0.7% (11 / 1,591), Pancreatic, MSS 0% (0 / 1,100) · q 0.0084MYD88: Colorectal, MSS 0.5% (23 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0085TAP1: Colorectal, MSS 0.6% (26 / 4,059), Pancreatic, MSS 0.2% (4 / 2,588) · q 0.0086ABRAXAS1: Colorectal, MSS 0.5% (26 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0087RAD54L: Colorectal, MSS 0.8% (39 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0092CDH1: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0096PALB2: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0096TNFRSF14: Colorectal, MSS 0.3% (16 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0097KLF5: Colorectal, MSS 1.8% (28 / 1,591), Pancreatic, MSS 0.5% (6 / 1,100) · q 0.0099FANCA: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0099RAB35: Colorectal, MSS 0.2% (11 / 4,806), Pancreatic, MSS 0% (0 / 3,083) · q 0.01XPO1: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.01SMARCB1: Colorectal, MSS 0.8% (41 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 0.011SHOC2: Colorectal, MSS 0.5% (19 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.012AURKA: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.012FYN: Colorectal, MSS 0.8% (37 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 0.012IL7R: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.012E2F3: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.013FOXF1: Colorectal, MSS 0.9% (14 / 1,591), Pancreatic, MSS 0.1% (1 / 1,100) · q 0.013TOP1: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.014MLLT1: Colorectal, MSS 0.6% (10 / 1,591), Pancreatic, MSS 0% (0 / 1,100) · q 0.014JAK2: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.015ERG: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.015PRDM14: Colorectal, MSS 1.0% (39 / 4,059), Pancreatic, MSS 0.4% (10 / 2,588) · q 0.015ARID2: Colorectal, MSS 2.2% (112 / 4,986), Pancreatic, MSS 1.4% (44 / 3,117) · q 0.015EIF4E: Colorectal, MSS 0.3% (14 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.015HOXB13: Colorectal, MSS 0.3% (15 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.015EGFL7: Colorectal, MSS 0.3% (15 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.015SUFU: Colorectal, MSS 0.3% (15 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.015USP8: Colorectal, MSS 1.1% (17 / 1,591), Pancreatic, MSS 0.2% (2 / 1,100) · q 0.015CBL: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.016GREM1: Colorectal, MSS 0.2% (11 / 4,986), Pancreatic, MSS 0% (0 / 3,117) · q 0.017EIF4A2: Colorectal, MSS 0.5% (23 / 4,806), Pancreatic, MSS 0.1% (4 / 3,083) · q 0.018ARID1A: Colorectal, MSS 6.2% (307 / 4,986), Pancreatic, MSS 7.7% (239 / 3,117) · q 0.018CXCR4: Colorectal, MSS 0.4% (20 / 4,806), Pancreatic, MSS 0.1% (3 / 3,083) · q 0.018MSH6: Colorectal, MSS 1.5% (74 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 0.018CHEK1: Colorectal, MSS 0.5% (23 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.018DCUN1D1: Colorectal, MSS 0.4% (21 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.019FGF4: Colorectal, MSS 0.4% (21 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.019GATA2: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.021SDHA: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.021CDC73: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.021FGFR2: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.021BCL10: Colorectal, MSS 0.3% (13 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.023H3C12: Colorectal, MSS 0.3% (13 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.023COP1: Colorectal, MSS 0.7% (36 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.023ACVR1: Colorectal, MSS 0.5% (25 / 4,806), Pancreatic, MSS 0.2% (5 / 3,083) · q 0.024CBFB: Colorectal, MSS 0.3% (14 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.024EPCAM: Colorectal, MSS 0.3% (14 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.024ABL1: Colorectal, MSS 1.0% (49 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.024IGF1: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.024RPS6KB2: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.024FGFR4: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 0.024KMT5A: Colorectal, MSS 0.4% (16 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.025PPP4R2: Colorectal, MSS 0.4% (16 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.025RRAS: Colorectal, MSS 0.4% (16 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.025RAD51C: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.026SMARCD1: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.026NSD2: Colorectal, MSS 1.2% (50 / 4,059), Pancreatic, MSS 0.6% (16 / 2,588) · q 0.026STK40: Colorectal, MSS 0.4% (19 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.026ERCC3: Colorectal, MSS 0.7% (37 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 0.027SDHB: Colorectal, MSS 0.3% (17 / 4,986), Pancreatic, MSS 0.1% (2 / 3,117) · q 0.027CSDE1: Colorectal, MSS 0.9% (38 / 4,059), Pancreatic, MSS 0.4% (11 / 2,588) · q 0.031IFNGR1: Colorectal, MSS 0.5% (27 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.031RPTOR: Colorectal, MSS 1.0% (48 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.031TGFBR1: Colorectal, MSS 1.4% (69 / 4,986), Pancreatic, MSS 2.1% (65 / 3,117) · q 0.033TSC1: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 0.033MAP2K4: Colorectal, MSS 1.9% (96 / 4,986), Pancreatic, MSS 1.3% (39 / 3,117) · q 0.034CDK12: Colorectal, MSS 1.2% (60 / 4,986), Pancreatic, MSS 0.7% (21 / 3,117) · q 0.035HLA-A: Colorectal, MSS 0.8% (39 / 4,806), Pancreatic, MSS 0.4% (12 / 3,083) · q 0.036BRCA2: Colorectal, MSS 3.1% (155 / 4,986), Pancreatic, MSS 2.2% (70 / 3,117) · q 0.036APCKRASCDKN2ATCF7L2PIK3CAFBXW7SOX9BRAFAMER1SMAD2MEN1TP53← Pancreatic, MSSColorectal, MSS →the 300 most significant genes020406080100Altered frequency in Pancreatic, MSS (%)Altered frequency in Pancreatic, MSS…020406080100Altered frequency in Colorectal, MSS (%)Altered frequency in Colorectal, MSS…APC: Colorectal, MSS 76.5% (3,815 / 4,986), Pancreatic, MSS 1.4% (45 / 3,117) · q <1e-300KRAS: Colorectal, MSS 43.7% (2,178 / 4,986), Pancreatic, MSS 80.8% (2,518 / 3,117) · q 3.8e-248CDKN2A: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 20.2% (629 / 3,117) · q 8.2e-209TCF7L2: Colorectal, MSS 11.4% (547 / 4,806), Pancreatic, MSS 0.1% (3 / 3,083) · q 1.7e-115PIK3CA: Colorectal, MSS 17.6% (876 / 4,986), Pancreatic, MSS 2.3% (71 / 3,117) · q 1.9e-115FBXW7: Colorectal, MSS 12.7% (635 / 4,986), Pancreatic, MSS 1.1% (34 / 3,117) · q 1.4e-95SOX9: Colorectal, MSS 9.4% (470 / 4,986), Pancreatic, MSS 0.8% (25 / 3,117) · q 1.7e-69BRAF: Colorectal, MSS 7.5% (373 / 4,986), Pancreatic, MSS 1.3% (41 / 3,117) · q 4.2e-39AMER1: Colorectal, MSS 5.6% (281 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 3.1e-32SMAD2: Colorectal, MSS 4.2% (211 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 1.3e-29MEN1: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 4.1% (128 / 3,117) · q 3e-29TP53: Colorectal, MSS 78.0% (3,890 / 4,986), Pancreatic, MSS 66.6% (2,077 / 3,117) · q 1.2e-27CTNNB1: Colorectal, MSS 5.4% (269 / 4,986), Pancreatic, MSS 1.1% (34 / 3,117) · q 2.1e-25NRAS: Colorectal, MSS 3.9% (196 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 8.8e-24PIK3R1: Colorectal, MSS 3.6% (178 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 2e-23PTPRT: Colorectal, MSS 6.3% (315 / 4,986), Pancreatic, MSS 1.9% (58 / 3,117) · q 2.1e-21PTPRS: Colorectal, MSS 5.2% (261 / 4,986), Pancreatic, MSS 1.6% (49 / 3,117) · q 2.3e-17EPHA3: Colorectal, MSS 3.5% (176 / 4,986), Pancreatic, MSS 0.8% (24 / 3,117) · q 1.2e-15CARD11: Colorectal, MSS 3.3% (166 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 5.6e-15GRIN2A: Colorectal, MSS 3.8% (188 / 4,986), Pancreatic, MSS 1.0% (30 / 3,117) · q 1.3e-14ASXL1: Colorectal, MSS 2.6% (128 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.7e-14MTOR: Colorectal, MSS 3.0% (150 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 1.5e-13PLCG2: Colorectal, MSS 2.6% (123 / 4,806), Pancreatic, MSS 0.4% (13 / 3,083) · q 2.2e-13KDR: Colorectal, MSS 3.0% (148 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 3.3e-13ERBB2: Colorectal, MSS 3.1% (155 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 6.2e-13NF1: Colorectal, MSS 3.3% (166 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 1e-12EPHA5: Colorectal, MSS 3.6% (181 / 4,986), Pancreatic, MSS 1.0% (32 / 3,117) · q 1e-12PIK3CG: Colorectal, MSS 3.1% (156 / 4,986), Pancreatic, MSS 0.8% (25 / 3,117) · q 3.3e-12ERBB3: Colorectal, MSS 3.2% (162 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 3.3e-12PDGFRA: Colorectal, MSS 2.2% (110 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 4.1e-12PTEN: Colorectal, MSS 3.9% (192 / 4,986), Pancreatic, MSS 1.2% (38 / 3,117) · q 5e-12AR: Colorectal, MSS 2.8% (140 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 3.5e-11ALK: Colorectal, MSS 3.1% (153 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 8.1e-11ZFHX3: Colorectal, MSS 3.8% (182 / 4,806), Pancreatic, MSS 1.3% (41 / 3,083) · q 2.7e-10PIK3C2G: Colorectal, MSS 2.4% (122 / 4,986), Pancreatic, MSS 0.6% (19 / 3,117) · q 8.8e-10AXIN2: Colorectal, MSS 2.8% (141 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 1.3e-9EPHA7: Colorectal, MSS 2.5% (118 / 4,806), Pancreatic, MSS 0.6% (19 / 3,083) · q 1.6e-9B2M: Colorectal, MSS 1.5% (76 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 1.8e-9SOX17: Colorectal, MSS 2.0% (101 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 1.9e-9KDM6A: Colorectal, MSS 1.5% (74 / 4,986), Pancreatic, MSS 3.7% (116 / 3,117) · q 2.5e-9SLX4: Colorectal, MSS 2.0% (80 / 4,059), Pancreatic, MSS 0.3% (8 / 2,588) · q 4e-9CREBBP: Colorectal, MSS 2.9% (146 / 4,986), Pancreatic, MSS 1.0% (30 / 3,117) · q 6.3e-9FAT1: Colorectal, MSS 3.4% (172 / 4,986), Pancreatic, MSS 1.3% (40 / 3,117) · q 7.8e-9NCOR1: Colorectal, MSS 2.3% (117 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 8.9e-9NOTCH3: Colorectal, MSS 3.3% (163 / 4,986), Pancreatic, MSS 1.2% (37 / 3,117) · q 1e-8SMO: Colorectal, MSS 1.5% (77 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 1.9e-8TP53BP1: Colorectal, MSS 2.2% (90 / 4,059), Pancreatic, MSS 0.5% (12 / 2,588) · q 1.9e-8INHBA: Colorectal, MSS 1.7% (82 / 4,806), Pancreatic, MSS 0.3% (10 / 3,083) · q 2.1e-8ATM: Colorectal, MSS 6.0% (298 / 4,986), Pancreatic, MSS 3.1% (97 / 3,117) · q 2.3e-8NOTCH4: Colorectal, MSS 2.3% (117 / 4,986), Pancreatic, MSS 0.7% (21 / 3,117) · q 2.6e-8TET1: Colorectal, MSS 2.1% (104 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 4e-8EPHB1: Colorectal, MSS 2.9% (144 / 4,986), Pancreatic, MSS 1.0% (32 / 3,117) · q 6e-8IKZF1: Colorectal, MSS 2.0% (102 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 9.1e-8ATR: Colorectal, MSS 2.4% (118 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 1.1e-7MITF: Colorectal, MSS 1.1% (57 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 1.4e-7SPEN: Colorectal, MSS 2.3% (116 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 1.6e-7ROS1: Colorectal, MSS 2.3% (117 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 1.6e-7IRS1: Colorectal, MSS 1.7% (87 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 1.7e-7DAXX: Colorectal, MSS 0.7% (34 / 4,986), Pancreatic, MSS 2.1% (67 / 3,117) · q 1.8e-7MAP3K1: Colorectal, MSS 1.9% (93 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 1.8e-7FOXP1: Colorectal, MSS 1.5% (75 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 1.8e-7U2AF1: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 1.7% (53 / 3,117) · q 2e-7PREX2: Colorectal, MSS 4.3% (175 / 4,059), Pancreatic, MSS 1.9% (49 / 2,588) · q 3.2e-7TBX3: Colorectal, MSS 1.9% (94 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 3.9e-7POLE: Colorectal, MSS 2.5% (123 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 4.6e-7PTCH1: Colorectal, MSS 1.7% (84 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 5.5e-7HGF: Colorectal, MSS 1.8% (90 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 5.7e-7ERBB4: Colorectal, MSS 3.7% (183 / 4,986), Pancreatic, MSS 1.7% (52 / 3,117) · q 6.1e-7RASA1: Colorectal, MSS 1.6% (82 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 8.1e-7TGFBR2: Colorectal, MSS 1.7% (86 / 4,986), Pancreatic, MSS 3.6% (112 / 3,117) · q 1.8e-6NSD1: Colorectal, MSS 1.7% (86 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 1.8e-6KMT2A: Colorectal, MSS 2.6% (130 / 4,986), Pancreatic, MSS 1.0% (32 / 3,117) · q 2.1e-6FLT4: Colorectal, MSS 2.9% (147 / 4,986), Pancreatic, MSS 1.3% (39 / 3,117) · q 2.4e-6IGF1R: Colorectal, MSS 1.6% (79 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 2.6e-6DICER1: Colorectal, MSS 1.6% (82 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.6e-6ARID1B: Colorectal, MSS 2.7% (133 / 4,986), Pancreatic, MSS 1.1% (34 / 3,117) · q 3.1e-6MUTYH: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0% (0 / 3,117) · q 3.5e-6SMAD3: Colorectal, MSS 3.7% (183 / 4,986), Pancreatic, MSS 1.8% (56 / 3,117) · q 4.4e-6SMAD4: Colorectal, MSS 15.1% (752 / 4,986), Pancreatic, MSS 19.3% (603 / 3,117) · q 4.4e-6TET2: Colorectal, MSS 1.8% (91 / 4,986), Pancreatic, MSS 0.6% (18 / 3,117) · q 4.7e-6KMT2B: Colorectal, MSS 2.9% (119 / 4,059), Pancreatic, MSS 1.2% (30 / 2,588) · q 5.7e-6TEK: Colorectal, MSS 1.7% (69 / 4,059), Pancreatic, MSS 0.4% (11 / 2,588) · q 7.5e-6PPP2R1A: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 7.5e-6AXL: Colorectal, MSS 1.6% (81 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 7.7e-6DNMT3B: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 7.7e-6STAT3: Colorectal, MSS 0.7% (33 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 7.7e-6PIK3CD: Colorectal, MSS 1.5% (75 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.7e-6ESR1: Colorectal, MSS 1.8% (91 / 4,986), Pancreatic, MSS 0.6% (19 / 3,117) · q 8.7e-6AKT1: Colorectal, MSS 1.1% (56 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 8.9e-6GATA3: Colorectal, MSS 1.1% (56 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 8.9e-6MRE11: Colorectal, MSS 1.0% (49 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 1e-5ANKRD11: Colorectal, MSS 2.5% (120 / 4,806), Pancreatic, MSS 1.0% (32 / 3,083) · q 1.1e-5FLT3: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 1.1e-5PMS1: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 1.2e-5NSD3: Colorectal, MSS 1.4% (55 / 4,059), Pancreatic, MSS 0.3% (7 / 2,588) · q 1.2e-5CDK8: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 1.3e-5BRIP1: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 1.5e-5CTCF: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 1.5e-5TP63: Colorectal, MSS 1.3% (67 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 1.6e-5MGA: Colorectal, MSS 3.1% (149 / 4,806), Pancreatic, MSS 1.5% (45 / 3,083) · q 1.6e-5LATS2: Colorectal, MSS 1.8% (89 / 4,986), Pancreatic, MSS 0.6% (19 / 3,117) · q 1.6e-5STK11: Colorectal, MSS 0.6% (30 / 4,986), Pancreatic, MSS 1.7% (53 / 3,117) · q 1.7e-5DROSHA: Colorectal, MSS 1.8% (73 / 4,059), Pancreatic, MSS 0.5% (14 / 2,588) · q 1.9e-5BRD4: Colorectal, MSS 1.5% (77 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 2e-5KDM5A: Colorectal, MSS 1.5% (74 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.1e-5DNMT1: Colorectal, MSS 1.5% (75 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.1e-5PRKN: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 2.2e-5ASXL2: Colorectal, MSS 1.6% (82 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 2.5e-5NTRK3: Colorectal, MSS 2.1% (107 / 4,986), Pancreatic, MSS 0.9% (27 / 3,117) · q 2.7e-5RAF1: Colorectal, MSS 1.1% (53 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 2.8e-5CSF3R: Colorectal, MSS 1.2% (58 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 2.8e-5PTPRD: Colorectal, MSS 2.2% (112 / 4,986), Pancreatic, MSS 0.9% (29 / 3,117) · q 2.9e-5EP300: Colorectal, MSS 2.5% (125 / 4,986), Pancreatic, MSS 1.1% (35 / 3,117) · q 3.4e-5SMARCA2: Colorectal, MSS 2.8% (45 / 1,591), Pancreatic, MSS 0.5% (6 / 1,100) · q 3.6e-5MAP2K1: Colorectal, MSS 1.0% (49 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 3.8e-5LZTR1: Colorectal, MSS 1.9% (31 / 1,591), Pancreatic, MSS 0.2% (2 / 1,100) · q 3.8e-5PRDM1: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 4.2e-5POLD1: Colorectal, MSS 1.2% (57 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 4.2e-5FLCN: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 4.4e-5CYLD: Colorectal, MSS 1.1% (44 / 4,059), Pancreatic, MSS 0.2% (5 / 2,588) · q 4.5e-5BMPR1A: Colorectal, MSS 1.2% (58 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 4.5e-5PAK5: Colorectal, MSS 1.2% (61 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 4.6e-5GLI1: Colorectal, MSS 1.6% (77 / 4,806), Pancreatic, MSS 0.6% (17 / 3,083) · q 6.2e-5ERCC4: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 8.1e-5KIT: Colorectal, MSS 1.5% (73 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 8.1e-5SESN1: Colorectal, MSS 0.7% (28 / 4,059), Pancreatic, MSS 0% (1 / 2,588) · q 8.7e-5FGFR1: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 9.3e-5ALB: Colorectal, MSS 1.3% (20 / 1,591), Pancreatic, MSS 0% (0 / 1,100) · q 1.3e-4MDC1: Colorectal, MSS 1.4% (70 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 1.6e-4PGR: Colorectal, MSS 1.7% (81 / 4,806), Pancreatic, MSS 0.6% (20 / 3,083) · q 1.9e-4DDR2: Colorectal, MSS 1.2% (61 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 2e-4ALOX12B: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 2e-4ETV1: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 2e-4PTPN11: Colorectal, MSS 0.9% (47 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 2.1e-4MYOD1: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 2.1e-4CASP8: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.4e-4NOTCH2: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 2.4e-4BRCA1: Colorectal, MSS 1.5% (73 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 2.6e-4CYSLTR2: Colorectal, MSS 0.8% (32 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 2.9e-4INPP4B: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 3e-4TERT: Colorectal, MSS 2.5% (124 / 4,986), Pancreatic, MSS 1.3% (39 / 3,117) · q 3e-4BARD1: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 3.1e-4ARID5B: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 3.2e-4RET: Colorectal, MSS 1.9% (94 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 3.2e-4RNF43: Colorectal, MSS 3.7% (182 / 4,986), Pancreatic, MSS 5.5% (171 / 3,117) · q 3.7e-4CIC: Colorectal, MSS 1.7% (84 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 3.9e-4MSH2: Colorectal, MSS 1.0% (50 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 4.4e-4PAX5: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 4.7e-4JAK3: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.5% (17 / 3,117) · q 5e-4DOT1L: Colorectal, MSS 1.7% (83 / 4,986), Pancreatic, MSS 0.7% (22 / 3,117) · q 5.3e-4ELF3: Colorectal, MSS 2.6% (104 / 4,059), Pancreatic, MSS 1.2% (32 / 2,588) · q 5.5e-4CHEK2: Colorectal, MSS 0.7% (37 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 6.2e-4IRF4: Colorectal, MSS 0.9% (46 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 6.6e-4ERCC5: Colorectal, MSS 1.2% (59 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.1e-4TSHR: Colorectal, MSS 1.2% (59 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 7.1e-4TCF3: Colorectal, MSS 1.0% (47 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 8.8e-4NEGR1: Colorectal, MSS 0.9% (44 / 4,806), Pancreatic, MSS 0.3% (8 / 3,083) · q 9e-4HLA-B: Colorectal, MSS 1.0% (41 / 4,059), Pancreatic, MSS 0.3% (7 / 2,588) · q 9.2e-4INSR: Colorectal, MSS 1.0% (48 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 9.2e-4WT1: Colorectal, MSS 1.0% (48 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 9.2e-4PHOX2B: Colorectal, MSS 0.8% (42 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 9.6e-4JAK1: Colorectal, MSS 1.2% (58 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 9.8e-4RECQL4: Colorectal, MSS 1.3% (66 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.001MSH3: Colorectal, MSS 1.2% (49 / 4,059), Pancreatic, MSS 0.4% (10 / 2,588) · q 0.0012PRKD1: Colorectal, MSS 2.2% (91 / 4,059), Pancreatic, MSS 1.1% (28 / 2,588) · q 0.0012MED12: Colorectal, MSS 2.2% (111 / 4,986), Pancreatic, MSS 1.2% (36 / 3,117) · q 0.0012FGF3: Colorectal, MSS 0.9% (46 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0013PPP6C: Colorectal, MSS 0.5% (24 / 4,806), Pancreatic, MSS 0.1% (2 / 3,083) · q 0.0014MALT1: Colorectal, MSS 0.5% (25 / 4,806), Pancreatic, MSS 0.1% (2 / 3,083) · q 0.0014TNFAIP3: Colorectal, MSS 0.8% (38 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.0014INPP4A: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.0015RRAGC: Colorectal, MSS 0.5% (20 / 4,059), Pancreatic, MSS 0% (1 / 2,588) · q 0.0016RB1: Colorectal, MSS 1.4% (70 / 4,986), Pancreatic, MSS 2.5% (77 / 3,117) · q 0.0017STAG2: Colorectal, MSS 1.2% (59 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0017PIK3R2: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0018UPF1: Colorectal, MSS 1.0% (42 / 4,059), Pancreatic, MSS 0.3% (8 / 2,588) · q 0.0018IRS2: Colorectal, MSS 1.6% (79 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 0.0019MPL: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0019EZH2: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 0.002HNF1A: Colorectal, MSS 0.8% (40 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.002PIK3CB: Colorectal, MSS 1.1% (53 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.002LATS1: Colorectal, MSS 1.4% (72 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0021DIS3: Colorectal, MSS 1.0% (50 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.0022MST1: Colorectal, MSS 0.5% (26 / 4,806), Pancreatic, MSS 0.1% (3 / 3,083) · q 0.0025MSI1: Colorectal, MSS 0.6% (26 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0025WWTR1: Colorectal, MSS 0.6% (26 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0025NTRK2: Colorectal, MSS 1.2% (62 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.0025RAD50: Colorectal, MSS 1.2% (62 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.0025JUN: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 0.0025SH2B3: Colorectal, MSS 1.1% (51 / 4,806), Pancreatic, MSS 0.4% (12 / 3,083) · q 0.0027RAD21: Colorectal, MSS 0.8% (38 / 4,806), Pancreatic, MSS 0.2% (7 / 3,083) · q 0.0027KDM5C: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0027TAP2: Colorectal, MSS 0.8% (32 / 4,059), Pancreatic, MSS 0.2% (5 / 2,588) · q 0.0027SHQ1: Colorectal, MSS 0.6% (30 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0028CDKN1B: Colorectal, MSS 0.6% (29 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0028IDH1: Colorectal, MSS 0.7% (33 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.0029MET: Colorectal, MSS 1.2% (60 / 4,986), Pancreatic, MSS 0.5% (16 / 3,117) · q 0.0033FLT1: Colorectal, MSS 1.8% (92 / 4,986), Pancreatic, MSS 1.0% (30 / 3,117) · q 0.0034CDK6: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 0.1% (2 / 3,117) · q 0.0034EGFR: Colorectal, MSS 1.4% (69 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0035PPM1D: Colorectal, MSS 0.8% (39 / 4,806), Pancreatic, MSS 0.3% (8 / 3,083) · q 0.0036NUF2: Colorectal, MSS 0.6% (25 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0037RPS6KA4: Colorectal, MSS 0.8% (40 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 0.0037CDKN2B: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0039LMO1: Colorectal, MSS 0.4% (18 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0039NKX3-1: Colorectal, MSS 0.4% (18 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0039RIT1: Colorectal, MSS 0.4% (18 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0039MST1R: Colorectal, MSS 1.0% (47 / 4,806), Pancreatic, MSS 0.4% (11 / 3,083) · q 0.0039NTRK1: Colorectal, MSS 1.4% (71 / 4,986), Pancreatic, MSS 0.7% (21 / 3,117) · q 0.004FGFR3: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.0041MYC: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.0041NOTCH1: Colorectal, MSS 2.0% (102 / 4,986), Pancreatic, MSS 1.1% (35 / 3,117) · q 0.0043ZNRF3: Colorectal, MSS 1.4% (23 / 1,591), Pancreatic, MSS 0.3% (3 / 1,100) · q 0.0046GAB1: Colorectal, MSS 1.0% (16 / 1,591), Pancreatic, MSS 0.1% (1 / 1,100) · q 0.0051ARAF: Colorectal, MSS 0.8% (39 / 4,986), Pancreatic, MSS 0.3% (8 / 3,117) · q 0.0052AGO2: Colorectal, MSS 1.1% (45 / 4,059), Pancreatic, MSS 0.4% (11 / 2,588) · q 0.0054SESN3: Colorectal, MSS 0.6% (24 / 4,059), Pancreatic, MSS 0.1% (3 / 2,588) · q 0.0054MAP3K13: Colorectal, MSS 1.1% (54 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0054ERCC2: Colorectal, MSS 0.9% (46 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.0055NKX2-1: Colorectal, MSS 0.7% (36 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.0055H3-5: Colorectal, MSS 0.5% (24 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0056MDM4: Colorectal, MSS 0.5% (24 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0056PMS2: Colorectal, MSS 0.7% (33 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.0057RECQL: Colorectal, MSS 0.7% (30 / 4,059), Pancreatic, MSS 0.2% (5 / 2,588) · q 0.0057NCOA3: Colorectal, MSS 1.0% (50 / 4,806), Pancreatic, MSS 0.4% (13 / 3,083) · q 0.0057BLM: Colorectal, MSS 1.1% (55 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.0063SOS1: Colorectal, MSS 1.2% (47 / 4,059), Pancreatic, MSS 0.5% (12 / 2,588) · q 0.0064NBN: Colorectal, MSS 0.8% (40 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0066GNAQ: Colorectal, MSS 0.4% (20 / 4,986), Pancreatic, MSS 0.1% (2 / 3,117) · q 0.0076GAB2: Colorectal, MSS 0.7% (11 / 1,591), Pancreatic, MSS 0% (0 / 1,100) · q 0.0084MYD88: Colorectal, MSS 0.5% (23 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.0085TAP1: Colorectal, MSS 0.6% (26 / 4,059), Pancreatic, MSS 0.2% (4 / 2,588) · q 0.0086ABRAXAS1: Colorectal, MSS 0.5% (26 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.0087RAD54L: Colorectal, MSS 0.8% (39 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.0092CDH1: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0096PALB2: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.4% (14 / 3,117) · q 0.0096TNFRSF14: Colorectal, MSS 0.3% (16 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.0097KLF5: Colorectal, MSS 1.8% (28 / 1,591), Pancreatic, MSS 0.5% (6 / 1,100) · q 0.0099FANCA: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.6% (20 / 3,117) · q 0.0099RAB35: Colorectal, MSS 0.2% (11 / 4,806), Pancreatic, MSS 0% (0 / 3,083) · q 0.01XPO1: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.01SMARCB1: Colorectal, MSS 0.8% (41 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 0.011SHOC2: Colorectal, MSS 0.5% (19 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.012AURKA: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.012FYN: Colorectal, MSS 0.8% (37 / 4,806), Pancreatic, MSS 0.3% (9 / 3,083) · q 0.012IL7R: Colorectal, MSS 0.9% (45 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.012E2F3: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.013FOXF1: Colorectal, MSS 0.9% (14 / 1,591), Pancreatic, MSS 0.1% (1 / 1,100) · q 0.013TOP1: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.4% (11 / 3,117) · q 0.014MLLT1: Colorectal, MSS 0.6% (10 / 1,591), Pancreatic, MSS 0% (0 / 1,100) · q 0.014JAK2: Colorectal, MSS 1.0% (51 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.015ERG: Colorectal, MSS 1.0% (52 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.015PRDM14: Colorectal, MSS 1.0% (39 / 4,059), Pancreatic, MSS 0.4% (10 / 2,588) · q 0.015ARID2: Colorectal, MSS 2.2% (112 / 4,986), Pancreatic, MSS 1.4% (44 / 3,117) · q 0.015EIF4E: Colorectal, MSS 0.3% (14 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.015HOXB13: Colorectal, MSS 0.3% (15 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.015EGFL7: Colorectal, MSS 0.3% (15 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.015SUFU: Colorectal, MSS 0.3% (15 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.015USP8: Colorectal, MSS 1.1% (17 / 1,591), Pancreatic, MSS 0.2% (2 / 1,100) · q 0.015CBL: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.016GREM1: Colorectal, MSS 0.2% (11 / 4,986), Pancreatic, MSS 0% (0 / 3,117) · q 0.017EIF4A2: Colorectal, MSS 0.5% (23 / 4,806), Pancreatic, MSS 0.1% (4 / 3,083) · q 0.018ARID1A: Colorectal, MSS 6.2% (307 / 4,986), Pancreatic, MSS 7.7% (239 / 3,117) · q 0.018CXCR4: Colorectal, MSS 0.4% (20 / 4,806), Pancreatic, MSS 0.1% (3 / 3,083) · q 0.018MSH6: Colorectal, MSS 1.5% (74 / 4,986), Pancreatic, MSS 0.8% (26 / 3,117) · q 0.018CHEK1: Colorectal, MSS 0.5% (23 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.018DCUN1D1: Colorectal, MSS 0.4% (21 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.019FGF4: Colorectal, MSS 0.4% (21 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.019GATA2: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.021SDHA: Colorectal, MSS 0.6% (31 / 4,986), Pancreatic, MSS 0.2% (7 / 3,117) · q 0.021CDC73: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.021FGFR2: Colorectal, MSS 0.9% (43 / 4,986), Pancreatic, MSS 0.4% (12 / 3,117) · q 0.021BCL10: Colorectal, MSS 0.3% (13 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.023H3C12: Colorectal, MSS 0.3% (13 / 4,806), Pancreatic, MSS 0% (1 / 3,083) · q 0.023COP1: Colorectal, MSS 0.7% (36 / 4,986), Pancreatic, MSS 0.3% (9 / 3,117) · q 0.023ACVR1: Colorectal, MSS 0.5% (25 / 4,806), Pancreatic, MSS 0.2% (5 / 3,083) · q 0.024CBFB: Colorectal, MSS 0.3% (14 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.024EPCAM: Colorectal, MSS 0.3% (14 / 4,986), Pancreatic, MSS 0% (1 / 3,117) · q 0.024ABL1: Colorectal, MSS 1.0% (49 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.024IGF1: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.024RPS6KB2: Colorectal, MSS 0.5% (25 / 4,986), Pancreatic, MSS 0.2% (5 / 3,117) · q 0.024FGFR4: Colorectal, MSS 0.9% (44 / 4,986), Pancreatic, MSS 0.4% (13 / 3,117) · q 0.024KMT5A: Colorectal, MSS 0.4% (16 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.025PPP4R2: Colorectal, MSS 0.4% (16 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.025RRAS: Colorectal, MSS 0.4% (16 / 4,059), Pancreatic, MSS 0.1% (2 / 2,588) · q 0.025RAD51C: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.026SMARCD1: Colorectal, MSS 0.4% (22 / 4,986), Pancreatic, MSS 0.1% (4 / 3,117) · q 0.026NSD2: Colorectal, MSS 1.2% (50 / 4,059), Pancreatic, MSS 0.6% (16 / 2,588) · q 0.026STK40: Colorectal, MSS 0.4% (19 / 4,986), Pancreatic, MSS 0.1% (3 / 3,117) · q 0.026ERCC3: Colorectal, MSS 0.7% (37 / 4,986), Pancreatic, MSS 0.3% (10 / 3,117) · q 0.027SDHB: Colorectal, MSS 0.3% (17 / 4,986), Pancreatic, MSS 0.1% (2 / 3,117) · q 0.027CSDE1: Colorectal, MSS 0.9% (38 / 4,059), Pancreatic, MSS 0.4% (11 / 2,588) · q 0.031IFNGR1: Colorectal, MSS 0.5% (27 / 4,986), Pancreatic, MSS 0.2% (6 / 3,117) · q 0.031RPTOR: Colorectal, MSS 1.0% (48 / 4,986), Pancreatic, MSS 0.5% (15 / 3,117) · q 0.031TGFBR1: Colorectal, MSS 1.4% (69 / 4,986), Pancreatic, MSS 2.1% (65 / 3,117) · q 0.033TSC1: Colorectal, MSS 1.3% (64 / 4,986), Pancreatic, MSS 0.7% (23 / 3,117) · q 0.033MAP2K4: Colorectal, MSS 1.9% (96 / 4,986), Pancreatic, MSS 1.3% (39 / 3,117) · q 0.034CDK12: Colorectal, MSS 1.2% (60 / 4,986), Pancreatic, MSS 0.7% (21 / 3,117) · q 0.035HLA-A: Colorectal, MSS 0.8% (39 / 4,806), Pancreatic, MSS 0.4% (12 / 3,083) · q 0.036BRCA2: Colorectal, MSS 3.1% (155 / 4,986), Pancreatic, MSS 2.2% (70 / 3,117) · q 0.036Genes with highest frequency in any group020406080100Alteration frequency (%)KRAS in Colorectal, MSS: 43.7% (2,178 / 4,986)KRAS in Pancreatic, MSS: 80.8% (2,518 / 3,117)TP53 in Colorectal, MSS: 78.0% (3,890 / 4,986)TP53 in Pancreatic, MSS: 66.6% (2,077 / 3,117)APC in Colorectal, MSS: 76.5% (3,815 / 4,986)APC in Pancreatic, MSS: 1.4% (45 / 3,117)CDKN2A in Colorectal, MSS: 1.0% (52 / 4,986)CDKN2A in Pancreatic, MSS: 20.2% (629 / 3,117)SMAD4 in Colorectal, MSS: 15.1% (752 / 4,986)SMAD4 in Pancreatic, MSS: 19.3% (603 / 3,117)PIK3CA in Colorectal, MSS: 17.6% (876 / 4,986)PIK3CA in Pancreatic, MSS: 2.3% (71 / 3,117)FBXW7 in Colorectal, MSS: 12.7% (635 / 4,986)FBXW7 in Pancreatic, MSS: 1.1% (34 / 3,117)TCF7L2 in Colorectal, MSS: 11.4% (547 / 4,806)TCF7L2 in Pancreatic, MSS: 0.1% (3 / 3,083)SOX9 in Colorectal, MSS: 9.4% (470 / 4,986)SOX9 in Pancreatic, MSS: 0.8% (25 / 3,117)ARID1A in Colorectal, MSS: 6.2% (307 / 4,986)ARID1A in Pancreatic, MSS: 7.7% (239 / 3,117)KRAS *TP53 *APC *CDKN2A *SMAD4 *PIK3CA *FBXW7 *TCF7L2 *SOX9 *ARID1A *Colorectal, MSSPancreatic, MSS* q < 0.05: the gene's frequency differs between the groups* q < 0.05: the gene's frequency differs between the g…GeneCytobandColorectal, MSSPancreatic, MSSLog2 Ratiop-Valueq-ValueEnriched inAPC5q22.23,815 (76.5%)45 (1.4%)5.73<1e-300<1e-300Colorectal, MSSKRAS12p12.12,178 (43.7%)2,518 (80.8%)−0.891.5e-2503.8e-248Pancreatic, MSSCDKN2A9p21.352 (1.0%)629 (20.2%)−4.275e-2118.2e-209Pancreatic, MSSTCF7L210q25.2-q25.3547 (11.4%)3 (0.1%)6.871.4e-1171.7e-115Colorectal, MSSPIK3CA3q26.32876 (17.6%)71 (2.3%)2.951.9e-1171.9e-115Colorectal, MSSFBXW74q31.3635 (12.7%)34 (1.1%)3.551.8e-971.4e-95Colorectal, MSSSOX917q24.3470 (9.4%)25 (0.8%)3.552.5e-711.7e-69Colorectal, MSSBRAF7q34373 (7.5%)41 (1.3%)2.516.8e-414.2e-39Colorectal, MSSAMER1Xq11.2281 (5.6%)26 (0.8%)2.765.6e-343.1e-32Colorectal, MSSSMAD218q21.1211 (4.2%)12 (0.4%)3.462.5e-311.3e-29Colorectal, MSSMEN111q1325 (0.5%)128 (4.1%)−3.036.6e-313e-29Pancreatic, MSSTP5317p13.13,890 (78.0%)2,077 (66.6%)0.233e-291.2e-27Colorectal, MSSCTNNB13p22.1269 (5.4%)34 (1.1%)2.315.6e-272.1e-25Colorectal, MSSNRAS1p13.2196 (3.9%)16 (0.5%)2.942.5e-258.8e-24Colorectal, MSSPIK3R15q13.1178 (3.6%)12 (0.4%)3.216e-252e-23Colorectal, MSSPTPRT20q12-q13.11315 (6.3%)58 (1.9%)1.766.7e-232.1e-21Colorectal, MSSPTPRS19p13.3261 (5.2%)49 (1.6%)1.747.9e-192.3e-17Colorectal, MSSEPHA33p11.1176 (3.5%)24 (0.8%)2.204.4e-171.2e-15Colorectal, MSS+476 more genes tested (the full table is in the result and the MCP text)Every gene's mutation frequency in each cohort, counted in SAMPLES over the samples profiled for that gene (a panel that lists it, or whole-exome; a sample alteredoff-panel counts as measured), uncalled mutations excluded as the portal excludes them. 494 genes tested with a two-sided Fisher's exact test; q isBenjamini–Hochberg across all of them. 8 altered genes were not tested: fewer than 5 altered samples across the cohorts, or not profiled in one of them. The log ratio islog2 of the first cohort's altered share over the second's, undefined (drawn at the edge) when either is zero. A gene enriched here is more often altered, not necessarilymore important: a cohort holding hypermutated tumours (MSI-high, POLE) is enriched for mutations in almost every gene at once — exclude them in the cohort definitionto see past that. diff --git a/test/snapshots/enrichment.txt b/test/snapshots/enrichment.txt new file mode 100644 index 0000000..7effe8c --- /dev/null +++ b/test/snapshots/enrichment.txt @@ -0,0 +1,59 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Colorectal, MSS: 4,957 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) AND NOT MSI_TYPE in [Instable] (any sample) +- Pancreatic, MSS: 3,095 patients — CANCER_TYPE in [Pancreatic Cancer] (any sample) AND NOT MSI_TYPE in [Instable] (any sample) + +Alteration enrichment (mutation; two-sided Fisher's exact test, BH q over 494 genes; 316 at q<0.05): + APC: Colorectal, MSS 76.5% (3815/4986) | Pancreatic, MSS 1.4% (45/3117), log2 ratio 5.73, q=<1e-300, enriched in Colorectal, MSS + KRAS: Colorectal, MSS 43.7% (2178/4986) | Pancreatic, MSS 80.8% (2518/3117), log2 ratio -0.89, q=3.8e-248, enriched in Pancreatic, MSS + CDKN2A: Colorectal, MSS 1% (52/4986) | Pancreatic, MSS 20.2% (629/3117), log2 ratio -4.27, q=8.2e-209, enriched in Pancreatic, MSS + TCF7L2: Colorectal, MSS 11.4% (547/4806) | Pancreatic, MSS 0.1% (3/3083), log2 ratio 6.87, q=1.7e-115, enriched in Colorectal, MSS + PIK3CA: Colorectal, MSS 17.6% (876/4986) | Pancreatic, MSS 2.3% (71/3117), log2 ratio 2.95, q=1.9e-115, enriched in Colorectal, MSS + FBXW7: Colorectal, MSS 12.7% (635/4986) | Pancreatic, MSS 1.1% (34/3117), log2 ratio 3.55, q=1.4e-95, enriched in Colorectal, MSS + SOX9: Colorectal, MSS 9.4% (470/4986) | Pancreatic, MSS 0.8% (25/3117), log2 ratio 3.55, q=1.7e-69, enriched in Colorectal, MSS + BRAF: Colorectal, MSS 7.5% (373/4986) | Pancreatic, MSS 1.3% (41/3117), log2 ratio 2.51, q=4.2e-39, enriched in Colorectal, MSS + AMER1: Colorectal, MSS 5.6% (281/4986) | Pancreatic, MSS 0.8% (26/3117), log2 ratio 2.76, q=3.1e-32, enriched in Colorectal, MSS + SMAD2: Colorectal, MSS 4.2% (211/4986) | Pancreatic, MSS 0.4% (12/3117), log2 ratio 3.46, q=1.3e-29, enriched in Colorectal, MSS + MEN1: Colorectal, MSS 0.5% (25/4986) | Pancreatic, MSS 4.1% (128/3117), log2 ratio -3.03, q=3.0e-29, enriched in Pancreatic, MSS + TP53: Colorectal, MSS 78% (3890/4986) | Pancreatic, MSS 66.6% (2077/3117), log2 ratio 0.23, q=1.2e-27, enriched in Colorectal, MSS + CTNNB1: Colorectal, MSS 5.4% (269/4986) | Pancreatic, MSS 1.1% (34/3117), log2 ratio 2.31, q=2.1e-25, enriched in Colorectal, MSS + NRAS: Colorectal, MSS 3.9% (196/4986) | Pancreatic, MSS 0.5% (16/3117), log2 ratio 2.94, q=8.8e-24, enriched in Colorectal, MSS + PIK3R1: Colorectal, MSS 3.6% (178/4986) | Pancreatic, MSS 0.4% (12/3117), log2 ratio 3.21, q=2.0e-23, enriched in Colorectal, MSS + PTPRT: Colorectal, MSS 6.3% (315/4986) | Pancreatic, MSS 1.9% (58/3117), log2 ratio 1.76, q=2.1e-21, enriched in Colorectal, MSS + PTPRS: Colorectal, MSS 5.2% (261/4986) | Pancreatic, MSS 1.6% (49/3117), log2 ratio 1.74, q=2.3e-17, enriched in Colorectal, MSS + EPHA3: Colorectal, MSS 3.5% (176/4986) | Pancreatic, MSS 0.8% (24/3117), log2 ratio 2.20, q=1.2e-15, enriched in Colorectal, MSS + CARD11: Colorectal, MSS 3.3% (166/4986) | Pancreatic, MSS 0.7% (22/3117), log2 ratio 2.24, q=5.6e-15, enriched in Colorectal, MSS + GRIN2A: Colorectal, MSS 3.8% (188/4986) | Pancreatic, MSS 1% (30/3117), log2 ratio 1.97, q=1.3e-14, enriched in Colorectal, MSS + ASXL1: Colorectal, MSS 2.6% (128/4986) | Pancreatic, MSS 0.4% (13/3117), log2 ratio 2.62, q=7.7e-14, enriched in Colorectal, MSS + MTOR: Colorectal, MSS 3% (150/4986) | Pancreatic, MSS 0.6% (20/3117), log2 ratio 2.23, q=1.5e-13, enriched in Colorectal, MSS + PLCG2: Colorectal, MSS 2.6% (123/4806) | Pancreatic, MSS 0.4% (13/3083), log2 ratio 2.60, q=2.2e-13, enriched in Colorectal, MSS + KDR: Colorectal, MSS 3% (148/4986) | Pancreatic, MSS 0.6% (20/3117), log2 ratio 2.21, q=3.3e-13, enriched in Colorectal, MSS + ERBB2: Colorectal, MSS 3.1% (155/4986) | Pancreatic, MSS 0.7% (23/3117), log2 ratio 2.07, q=6.2e-13, enriched in Colorectal, MSS + NF1: Colorectal, MSS 3.3% (166/4986) | Pancreatic, MSS 0.9% (27/3117), log2 ratio 1.94, q=1.0e-12, enriched in Colorectal, MSS + EPHA5: Colorectal, MSS 3.6% (181/4986) | Pancreatic, MSS 1% (32/3117), log2 ratio 1.82, q=1.0e-12, enriched in Colorectal, MSS + PIK3CG: Colorectal, MSS 3.1% (156/4986) | Pancreatic, MSS 0.8% (25/3117), log2 ratio 1.96, q=3.3e-12, enriched in Colorectal, MSS + ERBB3: Colorectal, MSS 3.2% (162/4986) | Pancreatic, MSS 0.9% (27/3117), log2 ratio 1.91, q=3.3e-12, enriched in Colorectal, MSS + PDGFRA: Colorectal, MSS 2.2% (110/4986) | Pancreatic, MSS 0.4% (11/3117), log2 ratio 2.64, q=4.1e-12, enriched in Colorectal, MSS + PTEN: Colorectal, MSS 3.9% (192/4986) | Pancreatic, MSS 1.2% (38/3117), log2 ratio 1.66, q=5.0e-12, enriched in Colorectal, MSS + AR: Colorectal, MSS 2.8% (140/4986) | Pancreatic, MSS 0.7% (22/3117), log2 ratio 1.99, q=3.5e-11, enriched in Colorectal, MSS + ALK: Colorectal, MSS 3.1% (153/4986) | Pancreatic, MSS 0.9% (27/3117), log2 ratio 1.82, q=8.1e-11, enriched in Colorectal, MSS + ZFHX3: Colorectal, MSS 3.8% (182/4806) | Pancreatic, MSS 1.3% (41/3083), log2 ratio 1.51, q=2.7e-10, enriched in Colorectal, MSS + PIK3C2G: Colorectal, MSS 2.4% (122/4986) | Pancreatic, MSS 0.6% (19/3117), log2 ratio 2.01, q=8.8e-10, enriched in Colorectal, MSS + AXIN2: Colorectal, MSS 2.8% (141/4986) | Pancreatic, MSS 0.8% (26/3117), log2 ratio 1.76, q=1.3e-9, enriched in Colorectal, MSS + EPHA7: Colorectal, MSS 2.5% (118/4806) | Pancreatic, MSS 0.6% (19/3083), log2 ratio 1.99, q=1.6e-9, enriched in Colorectal, MSS + B2M: Colorectal, MSS 1.5% (76/4986) | Pancreatic, MSS 0.2% (6/3117), log2 ratio 2.99, q=1.8e-9, enriched in Colorectal, MSS + SOX17: Colorectal, MSS 2% (101/4986) | Pancreatic, MSS 0.4% (13/3117), log2 ratio 2.28, q=1.9e-9, enriched in Colorectal, MSS + KDM6A: Colorectal, MSS 1.5% (74/4986) | Pancreatic, MSS 3.7% (116/3117), log2 ratio -1.33, q=2.5e-9, enriched in Pancreatic, MSS + … 454 more genes tested + CAVEAT (tell the user): Every gene's mutation frequency in each cohort, counted in SAMPLES over the samples profiled for that gene (a panel that lists it, or whole-exome; a sample altered off-panel counts as measured), uncalled mutations excluded as the portal excludes them. 494 genes tested with a two-sided Fisher's exact test; q is Benjamini–Hochberg across all of them. 8 altered genes were not tested: fewer than 5 altered samples across the cohorts, or not profiled in one of them. The log ratio is log2 of the first cohort's altered share over the second's, undefined (drawn at the edge) when either is zero. A gene enriched here is more often altered, not necessarily more important: a cohort holding hypermutated tumours (MSI-high, POLE) is enriched for mutations in almost every gene at once — exclude them in the cohort definition to see past that. + METHOD: + - Count altered and profiled samples per gene [Colorectal, MSS · msk_chord_2024]: The enrichment queries above: per gene, samples with a mutation; per gene, samples on a panel listing it (counted per panel, then joined to its genes); and the whole-exome samples, profiled for every gene. + whole-exome samples: 0 + - Count altered and profiled samples per gene [Pancreatic, MSS · msk_chord_2024]: The enrichment queries above: per gene, samples with a mutation; per gene, samples on a panel listing it (counted per panel, then joined to its genes); and the whole-exome samples, profiled for every gene. + whole-exome samples: 0 + - Profiled = panel samples + whole-exome samples, summed across studies: A sample altered in a gene its panel does not list still counts as measured. Genes with fewer than 5 altered samples across the cohorts, or not profiled in one of them, are not tested. + tested: 494 + not tested: 8 + - Fisher's exact test per gene, then Benjamini–Hochberg: A two-sided Fisher's exact test on altered vs not among the profiled, per gene; q across every gene tested. + Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/genome.json b/test/snapshots/genome.json new file mode 100644 index 0000000..d12a062 --- /dev/null +++ b/test/snapshots/genome.json @@ -0,0 +1,475 @@ +{ + "study": "msk_impact_50k_2026", + "cohorts": { + "Colorectal": { + "count": 4993, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample)", + "studies": [ + "msk_impact_50k_2026" + ] + }, + "Breast": { + "count": 5803, + "text": "CANCER_TYPE in [Breast Cancer] (any sample)", + "studies": [ + "msk_impact_50k_2026" + ] + } + }, + "views": [ + { + "kind": "genome", + "cohorts": [ + "Colorectal", + "Breast" + ], + "genome": { + "build": "hg19", + "binMb": 2, + "threshold": 0.2, + "includeX": false, + "bins": [ + { + "chrom": "1", + "start": 0 + }, + { + "chrom": "1", + "start": 2000000 + }, + { + "chrom": "1", + "start": 4000000 + }, + { + "chrom": "1", + "start": 6000000 + }, + { + "chrom": "1", + "start": 8000000 + }, + { + "chrom": "1", + "start": 10000000 + }, + { + "chrom": "1", + "start": 12000000 + }, + { + "chrom": "1", + "start": 14000000 + }, + { + "chrom": "1", + "start": 16000000 + }, + { + "chrom": "1", + "start": 18000000 + }, + { + "chrom": "1", + "start": 20000000 + }, + { + "chrom": "1", + "start": 22000000 + }, + { + "chrom": "1", + "start": 24000000 + }, + { + "chrom": "1", + "start": 26000000 + }, + { + "chrom": "1", + "start": 28000000 + }, + { + "chrom": "1", + "start": 30000000 + }, + { + "chrom": "1", + "start": 32000000 + }, + { + "chrom": "1", + "start": 34000000 + }, + { + "chrom": "1", + "start": 36000000 + }, + { + "chrom": "1", + "start": 38000000 + }, + { + "…": "1432 more", + "sha256": "11021b31f868c895" + } + ], + "series": [ + { + "cohort": "Colorectal", + "samples": 5395, + "segmented": 5390, + "profiled": [ + 829, + 5254, + 5310, + 5310, + 5120, + 5327, + 5336, + 5338, + 5320, + 5327, + 5358, + 5127, + 5228, + 5241, + 5216, + 5175, + 5173, + 5173, + 5259, + 5275, + { + "…": "1432 more", + "sha256": "c2218b32c5ea9c1e" + } + ], + "gain": [ + 18, + 80, + 72, + 72, + 58, + 50, + 52, + 56, + 54, + 57, + 58, + 69, + 59, + 58, + 22, + 30, + 31, + 31, + 78, + 86, + { + "…": "1432 more", + "sha256": "9071064cfbef82a4" + } + ], + "loss": [ + 155, + 1129, + 1199, + 1199, + 1187, + 1286, + 1269, + 1260, + 1280, + 1298, + 1325, + 1303, + 1512, + 1514, + 1249, + 1040, + 1018, + 1018, + 903, + 902, + { + "…": "1432 more", + "sha256": "05622f1b4e38b879" + } + ] + }, + { + "cohort": "Breast", + "samples": 6907, + "segmented": 6906, + "profiled": [ + 703, + 6686, + 6753, + 6753, + 6271, + 6713, + 6748, + 6763, + 6744, + 6747, + 6807, + 6463, + 6624, + 6639, + 6587, + 6659, + 6668, + 6668, + 6565, + 6587, + { + "…": "1432 more", + "sha256": "29fc7d02b1babbec" + } + ], + "gain": [ + 44, + 182, + 170, + 170, + 141, + 132, + 141, + 161, + 188, + 186, + 188, + 177, + 174, + 175, + 172, + 217, + 225, + 225, + 353, + 365, + { + "…": "1432 more", + "sha256": "b24536dbd6cbad97" + } + ], + "loss": [ + 201, + 1846, + 1906, + 1906, + 1680, + 1902, + 1872, + 1850, + 1841, + 1809, + 1824, + 1760, + 2008, + 2014, + 1608, + 1429, + 1416, + 1416, + 1161, + 1157, + { + "…": "1432 more", + "sha256": "d31a3cab65c7e604" + } + ] + } + ], + "test": { + "gainQ": [ + 0.00008545878862445828, + 0.000009030934919032, + 0.000007052613800163918, + 0.000007052613800163918, + 0.000006424362049596166, + 0.000004690200061493557, + 0.0000010266350704572462, + 3.284080897211836e-8, + 1.8154049214540513e-12, + 2.3540693323143305e-11, + 2.9957787840506274e-11, + 2.1876619846395273e-7, + 4.1811661928362945e-9, + 1.7981085382803662e-9, + 3.822800792218554e-23, + 7.054747659995672e-27, + 7.025354497705347e-28, + 7.025354497705347e-28, + 1.7450212124036932e-31, + 2.2841786286715866e-30, + { + "…": "1432 more", + "sha256": "28986f17dabb26fb" + } + ], + "lossQ": [ + 0.000007013609127477512, + 2.243524316793396e-14, + 2.790086852777875e-12, + 2.790086852777875e-12, + 0.000014166292192959972, + 3.08684191056184e-7, + 0.0000011271795899166522, + 0.0000036741504423566186, + 0.00007628596613207397, + 0.002904360074218777, + 0.012386926935199553, + 0.03344282841782284, + 0.11136786598644766, + 0.09922195566989905, + 0.5770901208813335, + 0.08021141405862506, + 0.04465757638582967, + 0.04465757638582967, + 0.500573996127623, + 0.5297453577870423, + { + "…": "1432 more", + "sha256": "693b40669105adf0" + } + ], + "significantGain": 1255, + "significantLoss": 1217 + } + }, + "participation": { + "studies": [ + { + "study": "msk_impact_50k_2026", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Share of each cohort's segmented SAMPLES (not patients: a patient with two segmented samples counts twice) gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) in each 2 Mb bin, hg19. Each bin's denominator is the samples whose segmentation covers it; a bin takes the value of the segment over its midpoint, so an event narrower than 2 Mb can be missed — use a smaller binMb to find it. 12,296 of 12,302 samples have segments. Thresholds on a log ratio are not purity- or ploidy-corrected: a low-purity tumour's real loss can sit inside ±0.2. Chromosome X is not drawn (includeX: true adds it). Per-bin two-sided Fisher tests, Benjamini–Hochberg across bins separately for gains and losses; adjacent bins are not independent, so read a run of significant bins as one region, not many findings.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count gained and lost samples per bin", + "detail": "The genome:coverage and genome:bins queries above. Per 2 Mb bin on hg19: the cohort's SAMPLES (a patient with two segmented samples counts twice) whose segmentation covers the bin's midpoint, and of those the ones gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) there. Counts only.", + "scope": "Colorectal · msk_impact_50k_2026", + "rowsIn": 4993 + }, + { + "kind": "fetch", + "title": "Count gained and lost samples per bin", + "detail": "The genome:coverage and genome:bins queries above. Per 2 Mb bin on hg19: the cohort's SAMPLES (a patient with two segmented samples counts twice) whose segmentation covers the bin's midpoint, and of those the ones gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) there. Counts only.", + "scope": "Breast · msk_impact_50k_2026", + "rowsIn": 5803 + }, + { + "kind": "transform", + "title": "Place the bins on one axis", + "detail": "Chromosomes 1–22 at hg19 lengths, 1,452 bins; counts add across studies (all on one build).", + "params": [ + [ + "Colorectal", + "5,390 of 5,395 samples segmented" + ], + [ + "Breast", + "6,906 of 6,907 samples segmented" + ] + ] + }, + { + "kind": "statistic", + "title": "Fisher's exact test per bin", + "detail": "Two-sided, on gained vs not (and separately lost vs not) among each cohort's covered samples, in every bin both cohorts cover." + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across bins", + "detail": "Separately for gains and losses. Adjacent bins are not independent: a run of significant bins is one region, not many findings." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "genome:1:0:gain_q": { + "v": 0.00008545878862445828 + }, + "genome:1:0:loss_q": { + "v": 0.000007013609127477512 + }, + "genome:1:1:gain_q": { + "v": 0.000009030934919032 + }, + "genome:1:1:loss_q": { + "v": 2.243524316793396e-14 + }, + "genome:1:2:gain_q": { + "v": 0.000007052613800163918 + }, + "genome:1:2:loss_q": { + "v": 2.790086852777875e-12 + }, + "genome:1:3:gain_q": { + "v": 0.000007052613800163918 + }, + "genome:1:3:loss_q": { + "v": 2.790086852777875e-12 + }, + "genome:1:4:gain_q": { + "v": 0.000006424362049596166 + }, + "genome:1:4:loss_q": { + "v": 0.000014166292192959972 + }, + "genome:1:5:gain_q": { + "v": 0.000004690200061493557 + }, + "genome:1:5:loss_q": { + "v": 3.08684191056184e-7 + }, + "genome:1:6:gain_q": { + "v": 0.0000010266350704572462 + }, + "genome:1:6:loss_q": { + "v": 0.0000011271795899166522 + }, + "genome:1:7:gain_q": { + "v": 3.284080897211836e-8 + }, + "genome:1:7:loss_q": { + "v": 0.0000036741504423566186 + }, + "genome:1:8:gain_q": { + "v": 1.8154049214540513e-12 + }, + "genome:1:8:loss_q": { + "v": 0.00007628596613207397 + }, + "genome:1:9:gain_q": { + "v": 2.3540693323143305e-11 + }, + "genome:1:9:loss_q": { + "v": 0.002904360074218777 + }, + "…": { + "more": 2752, + "sha256": "14aedf4afb06c134" + } + } + } + } + ] +} diff --git a/test/snapshots/genome.sql b/test/snapshots/genome.sql new file mode 100644 index 0000000..c2b9396 --- /dev/null +++ b/test/snapshots/genome.sql @@ -0,0 +1,102 @@ +-- cohort Colorectal +-- msk_impact_50k_2026 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) + +-- cohort Breast +-- msk_impact_50k_2026 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer')))) + +-- view 0 genome: genome:bins:Breast · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +samp AS ( + SELECT internal_id AS sid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +seg AS ( + SELECT s.sample_id AS sid, multiIf(s.chr IN ('23', 'X', 'chrX'), 'X', replaceOne(s.chr, 'chr', '')) AS chrom, + s.start AS st, s.end AS en, s.segment_mean AS m + FROM snapshot_db.copy_number_seg s + WHERE s.cancer_study_id = (SELECT cancer_study_id FROM snapshot_db.cancer_study WHERE cancer_study_identifier = 'msk_impact_50k_2026') + AND s.sample_id IN (SELECT sid FROM samp) AND isFinite(s.segment_mean) +), +binned AS ( + SELECT sid, chrom, bin, avg(m) AS v FROM ( + SELECT sid, chrom, m, + arrayJoin(range(toUInt64(greatest(0, ceil((st - 1000000) / 2000000))), + toUInt64(greatest(0, floor((en - 1000000) / 2000000) + 1)))) AS bin + FROM seg WHERE chrom IN ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22') AND en >= st + ) GROUP BY sid, chrom, bin +) +SELECT chrom, bin, count() AS profiled, countIf(v >= 0.2) AS gain, countIf(v <= -0.2) AS loss +FROM binned GROUP BY chrom, bin ORDER BY chrom, bin + +-- view 0 genome: genome:bins:Colorectal · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +samp AS ( + SELECT internal_id AS sid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +seg AS ( + SELECT s.sample_id AS sid, multiIf(s.chr IN ('23', 'X', 'chrX'), 'X', replaceOne(s.chr, 'chr', '')) AS chrom, + s.start AS st, s.end AS en, s.segment_mean AS m + FROM snapshot_db.copy_number_seg s + WHERE s.cancer_study_id = (SELECT cancer_study_id FROM snapshot_db.cancer_study WHERE cancer_study_identifier = 'msk_impact_50k_2026') + AND s.sample_id IN (SELECT sid FROM samp) AND isFinite(s.segment_mean) +), +binned AS ( + SELECT sid, chrom, bin, avg(m) AS v FROM ( + SELECT sid, chrom, m, + arrayJoin(range(toUInt64(greatest(0, ceil((st - 1000000) / 2000000))), + toUInt64(greatest(0, floor((en - 1000000) / 2000000) + 1)))) AS bin + FROM seg WHERE chrom IN ('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22') AND en >= st + ) GROUP BY sid, chrom, bin +) +SELECT chrom, bin, count() AS profiled, countIf(v >= 0.2) AS gain, countIf(v <= -0.2) AS loss +FROM binned GROUP BY chrom, bin ORDER BY chrom, bin + +-- view 0 genome: genome:build · msk_impact_50k_2026 +SELECT rg.name AS build FROM snapshot_db.cancer_study cs +JOIN snapshot_db.reference_genome rg ON rg.reference_genome_id = cs.reference_genome_id +WHERE cs.cancer_study_identifier = 'msk_impact_50k_2026' + +-- view 0 genome: genome:coverage:Breast · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +samp AS ( + SELECT internal_id AS sid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +) +SELECT (SELECT count() FROM samp) AS samples, + (SELECT uniqExact(sample_id) FROM snapshot_db.copy_number_seg + WHERE cancer_study_id = (SELECT cancer_study_id FROM snapshot_db.cancer_study WHERE cancer_study_identifier = 'msk_impact_50k_2026') + AND sample_id IN (SELECT sid FROM samp)) AS segmented +FROM system.one + +-- view 0 genome: genome:coverage:Colorectal · msk_impact_50k_2026 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +samp AS ( + SELECT internal_id AS sid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +) +SELECT (SELECT count() FROM samp) AS samples, + (SELECT uniqExact(sample_id) FROM snapshot_db.copy_number_seg + WHERE cancer_study_id = (SELECT cancer_study_id FROM snapshot_db.cancer_study WHERE cancer_study_identifier = 'msk_impact_50k_2026') + AND sample_id IN (SELECT sid FROM samp)) AS segmented +FROM system.one diff --git a/test/snapshots/genome.svg b/test/snapshots/genome.svg new file mode 100644 index 0000000..6d14f91 --- /dev/null +++ b/test/snapshots/genome.svg @@ -0,0 +1,2 @@ + +Genome-wide copy number — Colorectal, BreastColorectal5,390 segmented samples−60%−40%−20%0+20%+40%+60%% of samplesBreast6,906 segmented samples−60%−40%−20%0+20%+40%+60%% of samples12345678910111213141516171819202122gain differsloss differsq < 0.05, higher in:ColorectalBreastgainedlostno segment covers this binShare of each cohort's segmented SAMPLES (not patients: a patient with two segmented samples counts twice) gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) in each2 Mb bin, hg19. Each bin's denominator is the samples whose segmentation covers it; a bin takes the value of the segment over its midpoint, so an event narrower than 2Mb can be missed — use a smaller binMb to find it. 12,296 of 12,302 samples have segments. Thresholds on a log ratio are not purity- or ploidy-corrected: a low-puritytumour's real loss can sit inside ±0.2. Chromosome X is not drawn (includeX: true adds it). Per-bin two-sided Fisher tests, Benjamini–Hochberg across bins separately forgains and losses; adjacent bins are not independent, so read a run of significant bins as one region, not many findings. diff --git a/test/snapshots/genome.txt b/test/snapshots/genome.txt new file mode 100644 index 0000000..70a4cba --- /dev/null +++ b/test/snapshots/genome.txt @@ -0,0 +1,20 @@ +Analysis over msk_impact_50k_2026 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Colorectal: 4,993 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) +- Breast: 5,803 patients — CANCER_TYPE in [Breast Cancer] (any sample) + +Genome-wide copy number (hg19, 2 Mb bins, |log2| ≥ 0.2; peak % gained/lost per chromosome): + Colorectal (5,390 segmented samples): chr1 +13/−29, chr2 +4/−5, chr3 +6/−10, chr4 +2/−27, chr5 +11/−17, chr6 +11/−15, chr7 +31/−2, chr8 +35/−40, chr9 +7/−10, chr10 +4/−14, chr11 +5/−10, chr12 +11/−7, chr13 +46/−2, chr14 +4/−21, chr15 +5/−24, chr16 +15/−7, chr17 +9/−39, chr18 +3/−55, chr19 +9/−13, chr20 +61/−10, chr21 +3/−16, chr22 +4/−23 + Breast (6,906 segmented samples): chr1 +51/−30, chr2 +7/−16, chr3 +16/−25, chr4 +5/−24, chr5 +17/−18, chr6 +17/−32, chr7 +16/−11, chr8 +49/−43, chr9 +7/−28, chr10 +17/−21, chr11 +27/−41, chr12 +14/−15, chr13 +10/−37, chr14 +11/−22, chr15 +13/−27, chr16 +31/−44, chr17 +25/−45, chr18 +7/−25, chr19 +11/−33, chr20 +32/−10, chr21 +14/−12, chr22 +7/−31 + bins differing at q<0.05: 1255 for gains, 1217 for losses, of 1452 + CAVEAT (tell the user): Share of each cohort's segmented SAMPLES (not patients: a patient with two segmented samples counts twice) gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) in each 2 Mb bin, hg19. Each bin's denominator is the samples whose segmentation covers it; a bin takes the value of the segment over its midpoint, so an event narrower than 2 Mb can be missed — use a smaller binMb to find it. 12,296 of 12,302 samples have segments. Thresholds on a log ratio are not purity- or ploidy-corrected: a low-purity tumour's real loss can sit inside ±0.2. Chromosome X is not drawn (includeX: true adds it). Per-bin two-sided Fisher tests, Benjamini–Hochberg across bins separately for gains and losses; adjacent bins are not independent, so read a run of significant bins as one region, not many findings. + METHOD: + - Count gained and lost samples per bin [Colorectal · msk_impact_50k_2026]: The genome:coverage and genome:bins queries above. Per 2 Mb bin on hg19: the cohort's SAMPLES (a patient with two segmented samples counts twice) whose segmentation covers the bin's midpoint, and of those the ones gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) there. Counts only. + - Count gained and lost samples per bin [Breast · msk_impact_50k_2026]: The genome:coverage and genome:bins queries above. Per 2 Mb bin on hg19: the cohort's SAMPLES (a patient with two segmented samples counts twice) whose segmentation covers the bin's midpoint, and of those the ones gained (log2 segment mean ≥ 0.2) or lost (≤ −0.2) there. Counts only. + - Place the bins on one axis: Chromosomes 1–22 at hg19 lengths, 1,452 bins; counts add across studies (all on one build). + Colorectal: 5,390 of 5,395 samples segmented + Breast: 6,906 of 6,907 samples segmented + - Fisher's exact test per bin: Two-sided, on gained vs not (and separately lost vs not) among each cohort's covered samples, in every bin both cohorts cover. + - Benjamini–Hochberg across bins: Separately for gains and losses. Adjacent bins are not independent: a run of significant bins is one region, not many findings. + Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/hotspots.json b/test/snapshots/hotspots.json new file mode 100644 index 0000000..209c220 --- /dev/null +++ b/test/snapshots/hotspots.json @@ -0,0 +1,2279 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "CRC": { + "count": 5543, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "hotspots", + "cohorts": [ + "CRC" + ], + "hotspots": [ + { + "gene": "KRAS", + "mutated": 2362, + "mutations": 2424, + "positions": [ + { + "pos": 10, + "n": 5, + "color": "#993404", + "impact": "inframe", + "driver": true, + "changes": [ + { + "change": "G10dup", + "n": 5, + "rows": 5, + "driver": true, + "impact": "inframe" + } + ], + "types": [ + { + "mtype": "In_Frame_Ins", + "driver": true, + "rows": 5 + } + ] + }, + { + "pos": 12, + "n": 1583, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G12D", + "n": 688, + "rows": 689, + "driver": true, + "impact": "missense" + }, + { + "change": "G12V", + "n": 487, + "rows": 488, + "driver": true, + "impact": "missense" + }, + { + "change": "G12C", + "n": 162, + "rows": 162, + "driver": true, + "impact": "missense" + }, + { + "change": "G12S", + "n": 109, + "rows": 109, + "driver": true, + "impact": "missense" + }, + { + "change": "G12A", + "n": 108, + "rows": 108, + "driver": true, + "impact": "missense" + }, + { + "change": "G12R", + "n": 26, + "rows": 26, + "driver": true, + "impact": "missense" + }, + { + "change": "G12F", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 1585 + } + ] + }, + { + "pos": 13, + "n": 446, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G13D", + "n": 426, + "rows": 426, + "driver": true, + "impact": "missense" + }, + { + "change": "G13C", + "n": 20, + "rows": 20, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 446 + } + ] + }, + { + "pos": 14, + "n": 10, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "V14I", + "n": 10, + "rows": 10, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 10 + } + ] + }, + { + "pos": 33, + "n": 6, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "D33E", + "n": 6, + "rows": 6, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 6 + } + ] + }, + { + "pos": 57, + "n": 3, + "color": "#53D400", + "impact": "missense", + "driver": false, + "changes": [ + { + "change": "D57N", + "n": 3, + "rows": 3, + "driver": false, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": false, + "rows": 3 + } + ] + }, + { + "pos": 59, + "n": 13, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "A59T", + "n": 13, + "rows": 13, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 13 + } + ] + }, + { + "pos": 60, + "n": 18, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "Q61K", + "n": 18, + "rows": 18, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 18 + } + ] + }, + { + "pos": 61, + "n": 82, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "Q61H", + "n": 55, + "rows": 55, + "driver": true, + "impact": "missense" + }, + { + "change": "Q61R", + "n": 15, + "rows": 15, + "driver": true, + "impact": "missense" + }, + { + "change": "Q61L", + "n": 8, + "rows": 8, + "driver": true, + "impact": "missense" + }, + { + "change": "Q61K", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 82 + } + ] + }, + { + "pos": 68, + "n": 3, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R68S", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 117, + "n": 26, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "K117N", + "n": 26, + "rows": 26, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 26 + } + ] + }, + { + "pos": 146, + "n": 176, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "A146T", + "n": 140, + "rows": 140, + "driver": true, + "impact": "missense" + }, + { + "change": "A146V", + "n": 27, + "rows": 27, + "driver": true, + "impact": "missense" + }, + { + "change": "A146P", + "n": 9, + "rows": 9, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 176 + } + ] + } + ], + "domains": [ + { + "accession": "PF00071", + "name": "Ras", + "start": 5, + "end": 164, + "color": "#2dcf00" + } + ], + "topChanges": [ + { + "change": "G12D", + "pos": 12, + "n": 688, + "pct": 29.1 + }, + { + "change": "G12V", + "pos": 12, + "n": 487, + "pct": 20.6 + }, + { + "change": "G13D", + "pos": 13, + "n": 426, + "pct": 18 + }, + { + "change": "G12C", + "pos": 12, + "n": 162, + "pct": 6.9 + }, + { + "change": "A146T", + "pos": 146, + "n": 140, + "pct": 5.9 + }, + { + "change": "G12S", + "pos": 12, + "n": 109, + "pct": 4.6 + }, + { + "change": "G12A", + "pos": 12, + "n": 108, + "pct": 4.6 + }, + { + "change": "Q61H", + "pos": 61, + "n": 55, + "pct": 2.3 + }, + { + "change": "A146V", + "pos": 146, + "n": 27, + "pct": 1.1 + }, + { + "change": "G12R", + "pos": 12, + "n": 26, + "pct": 1.1 + } + ], + "proteinLength": 188, + "lengthSource": "genome-nexus", + "transcript": "ENST00000311936", + "unpositioned": 0, + "withheld": 53, + "label": { + "pos": 12, + "text": "G12D/V/C and 4 more" + }, + "somaticSamples": 2371, + "cohortSamples": 5584, + "tally": { + "missense": { + "driver": 2365, + "vus": 3 + }, + "truncating": { + "driver": 0, + "vus": 0 + }, + "inframe": { + "driver": 5, + "vus": 0 + }, + "splice": { + "driver": 0, + "vus": 0 + }, + "fusion": { + "driver": 0, + "vus": 0 + }, + "other": { + "driver": 0, + "vus": 0 + } + }, + "ids": { + "refseq": "NM_004985", + "ccds": "CCDS8702", + "uniprotAccession": "P01116", + "uniprotName": "RASK_HUMAN", + "ensembl": "ENST00000311936.3" + } + }, + { + "gene": "BRAF", + "mutated": 622, + "mutations": 658, + "positions": [ + { + "pos": 241, + "n": 4, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "T241M", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 362, + "n": 5, + "color": "#53D400", + "impact": "missense", + "driver": false, + "changes": [ + { + "change": "R362Q", + "n": 5, + "rows": 5, + "driver": false, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": false, + "rows": 5 + } + ] + }, + { + "pos": 403, + "n": 19, + "color": "#708090", + "impact": "truncating", + "driver": false, + "changes": [ + { + "change": "A404Cfs*9", + "n": 10, + "rows": 10, + "driver": false, + "impact": "truncating" + }, + { + "change": "P403Lfs*8", + "n": 9, + "rows": 9, + "driver": false, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Del", + "driver": false, + "rows": 9 + }, + { + "mtype": "Frame_Shift_Ins", + "driver": false, + "rows": 10 + } + ] + }, + { + "pos": 466, + "n": 6, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G466E", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + }, + { + "change": "G466V", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 6 + } + ] + }, + { + "pos": 469, + "n": 14, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G469A", + "n": 10, + "rows": 10, + "driver": true, + "impact": "missense" + }, + { + "change": "G469R", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 14 + } + ] + }, + { + "pos": 581, + "n": 4, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "N581S", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 594, + "n": 46, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "D594G", + "n": 38, + "rows": 38, + "driver": true, + "impact": "missense" + }, + { + "change": "D594N", + "n": 8, + "rows": 8, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 46 + } + ] + }, + { + "pos": 595, + "n": 4, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "F595L", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 600, + "n": 438, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "V600E", + "n": 438, + "rows": 438, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 438 + } + ] + }, + { + "pos": 601, + "n": 4, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "K601E", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 762, + "n": 3, + "color": "#53D400", + "impact": "missense", + "driver": false, + "changes": [ + { + "change": "A762V", + "n": 3, + "rows": 3, + "driver": false, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": false, + "rows": 3 + } + ] + } + ], + "domains": [ + { + "accession": "PF02196", + "name": "RBD", + "start": 156, + "end": 227, + "color": "#2dcf00" + }, + { + "accession": "PF00130", + "name": "C1_1", + "start": 235, + "end": 280, + "color": "#ff5353" + }, + { + "accession": "PF07714", + "name": "Pkinase_Tyr", + "start": 458, + "end": 712, + "color": "#5b5bff" + } + ], + "topChanges": [ + { + "change": "V600E", + "pos": 600, + "n": 438, + "pct": 70.4 + }, + { + "change": "D594G", + "pos": 594, + "n": 38, + "pct": 6.1 + }, + { + "change": "G469A", + "pos": 469, + "n": 10, + "pct": 1.6 + }, + { + "change": "A404Cfs*9", + "pos": 403, + "n": 10, + "pct": 1.6 + }, + { + "change": "P403Lfs*8", + "pos": 403, + "n": 9, + "pct": 1.4 + }, + { + "change": "D594N", + "pos": 594, + "n": 8, + "pct": 1.3 + }, + { + "change": "R362Q", + "pos": 362, + "n": 5, + "pct": 0.8 + }, + { + "change": "K601E", + "pos": 601, + "n": 4, + "pct": 0.6 + }, + { + "change": "G469R", + "pos": 469, + "n": 4, + "pct": 0.6 + }, + { + "change": "F595L", + "pos": 595, + "n": 4, + "pct": 0.6 + } + ], + "proteinLength": 766, + "lengthSource": "genome-nexus", + "transcript": "ENST00000288602", + "unpositioned": 0, + "withheld": 111, + "label": { + "pos": 600, + "text": "V600E" + }, + "somaticSamples": 623, + "cohortSamples": 5584, + "tally": { + "missense": { + "driver": 520, + "vus": 8 + }, + "truncating": { + "driver": 0, + "vus": 19 + }, + "inframe": { + "driver": 0, + "vus": 0 + }, + "splice": { + "driver": 0, + "vus": 0 + }, + "fusion": { + "driver": 0, + "vus": 0 + }, + "other": { + "driver": 0, + "vus": 0 + } + }, + "ids": { + "refseq": "NM_004333", + "ccds": "CCDS5863", + "uniprotAccession": "P15056", + "uniprotName": "BRAF_HUMAN", + "ensembl": "ENST00000288602.6" + } + }, + { + "gene": "PIK3CA", + "mutated": 1147, + "mutations": 1330, + "positions": [ + { + "pos": 38, + "n": 23, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R38H", + "n": 10, + "rows": 10, + "driver": true, + "impact": "missense" + }, + { + "change": "R38C", + "n": 8, + "rows": 8, + "driver": true, + "impact": "missense" + }, + { + "change": "R38S", + "n": 5, + "rows": 5, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 23 + } + ] + }, + { + "pos": 81, + "n": 9, + "color": "#53D400", + "impact": "missense", + "driver": false, + "changes": [ + { + "change": "E81K", + "n": 9, + "rows": 9, + "driver": false, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": false, + "rows": 9 + } + ] + }, + { + "pos": 83, + "n": 3, + "color": "#53D400", + "impact": "missense", + "driver": false, + "changes": [ + { + "change": "F83K", + "n": 3, + "rows": 3, + "driver": false, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": false, + "rows": 3 + } + ] + }, + { + "pos": 88, + "n": 47, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R88Q", + "n": 47, + "rows": 47, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 47 + } + ] + }, + { + "pos": 93, + "n": 23, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R93W", + "n": 16, + "rows": 16, + "driver": true, + "impact": "missense" + }, + { + "change": "R93Q", + "n": 7, + "rows": 7, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 23 + } + ] + }, + { + "pos": 106, + "n": 11, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G106V", + "n": 11, + "rows": 11, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 11 + } + ] + }, + { + "pos": 108, + "n": 27, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R108H", + "n": 24, + "rows": 24, + "driver": true, + "impact": "missense" + }, + { + "change": "R108C", + "n": 3, + "rows": 3, + "driver": false, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": false, + "rows": 3 + }, + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 24 + } + ] + }, + { + "pos": 109, + "n": 14, + "color": "#993404", + "impact": "inframe", + "driver": true, + "changes": [ + { + "change": "E110del", + "n": 14, + "rows": 14, + "driver": true, + "impact": "inframe" + } + ], + "types": [ + { + "mtype": "In_Frame_Del", + "driver": true, + "rows": 14 + } + ] + }, + { + "pos": 111, + "n": 17, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "K111E", + "n": 10, + "rows": 10, + "driver": true, + "impact": "missense" + }, + { + "change": "K111N", + "n": 7, + "rows": 7, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 17 + } + ] + }, + { + "pos": 118, + "n": 10, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G118D", + "n": 10, + "rows": 10, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 10 + } + ] + }, + { + "pos": 227, + "n": 5, + "color": "#708090", + "impact": "truncating", + "driver": false, + "changes": [ + { + "change": "T229Lfs*11", + "n": 5, + "rows": 5, + "driver": false, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Del", + "driver": false, + "rows": 5 + } + ] + }, + { + "pos": 344, + "n": 15, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "V344G", + "n": 11, + "rows": 11, + "driver": true, + "impact": "missense" + }, + { + "change": "V344M", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 15 + } + ] + }, + { + "pos": 345, + "n": 23, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "N345K", + "n": 20, + "rows": 20, + "driver": true, + "impact": "missense" + }, + { + "change": "N345I", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 23 + } + ] + }, + { + "pos": 350, + "n": 5, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "D350G", + "n": 5, + "rows": 5, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 5 + } + ] + }, + { + "pos": 357, + "n": 5, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R357Q", + "n": 5, + "rows": 5, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 5 + } + ] + }, + { + "pos": 364, + "n": 3, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G364R", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 365, + "n": 4, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "E365K", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 378, + "n": 5, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "C378R", + "n": 5, + "rows": 5, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 5 + } + ] + }, + { + "pos": 418, + "n": 3, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "E418K", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 420, + "n": 39, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "C420R", + "n": 39, + "rows": 39, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 39 + } + ] + }, + { + "…": "17 more", + "sha256": "9a8135c6776c47e4" + } + ], + "domains": [ + { + "accession": "PF02192", + "name": "PI3K_p85B", + "start": 32, + "end": 108, + "color": "#2dcf00" + }, + { + "accession": "PF00794", + "name": "PI3K_rbd", + "start": 174, + "end": 291, + "color": "#ff5353" + }, + { + "accession": "PF00792", + "name": "PI3K_C2", + "start": 351, + "end": 483, + "color": "#5b5bff" + }, + { + "accession": "PF00613", + "name": "PI3Ka", + "start": 520, + "end": 703, + "color": "#ebd61d" + }, + { + "accession": "PF00454", + "name": "PI3_PI4_kinase", + "start": 798, + "end": 1014, + "color": "#ba21e0" + } + ], + "topChanges": [ + { + "change": "E545K", + "pos": 545, + "n": 253, + "pct": 22.1 + }, + { + "change": "H1047R", + "pos": 1047, + "n": 189, + "pct": 16.5 + }, + { + "change": "E542K", + "pos": 542, + "n": 159, + "pct": 13.9 + }, + { + "change": "R88Q", + "pos": 88, + "n": 47, + "pct": 4.1 + }, + { + "change": "Q546K", + "pos": 546, + "n": 41, + "pct": 3.6 + }, + { + "change": "C420R", + "pos": 420, + "n": 39, + "pct": 3.4 + }, + { + "change": "H1047L", + "pos": 1047, + "n": 24, + "pct": 2.1 + }, + { + "change": "R108H", + "pos": 108, + "n": 24, + "pct": 2.1 + }, + { + "change": "N345K", + "pos": 345, + "n": 20, + "pct": 1.7 + }, + { + "change": "E545G", + "pos": 545, + "n": 19, + "pct": 1.7 + } + ], + "proteinLength": 1068, + "lengthSource": "genome-nexus", + "transcript": "ENST00000263967", + "unpositioned": 0, + "withheld": 231, + "label": { + "pos": 545, + "text": "E545K/G/D" + }, + "somaticSamples": 1147, + "cohortSamples": 5584, + "tally": { + "missense": { + "driver": 1036, + "vus": 41 + }, + "truncating": { + "driver": 0, + "vus": 8 + }, + "inframe": { + "driver": 14, + "vus": 0 + }, + "splice": { + "driver": 0, + "vus": 0 + }, + "fusion": { + "driver": 0, + "vus": 0 + }, + "other": { + "driver": 0, + "vus": 0 + } + }, + "ids": { + "refseq": "NM_006218", + "ccds": "CCDS43171", + "uniprotAccession": "P42336", + "uniprotName": "PK3CA_HUMAN", + "ensembl": "ENST00000263967.3" + } + }, + { + "gene": "TP53", + "mutated": 4080, + "mutations": 4441, + "positions": [ + { + "pos": 10, + "n": 10, + "color": "#e5802b", + "impact": "splice", + "driver": true, + "changes": [ + { + "change": "X10_splice", + "n": 10, + "rows": 10, + "driver": true, + "impact": "splice" + } + ], + "types": [ + { + "mtype": "Splice_Site", + "driver": true, + "rows": 10 + } + ] + }, + { + "pos": 32, + "n": 4, + "color": "#e5802b", + "impact": "splice", + "driver": true, + "changes": [ + { + "change": "X32_splice", + "n": 4, + "rows": 4, + "driver": true, + "impact": "splice" + } + ], + "types": [ + { + "mtype": "Splice_Site", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 33, + "n": 9, + "color": "#e5802b", + "impact": "splice", + "driver": true, + "changes": [ + { + "change": "X33_splice", + "n": 9, + "rows": 9, + "driver": true, + "impact": "splice" + } + ], + "types": [ + { + "mtype": "Splice_Site", + "driver": true, + "rows": 9 + } + ] + }, + { + "pos": 34, + "n": 6, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "P36Afs*7", + "n": 6, + "rows": 6, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Ins", + "driver": true, + "rows": 6 + } + ] + }, + { + "pos": 38, + "n": 8, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "Q38*", + "n": 5, + "rows": 5, + "driver": true, + "impact": "truncating" + }, + { + "change": "Q38Kfs*6", + "n": 3, + "rows": 3, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Nonsense_Mutation", + "driver": true, + "rows": 5 + }, + { + "mtype": "Frame_Shift_Del", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 51, + "n": 4, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "E51*", + "n": 4, + "rows": 4, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Nonsense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 52, + "n": 4, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "Q52*", + "n": 4, + "rows": 4, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Nonsense_Mutation", + "driver": true, + "rows": 4 + } + ] + }, + { + "pos": 53, + "n": 12, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "W53*", + "n": 12, + "rows": 12, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Nonsense_Mutation", + "driver": true, + "rows": 12 + } + ] + }, + { + "pos": 72, + "n": 27, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "V73Rfs*76", + "n": 14, + "rows": 14, + "driver": true, + "impact": "truncating" + }, + { + "change": "V73Wfs*50", + "n": 13, + "rows": 13, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Del", + "driver": true, + "rows": 13 + }, + { + "mtype": "Frame_Shift_Ins", + "driver": true, + "rows": 14 + } + ] + }, + { + "pos": 75, + "n": 6, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "A76Cfs*73", + "n": 3, + "rows": 3, + "driver": true, + "impact": "truncating" + }, + { + "change": "P75Lfs*48", + "n": 3, + "rows": 3, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Ins", + "driver": true, + "rows": 3 + }, + { + "mtype": "Frame_Shift_Del", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 89, + "n": 16, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "S90Pfs*33", + "n": 10, + "rows": 10, + "driver": true, + "impact": "truncating" + }, + { + "change": "S90Lfs*59", + "n": 6, + "rows": 6, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Del", + "driver": true, + "rows": 10 + }, + { + "mtype": "Frame_Shift_Ins", + "driver": true, + "rows": 6 + } + ] + }, + { + "pos": 91, + "n": 12, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "W91*", + "n": 12, + "rows": 12, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Nonsense_Mutation", + "driver": true, + "rows": 12 + } + ] + }, + { + "pos": 104, + "n": 6, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "Q104*", + "n": 6, + "rows": 6, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Nonsense_Mutation", + "driver": true, + "rows": 6 + } + ] + }, + { + "pos": 105, + "n": 9, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "G105V", + "n": 6, + "rows": 6, + "driver": true, + "impact": "missense" + }, + { + "change": "G105C", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 9 + } + ] + }, + { + "pos": 109, + "n": 3, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "F109S", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 110, + "n": 11, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "R110L", + "n": 7, + "rows": 7, + "driver": true, + "impact": "missense" + }, + { + "change": "R110P", + "n": 4, + "rows": 4, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 11 + } + ] + }, + { + "pos": 111, + "n": 6, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "L111P", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + }, + { + "change": "L111Q", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 6 + } + ] + }, + { + "pos": 113, + "n": 3, + "color": "#008000", + "impact": "missense", + "driver": true, + "changes": [ + { + "change": "F113C", + "n": 3, + "rows": 3, + "driver": true, + "impact": "missense" + } + ], + "types": [ + { + "mtype": "Missense_Mutation", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 114, + "n": 3, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "H115Afs*34", + "n": 3, + "rows": 3, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Ins", + "driver": true, + "rows": 3 + } + ] + }, + { + "pos": 122, + "n": 8, + "color": "#000000", + "impact": "truncating", + "driver": true, + "changes": [ + { + "change": "V122Dfs*26", + "n": 8, + "rows": 8, + "driver": true, + "impact": "truncating" + } + ], + "types": [ + { + "mtype": "Frame_Shift_Del", + "driver": true, + "rows": 8 + } + ] + }, + { + "…": "121 more", + "sha256": "7f03d7086ff7ec0c" + } + ], + "domains": [ + { + "accession": "PF08563", + "name": "P53_TAD", + "start": 6, + "end": 29, + "color": "#2dcf00" + }, + { + "accession": "PF00870", + "name": "P53", + "start": 95, + "end": 288, + "color": "#ff5353" + }, + { + "accession": "PF07710", + "name": "P53_tetramer", + "start": 318, + "end": 358, + "color": "#5b5bff" + } + ], + "topChanges": [ + { + "change": "R175H", + "pos": 175, + "n": 391, + "pct": 9.6 + }, + { + "change": "R282W", + "pos": 282, + "n": 219, + "pct": 5.4 + }, + { + "change": "R248Q", + "pos": 248, + "n": 183, + "pct": 4.5 + }, + { + "change": "R273C", + "pos": 273, + "n": 182, + "pct": 4.5 + }, + { + "change": "R273H", + "pos": 273, + "n": 179, + "pct": 4.4 + }, + { + "change": "R248W", + "pos": 248, + "n": 146, + "pct": 3.6 + }, + { + "change": "R213*", + "pos": 213, + "n": 141, + "pct": 3.5 + }, + { + "change": "G245S", + "pos": 245, + "n": 119, + "pct": 2.9 + }, + { + "change": "R196*", + "pos": 196, + "n": 107, + "pct": 2.6 + }, + { + "change": "R342*", + "pos": 342, + "n": 90, + "pct": 2.2 + } + ], + "proteinLength": 393, + "lengthSource": "genome-nexus", + "transcript": "ENST00000269305", + "unpositioned": 0, + "withheld": 717, + "label": { + "pos": 175, + "text": "R175H/C/L" + }, + "somaticSamples": 4088, + "cohortSamples": 5584, + "tally": { + "missense": { + "driver": 2628, + "vus": 26 + }, + "truncating": { + "driver": 796, + "vus": 0 + }, + "inframe": { + "driver": 30, + "vus": 0 + }, + "splice": { + "driver": 244, + "vus": 0 + }, + "fusion": { + "driver": 0, + "vus": 0 + }, + "other": { + "driver": 0, + "vus": 0 + } + }, + "ids": { + "refseq": "NM_000546", + "ccds": "CCDS11118", + "uniprotAccession": "P04637", + "uniprotName": "P53_HUMAN", + "ensembl": "ENST00000269305.4" + } + } + ], + "studies": [ + "msk_chord_2024" + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "Mutations in “CRC” by protein position, as cBioPortal's mutation tab draws them: one stem per codon (the stored protein start position), its height the number of distinct patient + protein change pairs there. Colour is the codon's dominant mutation type, putative drivers before VUS (driver = OncoKB oncogenic, pinned; the portal also counts hotspots and custom annotations). VUS and germline mutations are included, as they are by default on the portal. A suppression floor of 3 patients per change was applied BY EACH SITE before returning anything, withholding 1,112 mutations." + } + ] +} diff --git a/test/snapshots/hotspots.sql b/test/snapshots/hotspots.sql new file mode 100644 index 0000000..299c20a --- /dev/null +++ b/test/snapshots/hotspots.sql @@ -0,0 +1,62 @@ +-- cohort CRC +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) + +-- view 0 hotspots: lollipop:changes · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), + m AS (SELECT `GENE.hugoGeneSymbol` AS gene, proteinPosStart AS pos, proteinChange AS change, mutationType AS mtype, + patientId AS pid, sampleId AS sid, mutationStatus AS status, if((`GENE.hugoGeneSymbol`, proteinChange) IN (SELECT hugo_gene_symbol, alteration FROM oncokb_annotation.variant_annotation + WHERE oncokb_version = 'v7.5' AND is_driver AND alteration_type = 'MUTATION'), 1, 0) AS driver + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND `GENE.hugoGeneSymbol` IN ('KRAS','BRAF','PIK3CA','TP53') + AND molecularProfileId NOT LIKE '%uncalled%' AND proteinChange != '' + AND patientId IN (SELECT pid FROM cohort)), + kept AS (SELECT gene, pos, change FROM m GROUP BY gene, pos, change HAVING uniqExact(pid) >= 3) +SELECT gene, pos, change, uniqExact(pid) AS n, count() AS rows, max(driver) AS driver, topK(1)(multiIf(lowerUTF8(mtype) IN ('missense_mutation', 'missense', 'missense_variant'), 'missense', lowerUTF8(mtype) IN ('frame_shift_ins', 'frame_shift_del', 'frameshift', 'frameshift_deletion', 'frameshift_insertion', 'de_novo_start_outofframe', 'frameshift_variant', 'nonsense_mutation', 'nonsense', 'stopgain_snv', 'stop_gained', 'translation_start_site', 'initiator_codon_variant', 'start_codon_snp', 'start_codon_del', 'nonstop_mutation', 'stop_lost', 'truncating', 'feature_truncation'), 'truncating', lowerUTF8(mtype) IN ('inframe_del', 'inframe_deletion', 'in_frame_del', 'in_frame_deletion', 'inframe_ins', 'inframe_insertion', 'in_frame_ins', 'in_frame_insertion', 'indel', 'nonframeshift_deletion', 'nonframeshift', 'nonframeshift insertion', 'nonframeshift_insertion', 'inframe'), 'inframe', lowerUTF8(mtype) IN ('splice_site', 'splice', 'splice site', 'splicing', 'splice_site_snp', 'splice_site_del', 'splice_site_indel', 'splice_region_variant', 'splice_region'), 'splice', lowerUTF8(mtype) IN ('fusion'), 'fusion', 'other'))[1] AS impact +FROM m GROUP BY gene, pos, change HAVING n >= 3 + +-- view 0 hotspots: lollipop:samples · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))) +SELECT uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived +WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + +-- view 0 hotspots: lollipop:totals · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), + m AS (SELECT `GENE.hugoGeneSymbol` AS gene, proteinPosStart AS pos, proteinChange AS change, mutationType AS mtype, + patientId AS pid, sampleId AS sid, mutationStatus AS status, 1 AS driver + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND `GENE.hugoGeneSymbol` IN ('KRAS','BRAF','PIK3CA','TP53') + AND molecularProfileId NOT LIKE '%uncalled%' AND proteinChange != '' + AND patientId IN (SELECT pid FROM cohort)), + kept AS (SELECT gene, pos, change FROM m GROUP BY gene, pos, change HAVING uniqExact(pid) >= 1) +SELECT gene, uniqExact(pid) AS patients, uniqExact((pid, change)) AS pairs, + uniqExactIf(sid, status != 'GERMLINE') AS somatic_samples +FROM m GROUP BY gene + +-- view 0 hotspots: lollipop:types · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), + m AS (SELECT `GENE.hugoGeneSymbol` AS gene, proteinPosStart AS pos, proteinChange AS change, mutationType AS mtype, + patientId AS pid, sampleId AS sid, mutationStatus AS status, if((`GENE.hugoGeneSymbol`, proteinChange) IN (SELECT hugo_gene_symbol, alteration FROM oncokb_annotation.variant_annotation + WHERE oncokb_version = 'v7.5' AND is_driver AND alteration_type = 'MUTATION'), 1, 0) AS driver + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND `GENE.hugoGeneSymbol` IN ('KRAS','BRAF','PIK3CA','TP53') + AND molecularProfileId NOT LIKE '%uncalled%' AND proteinChange != '' + AND patientId IN (SELECT pid FROM cohort)), + kept AS (SELECT gene, pos, change FROM m GROUP BY gene, pos, change HAVING uniqExact(pid) >= 3) +SELECT gene, pos, mtype, driver, count() AS rows +FROM m WHERE (gene, ifNull(pos, -1), change) IN (SELECT gene, ifNull(pos, -1), change FROM kept) GROUP BY gene, pos, mtype, driver diff --git a/test/snapshots/hotspots.svg b/test/snapshots/hotspots.svg new file mode 100644 index 0000000..8cd340e --- /dev/null +++ b/test/snapshots/hotspots.svg @@ -0,0 +1,355 @@ + +Mutations by protein position — KRAS, BRAF, PIK3CA, TP53KRAS2,424 mutations · 2,362 mutated patients05001,0001,5002,000# KRAS MutationsRas (PF00071): 5–164Ras020406080100120140160188aacodon 10: 5 mutations +G10dup 5codon 12: 1,583 mutations +G12D 688 +G12V 487 +G12C 162 +G12S 109 +G12A 108 +G12R 26 +G12F 3codon 13: 446 mutations +G13D 426 +G13C 20codon 14: 10 mutations +V14I 10codon 33: 6 mutations +D33E 6codon 57: 3 mutations +D57N 3codon 59: 13 mutations +A59T 13codon 60: 18 mutations +Q61K 18codon 61: 82 mutations +Q61H 55 +Q61R 15 +Q61L 8 +Q61K 4codon 68: 3 mutations +R68S 3codon 117: 26 mutations +K117N 26codon 146: 176 mutations +A146T 140 +A146V 27 +A146P 9G12D/V/C and 4 moreMissenseMissense (VUS)InframeBRAF658 mutations · 622 mutated patients0100200300400500# BRAF MutationsRBD (PF02196): 156–227RBDC1_1 (PF00130): 235–280C1_1Pkinase_Tyr (PF07714): 458–712Pkinase_Tyr0100200300400500600700766aacodon 241: 4 mutations +T241M 4codon 362: 5 mutations +R362Q 5codon 403: 19 mutations +A404Cfs*9 10 +P403Lfs*8 9codon 466: 6 mutations +G466E 3 +G466V 3codon 469: 14 mutations +G469A 10 +G469R 4codon 581: 4 mutations +N581S 4codon 594: 46 mutations +D594G 38 +D594N 8codon 595: 4 mutations +F595L 4codon 600: 438 mutations +V600E 438codon 601: 4 mutations +K601E 4codon 762: 3 mutations +A762V 3V600EMissenseMissense (VUS)Truncating (VUS)PIK3CA1,330 mutations · 1,147 mutated patients0100200300# PIK3CA MutationsPI3K_p85B (PF02192): 32–108PI3K_p85BPI3K_…PI3K_rbd (PF00794): 174–291PI3K_rbdPI3K_C2 (PF00792): 351–483PI3K_C2PI3Ka (PF00613): 520–703PI3KaPI3_PI4_kinase (PF00454): 798–1014PI3_PI4_kinase02004006008001,068aacodon 38: 23 mutations +R38H 10 +R38C 8 +R38S 5codon 81: 9 mutations +E81K 9codon 83: 3 mutations +F83K 3codon 88: 47 mutations +R88Q 47codon 93: 23 mutations +R93W 16 +R93Q 7codon 106: 11 mutations +G106V 11codon 108: 27 mutations +R108H 24 +R108C 3codon 109: 14 mutations +E110del 14codon 111: 17 mutations +K111E 10 +K111N 7codon 118: 10 mutations +G118D 10codon 227: 5 mutations +T229Lfs*11 5codon 344: 15 mutations +V344G 11 +V344M 4codon 345: 23 mutations +N345K 20 +N345I 3codon 350: 5 mutations +D350G 5codon 357: 5 mutations +R357Q 5codon 364: 3 mutations +G364R 3codon 365: 4 mutations +E365K 4codon 378: 5 mutations +C378R 5codon 418: 3 mutations +E418K 3codon 420: 39 mutations +C420R 39codon 453: 10 mutations +E453K 10codon 542: 163 mutations +E542K 159 +E542Q 4codon 545: 276 mutations +E545K 253 +E545G 19 +E545D 4codon 546: 60 mutations +Q546K 41 +Q546R 10 +Q546P 5 +Q546H 4codon 726: 12 mutations +E726K 12codon 808: 4 mutations +R808W 4codon 901: 4 mutations +C901F 4codon 1004: 3 mutations +M1004I 3codon 1007: 4 mutations +G1007R 4codon 1021: 10 mutations +Y1021C 10codon 1023: 3 mutations +R1023* 3codon 1025: 9 mutations +T1025A 9codon 1043: 12 mutations +M1043I 9 +M1043V 3codon 1044: 3 mutations +N1044K 3codon 1047: 226 mutations +H1047R 189 +H1047L 24 +H1047Y 13codon 1049: 6 mutations +G1049R 6codon 1065: 3 mutations +H1065Y 3E545K/G/DMissenseMissense (VUS)Truncating (VUS)InframeTP534,441 mutations · 4,080 mutated patients0100200300400500# TP53 MutationsP53_TAD (PF08563): 6–29P53_TADP53_…P53 (PF00870): 95–288P53P53_tetramer (PF07710): 318–358P53_tetramerP53_tetra…050100150200250300350393aacodon 10: 10 mutations +X10_splice 10codon 32: 4 mutations +X32_splice 4codon 33: 9 mutations +X33_splice 9codon 34: 6 mutations +P36Afs*7 6codon 38: 8 mutations +Q38* 5 +Q38Kfs*6 3codon 51: 4 mutations +E51* 4codon 52: 4 mutations +Q52* 4codon 53: 12 mutations +W53* 12codon 72: 27 mutations +V73Rfs*76 14 +V73Wfs*50 13codon 75: 6 mutations +A76Cfs*73 3 +P75Lfs*48 3codon 89: 16 mutations +S90Pfs*33 10 +S90Lfs*59 6codon 91: 12 mutations +W91* 12codon 104: 6 mutations +Q104* 6codon 105: 9 mutations +G105V 6 +G105C 3codon 109: 3 mutations +F109S 3codon 110: 11 mutations +R110L 7 +R110P 4codon 111: 6 mutations +L111P 3 +L111Q 3codon 113: 3 mutations +F113C 3codon 114: 3 mutations +H115Afs*34 3codon 122: 8 mutations +V122Dfs*26 8codon 124: 3 mutations +C124Wfs*25 3codon 125: 27 mutations +X125_splice 16 +T125M 11codon 126: 49 mutations +X126_splice 34 +Y126C 6 +Y126H 5 +Y126* 4codon 127: 10 mutations +S127F 7 +S127P 3codon 130: 11 mutations +L130F 4 +L130V 4 +L130Sfs*40 3codon 131: 5 mutations +N131del 5codon 132: 27 mutations +K132R 13 +K132N 11 +K132E 3codon 133: 4 mutations +M133T 4codon 134: 5 mutations +F134L 5codon 135: 30 mutations +C135F 14 +C135Y 13 +C135R 3codon 136: 8 mutations +Q136* 8codon 138: 7 mutations +A138V 7codon 141: 19 mutations +C141Y 11 +C141R 5 +C141W 3codon 143: 9 mutations +V143M 9codon 144: 5 mutations +Q144* 5codon 146: 20 mutations +W146* 20codon 151: 30 mutations +P151S 17 +P151T 6 +P151H 4 +P151R 3codon 152: 48 mutations +P152L 25 +P153Afs*28 9 +P152Afs*14 8 +P152Rfs*18 6codon 154: 5 mutations +G154V 5codon 156: 3 mutations +R156P 3codon 157: 8 mutations +V157F 5 +V157I 3codon 158: 38 mutations +R158H 30 +R158C 5 +R158L 3codon 159: 15 mutations +A159V 8 +A159P 7codon 161: 19 mutations +A161T 16 +A161D 3codon 163: 11 mutations +Y163C 11codon 165: 6 mutations +Q165* 6codon 166: 4 mutations +S166* 4codon 167: 6 mutations +Q167* 6codon 168: 5 mutations +H168R 5codon 170: 3 mutations +T170M 3codon 171: 3 mutations +E171* 3codon 172: 5 mutations +V172F 5codon 173: 40 mutations +V173M 20 +V173L 17 +V173A 3codon 175: 403 mutations +R175H 391 +R175C 9 +R175L 3codon 176: 58 mutations +C176F 24 +C176Y 20 +C176S 7 +C176R 4 +C176* 3codon 177: 9 mutations +P177_C182del 9codon 178: 12 mutations +H178Tfs*69 5 +H178P 4 +H178Pfs*3 3codon 179: 45 mutations +H179Y 19 +H179R 12 +H179Q 7 +H179L 4 +H179D 3codon 181: 20 mutations +R181H 11 +R181C 9codon 183: 3 mutations +S183* 3codon 187: 36 mutations +X187_splice 36codon 190: 23 mutations +P190L 13 +P190T 7 +P190Lfs*57 3codon 191: 5 mutations +P191del 5codon 192: 8 mutations +Q192* 8codon 193: 26 mutations +H193R 14 +H193Y 6 +H193L 3 +H193N 3codon 194: 16 mutations +L194R 6 +L194F 4 +L194H 3 +L194P 3codon 195: 23 mutations +I195T 13 +I195F 4 +I195N 3 +I195S 3codon 196: 111 mutations +R196* 107 +R196Q 4codon 197: 12 mutations +V197M 12codon 198: 5 mutations +E198* 5codon 199: 5 mutations +G199V 5codon 204: 6 mutations +E204* 6codon 205: 15 mutations +Y205C 7 +Y205H 5 +Y205D 3codon 209: 13 mutations +R209Kfs*6 13codon 211: 6 mutations +T211I 6codon 212: 5 mutations +F212Sfs*3 5codon 213: 160 mutations +R213* 141 +R213Q 10 +R213L 9codon 214: 11 mutations +H214R 6 +H214Qfs*7 5codon 215: 12 mutations +S215G 5 +S215N 4 +S215R 3codon 216: 15 mutations +V216M 10 +V216L 5codon 220: 35 mutations +Y220C 35codon 222: 3 mutations +P222L 3codon 224: 33 mutations +X224_splice 24 +E224D 5 +E224* 4codon 225: 21 mutations +X225_splice 21codon 227: 3 mutations +D228* 3codon 229: 5 mutations +C229Yfs*10 5codon 234: 26 mutations +Y234C 17 +Y234H 5 +Y234* 4codon 236: 15 mutations +Y236C 10 +Y236N 5codon 237: 22 mutations +M237I 22codon 238: 16 mutations +C238Y 16codon 239: 10 mutations +N239D 7 +N239S 3codon 241: 26 mutations +S241F 8 +C242Afs*5 7 +S241Y 5 +S241C 3 +S241P 3codon 242: 28 mutations +C242Y 12 +C242F 10 +C242S 6codon 244: 20 mutations +G244D 10 +G244S 6 +G244C 4codon 245: 144 mutations +G245S 119 +G245D 13 +G245V 7 +G245C 5codon 246: 4 mutations +M246V 4codon 248: 334 mutations +R248Q 183 +R248W 146 +R248L 5codon 249: 17 mutations +R249W 6 +R249S 5 +R249G 3 +R249M 3codon 250: 12 mutations +P250L 12codon 253: 3 mutations +T253Nfs*11 3codon 254: 6 mutations +I254N 3 +I254T 3codon 255: 13 mutations +I255T 7 +I255del 6codon 257: 10 mutations +L257P 7 +L257R 3codon 258: 28 mutations +E258K 11 +E258* 7 +E258G 7 +E258D 3codon 259: 7 mutations +D259Y 7codon 261: 26 mutations +X261_splice 26codon 262: 6 mutations +G262V 6codon 264: 5 mutations +L265del 5codon 265: 5 mutations +L265P 5codon 266: 43 mutations +G266E 22 +G266R 10 +G266* 6 +G266V 5codon 267: 13 mutations +R267W 9 +R267Q 4codon 270: 14 mutations +F270L 9 +F270C 5codon 271: 10 mutations +E271* 6 +E271K 4codon 272: 17 mutations +V272M 9 +V272L 5 +V272E 3codon 273: 371 mutations +R273C 182 +R273H 179 +R273L 7 +R273P 3codon 274: 10 mutations +V274A 6 +V274F 4codon 275: 12 mutations +C275F 7 +C275Y 5codon 277: 4 mutations +C277F 4codon 278: 31 mutations +P278S 9 +P278L 6 +P278R 5 +P278T 5 +P278A 3 +P278H 3codon 280: 11 mutations +R280K 5 +R280* 3 +R280G 3codon 281: 10 mutations +D281G 5 +D281N 5codon 282: 219 mutations +R282W 219codon 285: 11 mutations +E285K 11codon 286: 22 mutations +E286K 19 +E286G 3codon 290: 3 mutations +R290H 3codon 294: 10 mutations +E294* 7 +E294Sfs*51 3codon 298: 6 mutations +E298* 6codon 301: 10 mutations +P301Qfs*44 7 +G302Rfs*4 3codon 306: 76 mutations +R306* 76codon 307: 27 mutations +X307_splice 27codon 317: 6 mutations +Q317* 6codon 321: 4 mutations +K321Nfs*24 4codon 327: 3 mutations +Y327* 3codon 331: 26 mutations +X331_splice 23 +Q331* 3codon 332: 14 mutations +X332_splice 14codon 337: 14 mutations +R337C 14codon 339: 4 mutations +E339* 4codon 342: 93 mutations +R342* 90 +R342Efs*3 3codon 349: 3 mutations +E349* 3codon 373: 5 mutations +K373Rfs*49 5codon 382: 21 mutations +K382Nfs*40 21R175H/C/LMissenseMissense (VUS)TruncatingInframeSpliceMutations in “CRC” by protein position, as cBioPortal's mutation tab draws them: one stem per codon (the stored protein start position), its height thenumber of distinct patient + protein change pairs there. Colour is the codon's dominant mutation type, putative drivers before VUS (driver = OncoKBoncogenic, pinned; the portal also counts hotspots and custom annotations). VUS and germline mutations are included, as they are by default on the portal. Asuppression floor of 3 patients per change was applied BY EACH SITE before returning anything, withholding 1,112 mutations. KRAS: somatic mutationfrequency 42.5%; mutation rows missense 2,365 driver / 3 VUS, inframe 5 driver / 0 VUS. BRAF: somatic mutation frequency 11.2%; mutation rowsmissense 520 driver / 8 VUS, truncating 0 driver / 19 VUS. PIK3CA: somatic mutation frequency 20.5%; mutation rows missense 1,036 driver / 41 VUS,truncating 0 driver / 8 VUS, inframe 14 driver / 0 VUS. TP53: somatic mutation frequency 73.2%; mutation rows missense 2,628 driver / 26 VUS, truncating796 driver / 0 VUS, inframe 30 driver / 0 VUS, splice 244 driver / 0 VUS. diff --git a/test/snapshots/hotspots.txt b/test/snapshots/hotspots.txt new file mode 100644 index 0000000..b1b7c3d --- /dev/null +++ b/test/snapshots/hotspots.txt @@ -0,0 +1,12 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- CRC: 5,543 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) + +Mutations by protein position (commonest changes; share of patients mutated in THAT gene): + KRAS: 2,362 mutated, 2,424 mutations on 12 codons — G12D 688 (29.1%), G12V 487 (20.6%), G13D 426 (18%), G12C 162 (6.9%), A146T 140 (5.9%), G12S 109 (4.6%) [53 below the suppression floor] + BRAF: 622 mutated, 658 mutations on 11 codons — V600E 438 (70.4%), D594G 38 (6.1%), G469A 10 (1.6%), A404Cfs*9 10 (1.6%), P403Lfs*8 9 (1.4%), D594N 8 (1.3%) [111 below the suppression floor] + PIK3CA: 1,147 mutated, 1,330 mutations on 37 codons — E545K 253 (22.1%), H1047R 189 (16.5%), E542K 159 (13.9%), R88Q 47 (4.1%), Q546K 41 (3.6%), C420R 39 (3.4%) [231 below the suppression floor] + TP53: 4,080 mutated, 4,441 mutations on 141 codons — R175H 391 (9.6%), R282W 219 (5.4%), R248Q 183 (4.5%), R273C 182 (4.5%), R273H 179 (4.4%), R248W 146 (3.6%) [717 below the suppression floor] + KRAS: somatic mutation frequency 42.5%; mutation rows missense 2,365 driver / 3 VUS, inframe 5 driver / 0 VUS. BRAF: somatic mutation frequency 11.2%; mutation rows missense 520 driver / 8 VUS, truncating 0 driver / 19 VUS. PIK3CA: somatic mutation frequency 20.5%; mutation rows missense 1,036 driver / 41 VUS, truncating 0 driver / 8 VUS, inframe 14 driver / 0 VUS. TP53: somatic mutation frequency 73.2%; mutation rows missense 2,628 driver / 26 VUS, truncating 796 driver / 0 VUS, inframe 30 driver / 0 VUS, splice 244 driver / 0 VUS. + Mutations in “CRC” by protein position, as cBioPortal's mutation tab draws them: one stem per codon (the stored protein start position), its height the number of distinct patient + protein change pairs there. Colour is the codon's dominant mutation type, putative drivers before VUS (driver = OncoKB oncogenic, pinned; the portal also counts hotspots and custom annotations). VUS and germline mutations are included, as they are by default on the portal. A suppression floor of 3 patients per change was applied BY EACH SITE before returning anything, withholding 1,112 mutations. diff --git a/test/snapshots/incidence.json b/test/snapshots/incidence.json new file mode 100644 index 0000000..27d85a7 --- /dev/null +++ b/test/snapshots/incidence.json @@ -0,0 +1,836 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "NSCLC": { + "count": 7809, + "text": "CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + }, + "Breast": { + "count": 5368, + "text": "CANCER_TYPE in [Breast Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + }, + "Colorectal": { + "count": 5543, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "incidence", + "cohorts": [ + "NSCLC", + "Breast", + "Colorectal" + ], + "incidence": { + "eventLabel": "brain metastasis", + "curves": [ + { + "cohort": "NSCLC", + "n": 6457, + "events": 1406, + "competing": 1967, + "censored": 3084, + "points": [ + { + "t": 0.0329, + "f1": 0.00341, + "f2": 0.00155, + "se1": 0.00073, + "atRisk": 6457 + }, + { + "t": 0.0657, + "f1": 0.00621, + "f2": 0.00155, + "se1": 0.00098, + "atRisk": 6399 + }, + { + "t": 0.0658, + "f1": 0.00621, + "f2": 0.00202, + "se1": 0.00098, + "atRisk": 6381 + }, + { + "t": 0.0986, + "f1": 0.00838, + "f2": 0.00217, + "se1": 0.00114, + "atRisk": 6378 + }, + { + "t": 0.1314, + "f1": 0.00963, + "f2": 0.00217, + "se1": 0.00122, + "atRisk": 6362 + }, + { + "t": 0.1315, + "f1": 0.00963, + "f2": 0.00233, + "se1": 0.00122, + "atRisk": 6354 + }, + { + "t": 0.1643, + "f1": 0.01118, + "f2": 0.00233, + "se1": 0.00131, + "atRisk": 6352 + }, + { + "t": 0.1644, + "f1": 0.01118, + "f2": 0.00264, + "se1": 0.00131, + "atRisk": 6342 + }, + { + "t": 0.1971, + "f1": 0.01367, + "f2": 0.00264, + "se1": 0.00145, + "atRisk": 6339 + }, + { + "t": 0.1973, + "f1": 0.01367, + "f2": 0.00295, + "se1": 0.00145, + "atRisk": 6323 + }, + { + "t": 0.23, + "f1": 0.01585, + "f2": 0.00295, + "se1": 0.00156, + "atRisk": 6320 + }, + { + "t": 0.2301, + "f1": 0.01585, + "f2": 0.00342, + "se1": 0.00156, + "atRisk": 6306 + }, + { + "t": 0.2628, + "f1": 0.0171, + "f2": 0.00342, + "se1": 0.00162, + "atRisk": 6299 + }, + { + "t": 0.263, + "f1": 0.0171, + "f2": 0.00357, + "se1": 0.00162, + "atRisk": 6291 + }, + { + "t": 0.2957, + "f1": 0.01834, + "f2": 0.00357, + "se1": 0.00167, + "atRisk": 6289 + }, + { + "t": 0.2959, + "f1": 0.01834, + "f2": 0.00404, + "se1": 0.00167, + "atRisk": 6281 + }, + { + "t": 0.3285, + "f1": 0.01912, + "f2": 0.00404, + "se1": 0.00171, + "atRisk": 6277 + }, + { + "t": 0.3288, + "f1": 0.01912, + "f2": 0.00482, + "se1": 0.00171, + "atRisk": 6272 + }, + { + "t": 0.3614, + "f1": 0.02006, + "f2": 0.00482, + "se1": 0.00175, + "atRisk": 6266 + }, + { + "t": 0.3943, + "f1": 0.0213, + "f2": 0.00482, + "se1": 0.0018, + "atRisk": 6257 + }, + { + "…": "1763 more", + "sha256": "f95d2278c077fc4d" + } + ], + "excluded": { + "prior": 1352, + "unobserved": 0, + "noFollowup": 0, + "noAnchor": 0 + }, + "late": 0 + }, + { + "cohort": "Breast", + "n": 4723, + "events": 905, + "competing": 956, + "censored": 2862, + "points": [ + { + "t": 0.0329, + "f1": 0.00085, + "f2": 0.00106, + "se1": 0.00042, + "atRisk": 4723 + }, + { + "t": 0.0657, + "f1": 0.00127, + "f2": 0.00106, + "se1": 0.00052, + "atRisk": 4684 + }, + { + "t": 0.0986, + "f1": 0.00191, + "f2": 0.00106, + "se1": 0.00064, + "atRisk": 4682 + }, + { + "t": 0.1314, + "f1": 0.00213, + "f2": 0.00106, + "se1": 0.00067, + "atRisk": 4678 + }, + { + "t": 0.1315, + "f1": 0.00213, + "f2": 0.00127, + "se1": 0.00067, + "atRisk": 4677 + }, + { + "t": 0.1643, + "f1": 0.00298, + "f2": 0.00127, + "se1": 0.00079, + "atRisk": 4676 + }, + { + "t": 0.1644, + "f1": 0.00298, + "f2": 0.0017, + "se1": 0.00079, + "atRisk": 4672 + }, + { + "t": 0.1971, + "f1": 0.00426, + "f2": 0.0017, + "se1": 0.00095, + "atRisk": 4669 + }, + { + "t": 0.1973, + "f1": 0.00426, + "f2": 0.00191, + "se1": 0.00095, + "atRisk": 4663 + }, + { + "t": 0.23, + "f1": 0.00532, + "f2": 0.00191, + "se1": 0.00106, + "atRisk": 4662 + }, + { + "t": 0.2301, + "f1": 0.00532, + "f2": 0.00212, + "se1": 0.00106, + "atRisk": 4657 + }, + { + "t": 0.2628, + "f1": 0.00596, + "f2": 0.00212, + "se1": 0.00112, + "atRisk": 4655 + }, + { + "t": 0.2957, + "f1": 0.0066, + "f2": 0.00212, + "se1": 0.00118, + "atRisk": 4652 + }, + { + "t": 0.2959, + "f1": 0.0066, + "f2": 0.00255, + "se1": 0.00118, + "atRisk": 4649 + }, + { + "t": 0.3288, + "f1": 0.0066, + "f2": 0.00276, + "se1": 0.00118, + "atRisk": 4646 + }, + { + "t": 0.3614, + "f1": 0.00682, + "f2": 0.00276, + "se1": 0.0012, + "atRisk": 4644 + }, + { + "t": 0.3943, + "f1": 0.00831, + "f2": 0.00276, + "se1": 0.00132, + "atRisk": 4642 + }, + { + "t": 0.3945, + "f1": 0.00831, + "f2": 0.00298, + "se1": 0.00132, + "atRisk": 4635 + }, + { + "t": 0.4271, + "f1": 0.00874, + "f2": 0.00298, + "se1": 0.00136, + "atRisk": 4633 + }, + { + "t": 0.46, + "f1": 0.00895, + "f2": 0.00298, + "se1": 0.00137, + "atRisk": 4631 + }, + { + "…": "1337 more", + "sha256": "3d7224636833ad18" + } + ], + "excluded": { + "prior": 645, + "unobserved": 0, + "noFollowup": 0, + "noAnchor": 0 + }, + "late": 0 + }, + { + "cohort": "Colorectal", + "n": 5439, + "events": 447, + "competing": 1783, + "censored": 3209, + "points": [ + { + "t": 0.0329, + "f1": 0.00018, + "f2": 0.00092, + "se1": 0.00018, + "atRisk": 5439 + }, + { + "t": 0.1314, + "f1": 0.00055, + "f2": 0.00092, + "se1": 0.00032, + "atRisk": 5392 + }, + { + "t": 0.1643, + "f1": 0.00074, + "f2": 0.00092, + "se1": 0.00037, + "atRisk": 5389 + }, + { + "t": 0.1971, + "f1": 0.0013, + "f2": 0.00092, + "se1": 0.00049, + "atRisk": 5385 + }, + { + "t": 0.1973, + "f1": 0.0013, + "f2": 0.0011, + "se1": 0.00049, + "atRisk": 5382 + }, + { + "t": 0.23, + "f1": 0.00148, + "f2": 0.0011, + "se1": 0.00052, + "atRisk": 5380 + }, + { + "t": 0.2301, + "f1": 0.00148, + "f2": 0.00185, + "se1": 0.00052, + "atRisk": 5379 + }, + { + "t": 0.263, + "f1": 0.00148, + "f2": 0.00203, + "se1": 0.00052, + "atRisk": 5371 + }, + { + "t": 0.2957, + "f1": 0.00185, + "f2": 0.00203, + "se1": 0.00059, + "atRisk": 5369 + }, + { + "t": 0.3288, + "f1": 0.00185, + "f2": 0.0024, + "se1": 0.00059, + "atRisk": 5365 + }, + { + "t": 0.3614, + "f1": 0.00204, + "f2": 0.0024, + "se1": 0.00061, + "atRisk": 5361 + }, + { + "t": 0.3616, + "f1": 0.00204, + "f2": 0.00259, + "se1": 0.00061, + "atRisk": 5360 + }, + { + "t": 0.3945, + "f1": 0.00204, + "f2": 0.00277, + "se1": 0.00061, + "atRisk": 5358 + }, + { + "t": 0.4271, + "f1": 0.00222, + "f2": 0.00277, + "se1": 0.00064, + "atRisk": 5354 + }, + { + "t": 0.4274, + "f1": 0.00222, + "f2": 0.00315, + "se1": 0.00064, + "atRisk": 5353 + }, + { + "t": 0.46, + "f1": 0.00241, + "f2": 0.00315, + "se1": 0.00067, + "atRisk": 5350 + }, + { + "t": 0.4603, + "f1": 0.00241, + "f2": 0.00352, + "se1": 0.00067, + "atRisk": 5349 + }, + { + "t": 0.526, + "f1": 0.00241, + "f2": 0.0037, + "se1": 0.00067, + "atRisk": 5346 + }, + { + "t": 0.5585, + "f1": 0.0026, + "f2": 0.0037, + "se1": 0.00069, + "atRisk": 5344 + }, + { + "t": 0.6247, + "f1": 0.0026, + "f2": 0.00408, + "se1": 0.00069, + "atRisk": 5342 + }, + { + "…": "1399 more", + "sha256": "75820d7e0cbdd51a" + } + ], + "excluded": { + "prior": 104, + "unobserved": 0, + "noFollowup": 0, + "noAnchor": 0 + }, + "late": 0 + } + ], + "horizons": [ + { + "months": 12, + "cells": [ + { + "cohort": "NSCLC", + "f1": 0.13109119321243984, + "lo": 0.12275472329176881, + "hi": 0.13942766313311086, + "naive": 0.14090000000000003, + "atRisk": 4223 + }, + { + "cohort": "Breast", + "f1": 0.09076442001016774, + "lo": 0.08245310725479074, + "hi": 0.09907573276554474, + "naive": 0.09450000000000003, + "atRisk": 3667 + }, + { + "cohort": "Colorectal", + "f1": 0.0314726097593687, + "lo": 0.026729157383594535, + "hi": 0.03621606213514286, + "naive": 0.033399999999999985, + "atRisk": 4109 + } + ] + }, + { + "months": 24, + "cells": [ + { + "cohort": "NSCLC", + "f1": 0.18355912082668832, + "lo": 0.17377663726429607, + "hi": 0.19334160438908057, + "naive": 0.20830000000000004, + "atRisk": 2911 + }, + { + "cohort": "Breast", + "f1": 0.13557168300700778, + "lo": 0.12552839318649045, + "hi": 0.1456149728275251, + "naive": 0.1451, + "atRisk": 2924 + }, + { + "cohort": "Colorectal", + "f1": 0.057539779761021585, + "lo": 0.05093075326178087, + "hi": 0.0641488062602623, + "naive": 0.06589999999999996, + "atRisk": 2744 + } + ] + }, + { + "months": 60, + "cells": [ + { + "cohort": "NSCLC", + "f1": 0.24663153687867914, + "lo": 0.23480543347943614, + "hi": 0.2584576402779222, + "naive": 0.30400000000000005, + "atRisk": 982 + }, + { + "cohort": "Breast", + "f1": 0.20569290620540176, + "lo": 0.1930934002582669, + "hi": 0.2182924121525366, + "naive": 0.2328, + "atRisk": 1319 + }, + { + "cohort": "Colorectal", + "f1": 0.10770994150824832, + "lo": 0.0974147053882567, + "hi": 0.11800517762823995, + "naive": 0.14400000000000002, + "atRisk": 649 + } + ] + } + ], + "gray": { + "statistic": 375.8721732308949, + "p": 0.0004997501249375312, + "permutations": 2000, + "groups": 3 + } + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Cumulative incidence of the first brain metastasis after the study's day 0, with death (OS_STATUS) as a competing risk: Aalen–Johansen, 95% intervals from its delta-method standard error. It is not 1 − Kaplan–Meier: that treats the dead as still at risk of the event and overstates incidence whenever death is common — the table sets the two side by side. Excluded rather than counted as event-free: 2101 who already had it by day 0, 0 without follow-up. Gray's test (weight 1) by permutation of cohort labels, 2000 shuffles, seeded; exact under the null that the cohorts share one distribution, entry times included. An event recorded from notes or registries is only as complete as the recording.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Classify and count each patient's outcome", + "detail": "The incidence query above. Per patient, months from the study's day 0 (days ÷ 30.4375, rounded to 4 decimals) to the first brain metastasis after it (cause 1), death without it (cause 2, from OS_STATUS), or last follow-up (censored, OS_MONTHS); then counted by (entry, months, cause). Counts only.", + "scope": "NSCLC · msk_chord_2024", + "rowsIn": 7809 + }, + { + "kind": "fetch", + "title": "Classify and count each patient's outcome", + "detail": "The incidence query above. Per patient, months from the study's day 0 (days ÷ 30.4375, rounded to 4 decimals) to the first brain metastasis after it (cause 1), death without it (cause 2, from OS_STATUS), or last follow-up (censored, OS_MONTHS); then counted by (entry, months, cause). Counts only.", + "scope": "Breast · msk_chord_2024", + "rowsIn": 5368 + }, + { + "kind": "fetch", + "title": "Classify and count each patient's outcome", + "detail": "The incidence query above. Per patient, months from the study's day 0 (days ÷ 30.4375, rounded to 4 decimals) to the first brain metastasis after it (cause 1), death without it (cause 2, from OS_STATUS), or last follow-up (censored, OS_MONTHS); then counted by (entry, months, cause). Counts only.", + "scope": "Colorectal · msk_chord_2024", + "rowsIn": 5543 + }, + { + "kind": "transform", + "title": "Set aside patients who cannot enter the risk set", + "detail": "Named and counted rather than treated as event-free. A patient whose first event was recorded after their last follow-up is kept, as censored or dead at follow-up.", + "params": [ + [ + "NSCLC", + "1352 already had it by day 0 · 0 without follow-up" + ], + [ + "Breast", + "645 already had it by day 0 · 0 without follow-up" + ], + [ + "Colorectal", + "104 already had it by day 0 · 0 without follow-up" + ] + ] + }, + { + "kind": "statistic", + "title": "Estimate cumulative incidence by Aalen–Johansen", + "detail": "Death is a competing risk: at each time F1 rises by S(t−)·d1/R, with S the all-cause Kaplan–Meier survival and R those at risk. Standard error by the delta method (Aalen 1978); 95% interval F1 ± 1.959964·SE, clamped to [0, 1]. At each horizon the curve's value there, beside 1 − Kaplan–Meier of the event alone, which counts the dead as still at risk and overstates incidence.", + "params": [ + [ + "horizons (months)", + "12, 24, 60" + ], + [ + "NSCLC", + "6,457 at risk · 1406 events · 1967 deaths first · 3084 censored" + ], + [ + "Breast", + "4,723 at risk · 905 events · 956 deaths first · 2862 censored" + ], + [ + "Colorectal", + "5,439 at risk · 447 events · 1783 deaths first · 3209 censored" + ] + ] + }, + { + "kind": "statistic", + "title": "Gray-type test by permutation", + "detail": "Per cohort, observed cause-1 events minus those expected from the pooled subdistribution hazard, the subdistribution risk set being Y·(1 − F1)/S (Gray 1988, weight 1), summed as Σ (O − E)²/E over cohorts. This is not Gray's variance-standardised χ², so its p does not come from a χ² table: the cohort labels are shuffled across the pooled records 2,000 times by a generator seeded with 1, and p = (b + 1)/(m + 1). Exact under the null that every cohort's records, entry times included, come from one distribution.", + "params": [ + [ + "statistic / p", + "375.8722 / 0.000500" + ] + ] + } + ], + "implementation": { + "functions": [ + "aalenJohansen", + "cifAt", + "kaplanMeier", + "grayPermutationTest" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Cumulative incidence and its standard error match statsmodels 0.15.0 CumIncidenceRight to 1e-12, and with delayed entry lifelines' AalenJohansenFitter; the Gray-type statistic and permutation p match the script's port exactly (test/incidence-golden.test.ts).", + "check": { + "incidence:NSCLC:12:f1": { + "v": 0.13109119321243984, + "abs": 1e-9 + }, + "incidence:NSCLC:12:lo": { + "v": 0.12275472329176881, + "abs": 1e-9 + }, + "incidence:NSCLC:12:hi": { + "v": 0.13942766313311086, + "abs": 1e-9 + }, + "incidence:Breast:12:f1": { + "v": 0.09076442001016774, + "abs": 1e-9 + }, + "incidence:Breast:12:lo": { + "v": 0.08245310725479074, + "abs": 1e-9 + }, + "incidence:Breast:12:hi": { + "v": 0.09907573276554474, + "abs": 1e-9 + }, + "incidence:Colorectal:12:f1": { + "v": 0.0314726097593687, + "abs": 1e-9 + }, + "incidence:Colorectal:12:lo": { + "v": 0.026729157383594535, + "abs": 1e-9 + }, + "incidence:Colorectal:12:hi": { + "v": 0.03621606213514286, + "abs": 1e-9 + }, + "incidence:NSCLC:24:f1": { + "v": 0.18355912082668832, + "abs": 1e-9 + }, + "incidence:NSCLC:24:lo": { + "v": 0.17377663726429607, + "abs": 1e-9 + }, + "incidence:NSCLC:24:hi": { + "v": 0.19334160438908057, + "abs": 1e-9 + }, + "incidence:Breast:24:f1": { + "v": 0.13557168300700778, + "abs": 1e-9 + }, + "incidence:Breast:24:lo": { + "v": 0.12552839318649045, + "abs": 1e-9 + }, + "incidence:Breast:24:hi": { + "v": 0.1456149728275251, + "abs": 1e-9 + }, + "incidence:Colorectal:24:f1": { + "v": 0.057539779761021585, + "abs": 1e-9 + }, + "incidence:Colorectal:24:lo": { + "v": 0.05093075326178087, + "abs": 1e-9 + }, + "incidence:Colorectal:24:hi": { + "v": 0.0641488062602623, + "abs": 1e-9 + }, + "incidence:NSCLC:60:f1": { + "v": 0.24663153687867914, + "abs": 1e-9 + }, + "incidence:NSCLC:60:lo": { + "v": 0.23480543347943614, + "abs": 1e-9 + }, + "incidence:NSCLC:60:hi": { + "v": 0.2584576402779222, + "abs": 1e-9 + }, + "incidence:Breast:60:f1": { + "v": 0.20569290620540176, + "abs": 1e-9 + }, + "incidence:Breast:60:lo": { + "v": 0.1930934002582669, + "abs": 1e-9 + }, + "incidence:Breast:60:hi": { + "v": 0.2182924121525366, + "abs": 1e-9 + }, + "incidence:Colorectal:60:f1": { + "v": 0.10770994150824832, + "abs": 1e-9 + }, + "incidence:Colorectal:60:lo": { + "v": 0.0974147053882567, + "abs": 1e-9 + }, + "incidence:Colorectal:60:hi": { + "v": 0.11800517762823995, + "abs": 1e-9 + }, + "gray:statistic": { + "v": 375.8721732308949, + "rel": 1e-12 + }, + "gray:p": { + "v": 0.0004997501249375312, + "abs": 0 + } + } + } + } + ] +} diff --git a/test/snapshots/incidence.sql b/test/snapshots/incidence.sql new file mode 100644 index 0000000..c5e9feb --- /dev/null +++ b/test/snapshots/incidence.sql @@ -0,0 +1,170 @@ +-- cohort NSCLC +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer')))) + +-- cohort Breast +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer')))) + +-- cohort Colorectal +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) + +-- view 0 incidence: incidence:Breast · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name = 'OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' AND attribute_name IN ('OS_MONTHS', 'OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +anch AS (SELECT pid, toInt64(0) AS day FROM cohort), +ev AS (SELECT p.stable_id AS pid, ce.start_date AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Diagnosis')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('TUMOR_SITE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('CNS/Brain'))) + AND p.stable_id IN (SELECT pid FROM cohort)), +evs AS ( + SELECT ev.pid AS pid, countIf(ev.day <= anch.day) AS n_prior, countIf(ev.day > anch.day) AS n_after, + minIf(ev.day, ev.day > anch.day) AS first_after + FROM ev INNER JOIN anch ON anch.pid = ev.pid GROUP BY ev.pid +), +per AS ( + SELECT anch.pid AS pid, anch.day AS a, os.months AS months, os.status LIKE '1%' AS dead, + evs.pid != '' AS has_ev, evs.n_prior AS n_prior, evs.n_after AS n_after, evs.first_after AS first_after + FROM anch + LEFT JOIN os ON os.pid = anch.pid + LEFT JOIN evs ON evs.pid = anch.pid +), +cls AS ( + SELECT greatest(0, -a) / 30.4375 AS entry, months - a / 30.4375 AS tend, + (first_after - a) / 30.4375 AS tev, + multiIf(months IS NULL OR months - a / 30.4375 <= 0, 'nofollowup', + has_ev AND n_prior > 0, 'prior', + has_ev AND n_after > 0 AND first_after < 0, 'unobserved', + 'record') AS kind, + has_ev AND n_after > 0 AND (first_after - a) / 30.4375 <= months - a / 30.4375 AS hit, + has_ev AND n_after > 0 AND (first_after - a) / 30.4375 > months - a / 30.4375 AS late, + dead + FROM per +) +SELECT kind, if(kind = 'record', round(entry, 4), 0) AS entry, if(kind = 'record', round(if(hit, tev, tend), 4), 0) AS t, + if(kind != 'record', -1, if(hit, 1, if(dead, 2, 0))) AS cause, late, count() AS n +FROM cls GROUP BY kind, entry, t, cause, late ORDER BY t + +-- view 0 incidence: incidence:Colorectal · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name = 'OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' AND attribute_name IN ('OS_MONTHS', 'OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +anch AS (SELECT pid, toInt64(0) AS day FROM cohort), +ev AS (SELECT p.stable_id AS pid, ce.start_date AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Diagnosis')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('TUMOR_SITE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('CNS/Brain'))) + AND p.stable_id IN (SELECT pid FROM cohort)), +evs AS ( + SELECT ev.pid AS pid, countIf(ev.day <= anch.day) AS n_prior, countIf(ev.day > anch.day) AS n_after, + minIf(ev.day, ev.day > anch.day) AS first_after + FROM ev INNER JOIN anch ON anch.pid = ev.pid GROUP BY ev.pid +), +per AS ( + SELECT anch.pid AS pid, anch.day AS a, os.months AS months, os.status LIKE '1%' AS dead, + evs.pid != '' AS has_ev, evs.n_prior AS n_prior, evs.n_after AS n_after, evs.first_after AS first_after + FROM anch + LEFT JOIN os ON os.pid = anch.pid + LEFT JOIN evs ON evs.pid = anch.pid +), +cls AS ( + SELECT greatest(0, -a) / 30.4375 AS entry, months - a / 30.4375 AS tend, + (first_after - a) / 30.4375 AS tev, + multiIf(months IS NULL OR months - a / 30.4375 <= 0, 'nofollowup', + has_ev AND n_prior > 0, 'prior', + has_ev AND n_after > 0 AND first_after < 0, 'unobserved', + 'record') AS kind, + has_ev AND n_after > 0 AND (first_after - a) / 30.4375 <= months - a / 30.4375 AS hit, + has_ev AND n_after > 0 AND (first_after - a) / 30.4375 > months - a / 30.4375 AS late, + dead + FROM per +) +SELECT kind, if(kind = 'record', round(entry, 4), 0) AS entry, if(kind = 'record', round(if(hit, tev, tend), 4), 0) AS t, + if(kind != 'record', -1, if(hit, 1, if(dead, 2, 0))) AS cause, late, count() AS n +FROM cls GROUP BY kind, entry, t, cause, late ORDER BY t + +-- view 0 incidence: incidence:NSCLC · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name = 'OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' AND attribute_name IN ('OS_MONTHS', 'OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +anch AS (SELECT pid, toInt64(0) AS day FROM cohort), +ev AS (SELECT p.stable_id AS pid, ce.start_date AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Diagnosis')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('TUMOR_SITE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('CNS/Brain'))) + AND p.stable_id IN (SELECT pid FROM cohort)), +evs AS ( + SELECT ev.pid AS pid, countIf(ev.day <= anch.day) AS n_prior, countIf(ev.day > anch.day) AS n_after, + minIf(ev.day, ev.day > anch.day) AS first_after + FROM ev INNER JOIN anch ON anch.pid = ev.pid GROUP BY ev.pid +), +per AS ( + SELECT anch.pid AS pid, anch.day AS a, os.months AS months, os.status LIKE '1%' AS dead, + evs.pid != '' AS has_ev, evs.n_prior AS n_prior, evs.n_after AS n_after, evs.first_after AS first_after + FROM anch + LEFT JOIN os ON os.pid = anch.pid + LEFT JOIN evs ON evs.pid = anch.pid +), +cls AS ( + SELECT greatest(0, -a) / 30.4375 AS entry, months - a / 30.4375 AS tend, + (first_after - a) / 30.4375 AS tev, + multiIf(months IS NULL OR months - a / 30.4375 <= 0, 'nofollowup', + has_ev AND n_prior > 0, 'prior', + has_ev AND n_after > 0 AND first_after < 0, 'unobserved', + 'record') AS kind, + has_ev AND n_after > 0 AND (first_after - a) / 30.4375 <= months - a / 30.4375 AS hit, + has_ev AND n_after > 0 AND (first_after - a) / 30.4375 > months - a / 30.4375 AS late, + dead + FROM per +) +SELECT kind, if(kind = 'record', round(entry, 4), 0) AS entry, if(kind = 'record', round(if(hit, tev, tend), 4), 0) AS t, + if(kind != 'record', -1, if(hit, 1, if(dead, 2, 0))) AS cause, late, count() AS n +FROM cls GROUP BY kind, entry, t, cause, late ORDER BY t diff --git a/test/snapshots/incidence.svg b/test/snapshots/incidence.svg new file mode 100644 index 0000000..8f291e4 --- /dev/null +++ b/test/snapshots/incidence.svg @@ -0,0 +1,2 @@ + +Cumulative incidence of brain metastasis — NSCLC, Breast, Colorectal0%10%20%30%40%50%Cumulative incidence0244872Months from the study's day 0brain metastasisdeath without it (competing)95% intervalincidence by12 months24 months60 monthsNSCLC13.1% [12.3%–13.9%]1−KM 14.1%18.4% [17.4%–19.3%]1−KM 20.8%24.7% [23.5%–25.8%]1−KM 30.4%Breast9.1% [8.2%–9.9%]1−KM 9.5%13.6% [12.6%–14.6%]1−KM 14.5%20.6% [19.3%–21.8%]1−KM 23.3%Colorectal3.1% [2.7%–3.6%]1−KM 3.3%5.8% [5.1%–6.4%]1−KM 6.6%10.8% [9.7%–11.8%]1−KM 14.4%NSCLC — n = 6,457: 1,406 events, 1,967 died first, 3,084 censored · not at risk: 1,352 already had itBreast — n = 4,723: 905 events, 956 died first, 2,862 censored · not at risk: 645 already had itColorectal — n = 5,439: 447 events, 1,783 died first, 3,209 censored · not at risk: 104 already had itGray's test across 3 cohorts: statistic 376, permutation p ≤ 5e-4 (no shuffle of 2,000 as extreme)Cumulative incidence of the first brain metastasis after the study's day 0, with death (OS_STATUS) as a competing risk: Aalen–Johansen, 95% intervals from itsdelta-method standard error. It is not 1 − Kaplan–Meier: that treats the dead as still at risk of the event and overstates incidence whenever death is common — thetable sets the two side by side. Excluded rather than counted as event-free: 2101 who already had it by day 0, 0 without follow-up. Gray's test (weight 1) bypermutation of cohort labels, 2000 shuffles, seeded; exact under the null that the cohorts share one distribution, entry times included. An event recorded from notesor registries is only as complete as the recording. diff --git a/test/snapshots/incidence.txt b/test/snapshots/incidence.txt new file mode 100644 index 0000000..11d2fea --- /dev/null +++ b/test/snapshots/incidence.txt @@ -0,0 +1,32 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- NSCLC: 7,809 patients — CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample) +- Breast: 5,368 patients — CANCER_TYPE in [Breast Cancer] (any sample) +- Colorectal: 5,543 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) + +Cumulative incidence of brain metastasis, death competing (Aalen-Johansen): + NSCLC: n=6,457, 1406 events, 1967 died first, 3084 censored; not at risk: 1352 already had it, 0 before observation, 0 no anchor, 0 no follow-up + Breast: n=4,723, 905 events, 956 died first, 2862 censored; not at risk: 645 already had it, 0 before observation, 0 no anchor, 0 no follow-up + Colorectal: n=5,439, 447 events, 1783 died first, 3209 censored; not at risk: 104 already had it, 0 before observation, 0 no anchor, 0 no follow-up + at 12 months: NSCLC 13.1% (95% CI 12.3-13.9; 1-KM would say 14.1%) | Breast 9.1% (95% CI 8.2-9.9; 1-KM would say 9.5%) | Colorectal 3.1% (95% CI 2.7-3.6; 1-KM would say 3.3%) + at 24 months: NSCLC 18.4% (95% CI 17.4-19.3; 1-KM would say 20.8%) | Breast 13.6% (95% CI 12.6-14.6; 1-KM would say 14.5%) | Colorectal 5.8% (95% CI 5.1-6.4; 1-KM would say 6.6%) + at 60 months: NSCLC 24.7% (95% CI 23.5-25.8; 1-KM would say 30.4%) | Breast 20.6% (95% CI 19.3-21.8; 1-KM would say 23.3%) | Colorectal 10.8% (95% CI 9.7-11.8; 1-KM would say 14.4%) + Gray's test: statistic 375.87, permutation p=0.0005 (2000 shuffles) + CAVEAT (tell the user): Cumulative incidence of the first brain metastasis after the study's day 0, with death (OS_STATUS) as a competing risk: Aalen–Johansen, 95% intervals from its delta-method standard error. It is not 1 − Kaplan–Meier: that treats the dead as still at risk of the event and overstates incidence whenever death is common — the table sets the two side by side. Excluded rather than counted as event-free: 2101 who already had it by day 0, 0 without follow-up. Gray's test (weight 1) by permutation of cohort labels, 2000 shuffles, seeded; exact under the null that the cohorts share one distribution, entry times included. An event recorded from notes or registries is only as complete as the recording. + METHOD: + - Classify and count each patient's outcome [NSCLC · msk_chord_2024]: The incidence query above. Per patient, months from the study's day 0 (days ÷ 30.4375, rounded to 4 decimals) to the first brain metastasis after it (cause 1), death without it (cause 2, from OS_STATUS), or last follow-up (censored, OS_MONTHS); then counted by (entry, months, cause). Counts only. + - Classify and count each patient's outcome [Breast · msk_chord_2024]: The incidence query above. Per patient, months from the study's day 0 (days ÷ 30.4375, rounded to 4 decimals) to the first brain metastasis after it (cause 1), death without it (cause 2, from OS_STATUS), or last follow-up (censored, OS_MONTHS); then counted by (entry, months, cause). Counts only. + - Classify and count each patient's outcome [Colorectal · msk_chord_2024]: The incidence query above. Per patient, months from the study's day 0 (days ÷ 30.4375, rounded to 4 decimals) to the first brain metastasis after it (cause 1), death without it (cause 2, from OS_STATUS), or last follow-up (censored, OS_MONTHS); then counted by (entry, months, cause). Counts only. + - Set aside patients who cannot enter the risk set: Named and counted rather than treated as event-free. A patient whose first event was recorded after their last follow-up is kept, as censored or dead at follow-up. + NSCLC: 1352 already had it by day 0 · 0 without follow-up + Breast: 645 already had it by day 0 · 0 without follow-up + Colorectal: 104 already had it by day 0 · 0 without follow-up + - Estimate cumulative incidence by Aalen–Johansen: Death is a competing risk: at each time F1 rises by S(t−)·d1/R, with S the all-cause Kaplan–Meier survival and R those at risk. Standard error by the delta method (Aalen 1978); 95% interval F1 ± 1.959964·SE, clamped to [0, 1]. At each horizon the curve's value there, beside 1 − Kaplan–Meier of the event alone, which counts the dead as still at risk and overstates incidence. + horizons (months): 12, 24, 60 + NSCLC: 6,457 at risk · 1406 events · 1967 deaths first · 3084 censored + Breast: 4,723 at risk · 905 events · 956 deaths first · 2862 censored + Colorectal: 5,439 at risk · 447 events · 1783 deaths first · 3209 censored + - Gray-type test by permutation: Per cohort, observed cause-1 events minus those expected from the pooled subdistribution hazard, the subdistribution risk set being Y·(1 − F1)/S (Gray 1988, weight 1), summed as Σ (O − E)²/E over cohorts. This is not Gray's variance-standardised χ², so its p does not come from a χ² table: the cohort labels are shuffled across the pooled records 2,000 times by a generator seeded with 1, and p = (b + 1)/(m + 1). Exact under the null that every cohort's records, entry times included, come from one distribution. + statistic / p: 375.8722 / 0.000500 + Cumulative incidence and its standard error match statsmodels 0.15.0 CumIncidenceRight to 1e-12, and with delayed entry lifelines' AalenJohansenFitter; the Gray-type statistic and permutation p match the script's port exactly (test/incidence-golden.test.ts). diff --git a/test/snapshots/labs.json b/test/snapshots/labs.json new file mode 100644 index 0000000..c9dac5f --- /dev/null +++ b/test/snapshots/labs.json @@ -0,0 +1,568 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Prostate, TP53 mutant": { + "count": 849, + "text": "CANCER_TYPE in [Prostate Cancer] (any sample) AND OQL[TP53: MUT]", + "studies": [ + "msk_chord_2024" + ] + }, + "Prostate, TP53 wild-type": { + "count": 2284, + "text": "CANCER_TYPE in [Prostate Cancer] (any sample) AND NOT OQL[TP53]", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "labs", + "cohorts": [ + "Prostate, TP53 mutant", + "Prostate, TP53 wild-type" + ], + "labs": { + "test": "PSA", + "anchoredTo": "Treatment [SUBTYPE=Hormone]", + "responseDrop": 50, + "fromWeeks": -12, + "toWeeks": 52, + "binWeeks": 4, + "baselineDays": 90, + "panels": [ + { + "cohort": "Prostate, TP53 mutant", + "anchored": 792, + "baseline": 649, + "positiveBaseline": 631, + "evaluable": 586, + "course": [ + { + "week": -12, + "n": 84, + "q1": -36.5, + "median": -13, + "q3": 32 + }, + { + "week": -8, + "n": 119, + "q1": -32, + "median": -12, + "q3": 4 + }, + { + "week": -4, + "n": 149, + "q1": -18, + "median": -6, + "q3": 8 + }, + { + "week": 0, + "n": 208, + "q1": -84, + "median": -56, + "q3": -6 + }, + { + "week": 4, + "n": 407, + "q1": -96, + "median": -86, + "q3": -48 + }, + { + "week": 8, + "n": 319, + "q1": -98, + "median": -94, + "q3": -66 + }, + { + "week": 12, + "n": 327, + "q1": -100, + "median": -96, + "q3": -63 + }, + { + "week": 16, + "n": 350, + "q1": -100, + "median": -98, + "q3": -82 + }, + { + "week": 20, + "n": 245, + "q1": -100, + "median": -98, + "q3": -64 + }, + { + "week": 24, + "n": 269, + "q1": -100, + "median": -96, + "q3": -62 + }, + { + "week": 28, + "n": 310, + "q1": -100, + "median": -98, + "q3": -74.5 + }, + { + "week": 32, + "n": 234, + "q1": -100, + "median": -96, + "q3": -72 + }, + { + "week": 36, + "n": 217, + "q1": -100, + "median": -96, + "q3": -42 + }, + { + "week": 40, + "n": 273, + "q1": -100, + "median": -98, + "q3": -54 + }, + { + "week": 44, + "n": 238, + "q1": -100, + "median": -95, + "q3": -44.5 + }, + { + "week": 48, + "n": 213, + "q1": -100, + "median": -94, + "q3": -22 + }, + { + "week": 52, + "n": 23, + "q1": -100, + "median": -82, + "q3": 31 + } + ], + "best": [ + 311, + 69, + 29, + 12, + 10, + 12, + 6, + 6, + 9, + 7, + 5, + 3, + 1, + 3, + 3, + 1, + 3, + 2, + 1, + 2, + { + "…": "181 more", + "sha256": "33dc4736a2e19428" + } + ], + "responders": 503, + "waterfall": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + { + "…": "566 more", + "sha256": "f1b10b1b2f434557" + } + ] + }, + { + "cohort": "Prostate, TP53 wild-type", + "anchored": 1888, + "baseline": 1568, + "positiveBaseline": 1543, + "evaluable": 1449, + "course": [ + { + "week": -12, + "n": 255, + "q1": -41, + "median": -22, + "q3": -4 + }, + { + "week": -8, + "n": 356, + "q1": -30, + "median": -14, + "q3": 2 + }, + { + "week": -4, + "n": 328, + "q1": -14, + "median": -6, + "q3": 6 + }, + { + "week": 0, + "n": 495, + "q1": -84, + "median": -64, + "q3": -19 + }, + { + "week": 4, + "n": 947, + "q1": -96, + "median": -90, + "q3": -72 + }, + { + "week": 8, + "n": 722, + "q1": -100, + "median": -98, + "q3": -84.5 + }, + { + "week": 12, + "n": 772, + "q1": -100, + "median": -98, + "q3": -88 + }, + { + "week": 16, + "n": 799, + "q1": -100, + "median": -100, + "q3": -94 + }, + { + "week": 20, + "n": 563, + "q1": -100, + "median": -100, + "q3": -92 + }, + { + "week": 24, + "n": 582, + "q1": -100, + "median": -100, + "q3": -92 + }, + { + "week": 28, + "n": 733, + "q1": -100, + "median": -100, + "q3": -94 + }, + { + "week": 32, + "n": 464, + "q1": -100, + "median": -100, + "q3": -88 + }, + { + "week": 36, + "n": 488, + "q1": -100, + "median": -100, + "q3": -77.5 + }, + { + "week": 40, + "n": 615, + "q1": -100, + "median": -100, + "q3": -90 + }, + { + "week": 44, + "n": 508, + "q1": -100, + "median": -100, + "q3": -78 + }, + { + "week": 48, + "n": 480, + "q1": -100, + "median": -100, + "q3": -69.5 + }, + { + "week": 52, + "n": 56, + "q1": -100, + "median": -98, + "q3": -21.5 + } + ], + "best": [ + 966, + 121, + 49, + 43, + 32, + 15, + 17, + 13, + 8, + 4, + 8, + 11, + 7, + 3, + 9, + 8, + 3, + 3, + 3, + 5, + { + "…": "181 more", + "sha256": "c24b835620b51a4f" + } + ], + "responders": 1347, + "waterfall": [ + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + -100, + { + "…": "1429 more", + "sha256": "96ae3b8f4f34c36f" + } + ] + } + ], + "responseP": 0.0000014345634433689822 + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "PSA as % change from each patient's baseline — the mean of their readings on the last day with any, in the 90 days up to and including the first Treatment [SUBTYPE=Hormone] — over -12 to 52 weeks around it, in 4-week bins; a patient tested several times in a bin counts once, at their mean, and no reading from the baseline day is drawn. Median and interquartile band are read from 2-point histograms, so they are exact to within a point, and the figure draws only bins with at least 5 patients; values above +300% share the top bin. Best response is each patient's lowest value after the anchor within the window; a responder fell by at least 50% (PCWG3's PSA50), counted exactly. Denominators: Prostate, TP53 mutant — 792 anchored, 649 with a baseline (18 of them left out: a baseline of 0 or below has no % change), 586 with a value after; Prostate, TP53 wild-type — 1,888 anchored, 1,568 with a baseline (25 of them left out: a baseline of 0 or below has no % change), 1,449 with a value after. Patients tested more often are over-represented in any bin they appear in, and testing itself is more frequent when a value is moving; the course is of those measured, not of everyone. Response rates compared with a two-sided Fisher test. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients' % change from baseline", + "detail": "The labs:course and labs:best queries above (and labs:waterfall, one bar per patient, from a patient-level participant). Counts per bin and per rule, no individual value except the waterfall's bars.", + "scope": "Prostate, TP53 mutant · msk_chord_2024", + "rowsIn": 849 + }, + { + "kind": "fetch", + "title": "Count patients' % change from baseline", + "detail": "The labs:course and labs:best queries above (and labs:waterfall, one bar per patient, from a patient-level participant). Counts per bin and per rule, no individual value except the waterfall's bars.", + "scope": "Prostate, TP53 wild-type · msk_chord_2024", + "rowsIn": 2284 + }, + { + "kind": "transform", + "title": "Anchor, baseline and change", + "detail": "Day 0 is each patient's first Treatment [SUBTYPE=Hormone] (event type, key and value matched ignoring case); a patient without one is not anchored. PSA readings are those whose result parses as a number. The baseline is the mean of a patient's readings on the last day with any in the 90 days up to and including day 0; a patient without one has no baseline, and one whose baseline is 0 or below is left out, since a % change from it means nothing. Every later reading becomes 100·(value − baseline)/baseline; readings on the baseline day itself are not used.", + "params": [ + [ + "Prostate, TP53 mutant", + "792 anchored → 649 with a baseline → 631 with a positive one → 586 with a reading after day 0" + ], + [ + "Prostate, TP53 wild-type", + "1,888 anchored → 1,568 with a baseline → 1,543 with a positive one → 1,449 with a reading after day 0" + ] + ] + }, + { + "kind": "transform", + "title": "Bin the course", + "detail": "Weeks -12 to 52 around day 0 in 4-week bins; a patient tested several times in a bin counts once, at their mean. % change in 2-point bins from -100 to 300, values beyond either end in the end bin. The figure draws a bin only from 5 patients." + }, + { + "kind": "statistic", + "title": "Median and interquartile range per week", + "detail": "From each bin's histogram, with the bin midpoints as values and linear interpolation between ranks — exact to within a 2-point bin." + }, + { + "kind": "statistic", + "title": "Best response", + "detail": "Each patient's lowest % change after day 0 within the window; a responder fell by at least 50%, counted from the unbinned values. The two cohorts' response rates are compared with a two-sided Fisher's exact test.", + "params": [ + [ + "Prostate, TP53 mutant", + "503 responders of 586" + ], + [ + "Prostate, TP53 wild-type", + "1,347 responders of 1,449" + ] + ] + } + ], + "implementation": { + "functions": [ + "quantilesFromHistogram", + "fisherExact" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Quantiles from histograms match numpy percentile on the expanded values, and Fisher's exact test scipy 1.18.1 fisher_exact, to a relative 1e-6 (test/moments-golden.test.ts, test/tables-golden.test.ts).", + "check": { + "labs:Prostate, TP53 mutant:-12:q1": { + "v": -36.5, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-12:median": { + "v": -13, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-12:q3": { + "v": 32, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-8:q1": { + "v": -32, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-8:median": { + "v": -12, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-8:q3": { + "v": 4, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-4:q1": { + "v": -18, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-4:median": { + "v": -6, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:-4:q3": { + "v": 8, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:0:q1": { + "v": -84, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:0:median": { + "v": -56, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:0:q3": { + "v": -6, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:4:q1": { + "v": -96, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:4:median": { + "v": -86, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:4:q3": { + "v": -48, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:8:q1": { + "v": -98, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:8:median": { + "v": -94, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:8:q3": { + "v": -66, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:12:q1": { + "v": -100, + "abs": 0.000500001 + }, + "labs:Prostate, TP53 mutant:12:median": { + "v": -96, + "abs": 0.000500001 + }, + "…": { + "more": 83, + "sha256": "c0351cf9c722cb35" + } + } + } + } + ] +} diff --git a/test/snapshots/labs.sql b/test/snapshots/labs.sql new file mode 100644 index 0000000..8013771 --- /dev/null +++ b/test/snapshots/labs.sql @@ -0,0 +1,325 @@ +-- cohort Prostate, TP53 mutant +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort Prostate, TP53 wild-type +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) + +-- view 0 labs: labs:best:Prostate, TP53 mutant · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('Hormone'))) + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +lab AS ( + SELECT p.stable_id AS pid, ce.start_date AS day, if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN snapshot_db.clinical_event_data t ON t.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(t.key)) = lowerUTF8(trimBoth('TEST')) AND lowerUTF8(trimBoth(t.value)) = lowerUTF8(trimBoth('PSA')) + JOIN snapshot_db.clinical_event_data r ON r.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(r.key)) = lowerUTF8(trimBoth('RESULT')) + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Lab_Test')) + AND p.stable_id IN (SELECT pid FROM anch) AND if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) IS NOT NULL +), +base AS ( + SELECT lab.pid AS pid, max(lab.day) AS bday, + arrayAvg(arrayMap((x) -> assumeNotNull(x.1), arrayFilter((x) -> x.2 = bday, groupArray((lab.v, lab.day))))) AS b + FROM lab INNER JOIN anch ON anch.pid = lab.pid + WHERE lab.day >= anch.day - 90 AND lab.day <= anch.day GROUP BY lab.pid +), +chg AS ( + SELECT lab.pid AS pid, lab.day - anch.day AS rel, 100 * (lab.v - base.b) / base.b AS pc + FROM lab INNER JOIN anch ON anch.pid = lab.pid INNER JOIN base ON base.pid = lab.pid + WHERE base.b > 0 AND lab.day != base.bday + AND lab.day - anch.day >= -84 AND lab.day - anch.day <= 364 +) +SELECT 'best' AS what, toInt32(floor((least(300, greatest(-100, best)) - (-100) + 1) / 2)) AS pbin, count() AS n FROM (SELECT pid, min(pc) AS best FROM chg WHERE rel > 0 GROUP BY pid) GROUP BY pbin +UNION ALL SELECT 'responders' AS what, 0 AS pbin, countIf(best <= -50) AS n FROM (SELECT pid, min(pc) AS best FROM chg WHERE rel > 0 GROUP BY pid) +UNION ALL SELECT 'anchored' AS what, 0 AS pbin, count() AS n FROM anch +UNION ALL SELECT 'baseline' AS what, 0 AS pbin, count() AS n FROM base +UNION ALL SELECT 'positive_baseline' AS what, 0 AS pbin, countIf(b > 0) AS n FROM base +UNION ALL SELECT 'after' AS what, 0 AS pbin, uniqExactIf(pid, rel > 0) AS n FROM chg + +-- view 0 labs: labs:best:Prostate, TP53 wild-type · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2))))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('Hormone'))) + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +lab AS ( + SELECT p.stable_id AS pid, ce.start_date AS day, if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN snapshot_db.clinical_event_data t ON t.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(t.key)) = lowerUTF8(trimBoth('TEST')) AND lowerUTF8(trimBoth(t.value)) = lowerUTF8(trimBoth('PSA')) + JOIN snapshot_db.clinical_event_data r ON r.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(r.key)) = lowerUTF8(trimBoth('RESULT')) + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Lab_Test')) + AND p.stable_id IN (SELECT pid FROM anch) AND if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) IS NOT NULL +), +base AS ( + SELECT lab.pid AS pid, max(lab.day) AS bday, + arrayAvg(arrayMap((x) -> assumeNotNull(x.1), arrayFilter((x) -> x.2 = bday, groupArray((lab.v, lab.day))))) AS b + FROM lab INNER JOIN anch ON anch.pid = lab.pid + WHERE lab.day >= anch.day - 90 AND lab.day <= anch.day GROUP BY lab.pid +), +chg AS ( + SELECT lab.pid AS pid, lab.day - anch.day AS rel, 100 * (lab.v - base.b) / base.b AS pc + FROM lab INNER JOIN anch ON anch.pid = lab.pid INNER JOIN base ON base.pid = lab.pid + WHERE base.b > 0 AND lab.day != base.bday + AND lab.day - anch.day >= -84 AND lab.day - anch.day <= 364 +) +SELECT 'best' AS what, toInt32(floor((least(300, greatest(-100, best)) - (-100) + 1) / 2)) AS pbin, count() AS n FROM (SELECT pid, min(pc) AS best FROM chg WHERE rel > 0 GROUP BY pid) GROUP BY pbin +UNION ALL SELECT 'responders' AS what, 0 AS pbin, countIf(best <= -50) AS n FROM (SELECT pid, min(pc) AS best FROM chg WHERE rel > 0 GROUP BY pid) +UNION ALL SELECT 'anchored' AS what, 0 AS pbin, count() AS n FROM anch +UNION ALL SELECT 'baseline' AS what, 0 AS pbin, count() AS n FROM base +UNION ALL SELECT 'positive_baseline' AS what, 0 AS pbin, countIf(b > 0) AS n FROM base +UNION ALL SELECT 'after' AS what, 0 AS pbin, uniqExactIf(pid, rel > 0) AS n FROM chg + +-- view 0 labs: labs:course:Prostate, TP53 mutant · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('Hormone'))) + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +lab AS ( + SELECT p.stable_id AS pid, ce.start_date AS day, if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN snapshot_db.clinical_event_data t ON t.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(t.key)) = lowerUTF8(trimBoth('TEST')) AND lowerUTF8(trimBoth(t.value)) = lowerUTF8(trimBoth('PSA')) + JOIN snapshot_db.clinical_event_data r ON r.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(r.key)) = lowerUTF8(trimBoth('RESULT')) + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Lab_Test')) + AND p.stable_id IN (SELECT pid FROM anch) AND if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) IS NOT NULL +), +base AS ( + SELECT lab.pid AS pid, max(lab.day) AS bday, + arrayAvg(arrayMap((x) -> assumeNotNull(x.1), arrayFilter((x) -> x.2 = bday, groupArray((lab.v, lab.day))))) AS b + FROM lab INNER JOIN anch ON anch.pid = lab.pid + WHERE lab.day >= anch.day - 90 AND lab.day <= anch.day GROUP BY lab.pid +), +chg AS ( + SELECT lab.pid AS pid, lab.day - anch.day AS rel, 100 * (lab.v - base.b) / base.b AS pc + FROM lab INNER JOIN anch ON anch.pid = lab.pid INNER JOIN base ON base.pid = lab.pid + WHERE base.b > 0 AND lab.day != base.bday + AND lab.day - anch.day >= -84 AND lab.day - anch.day <= 364 +) +SELECT tbin, pbin, count() AS n FROM ( + SELECT pid, toInt32(floor(rel / 28)) AS tbin, toInt32(floor((least(300, greatest(-100, avg(pc))) - (-100) + 1) / 2)) AS pbin + FROM chg GROUP BY pid, tbin +) GROUP BY tbin, pbin ORDER BY tbin, pbin + +-- view 0 labs: labs:course:Prostate, TP53 wild-type · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2))))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('Hormone'))) + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +lab AS ( + SELECT p.stable_id AS pid, ce.start_date AS day, if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN snapshot_db.clinical_event_data t ON t.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(t.key)) = lowerUTF8(trimBoth('TEST')) AND lowerUTF8(trimBoth(t.value)) = lowerUTF8(trimBoth('PSA')) + JOIN snapshot_db.clinical_event_data r ON r.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(r.key)) = lowerUTF8(trimBoth('RESULT')) + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Lab_Test')) + AND p.stable_id IN (SELECT pid FROM anch) AND if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) IS NOT NULL +), +base AS ( + SELECT lab.pid AS pid, max(lab.day) AS bday, + arrayAvg(arrayMap((x) -> assumeNotNull(x.1), arrayFilter((x) -> x.2 = bday, groupArray((lab.v, lab.day))))) AS b + FROM lab INNER JOIN anch ON anch.pid = lab.pid + WHERE lab.day >= anch.day - 90 AND lab.day <= anch.day GROUP BY lab.pid +), +chg AS ( + SELECT lab.pid AS pid, lab.day - anch.day AS rel, 100 * (lab.v - base.b) / base.b AS pc + FROM lab INNER JOIN anch ON anch.pid = lab.pid INNER JOIN base ON base.pid = lab.pid + WHERE base.b > 0 AND lab.day != base.bday + AND lab.day - anch.day >= -84 AND lab.day - anch.day <= 364 +) +SELECT tbin, pbin, count() AS n FROM ( + SELECT pid, toInt32(floor(rel / 28)) AS tbin, toInt32(floor((least(300, greatest(-100, avg(pc))) - (-100) + 1) / 2)) AS pbin + FROM chg GROUP BY pid, tbin +) GROUP BY tbin, pbin ORDER BY tbin, pbin + +-- view 0 labs: labs:waterfall:Prostate, TP53 mutant · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('Hormone'))) + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +lab AS ( + SELECT p.stable_id AS pid, ce.start_date AS day, if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN snapshot_db.clinical_event_data t ON t.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(t.key)) = lowerUTF8(trimBoth('TEST')) AND lowerUTF8(trimBoth(t.value)) = lowerUTF8(trimBoth('PSA')) + JOIN snapshot_db.clinical_event_data r ON r.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(r.key)) = lowerUTF8(trimBoth('RESULT')) + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Lab_Test')) + AND p.stable_id IN (SELECT pid FROM anch) AND if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) IS NOT NULL +), +base AS ( + SELECT lab.pid AS pid, max(lab.day) AS bday, + arrayAvg(arrayMap((x) -> assumeNotNull(x.1), arrayFilter((x) -> x.2 = bday, groupArray((lab.v, lab.day))))) AS b + FROM lab INNER JOIN anch ON anch.pid = lab.pid + WHERE lab.day >= anch.day - 90 AND lab.day <= anch.day GROUP BY lab.pid +), +chg AS ( + SELECT lab.pid AS pid, lab.day - anch.day AS rel, 100 * (lab.v - base.b) / base.b AS pc + FROM lab INNER JOIN anch ON anch.pid = lab.pid INNER JOIN base ON base.pid = lab.pid + WHERE base.b > 0 AND lab.day != base.bday + AND lab.day - anch.day >= -84 AND lab.day - anch.day <= 364 +) +SELECT round(best, 1) AS best FROM (SELECT pid, min(pc) AS best FROM chg WHERE rel > 0 GROUP BY pid) +ORDER BY best LIMIT 5000 + +-- view 0 labs: labs:waterfall:Prostate, TP53 wild-type · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Prostate Cancer')))) +INTERSECT DISTINCT +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2))))), +anch AS ( + SELECT p.stable_id AS pid, min(ce.start_date) AS day + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_data WHERE lowerUTF8(trimBoth(key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(value)) = lowerUTF8(trimBoth('Hormone'))) + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +lab AS ( + SELECT p.stable_id AS pid, ce.start_date AS day, if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) AS v + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + JOIN snapshot_db.clinical_event_data t ON t.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(t.key)) = lowerUTF8(trimBoth('TEST')) AND lowerUTF8(trimBoth(t.value)) = lowerUTF8(trimBoth('PSA')) + JOIN snapshot_db.clinical_event_data r ON r.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(r.key)) = lowerUTF8(trimBoth('RESULT')) + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Lab_Test')) + AND p.stable_id IN (SELECT pid FROM anch) AND if(isFinite(ifNull(toFloat64OrNull(r.value), nan)), toFloat64OrNull(r.value), NULL) IS NOT NULL +), +base AS ( + SELECT lab.pid AS pid, max(lab.day) AS bday, + arrayAvg(arrayMap((x) -> assumeNotNull(x.1), arrayFilter((x) -> x.2 = bday, groupArray((lab.v, lab.day))))) AS b + FROM lab INNER JOIN anch ON anch.pid = lab.pid + WHERE lab.day >= anch.day - 90 AND lab.day <= anch.day GROUP BY lab.pid +), +chg AS ( + SELECT lab.pid AS pid, lab.day - anch.day AS rel, 100 * (lab.v - base.b) / base.b AS pc + FROM lab INNER JOIN anch ON anch.pid = lab.pid INNER JOIN base ON base.pid = lab.pid + WHERE base.b > 0 AND lab.day != base.bday + AND lab.day - anch.day >= -84 AND lab.day - anch.day <= 364 +) +SELECT round(best, 1) AS best FROM (SELECT pid, min(pc) AS best FROM chg WHERE rel > 0 GROUP BY pid) +ORDER BY best LIMIT 5000 diff --git a/test/snapshots/labs.svg b/test/snapshots/labs.svg new file mode 100644 index 0000000..cf0fd37 --- /dev/null +++ b/test/snapshots/labs.svg @@ -0,0 +1,2 @@ + +Lab course — PSA from Treatment [SUBTYPE=Hormone] — Prostate, TP53 mutant, Prostate, TP53 wild-typePSA, % change from baseline−100%−50%0%+50%+100%% change from baseline−12012243648Weeks from Treatment [SUBTYPE=Hormone]responder: fell ≥50%Best % change after the start, worst to bestProstate, TP53 mutant85.8% fell ≥50% (503/586)−100%−50%0%+50%+100%best % changepatients, worst to best: 586Prostate, TP53 wild-type93.0% fell ≥50% (1,347/1,449)−100%−50%0%+50%+100%best % changepatients, worst to best: 1,449Prostate, TP53 mutant · 792 started, 649 with a baseline, 586 measured afterProstate, TP53 wild-type · 1,888 started, 1,568 with a baseline, 1,449 measured afterresponse rates differ: Fisher p = 1.4e-6PSA as % change from each patient's baseline — the mean of their readings on the last day with any, in the 90 days up to and including the first Treatment[SUBTYPE=Hormone] — over -12 to 52 weeks around it, in 4-week bins; a patient tested several times in a bin counts once, at their mean, and no reading from thebaseline day is drawn. Median and interquartile band are read from 2-point histograms, so they are exact to within a point, and the figure draws only bins with at least 5patients; values above +300% share the top bin. Best response is each patient's lowest value after the anchor within the window; a responder fell by at least 50%(PCWG3's PSA50), counted exactly. Denominators: Prostate, TP53 mutant — 792 anchored, 649 with a baseline (18 of them left out: a baseline of 0 or below has no %change), 586 with a value after; Prostate, TP53 wild-type — 1,888 anchored, 1,568 with a baseline (25 of them left out: a baseline of 0 or below has no % change), 1,449with a value after. Patients tested more often are over-represented in any bin they appear in, and testing itself is more frequent when a value is moving; the course is ofthose measured, not of everyone. Response rates compared with a two-sided Fisher test. diff --git a/test/snapshots/labs.txt b/test/snapshots/labs.txt new file mode 100644 index 0000000..c8e69b8 --- /dev/null +++ b/test/snapshots/labs.txt @@ -0,0 +1,25 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Prostate, TP53 mutant: 849 patients — CANCER_TYPE in [Prostate Cancer] (any sample) AND OQL[TP53: MUT] +- Prostate, TP53 wild-type: 2,284 patients — CANCER_TYPE in [Prostate Cancer] (any sample) AND NOT OQL[TP53] + +Lab course: PSA % change from baseline, weeks from Treatment [SUBTYPE=Hormone]: + Prostate, TP53 mutant: 792 started, 649 with a baseline, 586 measured after; 85.8% fell ≥50% (503/586) + median [IQR] by week: -12w -13% [-36.5, 32], -8w -12% [-32, 4], -4w -6% [-18, 8], 0w -56% [-84, -6], 4w -86% [-96, -48], 8w -94% [-98, -66], 12w -96% [-100, -63], 16w -98% [-100, -82], 20w -98% [-100, -64], 24w -96% [-100, -62], 28w -98% [-100, -74.5], 32w -96% [-100, -72], 36w -96% [-100, -42], 40w -98% [-100, -54], 44w -95% [-100, -44.5], 48w -94% [-100, -22], 52w -82% [-100, 31] + Prostate, TP53 wild-type: 1,888 started, 1,568 with a baseline, 1,449 measured after; 93.0% fell ≥50% (1347/1449) + median [IQR] by week: -12w -22% [-41, -4], -8w -14% [-30, 2], -4w -6% [-14, 6], 0w -64% [-84, -19], 4w -90% [-96, -72], 8w -98% [-100, -84.5], 12w -98% [-100, -88], 16w -100% [-100, -94], 20w -100% [-100, -92], 24w -100% [-100, -92], 28w -100% [-100, -94], 32w -100% [-100, -88], 36w -100% [-100, -77.5], 40w -100% [-100, -90], 44w -100% [-100, -78], 48w -100% [-100, -69.5], 52w -98% [-100, -21.5] + response rates differ: Fisher p=1.4e-6 + CAVEAT (tell the user): PSA as % change from each patient's baseline — the mean of their readings on the last day with any, in the 90 days up to and including the first Treatment [SUBTYPE=Hormone] — over -12 to 52 weeks around it, in 4-week bins; a patient tested several times in a bin counts once, at their mean, and no reading from the baseline day is drawn. Median and interquartile band are read from 2-point histograms, so they are exact to within a point, and the figure draws only bins with at least 5 patients; values above +300% share the top bin. Best response is each patient's lowest value after the anchor within the window; a responder fell by at least 50% (PCWG3's PSA50), counted exactly. Denominators: Prostate, TP53 mutant — 792 anchored, 649 with a baseline (18 of them left out: a baseline of 0 or below has no % change), 586 with a value after; Prostate, TP53 wild-type — 1,888 anchored, 1,568 with a baseline (25 of them left out: a baseline of 0 or below has no % change), 1,449 with a value after. Patients tested more often are over-represented in any bin they appear in, and testing itself is more frequent when a value is moving; the course is of those measured, not of everyone. Response rates compared with a two-sided Fisher test. + METHOD: + - Count patients' % change from baseline [Prostate, TP53 mutant · msk_chord_2024]: The labs:course and labs:best queries above (and labs:waterfall, one bar per patient, from a patient-level participant). Counts per bin and per rule, no individual value except the waterfall's bars. + - Count patients' % change from baseline [Prostate, TP53 wild-type · msk_chord_2024]: The labs:course and labs:best queries above (and labs:waterfall, one bar per patient, from a patient-level participant). Counts per bin and per rule, no individual value except the waterfall's bars. + - Anchor, baseline and change: Day 0 is each patient's first Treatment [SUBTYPE=Hormone] (event type, key and value matched ignoring case); a patient without one is not anchored. PSA readings are those whose result parses as a number. The baseline is the mean of a patient's readings on the last day with any in the 90 days up to and including day 0; a patient without one has no baseline, and one whose baseline is 0 or below is left out, since a % change from it means nothing. Every later reading becomes 100·(value − baseline)/baseline; readings on the baseline day itself are not used. + Prostate, TP53 mutant: 792 anchored → 649 with a baseline → 631 with a positive one → 586 with a reading after day 0 + Prostate, TP53 wild-type: 1,888 anchored → 1,568 with a baseline → 1,543 with a positive one → 1,449 with a reading after day 0 + - Bin the course: Weeks -12 to 52 around day 0 in 4-week bins; a patient tested several times in a bin counts once, at their mean. % change in 2-point bins from -100 to 300, values beyond either end in the end bin. The figure draws a bin only from 5 patients. + - Median and interquartile range per week: From each bin's histogram, with the bin midpoints as values and linear interpolation between ranks — exact to within a 2-point bin. + - Best response: Each patient's lowest % change after day 0 within the window; a responder fell by at least 50%, counted from the unbinned values. The two cohorts' response rates are compared with a two-sided Fisher's exact test. + Prostate, TP53 mutant: 503 responders of 586 + Prostate, TP53 wild-type: 1,347 responders of 1,449 + Quantiles from histograms match numpy percentile on the expanded values, and Fisher's exact test scipy 1.18.1 fisher_exact, to a relative 1e-6 (test/moments-golden.test.ts, test/tables-golden.test.ts). diff --git a/test/snapshots/logistic.json b/test/snapshots/logistic.json new file mode 100644 index 0000000..76a7e05 --- /dev/null +++ b/test/snapshots/logistic.json @@ -0,0 +1,140 @@ +{ + "study": "crc_apc_impact_2020", + "cohorts": { + "all patients": { + "count": 471, + "text": "all patients in the study", + "studies": [ + "crc_apc_impact_2020" + ] + } + }, + "views": [ + { + "kind": "logistic", + "cohorts": [ + "all patients" + ], + "logistic": { + "coefficients": [ + { + "label": "APC mutation status: Mutated", + "reference": "Not mutated", + "level": "Mutated", + "axisIndex": 0, + "beta": -1.264274030987992, + "se": 0.4053957847207888, + "or": 0.28244426751592355, + "ciLow": 0.12760251879097487, + "ciHigh": 0.6251817362891188, + "p": 0.001817022203426293 + } + ], + "n": 470, + "events": 27, + "outcomeOther": [ + "Do not report", + "Indeterminate", + "Stable" + ] + }, + "participation": { + "studies": [ + { + "study": "crc_apc_impact_2020", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Logistic regression on 470 patients, 27 with MSI_TYPE = Instable (1 term). Every other observed value of MSI_TYPE (Do not report, Indeterminate, Stable) was treated as “not event.” 1 patient from patient-level participants lacked the outcome or a covariate and were excluded. Computed from real per-patient rows within each local study — not pooled aggregate counts across untrusted remote peers.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Fetch one row per patient", + "detail": "The logisticRows query above. Patients with a value for MSI_TYPE and for every covariate are kept. 1 cohort patient had no row.", + "scope": "crc_apc_impact_2020", + "rowsIn": 471, + "rowsOut": 470 + }, + { + "kind": "transform", + "title": "Code the outcome", + "detail": "1 if MSI_TYPE = “Instable”, else 0 — every other observed value (Do not report, Indeterminate, Stable) counts as not the event." + }, + { + "kind": "transform", + "title": "Code the covariates", + "detail": "Each numeric covariate is one term. Each categorical covariate becomes one 0/1 term per level, measured against a reference level that gets no term.", + "params": [ + [ + "APC mutation status: Mutated", + "1 if c0 = “Mutated”, else 0 · 325 of 470 patients · reference “Not mutated”: the fixed default for a mutated-vs-not axis" + ] + ] + }, + { + "kind": "statistic", + "title": "Fit a logistic regression", + "detail": "Maximum likelihood for a binomial GLM with a logit link and an intercept, by Newton–Raphson with step-halving.", + "params": [ + [ + "patients / events", + "470 / 27" + ], + [ + "terms", + "1 plus an intercept (not drawn)" + ], + [ + "standard errors", + "from the Fisher information at the estimate" + ], + [ + "95% interval", + "exp(β ± 1.959964·SE), Wald" + ], + [ + "p-value", + "Wald χ² on 1 df, (β/SE)²" + ], + [ + "fit", + "converged in 8 iterations" + ], + [ + "log likelihood", + "-98.4061" + ] + ] + } + ], + "implementation": { + "functions": [ + "logisticRegression" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Matches statsmodels 0.15.0 Logit to a relative 1e-6 on coefficients, SEs, p-values and intervals (test/regression-golden.test.ts).", + "check": { + "logistic:APC mutation status: Mutated:beta": { + "v": -1.264274030987992 + }, + "logistic:APC mutation status: Mutated:se": { + "v": 0.4053957847207888 + }, + "logistic:APC mutation status: Mutated:p": { + "v": 0.001817022203426293, + "rel": 0.00001, + "abs": 1e-14 + } + } + } + } + ] +} diff --git a/test/snapshots/logistic.sql b/test/snapshots/logistic.sql new file mode 100644 index 0000000..6133523 --- /dev/null +++ b/test/snapshots/logistic.sql @@ -0,0 +1,84 @@ +-- cohort all patients +-- crc_apc_impact_2020 +SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' + +-- view 0 logistic: logisticNotProfiled · crc_apc_impact_2020 +SELECT countIf(c0 = 'Not profiled') AS n FROM ( +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020'), +y0 AS ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND attribute_name = 'MSI_TYPE' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND attribute_name = 'MSI_TYPE' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +), +c0 AS ( +SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'APC'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS alt_case, if(countIf(g.variant_type = 'mutation') > 0, 'Mutated', 'Not mutated') AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND hugo_gene_symbol IN ('APC') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'crc_apc_impact_2020' AND replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case) +) +SELECT y0.v AS y, c0.v AS c0 +FROM y0 + INNER JOIN c0 ON c0.id = y0.id +) + +-- view 0 logistic: logisticRows · crc_apc_impact_2020 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020'), +y0 AS ( +SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND attribute_name = 'MSI_TYPE' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND attribute_name = 'MSI_TYPE' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +) GROUP BY id +), +c0 AS ( +SELECT id, v FROM ( +SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'crc_apc_impact_2020' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'APC'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') AS alt_case, if(countIf(g.variant_type = 'mutation') > 0, 'Mutated', 'Not mutated') AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'crc_apc_impact_2020' AND hugo_gene_symbol IN ('APC') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'crc_apc_impact_2020' AND replaceOne(sd.patient_unique_id, 'crc_apc_impact_2020_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case) +) WHERE v != 'Not profiled' +) +SELECT y0.v AS y, c0.v AS c0 +FROM y0 + INNER JOIN c0 ON c0.id = y0.id diff --git a/test/snapshots/logistic.svg b/test/snapshots/logistic.svg new file mode 100644 index 0000000..bf605c1 --- /dev/null +++ b/test/snapshots/logistic.svg @@ -0,0 +1,2 @@ + +Logistic regression — odds ratiosOR [95% CI]pAPC mutation status: Mutated vs Not mutated0.28 [0.13–0.63]0.0018OR = 10.20.40.60.81OR (log scale) — left of 1 is lower, right is higherLogistic regression on 470 patients, 27 with MSI_TYPE = Instable (1 term). Every other observed value of MSI_TYPE (Do not report, Indeterminate, Stable) wastreated as “not event.” 1 patient from patient-level participants lacked the outcome or a covariate and were excluded. Computed from real per-patient rows withineach local study — not pooled aggregate counts across untrusted remote peers. diff --git a/test/snapshots/logistic.txt b/test/snapshots/logistic.txt new file mode 100644 index 0000000..6792d41 --- /dev/null +++ b/test/snapshots/logistic.txt @@ -0,0 +1,22 @@ +Analysis over crc_apc_impact_2020 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- all patients: 471 patients — all patients in the study + +Logistic regression (n=470, 27 with the outcome): + APC mutation status: Mutated vs Not mutated: OR 0.28 (95% CI 0.13-0.63) p=0.0018 + CAVEAT (tell the user): Logistic regression on 470 patients, 27 with MSI_TYPE = Instable (1 term). Every other observed value of MSI_TYPE (Do not report, Indeterminate, Stable) was treated as “not event.” 1 patient from patient-level participants lacked the outcome or a covariate and were excluded. Computed from real per-patient rows within each local study — not pooled aggregate counts across untrusted remote peers. + METHOD: + - Fetch one row per patient [crc_apc_impact_2020] (471 → 470 rows): The logisticRows query above. Patients with a value for MSI_TYPE and for every covariate are kept. 1 cohort patient had no row. + - Code the outcome: 1 if MSI_TYPE = “Instable”, else 0 — every other observed value (Do not report, Indeterminate, Stable) counts as not the event. + - Code the covariates: Each numeric covariate is one term. Each categorical covariate becomes one 0/1 term per level, measured against a reference level that gets no term. + APC mutation status: Mutated: 1 if c0 = “Mutated”, else 0 · 325 of 470 patients · reference “Not mutated”: the fixed default for a mutated-vs-not axis + - Fit a logistic regression: Maximum likelihood for a binomial GLM with a logit link and an intercept, by Newton–Raphson with step-halving. + patients / events: 470 / 27 + terms: 1 plus an intercept (not drawn) + standard errors: from the Fisher information at the estimate + 95% interval: exp(β ± 1.959964·SE), Wald + p-value: Wald χ² on 1 df, (β/SE)² + fit: converged in 8 iterations + log likelihood: -98.4061 + Matches statsmodels 0.15.0 Logit to a relative 1e-6 on coefficients, SEs, p-values and intervals (test/regression-golden.test.ts). diff --git a/test/snapshots/mutations.json b/test/snapshots/mutations.json new file mode 100644 index 0000000..88ffb9a --- /dev/null +++ b/test/snapshots/mutations.json @@ -0,0 +1,709 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Colorectal": { + "count": 5543, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "mutations", + "cohorts": [ + "Colorectal" + ], + "mutations": { + "gene": "KRAS", + "columns": [ + { + "id": "sample", + "name": "Sample ID", + "numeric": false + }, + { + "id": "cancerType", + "name": "Cancer Type Detailed", + "numeric": false + }, + { + "id": "proteinChange", + "name": "Protein Change", + "numeric": false + }, + { + "id": "annotation", + "name": "Annotation (OncoKB)", + "numeric": false + }, + { + "id": "mutationType", + "name": "Mutation Type", + "numeric": false + }, + { + "id": "alteration", + "name": "Alteration", + "numeric": false + }, + { + "id": "variantType", + "name": "Variant Type", + "numeric": false + }, + { + "id": "vaf", + "name": "Allele Freq (T)", + "numeric": true + }, + { + "id": "altCount", + "name": "Variant Reads", + "numeric": true + }, + { + "id": "refCount", + "name": "Ref Reads", + "numeric": true + }, + { + "id": "mutCount", + "name": "# Mut in Sample", + "numeric": true + }, + { + "id": "chr", + "name": "Chromosome", + "numeric": false + }, + { + "id": "start", + "name": "Start Pos", + "numeric": true + }, + { + "id": "end", + "name": "End Pos", + "numeric": true + }, + { + "id": "ref", + "name": "Ref", + "numeric": false + }, + { + "id": "var", + "name": "Var", + "numeric": false + }, + { + "id": "status", + "name": "MS", + "numeric": false + } + ], + "shown": [ + "sample", + "proteinChange", + "annotation", + "vaf", + "mutCount" + ], + "defaults": [ + "sample", + "cancerType", + "proteinChange", + "annotation", + "mutationType", + "mutCount" + ], + "query": { + "columns": [ + "sample", + "proteinChange", + "annotation", + "vaf", + "mutCount" + ], + "filters": { + "proteinChange": { + "op": "regex", + "value": "^G1[23]" + }, + "vaf": { + "min": 0.2 + } + }, + "sort": { + "column": "vaf", + "desc": true + } + }, + "rows": [ + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0044990", + "sample": "P-0044990-T01-IM6", + "values": [ + "P-0044990-T01-IM6", + "Colon Adenocarcinoma", + "G12D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.928, + 257, + 20, + 9, + "12", + 25398284, + 25398284, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0074217", + "sample": "P-0074217-T02-IM7", + "values": [ + "P-0074217-T02-IM7", + "Large Cell Neuroendocrine Carcinoma", + "G12C", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.922, + 665, + 56, + 3, + "12", + 25398285, + 25398285, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0066632", + "sample": "P-0066632-T01-IM7", + "values": [ + "P-0066632-T01-IM7", + "Colon Adenocarcinoma", + "G12D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.896, + 121, + 14, + 7, + "12", + 25398284, + 25398284, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0011108", + "sample": "P-0011108-T01-IM5", + "values": [ + "P-0011108-T01-IM5", + "Colon Adenocarcinoma", + "G12D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.888, + 772, + 97, + 9, + "12", + 25398284, + 25398284, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0046395", + "sample": "P-0046395-T01-IM6", + "values": [ + "P-0046395-T01-IM6", + "Colorectal Adenocarcinoma", + "G13D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.814, + 415, + 95, + 10, + "12", + 25398281, + 25398281, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0018448", + "sample": "P-0018448-T01-IM6", + "values": [ + "P-0018448-T01-IM6", + "Colon Adenocarcinoma", + "G12D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.799, + 860, + 217, + 16, + "12", + 25398284, + 25398284, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0055331", + "sample": "P-0055331-T01-IM6", + "values": [ + "P-0055331-T01-IM6", + "Colon Adenocarcinoma", + "G12A", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.796, + 266, + 68, + 9, + "12", + 25398284, + 25398284, + "C", + "G", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0057020", + "sample": "P-0057020-T01-IM6", + "values": [ + "P-0057020-T01-IM6", + "Colorectal Adenocarcinoma", + "G12C", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.792, + 179, + 47, + 7, + "12", + 25398285, + 25398285, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0012877", + "sample": "P-0012877-T01-IM5", + "values": [ + "P-0012877-T01-IM5", + "Colon Adenocarcinoma", + "G12D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.791, + 457, + 121, + 10, + "12", + 25398284, + 25398284, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0005029", + "sample": "P-0005029-T01-IM5", + "values": [ + "P-0005029-T01-IM5", + "Rectal Adenocarcinoma", + "G13D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.786, + 434, + 118, + 3, + "12", + 25398281, + 25398281, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0015210", + "sample": "P-0015210-T01-IM6", + "values": [ + "P-0015210-T01-IM6", + "Colon Adenocarcinoma", + "G12D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.775, + 856, + 248, + 5, + "12", + 25398284, + 25398284, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0000739", + "sample": "P-0000739-T01-IM3", + "values": [ + "P-0000739-T01-IM3", + "Colon Adenocarcinoma", + "G12C", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.768, + 540, + 163, + 7, + "12", + 25398285, + 25398285, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0078660", + "sample": "P-0078660-T01-IM7", + "values": [ + "P-0078660-T01-IM7", + "Colorectal Adenocarcinoma", + "G12C", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.763, + 161, + 50, + 13, + "12", + 25398285, + 25398285, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0007990", + "sample": "P-0007990-T01-IM5", + "values": [ + "P-0007990-T01-IM5", + "Colon Adenocarcinoma", + "G12S", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.759, + 1216, + 386, + 7, + "12", + 25398285, + 25398285, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0050517", + "sample": "P-0050517-T01-IM6", + "values": [ + "P-0050517-T01-IM6", + "Colon Adenocarcinoma", + "G12V", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.751, + 175, + 58, + 10, + "12", + 25398284, + 25398284, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0039168", + "sample": "P-0039168-T01-IM6", + "values": [ + "P-0039168-T01-IM6", + "Mucinous Adenocarcinoma of the Colon and Rectum", + "G12S", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.744, + 886, + 305, + 4, + "12", + 25398285, + 25398285, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0041600", + "sample": "P-0041600-T01-IM6", + "values": [ + "P-0041600-T01-IM6", + "Colorectal Adenocarcinoma", + "G12V", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.741, + 304, + 106, + 6, + "12", + 25398284, + 25398284, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0046742", + "sample": "P-0046742-T01-IM6", + "values": [ + "P-0046742-T01-IM6", + "Colon Adenocarcinoma", + "G13D", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.724, + 184, + 70, + 7, + "12", + 25398281, + 25398281, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0008735", + "sample": "P-0008735-T01-IM5", + "values": [ + "P-0008735-T01-IM5", + "Colon Adenocarcinoma", + "G12C", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.723, + 748, + 286, + 10, + "12", + 25398285, + 25398285, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "patient": "P-0089247", + "sample": "P-0089247-T01-IM7", + "values": [ + "P-0089247-T01-IM7", + "Colon Adenocarcinoma", + "G12V", + "Oncogenic · Level 1", + "Missense_Mutation", + "Missense · Driver", + "SNP", + 0.722, + 255, + 98, + 8, + "12", + 25398284, + 25398284, + "C", + "A", + "SOMATIC" + ] + }, + { + "…": "5 more", + "sha256": "a704ba8fc2fb562f" + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Colorectal", + "study": "msk_chord_2024", + "total": 1378, + "all": 2426 + } + ], + "total": 1378, + "all": 2426, + "oncokbPin": "v7.5" + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "Every KRAS mutation call in the cohort's samples, one row per call; uncalled mutations are left out, as the portal leaves them out. Annotation is OncoKB v7.5 (oncogenicity and its highest sensitivity level for the gene). Allele frequency is variant reads over variant + reference reads; # Mut in Sample is the study's own MUTATION_COUNT, blank where it records none. Showing 1,378 of 2,426 mutations: rows Protein Change matches /^G1[23]/; Allele Freq (T) ≥ 0.2. Sorted by Allele Freq (T) (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count the KRAS mutation calls per cohort and study, and those the query keeps", + "detail": "The mutations:counts query above: every called KRAS mutation in each cohort's samples (uncalled calls left out), with the sample's CANCER_TYPE_DETAILED and MUTATION_COUNT where recorded and the OncoKB v7.5 call for its protein change; allele frequency = variant / (variant + reference) reads. The query keeps rows Protein Change matches /^G1[23]/; Allele Freq (T) ≥ 0.2.", + "params": [ + [ + "Colorectal · msk_chord_2024", + "1,378 of 2,426" + ] + ] + }, + { + "kind": "fetch", + "title": "Sort them together and take one page", + "detail": "The mutations:rows query above: the KRAS mutation calls of every cohort and study combined in one query, kept to rows Protein Change matches /^G1[23]/; Allele Freq (T) ≥ 0.2, sorted by Allele Freq (T) descending, missing last, then sample, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset." + } + ], + "implementation": { + "functions": [ + "mutationRowSource", + "pageSql", + "countsSql" + ], + "file": "lib/mutation-table.ts, lib/table-query.ts", + "commit": null + }, + "verification": "A listing: no statistic is computed, so there is no script — the queries are the numbers." + } + } + ] +} diff --git a/test/snapshots/mutations.sql b/test/snapshots/mutations.sql new file mode 100644 index 0000000..9db37e0 --- /dev/null +++ b/test/snapshots/mutations.sql @@ -0,0 +1,77 @@ +-- cohort Colorectal +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) + +-- view 0 mutations: mutations:counts · msk_chord_2024 +WITH ann AS (SELECT alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'MUTATION' AND hugo_gene_symbol = 'KRAS' + GROUP BY alteration), +c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +m0 AS ( + SELECT patientId AS pid, sampleId AS sid, proteinChange, mutationType, variantType, chr, startPosition AS start, endPosition AS end, + referenceAllele AS ref, tumorSeqAllele AS var, tumorAltCount AS altCount, tumorRefCount AS refCount, mutationStatus AS status, proteinPosStart AS pos + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND `GENE.hugoGeneSymbol` = 'KRAS' + AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) +), +ct0 AS (SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, any(attribute_value) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' AND attribute_name = 'CANCER_TYPE_DETAILED' + AND sample_unique_id IN (SELECT concat('msk_chord_2024_', sid) FROM m0) GROUP BY sid), +mc0 AS (SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, any(attribute_value) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' AND attribute_name = 'MUTATION_COUNT' + AND sample_unique_id IN (SELECT concat('msk_chord_2024_', sid) FROM m0) GROUP BY sid), +rows AS ( + SELECT 'Colorectal' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, + m.pid AS patient, m.sid AS sid, ct.v AS cancerType, m.proteinChange AS proteinChange, + ann.oncogenicity AS oncogenicity, ann.level AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + m.mutationType AS mutationType, m.variantType AS variantType, + if(m.altCount + m.refCount > 0, m.altCount / (m.altCount + m.refCount), NULL) AS vaf, m.altCount AS altCount, m.refCount AS refCount, + toInt64OrNull(mc.v) AS mutCount, m.chr AS chr, m.start AS start, m.end AS end, m.ref AS ref, m.var AS var, m.status AS status, m.pos AS pos + FROM m0 AS m + LEFT JOIN ann ON ann.alteration = m.proteinChange + LEFT JOIN ct0 AS ct ON ct.sid = m.sid LEFT JOIN mc0 AS mc ON mc.sid = m.sid +) +SELECT cohort, study, countIf((match(ifNull(toString(proteinChange), ''), '^G1[23]')) AND (CAST(vaf AS Nullable(Float64)) IS NOT NULL AND CAST(vaf AS Nullable(Float64)) >= 0.2)) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 mutations: mutations:rows · msk_chord_2024 +WITH ann AS (SELECT alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'MUTATION' AND hugo_gene_symbol = 'KRAS' + GROUP BY alteration), +c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +m0 AS ( + SELECT patientId AS pid, sampleId AS sid, proteinChange, mutationType, variantType, chr, startPosition AS start, endPosition AS end, + referenceAllele AS ref, tumorSeqAllele AS var, tumorAltCount AS altCount, tumorRefCount AS refCount, mutationStatus AS status, proteinPosStart AS pos + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND `GENE.hugoGeneSymbol` = 'KRAS' + AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) +), +ct0 AS (SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, any(attribute_value) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' AND attribute_name = 'CANCER_TYPE_DETAILED' + AND sample_unique_id IN (SELECT concat('msk_chord_2024_', sid) FROM m0) GROUP BY sid), +mc0 AS (SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, any(attribute_value) AS v FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' AND attribute_name = 'MUTATION_COUNT' + AND sample_unique_id IN (SELECT concat('msk_chord_2024_', sid) FROM m0) GROUP BY sid), +rows AS ( + SELECT 'Colorectal' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, + m.pid AS patient, m.sid AS sid, ct.v AS cancerType, m.proteinChange AS proteinChange, + ann.oncogenicity AS oncogenicity, ann.level AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + m.mutationType AS mutationType, m.variantType AS variantType, + if(m.altCount + m.refCount > 0, m.altCount / (m.altCount + m.refCount), NULL) AS vaf, m.altCount AS altCount, m.refCount AS refCount, + toInt64OrNull(mc.v) AS mutCount, m.chr AS chr, m.start AS start, m.end AS end, m.ref AS ref, m.var AS var, m.status AS status, m.pos AS pos + FROM m0 AS m + LEFT JOIN ann ON ann.alteration = m.proteinChange + LEFT JOIN ct0 AS ct ON ct.sid = m.sid LEFT JOIN mc0 AS mc ON mc.sid = m.sid +) +SELECT *, count() OVER () AS total FROM rows +WHERE (match(ifNull(toString(proteinChange), ''), '^G1[23]')) AND (CAST(vaf AS Nullable(Float64)) IS NOT NULL AND CAST(vaf AS Nullable(Float64)) >= 0.2) +ORDER BY CAST(vaf AS Nullable(Float64)) DESC NULLS LAST, sid, ord, proteinChange +LIMIT 25 OFFSET 0 diff --git a/test/snapshots/mutations.svg b/test/snapshots/mutations.svg new file mode 100644 index 0000000..4ce19f7 --- /dev/null +++ b/test/snapshots/mutations.svg @@ -0,0 +1,2 @@ + +(no figure) diff --git a/test/snapshots/mutations.txt b/test/snapshots/mutations.txt new file mode 100644 index 0000000..5ec15ce --- /dev/null +++ b/test/snapshots/mutations.txt @@ -0,0 +1,39 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Colorectal: 5,543 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) + +KRAS mutations: 1,378 of 2,426 rows kept by the query; the first 25, tab-separated (the web app's view pages and downloads every row, with every column): + cohort sample proteinChange annotation vaf mutCount + Colorectal P-0044990-T01-IM6 G12D Oncogenic · Level 1 0.928 9 + Colorectal P-0074217-T02-IM7 G12C Oncogenic · Level 1 0.922 3 + Colorectal P-0066632-T01-IM7 G12D Oncogenic · Level 1 0.896 7 + Colorectal P-0011108-T01-IM5 G12D Oncogenic · Level 1 0.888 9 + Colorectal P-0046395-T01-IM6 G13D Oncogenic · Level 1 0.814 10 + Colorectal P-0018448-T01-IM6 G12D Oncogenic · Level 1 0.799 16 + Colorectal P-0055331-T01-IM6 G12A Oncogenic · Level 1 0.796 9 + Colorectal P-0057020-T01-IM6 G12C Oncogenic · Level 1 0.792 7 + Colorectal P-0012877-T01-IM5 G12D Oncogenic · Level 1 0.791 10 + Colorectal P-0005029-T01-IM5 G13D Oncogenic · Level 1 0.786 3 + Colorectal P-0015210-T01-IM6 G12D Oncogenic · Level 1 0.775 5 + Colorectal P-0000739-T01-IM3 G12C Oncogenic · Level 1 0.768 7 + Colorectal P-0078660-T01-IM7 G12C Oncogenic · Level 1 0.763 13 + Colorectal P-0007990-T01-IM5 G12S Oncogenic · Level 1 0.759 7 + Colorectal P-0050517-T01-IM6 G12V Oncogenic · Level 1 0.751 10 + Colorectal P-0039168-T01-IM6 G12S Oncogenic · Level 1 0.744 4 + Colorectal P-0041600-T01-IM6 G12V Oncogenic · Level 1 0.741 6 + Colorectal P-0046742-T01-IM6 G13D Oncogenic · Level 1 0.724 7 + Colorectal P-0008735-T01-IM5 G12C Oncogenic · Level 1 0.723 10 + Colorectal P-0089247-T01-IM7 G12V Oncogenic · Level 1 0.722 8 + Colorectal P-0057012-T01-IM6 G12V Oncogenic · Level 1 0.72 9 + Colorectal P-0012653-T01-IM5 G13D Oncogenic · Level 1 0.718 4 + Colorectal P-0042211-T01-IM6 G12D Oncogenic · Level 1 0.718 8 + Colorectal P-0087879-T01-IM7 G13D Oncogenic · Level 1 0.718 8 + Colorectal P-0077659-T01-IM7 G12R Oncogenic · Level 1 0.716 38 + … 1,353 more rows + CAVEAT (tell the user): Every KRAS mutation call in the cohort's samples, one row per call; uncalled mutations are left out, as the portal leaves them out. Annotation is OncoKB v7.5 (oncogenicity and its highest sensitivity level for the gene). Allele frequency is variant reads over variant + reference reads; # Mut in Sample is the study's own MUTATION_COUNT, blank where it records none. Showing 1,378 of 2,426 mutations: rows Protein Change matches /^G1[23]/; Allele Freq (T) ≥ 0.2. Sorted by Allele Freq (T) (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. + METHOD: + - Count the KRAS mutation calls per cohort and study, and those the query keeps: The mutations:counts query above: every called KRAS mutation in each cohort's samples (uncalled calls left out), with the sample's CANCER_TYPE_DETAILED and MUTATION_COUNT where recorded and the OncoKB v7.5 call for its protein change; allele frequency = variant / (variant + reference) reads. The query keeps rows Protein Change matches /^G1[23]/; Allele Freq (T) ≥ 0.2. + Colorectal · msk_chord_2024: 1,378 of 2,426 + - Sort them together and take one page: The mutations:rows query above: the KRAS mutation calls of every cohort and study combined in one query, kept to rows Protein Change matches /^G1[23]/; Allele Freq (T) ≥ 0.2, sorted by Allele Freq (T) descending, missing last, then sample, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset. + A listing: no statistic is computed, so there is no script — the queries are the numbers. diff --git a/test/snapshots/overlap.json b/test/snapshots/overlap.json new file mode 100644 index 0000000..3425ccb --- /dev/null +++ b/test/snapshots/overlap.json @@ -0,0 +1,237 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "TP53 mutant": { + "count": 13105, + "text": "OQL[TP53: MUT]", + "studies": [ + "msk_chord_2024" + ] + }, + "KRAS mutant": { + "count": 7115, + "text": "OQL[KRAS: MUT]", + "studies": [ + "msk_chord_2024" + ] + }, + "Immunotherapy": { + "count": 3341, + "text": "has Immuno treatment", + "studies": [ + "msk_chord_2024" + ] + }, + "NSCLC": { + "count": 7809, + "text": "CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "overlap", + "cohorts": [ + "TP53 mutant", + "KRAS mutant", + "Immunotherapy", + "NSCLC" + ], + "overlap": { + "sets": [ + { + "name": "TP53 mutant", + "size": 13105, + "samples": 13172 + }, + { + "name": "KRAS mutant", + "size": 7115, + "samples": 7161 + }, + { + "name": "Immunotherapy", + "size": 3341, + "samples": 3372 + }, + { + "name": "NSCLC", + "size": 7809, + "samples": 7876 + } + ], + "intersections": [ + { + "members": [ + "TP53 mutant" + ], + "n": 5314, + "samples": 5320 + }, + { + "members": [ + "TP53 mutant", + "KRAS mutant" + ], + "n": 3391, + "samples": 3402 + }, + { + "members": [ + "TP53 mutant", + "NSCLC" + ], + "n": 2043, + "samples": 2055 + }, + { + "members": [ + "NSCLC" + ], + "n": 1887, + "samples": 1897 + }, + { + "members": [ + "KRAS mutant" + ], + "n": 1381, + "samples": 1381 + }, + { + "members": [ + "TP53 mutant", + "Immunotherapy", + "NSCLC" + ], + "n": 1167, + "samples": 1176 + }, + { + "members": [ + "KRAS mutant", + "NSCLC" + ], + "n": 838, + "samples": 842 + }, + { + "members": [ + "KRAS mutant", + "Immunotherapy", + "NSCLC" + ], + "n": 546, + "samples": 548 + }, + { + "members": [ + "Immunotherapy", + "NSCLC" + ], + "n": 518, + "samples": 523 + }, + { + "members": [ + "TP53 mutant", + "KRAS mutant", + "Immunotherapy", + "NSCLC" + ], + "n": 435, + "samples": 444 + }, + { + "members": [ + "TP53 mutant", + "KRAS mutant", + "NSCLC" + ], + "n": 375, + "samples": 391 + }, + { + "members": [ + "TP53 mutant", + "Immunotherapy" + ], + "n": 292, + "samples": 293 + }, + { + "members": [ + "Immunotherapy" + ], + "n": 234, + "samples": 235 + }, + { + "members": [ + "TP53 mutant", + "KRAS mutant", + "Immunotherapy" + ], + "n": 88, + "samples": 91 + }, + { + "members": [ + "KRAS mutant", + "Immunotherapy" + ], + "n": 61, + "samples": 62 + } + ], + "union": 18570 + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Patients in exactly the marked cohorts and none of the others, for every combination that has any — computed inside each study's database, which returns one count per combination. 18,570 patients are in at least one of the 4 cohorts. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients per combination of cohorts", + "detail": "The overlap query above: every patient in any of TP53 mutant, KRAS mutant, Immunotherapy, NSCLC gets a bitmask of the cohorts it is in, and the study returns one count per bitmask. Counts only.", + "scope": "msk_chord_2024", + "rowsOut": 18570 + }, + { + "kind": "transform", + "title": "Add the counts across studies and name each combination", + "detail": "Each study's bits are mapped back to the view's cohort order; combinations add exactly, and a patient can only overlap within one study.", + "params": [ + [ + "patients in any cohort", + "18,570" + ], + [ + "combinations with patients", + "15" + ] + ] + } + ], + "implementation": { + "functions": [], + "file": "lib/views/overlap.ts", + "commit": null + } + } + } + ] +} diff --git a/test/snapshots/overlap.sql b/test/snapshots/overlap.sql new file mode 100644 index 0000000..0d3a996 --- /dev/null +++ b/test/snapshots/overlap.sql @@ -0,0 +1,82 @@ +-- cohort TP53 mutant +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort KRAS mutant +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort Immunotherapy +-- msk_chord_2024 +(WITH +study_patients AS ( + SELECT p.internal_id FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' +), +sel_a AS ( +SELECT ce.patient_id, ce.start_date, ce.stop_date + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.clinical_event_data a0 ON a0.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(a0.key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(a0.value)) = lowerUTF8(trimBoth('Immuno')) + WHERE lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.patient_id IN (SELECT internal_id FROM study_patients) +) +SELECT DISTINCT p.stable_id AS pid +FROM sel_a + JOIN snapshot_db.patient p ON p.internal_id = sel_a.patient_id +WHERE 1 +ORDER BY pid LIMIT 1000000) + +-- cohort NSCLC +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer')))) + +-- view 0 overlap: overlap · msk_chord_2024 +WITH c0 AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +c1 AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +c2 AS ((WITH +study_patients AS ( + SELECT p.internal_id FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' +), +sel_a AS ( +SELECT ce.patient_id, ce.start_date, ce.stop_date + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.clinical_event_data a0 ON a0.clinical_event_id = ce.clinical_event_id AND lowerUTF8(trimBoth(a0.key)) = lowerUTF8(trimBoth('SUBTYPE')) AND lowerUTF8(trimBoth(a0.value)) = lowerUTF8(trimBoth('Immuno')) + WHERE lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('Treatment')) + AND ce.patient_id IN (SELECT internal_id FROM study_patients) +) +SELECT DISTINCT p.stable_id AS pid +FROM sel_a + JOIN snapshot_db.patient p ON p.internal_id = sel_a.patient_id +WHERE 1 +ORDER BY pid LIMIT 1000000)), +c3 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer'))))), +u AS (SELECT pid FROM c0 UNION DISTINCT SELECT pid FROM c1 UNION DISTINCT SELECT pid FROM c2 UNION DISTINCT SELECT pid FROM c3), +m AS (SELECT pid, (pid IN (SELECT pid FROM c0)) * 1 + (pid IN (SELECT pid FROM c1)) * 2 + (pid IN (SELECT pid FROM c2)) * 4 + (pid IN (SELECT pid FROM c3)) * 8 AS mask FROM u), +s AS (SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, count() AS ns FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM u) GROUP BY pid) +SELECT mask, count() AS n, sum(s.ns) AS samples FROM m LEFT JOIN s ON s.pid = m.pid GROUP BY mask ORDER BY n DESC diff --git a/test/snapshots/overlap.svg b/test/snapshots/overlap.svg new file mode 100644 index 0000000..4793182 --- /dev/null +++ b/test/snapshots/overlap.svg @@ -0,0 +1,2 @@ + +Cohort overlap — TP53 mutant, KRAS mutant, Immunotherapy, NSCLC02,0004,0006,000patients in exactly these cohortsTP53 mutant: 5,314 patients5,314TP53 mutant ∩ KRAS mutant: 3,391 patients3,391TP53 mutant ∩ NSCLC: 2,043 patients2,043NSCLC: 1,887 patients1,887KRAS mutant: 1,381 patients1,381TP53 mutant ∩ Immunotherapy ∩ NSCLC: 1,167 patients1,167KRAS mutant ∩ NSCLC: 838 patients838KRAS mutant ∩ Immunotherapy ∩ NSCLC: 546 patients546Immunotherapy ∩ NSCLC: 518 patients518TP53 mutant ∩ KRAS mutant ∩ Immunotherapy ∩ NSCLC: 435 patients435TP53 mutant ∩ KRAS mutant ∩ NSCLC: 375 patients375TP53 mutant ∩ Immunotherapy: 292 patients292Immunotherapy: 234 patients234TP53 mutant ∩ KRAS mutant ∩ Immunotherapy: 88 patients88KRAS mutant ∩ Immunotherapy: 61 patients61patientsTP53 mutant13,105KRAS mutant7,115Immunotherapy3,341NSCLC7,80918,570 patients in at least one cohort · 15 non-empty combinations of 15Patients in exactly the marked cohorts and none of the others, for every combination that has any — computed inside each study's database, which returns one count percombination. 18,570 patients are in at least one of the 4 cohorts. diff --git a/test/snapshots/overlap.txt b/test/snapshots/overlap.txt new file mode 100644 index 0000000..ae1afec --- /dev/null +++ b/test/snapshots/overlap.txt @@ -0,0 +1,32 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- TP53 mutant: 13,105 patients — OQL[TP53: MUT] +- KRAS mutant: 7,115 patients — OQL[KRAS: MUT] +- Immunotherapy: 3,341 patients — has Immuno treatment +- NSCLC: 7,809 patients — CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample) + +Cohort overlap (patients in exactly these cohorts and no other): + cohort sizes: TP53 mutant 13,105, KRAS mutant 7,115, Immunotherapy 3,341, NSCLC 7,809 + TP53 mutant only: 5,314 + TP53 mutant ∩ KRAS mutant only: 3,391 + TP53 mutant ∩ NSCLC only: 2,043 + NSCLC only: 1,887 + KRAS mutant only: 1,381 + TP53 mutant ∩ Immunotherapy ∩ NSCLC only: 1,167 + KRAS mutant ∩ NSCLC only: 838 + KRAS mutant ∩ Immunotherapy ∩ NSCLC only: 546 + Immunotherapy ∩ NSCLC only: 518 + TP53 mutant ∩ KRAS mutant ∩ Immunotherapy ∩ NSCLC: 435 + TP53 mutant ∩ KRAS mutant ∩ NSCLC only: 375 + TP53 mutant ∩ Immunotherapy only: 292 + Immunotherapy only: 234 + TP53 mutant ∩ KRAS mutant ∩ Immunotherapy only: 88 + KRAS mutant ∩ Immunotherapy only: 61 + 18,570 patients in at least one cohort + CAVEAT (tell the user): Patients in exactly the marked cohorts and none of the others, for every combination that has any — computed inside each study's database, which returns one count per combination. 18,570 patients are in at least one of the 4 cohorts. + METHOD: + - Count patients per combination of cohorts [msk_chord_2024]: The overlap query above: every patient in any of TP53 mutant, KRAS mutant, Immunotherapy, NSCLC gets a bitmask of the cohorts it is in, and the study returns one count per bitmask. Counts only. + - Add the counts across studies and name each combination: Each study's bits are mapped back to the view's cohort order; combinations add exactly, and a patient can only overlap within one study. + patients in any cohort: 18,570 + combinations with patients: 15 diff --git a/test/snapshots/paired.json b/test/snapshots/paired.json new file mode 100644 index 0000000..84b66e1 --- /dev/null +++ b/test/snapshots/paired.json @@ -0,0 +1,233 @@ +{ + "study": "msk_impact_50k_2026", + "cohorts": { + "all patients": { + "count": 48179, + "text": "all patients in the study", + "studies": [ + "msk_impact_50k_2026" + ] + } + }, + "views": [ + { + "kind": "paired", + "cohorts": [ + "all patients" + ], + "paired": { + "pairBy": { + "attribute": "SAMPLE_TYPE", + "a": [ + "Primary" + ], + "b": [ + "Metastasis" + ] + }, + "labels": { + "a": "Primary", + "b": "Metastasis" + }, + "measure": "driver", + "panels": [ + { + "cohort": "all patients", + "patients": 2278, + "aSamples": 2558, + "bSamples": 2674, + "genes": [ + { + "gene": "TP53", + "pairs": 2278, + "both": 930, + "aOnly": 108, + "bOnly": 161, + "neither": 1079, + "concordance": 0.776, + "p": 0.0014752559593677614, + "q": 0.002360409534988418 + }, + { + "gene": "KRAS", + "pairs": 2278, + "both": 235, + "aOnly": 58, + "bOnly": 75, + "neither": 1910, + "concordance": 0.639, + "p": 0.16508338915579682, + "q": 0.18866673046376778 + }, + { + "gene": "PIK3CA", + "pairs": 2278, + "both": 199, + "aOnly": 87, + "bOnly": 64, + "neither": 1928, + "concordance": 0.569, + "p": 0.07304915944162735, + "q": 0.09739887925550313 + }, + { + "gene": "ESR1", + "pairs": 2278, + "both": 4, + "aOnly": 7, + "bOnly": 49, + "neither": 2218, + "concordance": 0.067, + "p": 7.455210310203303e-9, + "q": 2.982084124081321e-8 + }, + { + "gene": "AR", + "pairs": 2278, + "both": 9, + "aOnly": 1, + "bOnly": 71, + "neither": 2197, + "concordance": 0.111, + "p": 3.091670257478201e-20, + "q": 2.473336205982561e-19 + }, + { + "gene": "CDKN2A", + "pairs": 2278, + "both": 222, + "aOnly": 123, + "bOnly": 180, + "neither": 1753, + "concordance": 0.423, + "p": 0.0012575668195445922, + "q": 0.002360409534988418 + }, + { + "gene": "MYC", + "pairs": 2278, + "both": 65, + "aOnly": 47, + "bOnly": 113, + "neither": 2053, + "concordance": 0.289, + "p": 1.876911518039637e-7, + "q": 5.005097381439033e-7 + }, + { + "gene": "TERT", + "pairs": 2278, + "both": 298, + "aOnly": 72, + "bOnly": 75, + "neither": 1833, + "concordance": 0.67, + "p": 0.8690499708342935, + "q": 0.8690499708342935 + } + ] + } + ] + }, + "participation": { + "studies": [ + { + "study": "msk_impact_50k_2026", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Within patients with samples on both sides, Primary and Metastasis (SAMPLE_TYPE = Primary vs Metastasis; all patients: 2,278 patients), per gene, among those profiled for it on BOTH sides by each side's own panels: an OncoKB driver (v7.5) on both sides, on the Primary side only, or the Metastasis side only; a patient with several samples on a side counts as altered there if any is. Concordance is both ÷ altered anywhere. The exact McNemar test asks whether discordance runs one way; q is Benjamini–Hochberg across the genes of each cohort. A sample's SAMPLE_TYPE records where the tissue came from, not when it was taken, so Metastasis-only is not the same as \"acquired later\"; and patients sampled twice are a selected group, typically with longer or harder disease courses.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count each gene's state in paired samples", + "detail": "The paired:patients and paired:genes queries above. Patients with both a SAMPLE_TYPE = Primary sample (Primary) and a SAMPLE_TYPE = Metastasis sample (Metastasis); per gene, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the Primary side only, or the Metastasis side only. A patient with several samples on one side counts as altered there if any is. Counts only.", + "scope": "all patients · msk_impact_50k_2026", + "rowsIn": 48179 + }, + { + "kind": "statistic", + "title": "Exact McNemar test per gene", + "detail": "Only the discordant patients carry information about direction: of the Primary-only and Metastasis-only patients, each is a fair coin under the null, so p is twice the smaller binomial tail (capped at 1). Concordance is both ÷ altered anywhere.", + "params": [ + [ + "all patients", + "2,278 patients with both kinds of sample" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across genes, per cohort", + "detail": "q-values over the genes with at least one discordant patient, separately for each cohort." + } + ], + "implementation": { + "functions": [ + "mcnemarExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "The exact McNemar test matches statsmodels 0.15.0 mcnemar(exact=True) and Benjamini–Hochberg multipletests, to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "paired:all patients:TP53:p": { + "v": 0.0014752559593677614 + }, + "paired:all patients:TP53:q": { + "v": 0.002360409534988418 + }, + "paired:all patients:KRAS:p": { + "v": 0.16508338915579682 + }, + "paired:all patients:KRAS:q": { + "v": 0.18866673046376778 + }, + "paired:all patients:PIK3CA:p": { + "v": 0.07304915944162735 + }, + "paired:all patients:PIK3CA:q": { + "v": 0.09739887925550313 + }, + "paired:all patients:ESR1:p": { + "v": 7.455210310203303e-9 + }, + "paired:all patients:ESR1:q": { + "v": 2.982084124081321e-8 + }, + "paired:all patients:AR:p": { + "v": 3.091670257478201e-20 + }, + "paired:all patients:AR:q": { + "v": 2.473336205982561e-19 + }, + "paired:all patients:CDKN2A:p": { + "v": 0.0012575668195445922 + }, + "paired:all patients:CDKN2A:q": { + "v": 0.002360409534988418 + }, + "paired:all patients:MYC:p": { + "v": 1.876911518039637e-7 + }, + "paired:all patients:MYC:q": { + "v": 5.005097381439033e-7 + }, + "paired:all patients:TERT:p": { + "v": 0.8690499708342935 + }, + "paired:all patients:TERT:q": { + "v": 0.8690499708342935 + } + } + } + } + ] +} diff --git a/test/snapshots/paired.sql b/test/snapshots/paired.sql new file mode 100644 index 0000000..b991703 --- /dev/null +++ b/test/snapshots/paired.sql @@ -0,0 +1,61 @@ +-- cohort all patients +-- msk_impact_50k_2026 +SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' + +-- view 0 paired: paired:genes:all patients · msk_impact_50k_2026 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Primary'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Metastasis'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'SAMPLE_TYPE' + AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)), +alt AS ( + SELECT g.hugo_gene_symbol AS gene, ps.pid AS pid, ps.side AS side, max(ann.is_driver) AS hit + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + INNER JOIN ps ON ps.suid = g.sample_unique_id + WHERE g.cancer_study_identifier = 'msk_impact_50k_2026' AND g.hugo_gene_symbol IN ('TP53','KRAS','PIK3CA','ESR1','AR','CDKN2A','MYC','TERT') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM ps) + GROUP BY gene, pid, side +), +cov AS ( + SELECT DISTINCT pg.gene AS gene, ps.pid AS pid, ps.side AS side + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('TP53','KRAS','PIK3CA','ESR1','AR','CDKN2A','MYC','TERT') + INNER JOIN ps ON ps.suid = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_impact_50k_2026' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') +), +per AS ( + SELECT gene, pid, max(side = 'a') AS pa, max(side = 'b') AS pb, + max(side = 'a' AND hit > 0) AS aa, max(side = 'b' AND hit > 0) AS ab + FROM (SELECT gene, pid, side, hit FROM alt UNION ALL SELECT gene, pid, side, 0 AS hit FROM cov) + GROUP BY gene, pid +) +SELECT gene, count() AS pairs, countIf(aa AND ab) AS both, countIf(aa AND NOT ab) AS a_only, countIf(ab AND NOT aa) AS b_only +FROM per WHERE pa AND pb GROUP BY gene + +-- view 0 paired: paired:patients:all patients · msk_impact_50k_2026 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Primary'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Metastasis'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_impact_50k_2026' AND type = 'sample' AND attribute_name = 'SAMPLE_TYPE' + AND replaceOne(patient_unique_id, 'msk_impact_50k_2026_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)) +SELECT uniqExact(pid) AS patients, countIf(side = 'a') AS a_samples, countIf(side = 'b') AS b_samples FROM ps diff --git a/test/snapshots/paired.svg b/test/snapshots/paired.svg new file mode 100644 index 0000000..b0e6ac2 --- /dev/null +++ b/test/snapshots/paired.svg @@ -0,0 +1,2 @@ + +Paired samples — Primary vs MetastasisPrimary onlybothMetastasis onlyall patients2,278 patients with both · 2,558 Primary and 2,674 Metastasis samplesconcordantprofiled pairsMcNemar qTP53TP53 — 108 patients altered Primary only108TP53 — 930 patients altered both930TP53 — 161 patients altered Metastasis only16177.6%2,2780.0024more Metastasis-onlyKRASKRAS — 58 patients altered Primary only58KRAS — 235 patients altered both235KRAS — 75 patients altered Metastasis only7563.9%2,2780.19PIK3CAPIK3CA — 87 patients altered Primary only87PIK3CA — 199 patients altered both199PIK3CA — 64 patients altered Metastasis only6456.9%2,2780.097ESR1ESR1 — 7 patients altered Primary onlyESR1 — 4 patients altered bothESR1 — 49 patients altered Metastasis only496.7%2,2783e-8more Metastasis-onlyARAR — 1 patients altered Primary onlyAR — 9 patients altered bothAR — 71 patients altered Metastasis only7111.1%2,2782.5e-19more Metastasis-onlyCDKN2ACDKN2A — 123 patients altered Primary only123CDKN2A — 222 patients altered both222CDKN2A — 180 patients altered Metastasis only18042.3%2,2780.0024more Metastasis-onlyMYCMYC — 47 patients altered Primary only47MYC — 65 patients altered both65MYC — 113 patients altered Metastasis only11328.9%2,2785e-7more Metastasis-onlyTERTTERT — 72 patients altered Primary only72TERT — 298 patients altered both298TERT — 75 patients altered Metastasis only7567.0%2,2780.8702004006008001,0001,200patients altered on either sideWithin patients with samples on both sides, Primary and Metastasis (SAMPLE_TYPE = Primary vs Metastasis; all patients: 2,278 patients), per gene, among those profiledfor it on BOTH sides by each side's own panels: an OncoKB driver (v7.5) on both sides, on the Primary side only, or the Metastasis side only; a patient with severalsamples on a side counts as altered there if any is. Concordance is both ÷ altered anywhere. The exact McNemar test asks whether discordance runs one way; q isBenjamini–Hochberg across the genes of each cohort. A sample's SAMPLE_TYPE records where the tissue came from, not when it was taken, so Metastasis-only is notthe same as "acquired later"; and patients sampled twice are a selected group, typically with longer or harder disease courses. diff --git a/test/snapshots/paired.txt b/test/snapshots/paired.txt new file mode 100644 index 0000000..9af231c --- /dev/null +++ b/test/snapshots/paired.txt @@ -0,0 +1,22 @@ +Analysis over msk_impact_50k_2026 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- all patients: 48,179 patients — all patients in the study + +Paired samples, Primary vs Metastasis (SAMPLE_TYPE Primary vs Metastasis; drivers; profiled on both sides): + all patients (2,278 patients with both): + TP53: both 930, Primary-only 108, Metastasis-only 161 of 2278 pairs, 78% concordant, McNemar q=0.0024 + KRAS: both 235, Primary-only 58, Metastasis-only 75 of 2278 pairs, 64% concordant, McNemar q=0.1887 + PIK3CA: both 199, Primary-only 87, Metastasis-only 64 of 2278 pairs, 57% concordant, McNemar q=0.0974 + ESR1: both 4, Primary-only 7, Metastasis-only 49 of 2278 pairs, 7% concordant, McNemar q=3.0e-8 + AR: both 9, Primary-only 1, Metastasis-only 71 of 2278 pairs, 11% concordant, McNemar q=2.5e-19 + CDKN2A: both 222, Primary-only 123, Metastasis-only 180 of 2278 pairs, 42% concordant, McNemar q=0.0024 + MYC: both 65, Primary-only 47, Metastasis-only 113 of 2278 pairs, 29% concordant, McNemar q=5.0e-7 + TERT: both 298, Primary-only 72, Metastasis-only 75 of 2278 pairs, 67% concordant, McNemar q=0.8690 + CAVEAT (tell the user): Within patients with samples on both sides, Primary and Metastasis (SAMPLE_TYPE = Primary vs Metastasis; all patients: 2,278 patients), per gene, among those profiled for it on BOTH sides by each side's own panels: an OncoKB driver (v7.5) on both sides, on the Primary side only, or the Metastasis side only; a patient with several samples on a side counts as altered there if any is. Concordance is both ÷ altered anywhere. The exact McNemar test asks whether discordance runs one way; q is Benjamini–Hochberg across the genes of each cohort. A sample's SAMPLE_TYPE records where the tissue came from, not when it was taken, so Metastasis-only is not the same as "acquired later"; and patients sampled twice are a selected group, typically with longer or harder disease courses. + METHOD: + - Count each gene's state in paired samples [all patients · msk_impact_50k_2026]: The paired:patients and paired:genes queries above. Patients with both a SAMPLE_TYPE = Primary sample (Primary) and a SAMPLE_TYPE = Metastasis sample (Metastasis); per gene, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the Primary side only, or the Metastasis side only. A patient with several samples on one side counts as altered there if any is. Counts only. + - Exact McNemar test per gene: Only the discordant patients carry information about direction: of the Primary-only and Metastasis-only patients, each is a fair coin under the null, so p is twice the smaller binomial tail (capped at 1). Concordance is both ÷ altered anywhere. + all patients: 2,278 patients with both kinds of sample + - Benjamini–Hochberg across genes, per cohort: q-values over the genes with at least one discordant patient, separately for each cohort. + The exact McNemar test matches statsmodels 0.15.0 mcnemar(exact=True) and Benjamini–Hochberg multipletests, to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/pathways.json b/test/snapshots/pathways.json new file mode 100644 index 0000000..fccf54c --- /dev/null +++ b/test/snapshots/pathways.json @@ -0,0 +1,1557 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Colorectal": { + "count": 5543, + "text": "CANCER_TYPE in [Colorectal Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + }, + "Pancreatic": { + "count": 3109, + "text": "CANCER_TYPE in [Pancreatic Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "pathways", + "cohorts": [ + "Colorectal", + "Pancreatic" + ], + "annotation": "OncoKB v7.5", + "pathways": { + "measure": "driver", + "rows": [ + { + "name": "RTK-RAS", + "source": "Sanchez-Vega 2018", + "genes": 85, + "profiledGenes": 47, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 3738, + "pct": 67.4 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 2600, + "pct": 83.6 + } + ], + "p": 6.382707592331983e-63, + "top": [ + { + "gene": "KRAS", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 2395, + "pct": 43.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 2517, + "pct": 81 + } + ], + "q": 7.736787074641247e-267 + }, + { + "gene": "BRAF", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 547, + "pct": 9.9 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 35, + "pct": 1.1 + } + ], + "q": 7.371186914678062e-68 + }, + { + "gene": "ERBB2", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 291, + "pct": 5.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 36, + "pct": 1.2 + } + ], + "q": 2.4107184931598108e-24 + }, + { + "gene": "NRAS", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 189, + "pct": 3.4 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 14, + "pct": 0.5 + } + ], + "q": 1.6486842887630062e-21 + }, + { + "gene": "FGFR1", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 136, + "pct": 2.5 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 53, + "pct": 1.7 + } + ], + "q": 0.03664470704728582 + }, + { + "gene": "ERBB3", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 130, + "pct": 2.3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 28, + "pct": 0.9 + } + ], + "q": 0.0000015378844163248904 + } + ], + "otherAltered": 32, + "notProfiled": [ + "GRB2", + "CBLB", + "CBLC", + "INSRR", + "SOS2", + "SHC1", + "SHC2", + "SHC3", + "SHC4", + "RASGRP1", + "RASGRP2", + "RASGRP3", + "RASGRP4", + "RAPGEF1", + "RAPGEF2", + "RASGRF1", + "RASGRF2", + "FNTA", + "FNTB", + "RCE1", + { + "…": "18 more", + "sha256": "143af5862385bf8b" + } + ], + "q": 1.2765415184663967e-62 + }, + { + "name": "PI3K", + "source": "Sanchez-Vega 2018", + "genes": 29, + "profiledGenes": 19, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 1754, + "pct": 31.6 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 312, + "pct": 10 + } + ], + "p": 5.785174993259107e-125, + "top": [ + { + "gene": "PIK3CA", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 1043, + "pct": 18.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 62, + "pct": 2 + } + ], + "q": 1.04249777901422e-139 + }, + { + "gene": "PTEN", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 375, + "pct": 6.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 45, + "pct": 1.4 + } + ], + "q": 2.9810488644959413e-32 + }, + { + "gene": "PIK3R1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 238, + "pct": 4.3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 10, + "pct": 0.3 + } + ], + "q": 2.8567255872660437e-33 + }, + { + "gene": "AKT2", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 37, + "pct": 0.7 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 98, + "pct": 3.2 + } + ], + "q": 2.7373073153379354e-17 + }, + { + "gene": "STK11", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 42, + "pct": 0.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 58, + "pct": 1.9 + } + ], + "q": 0.0000194231893011098 + }, + { + "gene": "AKT1", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 81, + "pct": 1.5 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 8, + "pct": 0.3 + } + ], + "q": 2.9547956089816697e-8 + } + ], + "otherAltered": 12, + "notProfiled": [ + "EIF4EBP1", + "AKT1S1", + "DEPDC5", + "DEPTOR", + "MLST8", + "NPRL2", + "NPRL3", + "PDK1", + "RPS6", + "RPS6KB1" + ], + "q": 1.4462937483147768e-124 + }, + { + "name": "TP53", + "source": "Sanchez-Vega 2018", + "genes": 6, + "profiledGenes": 5, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 4268, + "pct": 77 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 2129, + "pct": 68.5 + } + ], + "p": 8.772026952886191e-18, + "top": [ + { + "gene": "TP53", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 4064, + "pct": 73.3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 2068, + "pct": 66.5 + } + ], + "q": 1.3568235161012179e-10 + }, + { + "gene": "ATM", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 287, + "pct": 5.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 56, + "pct": 1.8 + } + ], + "q": 1.9565231030894814e-15 + }, + { + "gene": "MDM2", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 7, + "pct": 0.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 33, + "pct": 1.1 + } + ], + "q": 5.98899893763258e-9 + }, + { + "gene": "CHEK2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 42, + "pct": 0.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 6, + "pct": 0.2 + } + ], + "q": 0.0008755336584046769 + }, + { + "gene": "MDM4", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 2, + "pct": 0 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 5, + "pct": 0.2 + } + ], + "q": 0.15497444419975082 + } + ], + "otherAltered": 0, + "notProfiled": [ + "RPS6KA3" + ], + "q": 1.2531467075551702e-17 + }, + { + "name": "Cell cycle", + "source": "Sanchez-Vega 2018", + "genes": 15, + "profiledGenes": 13, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 489, + "pct": 8.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 1216, + "pct": 39.1 + } + ], + "p": 5.19604894684864e-245, + "top": [ + { + "gene": "CDKN2A", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 113, + "pct": 2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 1020, + "pct": 32.8 + } + ], + "q": 0 + }, + { + "gene": "CDKN2B", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 56, + "pct": 1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 422, + "pct": 13.6 + } + ], + "q": 2.854976940729066e-131 + }, + { + "gene": "RB1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 74, + "pct": 1.3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 77, + "pct": 2.5 + } + ], + "q": 0.00033381445051732216 + }, + { + "gene": "CCND2", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 124, + "pct": 2.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 18, + "pct": 0.6 + } + ], + "q": 1.6606086001959881e-9 + }, + { + "gene": "CCNE1", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 33, + "pct": 0.6 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 60, + "pct": 1.9 + } + ], + "q": 7.053667557890331e-8 + }, + { + "gene": "CDK6", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 10, + "pct": 0.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 41, + "pct": 1.3 + } + ], + "q": 3.600284835141912e-10 + } + ], + "otherAltered": 6, + "notProfiled": [ + "CDK2", + "E2F1" + ], + "q": 2.59802447342432e-244 + }, + { + "name": "MYC", + "source": "Sanchez-Vega 2018", + "genes": 13, + "profiledGenes": 5, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 451, + "pct": 8.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 156, + "pct": 5 + } + ], + "p": 2.905584066517031e-8, + "top": [ + { + "gene": "MYC", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 265, + "pct": 4.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 120, + "pct": 3.9 + } + ], + "q": 0.07900457825400134 + }, + { + "gene": "MGA", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5350, + "altered": 153, + "pct": 2.9 + }, + { + "cohort": "Pancreatic", + "profiled": 3076, + "altered": 22, + "pct": 0.7 + } + ], + "q": 4.50739167394809e-12 + }, + { + "gene": "MAX", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 22, + "pct": 0.4 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 6, + "pct": 0.2 + } + ], + "q": 0.1690748582290846 + }, + { + "gene": "MYCL", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 16, + "pct": 0.3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 8, + "pct": 0.3 + } + ], + "q": 1 + }, + { + "gene": "MYCN", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 4, + "pct": 0.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 2, + "pct": 0.1 + } + ], + "q": 1 + } + ], + "otherAltered": 0, + "notProfiled": [ + "MLX", + "MLXIP", + "MLXIPL", + "MNT", + "MXD1", + "MXD3", + "MXD4", + "MXI1" + ], + "q": 3.6319800831462886e-8 + }, + { + "name": "WNT", + "source": "Sanchez-Vega 2018", + "genes": 68, + "profiledGenes": 12, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 4536, + "pct": 81.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 243, + "pct": 7.8 + } + ], + "p": 0, + "top": [ + { + "gene": "APC", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 4050, + "pct": 73.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 30, + "pct": 1 + } + ], + "q": 0 + }, + { + "gene": "TCF7L2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5350, + "altered": 650, + "pct": 12.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3076, + "altered": 5, + "pct": 0.2 + } + ], + "q": 4.49559446623935e-124 + }, + { + "gene": "AMER1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 335, + "pct": 6 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 27, + "pct": 0.9 + } + ], + "q": 9.312200902062702e-37 + }, + { + "gene": "RNF43", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 284, + "pct": 5.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 124, + "pct": 4 + } + ], + "q": 0.029839748389764775 + }, + { + "gene": "AXIN2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 212, + "pct": 3.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 17, + "pct": 0.5 + } + ], + "q": 2.5792956149222336e-23 + }, + { + "gene": "ZNRF3", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 1798, + "altered": 68, + "pct": 3.8 + }, + { + "cohort": "Pancreatic", + "profiled": 1100, + "altered": 3, + "pct": 0.3 + } + ], + "q": 1.1129560807818555e-10 + } + ], + "otherAltered": 4, + "notProfiled": [ + "CHD8", + "LEF1", + "LGR4", + "LRP5", + "NDP", + "PORCN", + "RSPO1", + "SFRP1", + "SFRP2", + "SFRP4", + "SFRP5", + "SOST", + "TCF7L1", + "TLE1", + "TLE2", + "TLE3", + "TLE4", + "WIF1", + "DVL1", + "DVL2", + { + "…": "36 more", + "sha256": "e206ba224e3aee31" + } + ], + "q": 0 + }, + { + "name": "NOTCH", + "source": "Sanchez-Vega 2018", + "genes": 71, + "profiledGenes": 14, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 1215, + "pct": 21.9 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 108, + "pct": 3.5 + } + ], + "p": 2.6198371106471583e-139, + "top": [ + { + "gene": "FBXW7", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 750, + "pct": 13.5 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 31, + "pct": 1 + } + ], + "q": 6.244824193465761e-110 + }, + { + "gene": "CREBBP", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 166, + "pct": 3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 17, + "pct": 0.5 + } + ], + "q": 6.610313665059981e-16 + }, + { + "gene": "NCOR1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 149, + "pct": 2.7 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 5, + "pct": 0.2 + } + ], + "q": 3.7305309601101838e-22 + }, + { + "gene": "NOTCH3", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 128, + "pct": 2.3 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 7, + "pct": 0.2 + } + ], + "q": 1.7266539203953907e-16 + }, + { + "gene": "EP300", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 122, + "pct": 2.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 12, + "pct": 0.4 + } + ], + "q": 2.9399368751270945e-12 + }, + { + "gene": "SPEN", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 98, + "pct": 1.8 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 5, + "pct": 0.2 + } + ], + "q": 3.9508492708599596e-13 + } + ], + "otherAltered": 4, + "notProfiled": [ + "ARRDC1", + "CNTN6", + "HES1", + "HES2", + "HES3", + "HES4", + "HES5", + "HEY1", + "HEY2", + "HEYL", + "KAT2B", + "NOV", + "NRARP", + "PSEN2", + "LFNG", + "ITCH", + "NCSTN", + "JAG1", + "APH1A", + "FHL1", + { + "…": "37 more", + "sha256": "d68e27faa10564d1" + } + ], + "q": 8.732790368823861e-139 + }, + { + "name": "Hippo", + "source": "Sanchez-Vega 2018", + "genes": 38, + "profiledGenes": 6, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 260, + "pct": 4.7 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 40, + "pct": 1.3 + } + ], + "p": 6.015225330934694e-19, + "top": [ + { + "gene": "FAT1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 177, + "pct": 3.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 16, + "pct": 0.5 + } + ], + "q": 2.37601062548213e-18 + }, + { + "gene": "LATS1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 49, + "pct": 0.9 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 10, + "pct": 0.3 + } + ], + "q": 0.0033279240530356964 + }, + { + "gene": "LATS2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 34, + "pct": 0.6 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 5, + "pct": 0.2 + } + ], + "q": 0.0041179603472771 + }, + { + "gene": "NF2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 9, + "pct": 0.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 9, + "pct": 0.3 + } + ], + "q": 0.3109147064391383 + }, + { + "gene": "YAP1", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 10, + "pct": 0.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 1, + "pct": 0 + } + ], + "q": 0.15986587736599803 + } + ], + "otherAltered": 0, + "notProfiled": [ + "STK4", + "STK3", + "SAV1", + "MOB1A", + "MOB1B", + "TEAD1", + "TEAD2", + "TEAD3", + "TEAD4", + "PTPN14", + "WWC1", + "TAOK1", + "TAOK2", + "TAOK3", + "CRB1", + "CRB2", + "CRB3", + "LLGL1", + "LLGL2", + "HMCN1", + { + "…": "12 more", + "sha256": "fbb5c6a2c9e6c94a" + } + ], + "q": 1.0025375551557823e-18 + }, + { + "name": "TGF-β", + "source": "Sanchez-Vega 2018", + "genes": 7, + "profiledGenes": 5, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 1194, + "pct": 21.5 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 732, + "pct": 23.5 + } + ], + "p": 0.03335684499535692, + "top": [ + { + "gene": "SMAD4", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 859, + "pct": 15.5 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 655, + "pct": 21.1 + } + ], + "q": 3.7270880898502765e-10 + }, + { + "gene": "SMAD2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 225, + "pct": 4.1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 11, + "pct": 0.4 + } + ], + "q": 4.060527821165915e-30 + }, + { + "gene": "SMAD3", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 180, + "pct": 3.2 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 31, + "pct": 1 + } + ], + "q": 2.6199648767682504e-11 + }, + { + "gene": "TGFBR1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 48, + "pct": 0.9 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 42, + "pct": 1.4 + } + ], + "q": 0.05793031858365166 + }, + { + "gene": "TGFBR2", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 22, + "pct": 0.4 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 22, + "pct": 0.7 + } + ], + "q": 0.0908517357789052 + } + ], + "otherAltered": 0, + "notProfiled": [ + "ACVR2A", + "ACVR1B" + ], + "q": 0.037063161105952126 + }, + { + "name": "NRF2", + "source": "Sanchez-Vega 2018", + "genes": 3, + "profiledGenes": 3, + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 54, + "pct": 1 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 24, + "pct": 0.8 + } + ], + "p": 0.4067674356699012, + "top": [ + { + "gene": "KEAP1", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 33, + "pct": 0.6 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 19, + "pct": 0.6 + } + ], + "q": 1 + }, + { + "gene": "CUL3", + "role": "TSG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 20, + "pct": 0.4 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 1, + "pct": 0 + } + ], + "q": 0.004058675700131532 + }, + { + "gene": "NFE2L2", + "role": "OG", + "cells": [ + { + "cohort": "Colorectal", + "profiled": 5543, + "altered": 1, + "pct": 0 + }, + { + "cohort": "Pancreatic", + "profiled": 3109, + "altered": 4, + "pct": 0.1 + } + ], + "q": 0.0908517357789052 + } + ], + "otherAltered": 0, + "notProfiled": [], + "q": 0.4067674356699012 + } + ] + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Share of patients with an OncoKB driver (v7.5) in at least one member gene — drivers only, as Sanchez-Vega et al. counted curated oncogenic events. A pathway's denominator is the patients profiled for at least one of its genes, so a panel that covers few members makes a pathway look rarer than a genome-wide assay would; each member gene's own % is over the patients profiled for THAT gene. 206 member-gene slots were on no participating panel and are listed as not profiled rather than counted as unaltered. Pathway membership is the paper's Table S3; a gene's pathway role (oncogene / tumour suppressor) is not used in the count. Two-sided Fisher tests; q is Benjamini–Hochberg across the pathways drawn, and separately across every member gene tested.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients altered per pathway and per gene", + "detail": "The geneCounts and pathways:sets queries above. Per pathway: patients profiled for at least one member gene (the denominator) and of those, patients with an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in at least one member. Per member gene: the same over the patients profiled for that gene. Counts only.", + "scope": "Colorectal · msk_chord_2024", + "rowsIn": 5543, + "params": [ + [ + "pathways / sets", + "RTK-RAS (85), PI3K (29), TP53 (6), Cell cycle (15), MYC (13), WNT (68), NOTCH (71), Hippo (38), TGF-β (7), NRF2 (3)" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients altered per pathway and per gene", + "detail": "The geneCounts and pathways:sets queries above. Per pathway: patients profiled for at least one member gene (the denominator) and of those, patients with an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in at least one member. Per member gene: the same over the patients profiled for that gene. Counts only.", + "scope": "Pancreatic · msk_chord_2024", + "rowsIn": 3109, + "params": [ + [ + "pathways / sets", + "RTK-RAS (85), PI3K (29), TP53 (6), Cell cycle (15), MYC (13), WNT (68), NOTCH (71), Hippo (38), TGF-β (7), NRF2 (3)" + ] + ] + }, + { + "kind": "statistic", + "title": "Fisher's exact test per pathway and per member gene", + "detail": "Two-sided, altered vs not among the profiled, between the two cohorts." + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg", + "detail": "Across the pathways drawn, and separately across every member gene tested, each gene once even when it sits in two pathways." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "pathways:pathway:RTK-RAS:p": { + "v": 6.382707592331983e-63 + }, + "pathways:pathway:RTK-RAS:q": { + "v": 1.2765415184663967e-62 + }, + "pathways:pathway:PI3K:p": { + "v": 5.785174993259107e-125 + }, + "pathways:pathway:PI3K:q": { + "v": 1.4462937483147768e-124 + }, + "pathways:pathway:TP53:p": { + "v": 8.772026952886191e-18 + }, + "pathways:pathway:TP53:q": { + "v": 1.2531467075551702e-17 + }, + "pathways:pathway:Cell cycle:p": { + "v": 5.19604894684864e-245 + }, + "pathways:pathway:Cell cycle:q": { + "v": 2.59802447342432e-244 + }, + "pathways:pathway:MYC:p": { + "v": 2.905584066517031e-8 + }, + "pathways:pathway:MYC:q": { + "v": 3.6319800831462886e-8 + }, + "pathways:pathway:WNT:p": { + "v": 0 + }, + "pathways:pathway:WNT:q": { + "v": 0 + }, + "pathways:pathway:NOTCH:p": { + "v": 2.6198371106471583e-139 + }, + "pathways:pathway:NOTCH:q": { + "v": 8.732790368823861e-139 + }, + "pathways:pathway:Hippo:p": { + "v": 6.015225330934694e-19 + }, + "pathways:pathway:Hippo:q": { + "v": 1.0025375551557823e-18 + }, + "pathways:pathway:TGF-β:p": { + "v": 0.03335684499535692 + }, + "pathways:pathway:TGF-β:q": { + "v": 0.037063161105952126 + }, + "pathways:pathway:NRF2:p": { + "v": 0.4067674356699012 + }, + "pathways:pathway:NRF2:q": { + "v": 0.4067674356699012 + }, + "…": { + "more": 53, + "sha256": "dcbde1c378cc0869" + } + } + } + } + ] +} diff --git a/test/snapshots/pathways.sql b/test/snapshots/pathways.sql new file mode 100644 index 0000000..1ab78a1 --- /dev/null +++ b/test/snapshots/pathways.sql @@ -0,0 +1,203 @@ +-- cohort Colorectal +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer')))) + +-- cohort Pancreatic +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer')))) + +-- view 0 pathways: geneCounts · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene + +-- view 0 pathways: geneCounts · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer'))))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene + +-- view 0 pathways: pathways:sets:Colorectal · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Colorectal Cancer'))))), +members AS (SELECT tupleElement(m, 1) AS set_name, tupleElement(m, 2) AS gene FROM (SELECT arrayJoin([('RTK-RAS','ABL1'),('RTK-RAS','EGFR'),('RTK-RAS','ERBB2'),('RTK-RAS','ERBB3'),('RTK-RAS','ERBB4'),('RTK-RAS','PDGFRA'),('RTK-RAS','PDGFRB'),('RTK-RAS','MET'),('RTK-RAS','FGFR1'),('RTK-RAS','FGFR2'),('RTK-RAS','FGFR3'),('RTK-RAS','FGFR4'),('RTK-RAS','FLT3'),('RTK-RAS','ALK'),('RTK-RAS','RET'),('RTK-RAS','ROS1'),('RTK-RAS','KIT'),('RTK-RAS','IGF1R'),('RTK-RAS','NTRK1'),('RTK-RAS','NTRK2'),('RTK-RAS','NTRK3'),('RTK-RAS','SOS1'),('RTK-RAS','GRB2'),('RTK-RAS','PTPN11'),('RTK-RAS','KRAS'),('RTK-RAS','HRAS'),('RTK-RAS','NRAS'),('RTK-RAS','RIT1'),('RTK-RAS','ARAF'),('RTK-RAS','BRAF'),('RTK-RAS','RAF1'),('RTK-RAS','RAC1'),('RTK-RAS','MAP2K1'),('RTK-RAS','MAP2K2'),('RTK-RAS','MAPK1'),('RTK-RAS','NF1'),('RTK-RAS','RASA1'),('RTK-RAS','CBL'),('RTK-RAS','ERRFI1'),('RTK-RAS','CBLB'),('RTK-RAS','CBLC'),('RTK-RAS','INSR'),('RTK-RAS','INSRR'),('RTK-RAS','IRS1'),('RTK-RAS','SOS2'),('RTK-RAS','SHC1'),('RTK-RAS','SHC2'),('RTK-RAS','SHC3'),('RTK-RAS','SHC4'),('RTK-RAS','RASGRP1'),('RTK-RAS','RASGRP2'),('RTK-RAS','RASGRP3'),('RTK-RAS','RASGRP4'),('RTK-RAS','RAPGEF1'),('RTK-RAS','RAPGEF2'),('RTK-RAS','RASGRF1'),('RTK-RAS','RASGRF2'),('RTK-RAS','FNTA'),('RTK-RAS','FNTB'),('RTK-RAS','RCE1'),('RTK-RAS','ICMT'),('RTK-RAS','MRAS'),('RTK-RAS','PLXNB1'),('RTK-RAS','MAPK3'),('RTK-RAS','ARHGAP35'),('RTK-RAS','RASA2'),('RTK-RAS','RASA3'),('RTK-RAS','RASAL1'),('RTK-RAS','RASAL2'),('RTK-RAS','RASAL3'),('RTK-RAS','SPRED1'),('RTK-RAS','SPRED2'),('RTK-RAS','SPRED3'),('RTK-RAS','DAB2IP'),('RTK-RAS','SHOC2'),('RTK-RAS','PPP1CA'),('RTK-RAS','SCRIB'),('RTK-RAS','PIN1'),('RTK-RAS','KSR1'),('RTK-RAS','KSR2'),('RTK-RAS','PEBP1'),('RTK-RAS','ERF'),('RTK-RAS','PEA15'),('RTK-RAS','JAK2'),('RTK-RAS','IRS2'),('PI3K','EIF4EBP1'),('PI3K','AKT1'),('PI3K','AKT2'),('PI3K','AKT3'),('PI3K','AKT1S1'),('PI3K','DEPDC5'),('PI3K','DEPTOR'),('PI3K','INPP4B'),('PI3K','MAPKAP1'),('PI3K','MLST8'),('PI3K','MTOR'),('PI3K','NPRL2'),('PI3K','NPRL3'),('PI3K','PDK1'),('PI3K','PIK3CA'),('PI3K','PIK3CB'),('PI3K','PIK3R1'),('PI3K','PIK3R2'),('PI3K','PIK3R3'),('PI3K','PPP2R1A'),('PI3K','PTEN'),('PI3K','RHEB'),('PI3K','RICTOR'),('PI3K','RPTOR'),('PI3K','RPS6'),('PI3K','RPS6KB1'),('PI3K','STK11'),('PI3K','TSC1'),('PI3K','TSC2'),('TP53','TP53'),('TP53','MDM2'),('TP53','MDM4'),('TP53','ATM'),('TP53','CHEK2'),('TP53','RPS6KA3'),('Cell cycle','CDKN1A'),('Cell cycle','CDKN1B'),('Cell cycle','CDKN2A'),('Cell cycle','CDKN2B'),('Cell cycle','CDKN2C'),('Cell cycle','CCND1'),('Cell cycle','CCND2'),('Cell cycle','CCND3'),('Cell cycle','CCNE1'),('Cell cycle','CDK2'),('Cell cycle','CDK4'),('Cell cycle','CDK6'),('Cell cycle','RB1'),('Cell cycle','E2F1'),('Cell cycle','E2F3'),('MYC','MAX'),('MYC','MGA'),('MYC','MLX'),('MYC','MLXIP'),('MYC','MLXIPL'),('MYC','MNT'),('MYC','MXD1'),('MYC','MXD3'),('MYC','MXD4'),('MYC','MXI1'),('MYC','MYC'),('MYC','MYCL'),('MYC','MYCN'),('WNT','CHD8'),('WNT','LEF1'),('WNT','LGR4'),('WNT','LGR5'),('WNT','LRP5'),('WNT','LRP6'),('WNT','LZTR1'),('WNT','NDP'),('WNT','PORCN'),('WNT','RSPO1'),('WNT','SFRP1'),('WNT','SFRP2'),('WNT','SFRP4'),('WNT','SFRP5'),('WNT','SOST'),('WNT','TCF7L1'),('WNT','TLE1'),('WNT','TLE2'),('WNT','TLE3'),('WNT','TLE4'),('WNT','WIF1'),('WNT','ZNRF3'),('WNT','CTNNB1'),('WNT','DVL1'),('WNT','DVL2'),('WNT','DVL3'),('WNT','FRAT1'),('WNT','FRAT2'),('WNT','FZD1'),('WNT','FZD10'),('WNT','FZD2'),('WNT','FZD3'),('WNT','FZD4'),('WNT','FZD5'),('WNT','FZD6'),('WNT','FZD7'),('WNT','FZD8'),('WNT','FZD9'),('WNT','WNT1'),('WNT','WNT10A'),('WNT','WNT10B'),('WNT','WNT11'),('WNT','WNT16'),('WNT','WNT2'),('WNT','WNT3A'),('WNT','WNT4'),('WNT','WNT5A'),('WNT','WNT5B'),('WNT','WNT6'),('WNT','WNT7A'),('WNT','WNT7B'),('WNT','WNT8A'),('WNT','WNT8B'),('WNT','WNT9A'),('WNT','WNT9B'),('WNT','AMER1'),('WNT','APC'),('WNT','AXIN1'),('WNT','AXIN2'),('WNT','DKK1'),('WNT','DKK2'),('WNT','DKK3'),('WNT','DKK4'),('WNT','GSK3B'),('WNT','RNF43'),('WNT','TCF7'),('WNT','TCF7L2'),('WNT','CHD4'),('NOTCH','ARRDC1'),('NOTCH','CNTN6'),('NOTCH','CREBBP'),('NOTCH','EP300'),('NOTCH','HES1'),('NOTCH','HES2'),('NOTCH','HES3'),('NOTCH','HES4'),('NOTCH','HES5'),('NOTCH','HEY1'),('NOTCH','HEY2'),('NOTCH','HEYL'),('NOTCH','KAT2B'),('NOTCH','KDM5A'),('NOTCH','NOTCH1'),('NOTCH','NOTCH2'),('NOTCH','NOTCH3'),('NOTCH','NOTCH4'),('NOTCH','NOV'),('NOTCH','NRARP'),('NOTCH','PSEN2'),('NOTCH','LFNG'),('NOTCH','ITCH'),('NOTCH','NCSTN'),('NOTCH','SPEN'),('NOTCH','JAG1'),('NOTCH','APH1A'),('NOTCH','FBXW7'),('NOTCH','FHL1'),('NOTCH','THBS2'),('NOTCH','HDAC2'),('NOTCH','MFAP2'),('NOTCH','CUL1'),('NOTCH','RFNG'),('NOTCH','NCOR1'),('NOTCH','NCOR2'),('NOTCH','MFAP5'),('NOTCH','HDAC1'),('NOTCH','NUMB'),('NOTCH','JAG2'),('NOTCH','MAML3'),('NOTCH','MFNG'),('NOTCH','CIR1'),('NOTCH','CNTN1'),('NOTCH','MAML1'),('NOTCH','MAML2'),('NOTCH','NUMBL'),('NOTCH','PSEN1'),('NOTCH','PSENEN'),('NOTCH','RBPJ'),('NOTCH','RBPJL'),('NOTCH','RBX1'),('NOTCH','SAP30'),('NOTCH','SKP1'),('NOTCH','SNW1'),('NOTCH','CTBP1'),('NOTCH','CTBP2'),('NOTCH','ADAM10'),('NOTCH','APH1B'),('NOTCH','ADAM17'),('NOTCH','DLK1'),('NOTCH','DLL1'),('NOTCH','DLL3'),('NOTCH','DLL4'),('NOTCH','DNER'),('NOTCH','DTX1'),('NOTCH','DTX2'),('NOTCH','DTX3'),('NOTCH','DTX3L'),('NOTCH','DTX4'),('NOTCH','EGFL7'),('Hippo','STK4'),('Hippo','STK3'),('Hippo','SAV1'),('Hippo','LATS1'),('Hippo','LATS2'),('Hippo','MOB1A'),('Hippo','MOB1B'),('Hippo','YAP1'),('Hippo','WWTR1'),('Hippo','TEAD1'),('Hippo','TEAD2'),('Hippo','TEAD3'),('Hippo','TEAD4'),('Hippo','PTPN14'),('Hippo','NF2'),('Hippo','WWC1'),('Hippo','TAOK1'),('Hippo','TAOK2'),('Hippo','TAOK3'),('Hippo','CRB1'),('Hippo','CRB2'),('Hippo','CRB3'),('Hippo','LLGL1'),('Hippo','LLGL2'),('Hippo','HMCN1'),('Hippo','SCRIB'),('Hippo','HIPK2'),('Hippo','FAT1'),('Hippo','FAT2'),('Hippo','FAT3'),('Hippo','FAT4'),('Hippo','DCHS1'),('Hippo','DCHS2'),('Hippo','CSNK1E'),('Hippo','CSNK1D'),('Hippo','AJUBA'),('Hippo','LIMD1'),('Hippo','WTIP'),('TGF-β','TGFBR1'),('TGF-β','TGFBR2'),('TGF-β','ACVR2A'),('TGF-β','ACVR1B'),('TGF-β','SMAD2'),('TGF-β','SMAD3'),('TGF-β','SMAD4'),('NRF2','NFE2L2'),('NRF2','KEAP1'),('NRF2','CUL3')]) AS m)), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +per AS ( + SELECT members.set_name AS set_name, x.pid AS pid, max(x.is_alt) AS is_alt, max(x.is_drv) AS is_drv + FROM ( + SELECT gene, pid, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, 0 AS is_alt, 0 AS is_drv FROM covered + ) x + INNER JOIN members ON members.gene = x.gene + GROUP BY set_name, pid +) +SELECT set_name, uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM per GROUP BY set_name + +-- view 0 pathways: pathways:sets:Pancreatic · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer'))))), +members AS (SELECT tupleElement(m, 1) AS set_name, tupleElement(m, 2) AS gene FROM (SELECT arrayJoin([('RTK-RAS','ABL1'),('RTK-RAS','EGFR'),('RTK-RAS','ERBB2'),('RTK-RAS','ERBB3'),('RTK-RAS','ERBB4'),('RTK-RAS','PDGFRA'),('RTK-RAS','PDGFRB'),('RTK-RAS','MET'),('RTK-RAS','FGFR1'),('RTK-RAS','FGFR2'),('RTK-RAS','FGFR3'),('RTK-RAS','FGFR4'),('RTK-RAS','FLT3'),('RTK-RAS','ALK'),('RTK-RAS','RET'),('RTK-RAS','ROS1'),('RTK-RAS','KIT'),('RTK-RAS','IGF1R'),('RTK-RAS','NTRK1'),('RTK-RAS','NTRK2'),('RTK-RAS','NTRK3'),('RTK-RAS','SOS1'),('RTK-RAS','GRB2'),('RTK-RAS','PTPN11'),('RTK-RAS','KRAS'),('RTK-RAS','HRAS'),('RTK-RAS','NRAS'),('RTK-RAS','RIT1'),('RTK-RAS','ARAF'),('RTK-RAS','BRAF'),('RTK-RAS','RAF1'),('RTK-RAS','RAC1'),('RTK-RAS','MAP2K1'),('RTK-RAS','MAP2K2'),('RTK-RAS','MAPK1'),('RTK-RAS','NF1'),('RTK-RAS','RASA1'),('RTK-RAS','CBL'),('RTK-RAS','ERRFI1'),('RTK-RAS','CBLB'),('RTK-RAS','CBLC'),('RTK-RAS','INSR'),('RTK-RAS','INSRR'),('RTK-RAS','IRS1'),('RTK-RAS','SOS2'),('RTK-RAS','SHC1'),('RTK-RAS','SHC2'),('RTK-RAS','SHC3'),('RTK-RAS','SHC4'),('RTK-RAS','RASGRP1'),('RTK-RAS','RASGRP2'),('RTK-RAS','RASGRP3'),('RTK-RAS','RASGRP4'),('RTK-RAS','RAPGEF1'),('RTK-RAS','RAPGEF2'),('RTK-RAS','RASGRF1'),('RTK-RAS','RASGRF2'),('RTK-RAS','FNTA'),('RTK-RAS','FNTB'),('RTK-RAS','RCE1'),('RTK-RAS','ICMT'),('RTK-RAS','MRAS'),('RTK-RAS','PLXNB1'),('RTK-RAS','MAPK3'),('RTK-RAS','ARHGAP35'),('RTK-RAS','RASA2'),('RTK-RAS','RASA3'),('RTK-RAS','RASAL1'),('RTK-RAS','RASAL2'),('RTK-RAS','RASAL3'),('RTK-RAS','SPRED1'),('RTK-RAS','SPRED2'),('RTK-RAS','SPRED3'),('RTK-RAS','DAB2IP'),('RTK-RAS','SHOC2'),('RTK-RAS','PPP1CA'),('RTK-RAS','SCRIB'),('RTK-RAS','PIN1'),('RTK-RAS','KSR1'),('RTK-RAS','KSR2'),('RTK-RAS','PEBP1'),('RTK-RAS','ERF'),('RTK-RAS','PEA15'),('RTK-RAS','JAK2'),('RTK-RAS','IRS2'),('PI3K','EIF4EBP1'),('PI3K','AKT1'),('PI3K','AKT2'),('PI3K','AKT3'),('PI3K','AKT1S1'),('PI3K','DEPDC5'),('PI3K','DEPTOR'),('PI3K','INPP4B'),('PI3K','MAPKAP1'),('PI3K','MLST8'),('PI3K','MTOR'),('PI3K','NPRL2'),('PI3K','NPRL3'),('PI3K','PDK1'),('PI3K','PIK3CA'),('PI3K','PIK3CB'),('PI3K','PIK3R1'),('PI3K','PIK3R2'),('PI3K','PIK3R3'),('PI3K','PPP2R1A'),('PI3K','PTEN'),('PI3K','RHEB'),('PI3K','RICTOR'),('PI3K','RPTOR'),('PI3K','RPS6'),('PI3K','RPS6KB1'),('PI3K','STK11'),('PI3K','TSC1'),('PI3K','TSC2'),('TP53','TP53'),('TP53','MDM2'),('TP53','MDM4'),('TP53','ATM'),('TP53','CHEK2'),('TP53','RPS6KA3'),('Cell cycle','CDKN1A'),('Cell cycle','CDKN1B'),('Cell cycle','CDKN2A'),('Cell cycle','CDKN2B'),('Cell cycle','CDKN2C'),('Cell cycle','CCND1'),('Cell cycle','CCND2'),('Cell cycle','CCND3'),('Cell cycle','CCNE1'),('Cell cycle','CDK2'),('Cell cycle','CDK4'),('Cell cycle','CDK6'),('Cell cycle','RB1'),('Cell cycle','E2F1'),('Cell cycle','E2F3'),('MYC','MAX'),('MYC','MGA'),('MYC','MLX'),('MYC','MLXIP'),('MYC','MLXIPL'),('MYC','MNT'),('MYC','MXD1'),('MYC','MXD3'),('MYC','MXD4'),('MYC','MXI1'),('MYC','MYC'),('MYC','MYCL'),('MYC','MYCN'),('WNT','CHD8'),('WNT','LEF1'),('WNT','LGR4'),('WNT','LGR5'),('WNT','LRP5'),('WNT','LRP6'),('WNT','LZTR1'),('WNT','NDP'),('WNT','PORCN'),('WNT','RSPO1'),('WNT','SFRP1'),('WNT','SFRP2'),('WNT','SFRP4'),('WNT','SFRP5'),('WNT','SOST'),('WNT','TCF7L1'),('WNT','TLE1'),('WNT','TLE2'),('WNT','TLE3'),('WNT','TLE4'),('WNT','WIF1'),('WNT','ZNRF3'),('WNT','CTNNB1'),('WNT','DVL1'),('WNT','DVL2'),('WNT','DVL3'),('WNT','FRAT1'),('WNT','FRAT2'),('WNT','FZD1'),('WNT','FZD10'),('WNT','FZD2'),('WNT','FZD3'),('WNT','FZD4'),('WNT','FZD5'),('WNT','FZD6'),('WNT','FZD7'),('WNT','FZD8'),('WNT','FZD9'),('WNT','WNT1'),('WNT','WNT10A'),('WNT','WNT10B'),('WNT','WNT11'),('WNT','WNT16'),('WNT','WNT2'),('WNT','WNT3A'),('WNT','WNT4'),('WNT','WNT5A'),('WNT','WNT5B'),('WNT','WNT6'),('WNT','WNT7A'),('WNT','WNT7B'),('WNT','WNT8A'),('WNT','WNT8B'),('WNT','WNT9A'),('WNT','WNT9B'),('WNT','AMER1'),('WNT','APC'),('WNT','AXIN1'),('WNT','AXIN2'),('WNT','DKK1'),('WNT','DKK2'),('WNT','DKK3'),('WNT','DKK4'),('WNT','GSK3B'),('WNT','RNF43'),('WNT','TCF7'),('WNT','TCF7L2'),('WNT','CHD4'),('NOTCH','ARRDC1'),('NOTCH','CNTN6'),('NOTCH','CREBBP'),('NOTCH','EP300'),('NOTCH','HES1'),('NOTCH','HES2'),('NOTCH','HES3'),('NOTCH','HES4'),('NOTCH','HES5'),('NOTCH','HEY1'),('NOTCH','HEY2'),('NOTCH','HEYL'),('NOTCH','KAT2B'),('NOTCH','KDM5A'),('NOTCH','NOTCH1'),('NOTCH','NOTCH2'),('NOTCH','NOTCH3'),('NOTCH','NOTCH4'),('NOTCH','NOV'),('NOTCH','NRARP'),('NOTCH','PSEN2'),('NOTCH','LFNG'),('NOTCH','ITCH'),('NOTCH','NCSTN'),('NOTCH','SPEN'),('NOTCH','JAG1'),('NOTCH','APH1A'),('NOTCH','FBXW7'),('NOTCH','FHL1'),('NOTCH','THBS2'),('NOTCH','HDAC2'),('NOTCH','MFAP2'),('NOTCH','CUL1'),('NOTCH','RFNG'),('NOTCH','NCOR1'),('NOTCH','NCOR2'),('NOTCH','MFAP5'),('NOTCH','HDAC1'),('NOTCH','NUMB'),('NOTCH','JAG2'),('NOTCH','MAML3'),('NOTCH','MFNG'),('NOTCH','CIR1'),('NOTCH','CNTN1'),('NOTCH','MAML1'),('NOTCH','MAML2'),('NOTCH','NUMBL'),('NOTCH','PSEN1'),('NOTCH','PSENEN'),('NOTCH','RBPJ'),('NOTCH','RBPJL'),('NOTCH','RBX1'),('NOTCH','SAP30'),('NOTCH','SKP1'),('NOTCH','SNW1'),('NOTCH','CTBP1'),('NOTCH','CTBP2'),('NOTCH','ADAM10'),('NOTCH','APH1B'),('NOTCH','ADAM17'),('NOTCH','DLK1'),('NOTCH','DLL1'),('NOTCH','DLL3'),('NOTCH','DLL4'),('NOTCH','DNER'),('NOTCH','DTX1'),('NOTCH','DTX2'),('NOTCH','DTX3'),('NOTCH','DTX3L'),('NOTCH','DTX4'),('NOTCH','EGFL7'),('Hippo','STK4'),('Hippo','STK3'),('Hippo','SAV1'),('Hippo','LATS1'),('Hippo','LATS2'),('Hippo','MOB1A'),('Hippo','MOB1B'),('Hippo','YAP1'),('Hippo','WWTR1'),('Hippo','TEAD1'),('Hippo','TEAD2'),('Hippo','TEAD3'),('Hippo','TEAD4'),('Hippo','PTPN14'),('Hippo','NF2'),('Hippo','WWC1'),('Hippo','TAOK1'),('Hippo','TAOK2'),('Hippo','TAOK3'),('Hippo','CRB1'),('Hippo','CRB2'),('Hippo','CRB3'),('Hippo','LLGL1'),('Hippo','LLGL2'),('Hippo','HMCN1'),('Hippo','SCRIB'),('Hippo','HIPK2'),('Hippo','FAT1'),('Hippo','FAT2'),('Hippo','FAT3'),('Hippo','FAT4'),('Hippo','DCHS1'),('Hippo','DCHS2'),('Hippo','CSNK1E'),('Hippo','CSNK1D'),('Hippo','AJUBA'),('Hippo','LIMD1'),('Hippo','WTIP'),('TGF-β','TGFBR1'),('TGF-β','TGFBR2'),('TGF-β','ACVR2A'),('TGF-β','ACVR1B'),('TGF-β','SMAD2'),('TGF-β','SMAD3'),('TGF-β','SMAD4'),('NRF2','NFE2L2'),('NRF2','KEAP1'),('NRF2','CUL3')]) AS m)), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('ABL1','EGFR','ERBB2','ERBB3','ERBB4','PDGFRA','PDGFRB','MET','FGFR1','FGFR2','FGFR3','FGFR4','FLT3','ALK','RET','ROS1','KIT','IGF1R','NTRK1','NTRK2','NTRK3','SOS1','GRB2','PTPN11','KRAS','HRAS','NRAS','RIT1','ARAF','BRAF','RAF1','RAC1','MAP2K1','MAP2K2','MAPK1','NF1','RASA1','CBL','ERRFI1','CBLB','CBLC','INSR','INSRR','IRS1','SOS2','SHC1','SHC2','SHC3','SHC4','RASGRP1','RASGRP2','RASGRP3','RASGRP4','RAPGEF1','RAPGEF2','RASGRF1','RASGRF2','FNTA','FNTB','RCE1','ICMT','MRAS','PLXNB1','MAPK3','ARHGAP35','RASA2','RASA3','RASAL1','RASAL2','RASAL3','SPRED1','SPRED2','SPRED3','DAB2IP','SHOC2','PPP1CA','SCRIB','PIN1','KSR1','KSR2','PEBP1','ERF','PEA15','JAK2','IRS2','EIF4EBP1','AKT1','AKT2','AKT3','AKT1S1','DEPDC5','DEPTOR','INPP4B','MAPKAP1','MLST8','MTOR','NPRL2','NPRL3','PDK1','PIK3CA','PIK3CB','PIK3R1','PIK3R2','PIK3R3','PPP2R1A','PTEN','RHEB','RICTOR','RPTOR','RPS6','RPS6KB1','STK11','TSC1','TSC2','TP53','MDM2','MDM4','ATM','CHEK2','RPS6KA3','CDKN1A','CDKN1B','CDKN2A','CDKN2B','CDKN2C','CCND1','CCND2','CCND3','CCNE1','CDK2','CDK4','CDK6','RB1','E2F1','E2F3','MAX','MGA','MLX','MLXIP','MLXIPL','MNT','MXD1','MXD3','MXD4','MXI1','MYC','MYCL','MYCN','CHD8','LEF1','LGR4','LGR5','LRP5','LRP6','LZTR1','NDP','PORCN','RSPO1','SFRP1','SFRP2','SFRP4','SFRP5','SOST','TCF7L1','TLE1','TLE2','TLE3','TLE4','WIF1','ZNRF3','CTNNB1','DVL1','DVL2','DVL3','FRAT1','FRAT2','FZD1','FZD10','FZD2','FZD3','FZD4','FZD5','FZD6','FZD7','FZD8','FZD9','WNT1','WNT10A','WNT10B','WNT11','WNT16','WNT2','WNT3A','WNT4','WNT5A','WNT5B','WNT6','WNT7A','WNT7B','WNT8A','WNT8B','WNT9A','WNT9B','AMER1','APC','AXIN1','AXIN2','DKK1','DKK2','DKK3','DKK4','GSK3B','RNF43','TCF7','TCF7L2','CHD4','ARRDC1','CNTN6','CREBBP','EP300','HES1','HES2','HES3','HES4','HES5','HEY1','HEY2','HEYL','KAT2B','KDM5A','NOTCH1','NOTCH2','NOTCH3','NOTCH4','NOV','NRARP','PSEN2','LFNG','ITCH','NCSTN','SPEN','JAG1','APH1A','FBXW7','FHL1','THBS2','HDAC2','MFAP2','CUL1','RFNG','NCOR1','NCOR2','MFAP5','HDAC1','NUMB','JAG2','MAML3','MFNG','CIR1','CNTN1','MAML1','MAML2','NUMBL','PSEN1','PSENEN','RBPJ','RBPJL','RBX1','SAP30','SKP1','SNW1','CTBP1','CTBP2','ADAM10','APH1B','ADAM17','DLK1','DLL1','DLL3','DLL4','DNER','DTX1','DTX2','DTX3','DTX3L','DTX4','EGFL7','STK4','STK3','SAV1','LATS1','LATS2','MOB1A','MOB1B','YAP1','WWTR1','TEAD1','TEAD2','TEAD3','TEAD4','PTPN14','NF2','WWC1','TAOK1','TAOK2','TAOK3','CRB1','CRB2','CRB3','LLGL1','LLGL2','HMCN1','HIPK2','FAT1','FAT2','FAT3','FAT4','DCHS1','DCHS2','CSNK1E','CSNK1D','AJUBA','LIMD1','WTIP','TGFBR1','TGFBR2','ACVR2A','ACVR1B','SMAD2','SMAD3','SMAD4','NFE2L2','KEAP1','CUL3') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +per AS ( + SELECT members.set_name AS set_name, x.pid AS pid, max(x.is_alt) AS is_alt, max(x.is_drv) AS is_drv + FROM ( + SELECT gene, pid, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, 0 AS is_alt, 0 AS is_drv FROM covered + ) x + INNER JOIN members ON members.gene = x.gene + GROUP BY set_name, pid +) +SELECT set_name, uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM per GROUP BY set_name diff --git a/test/snapshots/pathways.svg b/test/snapshots/pathways.svg new file mode 100644 index 0000000..34fa6ad --- /dev/null +++ b/test/snapshots/pathways.svg @@ -0,0 +1,161 @@ + +Oncogenic signalling pathways — Colorectal, Pancreaticpathwaypatients with ≥1 member drivermost-altered members (% per cohort, ★ q < 0.05)0%50%100%RTK-RAS47 of 85 genes profiledColorectal: 67.4% (3,738 of 5,543)67.4%Pancreatic: 83.6% (2,600 of 3,109)83.6%q = 1.3e-62KRAS (oncogene) +Colorectal: 43.2% (2,395 of 5,543) +Pancreatic: 81.0% (2,517 of 3,109) +q = 7.7e-267KRAS ★43.2%81.0%BRAF (oncogene) +Colorectal: 9.9% (547 of 5,543) +Pancreatic: 1.1% (35 of 3,109) +q = 7.4e-68BRAF ★9.9%1.1%ERBB2 (oncogene) +Colorectal: 5.2% (291 of 5,543) +Pancreatic: 1.2% (36 of 3,109) +q = 2.4e-24ERBB2 ★5.2%1.2%NRAS (oncogene) +Colorectal: 3.4% (189 of 5,543) +Pancreatic: 0.5% (14 of 3,109) +q = 1.6e-21NRAS ★3.4%0.5%FGFR1 (oncogene) +Colorectal: 2.5% (136 of 5,543) +Pancreatic: 1.7% (53 of 3,109) +q = 0.037FGFR1 ★2.5%1.7%ERBB3 (oncogene) +Colorectal: 2.3% (130 of 5,543) +Pancreatic: 0.9% (28 of 3,109) +q = 1.5e-6ERBB3 ★2.3%0.9%+32 more altered38 never profiledPI3K19 of 29 genes profiledColorectal: 31.6% (1,754 of 5,543)31.6%Pancreatic: 10.0% (312 of 3,109)10.0%q = 1.4e-124PIK3CA (oncogene) +Colorectal: 18.8% (1,043 of 5,543) +Pancreatic: 2.0% (62 of 3,109) +q = 1e-139PIK3CA ★18.8%2.0%PTEN (tumour suppressor) +Colorectal: 6.8% (375 of 5,543) +Pancreatic: 1.4% (45 of 3,109) +q = 3e-32PTEN ★6.8%1.4%PIK3R1 (tumour suppressor) +Colorectal: 4.3% (238 of 5,543) +Pancreatic: 0.3% (10 of 3,109) +q = 2.9e-33PIK3R1 ★4.3%0.3%AKT2 (oncogene) +Colorectal: 0.7% (37 of 5,543) +Pancreatic: 3.2% (98 of 3,109) +q = 2.7e-17AKT2 ★0.7%3.2%STK11 (tumour suppressor) +Colorectal: 0.8% (42 of 5,543) +Pancreatic: 1.9% (58 of 3,109) +q = 1.9e-5STK11 ★0.8%1.9%AKT1 (oncogene) +Colorectal: 1.5% (81 of 5,543) +Pancreatic: 0.3% (8 of 3,109) +q = 3e-8AKT1 ★1.5%0.3%+12 more altered10 never profiledTP535 of 6 genes profiledColorectal: 77.0% (4,268 of 5,543)77.0%Pancreatic: 68.5% (2,129 of 3,109)68.5%q = 1.3e-17TP53 (tumour suppressor) +Colorectal: 73.3% (4,064 of 5,543) +Pancreatic: 66.5% (2,068 of 3,109) +q = 1.4e-10TP53 ★73.3%66.5%ATM (tumour suppressor) +Colorectal: 5.2% (287 of 5,543) +Pancreatic: 1.8% (56 of 3,109) +q = 2e-15ATM ★5.2%1.8%MDM2 (oncogene) +Colorectal: 0.1% (7 of 5,543) +Pancreatic: 1.1% (33 of 3,109) +q = 6e-9MDM2 ★0.1%1.1%CHEK2 (tumour suppressor) +Colorectal: 0.8% (42 of 5,543) +Pancreatic: 0.2% (6 of 3,109) +q = 8.8e-4CHEK2 ★0.8%0.2%MDM4 (oncogene) +Colorectal: 0% (2 of 5,543) +Pancreatic: 0.2% (5 of 3,109) +q = 0.15MDM40%0.2%1 never profiledCell cycle13 of 15 genes profiledColorectal: 8.8% (489 of 5,543)8.8%Pancreatic: 39.1% (1,216 of 3,109)39.1%q = 2.6e-244CDKN2A (tumour suppressor) +Colorectal: 2.0% (113 of 5,543) +Pancreatic: 32.8% (1,020 of 3,109) +q < 1e-300CDKN2A ★2.0%32.8%CDKN2B (tumour suppressor) +Colorectal: 1.0% (56 of 5,543) +Pancreatic: 13.6% (422 of 3,109) +q = 2.9e-131CDKN2B ★1.0%13.6%RB1 (tumour suppressor) +Colorectal: 1.3% (74 of 5,543) +Pancreatic: 2.5% (77 of 3,109) +q = 3.3e-4RB1 ★1.3%2.5%CCND2 (oncogene) +Colorectal: 2.2% (124 of 5,543) +Pancreatic: 0.6% (18 of 3,109) +q = 1.7e-9CCND2 ★2.2%0.6%CCNE1 (oncogene) +Colorectal: 0.6% (33 of 5,543) +Pancreatic: 1.9% (60 of 3,109) +q = 7.1e-8CCNE1 ★0.6%1.9%CDK6 (oncogene) +Colorectal: 0.2% (10 of 5,543) +Pancreatic: 1.3% (41 of 3,109) +q = 3.6e-10CDK6 ★0.2%1.3%+6 more altered2 never profiledMYC5 of 13 genes profiledColorectal: 8.1% (451 of 5,543)8.1%Pancreatic: 5.0% (156 of 3,109)5.0%q = 3.6e-8MYC (oncogene) +Colorectal: 4.8% (265 of 5,543) +Pancreatic: 3.9% (120 of 3,109) +q = 0.079MYC4.8%3.9%MGA (tumour suppressor) +Colorectal: 2.9% (153 of 5,350) +Pancreatic: 0.7% (22 of 3,076) +q = 4.5e-12MGA ★2.9%0.7%MAX (tumour suppressor) +Colorectal: 0.4% (22 of 5,543) +Pancreatic: 0.2% (6 of 3,109) +q = 0.17MAX0.4%0.2%MYCL (oncogene) +Colorectal: 0.3% (16 of 5,543) +Pancreatic: 0.3% (8 of 3,109) +q = 1.00MYCL0.3%0.3%MYCN (oncogene) +Colorectal: 0.1% (4 of 5,543) +Pancreatic: 0.1% (2 of 3,109) +q = 1.00MYCN0.1%0.1%8 never profiledWNT12 of 68 genes profiledColorectal: 81.8% (4,536 of 5,543)81.8%Pancreatic: 7.8% (243 of 3,109)7.8%q < 1e-300APC (tumour suppressor) +Colorectal: 73.1% (4,050 of 5,543) +Pancreatic: 1.0% (30 of 3,109) +q < 1e-300APC ★73.1%1.0%TCF7L2 (tumour suppressor) +Colorectal: 12.1% (650 of 5,350) +Pancreatic: 0.2% (5 of 3,076) +q = 4.5e-124TCF7L2 ★12.1%0.2%AMER1 (tumour suppressor) +Colorectal: 6.0% (335 of 5,543) +Pancreatic: 0.9% (27 of 3,109) +q = 9.3e-37AMER1 ★6.0%0.9%RNF43 (tumour suppressor) +Colorectal: 5.1% (284 of 5,543) +Pancreatic: 4.0% (124 of 3,109) +q = 0.03RNF43 ★5.1%4.0%AXIN2 (tumour suppressor) +Colorectal: 3.8% (212 of 5,543) +Pancreatic: 0.5% (17 of 3,109) +q = 2.6e-23AXIN2 ★3.8%0.5%ZNRF3 (tumour suppressor) +Colorectal: 3.8% (68 of 1,798) +Pancreatic: 0.3% (3 of 1,100) +q = 1.1e-10ZNRF3 ★3.8%0.3%+4 more altered56 never profiledNOTCH14 of 71 genes profiledColorectal: 21.9% (1,215 of 5,543)21.9%Pancreatic: 3.5% (108 of 3,109)3.5%q = 8.7e-139FBXW7 (tumour suppressor) +Colorectal: 13.5% (750 of 5,543) +Pancreatic: 1.0% (31 of 3,109) +q = 6.2e-110FBXW7 ★13.5%1.0%CREBBP (tumour suppressor) +Colorectal: 3.0% (166 of 5,543) +Pancreatic: 0.5% (17 of 3,109) +q = 6.6e-16CREBBP ★3.0%0.5%NCOR1 (tumour suppressor) +Colorectal: 2.7% (149 of 5,543) +Pancreatic: 0.2% (5 of 3,109) +q = 3.7e-22NCOR1 ★2.7%0.2%NOTCH3 (tumour suppressor) +Colorectal: 2.3% (128 of 5,543) +Pancreatic: 0.2% (7 of 3,109) +q = 1.7e-16NOTCH3 ★2.3%0.2%EP300 (tumour suppressor) +Colorectal: 2.2% (122 of 5,543) +Pancreatic: 0.4% (12 of 3,109) +q = 2.9e-12EP300 ★2.2%0.4%SPEN (tumour suppressor) +Colorectal: 1.8% (98 of 5,543) +Pancreatic: 0.2% (5 of 3,109) +q = 4e-13SPEN ★1.8%0.2%+4 more altered57 never profiledHippo6 of 38 genes profiledColorectal: 4.7% (260 of 5,543)4.7%Pancreatic: 1.3% (40 of 3,109)1.3%q = 1e-18FAT1 (tumour suppressor) +Colorectal: 3.2% (177 of 5,543) +Pancreatic: 0.5% (16 of 3,109) +q = 2.4e-18FAT1 ★3.2%0.5%LATS1 (tumour suppressor) +Colorectal: 0.9% (49 of 5,543) +Pancreatic: 0.3% (10 of 3,109) +q = 0.0033LATS1 ★0.9%0.3%LATS2 (tumour suppressor) +Colorectal: 0.6% (34 of 5,543) +Pancreatic: 0.2% (5 of 3,109) +q = 0.0041LATS2 ★0.6%0.2%NF2 (tumour suppressor) +Colorectal: 0.2% (9 of 5,543) +Pancreatic: 0.3% (9 of 3,109) +q = 0.31NF20.2%0.3%YAP1 (oncogene) +Colorectal: 0.2% (10 of 5,543) +Pancreatic: 0% (1 of 3,109) +q = 0.16YAP10.2%0%32 never profiledTGF-β5 of 7 genes profiledColorectal: 21.5% (1,194 of 5,543)21.5%Pancreatic: 23.5% (732 of 3,109)23.5%q = 0.037SMAD4 (tumour suppressor) +Colorectal: 15.5% (859 of 5,543) +Pancreatic: 21.1% (655 of 3,109) +q = 3.7e-10SMAD4 ★15.5%21.1%SMAD2 (tumour suppressor) +Colorectal: 4.1% (225 of 5,543) +Pancreatic: 0.4% (11 of 3,109) +q = 4.1e-30SMAD2 ★4.1%0.4%SMAD3 (tumour suppressor) +Colorectal: 3.2% (180 of 5,543) +Pancreatic: 1.0% (31 of 3,109) +q = 2.6e-11SMAD3 ★3.2%1.0%TGFBR1 (tumour suppressor) +Colorectal: 0.9% (48 of 5,543) +Pancreatic: 1.4% (42 of 3,109) +q = 0.058TGFBR10.9%1.4%TGFBR2 (tumour suppressor) +Colorectal: 0.4% (22 of 5,543) +Pancreatic: 0.7% (22 of 3,109) +q = 0.091TGFBR20.4%0.7%2 never profiledNRF23 of 3 genes profiledColorectal: 1.0% (54 of 5,543)1.0%Pancreatic: 0.8% (24 of 3,109)0.8%q = 0.41KEAP1 (tumour suppressor) +Colorectal: 0.6% (33 of 5,543) +Pancreatic: 0.6% (19 of 3,109) +q = 1.00KEAP10.6%0.6%CUL3 (tumour suppressor) +Colorectal: 0.4% (20 of 5,543) +Pancreatic: 0% (1 of 3,109) +q = 0.0041CUL3 ★0.4%0%NFE2L2 (oncogene) +Colorectal: 0% (1 of 5,543) +Pancreatic: 0.1% (4 of 3,109) +q = 0.091NFE2L20%0.1%ColorectalPancreaticoncogenetumour suppressor (paper's role)Share of patients with an OncoKB driver (v7.5) in at least one member gene — drivers only, as Sanchez-Vega et al. counted curated oncogenic events. A pathway'sdenominator is the patients profiled for at least one of its genes, so a panel that covers few members makes a pathway look rarer than a genome-wide assay would; eachmember gene's own % is over the patients profiled for THAT gene. 206 member-gene slots were on no participating panel and are listed as not profiled rather thancounted as unaltered. Pathway membership is the paper's Table S3; a gene's pathway role (oncogene / tumour suppressor) is not used in the count. Two-sided Fishertests; q is Benjamini–Hochberg across the pathways drawn, and separately across every member gene tested. diff --git a/test/snapshots/pathways.txt b/test/snapshots/pathways.txt new file mode 100644 index 0000000..16ea356 --- /dev/null +++ b/test/snapshots/pathways.txt @@ -0,0 +1,26 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Colorectal: 5,543 patients — CANCER_TYPE in [Colorectal Cancer] (any sample) +- Pancreatic: 3,109 patients — CANCER_TYPE in [Pancreatic Cancer] (any sample) + +Oncogenic signalling pathways (% of patients with ≥1 member driver; union-of-panels denominator): + RTK-RAS (47/85 genes profiled): Colorectal 67.4% | Pancreatic 83.6% q=1.3e-62; top: KRAS 43.2%/81%, BRAF 9.9%/1.1%, ERBB2 5.2%/1.2%, NRAS 3.4%/0.5%, FGFR1 2.5%/1.7%, ERBB3 2.3%/0.9%, +32 more altered + PI3K (19/29 genes profiled): Colorectal 31.6% | Pancreatic 10% q=1.4e-124; top: PIK3CA 18.8%/2%, PTEN 6.8%/1.4%, PIK3R1 4.3%/0.3%, AKT2 0.7%/3.2%, STK11 0.8%/1.9%, AKT1 1.5%/0.3%, +12 more altered + TP53 (5/6 genes profiled): Colorectal 77% | Pancreatic 68.5% q=1.3e-17; top: TP53 73.3%/66.5%, ATM 5.2%/1.8%, MDM2 0.1%/1.1%, CHEK2 0.8%/0.2%, MDM4 0%/0.2% + Cell cycle (13/15 genes profiled): Colorectal 8.8% | Pancreatic 39.1% q=2.6e-244; top: CDKN2A 2%/32.8%, CDKN2B 1%/13.6%, RB1 1.3%/2.5%, CCND2 2.2%/0.6%, CCNE1 0.6%/1.9%, CDK6 0.2%/1.3%, +6 more altered + MYC (5/13 genes profiled): Colorectal 8.1% | Pancreatic 5% q=3.6e-8; top: MYC 4.8%/3.9%, MGA 2.9%/0.7%, MAX 0.4%/0.2%, MYCL 0.3%/0.3%, MYCN 0.1%/0.1% + WNT (12/68 genes profiled): Colorectal 81.8% | Pancreatic 7.8% q=<1e-300; top: APC 73.1%/1%, TCF7L2 12.1%/0.2%, AMER1 6%/0.9%, RNF43 5.1%/4%, AXIN2 3.8%/0.5%, ZNRF3 3.8%/0.3%, +4 more altered + NOTCH (14/71 genes profiled): Colorectal 21.9% | Pancreatic 3.5% q=8.7e-139; top: FBXW7 13.5%/1%, CREBBP 3%/0.5%, NCOR1 2.7%/0.2%, NOTCH3 2.3%/0.2%, EP300 2.2%/0.4%, SPEN 1.8%/0.2%, +4 more altered + Hippo (6/38 genes profiled): Colorectal 4.7% | Pancreatic 1.3% q=1.0e-18; top: FAT1 3.2%/0.5%, LATS1 0.9%/0.3%, LATS2 0.6%/0.2%, NF2 0.2%/0.3%, YAP1 0.2%/0% + TGF-β (5/7 genes profiled): Colorectal 21.5% | Pancreatic 23.5% q=0.0371; top: SMAD4 15.5%/21.1%, SMAD2 4.1%/0.4%, SMAD3 3.2%/1%, TGFBR1 0.9%/1.4%, TGFBR2 0.4%/0.7% + NRF2 (3/3 genes profiled): Colorectal 1% | Pancreatic 0.8% q=0.4068; top: KEAP1 0.6%/0.6%, CUL3 0.4%/0%, NFE2L2 0%/0.1% + CAVEAT (tell the user): Share of patients with an OncoKB driver (v7.5) in at least one member gene — drivers only, as Sanchez-Vega et al. counted curated oncogenic events. A pathway's denominator is the patients profiled for at least one of its genes, so a panel that covers few members makes a pathway look rarer than a genome-wide assay would; each member gene's own % is over the patients profiled for THAT gene. 206 member-gene slots were on no participating panel and are listed as not profiled rather than counted as unaltered. Pathway membership is the paper's Table S3; a gene's pathway role (oncogene / tumour suppressor) is not used in the count. Two-sided Fisher tests; q is Benjamini–Hochberg across the pathways drawn, and separately across every member gene tested. + METHOD: + - Count patients altered per pathway and per gene [Colorectal · msk_chord_2024]: The geneCounts and pathways:sets queries above. Per pathway: patients profiled for at least one member gene (the denominator) and of those, patients with an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in at least one member. Per member gene: the same over the patients profiled for that gene. Counts only. + pathways / sets: RTK-RAS (85), PI3K (29), TP53 (6), Cell cycle (15), MYC (13), WNT (68), NOTCH (71), Hippo (38), TGF-β (7), NRF2 (3) + - Count patients altered per pathway and per gene [Pancreatic · msk_chord_2024]: The geneCounts and pathways:sets queries above. Per pathway: patients profiled for at least one member gene (the denominator) and of those, patients with an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5) in at least one member. Per member gene: the same over the patients profiled for that gene. Counts only. + pathways / sets: RTK-RAS (85), PI3K (29), TP53 (6), Cell cycle (15), MYC (13), WNT (68), NOTCH (71), Hippo (38), TGF-β (7), NRF2 (3) + - Fisher's exact test per pathway and per member gene: Two-sided, altered vs not among the profiled, between the two cohorts. + - Benjamini–Hochberg: Across the pathways drawn, and separately across every member gene tested, each gene once even when it sits in two pathways. + Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg statsmodels multipletests, to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/plot.json b/test/snapshots/plot.json new file mode 100644 index 0000000..24586d8 --- /dev/null +++ b/test/snapshots/plot.json @@ -0,0 +1,681 @@ +{ + "study": "brca_tcga_pan_can_atlas_2018", + "cohorts": { + "all samples": { + "count": 1084, + "text": "all patients in the study", + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ] + } + }, + "views": [ + { + "kind": "plot", + "plot": { + "shape": "box", + "n": 1068, + "x": { + "label": "ERBB2: Putative copy-number alterations from GISTIC", + "kind": "cat" + }, + "y": { + "label": "ERBB2: mRNA expression z-scores relative to all samples (log RNA Seq V2 RSEM)", + "kind": "num" + }, + "groups": [ + { + "g": "Shallow deletion", + "n": 260, + "lo": -3.8045, + "hi": 0.351, + "q1": -0.9513, + "median": -0.6594, + "q3": -0.4083, + "loWhisker": -1.7658, + "hiWhisker": 0.351 + }, + { + "g": "Diploid", + "n": 480, + "lo": -2.742, + "hi": 1.1073, + "q1": -0.4187, + "median": -0.1185, + "q3": 0.1519, + "loWhisker": -1.2746, + "hiWhisker": 1.0078 + }, + { + "g": "Gain", + "n": 206, + "lo": -1.5533000000000001, + "hi": 3.1795, + "q1": -0.23, + "median": 0.1592, + "q3": 0.415, + "loWhisker": -1.1975, + "hiWhisker": 1.3825 + }, + { + "g": "Amplification", + "n": 122, + "lo": -0.7721, + "hi": 3.7214, + "q1": 1.4466999999999999, + "median": 2.3303, + "q3": 2.8102, + "loWhisker": -0.5985500000000004, + "hiWhisker": 3.7214 + } + ], + "violin": [ + { + "g": "Gain", + "b": 15, + "n": 17 + }, + { + "g": "Diploid", + "b": 3, + "n": 2 + }, + { + "g": "Gain", + "b": 29, + "n": 1 + }, + { + "g": "Diploid", + "b": 16, + "n": 67 + }, + { + "g": "Shallow deletion", + "b": 9, + "n": 13 + }, + { + "g": "Amplification", + "b": 25, + "n": 2 + }, + { + "g": "Shallow deletion", + "b": 5, + "n": 4 + }, + { + "g": "Gain", + "b": 12, + "n": 6 + }, + { + "g": "Gain", + "b": 30, + "n": 1 + }, + { + "g": "Amplification", + "b": 36, + "n": 12 + }, + { + "g": "Diploid", + "b": 15, + "n": 65 + }, + { + "g": "Amplification", + "b": 21, + "n": 3 + }, + { + "g": "Gain", + "b": 9, + "n": 1 + }, + { + "g": "Amplification", + "b": 22, + "n": 3 + }, + { + "g": "Shallow deletion", + "b": 6, + "n": 6 + }, + { + "g": "Diploid", + "b": 12, + "n": 24 + }, + { + "g": "Amplification", + "b": 39, + "n": 12 + }, + { + "g": "Gain", + "b": 10, + "n": 2 + }, + { + "g": "Gain", + "b": 24, + "n": 1 + }, + { + "g": "Amplification", + "b": 26, + "n": 6 + }, + { + "…": "68 more", + "sha256": "6226d739d598cb9a" + } + ], + "violinBins": 40, + "overlay": "points", + "violinExtent": [ + -2.435, + 3.1795 + ], + "coverage": { + "total": 1084, + "nx": 1070, + "ny": 1082 + }, + "points": [ + { + "id": "TCGA-BH-A0BC-01", + "g": "Shallow deletion", + "v": -1.0313 + }, + { + "id": "TCGA-GM-A2DO-01", + "g": "Diploid", + "v": -0.5257 + }, + { + "id": "TCGA-D8-A27M-01", + "g": "Shallow deletion", + "v": -1.1943 + }, + { + "id": "TCGA-A2-A0YG-01", + "g": "Amplification", + "v": 2.6454 + }, + { + "id": "TCGA-AR-A1AY-01", + "g": "Shallow deletion", + "v": -0.8701 + }, + { + "id": "TCGA-A7-A3IZ-01", + "g": "Diploid", + "v": 0.2288 + }, + { + "id": "TCGA-C8-A1HN-01", + "g": "Gain", + "v": 0.221 + }, + { + "id": "TCGA-AR-A2LJ-01", + "g": "Amplification", + "v": 2.1318 + }, + { + "id": "TCGA-LL-A5YP-01", + "g": "Diploid", + "v": -0.9265 + }, + { + "id": "TCGA-OL-A6VR-01", + "g": "Diploid", + "v": -0.1528 + }, + { + "id": "TCGA-AR-A1AO-01", + "g": "Diploid", + "v": -0.9581 + }, + { + "id": "TCGA-A2-A3XV-01", + "g": "Amplification", + "v": 1.5072 + }, + { + "id": "TCGA-A2-A0ES-01", + "g": "Diploid", + "v": 0.0208 + }, + { + "id": "TCGA-AC-A3QP-01", + "g": "Diploid", + "v": 0.2131 + }, + { + "id": "TCGA-AR-A24P-01", + "g": "Gain", + "v": 0.2602 + }, + { + "id": "TCGA-B6-A0X0-01", + "g": "Diploid", + "v": 0.3066 + }, + { + "id": "TCGA-AR-A0U0-01", + "g": "Diploid", + "v": -0.5601 + }, + { + "id": "TCGA-BH-A1EU-01", + "g": "Shallow deletion", + "v": -1.0684 + }, + { + "id": "TCGA-AC-A2FF-01", + "g": "Diploid", + "v": 0.2463 + }, + { + "id": "TCGA-AN-A04C-01", + "g": "Amplification", + "v": 2.8872999999999998 + }, + { + "…": "1048 more", + "sha256": "ae5b2d782b1b6fdf" + } + ], + "pointSet": { + "rule": "all", + "drawn": 1068 + }, + "layers": [ + { + "kind": "outliers", + "label": "outliers", + "color": "#D55E00", + "n": 0, + "shown": "none", + "why": "at or under 10,000 cases there is no density for them to stand out of" + } + ] + }, + "cohorts": [ + "all samples" + ], + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ], + "participation": { + "studies": [ + { + "study": "brca_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "1,068 of 1,084 samples have a value on both axes (14 have no ERBB2: Putative copy-number alterations from GISTIC; 2 have no ERBB2: mRNA expression z-scores relative to all samples (log RNA Seq V2 RSEM)); only those are drawn. Point layers — outliers: not drawn, at or under 10,000 cases there is no density for them to stand out of." + }, + { + "kind": "plot", + "plot": { + "shape": "box", + "n": 1068, + "x": { + "label": "TP53 mutation type", + "kind": "cat" + }, + "y": { + "label": "FRACTION_GENOME_ALTERED", + "kind": "num" + }, + "groups": [ + { + "g": "Not mutated", + "n": 706, + "lo": 0, + "hi": 0.9971, + "q1": 0.1049, + "median": 0.1949, + "q3": 0.346, + "loWhisker": 0, + "hiWhisker": 0.7076499999999999 + }, + { + "g": "Missense", + "n": 209, + "lo": 0, + "hi": 0.9463, + "q1": 0.2622, + "median": 0.3797, + "q3": 0.5222, + "loWhisker": 0, + "hiWhisker": 0.9122 + }, + { + "g": "Truncating", + "n": 102, + "lo": 0.0002, + "hi": 0.947, + "q1": 0.2982, + "median": 0.4656, + "q3": 0.6182, + "loWhisker": 0.0002, + "hiWhisker": 0.947 + }, + { + "g": "Splice", + "n": 24, + "lo": 0.0027, + "hi": 0.8331, + "q1": 0.2373, + "median": 0.4675, + "q3": 0.5381, + "loWhisker": 0.0027, + "hiWhisker": 0.8331 + }, + { + "g": "Not profiled", + "n": 18, + "lo": 0, + "hi": 0.6502, + "q1": 0.0052, + "median": 0.1065, + "q3": 0.1675, + "loWhisker": 0, + "hiWhisker": 0.41095000000000004 + }, + { + "g": "Inframe", + "n": 5, + "lo": 0.2493, + "hi": 0.5605, + "q1": 0.2545, + "median": 0.2741, + "q3": 0.4806, + "loWhisker": 0.2493, + "hiWhisker": 0.5605 + }, + { + "g": "Multiple", + "n": 4, + "lo": 0.1011, + "hi": 0.6513, + "q1": 0.4622, + "median": 0.6276, + "q3": 0.6513, + "loWhisker": 0.17855000000000004, + "hiWhisker": 0.6513 + } + ], + "violin": [ + { + "g": "Not profiled", + "b": 0, + "n": 6 + }, + { + "g": "Missense", + "b": 34, + "n": 1 + }, + { + "g": "Not mutated", + "b": 30, + "n": 4 + }, + { + "g": "Missense", + "b": 28, + "n": 5 + }, + { + "g": "Not mutated", + "b": 8, + "n": 33 + }, + { + "g": "Truncating", + "b": 19, + "n": 1 + }, + { + "g": "Missense", + "b": 3, + "n": 1 + }, + { + "g": "Truncating", + "b": 12, + "n": 4 + }, + { + "g": "Truncating", + "b": 20, + "n": 6 + }, + { + "g": "Splice", + "b": 25, + "n": 1 + }, + { + "g": "Missense", + "b": 27, + "n": 8 + }, + { + "g": "Truncating", + "b": 11, + "n": 6 + }, + { + "g": "Missense", + "b": 4, + "n": 1 + }, + { + "g": "Not mutated", + "b": 23, + "n": 13 + }, + { + "g": "Not mutated", + "b": 1, + "n": 19 + }, + { + "g": "Truncating", + "b": 26, + "n": 5 + }, + { + "g": "Splice", + "b": 23, + "n": 2 + }, + { + "g": "Missense", + "b": 21, + "n": 9 + }, + { + "g": "Splice", + "b": 8, + "n": 1 + }, + { + "g": "Missense", + "b": 10, + "n": 6 + }, + { + "…": "123 more", + "sha256": "ddb05dbc992682e5" + } + ], + "violinBins": 40, + "overlay": "points", + "violinExtent": [ + 0, + 0.9228 + ], + "coverage": { + "total": 1084, + "nx": 1084, + "ny": 1068 + }, + "points": [ + { + "id": "TCGA-AO-A0J6-01", + "g": "Truncating", + "v": 0.4668 + }, + { + "id": "TCGA-AO-A12B-01", + "g": "Not mutated", + "v": 0.1121 + }, + { + "id": "TCGA-BH-A0DI-01", + "g": "Missense", + "v": 0.2622 + }, + { + "id": "TCGA-A8-A07F-01", + "g": "Not mutated", + "v": 0.6103 + }, + { + "id": "TCGA-C8-A12P-01", + "g": "Missense", + "v": 0.3385 + }, + { + "id": "TCGA-A8-A091-01", + "g": "Not mutated", + "v": 0.3068 + }, + { + "id": "TCGA-E2-A1L8-01", + "g": "Not mutated", + "v": 0.1645 + }, + { + "id": "TCGA-A7-A26F-01", + "g": "Missense", + "v": 0.3177 + }, + { + "id": "TCGA-BH-A0W7-01", + "g": "Not mutated", + "v": 0.3048 + }, + { + "id": "TCGA-A2-A0YH-01", + "g": "Missense", + "v": 0.3154 + }, + { + "id": "TCGA-E9-A243-01", + "g": "Multiple", + "v": 0.1011 + }, + { + "id": "TCGA-E2-A150-01", + "g": "Truncating", + "v": 0.671 + }, + { + "id": "TCGA-AO-A1KQ-01", + "g": "Not mutated", + "v": 0.5026 + }, + { + "id": "TCGA-C8-A12K-01", + "g": "Missense", + "v": 0.4856 + }, + { + "id": "TCGA-C8-A9FZ-01", + "g": "Not mutated", + "v": 0.6245 + }, + { + "id": "TCGA-OL-A66N-01", + "g": "Not mutated", + "v": 0.2094 + }, + { + "id": "TCGA-BH-A28Q-01", + "g": "Not mutated", + "v": 0.1605 + }, + { + "id": "TCGA-A2-A04Y-01", + "g": "Not mutated", + "v": 0.147 + }, + { + "id": "TCGA-D8-A1XU-01", + "g": "Not mutated", + "v": 0.9465 + }, + { + "id": "TCGA-B6-A0I1-01", + "g": "Missense", + "v": 0.3742 + }, + { + "…": "1048 more", + "sha256": "720bf7719a5722b2" + } + ], + "pointSet": { + "rule": "all", + "drawn": 1068 + }, + "layers": [ + { + "kind": "outliers", + "label": "outliers", + "color": "#D55E00", + "n": 0, + "shown": "none", + "why": "at or under 10,000 cases there is no density for them to stand out of" + } + ] + }, + "cohorts": [ + "all samples" + ], + "studies": [ + "brca_tcga_pan_can_atlas_2018" + ], + "participation": { + "studies": [ + { + "study": "brca_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "1,068 of 1,084 samples have a value on both axes (16 have no FRACTION_GENOME_ALTERED); only those are drawn. Point layers — outliers: not drawn, at or under 10,000 cases there is no density for them to stand out of." + } + ] +} diff --git a/test/snapshots/plot.sql b/test/snapshots/plot.sql new file mode 100644 index 0000000..821743d --- /dev/null +++ b/test/snapshots/plot.sql @@ -0,0 +1,232 @@ +-- cohort all samples +-- brca_tcga_pan_can_atlas_2018 +SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' + +-- view 0 plot: plot:box · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + vs AS (SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, + argMax(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL), 1) AS v +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_all_sample_Zscores' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY id), + gs AS (SELECT id, if(uniqExact(lv) > 1, 'Multiple', any(lv)) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, multiIf(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -2, 'Deep deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -1, 'Shallow deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 0, 'Diploid', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 1, 'Gain', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 2, 'Amplification', toString(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL))) AS lv +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'gistic' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort)) +GROUP BY id) +SELECT gs.v AS g, count() AS n, min(vs.v) AS lo, max(vs.v) AS hi, + quantilesExact(0.25, 0.5, 0.75)(vs.v) AS q +FROM vs INNER JOIN gs ON gs.id = vs.id +GROUP BY g ORDER BY n DESC LIMIT 151 + +-- view 0 plot: plot:coverage · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + cases AS (SELECT DISTINCT replaceOne(sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort)), + xs AS (SELECT id, if(uniqExact(lv) > 1, 'Multiple', any(lv)) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, multiIf(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -2, 'Deep deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -1, 'Shallow deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 0, 'Diploid', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 1, 'Gain', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 2, 'Amplification', toString(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL))) AS lv +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'gistic' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort)) +GROUP BY id), + ys AS (SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, + argMax(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL), 1) AS v +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_all_sample_Zscores' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY id) +SELECT count() AS total, countIf(id IN (SELECT id FROM xs)) AS nx, countIf(id IN (SELECT id FROM ys)) AS ny FROM cases + +-- view 0 plot: plot:points · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + vs AS (SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, + argMax(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL), 1) AS v +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_all_sample_Zscores' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY id), + gs AS (SELECT id, if(uniqExact(lv) > 1, 'Multiple', any(lv)) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, multiIf(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -2, 'Deep deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -1, 'Shallow deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 0, 'Diploid', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 1, 'Gain', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 2, 'Amplification', toString(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL))) AS lv +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'gistic' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort)) +GROUP BY id) +SELECT vs.id AS id, gs.v AS g, vs.v AS v +FROM vs INNER JOIN gs ON gs.id = vs.id +LIMIT 10001 + +-- view 0 plot: plot:violin · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + vs AS (SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, + argMax(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL), 1) AS v +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'rna_seq_v2_mrna_median_all_sample_Zscores' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY id), + gs AS (SELECT id, if(uniqExact(lv) > 1, 'Multiple', any(lv)) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, multiIf(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -2, 'Deep deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = -1, 'Shallow deletion', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 0, 'Diploid', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 1, 'Gain', if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) = 2, 'Amplification', toString(if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL))) AS lv +FROM snapshot_db.genetic_alteration_derived ga +JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = ga.sample_unique_id +WHERE ga.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND ga.profile_type = 'gistic' AND ga.hugo_gene_symbol = 'ERBB2' + AND if(isFinite(ifNull(toFloat64OrNull(ga.alteration_value), nan)), toFloat64OrNull(ga.alteration_value), NULL) IS NOT NULL AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort)) +GROUP BY id), + j AS (SELECT gs.v AS g, vs.v AS x FROM vs INNER JOIN gs ON gs.id = vs.id), + e AS (SELECT quantileExact(0.005)(x) x0, quantileExact(0.995)(x) x1 FROM j) +SELECT g, least(39, toUInt32(floor((x - x0) / nullIf(x1 - x0, 0) * 40))) AS b, count() AS n, any(x0) AS vx0, any(x1) AS vx1 +FROM j, e GROUP BY g, b + +-- view 1 plot: plot:box · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND attribute_name = 'FRACTION_GENOME_ALTERED' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived cd + JOIN snapshot_db.sample_derived sd ON sd.patient_unique_id = cd.patient_unique_id + WHERE cd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND cd.attribute_name = 'FRACTION_GENOME_ALTERED' AND cd.attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) IS NOT NULL + AND cd.type = 'patient' AND replaceOne(cd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS alt_case, multiIf(countIf(g.variant_type = 'mutation') = 0, 'Not mutated', length(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation')) > 1, 'Multiple', arrayElement(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation'), 1)) AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol IN ('TP53') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case)) +SELECT gs.v AS g, count() AS n, min(vs.v) AS lo, max(vs.v) AS hi, + quantilesExact(0.25, 0.5, 0.75)(vs.v) AS q +FROM vs INNER JOIN gs ON gs.id = vs.id +GROUP BY g ORDER BY n DESC LIMIT 151 + +-- view 1 plot: plot:coverage · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + cases AS (SELECT DISTINCT replaceOne(sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort)), + xs AS (SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS alt_case, multiIf(countIf(g.variant_type = 'mutation') = 0, 'Not mutated', length(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation')) > 1, 'Multiple', arrayElement(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation'), 1)) AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol IN ('TP53') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case)), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND attribute_name = 'FRACTION_GENOME_ALTERED' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived cd + JOIN snapshot_db.sample_derived sd ON sd.patient_unique_id = cd.patient_unique_id + WHERE cd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND cd.attribute_name = 'FRACTION_GENOME_ALTERED' AND cd.attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) IS NOT NULL + AND cd.type = 'patient' AND replaceOne(cd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT count() AS total, countIf(id IN (SELECT id FROM xs)) AS nx, countIf(id IN (SELECT id FROM ys)) AS ny FROM cases + +-- view 1 plot: plot:points · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND attribute_name = 'FRACTION_GENOME_ALTERED' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived cd + JOIN snapshot_db.sample_derived sd ON sd.patient_unique_id = cd.patient_unique_id + WHERE cd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND cd.attribute_name = 'FRACTION_GENOME_ALTERED' AND cd.attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) IS NOT NULL + AND cd.type = 'patient' AND replaceOne(cd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS alt_case, multiIf(countIf(g.variant_type = 'mutation') = 0, 'Not mutated', length(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation')) > 1, 'Multiple', arrayElement(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation'), 1)) AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol IN ('TP53') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case)) +SELECT vs.id AS id, gs.v AS g, vs.v AS v +FROM vs INNER JOIN gs ON gs.id = vs.id +LIMIT 10001 + +-- view 1 plot: plot:violin · brca_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND attribute_name = 'FRACTION_GENOME_ALTERED' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived cd + JOIN snapshot_db.sample_derived sd ON sd.patient_unique_id = cd.patient_unique_id + WHERE cd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND cd.attribute_name = 'FRACTION_GENOME_ALTERED' AND cd.attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(cd.attribute_value), nan)), toFloat64OrNull(cd.attribute_value), NULL) IS NOT NULL + AND cd.type = 'patient' AND replaceOne(cd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT alt_case AS id, if(hits = 0 AND NOT (alt_case IN (SELECT profiled_id FROM (SELECT DISTINCT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS profiled_id + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))))), 'Not profiled', v0) AS v FROM ( +SELECT replaceOne(sd.sample_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') AS alt_case, multiIf(countIf(g.variant_type = 'mutation') = 0, 'Not mutated', length(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation')) > 1, 'Multiple', arrayElement(groupUniqArrayIf(multiIf(lower(g.mutation_type) LIKE 'missense%', 'Missense', lower(g.mutation_type) LIKE 'nonsense%' OR lower(g.mutation_type) LIKE 'frame_shift%' OR lower(g.mutation_type) LIKE 'nonstop%', 'Truncating', lower(g.mutation_type) LIKE 'splice%', 'Splice', lower(g.mutation_type) LIKE 'in_frame%', 'Inframe', lower(g.mutation_type) LIKE '5''flank%' OR lower(g.mutation_type) LIKE 'promoter%', 'Promoter', 'Other'), g.variant_type = 'mutation'), 1)) AS v0, countIf(g.variant_type = 'mutation') AS hits +FROM snapshot_db.sample_derived sd +LEFT JOIN ( + SELECT sample_unique_id, mutation_type, variant_type, cna_alteration + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND hugo_gene_symbol IN ('TP53') + AND mutation_status != 'UNCALLED' +) g ON g.sample_unique_id = sd.sample_unique_id +WHERE sd.cancer_study_identifier = 'brca_tcga_pan_can_atlas_2018' AND replaceOne(sd.patient_unique_id, 'brca_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +GROUP BY alt_case)), + j AS (SELECT gs.v AS g, vs.v AS x FROM vs INNER JOIN gs ON gs.id = vs.id), + e AS (SELECT quantileExact(0.005)(x) x0, quantileExact(0.995)(x) x1 FROM j) +SELECT g, least(39, toUInt32(floor((x - x0) / nullIf(x1 - x0, 0) * 40))) AS b, count() AS n, any(x0) AS vx0, any(x1) AS vx1 +FROM j, e GROUP BY g, b diff --git a/test/snapshots/plot.svg b/test/snapshots/plot.svg new file mode 100644 index 0000000..6af087a --- /dev/null +++ b/test/snapshots/plot.svg @@ -0,0 +1,4 @@ + +Plot — ERBB2: mRNA expression z-scores relative to all samples (log RNA Seq V2 RSEM) by ERBB2: Putative copy-number alterations from GISTIC−4−202ERBB2: mRNA expression z-scores relative to all samples (log RNA Seq V2 RSEM)ERBB2: mRNA expression z-scores relative to all samples (log RNA…Shallow deletion: median −0.659, quartiles −0.951–−0.408, n = 260Diploid: median −0.118, quartiles −0.419–0.152, n = 480Gain: median 0.159, quartiles −0.23–0.415, n = 206Amplification: median 2.33, quartiles 1.45–2.81, n = 122Shallow deletion (260)Diploid (480)Gain (206)Amplification (122)ERBB2: Putative copy-number alterations from GISTIC1,068 of 1,084 samples have a value on both axes (14 have no ERBB2: Putative copy-number alterations from GISTIC; 2 have no ERBB2: mRNA expression z-scoresrelative to all samples (log RNA Seq V2 RSEM)); only those are drawn. Point layers — outliers: not drawn, at or under 10,000 cases there is no density for them to standout of. Box: quartiles with Tukey whiskers, computed over every case in the group; each name carries its count. Every value is drawn over its box; the jitter is fixed percase. + +Plot — FRACTION_GENOME_ALTERED by TP53 mutation type0.00.20.40.60.81.0FRACTION_GENOME_ALTEREDNot mutated: median 0.195, quartiles 0.105–0.346, n = 706Missense: median 0.38, quartiles 0.262–0.522, n = 209Truncating: median 0.466, quartiles 0.298–0.618, n = 102Splice: median 0.468, quartiles 0.237–0.538, n = 24Not profiled: median 0.106, quartiles 0.0052–0.168, n = 18Inframe: median 0.274, quartiles 0.255–0.481, n = 5Multiple: median 0.628, quartiles 0.462–0.651, n = 4Not mutated (706)Missense (209)Truncating (102)Splice (24)Not profiled (18)Inframe (5)Multiple (4)TP53 mutation type1,068 of 1,084 samples have a value on both axes (16 have no FRACTION_GENOME_ALTERED); only those are drawn. Point layers — outliers: not drawn, at or under10,000 cases there is no density for them to stand out of. Box: quartiles with Tukey whiskers, computed over every case in the group; each name carries its count. Everyvalue is drawn over its box; the jitter is fixed per case. diff --git a/test/snapshots/plot.txt b/test/snapshots/plot.txt new file mode 100644 index 0000000..c4a855b --- /dev/null +++ b/test/snapshots/plot.txt @@ -0,0 +1,23 @@ +Analysis over brca_tcga_pan_can_atlas_2018 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- all samples: 1,084 patients — all patients in the study + +Plot (box): ERBB2: mRNA expression z-scores relative to all samples (log RNA Seq V2 RSEM) by ERBB2: Putative copy-number alterations from GISTIC — 1,068 samples. + Shallow deletion: median -0.66 (IQR -0.95–-0.41, whiskers -1.77–0.35, n=260) + Diploid: median -0.12 (IQR -0.42–0.15, whiskers -1.27–1.01, n=480) + Gain: median 0.16 (IQR -0.23–0.41, whiskers -1.20–1.38, n=206) + Amplification: median 2.33 (IQR 1.45–2.81, whiskers -0.60–3.72, n=122) + Values are drawn as individual points. + 1,068 of 1,084 samples have a value on both axes (14 have no ERBB2: Putative copy-number alterations from GISTIC; 2 have no ERBB2: mRNA expression z-scores relative to all samples (log RNA Seq V2 RSEM)); only those are drawn. Point layers — outliers: not drawn, at or under 10,000 cases there is no density for them to stand out of. + +Plot (box): FRACTION_GENOME_ALTERED by TP53 mutation type — 1,068 samples. + Not mutated: median 0.19 (IQR 0.10–0.35, whiskers 0.00–0.71, n=706) + Missense: median 0.38 (IQR 0.26–0.52, whiskers 0.00–0.91, n=209) + Truncating: median 0.47 (IQR 0.30–0.62, whiskers 0.00–0.95, n=102) + Splice: median 0.47 (IQR 0.24–0.54, whiskers 0.00–0.83, n=24) + Not profiled: median 0.11 (IQR 0.01–0.17, whiskers 0.00–0.41, n=18) + Inframe: median 0.27 (IQR 0.25–0.48, whiskers 0.25–0.56, n=5) + Multiple: median 0.63 (IQR 0.46–0.65, whiskers 0.18–0.65, n=4) + Values are drawn as individual points. + 1,068 of 1,084 samples have a value on both axes (16 have no FRACTION_GENOME_ALTERED); only those are drawn. Point layers — outliers: not drawn, at or under 10,000 cases there is no density for them to stand out of. diff --git a/test/snapshots/pooled-paired.json b/test/snapshots/pooled-paired.json new file mode 100644 index 0000000..c1525ea --- /dev/null +++ b/test/snapshots/pooled-paired.json @@ -0,0 +1,431 @@ +{ + "study": "egc_msk_2017", + "cohorts": { + "before and after treatment": { + "count": 481, + "text": "all patients in the study — across 5 studies", + "studies": [ + "egc_msk_2017", + "breast_alpelisib_2020", + "egc_trap_ccr_msk_2023", + "blca_cornell_2016", + "brca_dldccc_2022" + ] + } + }, + "views": [ + { + "kind": "paired", + "cohorts": [ + "before and after treatment" + ], + "paired": { + "pairBy": { + "attribute": "IMPACT_PRE_POST", + "a": [ + "PRE-TX" + ], + "b": [ + "POST-TX" + ] + }, + "perStudy": { + "egc_msk_2017": { + "attribute": "IMPACT_PRE_POST", + "a": [ + "PRE-TX" + ], + "b": [ + "POST-TX" + ] + }, + "breast_alpelisib_2020": { + "attribute": "SAMPLE_COLLECTION_TIMEPOINT", + "a": [ + "pre-treatment" + ], + "b": [ + "post-treatment" + ] + }, + "egc_trap_ccr_msk_2023": { + "attribute": "PRE_OR_POST_TREATMENT", + "a": [ + "Pre" + ], + "b": [ + "Post" + ] + }, + "blca_cornell_2016": { + "attribute": "SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO", + "a": [ + "pre-chemotherapy" + ], + "b": [ + "post-chemotherapy" + ] + }, + "brca_dldccc_2022": { + "attribute": "TREATMENT_STATUS", + "a": [ + "Pre-Treatment" + ], + "b": [ + "Post-Treatment" + ] + } + }, + "labels": { + "a": "before", + "b": "after" + }, + "scan": { + "top": 12 + }, + "measure": "driver", + "panels": [ + { + "cohort": "before and after treatment", + "patients": 111, + "aSamples": 148, + "bSamples": 130, + "genes": [ + { + "gene": "CCND1", + "pairs": 95, + "both": 8, + "aOnly": 10, + "bOnly": 1, + "neither": 76, + "concordance": 0.421, + "p": 0.011718749999999981, + "q": 1 + }, + { + "gene": "MYC", + "pairs": 111, + "both": 5, + "aOnly": 10, + "bOnly": 2, + "neither": 94, + "concordance": 0.294, + "p": 0.03857421875000008, + "q": 1 + }, + { + "gene": "ERBB3", + "pairs": 40, + "both": 0, + "aOnly": 5, + "bOnly": 0, + "neither": 35, + "concordance": 0, + "p": 0.0625, + "q": 1 + }, + { + "gene": "MTAP", + "pairs": 26, + "both": 2, + "aOnly": 5, + "bOnly": 0, + "neither": 19, + "concordance": 0.286, + "p": 0.0625, + "q": 1 + }, + { + "gene": "TP53", + "pairs": 111, + "both": 52, + "aOnly": 10, + "bOnly": 3, + "neither": 46, + "concordance": 0.8, + "p": 0.09228515625000008, + "q": 1 + }, + { + "gene": "CDH1", + "pairs": 39, + "both": 2, + "aOnly": 4, + "bOnly": 0, + "neither": 33, + "concordance": 0.333, + "p": 0.125, + "q": 1 + }, + { + "gene": "FOXP1", + "pairs": 41, + "both": 0, + "aOnly": 0, + "bOnly": 4, + "neither": 37, + "concordance": 0, + "p": 0.125, + "q": 1 + }, + { + "gene": "FGFR1", + "pairs": 85, + "both": 3, + "aOnly": 6, + "bOnly": 1, + "neither": 75, + "concordance": 0.3, + "p": 0.12500000000000006, + "q": 1 + }, + { + "gene": "RSPO2", + "pairs": 32, + "both": 1, + "aOnly": 6, + "bOnly": 1, + "neither": 24, + "concordance": 0.125, + "p": 0.12500000000000006, + "q": 1 + }, + { + "gene": "LMNA", + "pairs": 42, + "both": 1, + "aOnly": 5, + "bOnly": 1, + "neither": 35, + "concordance": 0.143, + "p": 0.21875000000000017, + "q": 1 + }, + { + "gene": "BAALC", + "pairs": 42, + "both": 1, + "aOnly": 8, + "bOnly": 3, + "neither": 30, + "concordance": 0.083, + "p": 0.2265625000000001, + "q": 1 + }, + { + "gene": "UBR5", + "pairs": 42, + "both": 1, + "aOnly": 8, + "bOnly": 3, + "neither": 30, + "concordance": 0.083, + "p": 0.2265625000000001, + "q": 1 + } + ], + "tested": 278 + } + ] + }, + "participation": { + "studies": [ + { + "study": "egc_msk_2017", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "breast_alpelisib_2020", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "egc_trap_ccr_msk_2023", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "blca_cornell_2016", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "brca_dldccc_2022", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "studies": [ + "egc_msk_2017", + "breast_alpelisib_2020", + "egc_trap_ccr_msk_2023", + "blca_cornell_2016", + "brca_dldccc_2022" + ], + "caveat": "Within patients with samples on both sides, before and after (egc_msk_2017: IMPACT_PRE_POST PRE-TX vs POST-TX; breast_alpelisib_2020: SAMPLE_COLLECTION_TIMEPOINT pre-treatment vs post-treatment; egc_trap_ccr_msk_2023: PRE_OR_POST_TREATMENT Pre vs Post; blca_cornell_2016: SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO pre-chemotherapy vs post-chemotherapy; brca_dldccc_2022: TREATMENT_STATUS Pre-Treatment vs Post-Treatment; before and after treatment: 111 patients), per gene, among those profiled for it on BOTH sides by each side's own panels: an OncoKB driver (v7.5) on both sides, on the before side only, or the after side only; a patient with several samples on a side counts as altered there if any is. Concordance is both ÷ altered anywhere. The exact McNemar test asks whether discordance runs one way; q is Benjamini–Hochberg across the genes of each cohort. Genes were not chosen in advance: every gene with a driver in some paired patient was tested (before and after treatment: 278 genes with a discordant patient), q is taken across all of them, and the 12 most one-sided are drawn — at these sizes, read the counts, not only the q. Sides are as each study labels its samples; after-only means seen on that side and not the other, which is not proof it arose or vanished in between — a subclone one biopsy missed, or a lower-purity sample (common after treatment) under-calling its side, reads the same; and patients sampled twice are a selected group, typically with longer or harder disease courses. Counts are summed across 5 studies.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count each gene's state in paired samples", + "detail": "The paired:patients and paired:genes queries above. Patients with both a SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO = pre-chemotherapy sample (before) and a SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO = post-chemotherapy sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only.", + "scope": "before and after treatment · blca_cornell_2016", + "rowsIn": 32 + }, + { + "kind": "fetch", + "title": "Count each gene's state in paired samples", + "detail": "The paired:patients and paired:genes queries above. Patients with both a TREATMENT_STATUS = Pre-Treatment sample (before) and a TREATMENT_STATUS = Post-Treatment sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only.", + "scope": "before and after treatment · brca_dldccc_2022", + "rowsIn": 59 + }, + { + "kind": "fetch", + "title": "Count each gene's state in paired samples", + "detail": "The paired:patients and paired:genes queries above. Patients with both a SAMPLE_COLLECTION_TIMEPOINT = pre-treatment sample (before) and a SAMPLE_COLLECTION_TIMEPOINT = post-treatment sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only.", + "scope": "before and after treatment · breast_alpelisib_2020", + "rowsIn": 51 + }, + { + "kind": "fetch", + "title": "Count each gene's state in paired samples", + "detail": "The paired:patients and paired:genes queries above. Patients with both a IMPACT_PRE_POST = PRE-TX sample (before) and a IMPACT_PRE_POST = POST-TX sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only.", + "scope": "before and after treatment · egc_msk_2017", + "rowsIn": 305 + }, + { + "kind": "fetch", + "title": "Count each gene's state in paired samples", + "detail": "The paired:patients and paired:genes queries above. Patients with both a PRE_OR_POST_TREATMENT = Pre sample (before) and a PRE_OR_POST_TREATMENT = Post sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only.", + "scope": "before and after treatment · egc_trap_ccr_msk_2023", + "rowsIn": 34 + }, + { + "kind": "transform", + "title": "Add each cohort's counts across its studies", + "detail": "The counts add exactly." + }, + { + "kind": "statistic", + "title": "Exact McNemar test per gene", + "detail": "Only the discordant patients carry information about direction: of the before-only and after-only patients, each is a fair coin under the null, so p is twice the smaller binomial tail (capped at 1). Concordance is both ÷ altered anywhere.", + "params": [ + [ + "before and after treatment", + "111 patients with both kinds of sample" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across genes, per cohort", + "detail": "q-values over the genes with at least one discordant patient, separately for each cohort. In a scan that is every such gene, not only the ones drawn." + }, + { + "kind": "transform", + "title": "Draw the 12 most one-sided genes", + "detail": "Of the genes with a discordant patient, ordered by McNemar p, then by the size of the imbalance between before-only and after-only patients, then by the number of discordant patients, then by name; the first 12 are drawn and reported.", + "params": [ + [ + "before and after treatment", + "278 genes tested" + ] + ] + } + ], + "implementation": { + "functions": [ + "mcnemarExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "The exact McNemar test matches statsmodels 0.15.0 mcnemar(exact=True) and Benjamini–Hochberg multipletests, to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "paired:before and after treatment:CCND1:p": { + "v": 0.011718749999999981 + }, + "paired:before and after treatment:CCND1:q": { + "v": 1 + }, + "paired:before and after treatment:MYC:p": { + "v": 0.03857421875000008 + }, + "paired:before and after treatment:MYC:q": { + "v": 1 + }, + "paired:before and after treatment:ERBB3:p": { + "v": 0.0625 + }, + "paired:before and after treatment:ERBB3:q": { + "v": 1 + }, + "paired:before and after treatment:MTAP:p": { + "v": 0.0625 + }, + "paired:before and after treatment:MTAP:q": { + "v": 1 + }, + "paired:before and after treatment:TP53:p": { + "v": 0.09228515625000008 + }, + "paired:before and after treatment:TP53:q": { + "v": 1 + }, + "paired:before and after treatment:CDH1:p": { + "v": 0.125 + }, + "paired:before and after treatment:CDH1:q": { + "v": 1 + }, + "paired:before and after treatment:FOXP1:p": { + "v": 0.125 + }, + "paired:before and after treatment:FOXP1:q": { + "v": 1 + }, + "paired:before and after treatment:FGFR1:p": { + "v": 0.12500000000000006 + }, + "paired:before and after treatment:FGFR1:q": { + "v": 1 + }, + "paired:before and after treatment:RSPO2:p": { + "v": 0.12500000000000006 + }, + "paired:before and after treatment:RSPO2:q": { + "v": 1 + }, + "paired:before and after treatment:LMNA:p": { + "v": 0.21875000000000017 + }, + "paired:before and after treatment:LMNA:q": { + "v": 1 + }, + "paired:before and after treatment:BAALC:p": { + "v": 0.2265625000000001 + }, + "paired:before and after treatment:BAALC:q": { + "v": 1 + }, + "paired:before and after treatment:UBR5:p": { + "v": 0.2265625000000001 + }, + "paired:before and after treatment:UBR5:q": { + "v": 1 + } + } + } + } + ] +} diff --git a/test/snapshots/pooled-paired.sql b/test/snapshots/pooled-paired.sql new file mode 100644 index 0000000..3fa2e52 --- /dev/null +++ b/test/snapshots/pooled-paired.sql @@ -0,0 +1,322 @@ +-- cohort before and after treatment +-- egc_msk_2017 +SELECT DISTINCT replaceOne(patient_unique_id, 'egc_msk_2017_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'egc_msk_2017' + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- breast_alpelisib_2020 +SELECT DISTINCT replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'breast_alpelisib_2020' + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- egc_trap_ccr_msk_2023 +SELECT DISTINCT replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'egc_trap_ccr_msk_2023' + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- blca_cornell_2016 +SELECT DISTINCT replaceOne(patient_unique_id, 'blca_cornell_2016_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'blca_cornell_2016' + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- brca_dldccc_2022 +SELECT DISTINCT replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_dldccc_2022' + +-- view 0 paired: paired:genes:before and after treatment · blca_cornell_2016 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'blca_cornell_2016_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'blca_cornell_2016'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'blca_cornell_2016_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('pre-chemotherapy'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('post-chemotherapy'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'blca_cornell_2016' AND type = 'sample' AND attribute_name = 'SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO' + AND replaceOne(patient_unique_id, 'blca_cornell_2016_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)), +alt AS ( + SELECT g.hugo_gene_symbol AS gene, ps.pid AS pid, ps.side AS side, max(ann.is_driver) AS hit + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + INNER JOIN ps ON ps.suid = g.sample_unique_id + WHERE g.cancer_study_identifier = 'blca_cornell_2016' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM ps) + GROUP BY gene, pid, side + HAVING hit > 0 +), +cov AS ( + SELECT DISTINCT pg.gene AS gene, ps.pid AS pid, ps.side AS side + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT DISTINCT gene FROM alt) + INNER JOIN ps ON ps.suid = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'blca_cornell_2016' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') +), +per AS ( + SELECT gene, pid, max(side = 'a') AS pa, max(side = 'b') AS pb, + max(side = 'a' AND hit > 0) AS aa, max(side = 'b' AND hit > 0) AS ab + FROM (SELECT gene, pid, side, hit FROM alt UNION ALL SELECT gene, pid, side, 0 AS hit FROM cov) + GROUP BY gene, pid +) +SELECT gene, count() AS pairs, countIf(aa AND ab) AS both, countIf(aa AND NOT ab) AS a_only, countIf(ab AND NOT aa) AS b_only +FROM per WHERE pa AND pb GROUP BY gene HAVING both + a_only + b_only > 0 + +-- view 0 paired: paired:genes:before and after treatment · brca_dldccc_2022 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_dldccc_2022'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pre-Treatment'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Post-Treatment'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_dldccc_2022' AND type = 'sample' AND attribute_name = 'TREATMENT_STATUS' + AND replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)), +alt AS ( + SELECT g.hugo_gene_symbol AS gene, ps.pid AS pid, ps.side AS side, max(ann.is_driver) AS hit + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + INNER JOIN ps ON ps.suid = g.sample_unique_id + WHERE g.cancer_study_identifier = 'brca_dldccc_2022' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM ps) + GROUP BY gene, pid, side + HAVING hit > 0 +), +cov AS ( + SELECT DISTINCT pg.gene AS gene, ps.pid AS pid, ps.side AS side + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT DISTINCT gene FROM alt) + INNER JOIN ps ON ps.suid = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'brca_dldccc_2022' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') +), +per AS ( + SELECT gene, pid, max(side = 'a') AS pa, max(side = 'b') AS pb, + max(side = 'a' AND hit > 0) AS aa, max(side = 'b' AND hit > 0) AS ab + FROM (SELECT gene, pid, side, hit FROM alt UNION ALL SELECT gene, pid, side, 0 AS hit FROM cov) + GROUP BY gene, pid +) +SELECT gene, count() AS pairs, countIf(aa AND ab) AS both, countIf(aa AND NOT ab) AS a_only, countIf(ab AND NOT aa) AS b_only +FROM per WHERE pa AND pb GROUP BY gene HAVING both + a_only + b_only > 0 + +-- view 0 paired: paired:genes:before and after treatment · breast_alpelisib_2020 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'breast_alpelisib_2020'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('pre-treatment'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('post-treatment'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'breast_alpelisib_2020' AND type = 'sample' AND attribute_name = 'SAMPLE_COLLECTION_TIMEPOINT' + AND replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)), +alt AS ( + SELECT g.hugo_gene_symbol AS gene, ps.pid AS pid, ps.side AS side, max(ann.is_driver) AS hit + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + INNER JOIN ps ON ps.suid = g.sample_unique_id + WHERE g.cancer_study_identifier = 'breast_alpelisib_2020' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM ps) + GROUP BY gene, pid, side + HAVING hit > 0 +), +cov AS ( + SELECT DISTINCT pg.gene AS gene, ps.pid AS pid, ps.side AS side + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT DISTINCT gene FROM alt) + INNER JOIN ps ON ps.suid = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'breast_alpelisib_2020' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') +), +per AS ( + SELECT gene, pid, max(side = 'a') AS pa, max(side = 'b') AS pb, + max(side = 'a' AND hit > 0) AS aa, max(side = 'b' AND hit > 0) AS ab + FROM (SELECT gene, pid, side, hit FROM alt UNION ALL SELECT gene, pid, side, 0 AS hit FROM cov) + GROUP BY gene, pid +) +SELECT gene, count() AS pairs, countIf(aa AND ab) AS both, countIf(aa AND NOT ab) AS a_only, countIf(ab AND NOT aa) AS b_only +FROM per WHERE pa AND pb GROUP BY gene HAVING both + a_only + b_only > 0 + +-- view 0 paired: paired:genes:before and after treatment · egc_msk_2017 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'egc_msk_2017_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'egc_msk_2017'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'egc_msk_2017_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('PRE-TX'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('POST-TX'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'egc_msk_2017' AND type = 'sample' AND attribute_name = 'IMPACT_PRE_POST' + AND replaceOne(patient_unique_id, 'egc_msk_2017_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)), +alt AS ( + SELECT g.hugo_gene_symbol AS gene, ps.pid AS pid, ps.side AS side, max(ann.is_driver) AS hit + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + INNER JOIN ps ON ps.suid = g.sample_unique_id + WHERE g.cancer_study_identifier = 'egc_msk_2017' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM ps) + GROUP BY gene, pid, side + HAVING hit > 0 +), +cov AS ( + SELECT DISTINCT pg.gene AS gene, ps.pid AS pid, ps.side AS side + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT DISTINCT gene FROM alt) + INNER JOIN ps ON ps.suid = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'egc_msk_2017' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') +), +per AS ( + SELECT gene, pid, max(side = 'a') AS pa, max(side = 'b') AS pb, + max(side = 'a' AND hit > 0) AS aa, max(side = 'b' AND hit > 0) AS ab + FROM (SELECT gene, pid, side, hit FROM alt UNION ALL SELECT gene, pid, side, 0 AS hit FROM cov) + GROUP BY gene, pid +) +SELECT gene, count() AS pairs, countIf(aa AND ab) AS both, countIf(aa AND NOT ab) AS a_only, countIf(ab AND NOT aa) AS b_only +FROM per WHERE pa AND pb GROUP BY gene HAVING both + a_only + b_only > 0 + +-- view 0 paired: paired:genes:before and after treatment · egc_trap_ccr_msk_2023 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'egc_trap_ccr_msk_2023'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pre'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Post'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'egc_trap_ccr_msk_2023' AND type = 'sample' AND attribute_name = 'PRE_OR_POST_TREATMENT' + AND replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)), +alt AS ( + SELECT g.hugo_gene_symbol AS gene, ps.pid AS pid, ps.side AS side, max(ann.is_driver) AS hit + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + INNER JOIN ps ON ps.suid = g.sample_unique_id + WHERE g.cancer_study_identifier = 'egc_trap_ccr_msk_2023' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND g.sample_unique_id IN (SELECT suid FROM ps) + GROUP BY gene, pid, side + HAVING hit > 0 +), +cov AS ( + SELECT DISTINCT pg.gene AS gene, ps.pid AS pid, ps.side AS side + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT DISTINCT gene FROM alt) + INNER JOIN ps ON ps.suid = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'egc_trap_ccr_msk_2023' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') +), +per AS ( + SELECT gene, pid, max(side = 'a') AS pa, max(side = 'b') AS pb, + max(side = 'a' AND hit > 0) AS aa, max(side = 'b' AND hit > 0) AS ab + FROM (SELECT gene, pid, side, hit FROM alt UNION ALL SELECT gene, pid, side, 0 AS hit FROM cov) + GROUP BY gene, pid +) +SELECT gene, count() AS pairs, countIf(aa AND ab) AS both, countIf(aa AND NOT ab) AS a_only, countIf(ab AND NOT aa) AS b_only +FROM per WHERE pa AND pb GROUP BY gene HAVING both + a_only + b_only > 0 + +-- view 0 paired: paired:patients:before and after treatment · blca_cornell_2016 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'blca_cornell_2016_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'blca_cornell_2016'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'blca_cornell_2016_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('pre-chemotherapy'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('post-chemotherapy'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'blca_cornell_2016' AND type = 'sample' AND attribute_name = 'SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO' + AND replaceOne(patient_unique_id, 'blca_cornell_2016_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)) +SELECT uniqExact(pid) AS patients, countIf(side = 'a') AS a_samples, countIf(side = 'b') AS b_samples FROM ps + +-- view 0 paired: paired:patients:before and after treatment · brca_dldccc_2022 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'brca_dldccc_2022'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pre-Treatment'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Post-Treatment'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'brca_dldccc_2022' AND type = 'sample' AND attribute_name = 'TREATMENT_STATUS' + AND replaceOne(patient_unique_id, 'brca_dldccc_2022_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)) +SELECT uniqExact(pid) AS patients, countIf(side = 'a') AS a_samples, countIf(side = 'b') AS b_samples FROM ps + +-- view 0 paired: paired:patients:before and after treatment · breast_alpelisib_2020 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'breast_alpelisib_2020'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('pre-treatment'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('post-treatment'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'breast_alpelisib_2020' AND type = 'sample' AND attribute_name = 'SAMPLE_COLLECTION_TIMEPOINT' + AND replaceOne(patient_unique_id, 'breast_alpelisib_2020_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)) +SELECT uniqExact(pid) AS patients, countIf(side = 'a') AS a_samples, countIf(side = 'b') AS b_samples FROM ps + +-- view 0 paired: paired:patients:before and after treatment · egc_msk_2017 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'egc_msk_2017_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'egc_msk_2017'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'egc_msk_2017_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('PRE-TX'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('POST-TX'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'egc_msk_2017' AND type = 'sample' AND attribute_name = 'IMPACT_PRE_POST' + AND replaceOne(patient_unique_id, 'egc_msk_2017_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)) +SELECT uniqExact(pid) AS patients, countIf(side = 'a') AS a_samples, countIf(side = 'b') AS b_samples FROM ps + +-- view 0 paired: paired:patients:before and after treatment · egc_trap_ccr_msk_2023 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'egc_trap_ccr_msk_2023'), +sides AS ( + SELECT sample_unique_id AS suid, replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') AS pid, + multiIf(lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pre'))), 'a', lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Post'))), 'b', '') AS side + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'egc_trap_ccr_msk_2023' AND type = 'sample' AND attribute_name = 'PRE_OR_POST_TREATMENT' + AND replaceOne(patient_unique_id, 'egc_trap_ccr_msk_2023_', '') IN (SELECT pid FROM cohort) +), +paired AS (SELECT pid FROM sides GROUP BY pid HAVING countIf(side = 'a') > 0 AND countIf(side = 'b') > 0), +ps AS (SELECT suid, pid, side FROM sides WHERE side != '' AND pid IN (SELECT pid FROM paired)) +SELECT uniqExact(pid) AS patients, countIf(side = 'a') AS a_samples, countIf(side = 'b') AS b_samples FROM ps diff --git a/test/snapshots/pooled-paired.svg b/test/snapshots/pooled-paired.svg new file mode 100644 index 0000000..83ee2fe --- /dev/null +++ b/test/snapshots/pooled-paired.svg @@ -0,0 +1,2 @@ + +Paired samples — before vs afterbefore onlybothafter onlybefore and after treatment111 patients with both · 148 before and 130 after samples · 278 genes with a discordant patient, the 12 most one-sided drawnconcordantprofiled pairsMcNemar qCCND1CCND1 — 10 patients altered before only10CCND1 — 8 patients altered both8CCND1 — 1 patients altered after only42.1%951.00MYCMYC — 10 patients altered before only10MYC — 5 patients altered both5MYC — 2 patients altered after only229.4%1111.00ERBB3ERBB3 — 5 patients altered before only50%401.00MTAPMTAP — 5 patients altered before only5MTAP — 2 patients altered both228.6%261.00TP53TP53 — 10 patients altered before only10TP53 — 52 patients altered both52TP53 — 3 patients altered after only380.0%1111.00CDH1CDH1 — 4 patients altered before only4CDH1 — 2 patients altered both233.3%391.00FOXP1FOXP1 — 4 patients altered after only40%411.00FGFR1FGFR1 — 6 patients altered before only6FGFR1 — 3 patients altered both3FGFR1 — 1 patients altered after only30.0%851.00RSPO2RSPO2 — 6 patients altered before only6RSPO2 — 1 patients altered bothRSPO2 — 1 patients altered after only12.5%321.00LMNALMNA — 5 patients altered before only5LMNA — 1 patients altered bothLMNA — 1 patients altered after only14.3%421.00BAALCBAALC — 8 patients altered before only8BAALC — 1 patients altered bothBAALC — 3 patients altered after only38.3%421.00UBR5UBR5 — 8 patients altered before only8UBR5 — 1 patients altered bothUBR5 — 3 patients altered after only38.3%421.00010203040506070patients altered on either sideWithin patients with samples on both sides, before and after (egc_msk_2017: IMPACT_PRE_POST PRE-TX vs POST-TX; breast_alpelisib_2020:SAMPLE_COLLECTION_TIMEPOINT pre-treatment vs post-treatment; egc_trap_ccr_msk_2023: PRE_OR_POST_TREATMENT Pre vs Post; blca_cornell_2016:SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO pre-chemotherapy vs post-chemotherapy; brca_dldccc_2022: TREATMENT_STATUS Pre-Treatment vsPost-Treatment; before and after treatment: 111 patients), per gene, among those profiled for it on BOTH sides by each side's own panels: an OncoKB driver (v7.5) onboth sides, on the before side only, or the after side only; a patient with several samples on a side counts as altered there if any is. Concordance is both ÷ alteredanywhere. The exact McNemar test asks whether discordance runs one way; q is Benjamini–Hochberg across the genes of each cohort. Genes were not chosen inadvance: every gene with a driver in some paired patient was tested (before and after treatment: 278 genes with a discordant patient), q is taken across all of them, andthe 12 most one-sided are drawn — at these sizes, read the counts, not only the q. Sides are as each study labels its samples; after-only means seen on that side and notthe other, which is not proof it arose or vanished in between — a subclone one biopsy missed, or a lower-purity sample (common after treatment) under-calling its side,reads the same; and patients sampled twice are a selected group, typically with longer or harder disease courses. Counts are summed across 5 studies. diff --git a/test/snapshots/pooled-paired.txt b/test/snapshots/pooled-paired.txt new file mode 100644 index 0000000..326559b --- /dev/null +++ b/test/snapshots/pooled-paired.txt @@ -0,0 +1,33 @@ +Analysis over egc_msk_2017 + breast_alpelisib_2020 + egc_trap_ccr_msk_2023 + blca_cornell_2016 + brca_dldccc_2022 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- before and after treatment: 481 patients — all patients in the study — across 5 studies + +Paired samples, before vs after (egc_msk_2017: IMPACT_PRE_POST PRE-TX vs POST-TX; breast_alpelisib_2020: SAMPLE_COLLECTION_TIMEPOINT pre-treatment vs post-treatment; egc_trap_ccr_msk_2023: PRE_OR_POST_TREATMENT Pre vs Post; blca_cornell_2016: SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO pre-chemotherapy vs post-chemotherapy; brca_dldccc_2022: TREATMENT_STATUS Pre-Treatment vs Post-Treatment; drivers; profiled on both sides): + before and after treatment (111 patients with both; scanned 278 genes with a discordant patient, the 12 most one-sided listed): + CCND1: both 8, before-only 10, after-only 1 of 95 pairs, 42% concordant, McNemar q=1.0000 + MYC: both 5, before-only 10, after-only 2 of 111 pairs, 29% concordant, McNemar q=1.0000 + ERBB3: both 0, before-only 5, after-only 0 of 40 pairs, 0% concordant, McNemar q=1.0000 + MTAP: both 2, before-only 5, after-only 0 of 26 pairs, 29% concordant, McNemar q=1.0000 + TP53: both 52, before-only 10, after-only 3 of 111 pairs, 80% concordant, McNemar q=1.0000 + CDH1: both 2, before-only 4, after-only 0 of 39 pairs, 33% concordant, McNemar q=1.0000 + FOXP1: both 0, before-only 0, after-only 4 of 41 pairs, 0% concordant, McNemar q=1.0000 + FGFR1: both 3, before-only 6, after-only 1 of 85 pairs, 30% concordant, McNemar q=1.0000 + RSPO2: both 1, before-only 6, after-only 1 of 32 pairs, 13% concordant, McNemar q=1.0000 + LMNA: both 1, before-only 5, after-only 1 of 42 pairs, 14% concordant, McNemar q=1.0000 + BAALC: both 1, before-only 8, after-only 3 of 42 pairs, 8% concordant, McNemar q=1.0000 + UBR5: both 1, before-only 8, after-only 3 of 42 pairs, 8% concordant, McNemar q=1.0000 + CAVEAT (tell the user): Within patients with samples on both sides, before and after (egc_msk_2017: IMPACT_PRE_POST PRE-TX vs POST-TX; breast_alpelisib_2020: SAMPLE_COLLECTION_TIMEPOINT pre-treatment vs post-treatment; egc_trap_ccr_msk_2023: PRE_OR_POST_TREATMENT Pre vs Post; blca_cornell_2016: SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO pre-chemotherapy vs post-chemotherapy; brca_dldccc_2022: TREATMENT_STATUS Pre-Treatment vs Post-Treatment; before and after treatment: 111 patients), per gene, among those profiled for it on BOTH sides by each side's own panels: an OncoKB driver (v7.5) on both sides, on the before side only, or the after side only; a patient with several samples on a side counts as altered there if any is. Concordance is both ÷ altered anywhere. The exact McNemar test asks whether discordance runs one way; q is Benjamini–Hochberg across the genes of each cohort. Genes were not chosen in advance: every gene with a driver in some paired patient was tested (before and after treatment: 278 genes with a discordant patient), q is taken across all of them, and the 12 most one-sided are drawn — at these sizes, read the counts, not only the q. Sides are as each study labels its samples; after-only means seen on that side and not the other, which is not proof it arose or vanished in between — a subclone one biopsy missed, or a lower-purity sample (common after treatment) under-calling its side, reads the same; and patients sampled twice are a selected group, typically with longer or harder disease courses. Counts are summed across 5 studies. + METHOD: + - Count each gene's state in paired samples [before and after treatment · blca_cornell_2016]: The paired:patients and paired:genes queries above. Patients with both a SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO = pre-chemotherapy sample (before) and a SPECIMEN_COLLECTION_PRE_OR_POST_CHEMO = post-chemotherapy sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only. + - Count each gene's state in paired samples [before and after treatment · brca_dldccc_2022]: The paired:patients and paired:genes queries above. Patients with both a TREATMENT_STATUS = Pre-Treatment sample (before) and a TREATMENT_STATUS = Post-Treatment sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only. + - Count each gene's state in paired samples [before and after treatment · breast_alpelisib_2020]: The paired:patients and paired:genes queries above. Patients with both a SAMPLE_COLLECTION_TIMEPOINT = pre-treatment sample (before) and a SAMPLE_COLLECTION_TIMEPOINT = post-treatment sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only. + - Count each gene's state in paired samples [before and after treatment · egc_msk_2017]: The paired:patients and paired:genes queries above. Patients with both a IMPACT_PRE_POST = PRE-TX sample (before) and a IMPACT_PRE_POST = POST-TX sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only. + - Count each gene's state in paired samples [before and after treatment · egc_trap_ccr_msk_2023]: The paired:patients and paired:genes queries above. Patients with both a PRE_OR_POST_TREATMENT = Pre sample (before) and a PRE_OR_POST_TREATMENT = Post sample (after); per gene — every gene altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) in some such patient, among those profiled for it on both sides by each side's own panels: altered (an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5)) on both sides, on the before side only, or the after side only. A patient with several samples on one side counts as altered there if any is. Counts only. + - Add each cohort's counts across its studies: The counts add exactly. + - Exact McNemar test per gene: Only the discordant patients carry information about direction: of the before-only and after-only patients, each is a fair coin under the null, so p is twice the smaller binomial tail (capped at 1). Concordance is both ÷ altered anywhere. + before and after treatment: 111 patients with both kinds of sample + - Benjamini–Hochberg across genes, per cohort: q-values over the genes with at least one discordant patient, separately for each cohort. In a scan that is every such gene, not only the ones drawn. + - Draw the 12 most one-sided genes: Of the genes with a discordant patient, ordered by McNemar p, then by the size of the imbalance between before-only and after-only patients, then by the number of discordant patients, then by name; the first 12 are drawn and reported. + before and after treatment: 278 genes tested + The exact McNemar test matches statsmodels 0.15.0 mcnemar(exact=True) and Benjamini–Hochberg multipletests, to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/riskmodel.json b/test/snapshots/riskmodel.json new file mode 100644 index 0000000..52279e3 --- /dev/null +++ b/test/snapshots/riskmodel.json @@ -0,0 +1,1242 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "NSCLC": { + "count": 7809, + "text": "CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "riskmodel", + "cohorts": [ + "NSCLC" + ], + "riskmodel": { + "study": "msk_chord_2024", + "n": 7809, + "events": 3975, + "notProfiled": 0, + "noStratum": 0, + "noCovariate": 0, + "noAnchor": 0, + "anchorAfterStart": 0, + "noFollowUp": 0, + "neverHeldOut": 1030, + "genesCovered": 341, + "candidates": 302, + "minMutated": 30, + "strata": null, + "strataLevels": 1, + "alpha": 0.5, + "runs": 5, + "seed": 1, + "measure": "any", + "anchoredTo": null, + "covariates": [], + "reportedOn": "held-out scores", + "validation": null, + "cIndex": { + "median": 0.6168658411216869, + "q1": 0.6151719755125308, + "q3": 0.618345332800991, + "values": [ + 0.6214956921331086, + 0.6168658411216869, + 0.6151719755125308, + 0.618345332800991, + 0.6083696410339355 + ] + }, + "features": [ + { + "gene": "TGFBR2", + "selected": 1, + "meanCoef": 0.3756881858515356, + "hr": 1.4559930637446943, + "mutated": 125 + }, + { + "gene": "TP53", + "selected": 1, + "meanCoef": 0.31460371046368396, + "hr": 1.3697163991122716, + "mutated": 4020 + }, + { + "gene": "KEAP1", + "selected": 1, + "meanCoef": 0.3128501747692992, + "hr": 1.3673166571467523, + "mutated": 1034 + }, + { + "gene": "SMARCA4", + "selected": 1, + "meanCoef": 0.23974131124443848, + "hr": 1.2709203349929472, + "mutated": 580 + }, + { + "gene": "STK11", + "selected": 1, + "meanCoef": 0.1966908730185321, + "hr": 1.2173676613439097, + "mutated": 1013 + }, + { + "gene": "NFE2L2", + "selected": 1, + "meanCoef": 0.15483221149577558, + "hr": 1.167462057957993, + "mutated": 238 + }, + { + "gene": "PTEN", + "selected": 1, + "meanCoef": 0.1286962187398602, + "hr": 1.1373445677156082, + "mutated": 259 + }, + { + "gene": "EGFR", + "selected": 1, + "meanCoef": -0.08508582323173386, + "hr": 0.9184334580914355, + "mutated": 1893 + }, + { + "gene": "CDK8", + "selected": 1, + "meanCoef": -0.07534218635470528, + "hr": 0.9274260794761086, + "mutated": 44 + }, + { + "gene": "EP300", + "selected": 1, + "meanCoef": 0.06877399418061789, + "hr": 1.0711940856916677, + "mutated": 220 + }, + { + "gene": "EPHA3", + "selected": 1, + "meanCoef": -0.0672742684609782, + "hr": 0.9349387419591588, + "mutated": 426 + }, + { + "gene": "PTPRD", + "selected": 1, + "meanCoef": -0.06696238120110658, + "hr": 0.9352303829187221, + "mutated": 644 + }, + { + "gene": "MED12", + "selected": 1, + "meanCoef": -0.044966872238501335, + "hr": 0.9560291524142562, + "mutated": 351 + }, + { + "gene": "CDK12", + "selected": 0.8, + "meanCoef": -0.1382875833756819, + "hr": 0.8708482142617805, + "mutated": 142 + }, + { + "gene": "DNMT3A", + "selected": 0.8, + "meanCoef": -0.11856603310660155, + "hr": 0.8881931635664834, + "mutated": 166 + }, + { + "gene": "ARID1B", + "selected": 0.8, + "meanCoef": -0.10316294144105707, + "hr": 0.901979991587487, + "mutated": 232 + }, + { + "gene": "ARAF", + "selected": 0.8, + "meanCoef": -0.10282008859918007, + "hr": 0.9022892910099821, + "mutated": 117 + }, + { + "gene": "MTOR", + "selected": 0.8, + "meanCoef": -0.08044178634429665, + "hr": 0.9227086162620373, + "mutated": 225 + }, + { + "gene": "NF2", + "selected": 0.8, + "meanCoef": 0.07117741354289957, + "hr": 1.0737717106140163, + "mutated": 106 + }, + { + "gene": "INPP4A", + "selected": 0.8, + "meanCoef": 0.06763303017865392, + "hr": 1.0699725887752938, + "mutated": 107 + }, + { + "…": "78 more", + "sha256": "31256c9241742517" + } + ], + "groups": [ + { + "name": "Low risk", + "from": null, + "to": 0, + "curve": { + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0.032876676, + "s": 0.9983 + }, + { + "t": 0.065753353, + "s": 0.9979 + }, + { + "t": 0.197260058, + "s": 0.9974 + }, + { + "t": 0.230136734, + "s": 0.997 + }, + { + "t": 0.295890087, + "s": 0.9966 + }, + { + "t": 0.328766763, + "s": 0.9957 + }, + { + "t": 0.427396792, + "s": 0.9953 + }, + { + "t": 0.460273468, + "s": 0.9948 + }, + { + "t": 0.493150144, + "s": 0.9944 + }, + { + "t": 0.526026821, + "s": 0.9936 + }, + { + "t": 0.558903497, + "s": 0.9927 + }, + { + "t": 0.62465685, + "s": 0.9923 + }, + { + "t": 0.657533526, + "s": 0.9918 + }, + { + "t": 0.723286879, + "s": 0.9914 + }, + { + "t": 0.756163555, + "s": 0.991 + }, + { + "t": 0.789040231, + "s": 0.9901 + }, + { + "t": 0.821916907, + "s": 0.9892 + }, + { + "t": 0.88767026, + "s": 0.9884 + }, + { + "t": 0.986300289, + "s": 0.9879 + }, + { + "…": "656 more", + "sha256": "597e8b77a63e19b3" + } + ], + "median": 68.21910332, + "n": 2337, + "events": 888, + "atRisk": [ + 2337, + 2285, + 2241, + 2190, + 2155, + 2128, + 2091, + 2046, + 2005, + 1963, + 1910, + 1867, + 1827, + 1778, + 1740, + 1695, + 1650, + 1606, + 1559, + 1517, + { + "…": "94 more", + "sha256": "c1ec549af52c115e" + } + ] + }, + "at12": 0.8551, + "at36": 0.6636, + "hr": null, + "ciLow": null, + "ciHigh": null, + "p": null + }, + { + "name": "Intermediate risk", + "from": 0, + "to": 0.3016946233069857, + "curve": { + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0.032876676, + "s": 0.9982 + }, + { + "t": 0.065753353, + "s": 0.9972 + }, + { + "t": 0.328766763, + "s": 0.9968 + }, + { + "t": 0.361643439, + "s": 0.9963 + }, + { + "t": 0.394520116, + "s": 0.9959 + }, + { + "t": 0.427396792, + "s": 0.9949 + }, + { + "t": 0.460273468, + "s": 0.994 + }, + { + "t": 0.493150144, + "s": 0.9935 + }, + { + "t": 0.526026821, + "s": 0.9926 + }, + { + "t": 0.558903497, + "s": 0.9912 + }, + { + "t": 0.591780173, + "s": 0.9894 + }, + { + "t": 0.62465685, + "s": 0.9884 + }, + { + "t": 0.657533526, + "s": 0.9861 + }, + { + "t": 0.690410202, + "s": 0.9847 + }, + { + "t": 0.723286879, + "s": 0.9843 + }, + { + "t": 0.756163555, + "s": 0.9834 + }, + { + "t": 0.789040231, + "s": 0.9829 + }, + { + "t": 0.821916907, + "s": 0.9824 + }, + { + "t": 0.854793584, + "s": 0.9815 + }, + { + "…": "759 more", + "sha256": "9a18f3e94636fa66" + } + ], + "median": 36.98626084, + "n": 2175, + "events": 1150, + "atRisk": [ + 2175, + 2108, + 2056, + 1997, + 1950, + 1908, + 1855, + 1801, + 1756, + 1711, + 1661, + 1605, + 1537, + 1498, + 1451, + 1405, + 1359, + 1313, + 1268, + 1219, + { + "…": "97 more", + "sha256": "ed9647d7f9072bd9" + } + ] + }, + "at12": 0.7626, + "at36": 0.5084, + "hr": 1.5755715478534928, + "ciLow": 1.4434046285647977, + "ciHigh": 1.719840475275301, + "p": 2.6970793770066445e-24 + }, + { + "name": "High risk", + "from": 0.3016946233069857, + "to": null, + "curve": { + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0.032876676, + "s": 0.9965 + }, + { + "t": 0.065753353, + "s": 0.996 + }, + { + "t": 0.098630029, + "s": 0.9956 + }, + { + "t": 0.131506705, + "s": 0.9947 + }, + { + "t": 0.164383381, + "s": 0.9938 + }, + { + "t": 0.197260058, + "s": 0.9929 + }, + { + "t": 0.230136734, + "s": 0.9925 + }, + { + "t": 0.26301341, + "s": 0.9907 + }, + { + "t": 0.295890087, + "s": 0.989 + }, + { + "t": 0.328766763, + "s": 0.9867 + }, + { + "t": 0.361643439, + "s": 0.9859 + }, + { + "t": 0.394520116, + "s": 0.9854 + }, + { + "t": 0.427396792, + "s": 0.9845 + }, + { + "t": 0.460273468, + "s": 0.9832 + }, + { + "t": 0.493150144, + "s": 0.981 + }, + { + "t": 0.526026821, + "s": 0.9805 + }, + { + "t": 0.558903497, + "s": 0.9797 + }, + { + "t": 0.591780173, + "s": 0.9783 + }, + { + "t": 0.62465685, + "s": 0.9766 + }, + { + "…": "734 more", + "sha256": "f843665b5fb4c45f" + } + ], + "median": 20.31778595, + "n": 2267, + "events": 1431, + "atRisk": [ + 2267, + 2164, + 2057, + 1947, + 1857, + 1790, + 1709, + 1628, + 1561, + 1489, + 1424, + 1368, + 1307, + 1250, + 1200, + 1143, + 1104, + 1069, + 1035, + 1002, + { + "…": "99 more", + "sha256": "d3cd3d3ba9c1abf3" + } + ] + }, + "at12": 0.6209, + "at36": 0.3901, + "hr": 2.2598878966067, + "ciLow": 2.077954719367011, + "ciHigh": 2.4577500450949112, + "p": 8.061734792990592e-81 + } + ], + "logrank": { + "chi2": 379.7226, + "p": 3.5018315605795624e-83, + "df": 2, + "observed": [ + 888, + 1150, + 1431 + ], + "expected": [ + 1365.9, + 1125.1, + 978 + ], + "groups": 3, + "strata": 1 + }, + "refit": { + "hr": 1.3904716239341377, + "ciLow": 1.3472535345929453, + "ciHigh": 1.4350760917099337, + "p": 4.687807751477433e-93 + }, + "histogram": { + "edges": [ + -0.46686479339293296, + -0.40876662683751785, + -0.3506684602821028, + -0.2925702937266877, + -0.2344721271712726, + -0.17637396061585753, + -0.11827579406044242, + -0.060177627505027365, + -0.002079460949612255, + 0.0560187056058028, + 0.11411687216121791, + 0.17221503871663302, + 0.23031320527204813, + 0.28841137182746324, + 0.34650953838287823, + 0.40460770493829334, + 0.46270587149370845, + 0.5208040380491236, + 0.5789022046045386, + 0.6370003711599538, + { + "…": "11 more", + "sha256": "c3ad99b7e6276bd2" + } + ], + "counts": [ + 1, + 5, + 4, + 16, + 45, + 166, + 583, + 354, + 1354, + 123, + 211, + 652, + 779, + 923, + 235, + 227, + 301, + 224, + 183, + 102, + { + "…": "10 more", + "sha256": "880020771049fdd3" + } + ] + }, + "scale": { + "min": -0.46686479339293296, + "max": 1.2760802032695195 + }, + "percentiles": [ + -0.46686479339293296, + -0.17817287815254684, + -0.13648247976492528, + -0.12124255034660834, + -0.1161264952078239, + -0.10784998949097846, + -0.10002149261679096, + -0.09487424225057817, + -0.09294532893413712, + -0.08372990134348336, + -0.07362198929333243, + -0.07036126353885327, + -0.06216834088782731, + -0.0493925022411116, + -0.038108818914458234, + -0.022290963663375865, + -0.01651160609674337, + -0.006389513683834213, + 0, + 0, + { + "…": "81 more", + "sha256": "cabbd9271b8f0ccd" + } + ], + "labelAbove": 0.5, + "cutsChosen": null, + "table1": { + "reportedOn": "held-out scores", + "measure": "any", + "groups": [ + { + "name": "Low risk", + "n": 2337 + }, + { + "name": "Intermediate risk", + "n": 2175 + }, + { + "name": "High risk", + "n": 2267 + } + ], + "describe": { + "attributes": [ + "STAGE_HIGHEST_RECORDED", + "GENDER", + "SMOKING_PREDICTIONS_3_CLASSES", + "CURRENT_AGE_DEID" + ], + "genes": [ + "KEAP1", + "TP53", + "ZFHX3" + ] + }, + "defaults": { + "attributes": false, + "genes": false + }, + "rows": [ + { + "kind": "cat", + "name": "STAGE_HIGHEST_RECORDED", + "per": "patient", + "role": null, + "levels": [ + { + "value": "Stage 1-3", + "counts": [ + 1438, + 1103, + 1244 + ] + }, + { + "value": "Stage 4", + "counts": [ + 898, + 1072, + 1023 + ] + }, + { + "value": "Unknown", + "counts": [ + 1, + 0, + 0 + ] + } + ], + "missing": [ + 0, + 0, + 0 + ], + "multiValued": 0, + "minExpected": 0.32, + "test": "chi-squared", + "statistic": 56.918, + "df": 4, + "p": 1.2871847901160984e-11, + "q": 2.1453079835268308e-11 + }, + { + "kind": "cat", + "name": "GENDER", + "per": "patient", + "role": null, + "levels": [ + { + "value": "Female", + "counts": [ + 1561, + 1304, + 1095 + ] + }, + { + "value": "Male", + "counts": [ + 775, + 871, + 1172 + ] + }, + { + "value": "Unknown", + "counts": [ + 1, + 0, + 0 + ] + } + ], + "missing": [ + 0, + 0, + 0 + ], + "multiValued": 0, + "minExpected": 0.32, + "test": "chi-squared", + "statistic": 167.47, + "df": 4, + "p": 3.651083887973751e-35, + "q": 9.127709719934377e-35 + }, + { + "kind": "cat", + "name": "SMOKING_PREDICTIONS_3_CLASSES", + "per": "patient", + "role": null, + "levels": [ + { + "value": "Former/Current Smoker", + "counts": [ + 1325, + 1504, + 1875 + ] + }, + { + "value": "Never", + "counts": [ + 919, + 588, + 261 + ] + }, + { + "value": "Unknown", + "counts": [ + 93, + 83, + 131 + ] + } + ], + "missing": [ + 0, + 0, + 0 + ], + "multiValued": 0, + "minExpected": 98.5, + "test": "chi-squared", + "statistic": 466.4278, + "df": 4, + "p": 1.2192483930603814e-99, + "q": 6.096241965301907e-99 + }, + { + "kind": "num", + "name": "CURRENT_AGE_DEID", + "per": "patient", + "role": null, + "perGroup": [ + { + "n": 2336, + "median": 72, + "q1": 64, + "q3": 79, + "missing": 1 + }, + { + "n": 2175, + "median": 71, + "q1": 63, + "q3": 77, + "missing": 0 + }, + { + "n": 2267, + "median": 70, + "q1": 63, + "q3": 77, + "missing": 0 + } + ], + "multiValued": 0, + "test": "Kruskal-Wallis", + "statistic": 30.7119, + "df": 2, + "p": 2.1428781728255618e-7, + "q": 2.1428781728255618e-7 + }, + { + "kind": "gene", + "name": "KEAP1", + "role": "in the model", + "perGroup": [ + { + "altered": 1, + "profiled": 2337, + "notProfiled": 0 + }, + { + "altered": 66, + "profiled": 2175, + "notProfiled": 0 + }, + { + "altered": 827, + "profiled": 2267, + "notProfiled": 0 + } + ], + "minExpected": 286.83, + "test": "chi-squared", + "statistic": 1622.8469, + "df": 2, + "p": 0, + "q": null + }, + { + "kind": "gene", + "name": "TP53", + "role": "in the model", + "perGroup": [ + { + "altered": 14, + "profiled": 2337, + "notProfiled": 0 + }, + { + "altered": 1615, + "profiled": 2175, + "notProfiled": 0 + }, + { + "altered": 1851, + "profiled": 2267, + "notProfiled": 0 + } + ], + "minExpected": 1058.46, + "test": "chi-squared", + "statistic": 3699.2236, + "df": 2, + "p": 0, + "q": null + }, + { + "kind": "gene", + "name": "ZFHX3", + "role": null, + "perGroup": [ + { + "altered": 57, + "profiled": 2249, + "notProfiled": 88 + }, + { + "altered": 108, + "profiled": 2091, + "notProfiled": 84 + }, + { + "altered": 144, + "profiled": 2162, + "notProfiled": 105 + } + ], + "minExpected": 99.37, + "test": "chi-squared", + "statistic": 42.6173, + "df": 2, + "p": 5.568821598887468e-10, + "q": 6.961026998609335e-10 + } + ], + "omitted": [], + "tested": 5 + } + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "Association, not cause: a gene's weight is its link to OS with the other candidates held fixed, in this cohort. Without strata, a gene that marks a cancer type carries that type's prognosis; on a cohort of several cancer types, stratify by CANCER_TYPE. Each patient is scored only by models that did not train on them. The group cuts are equal quantiles of the score, chosen without the outcome. Genes outside the panels every patient was sequenced on are not candidates, so a patient is never counted as wild-type for a gene they were not tested for. Table 1 describes the patients the curves draw; its rows marked “in the model” (the model's genes and covariates) and “outcome” differ between the groups by construction, so they get no q-value and are left out of the correction. The C-index ignores delayed entry. Seeded (seed 1): the same document gives the same model.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "One row per patient", + "scope": "NSCLC · msk_chord_2024", + "rowsIn": 7809, + "rowsOut": 7809, + "detail": "The riskmodel:rows query above: each patient's survival time and event, the panels their samples were sequenced on for mutations, the genes mutated in them, and their half of the engine's fixed held-out split. Patient-level: the rows never leave this server's engine, and no identifier is returned." + }, + { + "kind": "transform", + "title": "Patients, candidate genes and covariates", + "detail": "A gene is a candidate only if every patient's panels cover it, so no patient is counted as wild-type for a gene they were never tested for, and only if at least 30 patients have it mutated.", + "params": [ + [ + "genes covered for every patient", + "341" + ], + [ + "candidates", + "302" + ], + [ + "left out: no mutation panel on record", + "0" + ] + ] + }, + { + "kind": "statistic", + "title": "Elastic-net Cox, 5 random splits", + "detail": "Each run holds out a random 33% of the patients; on the rest, the penalty is chosen from a path of 25 by 3-fold cross-validated partial likelihood (Verweij & van Houwelingen), and the model at that penalty scores the held-out patients. Genes are scaled to unit variance before fitting; Breslow ties. A patient's risk score is the mean of the scores they got while held out (OncoCast's ensemble, Martin et al.).", + "params": [ + [ + "l1 share of the penalty (alpha)", + "0.5" + ], + [ + "runs", + "5" + ], + [ + "seed", + "1" + ], + [ + "test-set C-index, median (IQR)", + "0.617 (0.615–0.618)" + ], + [ + "never held out, so unscored", + "1030" + ] + ] + }, + { + "kind": "statistic", + "title": "Risk groups, their survival and hazard ratios", + "detail": "Cuts at equal quantiles of the held-out scores, each moved to the nearer edge of any run of tied scores so equal scores share a group — no outcome is used to place them. Each group is drawn as a Kaplan–Meier curve and read at 12 and 36 months; the groups are compared with a log-rank test, and a Cox model of the outcome on the group indicators gives each group's hazard ratio against the lowest (Newton–Raphson, full information matrix, 95% Wald intervals). A second Cox model on the standardised score alone gives the hazard ratio per standard deviation. The score is also shown on OncoCast's 0–10 scale, (score − min) / (max − min) × 10, min and max the lowest and highest held-out score; the scale is linear, so it moves no patient between groups and changes no number above.", + "params": [ + [ + "0 on the 0–10 scale (raw score)", + "-0.4669" + ], + [ + "10 on the 0–10 scale (raw score)", + "1.2761" + ], + [ + "Low risk", + "2,337 patients, 888 events, median 68.2 months" + ], + [ + "Intermediate risk", + "2,175 patients, 1,150 events, median 37.0 months, HR 1.58" + ], + [ + "High risk", + "2,267 patients, 1,431 events, median 20.3 months, HR 2.26" + ] + ] + }, + { + "kind": "fetch", + "title": "Table 1: the groups' patients again, with their clinical values", + "detail": "The riskmodel:table1 query above is the riskmodel:rows query with Table 1's attributes added: for each, the patient's value (a sample-level attribute: their first sample's), case and whitespace folded as everywhere in this app and shown in its commonest spelling, and how many values their samples hold. Its rows are kept exactly as the model's were and must match the model's patients one by one — survival time, entry and event — or the view is refused, so each group's column describes the patients its curve drew. riskmodel:table1-attributes gives each attribute's type (NUMBER is numeric), riskmodel:panels each mutation panel's genes. Patient-level: the rows never leave this server's engine; only the counts below do.", + "params": [ + [ + "Low risk", + "2,337 patients" + ], + [ + "Intermediate risk", + "2,175 patients" + ], + [ + "High risk", + "2,267 patients" + ] + ] + }, + { + "kind": "transform", + "title": "Table 1's rows", + "detail": "Attributes as the view names them; a categorical one with more than 100 values among these patients is set aside. Genes as the view names them. A gene is counted as mutated the way the model counts it (any mutation), and only among the patients whose mutation panels cover it (a whole-exome patient covers every gene): a patient whose panels do not is not profiled for it, never unaltered, and is counted as such in each group. A row the groups differ in by construction is marked: a gene the model kept in any run and a covariate are \"in the model\" (the score is built from them), the endpoint's own columns are \"outcome\" (the groups are cut to differ in survival); the model's stratum is marked \"stratum\" but is a description, since the score has no stratum term.", + "params": [] + }, + { + "kind": "statistic", + "title": "Each row tested across the groups", + "detail": "A categorical attribute: Pearson χ² on the group × value table, no continuity correction, an all-zero row or column dropped first, patients with no value left out. A gene: Pearson χ² on the group × (mutated, not mutated) table of its profiled patients. A numeric attribute: Kruskal–Wallis on each group's values, ranks averaged within ties and tie-corrected; medians and quartiles interpolating linearly between ranks. The smallest expected count is reported, since χ² is poor below about 5.", + "params": [ + [ + "STAGE_HIGHEST_RECORDED", + "χ² 56.918 on 4 df · p 1.29e-11" + ], + [ + "GENDER", + "χ² 167.47 on 4 df · p 3.65e-35" + ], + [ + "SMOKING_PREDICTIONS_3_CLASSES", + "χ² 466.4278 on 4 df · p 1.22e-99" + ], + [ + "CURRENT_AGE_DEID", + "H 30.7119 on 2 df · p 2.14e-7" + ], + [ + "gene:KEAP1", + "χ² 1622.8469 on 2 df · p <1e-300 · in the model" + ], + [ + "gene:TP53", + "χ² 3699.2236 on 2 df · p <1e-300 · in the model" + ], + [ + "gene:ZFHX3", + "χ² 42.6173 on 2 df · p 5.57e-10" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across Table 1's open rows", + "detail": "q-values over the 5 tested rows that are not in the model and not its outcome. Those rows differ between the groups by construction, so they get a p-value but no q-value and do not enter the correction, where their p-values would shrink every other row's q." + } + ], + "implementation": { + "functions": [ + "coxnetEnsemble", + "coxnetPath", + "cvLambda", + "concordance", + "coxFit", + "buildTable1", + "chiSquareTest", + "kruskalWallis", + "quantilesFromHistogram", + "benjaminiHochberg" + ], + "file": "lib/coxnet.ts, lib/views/riskmodel-table1.ts, lib/stats.ts", + "commit": null + }, + "verification": "lib/coxnet.ts's path is checked against scikit-survival's CoxnetSurvivalAnalysis, its delayed-entry, stratified fits (with standard errors) against statsmodels' PHReg and its C-index against lifelines, by test/coxnet-golden.test.ts (fixtures from python/golden/coxnet.py). The script below recomputes Table 1's tests and q-values from its counts (the model itself it does not refit); χ² matches scipy 1.18.1 chi2_contingency, Kruskal–Wallis and quantiles scipy/numpy, Benjamini–Hochberg statsmodels multipletests (test/tables-golden.test.ts, test/moments-golden.test.ts).", + "check": { + "table1:attribute:STAGE_HIGHEST_RECORDED:p": { + "v": 1.2871847901160984e-11 + }, + "table1:attribute:STAGE_HIGHEST_RECORDED:q": { + "v": 2.1453079835268308e-11 + }, + "table1:attribute:GENDER:p": { + "v": 3.651083887973751e-35 + }, + "table1:attribute:GENDER:q": { + "v": 9.127709719934377e-35 + }, + "table1:attribute:SMOKING_PREDICTIONS_3_CLASSES:p": { + "v": 1.2192483930603814e-99 + }, + "table1:attribute:SMOKING_PREDICTIONS_3_CLASSES:q": { + "v": 6.096241965301907e-99 + }, + "table1:attribute:CURRENT_AGE_DEID:p": { + "v": 2.1428781728255618e-7 + }, + "table1:attribute:CURRENT_AGE_DEID:q": { + "v": 2.1428781728255618e-7 + }, + "table1:gene:KEAP1:p": { + "v": 0 + }, + "table1:gene:TP53:p": { + "v": 0 + }, + "table1:gene:ZFHX3:p": { + "v": 5.568821598887468e-10 + }, + "table1:gene:ZFHX3:q": { + "v": 6.961026998609335e-10 + }, + "table1:attribute:CURRENT_AGE_DEID:Low risk:median": { + "v": 72, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:Low risk:q1": { + "v": 64, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:Low risk:q3": { + "v": 79, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:Intermediate risk:median": { + "v": 71, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:Intermediate risk:q1": { + "v": 63, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:Intermediate risk:q3": { + "v": 77, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:High risk:median": { + "v": 70, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:High risk:q1": { + "v": 63, + "abs": 0.000500001 + }, + "table1:attribute:CURRENT_AGE_DEID:High risk:q3": { + "v": 77, + "abs": 0.000500001 + } + } + } + } + ] +} diff --git a/test/snapshots/riskmodel.sql b/test/snapshots/riskmodel.sql new file mode 100644 index 0000000..d695454 --- /dev/null +++ b/test/snapshots/riskmodel.sql @@ -0,0 +1,115 @@ +-- cohort NSCLC +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer')))) + +-- view 0 riskmodel: riskmodel:panels · msk_chord_2024 +SELECT toString(pg.gene_panel_id) AS panel, groupUniqArray(pg.gene) AS genes +FROM snapshot_db.gene_panel_to_gene_derived pg +WHERE pg.gene_panel_id IN (SELECT DISTINCT gene_panel_id FROM snapshot_db.sample_to_gene_panel_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND alteration_type = 'MUTATION_EXTENDED') +GROUP BY panel + +-- view 0 riskmodel: riskmodel:panels · msk_chord_2024 +SELECT toString(pg.gene_panel_id) AS panel, groupUniqArray(pg.gene) AS genes +FROM snapshot_db.gene_panel_to_gene_derived pg +WHERE pg.gene_panel_id IN (SELECT DISTINCT gene_panel_id FROM snapshot_db.sample_to_gene_panel_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND alteration_type = 'MUTATION_EXTENDED') +GROUP BY panel + +-- view 0 riskmodel: riskmodel:rows · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status, + cityHash64(concat('cohort-lab-split-v1:msk_chord_2024:', replaceOne(patient_unique_id, 'msk_chord_2024_', ''))) % 2 AS half + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +panels AS ( + SELECT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid, groupUniqArray(toString(sp.gene_panel_id)) AS panels + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +mut AS ( + SELECT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, groupUniqArray(g.hugo_gene_symbol) AS genes + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' AND g.variant_type = 'mutation' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT os.months AS m, if(os.status LIKE '1%', 1, 0) AS ev, os.half AS half, panels.panels AS panels, mut.genes AS genes +FROM os + LEFT JOIN panels ON panels.pid = os.pid + LEFT JOIN mut ON mut.pid = os.pid +WHERE os.months IS NOT NULL AND os.months > 0 +ORDER BY os.pid + +-- view 0 riskmodel: riskmodel:table1 · msk_chord_2024 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Non-Small Cell Lung Cancer'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name='OS_MONTHS')), NULL) AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status, + cityHash64(concat('cohort-lab-split-v1:msk_chord_2024:', replaceOne(patient_unique_id, 'msk_chord_2024_', ''))) % 2 AS half + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +panels AS ( + SELECT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid, groupUniqArray(toString(sp.gene_panel_id)) AS panels + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +mut AS ( + SELECT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, groupUniqArray(g.hugo_gene_symbol) AS genes + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' AND g.variant_type = 'mutation' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +), +descr AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + argMinIf(lowerUTF8(trimBoth(attribute_value)), sample_unique_id, attribute_name = 'STAGE_HIGHEST_RECORDED') AS d0, argMinIf(attribute_value, sample_unique_id, attribute_name = 'STAGE_HIGHEST_RECORDED') AS r0, uniqExactIf(lowerUTF8(trimBoth(attribute_value)), attribute_name = 'STAGE_HIGHEST_RECORDED') AS u0, + argMinIf(lowerUTF8(trimBoth(attribute_value)), sample_unique_id, attribute_name = 'GENDER') AS d1, argMinIf(attribute_value, sample_unique_id, attribute_name = 'GENDER') AS r1, uniqExactIf(lowerUTF8(trimBoth(attribute_value)), attribute_name = 'GENDER') AS u1, + argMinIf(lowerUTF8(trimBoth(attribute_value)), sample_unique_id, attribute_name = 'SMOKING_PREDICTIONS_3_CLASSES') AS d2, argMinIf(attribute_value, sample_unique_id, attribute_name = 'SMOKING_PREDICTIONS_3_CLASSES') AS r2, uniqExactIf(lowerUTF8(trimBoth(attribute_value)), attribute_name = 'SMOKING_PREDICTIONS_3_CLASSES') AS u2, + argMinIf(lowerUTF8(trimBoth(attribute_value)), sample_unique_id, attribute_name = 'CURRENT_AGE_DEID') AS d3, argMinIf(attribute_value, sample_unique_id, attribute_name = 'CURRENT_AGE_DEID') AS r3, uniqExactIf(lowerUTF8(trimBoth(attribute_value)), attribute_name = 'CURRENT_AGE_DEID') AS u3 + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND attribute_name IN ('STAGE_HIGHEST_RECORDED','GENDER','SMOKING_PREDICTIONS_3_CLASSES','CURRENT_AGE_DEID') AND trimBoth(attribute_value) != '' + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT os.months AS m, if(os.status LIKE '1%', 1, 0) AS ev, os.half AS half, panels.panels AS panels, mut.genes AS genes, descr.d0 AS d0, descr.r0 AS r0, descr.u0 AS u0, descr.d1 AS d1, descr.r1 AS r1, descr.u1 AS u1, descr.d2 AS d2, descr.r2 AS r2, descr.u2 AS u2, descr.d3 AS d3, descr.r3 AS r3, descr.u3 AS u3 +FROM os + LEFT JOIN panels ON panels.pid = os.pid + LEFT JOIN mut ON mut.pid = os.pid + LEFT JOIN descr ON descr.pid = os.pid +WHERE os.months IS NOT NULL AND os.months > 0 +ORDER BY os.pid + +-- view 0 riskmodel: riskmodel:table1-attributes · msk_chord_2024 +SELECT m.attr_id AS id, m.display_name AS name, m.datatype AS datatype, m.patient_attribute AS patient, toInt32OrZero(m.priority) AS priority +FROM snapshot_db.clinical_attribute_meta m +JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = m.cancer_study_id +WHERE cs.cancer_study_identifier = 'msk_chord_2024' +ORDER BY priority DESC, name diff --git a/test/snapshots/riskmodel.svg b/test/snapshots/riskmodel.svg new file mode 100644 index 0000000..27809a5 --- /dev/null +++ b/test/snapshots/riskmodel.svg @@ -0,0 +1,2 @@ + +Risk model — Low risk, Intermediate risk, High risk0%25%50%75%100%Survival probability024487296Monthsgroupscore (0–10)patients · eventsmedian12 mo36 moHR vs lowest [95% CI]Low risk0–2.72,337 · 88868.2 mo86%66%referenceIntermediate risk2.7–4.42,175 · 1,15037 mo76%51%1.58 [1.44–1.72]p = 2.7e-24High risk4.4–102,267 · 1,43120.3 mo62%39%2.26 [2.08–2.46]p = 8.1e-81log-rank χ² = 380 (2 df) · p = 3.5e-83risk score alone: HR 1.39 per standard deviation [95% CI 1.35–1.44] · p = 4.7e-93held-out C-index 0.617 (IQR 0.615–0.618) over 5 runsRisk score, 0–10 (held-out scores), with the group cuts01,0002,000patients2.74.40246810risk score, 0–10 — lower risk ← → higher riskSelection frequency against mean hazard ratio (labelled: kept in ≥ 50% of runs)0%25%50%75%100%share of runs kept0.811.21.41.6mean hazard ratio where kept (log scale) — favourable ← → adverseTP53: kept in 100% of runs · mean HR 1.37 · 4,020 mutatedEGFR: kept in 100% of runs · mean HR 0.92 · 1,893 mutatedKEAP1: kept in 100% of runs · mean HR 1.37 · 1,034 mutatedSTK11: kept in 100% of runs · mean HR 1.22 · 1,013 mutatedPTPRD: kept in 100% of runs · mean HR 0.94 · 644 mutatedKMT2D: kept in 40% of runs · mean HR 1.01 · 629 mutatedSMARCA4: kept in 100% of runs · mean HR 1.27 · 580 mutatedCDKN2A: kept in 40% of runs · mean HR 1.02 · 546 mutatedATM: kept in 20% of runs · mean HR 1.03 · 541 mutatedPTPRT: kept in 60% of runs · mean HR 0.95 · 539 mutatedEPHA3: kept in 100% of runs · mean HR 0.93 · 426 mutatedRB1: kept in 40% of runs · mean HR 1.02 · 403 mutatedGRIN2A: kept in 40% of runs · mean HR 1.03 · 395 mutatedMED12: kept in 100% of runs · mean HR 0.96 · 351 mutatedNOTCH4: kept in 40% of runs · mean HR 0.93 · 301 mutatedAMER1: kept in 20% of runs · mean HR 0.97 · 287 mutatedTBX3: kept in 20% of runs · mean HR 0.97 · 269 mutatedBCOR: kept in 20% of runs · mean HR 1.00 · 268 mutatedPOLE: kept in 80% of runs · mean HR 0.95 · 265 mutatedPTEN: kept in 100% of runs · mean HR 1.14 · 259 mutatedBRCA2: kept in 20% of runs · mean HR 0.97 · 257 mutatedPAK5: kept in 20% of runs · mean HR 0.98 · 252 mutatedNFE2L2: kept in 100% of runs · mean HR 1.17 · 238 mutatedARID1B: kept in 80% of runs · mean HR 0.90 · 232 mutatedKMT2A: kept in 20% of runs · mean HR 0.98 · 227 mutatedMTOR: kept in 80% of runs · mean HR 0.92 · 225 mutatedRET: kept in 40% of runs · mean HR 0.95 · 223 mutatedEP300: kept in 100% of runs · mean HR 1.07 · 220 mutatedFLT4: kept in 20% of runs · mean HR 0.99 · 218 mutatedDICER1: kept in 20% of runs · mean HR 0.98 · 217 mutatedAR: kept in 20% of runs · mean HR 0.96 · 210 mutatedRASA1: kept in 40% of runs · mean HR 1.05 · 199 mutatedNSD1: kept in 20% of runs · mean HR 0.99 · 199 mutatedSTAG2: kept in 20% of runs · mean HR 0.95 · 194 mutatedMDC1: kept in 40% of runs · mean HR 1.07 · 180 mutatedIL7R: kept in 40% of runs · mean HR 0.98 · 175 mutatedDNMT3A: kept in 80% of runs · mean HR 0.89 · 166 mutatedSF3B1: kept in 40% of runs · mean HR 0.97 · 166 mutatedU2AF1: kept in 20% of runs · mean HR 0.93 · 166 mutatedJAK3: kept in 80% of runs · mean HR 0.95 · 154 mutatedBRIP1: kept in 20% of runs · mean HR 1.11 · 152 mutatedCDK12: kept in 80% of runs · mean HR 0.87 · 142 mutatedGATA3: kept in 60% of runs · mean HR 0.96 · 140 mutatedMAP3K1: kept in 20% of runs · mean HR 0.99 · 140 mutatedTP63: kept in 20% of runs · mean HR 1.00 · 137 mutatedTGFBR2: kept in 100% of runs · mean HR 1.46 · 125 mutatedFGFR4: kept in 60% of runs · mean HR 0.97 · 122 mutatedIGF1R: kept in 20% of runs · mean HR 1.01 · 119 mutatedARAF: kept in 80% of runs · mean HR 0.90 · 117 mutatedESR1: kept in 20% of runs · mean HR 0.96 · 109 mutatedGNAS: kept in 20% of runs · mean HR 0.98 · 108 mutatedINPP4A: kept in 80% of runs · mean HR 1.07 · 107 mutatedNF2: kept in 80% of runs · mean HR 1.07 · 106 mutatedTSC1: kept in 20% of runs · mean HR 0.89 · 105 mutatedBAP1: kept in 20% of runs · mean HR 1.09 · 105 mutatedABL1: kept in 40% of runs · mean HR 0.94 · 104 mutatedMYOD1: kept in 20% of runs · mean HR 0.92 · 102 mutatedFGFR1: kept in 20% of runs · mean HR 0.86 · 92 mutatedPARP1: kept in 20% of runs · mean HR 0.95 · 91 mutatedSDHA: kept in 40% of runs · mean HR 0.91 · 90 mutatedFH: kept in 20% of runs · mean HR 1.13 · 90 mutatedBLM: kept in 60% of runs · mean HR 0.86 · 89 mutatedSOX9: kept in 20% of runs · mean HR 0.99 · 89 mutatedAXL: kept in 20% of runs · mean HR 1.00 · 88 mutatedERCC4: kept in 20% of runs · mean HR 0.98 · 83 mutatedPAX5: kept in 80% of runs · mean HR 0.94 · 80 mutatedXPO1: kept in 20% of runs · mean HR 1.04 · 80 mutatedFOXP1: kept in 20% of runs · mean HR 0.99 · 80 mutatedCTCF: kept in 20% of runs · mean HR 0.98 · 77 mutatedRUNX1: kept in 40% of runs · mean HR 0.89 · 71 mutatedETV6: kept in 20% of runs · mean HR 1.03 · 69 mutatedERCC3: kept in 40% of runs · mean HR 1.04 · 67 mutatedTOP1: kept in 40% of runs · mean HR 0.98 · 67 mutatedBCL6: kept in 20% of runs · mean HR 1.00 · 65 mutatedFOXA1: kept in 20% of runs · mean HR 0.99 · 61 mutatedTNFAIP3: kept in 60% of runs · mean HR 0.95 · 60 mutatedFLCN: kept in 60% of runs · mean HR 0.94 · 55 mutatedH3-5: kept in 20% of runs · mean HR 0.90 · 54 mutatedEZH2: kept in 40% of runs · mean HR 0.99 · 52 mutatedSMARCB1: kept in 20% of runs · mean HR 1.04 · 51 mutatedMCL1: kept in 20% of runs · mean HR 0.92 · 50 mutatedSRC: kept in 20% of runs · mean HR 1.00 · 50 mutatedSPOP: kept in 40% of runs · mean HR 0.87 · 49 mutatedMDM4: kept in 20% of runs · mean HR 1.00 · 45 mutatedCDK8: kept in 100% of runs · mean HR 0.93 · 44 mutatedEED: kept in 40% of runs · mean HR 0.91 · 44 mutatedGSK3B: kept in 20% of runs · mean HR 0.96 · 44 mutatedAKT2: kept in 20% of runs · mean HR 1.17 · 43 mutatedCDK6: kept in 60% of runs · mean HR 0.91 · 42 mutatedMYC: kept in 20% of runs · mean HR 1.11 · 42 mutatedRAD51C: kept in 40% of runs · mean HR 1.01 · 38 mutatedMYCL: kept in 20% of runs · mean HR 0.96 · 37 mutatedLMO1: kept in 40% of runs · mean HR 0.92 · 36 mutatedCD79B: kept in 40% of runs · mean HR 0.96 · 35 mutatedSH2D1A: kept in 20% of runs · mean HR 0.88 · 33 mutatedRHOA: kept in 20% of runs · mean HR 1.11 · 30 mutatedMEF2B: kept in 20% of runs · mean HR 0.98 · 30 mutatedNKX3-1: kept in 20% of runs · mean HR 1.01 · 30 mutatedTGFBR2TP53KEAP1SMARCA4STK11NFE2L2PTENEGFRCDK8EP300EPHA3PTPRDMED12CDK12DNMT3AARID1BARAFMTORNF2INPP4APOLEBLMCDK6FLCNTNFAIP3PTPRTGATA3Point size: patients mutated (largest 4,020). 30 of 98 genes kept in ≥ 50% of runs are named. 3 of 30 genes named on this volcano could not be labelledwithout overprinting another label or point and are left unlabelled: PAX5, JAK3, FGFR4.Genes kept most often (share of runs · mean hazard ratio where kept)TGFBR2100% · 125 mutatedHR 1.46TP53100% · 4,020 mutatedHR 1.37KEAP1100% · 1,034 mutatedHR 1.37SMARCA4100% · 580 mutatedHR 1.27STK11100% · 1,013 mutatedHR 1.22NFE2L2100% · 238 mutatedHR 1.17PTEN100% · 259 mutatedHR 1.14EGFR100% · 1,893 mutatedHR 0.92CDK8100% · 44 mutatedHR 0.93EP300100% · 220 mutatedHR 1.07EPHA3100% · 426 mutatedHR 0.93PTPRD100% · 644 mutatedHR 0.94MED12100% · 351 mutatedHR 0.96CDK1280% · 142 mutatedHR 0.87DNMT3A80% · 166 mutatedHR 0.890.511.52mean hazard ratio where kept (log scale)7,809 patients, 3,975 events; 302 candidate genes (of 341 covered for every patient, mutated in ≥30); elastic net, alpha 0.5, seed 1. The risk score isOncoCast's 0–10 scale: 0 and 10 are the lowest and highest held-out score (raw linear predictor −0.467 to 1.28). 204 of the 302 candidate genes were neverkept, so are not on the volcano. Left out: 1,030 never held out (so unscored and in no group). 83 more genes were kept in at least one run; they are in theresult, not drawn. Table 1 (not drawn; in the result) compares the groups (Low / Intermediate / High, 2,337 / 2,175 / 2,267 patients) on 7 rows, each testedacross groups (χ² or Kruskal–Wallis), q-values Benjamini–Hochberg over 5 of them; a category's share is of the patients with a value. Differ at q < 0.05:STAGE_HIGHEST_RECORDED Stage 1-3 in 61.5% / 50.7% / 54.9% (q = 2.1e-11); GENDER Female in 66.8% / 60.0% / 48.3% (q = 9.1e-35);SMOKING_PREDICTIONS_3_CLASSES Former/Current Smoker in 56.7% / 69.1% / 82.7% (q = 6.1e-99); CURRENT_AGE_DEID median 72 / 71 / 70 (q =2.1e-7); ZFHX3 mutated in 2.5% / 5.2% / 6.7% of patients whose panels cover it (q = 7e-10). Different by construction, so no q-value: KEAP1 mutated in<0.1% / 3.0% / 36.5% of patients whose panels cover it (in the model, p < 1e-300); TP53 mutated in 0.6% / 74.3% / 81.6% of patients whose panels cover it(in the model, p < 1e-300). Association, not cause: a gene's weight is its link to OS with the other candidates held fixed, in this cohort. Without strata, a genethat marks a cancer type carries that type's prognosis; on a cohort of several cancer types, stratify by CANCER_TYPE. Each patient is scored only by modelsthat did not train on them. The group cuts are equal quantiles of the score, chosen without the outcome. Genes outside the panels every patient wassequenced on are not candidates, so a patient is never counted as wild-type for a gene they were not tested for. Table 1 describes the patients the curvesdraw; its rows marked “in the model” (the model's genes and covariates) and “outcome” differ between the groups by construction, so they get no q-valueand are left out of the correction. The C-index ignores delayed entry. Seeded (seed 1): the same document gives the same model. diff --git a/test/snapshots/riskmodel.txt b/test/snapshots/riskmodel.txt new file mode 100644 index 0000000..a221439 --- /dev/null +++ b/test/snapshots/riskmodel.txt @@ -0,0 +1,83 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- NSCLC: 7,809 patients — CANCER_TYPE in [Non-Small Cell Lung Cancer] (any sample) + +Risk model (elastic-net Cox, 5 held-out splits, alpha 0.5, seed 1; 7,809 patients, 3,975 events, 302 candidate genes): + held-out C-index 0.617 (IQR 0.615–0.618) + risk score on OncoCast's 0–10 scale (0 and 10 the lowest and highest held-out score; raw -0.467 to 1.276) + risk groups (held-out scores, equal quantiles): + Low risk (score 0–2.7): n=2337, 888 events, median 68.2mo, 12-month 86%, 36-month 66% + Intermediate risk (score 2.7–4.4): n=2175, 1150 events, median 37.0mo, 12-month 76%, 36-month 51%, HR vs lowest 1.58 (95% CI 1.44–1.72, 2.7e-24) + High risk (score 4.4–10): n=2267, 1431 events, median 20.3mo, 12-month 62%, 36-month 39%, HR vs lowest 2.26 (95% CI 2.08–2.46, 8.1e-81) + log-rank p=3.5e-83 + risk score alone: HR 1.39 per SD (95% CI 1.35–1.44, 4.7e-93) + genes kept most often: TGFBR2 100% HR 1.46, TP53 100% HR 1.37, KEAP1 100% HR 1.37, SMARCA4 100% HR 1.27, STK11 100% HR 1.22, NFE2L2 100% HR 1.17, PTEN 100% HR 1.14, EGFR 100% HR 0.92, CDK8 100% HR 0.93, EP300 100% HR 1.07, EPHA3 100% HR 0.93, PTPRD 100% HR 0.94, MED12 100% HR 0.96, CDK12 80% HR 0.87, DNMT3A 80% HR 0.89 + 1030 patients were never held out, so have no score + CAVEAT (tell the user): Association, not cause: a gene's weight is its link to OS with the other candidates held fixed, in this cohort. Without strata, a gene that marks a cancer type carries that type's prognosis; on a cohort of several cancer types, stratify by CANCER_TYPE. Each patient is scored only by models that did not train on them. The group cuts are equal quantiles of the score, chosen without the outcome. Genes outside the panels every patient was sequenced on are not candidates, so a patient is never counted as wild-type for a gene they were not tested for. Table 1 describes the patients the curves draw; its rows marked “in the model” (the model's genes and covariates) and “outcome” differ between the groups by construction, so they get no q-value and are left out of the correction. The C-index ignores delayed entry. Seeded (seed 1): the same document gives the same model. + METHOD: + - One row per patient [NSCLC · msk_chord_2024] (7,809 → 7,809 rows): The riskmodel:rows query above: each patient's survival time and event, the panels their samples were sequenced on for mutations, the genes mutated in them, and their half of the engine's fixed held-out split. Patient-level: the rows never leave this server's engine, and no identifier is returned. + - Patients, candidate genes and covariates: A gene is a candidate only if every patient's panels cover it, so no patient is counted as wild-type for a gene they were never tested for, and only if at least 30 patients have it mutated. + genes covered for every patient: 341 + candidates: 302 + left out: no mutation panel on record: 0 + - Elastic-net Cox, 5 random splits: Each run holds out a random 33% of the patients; on the rest, the penalty is chosen from a path of 25 by 3-fold cross-validated partial likelihood (Verweij & van Houwelingen), and the model at that penalty scores the held-out patients. Genes are scaled to unit variance before fitting; Breslow ties. A patient's risk score is the mean of the scores they got while held out (OncoCast's ensemble, Martin et al.). + l1 share of the penalty (alpha): 0.5 + runs: 5 + seed: 1 + test-set C-index, median (IQR): 0.617 (0.615–0.618) + never held out, so unscored: 1030 + - Risk groups, their survival and hazard ratios: Cuts at equal quantiles of the held-out scores, each moved to the nearer edge of any run of tied scores so equal scores share a group — no outcome is used to place them. Each group is drawn as a Kaplan–Meier curve and read at 12 and 36 months; the groups are compared with a log-rank test, and a Cox model of the outcome on the group indicators gives each group's hazard ratio against the lowest (Newton–Raphson, full information matrix, 95% Wald intervals). A second Cox model on the standardised score alone gives the hazard ratio per standard deviation. The score is also shown on OncoCast's 0–10 scale, (score − min) / (max − min) × 10, min and max the lowest and highest held-out score; the scale is linear, so it moves no patient between groups and changes no number above. + 0 on the 0–10 scale (raw score): -0.4669 + 10 on the 0–10 scale (raw score): 1.2761 + Low risk: 2,337 patients, 888 events, median 68.2 months + Intermediate risk: 2,175 patients, 1,150 events, median 37.0 months, HR 1.58 + High risk: 2,267 patients, 1,431 events, median 20.3 months, HR 2.26 + - Table 1: the groups' patients again, with their clinical values: The riskmodel:table1 query above is the riskmodel:rows query with Table 1's attributes added: for each, the patient's value (a sample-level attribute: their first sample's), case and whitespace folded as everywhere in this app and shown in its commonest spelling, and how many values their samples hold. Its rows are kept exactly as the model's were and must match the model's patients one by one — survival time, entry and event — or the view is refused, so each group's column describes the patients its curve drew. riskmodel:table1-attributes gives each attribute's type (NUMBER is numeric), riskmodel:panels each mutation panel's genes. Patient-level: the rows never leave this server's engine; only the counts below do. + Low risk: 2,337 patients + Intermediate risk: 2,175 patients + High risk: 2,267 patients + - Table 1's rows: Attributes as the view names them; a categorical one with more than 100 values among these patients is set aside. Genes as the view names them. A gene is counted as mutated the way the model counts it (any mutation), and only among the patients whose mutation panels cover it (a whole-exome patient covers every gene): a patient whose panels do not is not profiled for it, never unaltered, and is counted as such in each group. A row the groups differ in by construction is marked: a gene the model kept in any run and a covariate are "in the model" (the score is built from them), the endpoint's own columns are "outcome" (the groups are cut to differ in survival); the model's stratum is marked "stratum" but is a description, since the score has no stratum term. + - Each row tested across the groups: A categorical attribute: Pearson χ² on the group × value table, no continuity correction, an all-zero row or column dropped first, patients with no value left out. A gene: Pearson χ² on the group × (mutated, not mutated) table of its profiled patients. A numeric attribute: Kruskal–Wallis on each group's values, ranks averaged within ties and tie-corrected; medians and quartiles interpolating linearly between ranks. The smallest expected count is reported, since χ² is poor below about 5. + STAGE_HIGHEST_RECORDED: χ² 56.918 on 4 df · p 1.29e-11 + GENDER: χ² 167.47 on 4 df · p 3.65e-35 + SMOKING_PREDICTIONS_3_CLASSES: χ² 466.4278 on 4 df · p 1.22e-99 + CURRENT_AGE_DEID: H 30.7119 on 2 df · p 2.14e-7 + gene:KEAP1: χ² 1622.8469 on 2 df · p <1e-300 · in the model + gene:TP53: χ² 3699.2236 on 2 df · p <1e-300 · in the model + gene:ZFHX3: χ² 42.6173 on 2 df · p 5.57e-10 + - Benjamini–Hochberg across Table 1's open rows: q-values over the 5 tested rows that are not in the model and not its outcome. Those rows differ between the groups by construction, so they get a p-value but no q-value and do not enter the correction, where their p-values would shrink every other row's q. + lib/coxnet.ts's path is checked against scikit-survival's CoxnetSurvivalAnalysis, its delayed-entry, stratified fits (with standard errors) against statsmodels' PHReg and its C-index against lifelines, by test/coxnet-golden.test.ts (fixtures from python/golden/coxnet.py). The script below recomputes Table 1's tests and q-values from its counts (the model itself it does not refit); χ² matches scipy 1.18.1 chi2_contingency, Kruskal–Wallis and quantiles scipy/numpy, Benjamini–Hochberg statsmodels multipletests (test/tables-golden.test.ts, test/moments-golden.test.ts). + METHOD: + - One row per patient [NSCLC · msk_chord_2024] (7,809 → 7,809 rows): The riskmodel:rows query above: each patient's survival time and event, the panels their samples were sequenced on for mutations, the genes mutated in them, and their half of the engine's fixed held-out split. Patient-level: the rows never leave this server's engine, and no identifier is returned. + - Patients, candidate genes and covariates: A gene is a candidate only if every patient's panels cover it, so no patient is counted as wild-type for a gene they were never tested for, and only if at least 30 patients have it mutated. + genes covered for every patient: 341 + candidates: 302 + left out: no mutation panel on record: 0 + - Elastic-net Cox, 5 random splits: Each run holds out a random 33% of the patients; on the rest, the penalty is chosen from a path of 25 by 3-fold cross-validated partial likelihood (Verweij & van Houwelingen), and the model at that penalty scores the held-out patients. Genes are scaled to unit variance before fitting; Breslow ties. A patient's risk score is the mean of the scores they got while held out (OncoCast's ensemble, Martin et al.). + l1 share of the penalty (alpha): 0.5 + runs: 5 + seed: 1 + test-set C-index, median (IQR): 0.617 (0.615–0.618) + never held out, so unscored: 1030 + - Risk groups, their survival and hazard ratios: Cuts at equal quantiles of the held-out scores, each moved to the nearer edge of any run of tied scores so equal scores share a group — no outcome is used to place them. Each group is drawn as a Kaplan–Meier curve and read at 12 and 36 months; the groups are compared with a log-rank test, and a Cox model of the outcome on the group indicators gives each group's hazard ratio against the lowest (Newton–Raphson, full information matrix, 95% Wald intervals). A second Cox model on the standardised score alone gives the hazard ratio per standard deviation. The score is also shown on OncoCast's 0–10 scale, (score − min) / (max − min) × 10, min and max the lowest and highest held-out score; the scale is linear, so it moves no patient between groups and changes no number above. + 0 on the 0–10 scale (raw score): -0.4669 + 10 on the 0–10 scale (raw score): 1.2761 + Low risk: 2,337 patients, 888 events, median 68.2 months + Intermediate risk: 2,175 patients, 1,150 events, median 37.0 months, HR 1.58 + High risk: 2,267 patients, 1,431 events, median 20.3 months, HR 2.26 + - Table 1: the groups' patients again, with their clinical values: The riskmodel:table1 query above is the riskmodel:rows query with Table 1's attributes added: for each, the patient's value (a sample-level attribute: their first sample's), case and whitespace folded as everywhere in this app and shown in its commonest spelling, and how many values their samples hold. Its rows are kept exactly as the model's were and must match the model's patients one by one — survival time, entry and event — or the view is refused, so each group's column describes the patients its curve drew. riskmodel:table1-attributes gives each attribute's type (NUMBER is numeric), riskmodel:panels each mutation panel's genes. Patient-level: the rows never leave this server's engine; only the counts below do. + Low risk: 2,337 patients + Intermediate risk: 2,175 patients + High risk: 2,267 patients + - Table 1's rows: Attributes as the view names them; a categorical one with more than 100 values among these patients is set aside. Genes as the view names them. A gene is counted as mutated the way the model counts it (any mutation), and only among the patients whose mutation panels cover it (a whole-exome patient covers every gene): a patient whose panels do not is not profiled for it, never unaltered, and is counted as such in each group. A row the groups differ in by construction is marked: a gene the model kept in any run and a covariate are "in the model" (the score is built from them), the endpoint's own columns are "outcome" (the groups are cut to differ in survival); the model's stratum is marked "stratum" but is a description, since the score has no stratum term. + - Each row tested across the groups: A categorical attribute: Pearson χ² on the group × value table, no continuity correction, an all-zero row or column dropped first, patients with no value left out. A gene: Pearson χ² on the group × (mutated, not mutated) table of its profiled patients. A numeric attribute: Kruskal–Wallis on each group's values, ranks averaged within ties and tie-corrected; medians and quartiles interpolating linearly between ranks. The smallest expected count is reported, since χ² is poor below about 5. + STAGE_HIGHEST_RECORDED: χ² 56.918 on 4 df · p 1.29e-11 + GENDER: χ² 167.47 on 4 df · p 3.65e-35 + SMOKING_PREDICTIONS_3_CLASSES: χ² 466.4278 on 4 df · p 1.22e-99 + CURRENT_AGE_DEID: H 30.7119 on 2 df · p 2.14e-7 + gene:KEAP1: χ² 1622.8469 on 2 df · p <1e-300 · in the model + gene:TP53: χ² 3699.2236 on 2 df · p <1e-300 · in the model + gene:ZFHX3: χ² 42.6173 on 2 df · p 5.57e-10 + - Benjamini–Hochberg across Table 1's open rows: q-values over the 5 tested rows that are not in the model and not its outcome. Those rows differ between the groups by construction, so they get a p-value but no q-value and do not enter the correction, where their p-values would shrink every other row's q. + lib/coxnet.ts's path is checked against scikit-survival's CoxnetSurvivalAnalysis, its delayed-entry, stratified fits (with standard errors) against statsmodels' PHReg and its C-index against lifelines, by test/coxnet-golden.test.ts (fixtures from python/golden/coxnet.py). The script below recomputes Table 1's tests and q-values from its counts (the model itself it does not refit); χ² matches scipy 1.18.1 chi2_contingency, Kruskal–Wallis and quantiles scipy/numpy, Benjamini–Hochberg statsmodels multipletests (test/tables-golden.test.ts, test/moments-golden.test.ts). diff --git a/test/snapshots/sequence.json b/test/snapshots/sequence.json new file mode 100644 index 0000000..796240a --- /dev/null +++ b/test/snapshots/sequence.json @@ -0,0 +1,810 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "TP53 mut": { + "count": 13105, + "text": "OQL[TP53: MUT]", + "studies": [ + "msk_chord_2024" + ] + }, + "TP53 wt": { + "count": 11594, + "text": "NOT OQL[TP53:] AND profiled for TP53 MUTATION", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "sequence", + "cohorts": [ + "TP53 mut", + "TP53 wt" + ], + "studies": [ + "msk_chord_2024" + ], + "sequence": { + "labelKey": "SUBTYPE", + "lineGap": 90, + "steps": 3, + "foldedLabels": 51, + "truncated": false, + "keyOptions": [ + { + "key": "subtype", + "label": "SUBTYPE", + "patients": 12738, + "values": 10 + }, + { + "key": "agent", + "label": "AGENT", + "patients": 11575, + "values": 220 + }, + { + "key": "flag_orotopical", + "label": "FLAG_OROTOPICAL", + "patients": 11575, + "values": 2 + }, + { + "key": "rx_investigative", + "label": "RX_INVESTIGATIVE", + "patients": 11575, + "values": 2 + }, + { + "key": "inferred_tx_prob", + "label": "INFERRED_TX_PROB", + "patients": 10877, + "values": 99 + }, + { + "key": "prior_med_to_msk", + "label": "PRIOR_MED_TO_MSK", + "patients": 10877, + "values": 2 + }, + { + "key": "style_color", + "label": "STYLE_COLOR", + "patients": 10877, + "values": 2 + }, + { + "key": "treatment_type", + "label": "Treatment_TYPE", + "patients": 10877, + "values": 1 + } + ], + "panels": [ + { + "cohort": "TP53 mut", + "nodes": [ + { + "column": 1, + "label": "Chemo", + "kind": "regimen", + "n": 5239 + }, + { + "column": 1, + "label": "other", + "kind": "regimen", + "n": 2689 + }, + { + "column": 1, + "label": "Biologic + Chemo", + "kind": "regimen", + "n": 995 + }, + { + "column": 1, + "label": "Hormone", + "kind": "regimen", + "n": 672 + }, + { + "column": 1, + "label": "Chemo + Hormone", + "kind": "regimen", + "n": 644 + }, + { + "column": 1, + "label": "Chemo + Immuno", + "kind": "regimen", + "n": 639 + }, + { + "column": 1, + "label": "Targeted", + "kind": "regimen", + "n": 273 + }, + { + "column": 1, + "label": "Investigational", + "kind": "regimen", + "n": 254 + }, + { + "column": 1, + "label": "Chemo + Hormone + Targeted", + "kind": "regimen", + "n": 159 + }, + { + "column": 2, + "label": "", + "kind": "censored", + "n": 4206 + }, + { + "column": 2, + "label": "", + "kind": "stopped", + "n": 3285 + }, + { + "column": 2, + "label": "Chemo", + "kind": "regimen", + "n": 1400 + }, + { + "column": 2, + "label": "other", + "kind": "regimen", + "n": 1038 + }, + { + "column": 2, + "label": "Biologic + Chemo", + "kind": "regimen", + "n": 538 + }, + { + "column": 2, + "label": "Hormone", + "kind": "regimen", + "n": 489 + }, + { + "column": 2, + "label": "Targeted", + "kind": "regimen", + "n": 174 + }, + { + "column": 2, + "label": "Investigational", + "kind": "regimen", + "n": 140 + }, + { + "column": 2, + "label": "Chemo + Immuno", + "kind": "regimen", + "n": 133 + }, + { + "column": 2, + "label": "Chemo + Hormone", + "kind": "regimen", + "n": 115 + }, + { + "column": 2, + "label": "Chemo + Hormone + Targeted", + "kind": "regimen", + "n": 46 + }, + { + "…": "22 more", + "sha256": "4b96ee2a5c623769" + } + ], + "flows": [ + { + "column": 1, + "from": "Chemo", + "to": "", + "n": 1966, + "kind": "stopped" + }, + { + "column": 1, + "from": "other", + "to": "", + "n": 1700, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo", + "to": "Chemo", + "n": 1097, + "kind": "regimen" + }, + { + "column": 1, + "from": "Chemo", + "to": "", + "n": 964, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo", + "to": "other", + "n": 488, + "kind": "regimen" + }, + { + "column": 1, + "from": "other", + "to": "", + "n": 437, + "kind": "stopped" + }, + { + "column": 1, + "from": "Biologic + Chemo", + "to": "", + "n": 428, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo + Hormone", + "to": "", + "n": 335, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo", + "to": "Biologic + Chemo", + "n": 329, + "kind": "regimen" + }, + { + "column": 1, + "from": "Chemo + Immuno", + "to": "", + "n": 317, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo + Immuno", + "to": "", + "n": 222, + "kind": "stopped" + }, + { + "column": 1, + "from": "other", + "to": "other", + "n": 218, + "kind": "regimen" + }, + { + "column": 1, + "from": "Biologic + Chemo", + "to": "", + "n": 216, + "kind": "stopped" + }, + { + "column": 1, + "from": "Hormone", + "to": "Hormone", + "n": 211, + "kind": "regimen" + }, + { + "column": 1, + "from": "Hormone", + "to": "", + "n": 170, + "kind": "stopped" + }, + { + "column": 1, + "from": "Hormone", + "to": "", + "n": 161, + "kind": "censored" + }, + { + "column": 1, + "from": "Targeted", + "to": "", + "n": 136, + "kind": "censored" + }, + { + "column": 1, + "from": "Biologic + Chemo", + "to": "Biologic + Chemo", + "n": 135, + "kind": "regimen" + }, + { + "column": 1, + "from": "Chemo + Hormone", + "to": "", + "n": 135, + "kind": "stopped" + }, + { + "column": 1, + "from": "Chemo + Hormone + Targeted", + "to": "", + "n": 134, + "kind": "censored" + }, + { + "…": "227 more", + "sha256": "0f4c33632dbcf0ee" + } + ], + "started": 11564, + "censored": 6417 + }, + { + "cohort": "TP53 wt", + "nodes": [ + { + "column": 1, + "label": "Chemo", + "kind": "regimen", + "n": 2551 + }, + { + "column": 1, + "label": "other", + "kind": "regimen", + "n": 2434 + }, + { + "column": 1, + "label": "Hormone", + "kind": "regimen", + "n": 2209 + }, + { + "column": 1, + "label": "Chemo + Hormone", + "kind": "regimen", + "n": 781 + }, + { + "column": 1, + "label": "Chemo + Immuno", + "kind": "regimen", + "n": 365 + }, + { + "column": 1, + "label": "Biologic + Chemo", + "kind": "regimen", + "n": 351 + }, + { + "column": 1, + "label": "Chemo + Hormone + Targeted", + "kind": "regimen", + "n": 344 + }, + { + "column": 1, + "label": "Targeted", + "kind": "regimen", + "n": 320 + }, + { + "column": 1, + "label": "Investigational", + "kind": "regimen", + "n": 290 + }, + { + "column": 2, + "label": "", + "kind": "censored", + "n": 3577 + }, + { + "column": 2, + "label": "", + "kind": "stopped", + "n": 2399 + }, + { + "column": 2, + "label": "Hormone", + "kind": "regimen", + "n": 1172 + }, + { + "column": 2, + "label": "other", + "kind": "regimen", + "n": 910 + }, + { + "column": 2, + "label": "Chemo", + "kind": "regimen", + "n": 740 + }, + { + "column": 2, + "label": "Targeted", + "kind": "regimen", + "n": 212 + }, + { + "column": 2, + "label": "Biologic + Chemo", + "kind": "regimen", + "n": 164 + }, + { + "column": 2, + "label": "Investigational", + "kind": "regimen", + "n": 150 + }, + { + "column": 2, + "label": "Chemo + Hormone", + "kind": "regimen", + "n": 133 + }, + { + "column": 2, + "label": "Chemo + Hormone + Targeted", + "kind": "regimen", + "n": 106 + }, + { + "column": 2, + "label": "Chemo + Immuno", + "kind": "regimen", + "n": 82 + }, + { + "…": "22 more", + "sha256": "731466154026352e" + } + ], + "flows": [ + { + "column": 1, + "from": "other", + "to": "", + "n": 1449, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo", + "to": "", + "n": 868, + "kind": "stopped" + }, + { + "column": 1, + "from": "Hormone", + "to": "", + "n": 643, + "kind": "stopped" + }, + { + "column": 1, + "from": "Hormone", + "to": "Hormone", + "n": 630, + "kind": "regimen" + }, + { + "column": 1, + "from": "Hormone", + "to": "", + "n": 612, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo", + "to": "Chemo", + "n": 479, + "kind": "regimen" + }, + { + "column": 1, + "from": "Chemo + Hormone", + "to": "", + "n": 432, + "kind": "censored" + }, + { + "column": 1, + "from": "other", + "to": "", + "n": 393, + "kind": "stopped" + }, + { + "column": 1, + "from": "Chemo", + "to": "", + "n": 363, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo", + "to": "other", + "n": 288, + "kind": "regimen" + }, + { + "column": 1, + "from": "Chemo", + "to": "Hormone", + "n": 270, + "kind": "regimen" + }, + { + "column": 1, + "from": "Chemo + Hormone + Targeted", + "to": "", + "n": 269, + "kind": "censored" + }, + { + "column": 1, + "from": "other", + "to": "other", + "n": 223, + "kind": "regimen" + }, + { + "column": 1, + "from": "Hormone", + "to": "other", + "n": 171, + "kind": "regimen" + }, + { + "column": 1, + "from": "Targeted", + "to": "", + "n": 159, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo + Immuno", + "to": "", + "n": 155, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo + Hormone", + "to": "Hormone", + "n": 134, + "kind": "regimen" + }, + { + "column": 1, + "from": "Biologic + Chemo", + "to": "", + "n": 119, + "kind": "censored" + }, + { + "column": 1, + "from": "Chemo + Hormone", + "to": "", + "n": 115, + "kind": "stopped" + }, + { + "column": 1, + "from": "Chemo + Immuno", + "to": "", + "n": 115, + "kind": "stopped" + }, + { + "…": "234 more", + "sha256": "b7b472db490e48ad" + } + ], + "started": 9645, + "censored": 5474 + } + ] + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "caveat": "Therapies are grouped into LINES before being sequenced, by the definition every line count here shares: systemic-therapy treatment records (class, from SUBTYPE or else TREATMENT_TYPE, on the systemic list: chemotherapy, immunotherapy, targeted, hormone, biologic, investigational and their spellings; radiation, surgery, bone and ancillary treatment are not lines). A record starting more than 90 days after every earlier one has stopped begins a new line; anything closer is the same line, and a line is labelled by its whole combination (sorted, so 'A + B' and 'B + A' are one regimen). That grouping is the point — a patient here has a median of 6 treatment records and 4 distinct agents, and combination therapy is several records describing ONE decision, not several lines. Lines are labelled by SUBTYPE. ENDING A PATH IS SPLIT IN TWO, because the difference matters more than anything else here: 'no further line' means the study kept watching for at least 90 days (one line gap, the same rule that defines a line) and saw no further therapy; 'record ends here' means it did not, so nothing can be concluded about that patient. 55.5% of paths end censored — reading those as patients who finished treatment would be a claim about the record-keeping dressed up as one about the patient. Neither terminal is an outcome measure. 51 less common regimens folded into 'other', which is 23.3% of first-line patients in the first panel — combination regimens have a genuinely long tail, so 'other' is real diversity rather than a rounding bucket. Raise topN to split it further. Both panels share one scale and one colour per regimen, so their heights are directly comparable. TP53 mut: 11,564 with a first line; TP53 wt: 9,645 with a first line.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Build lines and count what follows what", + "detail": "The treatmentSequence query above builds every patient's lines in the database and returns, per line number, how many patients went from one regimen to the next, stopped, or were lost to follow-up — counts only — plus how many records it set aside.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105 + }, + { + "kind": "fetch", + "title": "Build lines and count what follows what", + "detail": "The treatmentSequence query above builds every patient's lines in the database and returns, per line number, how many patients went from one regimen to the next, stopped, or were lost to follow-up — counts only — plus how many records it set aside.", + "scope": "TP53 wt · msk_chord_2024", + "rowsIn": 11594 + }, + { + "kind": "transform", + "title": "Choose the records that form lines", + "detail": "The one definition every line count shares (lib/treatment-lines.ts): treatment records whose class is systemic therapy (chemo, chemotherapy, immuno, immunotherapy, immunotherapy (including vaccines), vaccine, targeted, targeted therapy, targeted molecular therapy, targeted antibody therapy, hormone, hormone therapy, hormonal therapy, biologic, investigational, systemic therapy, medical therapy, pharmaceutical therapy, nos). A record's class is its SUBTYPE, or its TREATMENT_TYPE where it has none; names and values match ignoring case.", + "params": [ + [ + "Radiation Therapy", + "28,738 records set aside: not a line class" + ], + [ + "Prior Medications to MSK", + "19,366 records set aside: not a line class" + ], + [ + "Bone Treatment", + "5,548 records set aside: not a line class" + ], + [ + "Other", + "12 records set aside: not a line class" + ] + ] + }, + { + "kind": "transform", + "title": "Group records into lines", + "detail": "Per patient, by start date: a record starting more than 90 days after every earlier one has stopped begins a new line; anything closer — overlapping, or a switch within the gap — is the same line. A line is named by its sorted combination of classes ('A + B'); the label never decides which records form a line." + }, + { + "kind": "transform", + "title": "Decide how each path ends", + "detail": "A patient's last line ends in 'no further line' only if they were observed for at least 90 days after it — their last contact being the later of their last recorded event of any type and their OS follow-up (OS_MONTHS × 30.4375 days) — and in 'record ends here' otherwise. Lines are followed up to line 3." + }, + { + "kind": "transform", + "title": "Keep the 8 most common regimens", + "detail": "Flows are summed across studies, then regimens ranked by the patients leaving them (or, for one seen only as a destination, arriving), ties by name, across every panel so a regimen keeps one identity; the rest are drawn as 'other'.", + "params": [ + [ + "regimens folded into 'other'", + "51" + ] + ] + } + ], + "implementation": { + "functions": [], + "file": "lib/treatment-lines.ts, lib/views/sequence.ts", + "commit": null + }, + "check": { + "sequence:TP53 mut:started": { + "v": 11564, + "abs": 0 + }, + "sequence:TP53 mut:censored": { + "v": 6417, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Chemo:n": { + "v": 5239, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:other:n": { + "v": 2689, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Biologic + Chemo:n": { + "v": 995, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Hormone:n": { + "v": 672, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Chemo + Hormone:n": { + "v": 644, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Chemo + Immuno:n": { + "v": 639, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Targeted:n": { + "v": 273, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Investigational:n": { + "v": 254, + "abs": 0 + }, + "sequence:TP53 mut:1:regimen:Chemo + Hormone + Targeted:n": { + "v": 159, + "abs": 0 + }, + "sequence:TP53 mut:2:censored::n": { + "v": 4206, + "abs": 0 + }, + "sequence:TP53 mut:2:stopped::n": { + "v": 3285, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:Chemo:n": { + "v": 1400, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:other:n": { + "v": 1038, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:Biologic + Chemo:n": { + "v": 538, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:Hormone:n": { + "v": 489, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:Targeted:n": { + "v": 174, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:Investigational:n": { + "v": 140, + "abs": 0 + }, + "sequence:TP53 mut:2:regimen:Chemo + Immuno:n": { + "v": 133, + "abs": 0 + }, + "…": { + "more": 68, + "sha256": "2abab4efd36844fb" + } + } + } + } + ] +} diff --git a/test/snapshots/sequence.sql b/test/snapshots/sequence.sql new file mode 100644 index 0000000..75d4892 --- /dev/null +++ b/test/snapshots/sequence.sql @@ -0,0 +1,262 @@ +-- cohort TP53 mut +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort TP53 wt +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))) + +-- view 0 sequence: sequenceKeys · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))) +SELECT lowerUTF8(trimBoth(d.key)) AS k, arraySort((x) -> (-x.2, x.1), arrayMap((v) -> (v, countEqual(groupArray(trimBoth(d.key)), v)), groupUniqArray(trimBoth(d.key))))[1].1 AS label, + uniqExact(p.stable_id) AS pts, uniqExact(lowerUTF8(trimBoth(d.value))) AS values +FROM snapshot_db.clinical_event ce +JOIN snapshot_db.clinical_event_data d ON d.clinical_event_id = ce.clinical_event_id +JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id +JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id +WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('treatment')) + AND p.stable_id IN (SELECT pid FROM cohort) +GROUP BY k ORDER BY pts DESC, k LIMIT 25 + +-- view 0 sequence: treatmentSequence:SUBTYPE/gap90 · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +txAll AS ( + SELECT ce.clinical_event_id AS eid, ce.patient_id AS patient_id, p.stable_id AS pid, + ce.start_date AS s, coalesce(ce.stop_date, ce.start_date) AS e, + coalesce(cl.cls, '') AS cls, coalesce(cl.cls_raw, '') AS cls_raw + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + LEFT JOIN ( + SELECT clinical_event_id, argMin(lowerUTF8(trimBoth(value)), (lowerUTF8(trimBoth(key)) != 'subtype', lowerUTF8(trimBoth(value)))) AS cls, + argMin(trimBoth(value), (lowerUTF8(trimBoth(key)) != 'subtype', lowerUTF8(trimBoth(value)))) AS cls_raw + FROM snapshot_db.clinical_event_data + WHERE lowerUTF8(trimBoth(key)) IN (lowerUTF8(trimBoth('subtype')), lowerUTF8(trimBoth('treatment_type'))) AND lowerUTF8(trimBoth(value)) != '' + AND clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(event_type)) = lowerUTF8(trimBoth('treatment'))) + GROUP BY clinical_event_id + ) cl ON cl.clinical_event_id = ce.clinical_event_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('treatment')) + AND p.stable_id IN (SELECT pid FROM cohort) +), +txLabelled AS ( + SELECT t.eid AS eid, t.patient_id AS patient_id, t.pid AS pid, t.s AS s, t.e AS e, t.cls AS cls, + t.cls AS lk, t.cls_raw AS lraw + FROM txAll t + WHERE t.cls IN (lowerUTF8(trimBoth('chemo')), lowerUTF8(trimBoth('chemotherapy')), lowerUTF8(trimBoth('immuno')), lowerUTF8(trimBoth('immunotherapy')), lowerUTF8(trimBoth('immunotherapy (including vaccines)')), lowerUTF8(trimBoth('vaccine')), lowerUTF8(trimBoth('targeted')), lowerUTF8(trimBoth('targeted therapy')), lowerUTF8(trimBoth('targeted molecular therapy')), lowerUTF8(trimBoth('targeted antibody therapy')), lowerUTF8(trimBoth('hormone')), lowerUTF8(trimBoth('hormone therapy')), lowerUTF8(trimBoth('hormonal therapy')), lowerUTF8(trimBoth('biologic')), lowerUTF8(trimBoth('investigational')), lowerUTF8(trimBoth('systemic therapy')), lowerUTF8(trimBoth('medical therapy')), lowerUTF8(trimBoth('pharmaceutical therapy, nos'))) +), +spell AS ( + SELECT lk, arraySort((x) -> (-x.2, x.1), groupArray((lraw, c)))[1].1 AS lbl FROM ( + SELECT lk, lraw, count() AS c FROM txLabelled WHERE lk != '' GROUP BY lk, lraw + ) GROUP BY lk +), +tx AS ( + SELECT x.eid AS eid, x.patient_id AS patient_id, x.pid AS pid, x.s AS s, x.e AS e, x.cls AS cls, + if(x.lk = '', '', sp.lbl) AS lbl + FROM txLabelled x LEFT JOIN spell sp ON sp.lk = x.lk +), +flagged AS ( + SELECT *, max(toNullable(e)) OVER (PARTITION BY patient_id + ORDER BY s, e, eid ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS pms + FROM tx +), +numbered AS ( + SELECT *, sum(if(pms IS NULL OR s > pms + 90, 1, 0)) OVER ( + PARTITION BY patient_id ORDER BY s, e, eid ROWS UNBOUNDED PRECEDING) AS line_no + FROM flagged +), +lines AS ( + SELECT patient_id, any(pid) AS pid, line_no, min(s) AS ls, max(e) AS le, + if(countIf(lbl != '') = 0, '(no class)', + arrayStringConcat(arraySort(groupUniqArrayIf(lbl, lbl != '')), ' + ')) AS combo + FROM numbered GROUP BY patient_id, line_no +), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) * 30.4375 AS os_day + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' + AND attribute_name = 'OS_MONTHS' + GROUP BY pid +), +seen AS ( + SELECT p.stable_id AS pid, max(coalesce(ce.stop_date, ce.start_date)) AS max_ev + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +obs AS ( + SELECT sn.pid AS pid, + greatest(toFloat64(sn.max_ev), coalesce(os.os_day, toFloat64(sn.max_ev))) AS last_seen + FROM seen sn LEFT JOIN os ON os.pid = sn.pid +), +seq AS ( + SELECT pid, line_no, combo, le AS line_end, + leadInFrame(combo) OVER (PARTITION BY pid ORDER BY line_no + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS nxt + FROM lines +), +fated AS ( + SELECT sq2.line_no AS line_no, sq2.combo AS combo, sq2.pid AS pid, + coalesce(sq2.nxt, '') AS nxt, + if(coalesce(sq2.nxt, '') != '', 0, + if(coalesce(o.last_seen, toFloat64(sq2.line_end)) - sq2.line_end >= 90, 1, 2)) AS fate + FROM seq sq2 LEFT JOIN obs o ON o.pid = sq2.pid +) +SELECT step, a, b, fate, n FROM ( + SELECT toUInt32(line_no) AS step, toString(combo) AS a, toString(nxt) AS b, toUInt8(fate) AS fate, toUInt64(uniqExact(pid)) AS n + FROM fated WHERE line_no <= 3 + GROUP BY step, a, b, fate ORDER BY n DESC, step, a, b, fate LIMIT 2000 +) +UNION ALL +SELECT toUInt32(0) AS step, toString(if(cls = '', '(no class)', any(cls_raw))) AS a, + toString(if(cls IN (lowerUTF8(trimBoth('chemo')), lowerUTF8(trimBoth('chemotherapy')), lowerUTF8(trimBoth('immuno')), lowerUTF8(trimBoth('immunotherapy')), lowerUTF8(trimBoth('immunotherapy (including vaccines)')), lowerUTF8(trimBoth('vaccine')), lowerUTF8(trimBoth('targeted')), lowerUTF8(trimBoth('targeted therapy')), lowerUTF8(trimBoth('targeted molecular therapy')), lowerUTF8(trimBoth('targeted antibody therapy')), lowerUTF8(trimBoth('hormone')), lowerUTF8(trimBoth('hormone therapy')), lowerUTF8(trimBoth('hormonal therapy')), lowerUTF8(trimBoth('biologic')), lowerUTF8(trimBoth('investigational')), lowerUTF8(trimBoth('systemic therapy')), lowerUTF8(trimBoth('medical therapy')), lowerUTF8(trimBoth('pharmaceutical therapy, nos'))), '#excluded by the document', '#not a line class')) AS b, + toUInt8(0) AS fate, toUInt64(count()) AS n +FROM txAll WHERE eid NOT IN (SELECT eid FROM txLabelled) +GROUP BY cls, b + +-- view 0 sequence: treatmentSequence:SUBTYPE/gap90 · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +txAll AS ( + SELECT ce.clinical_event_id AS eid, ce.patient_id AS patient_id, p.stable_id AS pid, + ce.start_date AS s, coalesce(ce.stop_date, ce.start_date) AS e, + coalesce(cl.cls, '') AS cls, coalesce(cl.cls_raw, '') AS cls_raw + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + LEFT JOIN ( + SELECT clinical_event_id, argMin(lowerUTF8(trimBoth(value)), (lowerUTF8(trimBoth(key)) != 'subtype', lowerUTF8(trimBoth(value)))) AS cls, + argMin(trimBoth(value), (lowerUTF8(trimBoth(key)) != 'subtype', lowerUTF8(trimBoth(value)))) AS cls_raw + FROM snapshot_db.clinical_event_data + WHERE lowerUTF8(trimBoth(key)) IN (lowerUTF8(trimBoth('subtype')), lowerUTF8(trimBoth('treatment_type'))) AND lowerUTF8(trimBoth(value)) != '' + AND clinical_event_id IN (SELECT clinical_event_id FROM snapshot_db.clinical_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND lowerUTF8(trimBoth(event_type)) = lowerUTF8(trimBoth('treatment'))) + GROUP BY clinical_event_id + ) cl ON cl.clinical_event_id = ce.clinical_event_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND lowerUTF8(trimBoth(ce.event_type)) = lowerUTF8(trimBoth('treatment')) + AND p.stable_id IN (SELECT pid FROM cohort) +), +txLabelled AS ( + SELECT t.eid AS eid, t.patient_id AS patient_id, t.pid AS pid, t.s AS s, t.e AS e, t.cls AS cls, + t.cls AS lk, t.cls_raw AS lraw + FROM txAll t + WHERE t.cls IN (lowerUTF8(trimBoth('chemo')), lowerUTF8(trimBoth('chemotherapy')), lowerUTF8(trimBoth('immuno')), lowerUTF8(trimBoth('immunotherapy')), lowerUTF8(trimBoth('immunotherapy (including vaccines)')), lowerUTF8(trimBoth('vaccine')), lowerUTF8(trimBoth('targeted')), lowerUTF8(trimBoth('targeted therapy')), lowerUTF8(trimBoth('targeted molecular therapy')), lowerUTF8(trimBoth('targeted antibody therapy')), lowerUTF8(trimBoth('hormone')), lowerUTF8(trimBoth('hormone therapy')), lowerUTF8(trimBoth('hormonal therapy')), lowerUTF8(trimBoth('biologic')), lowerUTF8(trimBoth('investigational')), lowerUTF8(trimBoth('systemic therapy')), lowerUTF8(trimBoth('medical therapy')), lowerUTF8(trimBoth('pharmaceutical therapy, nos'))) +), +spell AS ( + SELECT lk, arraySort((x) -> (-x.2, x.1), groupArray((lraw, c)))[1].1 AS lbl FROM ( + SELECT lk, lraw, count() AS c FROM txLabelled WHERE lk != '' GROUP BY lk, lraw + ) GROUP BY lk +), +tx AS ( + SELECT x.eid AS eid, x.patient_id AS patient_id, x.pid AS pid, x.s AS s, x.e AS e, x.cls AS cls, + if(x.lk = '', '', sp.lbl) AS lbl + FROM txLabelled x LEFT JOIN spell sp ON sp.lk = x.lk +), +flagged AS ( + SELECT *, max(toNullable(e)) OVER (PARTITION BY patient_id + ORDER BY s, e, eid ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) AS pms + FROM tx +), +numbered AS ( + SELECT *, sum(if(pms IS NULL OR s > pms + 90, 1, 0)) OVER ( + PARTITION BY patient_id ORDER BY s, e, eid ROWS UNBOUNDED PRECEDING) AS line_no + FROM flagged +), +lines AS ( + SELECT patient_id, any(pid) AS pid, line_no, min(s) AS ls, max(e) AS le, + if(countIf(lbl != '') = 0, '(no class)', + arrayStringConcat(arraySort(groupUniqArrayIf(lbl, lbl != '')), ' + ')) AS combo + FROM numbered GROUP BY patient_id, line_no +), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + if(isFinite(ifNull(toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), nan)), toFloat64OrNull(anyIf(attribute_value, attribute_name = 'OS_MONTHS')), NULL) * 30.4375 AS os_day + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' + AND attribute_name = 'OS_MONTHS' + GROUP BY pid +), +seen AS ( + SELECT p.stable_id AS pid, max(coalesce(ce.stop_date, ce.start_date)) AS max_ev + FROM snapshot_db.clinical_event ce + JOIN snapshot_db.patient p ON p.internal_id = ce.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' + AND p.stable_id IN (SELECT pid FROM cohort) + GROUP BY pid +), +obs AS ( + SELECT sn.pid AS pid, + greatest(toFloat64(sn.max_ev), coalesce(os.os_day, toFloat64(sn.max_ev))) AS last_seen + FROM seen sn LEFT JOIN os ON os.pid = sn.pid +), +seq AS ( + SELECT pid, line_no, combo, le AS line_end, + leadInFrame(combo) OVER (PARTITION BY pid ORDER BY line_no + ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS nxt + FROM lines +), +fated AS ( + SELECT sq2.line_no AS line_no, sq2.combo AS combo, sq2.pid AS pid, + coalesce(sq2.nxt, '') AS nxt, + if(coalesce(sq2.nxt, '') != '', 0, + if(coalesce(o.last_seen, toFloat64(sq2.line_end)) - sq2.line_end >= 90, 1, 2)) AS fate + FROM seq sq2 LEFT JOIN obs o ON o.pid = sq2.pid +) +SELECT step, a, b, fate, n FROM ( + SELECT toUInt32(line_no) AS step, toString(combo) AS a, toString(nxt) AS b, toUInt8(fate) AS fate, toUInt64(uniqExact(pid)) AS n + FROM fated WHERE line_no <= 3 + GROUP BY step, a, b, fate ORDER BY n DESC, step, a, b, fate LIMIT 2000 +) +UNION ALL +SELECT toUInt32(0) AS step, toString(if(cls = '', '(no class)', any(cls_raw))) AS a, + toString(if(cls IN (lowerUTF8(trimBoth('chemo')), lowerUTF8(trimBoth('chemotherapy')), lowerUTF8(trimBoth('immuno')), lowerUTF8(trimBoth('immunotherapy')), lowerUTF8(trimBoth('immunotherapy (including vaccines)')), lowerUTF8(trimBoth('vaccine')), lowerUTF8(trimBoth('targeted')), lowerUTF8(trimBoth('targeted therapy')), lowerUTF8(trimBoth('targeted molecular therapy')), lowerUTF8(trimBoth('targeted antibody therapy')), lowerUTF8(trimBoth('hormone')), lowerUTF8(trimBoth('hormone therapy')), lowerUTF8(trimBoth('hormonal therapy')), lowerUTF8(trimBoth('biologic')), lowerUTF8(trimBoth('investigational')), lowerUTF8(trimBoth('systemic therapy')), lowerUTF8(trimBoth('medical therapy')), lowerUTF8(trimBoth('pharmaceutical therapy, nos'))), '#excluded by the document', '#not a line class')) AS b, + toUInt8(0) AS fate, toUInt64(count()) AS n +FROM txAll WHERE eid NOT IN (SELECT eid FROM txLabelled) +GROUP BY cls, b diff --git a/test/snapshots/sequence.svg b/test/snapshots/sequence.svg new file mode 100644 index 0000000..918d66d --- /dev/null +++ b/test/snapshots/sequence.svg @@ -0,0 +1,2 @@ + +Treatment sequence — TP53 mut, TP53 wtChemoHormoneBiologic + ChemoChemo + HormoneChemo + ImmunoChemo + Hormone + TargetedTargetedInvestigationalother51 less common regimensno further linewatched, none startedrecord ends herenothing can be concludedTP53 mut— 11,564 with a first line, 55.5% of paths censoredline 1line 2line 3line 4+Chemo → Chemo, line 1 to 2: 1,097Chemo → other, line 1 to 2: 488Chemo → Biologic + Chemo, line 1 to 2: 329other → other, line 1 to 2: 218Hormone → Hormone, line 1 to 2: 211Biologic + Chemo → Biologic + Chemo, line 1 to 2: 135Chemo → Hormone, line 1 to 2: 126other → Chemo, line 1 to 2: 122Biologic + Chemo → other, line 1 to 2: 111Chemo → Chemo + Immuno, line 1 to 2: 81Biologic + Chemo → Chemo, line 1 to 2: 77Chemo + Hormone → Hormone, line 1 to 2: 77Chemo → Chemo + Hormone, line 1 to 2: 57Chemo → Investigational, line 1 to 2: 56other → Hormone, line 1 to 2: 56Chemo → Targeted, line 1 to 2: 54Hormone → other, line 1 to 2: 53Investigational → other, line 1 to 2: 50other → Targeted, line 1 to 2: 45Targeted → Targeted, line 1 to 2: 44other → Biologic + Chemo, line 1 to 2: 43Chemo + Hormone → other, line 1 to 2: 39Chemo + Immuno → other, line 1 to 2: 38other → Investigational, line 1 to 2: 37Targeted → other, line 1 to 2: 36Hormone → Chemo + Hormone, line 1 to 2: 35Investigational → Chemo, line 1 to 2: 26Chemo + Hormone → Chemo, line 1 to 2: 25Chemo + Immuno → Chemo, line 1 to 2: 25Hormone → Chemo, line 1 to 2: 22Investigational → Investigational, line 1 to 2: 22Chemo → Chemo + Hormone + Targeted, line 1 to 2: 21other → Chemo + Immuno, line 1 to 2: 18Chemo + Immuno → Chemo + Immuno, line 1 to 2: 17Investigational → Targeted, line 1 to 2: 11Chemo + Hormone → Chemo + Hormone, line 1 to 2: 10Chemo + Hormone → Chemo + Hormone + Targeted, line 1 to 2: 10Chemo + Immuno → Biologic + Chemo, line 1 to 2: 10Investigational → Chemo + Immuno, line 1 to 2: 10Biologic + Chemo → Targeted, line 1 to 2: 8Investigational → Hormone, line 1 to 2: 8Biologic + Chemo → Investigational, line 1 to 2: 7Hormone → Chemo + Hormone + Targeted, line 1 to 2: 7Investigational → Biologic + Chemo, line 1 to 2: 7Targeted → Investigational, line 1 to 2: 7other → Chemo + Hormone, line 1 to 2: 7Biologic + Chemo → Hormone, line 1 to 2: 6Chemo + Hormone → Biologic + Chemo, line 1 to 2: 6other → Chemo + Hormone + Targeted, line 1 to 2: 6Chemo + Hormone + Targeted → Chemo, line 1 to 2: 5Chemo + Immuno → Targeted, line 1 to 2: 5Chemo + Hormone + Targeted → other, line 1 to 2: 5Biologic + Chemo → Chemo + Hormone, line 1 to 2: 4Chemo + Hormone → Targeted, line 1 to 2: 4Hormone → Biologic + Chemo, line 1 to 2: 4Hormone → Investigational, line 1 to 2: 4Targeted → Biologic + Chemo, line 1 to 2: 4Biologic + Chemo → Chemo + Immuno, line 1 to 2: 3Chemo + Hormone → Investigational, line 1 to 2: 3Chemo + Immuno → Investigational, line 1 to 2: 3Hormone → Chemo + Immuno, line 1 to 2: 3Chemo + Hormone + Targeted → Hormone, line 1 to 2: 2Hormone → Targeted, line 1 to 2: 2Targeted → Hormone, line 1 to 2: 2Chemo + Hormone + Targeted → Investigational, line 1 to 2: 1Chemo + Hormone + Targeted → Targeted, line 1 to 2: 1Chemo + Immuno → Chemo + Hormone, line 1 to 2: 1Chemo + Immuno → Hormone, line 1 to 2: 1Investigational → Chemo + Hormone, line 1 to 2: 1Investigational → Chemo + Hormone + Targeted, line 1 to 2: 1Targeted → Chemo, line 1 to 2: 1Targeted → Chemo + Hormone + Targeted, line 1 to 2: 1Targeted → Chemo + Immuno, line 1 to 2: 1Chemo → no further line, line 1 to 2: 1,966other → no further line, line 1 to 2: 437Chemo + Immuno → no further line, line 1 to 2: 222Biologic + Chemo → no further line, line 1 to 2: 216Hormone → no further line, line 1 to 2: 170Chemo + Hormone → no further line, line 1 to 2: 135Investigational → no further line, line 1 to 2: 87Targeted → no further line, line 1 to 2: 41Chemo + Hormone + Targeted → no further line, line 1 to 2: 11other → record ends here, line 1 to 2: 1,700Chemo → record ends here, line 1 to 2: 964Biologic + Chemo → record ends here, line 1 to 2: 428Chemo + Hormone → record ends here, line 1 to 2: 335Chemo + Immuno → record ends here, line 1 to 2: 317Hormone → record ends here, line 1 to 2: 161Targeted → record ends here, line 1 to 2: 136Chemo + Hormone + Targeted → record ends here, line 1 to 2: 134Investigational → record ends here, line 1 to 2: 31Chemo → Chemo, line 2 to 3: 279Hormone → Hormone, line 2 to 3: 191other → other, line 2 to 3: 102Biologic + Chemo → Biologic + Chemo, line 2 to 3: 95Chemo → other, line 2 to 3: 94Chemo → Biologic + Chemo, line 2 to 3: 93other → Chemo, line 2 to 3: 48Hormone → other, line 2 to 3: 47Biologic + Chemo → other, line 2 to 3: 43Biologic + Chemo → Chemo, line 2 to 3: 42Targeted → Targeted, line 2 to 3: 35Investigational → other, line 2 to 3: 32Targeted → other, line 2 to 3: 31other → Biologic + Chemo, line 2 to 3: 29Chemo → Investigational, line 2 to 3: 27other → Targeted, line 2 to 3: 21Hormone → Chemo + Hormone, line 2 to 3: 20Chemo → Chemo + Immuno, line 2 to 3: 17Investigational → Investigational, line 2 to 3: 17other → Investigational, line 2 to 3: 17Hormone → Chemo + Hormone + Targeted, line 2 to 3: 15other → Chemo + Immuno, line 2 to 3: 14Investigational → Chemo, line 2 to 3: 12other → Hormone, line 2 to 3: 12Chemo → Chemo + Hormone, line 2 to 3: 11Hormone → Chemo, line 2 to 3: 11Chemo → Hormone, line 2 to 3: 10Biologic + Chemo → Investigational, line 2 to 3: 9Chemo → Targeted, line 2 to 3: 8Chemo + Hormone → Chemo, line 2 to 3: 8Chemo + Immuno → Chemo, line 2 to 3: 8Chemo + Immuno → other, line 2 to 3: 7Chemo + Immuno → Chemo + Immuno, line 2 to 3: 6Chemo + Hormone → other, line 2 to 3: 6Chemo + Hormone → Hormone, line 2 to 3: 5Investigational → Biologic + Chemo, line 2 to 3: 5Investigational → Targeted, line 2 to 3: 5Investigational → Hormone, line 2 to 3: 4Biologic + Chemo → Targeted, line 2 to 3: 3Targeted → Investigational, line 2 to 3: 3Chemo → Chemo + Hormone + Targeted, line 2 to 3: 2Chemo + Hormone → Chemo + Hormone, line 2 to 3: 2Chemo + Hormone + Targeted → Chemo, line 2 to 3: 2Chemo + Immuno → Biologic + Chemo, line 2 to 3: 2Chemo + Immuno → Investigational, line 2 to 3: 2Hormone → Chemo + Immuno, line 2 to 3: 2Investigational → Chemo + Hormone, line 2 to 3: 2Targeted → Chemo + Hormone + Targeted, line 2 to 3: 2other → Chemo + Hormone + Targeted, line 2 to 3: 2Biologic + Chemo → Chemo + Immuno, line 2 to 3: 1Biologic + Chemo → Hormone, line 2 to 3: 1Chemo + Hormone → Targeted, line 2 to 3: 1Chemo + Hormone + Targeted → Chemo + Hormone + Targeted, line 2 to 3: 1Chemo + Hormone + Targeted → other, line 2 to 3: 1Chemo + Immuno → Targeted, line 2 to 3: 1Hormone → Biologic + Chemo, line 2 to 3: 1Hormone → Investigational, line 2 to 3: 1Hormone → Targeted, line 2 to 3: 1other → Chemo + Hormone, line 2 to 3: 1Investigational → Chemo + Immuno, line 2 to 3: 1Targeted → Biologic + Chemo, line 2 to 3: 1Targeted → Chemo, line 2 to 3: 1Chemo → no further line, line 2 to 3: 428other → no further line, line 2 to 3: 205Biologic + Chemo → no further line, line 2 to 3: 115Hormone → no further line, line 2 to 3: 65Investigational → no further line, line 2 to 3: 47Chemo + Immuno → no further line, line 2 to 3: 31Chemo + Hormone → no further line, line 2 to 3: 23Targeted → no further line, line 2 to 3: 20Chemo + Hormone + Targeted → no further line, line 2 to 3: 5other → record ends here, line 2 to 3: 587Chemo → record ends here, line 2 to 3: 431Biologic + Chemo → record ends here, line 2 to 3: 229Hormone → record ends here, line 2 to 3: 135Targeted → record ends here, line 2 to 3: 81Chemo + Immuno → record ends here, line 2 to 3: 76Chemo + Hormone → record ends here, line 2 to 3: 70Chemo + Hormone + Targeted → record ends here, line 2 to 3: 37Investigational → record ends here, line 2 to 3: 15Hormone → Hormone, line 3 to 4: 112Chemo → Chemo, line 3 to 4: 81Biologic + Chemo → Biologic + Chemo, line 3 to 4: 50other → other, line 3 to 4: 49Chemo → Biologic + Chemo, line 3 to 4: 34Hormone → other, line 3 to 4: 30Chemo → other, line 3 to 4: 26other → Chemo, line 3 to 4: 24Biologic + Chemo → other, line 3 to 4: 16Targeted → Targeted, line 3 to 4: 15Investigational → other, line 3 to 4: 15Biologic + Chemo → Chemo, line 3 to 4: 14Hormone → Chemo + Hormone, line 3 to 4: 12Investigational → Investigational, line 3 to 4: 12Targeted → other, line 3 to 4: 12other → Biologic + Chemo, line 3 to 4: 10Hormone → Chemo + Hormone + Targeted, line 3 to 4: 8Investigational → Biologic + Chemo, line 3 to 4: 8Chemo → Chemo + Immuno, line 3 to 4: 6Hormone → Chemo, line 3 to 4: 5Investigational → Chemo, line 3 to 4: 5other → Targeted, line 3 to 4: 5other → Hormone, line 3 to 4: 5Chemo + Hormone → Hormone, line 3 to 4: 4Chemo + Immuno → other, line 3 to 4: 4Chemo + Hormone → other, line 3 to 4: 4Biologic + Chemo → Chemo + Immuno, line 3 to 4: 3Biologic + Chemo → Investigational, line 3 to 4: 3Chemo + Hormone → Chemo, line 3 to 4: 3Hormone → Targeted, line 3 to 4: 3Targeted → Chemo, line 3 to 4: 3other → Chemo + Immuno, line 3 to 4: 3Chemo → Chemo + Hormone, line 3 to 4: 2Chemo → Hormone, line 3 to 4: 2Chemo → Investigational, line 3 to 4: 2Hormone → Chemo + Immuno, line 3 to 4: 2Investigational → Hormone, line 3 to 4: 2Targeted → Biologic + Chemo, line 3 to 4: 2other → Investigational, line 3 to 4: 2other → Chemo + Hormone, line 3 to 4: 2Biologic + Chemo → Hormone, line 3 to 4: 1Biologic + Chemo → Targeted, line 3 to 4: 1other → Chemo + Hormone + Targeted, line 3 to 4: 1Chemo → Targeted, line 3 to 4: 1Chemo + Hormone → Biologic + Chemo, line 3 to 4: 1Chemo + Hormone → Chemo + Hormone, line 3 to 4: 1Chemo + Hormone → Investigational, line 3 to 4: 1Chemo + Hormone + Targeted → Biologic + Chemo, line 3 to 4: 1Chemo + Hormone + Targeted → other, line 3 to 4: 1Chemo + Immuno → Biologic + Chemo, line 3 to 4: 1Chemo + Immuno → Chemo + Hormone, line 3 to 4: 1Chemo + Immuno → Chemo + Immuno, line 3 to 4: 1Chemo + Immuno → Investigational, line 3 to 4: 1Hormone → Investigational, line 3 to 4: 1Investigational → Chemo + Hormone, line 3 to 4: 1Investigational → Targeted, line 3 to 4: 1Targeted → Chemo + Hormone + Targeted, line 3 to 4: 1Targeted → Investigational, line 3 to 4: 1Chemo → no further line, line 3 to 4: 114other → no further line, line 3 to 4: 67Biologic + Chemo → no further line, line 3 to 4: 45Hormone → no further line, line 3 to 4: 26Investigational → no further line, line 3 to 4: 20Chemo + Immuno → no further line, line 3 to 4: 16Targeted → no further line, line 3 to 4: 13Chemo + Hormone + Targeted → no further line, line 3 to 4: 3Chemo + Hormone → no further line, line 3 to 4: 1other → record ends here, line 3 to 4: 195Chemo → record ends here, line 3 to 4: 143Biologic + Chemo → record ends here, line 3 to 4: 93Targeted → record ends here, line 3 to 4: 28Hormone → record ends here, line 3 to 4: 24Chemo + Hormone → record ends here, line 3 to 4: 21Chemo + Hormone + Targeted → record ends here, line 3 to 4: 17Chemo + Immuno → record ends here, line 3 to 4: 17Investigational → record ends here, line 3 to 4: 12Chemo 5,239 (line 1)other 2,689 (line 1)Biologic + Chemo 995 (line 1)Hormone 672 (line 1)Chemo + Hormone 644 (line 1)Chemo + Immuno 639 (line 1)Targeted 273 (line 1)Investigational 254 (line 1)Chemo + Hormone + Targeted 159 (line 1)Chemo 1,400 (line 2)other 1,038 (line 2)Biologic + Chemo 538 (line 2)Hormone 489 (line 2)Targeted 174 (line 2)Investigational 140 (line 2)Chemo + Immuno 133 (line 2)Chemo + Hormone 115 (line 2)Chemo + Hormone + Targeted 46 (line 2)no further line 3,285 (line 2)record ends here 4,206 (line 2)Chemo 411 (line 3)other 363 (line 3)Biologic + Chemo 226 (line 3)Hormone 223 (line 3)Investigational 76 (line 3)Targeted 75 (line 3)Chemo + Immuno 41 (line 3)Chemo + Hormone 36 (line 3)Chemo + Hormone + Targeted 22 (line 3)no further line 939 (line 3)record ends here 1,661 (line 3)other 157 (line 4)Chemo 135 (line 4)Hormone 126 (line 4)Biologic + Chemo 107 (line 4)Targeted 26 (line 4)Investigational 23 (line 4)Chemo + Hormone 19 (line 4)Chemo + Immuno 15 (line 4)Chemo + Hormone + Targeted 10 (line 4)no further line 305 (line 4)record ends here 550 (line 4)Chemo 5,239other 2,689Biologic + Chemo 995Hormone 672Chemo + Hormone 644Chemo + Immuno 639Targeted 273Investigational 254Chemo + Hormone + Targeted 159Chemo 1,400other 1,038Biologic + Chemo 538Hormone 489Targeted 174Investigational 140Chemo + Immuno 133Chemo + Hormone 115no further line 3,285record ends here 4,206Chemo 411other 363Biologic + Chemo 226Hormone 223Investigational 76Targeted 75Chemo + Immuno 41Chemo + Hormone + Targeted 22no further line 939record ends here 1,661other 157Chemo 135Hormone 126Biologic + Chemo 107Investigational 23Chemo + Hormone 19Chemo + Immuno 15no further line 305record ends here 550TP53 wt— 9,645 with a first line, 56.8% of paths censoredline 1line 2line 3line 4+Hormone → Hormone, line 1 to 2: 630Chemo → Chemo, line 1 to 2: 479Chemo → other, line 1 to 2: 288Chemo → Hormone, line 1 to 2: 270other → other, line 1 to 2: 223Hormone → other, line 1 to 2: 171Chemo + Hormone → Hormone, line 1 to 2: 134other → Chemo, line 1 to 2: 104other → Hormone, line 1 to 2: 103Chemo → Biologic + Chemo, line 1 to 2: 73Hormone → Chemo + Hormone, line 1 to 2: 65other → Targeted, line 1 to 2: 61Targeted → Targeted, line 1 to 2: 54Investigational → other, line 1 to 2: 54Biologic + Chemo → other, line 1 to 2: 53Chemo → Targeted, line 1 to 2: 51Chemo → Chemo + Immuno, line 1 to 2: 47Investigational → Investigational, line 1 to 2: 43Chemo → Chemo + Hormone, line 1 to 2: 42Chemo → Investigational, line 1 to 2: 42Targeted → other, line 1 to 2: 39Biologic + Chemo → Biologic + Chemo, line 1 to 2: 38Chemo + Hormone → other, line 1 to 2: 38Biologic + Chemo → Chemo, line 1 to 2: 35other → Investigational, line 1 to 2: 35Hormone → Chemo, line 1 to 2: 33Hormone → Chemo + Hormone + Targeted, line 1 to 2: 32Chemo + Immuno → other, line 1 to 2: 31other → Biologic + Chemo, line 1 to 2: 29Chemo → Chemo + Hormone + Targeted, line 1 to 2: 28Chemo + Hormone → Chemo, line 1 to 2: 24Chemo + Immuno → Chemo, line 1 to 2: 24Investigational → Hormone, line 1 to 2: 23other → Chemo + Hormone + Targeted, line 1 to 2: 23Investigational → Chemo, line 1 to 2: 21Chemo + Hormone → Chemo + Hormone + Targeted, line 1 to 2: 17Chemo + Immuno → Chemo + Immuno, line 1 to 2: 16Investigational → Targeted, line 1 to 2: 16Chemo + Hormone → Chemo + Hormone, line 1 to 2: 15Chemo + Hormone + Targeted → other, line 1 to 2: 13Chemo + Hormone + Targeted → Chemo, line 1 to 2: 11Chemo + Immuno → Targeted, line 1 to 2: 10Chemo + Immuno → Biologic + Chemo, line 1 to 2: 9Targeted → Chemo, line 1 to 2: 9Biologic + Chemo → Investigational, line 1 to 2: 8Hormone → Investigational, line 1 to 2: 8other → Chemo + Immuno, line 1 to 2: 8Hormone → Targeted, line 1 to 2: 7Investigational → Biologic + Chemo, line 1 to 2: 7Biologic + Chemo → Hormone, line 1 to 2: 6Biologic + Chemo → Targeted, line 1 to 2: 6Chemo + Hormone + Targeted → Targeted, line 1 to 2: 6other → Chemo + Hormone, line 1 to 2: 6Targeted → Investigational, line 1 to 2: 5Biologic + Chemo → Chemo + Immuno, line 1 to 2: 4Chemo + Immuno → Investigational, line 1 to 2: 4Hormone → Biologic + Chemo, line 1 to 2: 4Hormone → Chemo + Immuno, line 1 to 2: 4Investigational → Chemo + Hormone, line 1 to 2: 4Chemo + Hormone + Targeted → Chemo + Hormone + Targeted, line 1 to 2: 3Chemo + Hormone + Targeted → Investigational, line 1 to 2: 3Targeted → Hormone, line 1 to 2: 3Chemo + Hormone → Biologic + Chemo, line 1 to 2: 2Chemo + Hormone → Investigational, line 1 to 2: 2Chemo + Hormone + Targeted → Hormone, line 1 to 2: 2Investigational → Chemo + Hormone + Targeted, line 1 to 2: 2Investigational → Chemo + Immuno, line 1 to 2: 2Biologic + Chemo → Chemo + Hormone, line 1 to 2: 1Chemo + Hormone → Chemo + Immuno, line 1 to 2: 1Chemo + Hormone → Targeted, line 1 to 2: 1Chemo + Hormone + Targeted → Biologic + Chemo, line 1 to 2: 1Chemo + Immuno → Hormone, line 1 to 2: 1Targeted → Biologic + Chemo, line 1 to 2: 1Targeted → Chemo + Hormone + Targeted, line 1 to 2: 1Chemo → no further line, line 1 to 2: 868Hormone → no further line, line 1 to 2: 643other → no further line, line 1 to 2: 393Chemo + Hormone → no further line, line 1 to 2: 115Chemo + Immuno → no further line, line 1 to 2: 115Investigational → no further line, line 1 to 2: 99Biologic + Chemo → no further line, line 1 to 2: 81Targeted → no further line, line 1 to 2: 49Chemo + Hormone + Targeted → no further line, line 1 to 2: 36other → record ends here, line 1 to 2: 1,449Hormone → record ends here, line 1 to 2: 612Chemo + Hormone → record ends here, line 1 to 2: 432Chemo → record ends here, line 1 to 2: 363Chemo + Hormone + Targeted → record ends here, line 1 to 2: 269Targeted → record ends here, line 1 to 2: 159Chemo + Immuno → record ends here, line 1 to 2: 155Biologic + Chemo → record ends here, line 1 to 2: 119Investigational → record ends here, line 1 to 2: 19Hormone → Hormone, line 2 to 3: 485Chemo → Chemo, line 2 to 3: 169Hormone → other, line 2 to 3: 118other → other, line 2 to 3: 104Chemo → other, line 2 to 3: 55other → Chemo, line 2 to 3: 52Targeted → Targeted, line 2 to 3: 44Hormone → Chemo + Hormone + Targeted, line 2 to 3: 33Investigational → other, line 2 to 3: 32Hormone → Chemo + Hormone, line 2 to 3: 28Targeted → other, line 2 to 3: 27Investigational → Investigational, line 2 to 3: 26Biologic + Chemo → other, line 2 to 3: 24other → Investigational, line 2 to 3: 23other → Hormone, line 2 to 3: 20Biologic + Chemo → Biologic + Chemo, line 2 to 3: 19Chemo → Hormone, line 2 to 3: 19Chemo + Hormone → Hormone, line 2 to 3: 17Hormone → Chemo, line 2 to 3: 16Investigational → Chemo, line 2 to 3: 16other → Targeted, line 2 to 3: 16Chemo → Biologic + Chemo, line 2 to 3: 15other → Biologic + Chemo, line 2 to 3: 14Chemo → Chemo + Immuno, line 2 to 3: 13Biologic + Chemo → Chemo, line 2 to 3: 12Chemo → Investigational, line 2 to 3: 11Chemo → Targeted, line 2 to 3: 11Investigational → Biologic + Chemo, line 2 to 3: 11Investigational → Targeted, line 2 to 3: 10Chemo → Chemo + Hormone + Targeted, line 2 to 3: 9Biologic + Chemo → Investigational, line 2 to 3: 8Chemo → Chemo + Hormone, line 2 to 3: 8Hormone → Investigational, line 2 to 3: 8Investigational → Hormone, line 2 to 3: 8Chemo + Hormone → Chemo, line 2 to 3: 7Chemo + Hormone → other, line 2 to 3: 7Chemo + Immuno → other, line 2 to 3: 7other → Chemo + Hormone + Targeted, line 2 to 3: 7Chemo + Hormone + Targeted → Hormone, line 2 to 3: 6Chemo + Immuno → Chemo + Immuno, line 2 to 3: 6Targeted → Chemo, line 2 to 3: 6Chemo + Immuno → Chemo, line 2 to 3: 5Hormone → Targeted, line 2 to 3: 5other → Chemo + Hormone, line 2 to 3: 5other → Chemo + Immuno, line 2 to 3: 5Biologic + Chemo → Targeted, line 2 to 3: 3Chemo + Hormone → Chemo + Hormone + Targeted, line 2 to 3: 3Targeted → Investigational, line 2 to 3: 3Biologic + Chemo → Chemo + Hormone, line 2 to 3: 2Chemo + Hormone + Targeted → Chemo + Hormone + Targeted, line 2 to 3: 2Chemo + Immuno → Biologic + Chemo, line 2 to 3: 2Hormone → Biologic + Chemo, line 2 to 3: 2Hormone → Chemo + Immuno, line 2 to 3: 2Investigational → Chemo + Hormone, line 2 to 3: 2Targeted → Biologic + Chemo, line 2 to 3: 2Chemo + Hormone + Targeted → other, line 2 to 3: 2Chemo + Hormone → Chemo + Hormone, line 2 to 3: 1Chemo + Hormone → Chemo + Immuno, line 2 to 3: 1Chemo + Hormone → Investigational, line 2 to 3: 1Chemo + Hormone + Targeted → Chemo, line 2 to 3: 1Chemo + Hormone + Targeted → Chemo + Hormone, line 2 to 3: 1Chemo + Hormone + Targeted → Investigational, line 2 to 3: 1Chemo + Immuno → Investigational, line 2 to 3: 1Chemo + Immuno → Targeted, line 2 to 3: 1Investigational → Chemo + Hormone + Targeted, line 2 to 3: 1Targeted → Chemo + Hormone, line 2 to 3: 1Targeted → Chemo + Hormone + Targeted, line 2 to 3: 1Targeted → Hormone, line 2 to 3: 1Chemo → no further line, line 2 to 3: 205Hormone → no further line, line 2 to 3: 183other → no further line, line 2 to 3: 176Investigational → no further line, line 2 to 3: 35Biologic + Chemo → no further line, line 2 to 3: 32Chemo + Immuno → no further line, line 2 to 3: 27Targeted → no further line, line 2 to 3: 25Chemo + Hormone → no further line, line 2 to 3: 18Chemo + Hormone + Targeted → no further line, line 2 to 3: 11other → record ends here, line 2 to 3: 488Hormone → record ends here, line 2 to 3: 292Chemo → record ends here, line 2 to 3: 225Targeted → record ends here, line 2 to 3: 102Chemo + Hormone + Targeted → record ends here, line 2 to 3: 82Chemo + Hormone → record ends here, line 2 to 3: 78Biologic + Chemo → record ends here, line 2 to 3: 64Chemo + Immuno → record ends here, line 2 to 3: 33Investigational → record ends here, line 2 to 3: 9Hormone → Hormone, line 3 to 4: 298Hormone → other, line 3 to 4: 65Chemo → Chemo, line 3 to 4: 63other → other, line 3 to 4: 44Chemo → other, line 3 to 4: 23Hormone → Chemo + Hormone + Targeted, line 3 to 4: 22Hormone → Chemo + Hormone, line 3 to 4: 19Targeted → Targeted, line 3 to 4: 19Investigational → Investigational, line 3 to 4: 18Investigational → other, line 3 to 4: 18other → Chemo, line 3 to 4: 14Biologic + Chemo → Biologic + Chemo, line 3 to 4: 11other → Investigational, line 3 to 4: 10Targeted → other, line 3 to 4: 10Chemo → Hormone, line 3 to 4: 9Chemo → Biologic + Chemo, line 3 to 4: 8Investigational → Chemo, line 3 to 4: 8Chemo → Chemo + Hormone, line 3 to 4: 7Hormone → Chemo, line 3 to 4: 7Investigational → Targeted, line 3 to 4: 7Chemo + Hormone + Targeted → Chemo, line 3 to 4: 6Investigational → Hormone, line 3 to 4: 6other → Hormone, line 3 to 4: 6other → Chemo + Hormone + Targeted, line 3 to 4: 6other → Biologic + Chemo, line 3 to 4: 6Biologic + Chemo → Chemo, line 3 to 4: 5Chemo + Hormone → Hormone, line 3 to 4: 5other → Chemo + Hormone, line 3 to 4: 5Chemo + Hormone → Chemo, line 3 to 4: 4Chemo + Hormone + Targeted → Chemo + Hormone + Targeted, line 3 to 4: 4Investigational → Chemo + Immuno, line 3 to 4: 4Chemo + Hormone + Targeted → other, line 3 to 4: 4other → Targeted, line 3 to 4: 4Chemo → Investigational, line 3 to 4: 3Chemo → Targeted, line 3 to 4: 3Investigational → Chemo + Hormone + Targeted, line 3 to 4: 3Biologic + Chemo → other, line 3 to 4: 3Chemo → Chemo + Immuno, line 3 to 4: 2Chemo + Hormone → Chemo + Hormone + Targeted, line 3 to 4: 2Hormone → Investigational, line 3 to 4: 2Targeted → Investigational, line 3 to 4: 2other → Chemo + Immuno, line 3 to 4: 2Biologic + Chemo → Targeted, line 3 to 4: 1Chemo → Chemo + Hormone + Targeted, line 3 to 4: 1Chemo + Hormone → other, line 3 to 4: 1Chemo + Hormone + Targeted → Biologic + Chemo, line 3 to 4: 1Chemo + Hormone + Targeted → Chemo + Hormone, line 3 to 4: 1Chemo + Hormone + Targeted → Hormone, line 3 to 4: 1Chemo + Hormone + Targeted → Targeted, line 3 to 4: 1Chemo + Immuno → Chemo, line 3 to 4: 1Chemo + Immuno → Chemo + Immuno, line 3 to 4: 1Chemo + Immuno → other, line 3 to 4: 1Hormone → Chemo + Immuno, line 3 to 4: 1Investigational → Biologic + Chemo, line 3 to 4: 1Targeted → Biologic + Chemo, line 3 to 4: 1Targeted → Chemo, line 3 to 4: 1Targeted → Chemo + Hormone + Targeted, line 3 to 4: 1Targeted → Hormone, line 3 to 4: 1other → no further line, line 3 to 4: 78Chemo → no further line, line 3 to 4: 73Hormone → no further line, line 3 to 4: 60Biologic + Chemo → no further line, line 3 to 4: 16Targeted → no further line, line 3 to 4: 15Investigational → no further line, line 3 to 4: 12Chemo + Hormone → no further line, line 3 to 4: 11Chemo + Immuno → no further line, line 3 to 4: 8Chemo + Hormone + Targeted → no further line, line 3 to 4: 4other → record ends here, line 3 to 4: 201Chemo → record ends here, line 3 to 4: 92Hormone → record ends here, line 3 to 4: 82Targeted → record ends here, line 3 to 4: 40Chemo + Hormone + Targeted → record ends here, line 3 to 4: 34Biologic + Chemo → record ends here, line 3 to 4: 29Chemo + Hormone → record ends here, line 3 to 4: 25Chemo + Immuno → record ends here, line 3 to 4: 16Investigational → record ends here, line 3 to 4: 5Chemo 2,551 (line 1)other 2,434 (line 1)Hormone 2,209 (line 1)Chemo + Hormone 781 (line 1)Chemo + Immuno 365 (line 1)Biologic + Chemo 351 (line 1)Chemo + Hormone + Targeted 344 (line 1)Targeted 320 (line 1)Investigational 290 (line 1)Hormone 1,172 (line 2)other 910 (line 2)Chemo 740 (line 2)Targeted 212 (line 2)Biologic + Chemo 164 (line 2)Investigational 150 (line 2)Chemo + Hormone 133 (line 2)Chemo + Hormone + Targeted 106 (line 2)Chemo + Immuno 82 (line 2)no further line 2,399 (line 2)record ends here 3,577 (line 2)Hormone 556 (line 3)other 376 (line 3)Chemo 284 (line 3)Targeted 90 (line 3)Investigational 82 (line 3)Biologic + Chemo 65 (line 3)Chemo + Hormone + Targeted 56 (line 3)Chemo + Hormone 48 (line 3)Chemo + Immuno 27 (line 3)no further line 712 (line 3)record ends here 1,373 (line 3)Hormone 326 (line 4)other 169 (line 4)Chemo 109 (line 4)Chemo + Hormone + Targeted 39 (line 4)Targeted 35 (line 4)Investigational 35 (line 4)Chemo + Hormone 32 (line 4)Biologic + Chemo 28 (line 4)Chemo + Immuno 10 (line 4)no further line 277 (line 4)record ends here 524 (line 4)Chemo 2,551other 2,434Hormone 2,209Chemo + Hormone 781Chemo + Immuno 365Biologic + Chemo 351Chemo + Hormone + Targeted 344Targeted 320Investigational 290Hormone 1,172other 910Chemo 740Targeted 212Biologic + Chemo 164Investigational 150Chemo + Hormone 133Chemo + Hormone + Targeted 106no further line 2,399record ends here 3,577Hormone 556other 376Chemo 284Targeted 90Investigational 82Biologic + Chemo 65Chemo + Hormone 48Chemo + Immuno 27no further line 712record ends here 1,373Hormone 326other 169Chemo 109Chemo + Hormone + Targeted 39Targeted 35Chemo + Hormone 32Biologic + Chemo 28no further line 277record ends here 5248 of 84 nodes are too small to label here; each names itself and its count on hover, and its colour is in the key above. Therapies are grouped into LINESbefore being sequenced, by the definition every line count here shares: systemic-therapy treatment records (class, from SUBTYPE or elseTREATMENT_TYPE, on the systemic list: chemotherapy, immunotherapy, targeted, hormone, biologic, investigational and their spellings; radiation, surgery,bone and ancillary treatment are not lines). A record starting more than 90 days after every earlier one has stopped begins a new line; anything closer is thesame line, and a line is labelled by its whole combination (sorted, so 'A + B' and 'B + A' are one regimen). That grouping is the point — a patient here has amedian of 6 treatment records and 4 distinct agents, and combination therapy is several records describing ONE decision, not several lines. Lines arelabelled by SUBTYPE. ENDING A PATH IS SPLIT IN TWO, because the difference matters more than anything else here: 'no further line' means the study keptwatching for at least 90 days (one line gap, the same rule that defines a line) and saw no further therapy; 'record ends here' means it did not, so nothing canbe concluded about that patient. 55.5% of paths end censored — reading those as patients who finished treatment would be a claim about therecord-keeping dressed up as one about the patient. Neither terminal is an outcome measure. 51 less common regimens folded into 'other', which is 23.3%of first-line patients in the first panel — combination regimens have a genuinely long tail, so 'other' is real diversity rather than a rounding bucket. Raise topNto split it further. Both panels share one scale and one colour per regimen, so their heights are directly comparable. TP53 mut: 11,564 with a first line; TP53wt: 9,645 with a first line. diff --git a/test/snapshots/sequence.txt b/test/snapshots/sequence.txt new file mode 100644 index 0000000..cebf052 --- /dev/null +++ b/test/snapshots/sequence.txt @@ -0,0 +1,24 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- TP53 mut: 13,105 patients — OQL[TP53: MUT] +- TP53 wt: 11,594 patients — NOT OQL[TP53:] AND profiled for TP53 MUTATION + +Treatment sequence (lines of therapy by SUBTYPE, 90-day line gap): + TP53 mut: 11,564 with a first line — Chemo 5,239, other 2,689, Biologic + Chemo 995, Hormone 672, Chemo + Hormone 644 + of all paths, 4,529 were WATCHED and began no further line; 6,417 (55%) end because the RECORD stops — nothing can be concluded about those + TP53 wt: 9,645 with a first line — Chemo 2,551, other 2,434, Hormone 2,209, Chemo + Hormone 781, Chemo + Immuno 365 + of all paths, 3,388 were WATCHED and began no further line; 5,474 (57%) end because the RECORD stops — nothing can be concluded about those + CAVEAT (tell the user): Therapies are grouped into LINES before being sequenced, by the definition every line count here shares: systemic-therapy treatment records (class, from SUBTYPE or else TREATMENT_TYPE, on the systemic list: chemotherapy, immunotherapy, targeted, hormone, biologic, investigational and their spellings; radiation, surgery, bone and ancillary treatment are not lines). A record starting more than 90 days after every earlier one has stopped begins a new line; anything closer is the same line, and a line is labelled by its whole combination (sorted, so 'A + B' and 'B + A' are one regimen). That grouping is the point — a patient here has a median of 6 treatment records and 4 distinct agents, and combination therapy is several records describing ONE decision, not several lines. Lines are labelled by SUBTYPE. ENDING A PATH IS SPLIT IN TWO, because the difference matters more than anything else here: 'no further line' means the study kept watching for at least 90 days (one line gap, the same rule that defines a line) and saw no further therapy; 'record ends here' means it did not, so nothing can be concluded about that patient. 55.5% of paths end censored — reading those as patients who finished treatment would be a claim about the record-keeping dressed up as one about the patient. Neither terminal is an outcome measure. 51 less common regimens folded into 'other', which is 23.3% of first-line patients in the first panel — combination regimens have a genuinely long tail, so 'other' is real diversity rather than a rounding bucket. Raise topN to split it further. Both panels share one scale and one colour per regimen, so their heights are directly comparable. TP53 mut: 11,564 with a first line; TP53 wt: 9,645 with a first line. + METHOD: + - Build lines and count what follows what [TP53 mut · msk_chord_2024]: The treatmentSequence query above builds every patient's lines in the database and returns, per line number, how many patients went from one regimen to the next, stopped, or were lost to follow-up — counts only — plus how many records it set aside. + - Build lines and count what follows what [TP53 wt · msk_chord_2024]: The treatmentSequence query above builds every patient's lines in the database and returns, per line number, how many patients went from one regimen to the next, stopped, or were lost to follow-up — counts only — plus how many records it set aside. + - Choose the records that form lines: The one definition every line count shares (lib/treatment-lines.ts): treatment records whose class is systemic therapy (chemo, chemotherapy, immuno, immunotherapy, immunotherapy (including vaccines), vaccine, targeted, targeted therapy, targeted molecular therapy, targeted antibody therapy, hormone, hormone therapy, hormonal therapy, biologic, investigational, systemic therapy, medical therapy, pharmaceutical therapy, nos). A record's class is its SUBTYPE, or its TREATMENT_TYPE where it has none; names and values match ignoring case. + Radiation Therapy: 28,738 records set aside: not a line class + Prior Medications to MSK: 19,366 records set aside: not a line class + Bone Treatment: 5,548 records set aside: not a line class + Other: 12 records set aside: not a line class + - Group records into lines: Per patient, by start date: a record starting more than 90 days after every earlier one has stopped begins a new line; anything closer — overlapping, or a switch within the gap — is the same line. A line is named by its sorted combination of classes ('A + B'); the label never decides which records form a line. + - Decide how each path ends: A patient's last line ends in 'no further line' only if they were observed for at least 90 days after it — their last contact being the later of their last recorded event of any type and their OS follow-up (OS_MONTHS × 30.4375 days) — and in 'record ends here' otherwise. Lines are followed up to line 3. + - Keep the 8 most common regimens: Flows are summed across studies, then regimens ranked by the patients leaving them (or, for one seen only as a destination, arriving), ties by name, across every panel so a regimen keeps one identity; the rest are drawn as 'other'. + regimens folded into 'other': 51 diff --git a/test/snapshots/survival.json b/test/snapshots/survival.json new file mode 100644 index 0000000..f6ccbb2 --- /dev/null +++ b/test/snapshots/survival.json @@ -0,0 +1,399 @@ +{ + "study": "ucec_msk_2018", + "cohorts": { + "MSI-H": { + "count": 28, + "text": "MSI_STATUS in [MSI-H] (any sample)", + "studies": [ + "ucec_msk_2018" + ] + }, + "MSS": { + "count": 148, + "text": "MSI_STATUS in [MSS] (any sample)", + "studies": [ + "ucec_msk_2018" + ] + } + }, + "views": [ + { + "kind": "survival", + "cohorts": [ + "MSI-H", + "MSS" + ], + "curves": [ + { + "cohort": "MSI-H", + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 1.67, + "s": 0.9643 + }, + { + "t": 3.3, + "s": 0.9286 + }, + { + "t": 5.5, + "s": 0.8929 + }, + { + "t": 5.63, + "s": 0.8571 + }, + { + "t": 8.8, + "s": 0.8182 + }, + { + "t": 9.77, + "s": 0.7773 + }, + { + "t": 10.57, + "s": 0.7364 + }, + { + "t": 12.47, + "s": 0.693 + }, + { + "t": 13.37, + "s": 0.6497 + }, + { + "t": 13.77, + "s": 0.6064 + }, + { + "t": 15.03, + "s": 0.5631 + }, + { + "t": 18.3, + "s": 0.5162 + }, + { + "t": 18.37, + "s": 0.4693 + }, + { + "t": 20.9, + "s": 0.4223 + }, + { + "t": 21.63, + "s": 0.3754 + }, + { + "t": 24.9, + "s": 0.3285 + }, + { + "t": 29.6, + "s": 0.2816 + }, + { + "t": 30.5, + "s": 0.2346 + }, + { + "t": 32.57, + "s": 0.1877 + }, + { + "…": "4 more", + "sha256": "ae4e15c7574d45c3" + } + ], + "median": 18.37, + "n": 28, + "events": 23, + "atRisk": [ + 28, + 28, + 27, + 27, + 26, + 26, + 24, + 23, + 22, + 20, + 19, + 18, + 17, + 16, + 14, + 14, + 13, + 13, + 12, + 10, + { + "…": "107 more", + "sha256": "ce019366da5426a4" + } + ], + "missing": 0 + }, + { + "cohort": "MSS", + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 1.9, + "s": 0.9932 + }, + { + "t": 2.57, + "s": 0.9865 + }, + { + "t": 2.6, + "s": 0.9797 + }, + { + "t": 2.9, + "s": 0.973 + }, + { + "t": 3.5, + "s": 0.9662 + }, + { + "t": 3.83, + "s": 0.9595 + }, + { + "t": 4.4, + "s": 0.9527 + }, + { + "t": 4.43, + "s": 0.9459 + }, + { + "t": 4.47, + "s": 0.9392 + }, + { + "t": 4.8, + "s": 0.9324 + }, + { + "t": 5.03, + "s": 0.9257 + }, + { + "t": 5.1, + "s": 0.9189 + }, + { + "t": 5.27, + "s": 0.9122 + }, + { + "t": 5.37, + "s": 0.9054 + }, + { + "t": 5.4, + "s": 0.8986 + }, + { + "t": 5.57, + "s": 0.8919 + }, + { + "t": 5.6, + "s": 0.8851 + }, + { + "t": 6.03, + "s": 0.8784 + }, + { + "t": 6.73, + "s": 0.8716 + }, + { + "…": "113 more", + "sha256": "d929e8ddbccaad19" + } + ], + "median": 15.3, + "n": 148, + "events": 142, + "atRisk": [ + 148, + 148, + 147, + 144, + 142, + 138, + 131, + 128, + 122, + 115, + 106, + 96, + 91, + 83, + 76, + 75, + 69, + 66, + 60, + 57, + { + "…": "167 more", + "sha256": "348a13dfb556251a" + } + ], + "missing": 0 + } + ], + "endpoint": "PFS_1L", + "participation": { + "studies": [ + { + "study": "ucec_msk_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "logrank": { + "chi2": 0.3942, + "p": 0.5301191634922409, + "df": 1, + "observed": [ + 23, + 141 + ], + "expected": [ + 25.9, + 138.1 + ], + "variance": 21.5713, + "strata": 1 + }, + "caveat": "PFS_1L from each study's own baseline (left truncation applies) Status '0:...' treated as censored. Log-rank on a single study, so no stratification applies.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:PFS_1L query above: patients grouped by identical PFS_MONTHS_FIRST_LINE_TX, event, returned as counts — no patient identifier leaves the database. Event: PROGRESSION_STATUS starting with “1”; any other value is censored. Every cohort patient had a value.", + "scope": "MSI-H · ucec_msk_2018", + "rowsIn": 28, + "rowsOut": 28, + "params": [ + [ + "count rows", + "28" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:PFS_1L query above: patients grouped by identical PFS_MONTHS_FIRST_LINE_TX, event, returned as counts — no patient identifier leaves the database. Event: PROGRESSION_STATUS starting with “1”; any other value is censored. Every cohort patient had a value.", + "scope": "MSS · ucec_msk_2018", + "rowsIn": 148, + "rowsOut": 148, + "params": [ + [ + "count rows", + "138" + ] + ] + }, + { + "kind": "statistic", + "title": "Estimate survival by Kaplan–Meier", + "detail": "The product-limit estimator, one curve per cohort, pooled over its studies. The median is the first time the curve is at or below 0.5.", + "params": [ + [ + "MSI-H", + "28 patients, 23 events, median 18.4 months" + ], + [ + "MSS", + "148 patients, 142 events, median 15.3 months" + ] + ] + }, + { + "kind": "statistic", + "title": "Two-group log-rank test", + "detail": "At each event time, every cohort's observed events against its share of the risk set, with the hypergeometric variance; χ² on 1 df.", + "params": [ + [ + "χ² / df / p", + "0.3942 / 1 / 0.530" + ] + ] + } + ], + "implementation": { + "functions": [ + "kaplanMeier", + "logRank" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Kaplan–Meier matches lifelines 0.30.3 KaplanMeierFitter (curves are reported to 4 decimals); the log-rank matches statsmodels 0.15.0 survdiff to a relative 1e-6, pooled, stratified, with delayed entry and for k groups (test/survival-golden.test.ts).", + "check": { + "km:MSI-H:n": { + "v": 28, + "abs": 0 + }, + "km:MSI-H:events": { + "v": 23, + "abs": 0 + }, + "km:MSI-H:median": { + "v": 18.37, + "abs": 1e-9 + }, + "km:MSS:n": { + "v": 148, + "abs": 0 + }, + "km:MSS:events": { + "v": 142, + "abs": 0 + }, + "km:MSS:median": { + "v": 15.3, + "abs": 1e-9 + }, + "logrank:chi2": { + "v": 0.3942, + "abs": 0.00005 + }, + "logrank:p": { + "v": 0.5301191634922409, + "rel": 0.00001, + "abs": 1e-300 + } + } + } + } + ] +} diff --git a/test/snapshots/survival.sql b/test/snapshots/survival.sql new file mode 100644 index 0000000..3a1529d --- /dev/null +++ b/test/snapshots/survival.sql @@ -0,0 +1,51 @@ +-- cohort MSI-H +-- ucec_msk_2018 +(SELECT DISTINCT replaceOne(patient_unique_id, 'ucec_msk_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'ucec_msk_2018' AND type = 'sample' + AND attribute_name = 'MSI_STATUS' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('MSI-H')))) + +-- cohort MSS +-- ucec_msk_2018 +(SELECT DISTINCT replaceOne(patient_unique_id, 'ucec_msk_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'ucec_msk_2018' AND type = 'sample' + AND attribute_name = 'MSI_STATUS' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('MSS')))) + +-- view 0 survival: survivalCounts:PFS_1L · ucec_msk_2018 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'ucec_msk_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'ucec_msk_2018' AND type = 'sample' + AND attribute_name = 'MSI_STATUS' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('MSI-H'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'ucec_msk_2018_', '') AS pid, + anyIf(attribute_value, attribute_name='PFS_MONTHS_FIRST_LINE_TX') AS months, + anyIf(attribute_value, attribute_name='PROGRESSION_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'ucec_msk_2018' AND type='patient' + AND attribute_name IN ('PFS_MONTHS_FIRST_LINE_TX','PROGRESSION_STATUS') + AND replaceOne(patient_unique_id, 'ucec_msk_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 0 survival: survivalCounts:PFS_1L · ucec_msk_2018 +WITH cohort AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'ucec_msk_2018_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'ucec_msk_2018' AND type = 'sample' + AND attribute_name = 'MSI_STATUS' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('MSS'))))), +os AS ( + SELECT replaceOne(patient_unique_id, 'ucec_msk_2018_', '') AS pid, + anyIf(attribute_value, attribute_name='PFS_MONTHS_FIRST_LINE_TX') AS months, + anyIf(attribute_value, attribute_name='PROGRESSION_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'ucec_msk_2018' AND type='patient' + AND attribute_name IN ('PFS_MONTHS_FIRST_LINE_TX','PROGRESSION_STATUS') + AND replaceOne(patient_unique_id, 'ucec_msk_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m diff --git a/test/snapshots/survival.svg b/test/snapshots/survival.svg new file mode 100644 index 0000000..619358f --- /dev/null +++ b/test/snapshots/survival.svg @@ -0,0 +1,2 @@ + +Kaplan–Meier — MSI-H, MSS0%25%50%75%100%Survival probability024487296120144168MonthsNumber at riskMSI-HMSI-H: 28 at risk at 0 months28MSI-H: 8 at risk at 24 months8MSI-H: 2 at risk at 48 months2MSI-H: 1 at risk at 72 months1MSI-H: 1 at risk at 96 months1MSI-H: 1 at risk at 120 months1MSI-H: 0 at risk at 144 months0MSI-H: 0 at risk at 168 months0MSSMSS: 148 at risk at 0 months148MSS: 43 at risk at 24 months43MSS: 12 at risk at 48 months12MSS: 6 at risk at 72 months6MSS: 2 at risk at 96 months2MSS: 1 at risk at 120 months1MSS: 1 at risk at 144 months1MSS: 1 at risk at 168 months1MSI-Hmedian 18.4 mo · n = 28 · 23 eventsMSSmedian 15.3 mo · n = 148 · 142 eventslog-rank χ² = 0.394 (1 df) · p = 0.53PFS_1L from each study's own baseline (left truncation applies) Status '0:...' treated as censored. Log-rank on a single study, so no stratification applies. diff --git a/test/snapshots/survival.txt b/test/snapshots/survival.txt new file mode 100644 index 0000000..c05c35c --- /dev/null +++ b/test/snapshots/survival.txt @@ -0,0 +1,22 @@ +Analysis over ucec_msk_2018 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- MSI-H: 28 patients — MSI_STATUS in [MSI-H] (any sample) +- MSS: 148 patients — MSI_STATUS in [MSS] (any sample) + +Survival (KM, PFS_1L): + MSI-H: median 18.4mo (n=28, 23 events) + MSS: median 15.3mo (n=148, 142 events) + log-rank p=0.5301 +CAVEAT (tell the user): PFS_1L from each study's own baseline (left truncation applies) Status '0:...' treated as censored. Log-rank on a single study, so no stratification applies. + METHOD: + - Count patients by time and status [MSI-H · ucec_msk_2018] (28 → 28 rows): The survivalCounts:PFS_1L query above: patients grouped by identical PFS_MONTHS_FIRST_LINE_TX, event, returned as counts — no patient identifier leaves the database. Event: PROGRESSION_STATUS starting with “1”; any other value is censored. Every cohort patient had a value. + count rows: 28 + - Count patients by time and status [MSS · ucec_msk_2018] (148 → 148 rows): The survivalCounts:PFS_1L query above: patients grouped by identical PFS_MONTHS_FIRST_LINE_TX, event, returned as counts — no patient identifier leaves the database. Event: PROGRESSION_STATUS starting with “1”; any other value is censored. Every cohort patient had a value. + count rows: 138 + - Estimate survival by Kaplan–Meier: The product-limit estimator, one curve per cohort, pooled over its studies. The median is the first time the curve is at or below 0.5. + MSI-H: 28 patients, 23 events, median 18.4 months + MSS: 148 patients, 142 events, median 15.3 months + - Two-group log-rank test: At each event time, every cohort's observed events against its share of the risk set, with the hypergeometric variance; χ² on 1 df. + χ² / df / p: 0.3942 / 1 / 0.530 + Kaplan–Meier matches lifelines 0.30.3 KaplanMeierFitter (curves are reported to 4 decimals); the log-rank matches statsmodels 0.15.0 survdiff to a relative 1e-6, pooled, stratified, with delayed entry and for k groups (test/survival-golden.test.ts). diff --git a/test/snapshots/table.json b/test/snapshots/table.json new file mode 100644 index 0000000..a5728b8 --- /dev/null +++ b/test/snapshots/table.json @@ -0,0 +1,888 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Pancreatic": { + "count": 3109, + "text": "CANCER_TYPE in [Pancreatic Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "table", + "cohorts": [ + "Pancreatic" + ], + "table": { + "unit": "sample", + "columns": [ + { + "id": "patient", + "name": "Patient ID", + "numeric": false + }, + { + "id": "sample", + "name": "Sample ID", + "numeric": false + }, + { + "id": "CANCER_TYPE", + "name": "Cancer Type", + "numeric": false + }, + { + "id": "CLINICAL_GROUP", + "name": "Clinical Group", + "numeric": false + }, + { + "id": "CLINICAL_SUMMARY", + "name": "Clinical Summary", + "numeric": false + }, + { + "id": "DIAGNOSIS_DESCRIPTION", + "name": "Diagnosis Description", + "numeric": false + }, + { + "id": "ICD_O_HISTOLOGY_DESCRIPTION", + "name": "ICD-O Histology Description", + "numeric": false + }, + { + "id": "PATHOLOGICAL_GROUP", + "name": "Pathological Group", + "numeric": false + }, + { + "id": "CANCER_TYPE_DETAILED", + "name": "Cancer Type Detailed", + "numeric": false + }, + { + "id": "OS_STATUS", + "name": "Overall Survival Status", + "numeric": false + }, + { + "id": "SAMPLE_TYPE", + "name": "Sample Type", + "numeric": false + }, + { + "id": "RACE", + "name": "Race", + "numeric": false + }, + { + "id": "GENDER", + "name": "Sex", + "numeric": false + }, + { + "id": "STAGE_HIGHEST_RECORDED", + "name": "Stage (Highest Recorded)", + "numeric": false + }, + { + "id": "ETHNICITY", + "name": "Ethnicity", + "numeric": false + }, + { + "id": "MSI_TYPE", + "name": "MSI Type", + "numeric": false + }, + { + "id": "GENE_PANEL", + "name": "Gene Panel", + "numeric": false + }, + { + "id": "CURRENT_AGE_DEID", + "name": "Current Age", + "numeric": true + }, + { + "id": "SMOKING_PREDICTIONS_3_CLASSES", + "name": "Smoking History (NLP)", + "numeric": false + }, + { + "id": "SOMATIC_STATUS", + "name": "Somatic Status", + "numeric": false + }, + { + "…": "32 more", + "sha256": "0faca185ba41eeac" + } + ], + "shown": [ + "patient", + "sample", + "CANCER_TYPE", + "CLINICAL_GROUP", + "CLINICAL_SUMMARY", + "DIAGNOSIS_DESCRIPTION", + "ICD_O_HISTOLOGY_DESCRIPTION", + "PATHOLOGICAL_GROUP", + "CANCER_TYPE_DETAILED", + "OS_STATUS", + "SAMPLE_TYPE", + "RACE", + "GENDER", + "STAGE_HIGHEST_RECORDED", + "ETHNICITY", + "MSI_TYPE", + "GENE_PANEL", + "CURRENT_AGE_DEID", + "SMOKING_PREDICTIONS_3_CLASSES", + "SOMATIC_STATUS", + { + "…": "32 more", + "sha256": "5b17d65b1df7f010" + } + ], + "defaults": [ + "patient", + "sample", + "CANCER_TYPE", + "CLINICAL_GROUP", + "CLINICAL_SUMMARY", + "DIAGNOSIS_DESCRIPTION", + "ICD_O_HISTOLOGY_DESCRIPTION", + "PATHOLOGICAL_GROUP", + "CANCER_TYPE_DETAILED", + "OS_STATUS", + "SAMPLE_TYPE", + "RACE", + "GENDER", + "STAGE_HIGHEST_RECORDED", + "ETHNICITY", + "MSI_TYPE", + "GENE_PANEL", + "CURRENT_AGE_DEID", + "SMOKING_PREDICTIONS_3_CLASSES", + "SOMATIC_STATUS", + { + "…": "32 more", + "sha256": "5b17d65b1df7f010" + } + ], + "query": { + "sort": { + "column": "CURRENT_AGE_DEID", + "desc": true + } + }, + "rows": [ + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0006018", + "sample": "P-0006018-T01-IM5", + "values": [ + "P-0006018", + "P-0006018-T01-IM5", + "Pancreatic Cancer", + "2A", + "Regional,Extension and Nodes", + "Pancreas", + "Blastoma, Nos", + "2B", + "Pancreatic Neuroendocrine Tumor", + "0:LIVING", + "Metastasis", + "White", + "Female", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT410", + "89", + "Unknown", + "Matched", + { + "…": "32 more", + "sha256": "afc13182844dc3f9" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0006930", + "sample": "P-0006930-T01-IM5", + "values": [ + "P-0006930", + "P-0006930-T01-IM5", + "Pancreatic Cancer", + "1A", + "Regional,Direct Extension", + "Pancreas", + "Adenocarcinoma, Nos", + "2A", + "Pancreatic Adenocarcinoma", + "0:LIVING", + "Primary", + "White", + "Female", + "Stage 1-3", + "Unknown whether Spanish or not", + "Stable", + "IMPACT410", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "8020c700bdb025bc" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0007791", + "sample": "P-0007791-T01-IM5", + "values": [ + "P-0007791", + "P-0007791-T01-IM5", + "Pancreatic Cancer", + "2A", + "Regional,Extension and Nodes", + "Pancreas", + "Tubular Adenocarcinoma", + "2B", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Male", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT410", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "e8e76e157522be59" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0009404", + "sample": "P-0009404-T01-IM5", + "values": [ + "P-0009404", + "P-0009404-T01-IM5", + "Pancreatic Cancer", + "1A", + "Regional,Direct Extension", + "Pancreas", + "Adenocarcinoma, Nos", + "2A", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT410", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "eb82e2189938f90b" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0010195", + "sample": "P-0010195-T01-IM5", + "values": [ + "P-0010195", + "P-0010195-T01-IM5", + "Pancreatic Cancer", + "3", + "Regional,Direct Extension", + "Pancreas", + "Adenocarcinoma, Nos", + "0", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 1-3", + "Spanish NOS; Hispanic NOS, Latino NOS", + "Stable", + "IMPACT410", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "7df155ddfc1b5f7e" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0011111", + "sample": "P-0011111-T01-IM5", + "values": [ + "P-0011111", + "P-0011111-T01-IM5", + "Pancreatic Cancer", + "1B", + "Regional Both 2 and 3", + "Pancreas", + "Infiltrating Duct Carcinoma", + "2B", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Male", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT410", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "efbfdff8d7af63df" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0012579", + "sample": "P-0012579-T01-IM5", + "values": [ + "P-0012579", + "P-0012579-T01-IM5", + "Pancreatic Cancer", + "1B", + "Regional by Direct Extension", + "Pancreas", + "Infiltrating Duct Carcinoma", + "2A", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT410", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "10f4e2e8ae1fcfda" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0013009", + "sample": "P-0013009-T01-IM5", + "values": [ + "P-0013009", + "P-0013009-T01-IM5", + "Pancreatic Cancer", + "4", + "Distant Metastases/Systemic Disease", + "Pancreas", + "Adenocarcinoma, Nos", + "", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 4", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT410", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "1fea999693130f2a" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0018639", + "sample": "P-0018639-T01-IM6", + "values": [ + "P-0018639", + "P-0018639-T01-IM6", + "Pancreatic Cancer", + "1A", + "Regional by Direct Extension", + "Pancreas", + "Infiltrating Duct Carcinoma", + "2A", + "Pancreatic Adenocarcinoma", + "0:LIVING", + "Primary", + "White", + "Female", + "Stage 1-3", + "Unknown whether Spanish or not", + "Do not report", + "IMPACT468", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "2c220bf4e83f8721" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0023044", + "sample": "P-0023044-T01-IM6", + "values": [ + "P-0023044", + "P-0023044-T01-IM6", + "Pancreatic Cancer", + "2A", + "Regional by Direct Extension", + "Pancreas", + "Adenocarcinoma, Nos", + "", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "2364ccef24263596" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0024552", + "sample": "P-0024552-T01-IM6", + "values": [ + "P-0024552", + "P-0024552-T01-IM6", + "Pancreatic Cancer", + "4", + "Distant Metastases/Systemic Disease", + "Pancreas", + "Adenocarcinoma, Nos", + "4", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Metastasis", + "White", + "Male", + "Stage 4", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "1edffbaf7be9de84" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0028084", + "sample": "P-0028084-T01-IM6", + "values": [ + "P-0028084", + "P-0028084-T01-IM6", + "Pancreatic Cancer", + "1B", + "Regional Both 2 and 3", + "Pancreas", + "Infiltrating Duct Carcinoma", + "2B", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "a37511482894836f" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0028158", + "sample": "P-0028158-T01-IM6", + "values": [ + "P-0028158", + "P-0028158-T01-IM6", + "Pancreatic Cancer", + "2A", + "Regional by Direct Extension", + "Pancreas", + "Carcinoma, Undifferentiated Type, Nos", + "", + "Undifferentiated Carcinoma of the Pancreas", + "1:DECEASED", + "Metastasis", + "White", + "Female", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "bf27641e9a00df42" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0028249", + "sample": "P-0028249-T01-IM6", + "values": [ + "P-0028249", + "P-0028249-T01-IM6", + "Pancreatic Cancer", + "1A", + "Regional Both 2 and 3", + "Pancreas", + "Infiltrating Duct Carcinoma", + "3", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Male", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "268d734a7e163257" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0029109", + "sample": "P-0029109-T01-IM6", + "values": [ + "P-0029109", + "P-0029109-T01-IM6", + "Pancreatic Cancer", + "", + "Localized", + "Pancreas", + "Adenocarcinoma, Nos", + "1A", + "Pancreatic Adenocarcinoma", + "0:LIVING", + "Primary", + "White", + "Female", + "Stage 1-3", + "Spanish NOS; Hispanic NOS, Latino NOS", + "Stable", + "IMPACT468", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "a2854bf8c1d89271" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0030506", + "sample": "P-0030506-T01-IM6", + "values": [ + "P-0030506", + "P-0030506-T01-IM6", + "Pancreatic Cancer", + "1B", + "Regional,Extension and Nodes", + "Pancreas", + "Infiltrating Duct Carcinoma", + "2B", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Male", + "Stage 1-3", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "b9188b83e59a6f8e" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0031431", + "sample": "P-0031431-T01-IM6", + "values": [ + "P-0031431", + "P-0031431-T01-IM6", + "Pancreatic Cancer", + "4", + "Distant Metastases/Systemic Disease", + "Pancreas", + "Adenocarcinoma, Nos", + "4", + "Pancreatic Adenocarcinoma", + "0:LIVING", + "Primary", + "White", + "Male", + "Stage 4", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "323df33aeef91a2c" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0032403", + "sample": "P-0032403-T01-IM6", + "values": [ + "P-0032403", + "P-0032403-T01-IM6", + "Pancreatic Cancer", + "4", + "Distant Metastases/Systemic Disease", + "Pancreas", + "Adenocarcinoma, Nos", + "4", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Female", + "Stage 4", + "Non-Spanish; Non-Hispanic", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "3c6e36eaac9ab4c3" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0037989", + "sample": "P-0037989-T01-IM6", + "values": [ + "P-0037989", + "P-0037989-T01-IM6", + "Pancreatic Cancer", + "1B", + "Regional To Lymph Nodes", + "Pancreas", + "Infiltrating Duct Carcinoma", + "2B", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Male", + "Stage 1-3", + "Unknown whether Spanish or not", + "Stable", + "IMPACT468", + "89", + "Never", + "Matched", + { + "…": "32 more", + "sha256": "c0d401658333a605" + } + ] + }, + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "patient": "P-0038511", + "sample": "P-0038511-T01-IM6", + "values": [ + "P-0038511", + "P-0038511-T01-IM6", + "Pancreatic Cancer", + "1B", + "Localized", + "Pancreas", + "Adenocarcinoma, Nos", + "", + "Pancreatic Adenocarcinoma", + "1:DECEASED", + "Primary", + "White", + "Male", + "Stage 1-3", + "Unknown whether Spanish or not", + "Stable", + "IMPACT468", + "89", + "Former/Current Smoker", + "Matched", + { + "…": "32 more", + "sha256": "15bf9c98fecb5f7c" + } + ] + }, + { + "…": "5 more", + "sha256": "627de08f5ae47ff2" + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Pancreatic", + "study": "msk_chord_2024", + "total": 3134, + "all": 3134 + } + ], + "total": 3134, + "all": 3134 + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "One row per sample of each cohort's patients, carrying its patient's attributes too, with 50 attributes as each study recorded them — vocabularies are not harmonized across studies. 3,134 samples. Sorted by Current Age (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count the samples per cohort and study", + "detail": "The table:counts query above: every sample of each cohort's patients (from the study's sample list, so a sample with no sample attribute still has a row), each with the value of each of the 50 attributes as recorded — blank where none was.", + "params": [ + [ + "Pancreatic · msk_chord_2024", + "3,134" + ] + ] + }, + { + "kind": "fetch", + "title": "Sort them together and take one page", + "detail": "The table:rows query above: the samples of every cohort and study combined in one query, sorted by Current Age descending with missing values last, then patient and sample id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset." + } + ], + "implementation": { + "functions": [ + "clinicalRowSource", + "pageSql", + "countsSql" + ], + "file": "lib/clinical-table.ts, lib/table-query.ts", + "commit": null + }, + "verification": "A listing: no statistic is computed, so there is no script — the queries are the numbers." + } + } + ] +} diff --git a/test/snapshots/table.sql b/test/snapshots/table.sql new file mode 100644 index 0000000..e94d6e0 --- /dev/null +++ b/test/snapshots/table.sql @@ -0,0 +1,80 @@ +-- cohort Pancreatic +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer')))) + +-- view 0 table: table:attributes · msk_chord_2024 +SELECT m.attr_id AS id, m.display_name AS name, m.datatype AS datatype, m.patient_attribute AS patient, toInt32OrZero(m.priority) AS priority +FROM snapshot_db.clinical_attribute_meta m +JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = m.cancer_study_id +WHERE cs.cancer_study_identifier = 'msk_chord_2024' +ORDER BY priority DESC, name + +-- view 0 table: table:counts · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer'))))), +u0 AS ( + SELECT patient_unique_id AS puid, sample_unique_id AS suid, 1 AS samples FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) +), +pv0 AS ( + SELECT patient_unique_id AS k, + CAST((groupArray(attribute_name), groupArray(attribute_value)), 'Map(String, String)') AS m + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' AND attribute_name IN ('CURRENT_AGE_DEID') + AND attribute_value != '' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY k +), +sv0 AS ( + SELECT sample_unique_id AS k, + CAST((groupArray(attribute_name), groupArray(attribute_value)), 'Map(String, String)') AS m + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' AND 0 + AND attribute_value != '' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY k +), +rows AS ( + SELECT 'Pancreatic' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, + replaceOne(u.puid, 'msk_chord_2024_', '') AS patient, replaceOne(u.suid, 'msk_chord_2024_', '') AS sample, u.samples AS samples, mapUpdate(pv.m, sv.m) AS m + FROM u0 AS u LEFT JOIN pv0 AS pv ON pv.k = u.puid LEFT JOIN sv0 AS sv ON sv.k = u.suid +) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 table: table:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Pancreatic Cancer'))))), +u0 AS ( + SELECT patient_unique_id AS puid, sample_unique_id AS suid, 1 AS samples FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) +), +pv0 AS ( + SELECT patient_unique_id AS k, + CAST((groupArray(attribute_name), groupArray(attribute_value)), 'Map(String, String)') AS m + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'patient' AND attribute_name IN ('OS_STATUS','RACE','GENDER','STAGE_HIGHEST_RECORDED','ETHNICITY','CURRENT_AGE_DEID','SMOKING_PREDICTIONS_3_CLASSES','PRIOR_MED_TO_MSK','GLEASON_HIGHEST_REPORTED','HISTORY_OF_PDL1','NUM_ICDO_DX','SAMPLE_COUNT','GLEASON_FIRST_REPORTED','HER2','HR','OS_MONTHS','ADRENAL_GLANDS','BONE','CNS_BRAIN','INTRA_ABDOMINAL','LIVER','LUNG','LYMPH_NODES','OTHER','PLEURA','REPRODUCTIVE_ORGANS') + AND attribute_value != '' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY k +), +sv0 AS ( + SELECT sample_unique_id AS k, + CAST((groupArray(attribute_name), groupArray(attribute_value)), 'Map(String, String)') AS m + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' AND attribute_name IN ('CANCER_TYPE','CLINICAL_GROUP','CLINICAL_SUMMARY','DIAGNOSIS_DESCRIPTION','ICD_O_HISTOLOGY_DESCRIPTION','PATHOLOGICAL_GROUP','CANCER_TYPE_DETAILED','SAMPLE_TYPE','MSI_TYPE','GENE_PANEL','SOMATIC_STATUS','SAMPLE_CLASS','MUTATION_COUNT','FRACTION_GENOME_ALTERED','TMB_NONSYNONYMOUS','GLEASON_SAMPLE_LEVEL','MSI_COMMENT','MSI_SCORE','METASTATIC_SITE','ONCOTREE_CODE','PRIMARY_SITE','PDL1_POSITIVE','SAMPLE_COVERAGE','TUMOR_PURITY') + AND attribute_value != '' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY k +), +rows AS ( + SELECT 'Pancreatic' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, + replaceOne(u.puid, 'msk_chord_2024_', '') AS patient, replaceOne(u.suid, 'msk_chord_2024_', '') AS sample, u.samples AS samples, mapUpdate(pv.m, sv.m) AS m + FROM u0 AS u LEFT JOIN pv0 AS pv ON pv.k = u.puid LEFT JOIN sv0 AS sv ON sv.k = u.suid +) +SELECT cohort, study, patient, sample, samples, m, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY if(isFinite(ifNull(toFloat64OrNull(m['CURRENT_AGE_DEID']), nan)), toFloat64OrNull(m['CURRENT_AGE_DEID']), NULL) DESC NULLS LAST, patient, sample, ord +LIMIT 25 OFFSET 0 diff --git a/test/snapshots/table.svg b/test/snapshots/table.svg new file mode 100644 index 0000000..7e001dc --- /dev/null +++ b/test/snapshots/table.svg @@ -0,0 +1,2 @@ + +(no figure) diff --git a/test/snapshots/table.txt b/test/snapshots/table.txt new file mode 100644 index 0000000..1bb6ae1 --- /dev/null +++ b/test/snapshots/table.txt @@ -0,0 +1,39 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Pancreatic: 3,109 patients — CANCER_TYPE in [Pancreatic Cancer] (any sample) + +Clinical data table (one row per sample): 3,134 rows; the first 25, tab-separated (the web app's view pages and downloads every row, with every column): + cohort patient sample CANCER_TYPE CLINICAL_GROUP CLINICAL_SUMMARY DIAGNOSIS_DESCRIPTION ICD_O_HISTOLOGY_DESCRIPTION PATHOLOGICAL_GROUP CANCER_TYPE_DETAILED OS_STATUS SAMPLE_TYPE RACE GENDER STAGE_HIGHEST_RECORDED ETHNICITY MSI_TYPE GENE_PANEL CURRENT_AGE_DEID SMOKING_PREDICTIONS_3_CLASSES SOMATIC_STATUS SAMPLE_CLASS PRIOR_MED_TO_MSK GLEASON_HIGHEST_REPORTED HISTORY_OF_PDL1 NUM_ICDO_DX MUTATION_COUNT FRACTION_GENOME_ALTERED SAMPLE_COUNT TMB_NONSYNONYMOUS GLEASON_SAMPLE_LEVEL GLEASON_FIRST_REPORTED HER2 HR MSI_COMMENT MSI_SCORE METASTATIC_SITE ONCOTREE_CODE OS_MONTHS PRIMARY_SITE PDL1_POSITIVE SAMPLE_COVERAGE TUMOR_PURITY ADRENAL_GLANDS BONE CNS_BRAIN INTRA_ABDOMINAL LIVER LUNG LYMPH_NODES OTHER PLEURA REPRODUCTIVE_ORGANS + Pancreatic P-0006018 P-0006018-T01-IM5 Pancreatic Cancer 2A Regional,Extension and Nodes Pancreas Blastoma, Nos 2B Pancreatic Neuroendocrine Tumor 0:LIVING Metastasis White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT410 89 Unknown Matched Tumor Unknown 2 2 0.7416 1 1.957439395 0.6 Liver PANET 0.032876676 Pancreas 564 90 Yes No No Yes Yes No Yes Yes No No + Pancreatic P-0006930 P-0006930-T01-IM5 Pancreatic Cancer 1A Regional,Direct Extension Pancreas Adenocarcinoma, Nos 2A Pancreatic Adenocarcinoma 0:LIVING Primary White Female Stage 1-3 Unknown whether Spanish or not Stable IMPACT410 89 Never Matched Tumor Unknown 1 5 0.1124 1 6.851037883 0 PAAD 11.99998685 Pancreas 1030 10 No No No No No Yes No Yes No No + Pancreatic P-0007791 P-0007791-T01-IM5 Pancreatic Cancer 2A Regional,Extension and Nodes Pancreas Tubular Adenocarcinoma 2B Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT410 89 Former/Current Smoker Matched Tumor No prior medications 1 1 0.0169 1 0.978719698 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 80.90950037 Pancreas 717 30 No No No No Yes No Yes Yes No No + Pancreatic P-0009404 P-0009404-T01-IM5 Pancreatic Cancer 1A Regional,Direct Extension Pancreas Adenocarcinoma, Nos 2A Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT410 89 Never Matched Tumor Unknown 1 5 0.0692 1 4.893598488 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 8.021909017 Pancreas 566 10 No Yes No Yes Yes No Yes Yes No Yes + Pancreatic P-0010195 P-0010195-T01-IM5 Pancreatic Cancer 3 Regional,Direct Extension Pancreas Adenocarcinoma, Nos 0 Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 1-3 Spanish NOS; Hispanic NOS, Latino NOS Stable IMPACT410 89 Former/Current Smoker Matched Tumor No prior medications 1 3 0.131 1 2.936159093 MICROSATELLITE STABLE (MSS). See MSI note below. 0.44 PAAD 3.978077832 Pancreas 236 30 No No No No No No No Yes No No + Pancreatic P-0011111 P-0011111-T01-IM5 Pancreatic Cancer 1B Regional Both 2 and 3 Pancreas Infiltrating Duct Carcinoma 2B Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT410 89 Never Matched Tumor No prior medications 2 4 0.0 1 3.91487879 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 26.33421772 Pancreas 379 20 No No No No No Yes Yes Yes No No + Pancreatic P-0012579 P-0012579-T01-IM5 Pancreatic Cancer 1B Regional by Direct Extension Pancreas Infiltrating Duct Carcinoma 2A Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT410 89 Former/Current Smoker Matched Tumor No prior medications 1 2 0.0618 1 1.957439395 0.07 PAAD 28.30681829 Pancreas 785 20 No No No No No No No Yes No No + Pancreatic P-0013009 P-0013009-T01-IM5 Pancreatic Cancer 4 Distant Metastases/Systemic Disease Pancreas Adenocarcinoma, Nos Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 4 Non-Spanish; Non-Hispanic Stable IMPACT410 89 Never Matched Tumor No prior medications 2 5 0.1705 1 4.893598488 0.14 PAAD 8.580812514 Pancreas 909 10 No No No Yes Yes Yes Yes Yes No No + Pancreatic P-0018639 P-0018639-T01-IM6 Pancreatic Cancer 1A Regional by Direct Extension Pancreas Infiltrating Duct Carcinoma 2A Pancreatic Adenocarcinoma 0:LIVING Primary White Female Stage 1-3 Unknown whether Spanish or not Do not report IMPACT468 89 Former/Current Smoker Matched Tumor No prior medications 3 5 0.0 1 4.323490475 0 PAAD 76.50402575 Pancreas 873 20 No No No No Yes Yes No Yes No No + Pancreatic P-0023044 P-0023044-T01-IM6 Pancreatic Cancer 2A Regional by Direct Extension Pancreas Adenocarcinoma, Nos Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor Prior medications to MSK 1 8 0.004 1 6.91758476 MICROSATELLITE STABLE (MSS). See MSI note below. 0.88 PAAD 6.246568497 Pancreas 174 30 No Yes No No Yes Yes Yes No No No + Pancreatic P-0024552 P-0024552-T01-IM6 Pancreatic Cancer 4 Distant Metastases/Systemic Disease Pancreas Adenocarcinoma, Nos 4 Pancreatic Adenocarcinoma 1:DECEASED Metastasis White Male Stage 4 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Former/Current Smoker Matched Tumor No prior medications 6 3 3 0.2175 1 2.594094285 6 MICROSATELLITE STABLE (MSS). See MSI note below. 0.29 Liver PAAD 6.082185115 Pancreas 829 40 Yes No No Yes Yes No No Yes No No + Pancreatic P-0028084 P-0028084-T01-IM6 Pancreatic Cancer 1B Regional Both 2 and 3 Pancreas Infiltrating Duct Carcinoma 2B Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor No prior medications 2 3 0.0121 1 2.594094285 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 52.27391532 Pancreas 696 10 No No No No No No No Yes No No + Pancreatic P-0028158 P-0028158-T01-IM6 Pancreatic Cancer 2A Regional by Direct Extension Pancreas Carcinoma, Undifferentiated Type, Nos Undifferentiated Carcinoma of the Pancreas 1:DECEASED Metastasis White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor No prior medications Yes 2 9 0.2976 1 7.782282855 MICROSATELLITE STABLE (MSS). See MSI note below. 0.61 UCP 16.53696818 Pancreas Yes 656 50 No No No No No Yes No Yes No No + Pancreatic P-0028249 P-0028249-T01-IM6 Pancreatic Cancer 1A Regional Both 2 and 3 Pancreas Infiltrating Duct Carcinoma 3 Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor No prior medications 1 6 0.0 1 5.18818857 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 31.69311595 Pancreas 758 10 No No No No No No Yes Yes No No + Pancreatic P-0029109 P-0029109-T01-IM6 Pancreatic Cancer Localized Pancreas Adenocarcinoma, Nos 1A Pancreatic Adenocarcinoma 0:LIVING Primary White Female Stage 1-3 Spanish NOS; Hispanic NOS, Latino NOS Stable IMPACT468 89 Former/Current Smoker Matched Tumor No prior medications 1 5 0.0 1 6.052886665 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 59.60541413 Pancreas 533 20 No No No No No No Yes Yes No No + Pancreatic P-0030506 P-0030506-T01-IM6 Pancreatic Cancer 1B Regional,Extension and Nodes Pancreas Infiltrating Duct Carcinoma 2B Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor Unknown 7 3 3 0.0549 1 2.594094285 7 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 6.016431763 Pancreas 525 40 No No No Yes Yes No No Yes No Yes + Pancreatic P-0031431 P-0031431-T01-IM6 Pancreatic Cancer 4 Distant Metastases/Systemic Disease Pancreas Adenocarcinoma, Nos 4 Pancreatic Adenocarcinoma 0:LIVING Primary White Male Stage 4 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Former/Current Smoker Matched Tumor No prior medications 1 10 0.2258 1 8.64698095 MICROSATELLITE STABLE (MSS). See MSI note below. 0.19 PAAD 47.93419404 Pancreas 530 30 No No No No No No No No No No + Pancreatic P-0032403 P-0032403-T01-IM6 Pancreatic Cancer 4 Distant Metastases/Systemic Disease Pancreas Adenocarcinoma, Nos 4 Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 4 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor No prior medications 1 6 0.235 1 5.18818857 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 43.59447277 Pancreas 645 30 No No No No Yes No No Yes No No + Pancreatic P-0037989 P-0037989-T01-IM6 Pancreatic Cancer 1B Regional To Lymph Nodes Pancreas Infiltrating Duct Carcinoma 2B Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Unknown whether Spanish or not Stable IMPACT468 89 Never Matched Tumor No prior medications 2 7 0.0349 1 6.052886665 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 19.0027189 Pancreas 652 40 No No No Yes No Yes No Yes No No + Pancreatic P-0038511 P-0038511-T01-IM6 Pancreatic Cancer 1B Localized Pancreas Adenocarcinoma, Nos Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Unknown whether Spanish or not Stable IMPACT468 89 Former/Current Smoker Matched Tumor No prior medications 7 2 6 0.3097 1 5.18818857 7 MICROSATELLITE STABLE (MSS). See MSI note below. 0.26 PAAD 12.95341046 Pancreas 587 40 No No No No Yes No No Yes No No + Pancreatic P-0039568 P-0039568-T01-IM6 Pancreatic Cancer 2A Regional Both 2 and 3 Pancreas Adenocarcinoma, Nos 3 Pancreatic Adenocarcinoma 0:LIVING Metastasis White Female Stage 1-3 Unknown whether Spanish or not Stable IMPACT468 89 Never Matched Tumor No prior medications 3 5 0.2215 1 4.323490475 MICROSATELLITE STABLE (MSS). See MSI note below. 0.06 Duodenum PAAD 35.60544043 Pancreas 592 30 No No No Yes No No Yes Yes No No + Pancreatic P-0040808 P-0040808-T01-IM6 Pancreatic Cancer 2A Localized Pancreas Adenocarcinoma, Nos Pancreatic Adenocarcinoma 1:DECEASED Primary White Male Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Former/Current Smoker Matched Tumor No prior medications 2 8 0.016 1 6.91758476 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 8.284922427 Pancreas 763 20 Yes No No No Yes No Yes Yes No No + Pancreatic P-0044512 P-0044512-T01-IM6 Pancreatic Cancer 1B Regional Both 2 and 3 Pancreas Infiltrating Duct Carcinoma 2B Pancreatic Adenocarcinoma 1:DECEASED Primary White Female Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Never Matched Tumor No prior medications 1 3 0.044 1 2.594094285 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 45.00816985 Pancreas 632 10 No No No Yes Yes Yes No Yes No No + Pancreatic P-0046434 P-0046434-T01-IM6 Pancreatic Cancer 3 Regional,Direct Extension Pancreas Adenocarcinoma, Nos Pancreatic Adenocarcinoma 1:DECEASED Metastasis White Male Stage 1-3 Unknown whether Spanish or not Stable IMPACT468 89 Never Matched Tumor Unknown 1 5 0.0461 1 4.323490475 MICROSATELLITE STABLE (MSS). See MSI note below. 0.06 Liver PAAD 7.956155664 Pancreas 474 10 No No No No Yes Yes No Yes No No + Pancreatic P-0048987 P-0048987-T01-IM6 Pancreatic Cancer Localized Pancreas Infiltrating Duct Carcinoma 1A Pancreatic Adenocarcinoma 0:LIVING Primary White Male Stage 1-3 Non-Spanish; Non-Hispanic Stable IMPACT468 89 Former/Current Smoker Matched Tumor Unknown 6 2 4 0.002 1 3.45879238 6 MICROSATELLITE STABLE (MSS). See MSI note below. 0 PAAD 46.8821404 Pancreas 626 20 No No No No Yes No No Yes No No + … 3,109 more rows + CAVEAT (tell the user): One row per sample of each cohort's patients, carrying its patient's attributes too, with 50 attributes as each study recorded them — vocabularies are not harmonized across studies. 3,134 samples. Sorted by Current Age (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. + METHOD: + - Count the samples per cohort and study: The table:counts query above: every sample of each cohort's patients (from the study's sample list, so a sample with no sample attribute still has a row), each with the value of each of the 50 attributes as recorded — blank where none was. + Pancreatic · msk_chord_2024: 3,134 + - Sort them together and take one page: The table:rows query above: the samples of every cohort and study combined in one query, sorted by Current Age descending with missing values last, then patient and sample id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset. + A listing: no statistic is computed, so there is no script — the queries are the numbers. diff --git a/test/snapshots/timeline.json b/test/snapshots/timeline.json new file mode 100644 index 0000000..8d62a60 --- /dev/null +++ b/test/snapshots/timeline.json @@ -0,0 +1,2243 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "Breast": { + "count": 5368, + "text": "CANCER_TYPE in [Breast Cancer] (any sample)", + "studies": [ + "msk_chord_2024" + ] + } + }, + "views": [ + { + "kind": "timeline", + "cohorts": [ + "Breast" + ], + "svg": "Timeline of P-0000012-26y9 years with no events, cut-15y-14y-13y-12y-11y-10y-9y-8y-7y-6y-5y-4y-3y-2y-1y01y2y3y4y5y6y7y8y9ySample acquisitionSample acquisition12SequencingSequencing21SurgerySurgeryTreatment▾ TreatmentChemo▸ ChemoRadiation TherapyRadiation TherapyInvestigational▾ InvestigationalINVESTIGATIONALINVESTIGATIONAL2Immuno▾ ImmunoNIVOLUMABNIVOLUMABDiagnosis▾ DiagnosisPrimaryPrimaryHasCancerHasCancerProgressionProgressionTumor SitesTumor SitesPerformance StatusPerformance StatusLab_Test▾ Lab_TestCEACEA4.61.2CA_15-3CA_15-3218P-0000012 (msk_chord_2024): 172 events in 6 event types, from -26 years, 5 months, 1 day to 9 years, 3 months, 2 days relative to diagnosis (day 0). Samples,numbered in collection order: 1 P-0000012-T02-IM3 (Primary), 2 P-0000012-T03-IM3 (Metastasis). 9 years with no events are cut from the axis (dashed line);expandGaps draws every year. Events of one type nest by attribute as on cBioPortal (treatment by subtype and agent, lab tests by test); vocabularies are the study's own.", + "timeline": { + "columns": [ + { + "id": "patient", + "name": "Patient ID", + "numeric": false + }, + { + "id": "source", + "name": "Source", + "numeric": false + }, + { + "id": "samples", + "name": "Samples", + "numeric": true + }, + { + "id": "events", + "name": "Events", + "numeric": true + }, + { + "id": "first", + "name": "First event (day)", + "numeric": true + }, + { + "id": "last", + "name": "Last event (day)", + "numeric": true + }, + { + "id": "span", + "name": "Span (days)", + "numeric": true + }, + { + "id": "types", + "name": "Event types", + "numeric": false + } + ], + "shown": [ + "patient", + "source", + "samples", + "events", + "span", + "types" + ], + "defaults": [ + "patient", + "source", + "samples", + "events", + "span", + "types" + ], + "query": { + "sort": { + "column": "events", + "desc": true + } + }, + "rows": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0014149", + "sample": "", + "values": [ + "P-0014149", + "this portal (primary)", + 1, + 925, + -3547, + 2590, + 6137, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0007146", + "sample": "", + "values": [ + "P-0007146", + "this portal (primary)", + 1, + 800, + -2420, + 2791, + 5211, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0015681", + "sample": "", + "values": [ + "P-0015681", + "this portal (primary)", + 1, + 717, + -6020, + 475, + 6495, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0041672", + "sample": "", + "values": [ + "P-0041672", + "this portal (primary)", + 1, + 708, + -3542, + 1133, + 4675, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0047755", + "sample": "", + "values": [ + "P-0047755", + "this portal (primary)", + 1, + 694, + -5120, + 182, + 5302, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0016734", + "sample": "", + "values": [ + "P-0016734", + "this portal (primary)", + 1, + 677, + -6200, + 565, + 6765, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0057382", + "sample": "", + "values": [ + "P-0057382", + "this portal (primary)", + 1, + 663, + -6967, + 926, + 7893, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0003958", + "sample": "", + "values": [ + "P-0003958", + "this portal (primary)", + 1, + 655, + -3390, + 3493, + 6883, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0010993", + "sample": "", + "values": [ + "P-0010993", + "this portal (primary)", + 1, + 652, + -4350, + 2142, + 6492, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0011420", + "sample": "", + "values": [ + "P-0011420", + "this portal (primary)", + 1, + 646, + -5572, + 2183, + 7755, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0015568", + "sample": "", + "values": [ + "P-0015568", + "this portal (primary)", + 1, + 642, + -8203, + 1526, + 9729, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0018146", + "sample": "", + "values": [ + "P-0018146", + "this portal (primary)", + 1, + 638, + -7821, + 1762, + 9583, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0008398", + "sample": "", + "values": [ + "P-0008398", + "this portal (primary)", + 1, + 635, + -847, + 2605, + 3452, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0029771", + "sample": "", + "values": [ + "P-0029771", + "this portal (primary)", + 1, + 632, + -2639, + 1995, + 4634, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0001990", + "sample": "", + "values": [ + "P-0001990", + "this portal (primary)", + 1, + 621, + -3820, + 1008, + 4828, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0007045", + "sample": "", + "values": [ + "P-0007045", + "this portal (primary)", + 1, + 612, + -3459, + 464, + 3923, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0013915", + "sample": "", + "values": [ + "P-0013915", + "this portal (primary)", + 1, + 609, + -4836, + 2168, + 7004, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0001939", + "sample": "", + "values": [ + "P-0001939", + "this portal (primary)", + 1, + 574, + -3575, + 2723, + 6298, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0025567", + "sample": "", + "values": [ + "P-0025567", + "this portal (primary)", + 1, + 573, + -3303, + 2061, + 5364, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0002531", + "sample": "", + "values": [ + "P-0002531", + "this portal (primary)", + 1, + 571, + -4323, + 2181, + 6504, + "Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment" + ] + }, + { + "…": "5 more", + "sha256": "43eea4588ff30354" + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "total": 5368, + "all": 5368 + } + ], + "total": 5368, + "all": 5368, + "patient": { + "study": "msk_chord_2024", + "patient": "P-0000012", + "events": [ + { + "type": "Diagnosis", + "start": -9641, + "end": null, + "attrs": [ + [ + "SUBTYPE", + "Primary" + ], + [ + "CLINICAL_GROUP", + "99" + ], + [ + "SUMMARY", + "N/A" + ], + [ + "PATH_GROUP", + "99" + ], + [ + "SOURCE", + "Tumor Registry" + ], + [ + "DX_DESCRIPTION", + "INFILTRATING DUCT CARCINOMA | BREAST, NOS (M8500/3 | C509)" + ], + [ + "STAGE_CDM_DERIVED", + "Stage 1-3" + ] + ] + }, + { + "type": "Sample acquisition", + "start": -5453, + "end": null, + "attrs": [ + [ + "SEQ_DATE", + "48" + ], + [ + "SAMPLE_ID", + "P-0000012-T02-IM3" + ] + ] + }, + { + "type": "Treatment", + "start": -5437, + "end": -5369, + "attrs": [ + [ + "SUBTYPE", + "Chemo" + ], + [ + "AGENT", + "CYCLOPHOSPHAMIDE" + ], + [ + "RX_INVESTIGATIVE", + "N" + ], + [ + "FLAG_OROTOPICAL", + "0" + ] + ] + }, + { + "type": "Treatment", + "start": -5437, + "end": -5326, + "attrs": [ + [ + "SUBTYPE", + "Chemo" + ], + [ + "AGENT", + "FLUOROURACIL" + ], + [ + "RX_INVESTIGATIVE", + "N" + ], + [ + "FLAG_OROTOPICAL", + "0" + ] + ] + }, + { + "type": "Treatment", + "start": -5437, + "end": -5327, + "attrs": [ + [ + "SUBTYPE", + "Chemo" + ], + [ + "AGENT", + "METHOTREXATE" + ], + [ + "RX_INVESTIGATIVE", + "N" + ], + [ + "FLAG_OROTOPICAL", + "0" + ] + ] + }, + { + "type": "Lab_Test", + "start": -5437, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.8" + ] + ] + }, + { + "type": "Lab_Test", + "start": -5307, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "21" + ] + ] + }, + { + "type": "Lab_Test", + "start": -5307, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.9" + ] + ] + }, + { + "type": "Lab_Test", + "start": -5178, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "16" + ] + ] + }, + { + "type": "Lab_Test", + "start": -5178, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.4" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4999, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "17" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4999, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.5" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4849, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "14" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4849, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.4" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4684, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "14" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4684, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.7" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4530, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "17" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4530, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.2" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4362, + "end": null, + "attrs": [ + [ + "TEST", + "CA_15-3" + ], + [ + "LR_UNIT_MEASURE", + "Units/ml" + ], + [ + "RESULT", + "13" + ] + ] + }, + { + "type": "Lab_Test", + "start": -4362, + "end": null, + "attrs": [ + [ + "TEST", + "CEA" + ], + [ + "LR_UNIT_MEASURE", + "ng/ml" + ], + [ + "RESULT", + "1.3" + ] + ] + }, + { + "…": "152 more", + "sha256": "5d06e726a3a25f5f" + } + ], + "samples": [ + { + "id": "P-0000012-T02-IM3", + "type": "Primary" + }, + { + "id": "P-0000012-T03-IM3", + "type": "Metastasis" + } + ], + "source": { + "label": "primary" + } + }, + "position": { + "index": 1251, + "prev": { + "study": "msk_chord_2024", + "id": "P-0082770" + }, + "next": { + "study": "msk_chord_2024", + "id": "P-0000478" + } + } + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "The list is one row per patient of each cohort; event counts and days come from the study's timeline, in days from diagnosis as the study records them. 5,368 patients. Sorted by Events (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count the patients per cohort and study", + "detail": "The timeline:counts query above: every patient of each cohort, with their sample count and, from the study's timeline, the number of events, the first and last event day (a range counted to its stop) and the event types — a patient with no timeline is listed with none.", + "params": [ + [ + "Breast · msk_chord_2024", + "5,368" + ] + ] + }, + { + "kind": "fetch", + "title": "Sort them together and take one page", + "detail": "The timeline:rows query above: the patients of every cohort and study combined in one query, sorted by Events descending with missing values last, then patient id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset." + }, + { + "kind": "fetch", + "title": "Read P-0000012's timeline", + "detail": "The timeline:events and timeline:samples queries above: every clinical event recorded for P-0000012 in msk_chord_2024 with all its attributes, and the patient's samples with their SAMPLE_TYPE. Events are drawn as stored, in days from diagnosis; tracks group them by event type (case-folded) and nest them by attribute as cBioPortal's patient view does.", + "params": [ + [ + "events", + "172" + ], + [ + "samples", + "2" + ] + ] + } + ], + "implementation": { + "functions": [ + "runTimeline", + "timelinePatientRowSource", + "patientEventsSql", + "buildTracks", + "pageSql", + "countsSql", + "rankSql" + ], + "file": "lib/views/timeline.ts, lib/patient-timeline.ts, lib/timeline-tracks.ts, lib/table-query.ts", + "commit": null + }, + "verification": "A listing and one patient's record: no statistic is computed, so there is no script — the queries are the numbers." + } + }, + { + "kind": "alterations", + "cohorts": [ + "Breast" + ], + "alterations": { + "columns": [ + { + "id": "patient", + "name": "Patient ID", + "numeric": false + }, + { + "id": "source", + "name": "Source", + "numeric": false + }, + { + "id": "samples", + "name": "Samples", + "numeric": true + }, + { + "id": "mutations", + "name": "Mutations", + "numeric": true + }, + { + "id": "cna", + "name": "CNAs", + "numeric": true + }, + { + "id": "sv", + "name": "Structural Variants", + "numeric": true + } + ], + "shown": [ + "patient", + "source", + "samples", + "mutations", + "cna", + "sv" + ], + "defaults": [ + "patient", + "source", + "samples", + "mutations", + "cna", + "sv" + ], + "query": {}, + "rows": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "", + "values": [ + "P-0000012", + "this portal (primary)", + 2, + 31, + 3, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000015", + "sample": "", + "values": [ + "P-0000015", + "this portal (primary)", + 1, + 7, + 11, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000041", + "sample": "", + "values": [ + "P-0000041", + "this portal (primary)", + 1, + 10, + 0, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000057", + "sample": "", + "values": [ + "P-0000057", + "this portal (primary)", + 1, + 5, + 0, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000058", + "sample": "", + "values": [ + "P-0000058", + "this portal (primary)", + 1, + 1, + 7, + 1 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000066", + "sample": "", + "values": [ + "P-0000066", + "this portal (primary)", + 1, + 4, + 5, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000077", + "sample": "", + "values": [ + "P-0000077", + "this portal (primary)", + 1, + 2, + 8, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000081", + "sample": "", + "values": [ + "P-0000081", + "this portal (primary)", + 1, + 6, + 0, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000093", + "sample": "", + "values": [ + "P-0000093", + "this portal (primary)", + 1, + 2, + 8, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000098", + "sample": "", + "values": [ + "P-0000098", + "this portal (primary)", + 1, + 1, + 0, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000102", + "sample": "", + "values": [ + "P-0000102", + "this portal (primary)", + 1, + 4, + 2, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000104", + "sample": "", + "values": [ + "P-0000104", + "this portal (primary)", + 1, + 5, + 5, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000106", + "sample": "", + "values": [ + "P-0000106", + "this portal (primary)", + 1, + 4, + 7, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000107", + "sample": "", + "values": [ + "P-0000107", + "this portal (primary)", + 1, + 4, + 0, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000120", + "sample": "", + "values": [ + "P-0000120", + "this portal (primary)", + 1, + 6, + 2, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000125", + "sample": "", + "values": [ + "P-0000125", + "this portal (primary)", + 1, + 4, + 0, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000126", + "sample": "", + "values": [ + "P-0000126", + "this portal (primary)", + 1, + 5, + 7, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000129", + "sample": "", + "values": [ + "P-0000129", + "this portal (primary)", + 1, + 1, + 6, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000131", + "sample": "", + "values": [ + "P-0000131", + "this portal (primary)", + 1, + 2, + 5, + 0 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000138", + "sample": "", + "values": [ + "P-0000138", + "this portal (primary)", + 1, + 33, + 1, + 0 + ] + }, + { + "…": "5 more", + "sha256": "2f80c61f3b5e2133" + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "total": 5368, + "all": 5368 + } + ], + "total": 5368, + "all": 5368, + "patient": { + "study": "msk_chord_2024", + "id": "P-0000012", + "samples": [ + { + "id": "P-0000012-T02-IM3", + "type": "Primary" + }, + { + "id": "P-0000012-T03-IM3", + "type": "Metastasis" + } + ] + }, + "position": { + "index": 0, + "prev": null, + "next": { + "study": "msk_chord_2024", + "id": "P-0000015" + } + }, + "tables": { + "mutations": { + "columns": [ + { + "id": "samples", + "name": "Samples", + "numeric": false + }, + { + "id": "gene", + "name": "Gene", + "numeric": false + }, + { + "id": "proteinChange", + "name": "Protein Change", + "numeric": false + }, + { + "id": "annotation", + "name": "Annotation (OncoKB)", + "numeric": false + }, + { + "id": "mutationType", + "name": "Mutation Type", + "numeric": false + }, + { + "id": "copy", + "name": "Copy #", + "numeric": false + }, + { + "id": "freq", + "name": "Cohort %", + "numeric": true + }, + { + "id": "vaf", + "name": "Allele Freq", + "numeric": true + }, + { + "id": "altCount", + "name": "Variant Reads", + "numeric": true + }, + { + "id": "refCount", + "name": "Ref Reads", + "numeric": true + }, + { + "id": "variantType", + "name": "Variant Type", + "numeric": false + }, + { + "id": "chr", + "name": "Chromosome", + "numeric": false + }, + { + "id": "start", + "name": "Start Pos", + "numeric": true + }, + { + "id": "end", + "name": "End Pos", + "numeric": true + }, + { + "id": "ref", + "name": "Ref", + "numeric": false + }, + { + "id": "var", + "name": "Var", + "numeric": false + }, + { + "id": "status", + "name": "MS", + "numeric": false + } + ], + "shown": [ + "samples", + "gene", + "proteinChange", + "annotation", + "mutationType", + "copy", + "freq", + "vaf" + ], + "defaults": [ + "samples", + "gene", + "proteinChange", + "annotation", + "mutationType", + "copy", + "freq", + "vaf" + ], + "query": {}, + "rows": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "ATRX", + "K983*", + "Likely Oncogenic", + "Nonsense_Mutation", + "", + 3.3, + 0.198, + 110, + 446, + "SNP", + "23", + 76937801, + 76937801, + "T", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "BLM", + "A363fs", + "Likely Oncogenic", + "Frame_Shift_Del", + "", + 1.4, + 0.128, + 43, + 294, + "DEL", + "15", + 91298168, + 91298168, + "G", + "-", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "FBXW7", + "G61*", + "Likely Oncogenic · Level 3A", + "Nonsense_Mutation", + "", + 4.5, + 0.228, + 130, + 440, + "SNP", + "4", + 153332775, + 153332775, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "FBXW7", + "X413_splice", + "Likely Oncogenic · Level 3A", + "Splice_Site", + "", + 4.5, + 0.255, + 85, + 248, + "SNP", + "4", + 153249542, + 153249542, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "MAP3K1", + "E302*", + "Likely Oncogenic", + "Nonsense_Mutation", + "", + 3.1, + 0.174, + 72, + 341, + "SNP", + "5", + 56160630, + 56160630, + "G", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "MAP3K1", + "X696_splice", + "Likely Oncogenic", + "Splice_Site", + "", + 3.1, + 0.201, + 57, + 227, + "SNP", + "5", + 56174930, + 56174930, + "T", + "G", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "PTPRD", + "E915*", + "Likely Oncogenic", + "Nonsense_Mutation", + "", + 4.3, + 0.176, + 94, + 439, + "SNP", + "9", + 8486074, + 8486074, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "PTPRD", + "P1338T", + "Unknown", + "Missense_Mutation", + "", + 4.3, + 0.298, + 135, + 318, + "SNP", + "9", + 8436666, + 8436666, + "G", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "PTPRT", + "G969V", + "Unknown", + "Missense_Mutation", + "", + 4.8, + 0.142, + 63, + 380, + "SNP", + "20", + 40748610, + 40748610, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "PTPRT", + "X1053_splice", + "Likely Oncogenic", + "Splice_Site", + "", + 4.8, + 0.051, + 13, + 243, + "SNP", + "20", + 40739128, + 40739128, + "C", + "G", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "SMARCA4", + "E1211*", + "Likely Oncogenic · Level 3A", + "Nonsense_Mutation", + "", + 4.3, + 0.208, + 82, + 313, + "SNP", + "19", + 11144050, + 11144050, + "G", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T02-IM3", + "values": [ + "P-0000012-T02-IM3", + "TP53", + "T256P", + "Likely Oncogenic", + "Missense_Mutation", + "", + 52.4, + 0.502, + 114, + 113, + "SNP", + "17", + 7577515, + 7577515, + "T", + "G", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "TP53", + "P67Qfs*56", + "Likely Oncogenic", + "Frame_Shift_Del", + "", + 52.4, + 0.402, + 88, + 131, + "DEL", + "17", + 7579487, + 7579487, + "G", + "-", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "ATR", + "R2431M", + "Unknown", + "Missense_Mutation", + "", + 2.7, + 0.174, + 84, + 398, + "SNP", + "3", + 142178126, + 142178126, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "AXIN2", + "I375M", + "Unknown", + "Missense_Mutation", + "", + 2.1, + 0.137, + 89, + 561, + "SNP", + "17", + 63534396, + 63534396, + "G", + "C", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "BRIP1", + "D393V", + "Unknown", + "Missense_Mutation", + "", + 1.4, + 0.146, + 92, + 538, + "SNP", + "17", + 59876623, + 59876623, + "T", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "CCNE1", + "A47V", + "Unknown", + "Missense_Mutation", + "", + 0.5, + 0.149, + 39, + 222, + "SNP", + "19", + 30303904, + 30303904, + "C", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "CREBBP", + "M2161I", + "Unknown", + "Missense_Mutation", + "", + 3.4, + 0.248, + 67, + 203, + "SNP", + "16", + 3778565, + 3778565, + "C", + "A", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "DOT1L", + "W305C", + "Unknown", + "Missense_Mutation", + "", + 2.3, + 0.158, + 61, + 324, + "SNP", + "19", + 2207631, + 2207631, + "G", + "T", + "SOMATIC" + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "FLT4", + "S293R", + "Unknown", + "Missense_Mutation", + "", + 2.8, + 0.179, + 42, + 193, + "SNP", + "5", + 180056365, + 180056365, + "G", + "T", + "SOMATIC" + ] + }, + { + "…": "5 more", + "sha256": "b95108249fcda8db" + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "total": 31, + "all": 31 + } + ], + "total": 31, + "all": 31 + }, + "cna": { + "columns": [ + { + "id": "samples", + "name": "Samples", + "numeric": false + }, + { + "id": "gene", + "name": "Gene", + "numeric": false + }, + { + "id": "cna", + "name": "CNA", + "numeric": false + }, + { + "id": "annotation", + "name": "Annotation (OncoKB)", + "numeric": false + }, + { + "id": "cytoband", + "name": "Cytoband", + "numeric": false + }, + { + "id": "freq", + "name": "Cohort %", + "numeric": true + } + ], + "shown": [ + "samples", + "gene", + "cna", + "annotation", + "cytoband", + "freq" + ], + "defaults": [ + "samples", + "gene", + "cna", + "annotation", + "cytoband", + "freq" + ], + "query": {}, + "rows": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T03-IM3", + "values": [ + "P-0000012-T03-IM3", + "CDK4", + "AMP", + "Oncogenic · Level 4", + "12q14.1", + 1.6 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T02-IM3", + "values": [ + "P-0000012-T02-IM3", + "MCL1", + "AMP", + "Oncogenic", + "1q21.2", + 1.5 + ] + }, + { + "cohort": "Breast", + "study": "msk_chord_2024", + "patient": "P-0000012", + "sample": "P-0000012-T02-IM3", + "values": [ + "P-0000012-T02-IM3", + "RIT1", + "AMP", + "Unknown", + "1q22", + 0.7 + ] + } + ], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "total": 3, + "all": 3 + } + ], + "total": 3, + "all": 3 + }, + "sv": { + "columns": [ + { + "id": "samples", + "name": "Samples", + "numeric": false + }, + { + "id": "gene1", + "name": "Gene 1", + "numeric": false + }, + { + "id": "gene2", + "name": "Gene 2", + "numeric": false + }, + { + "id": "class", + "name": "Variant Class", + "numeric": false + }, + { + "id": "eventInfo", + "name": "Event Info", + "numeric": false + }, + { + "id": "breakpointType", + "name": "Breakpoint Type", + "numeric": false + }, + { + "id": "connectionType", + "name": "Connection Type", + "numeric": false + }, + { + "id": "frame", + "name": "Effect on Frame", + "numeric": false + }, + { + "id": "site1", + "name": "Site 1 Description", + "numeric": false + }, + { + "id": "site2", + "name": "Site 2 Description", + "numeric": false + }, + { + "id": "pos1", + "name": "Site 1 Position", + "numeric": false + }, + { + "id": "pos2", + "name": "Site 2 Position", + "numeric": false + }, + { + "id": "length", + "name": "Length", + "numeric": true + }, + { + "id": "tumorVariantCount", + "name": "Tumor Variant Count", + "numeric": true + }, + { + "id": "tumorReadCount", + "name": "Tumor Read Count", + "numeric": true + }, + { + "id": "dnaSupport", + "name": "DNA Support", + "numeric": false + }, + { + "id": "rnaSupport", + "name": "RNA Support", + "numeric": false + }, + { + "id": "status", + "name": "Status", + "numeric": false + }, + { + "id": "svAnnotation", + "name": "Study Annotation", + "numeric": false + }, + { + "id": "comments", + "name": "Comments", + "numeric": false + } + ], + "shown": [ + "samples", + "gene1", + "gene2", + "class", + "eventInfo", + "breakpointType", + "connectionType" + ], + "defaults": [ + "samples", + "gene1", + "gene2", + "class", + "eventInfo", + "breakpointType", + "connectionType" + ], + "query": {}, + "rows": [], + "offset": 0, + "pageSize": 25, + "lists": [ + { + "cohort": "Breast", + "study": "msk_chord_2024", + "total": 0, + "all": 0 + } + ], + "total": 0, + "all": 0 + } + }, + "oncokbPin": "v7.5" + }, + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": true, + "aggregateOnly": [] + }, + "caveat": "P-0000012 — Mutations: 31 rows; Copy Number Alterations: 3 rows; Structural Variants: 0 rows. Each table lists a variant, a gene's call or an event once however many of the patient's samples carry it (Samples names them); allele frequency and read counts are the highest among those samples. Copy number is the deep calls only (AMP, HOMDEL), as the portal's patient view lists them; Copy # on a mutation is the gene's deep calls anywhere in the patient. Cohort % is the share of the study's samples profiled for the gene by their panel with a mutation in it, or with the same copy-number call. Annotation is OncoKB v7.5 (oncogenicity and its highest sensitivity level); structural variants carry the study's own annotation, not OncoKB's. The patient list: 5,368 patients. Sorted with patients who have any alteration first, then by patient id across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. ", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count the patients per cohort and study", + "detail": "The alterations:counts query above: every patient of each cohort, with their sample count and how many rows each of the three tables lists for them (a mutation, a gene's deep copy-number call, a structural variant — each counted once however many samples carry it).", + "params": [ + [ + "Breast · msk_chord_2024", + "5,368" + ] + ] + }, + { + "kind": "fetch", + "title": "Sort them together and take one page", + "detail": "The alterations:rows query above: the patients of every cohort and study combined in one query, sorted patients with any alteration first, then by patient id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset." + }, + { + "kind": "fetch", + "title": "Read P-0000012's three tables", + "detail": "The alterations:mutations, alterations:cna and alterations:sv queries above, each paged, searched, filtered and sorted in the database like any table view. Mutations: every called mutation of the patient's samples (uncalled calls left out), one row per variant with the samples carrying it, the highest allele frequency among them (variant / (variant + reference) reads) with that sample's reads, and the gene's deep copy-number calls in the patient (Copy #). Copy-number alterations: the deep calls (AMP, HOMDEL), one row per gene and call. Structural variants: one row per event (both genes and breakpoints, class, event info), the highest read counts among its samples. Cohort % is the share of the study's samples profiled for the gene (by their gene panel) with any mutation in it, or with the same copy-number call; the annotation is the OncoKB v7.5 call for the protein change, or for AMPLIFICATION / DELETION.", + "params": [ + [ + "Mutations", + "31 rows" + ], + [ + "Copy Number Alterations", + "3 rows" + ], + [ + "Structural Variants", + "0 rows" + ] + ] + } + ], + "implementation": { + "functions": [ + "runAlterations", + "alterationPatientRowSource", + "patientMutationsSource", + "patientCnaSource", + "patientSvSource", + "pageSql", + "countsSql", + "rankSql" + ], + "file": "lib/views/alterations.ts, lib/patient-alterations.ts, lib/table-query.ts", + "commit": null + }, + "verification": "A listing: no statistic is computed, so there is no script — the queries are the numbers." + } + } + ] +} diff --git a/test/snapshots/timeline.sql b/test/snapshots/timeline.sql new file mode 100644 index 0000000..1d5090f --- /dev/null +++ b/test/snapshots/timeline.sql @@ -0,0 +1,511 @@ +-- cohort Breast +-- msk_chord_2024 +(SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer')))) + +-- view 0 timeline: timeline:counts · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +pt0 AS ( + SELECT p.internal_id AS iid, p.stable_id AS pid FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) +), +ev0 AS ( + SELECT ce.patient_id AS iid, count() AS events, min(ce.start_date) AS first, + max(greatest(ce.start_date, ifNull(ce.stop_date, ce.start_date))) AS last, + arrayStringConcat(arraySort(groupUniqArray(trimBoth(ce.event_type))), ', ') AS types + FROM snapshot_db.clinical_event ce WHERE ce.patient_id IN (SELECT iid FROM pt0) + GROUP BY iid +), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS samples FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, pt.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.samples, 0)) AS samples, toUInt64(ifNull(ev.events, 0)) AS events, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.first)), NULL) AS first, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.last)), NULL) AS last, + ifNull(ev.types, '') AS types + FROM pt0 AS pt LEFT JOIN ev0 AS ev ON ev.iid = pt.iid LEFT JOIN sm0 AS sm ON sm.pid = pt.pid +) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 0 timeline: timeline:events · msk_chord_2024 +WITH pt AS ( + SELECT p.internal_id FROM snapshot_db.patient p JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id = 'P-0000012' +), ev AS ( + SELECT clinical_event_id, event_type, start_date, stop_date FROM snapshot_db.clinical_event WHERE patient_id IN (SELECT internal_id FROM pt) +) +SELECT ev.clinical_event_id AS id, ev.event_type AS type, ev.start_date AS start, ev.stop_date AS stop, + groupArrayIf((d.key, d.value), d.key != '') AS attrs +FROM ev LEFT JOIN ( + SELECT clinical_event_id, key, value FROM snapshot_db.clinical_event_data WHERE clinical_event_id IN (SELECT clinical_event_id FROM ev) +) d ON d.clinical_event_id = ev.clinical_event_id +GROUP BY id, type, start, stop +ORDER BY start, id + +-- view 0 timeline: timeline:rank · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +pt0 AS ( + SELECT p.internal_id AS iid, p.stable_id AS pid FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) +), +ev0 AS ( + SELECT ce.patient_id AS iid, count() AS events, min(ce.start_date) AS first, + max(greatest(ce.start_date, ifNull(ce.stop_date, ce.start_date))) AS last, + arrayStringConcat(arraySort(groupUniqArray(trimBoth(ce.event_type))), ', ') AS types + FROM snapshot_db.clinical_event ce WHERE ce.patient_id IN (SELECT iid FROM pt0) + GROUP BY iid +), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS samples FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, pt.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.samples, 0)) AS samples, toUInt64(ifNull(ev.events, 0)) AS events, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.first)), NULL) AS first, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.last)), NULL) AS last, + ifNull(ev.types, '') AS types + FROM pt0 AS pt LEFT JOIN ev0 AS ev ON ev.iid = pt.iid LEFT JOIN sm0 AS sm ON sm.pid = pt.pid +) +SELECT idx FROM (SELECT study, patient, row_number() OVER (ORDER BY toFloat64(events) DESC NULLS LAST, patient, ord) - 1 AS idx FROM rows +WHERE 1) +WHERE study = 'msk_chord_2024' AND patient = 'P-0000012' LIMIT 1 + +-- view 0 timeline: timeline:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +pt0 AS ( + SELECT p.internal_id AS iid, p.stable_id AS pid FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) +), +ev0 AS ( + SELECT ce.patient_id AS iid, count() AS events, min(ce.start_date) AS first, + max(greatest(ce.start_date, ifNull(ce.stop_date, ce.start_date))) AS last, + arrayStringConcat(arraySort(groupUniqArray(trimBoth(ce.event_type))), ', ') AS types + FROM snapshot_db.clinical_event ce WHERE ce.patient_id IN (SELECT iid FROM pt0) + GROUP BY iid +), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS samples FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, pt.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.samples, 0)) AS samples, toUInt64(ifNull(ev.events, 0)) AS events, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.first)), NULL) AS first, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.last)), NULL) AS last, + ifNull(ev.types, '') AS types + FROM pt0 AS pt LEFT JOIN ev0 AS ev ON ev.iid = pt.iid LEFT JOIN sm0 AS sm ON sm.pid = pt.pid +) +SELECT cohort, study, patient, sample, source, samples, events, first, last, types, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY toFloat64(events) DESC NULLS LAST, patient, ord +LIMIT 25 OFFSET 0 + +-- view 0 timeline: timeline:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +pt0 AS ( + SELECT p.internal_id AS iid, p.stable_id AS pid FROM snapshot_db.patient p + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) +), +ev0 AS ( + SELECT ce.patient_id AS iid, count() AS events, min(ce.start_date) AS first, + max(greatest(ce.start_date, ifNull(ce.stop_date, ce.start_date))) AS last, + arrayStringConcat(arraySort(groupUniqArray(trimBoth(ce.event_type))), ', ') AS types + FROM snapshot_db.clinical_event ce WHERE ce.patient_id IN (SELECT iid FROM pt0) + GROUP BY iid +), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS samples FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, pt.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.samples, 0)) AS samples, toUInt64(ifNull(ev.events, 0)) AS events, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.first)), NULL) AS first, + if(ifNull(ev.events, 0) > 0, toNullable(toInt64(ev.last)), NULL) AS last, + ifNull(ev.types, '') AS types + FROM pt0 AS pt LEFT JOIN ev0 AS ev ON ev.iid = pt.iid LEFT JOIN sm0 AS sm ON sm.pid = pt.pid +) +SELECT cohort, study, patient, sample, source, samples, events, first, last, types, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY toFloat64(events) DESC NULLS LAST, patient, ord +LIMIT 3 OFFSET 1250 + +-- view 0 timeline: timeline:samples · msk_chord_2024 +SELECT replaceOne(s.sample_unique_id, 'msk_chord_2024_', '') AS id, any(c.attribute_value) AS type +FROM snapshot_db.sample_derived s +LEFT JOIN snapshot_db.clinical_data_derived c ON c.sample_unique_id = s.sample_unique_id AND c.type = 'sample' + AND c.cancer_study_identifier = 'msk_chord_2024' AND c.attribute_name = 'SAMPLE_TYPE' +WHERE s.cancer_study_identifier = 'msk_chord_2024' AND s.patient_unique_id = 'msk_chord_2024_P-0000012' +GROUP BY id ORDER BY id + +-- view 1 alterations: alterations:cna:counts · msk_chord_2024 +WITH c AS ( + SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, hugo_gene_symbol AS gene, cna_alteration AS alt, cna_cytoband AS cytoband + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0000012' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 +), +g AS (SELECT gene, alt, any(cytoband) AS cytoband, arrayStringConcat(arraySort(x -> if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid))) AS so FROM c GROUP BY gene, alt), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'CNA' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +fa AS (SELECT hugo_gene_symbol AS gene, cna_alteration AS alt, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alt), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'COPY_NUMBER_ALTERATION' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, if(g.alt > 0, 'AMP', 'HOMDEL') AS cna, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.cytoband AS cytoband, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = if(g.alt > 0, 'AMPLIFICATION', 'DELETION') + LEFT JOIN fa ON fa.gene = g.gene AND fa.alt = g.alt LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 1 alterations: alterations:cna:rows · msk_chord_2024 +WITH c AS ( + SELECT replaceOne(sample_unique_id, 'msk_chord_2024_', '') AS sid, hugo_gene_symbol AS gene, cna_alteration AS alt, cna_cytoband AS cytoband + FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0000012' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 +), +g AS (SELECT gene, alt, any(cytoband) AS cytoband, arrayStringConcat(arraySort(x -> if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid))) AS so FROM c GROUP BY gene, alt), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'CNA' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +fa AS (SELECT hugo_gene_symbol AS gene, cna_alteration AS alt, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alt), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'COPY_NUMBER_ALTERATION' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, if(g.alt > 0, 'AMP', 'HOMDEL') AS cna, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.cytoband AS cytoband, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = if(g.alt > 0, 'AMPLIFICATION', 'DELETION') + LEFT JOIN fa ON fa.gene = g.gene AND fa.alt = g.alt LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT *, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY gdrv DESC, gene, so, gene, cna +LIMIT 25 OFFSET 0 + +-- view 1 alterations: alterations:counts · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 1 alterations: alterations:mutations:counts · msk_chord_2024 +WITH m AS ( + SELECT sampleId AS sid, `GENE.hugoGeneSymbol` AS gene, proteinChange, mutationType, variantType, chr, startPosition AS start, endPosition AS end, + referenceAllele AS ref, tumorSeqAllele AS var, tumorAltCount AS ac, tumorRefCount AS rc, mutationStatus AS ms, proteinPosStart AS codon, + if(tumorAltCount + tumorRefCount > 0, tumorAltCount / (tumorAltCount + tumorRefCount), NULL) AS f + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND patientId = 'P-0000012' AND molecularProfileId NOT LIKE '%uncalled%' +), +g AS ( + SELECT gene, proteinChange, mutationType, variantType, chr, start, end, ref, var, any(ms) AS status, min(codon) AS pos, arrayStringConcat(arraySort(x -> if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid))) AS so, + max(f) AS vaf, argMax(ac, ifNull(f, -1)) AS altCount, argMax(rc, ifNull(f, -1)) AS refCount + FROM m GROUP BY gene, proteinChange, mutationType, variantType, chr, start, end, ref, var +), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'MUTATION' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +cn AS (SELECT hugo_gene_symbol AS gene, arrayStringConcat(arraySort(groupUniqArray(if(cna_alteration > 0, 'AMP', 'HOMDEL'))), ', ') AS copy + FROM snapshot_db.genomic_event_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0000012' + AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fa AS (SELECT hugo_gene_symbol AS gene, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'mutation' AND genetic_profile_stable_id NOT LIKE '%uncalled%' + AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, g.proteinChange AS proteinChange, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.mutationType AS mutationType, ifNull(cn.copy, '') AS copy, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq, + g.vaf AS vaf, g.altCount AS altCount, g.refCount AS refCount, g.variantType AS variantType, g.chr AS chr, g.start AS start, g.end AS end, + g.ref AS ref, g.var AS var, g.status AS status, g.pos AS pos + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = g.proteinChange + LEFT JOIN cn ON cn.gene = g.gene LEFT JOIN fa ON fa.gene = g.gene LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 1 alterations: alterations:mutations:rows · msk_chord_2024 +WITH m AS ( + SELECT sampleId AS sid, `GENE.hugoGeneSymbol` AS gene, proteinChange, mutationType, variantType, chr, startPosition AS start, endPosition AS end, + referenceAllele AS ref, tumorSeqAllele AS var, tumorAltCount AS ac, tumorRefCount AS rc, mutationStatus AS ms, proteinPosStart AS codon, + if(tumorAltCount + tumorRefCount > 0, tumorAltCount / (tumorAltCount + tumorRefCount), NULL) AS f + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND patientId = 'P-0000012' AND molecularProfileId NOT LIKE '%uncalled%' +), +g AS ( + SELECT gene, proteinChange, mutationType, variantType, chr, start, end, ref, var, any(ms) AS status, min(codon) AS pos, arrayStringConcat(arraySort(x -> if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid))) AS so, + max(f) AS vaf, argMax(ac, ifNull(f, -1)) AS altCount, argMax(rc, ifNull(f, -1)) AS refCount + FROM m GROUP BY gene, proteinChange, mutationType, variantType, chr, start, end, ref, var +), +ann AS (SELECT hugo_gene_symbol AS gene, alteration, any(oncogenicity) AS oncogenicity, any(highest_sensitive_level) AS level, max(is_driver) AS driver + FROM oncokb_annotation.variant_annotation WHERE oncokb_version = 'v7.5' AND alteration_type = 'MUTATION' AND hugo_gene_symbol IN (SELECT gene FROM g) + GROUP BY gene, alteration), +cn AS (SELECT hugo_gene_symbol AS gene, arrayStringConcat(arraySort(groupUniqArray(if(cna_alteration > 0, 'AMP', 'HOMDEL'))), ', ') AS copy + FROM snapshot_db.genomic_event_derived WHERE cancer_study_identifier = 'msk_chord_2024' AND patient_unique_id = 'msk_chord_2024_P-0000012' + AND variant_type = 'cna' AND abs(cna_alteration) >= 2 AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fa AS (SELECT hugo_gene_symbol AS gene, uniqExact(sample_unique_id) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'mutation' AND genetic_profile_stable_id NOT LIKE '%uncalled%' + AND hugo_gene_symbol IN (SELECT gene FROM g) GROUP BY gene), +fp AS (SELECT pg.gene AS gene, uniqExact(sp.sample_unique_id) AS n FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN (SELECT gene FROM g) + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' GROUP BY gene), +rows AS (SELECT *, max(drv) OVER (PARTITION BY gene) AS gdrv FROM ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, splitByString(', ', g.samples)[1] AS sid, g.samples AS samples, g.so AS so, g.gene AS gene, g.proteinChange AS proteinChange, ifNull(ann.oncogenicity, '') AS oncogenicity, ifNull(ann.level, '') AS level, toUInt8(ifNull(ann.driver, 0)) AS drv, + g.mutationType AS mutationType, ifNull(cn.copy, '') AS copy, if(ifNull(fp.n, 0) > 0, 100 * ifNull(fa.n, 0) / fp.n, NULL) AS freq, + g.vaf AS vaf, g.altCount AS altCount, g.refCount AS refCount, g.variantType AS variantType, g.chr AS chr, g.start AS start, g.end AS end, + g.ref AS ref, g.var AS var, g.status AS status, g.pos AS pos + FROM g + LEFT JOIN ann ON ann.gene = g.gene AND ann.alteration = g.proteinChange + LEFT JOIN cn ON cn.gene = g.gene LEFT JOIN fa ON fa.gene = g.gene LEFT JOIN fp ON fp.gene = g.gene +)) +SELECT *, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY gdrv DESC, gene, so, pos ASC NULLS LAST, gene, chr, start, end, ref, var, proteinChange, mutationType +LIMIT 25 OFFSET 0 + +-- view 1 alterations: alterations:rank · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT idx FROM (SELECT study, patient, row_number() OVER (ORDER BY mutations + cna + sv = 0, patient, patient, ord) - 1 AS idx FROM rows +WHERE 1) +WHERE study = 'msk_chord_2024' AND patient = 'P-0000012' LIMIT 1 + +-- view 1 alterations: alterations:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT cohort, study, patient, sample, source, samples, mutations, cna, sv, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY mutations + cna + sv = 0, patient, patient, ord +LIMIT 2 OFFSET 0 + +-- view 1 alterations: alterations:rows · msk_chord_2024 +WITH c0 AS ((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type = 'sample' + AND attribute_name = 'CANCER_TYPE' AND lowerUTF8(trimBoth(attribute_value)) IN (lowerUTF8(trimBoth('Breast Cancer'))))), +sm0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(sample_unique_id) AS n FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +mu0 AS ( + SELECT patientId AS pid, uniqExact(tuple(`GENE.hugoGeneSymbol`, proteinChange, mutationType, variantType, chr, startPosition, endPosition, referenceAllele, tumorSeqAllele)) AS n + FROM snapshot_db.mutation_derived + WHERE studyId = 'msk_chord_2024' AND molecularProfileId NOT LIKE '%uncalled%' AND patientId IN (SELECT pid FROM c0) + GROUP BY pid +), +cn0 AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, uniqExact(hugo_gene_symbol, cna_alteration) AS n FROM snapshot_db.genomic_event_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND variant_type = 'cna' AND abs(cna_alteration) >= 2 + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM c0) + GROUP BY pid +), +sv0 AS ( + SELECT p.stable_id AS pid, uniqExact(tuple(sv.site1_entrez_gene_id, sv.site2_entrez_gene_id, sv.class, sv.event_info, sv.site1_chromosome, sv.site1_position, sv.site2_chromosome, sv.site2_position)) AS n + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample s ON s.internal_id = sv.sample_id + JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id IN (SELECT pid FROM c0) + GROUP BY pid +), +rows AS ( + SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, c.pid AS patient, '' AS sample, 'this portal (primary)' AS source, + toUInt64(ifNull(sm.n, 0)) AS samples, toUInt64(ifNull(mu.n, 0)) AS mutations, toUInt64(ifNull(cn.n, 0)) AS cna, toUInt64(ifNull(sv.n, 0)) AS sv + FROM (SELECT DISTINCT pid FROM c0) AS c + LEFT JOIN sm0 AS sm ON sm.pid = c.pid LEFT JOIN mu0 AS mu ON mu.pid = c.pid + LEFT JOIN cn0 AS cn ON cn.pid = c.pid LEFT JOIN sv0 AS sv ON sv.pid = c.pid +) +SELECT cohort, study, patient, sample, source, samples, mutations, cna, sv, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY mutations + cna + sv = 0, patient, patient, ord +LIMIT 25 OFFSET 0 + +-- view 1 alterations: alterations:samples:counts · msk_chord_2024 +WITH s AS (SELECT replaceOne(s.sample_unique_id, 'msk_chord_2024_', '') AS id, any(c.attribute_value) AS type +FROM snapshot_db.sample_derived s +LEFT JOIN snapshot_db.clinical_data_derived c ON c.sample_unique_id = s.sample_unique_id AND c.type = 'sample' + AND c.cancer_study_identifier = 'msk_chord_2024' AND c.attribute_name = 'SAMPLE_TYPE' +WHERE s.cancer_study_identifier = 'msk_chord_2024' AND s.patient_unique_id = 'msk_chord_2024_P-0000012' +GROUP BY id ORDER BY id), +rows AS (SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, s.id AS sid, ifNull(s.type, '') AS type FROM s) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study + +-- view 1 alterations: alterations:samples:rows · msk_chord_2024 +WITH s AS (SELECT replaceOne(s.sample_unique_id, 'msk_chord_2024_', '') AS id, any(c.attribute_value) AS type +FROM snapshot_db.sample_derived s +LEFT JOIN snapshot_db.clinical_data_derived c ON c.sample_unique_id = s.sample_unique_id AND c.type = 'sample' + AND c.cancer_study_identifier = 'msk_chord_2024' AND c.attribute_name = 'SAMPLE_TYPE' +WHERE s.cancer_study_identifier = 'msk_chord_2024' AND s.patient_unique_id = 'msk_chord_2024_P-0000012' +GROUP BY id ORDER BY id), +rows AS (SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, s.id AS sid, ifNull(s.type, '') AS type FROM s) +SELECT *, count() OVER () AS total FROM rows +WHERE 1 +ORDER BY sid, sid +LIMIT 1000 OFFSET 0 + +-- view 1 alterations: alterations:sv:counts · msk_chord_2024 +WITH s AS ( + SELECT smp.stable_id AS sid, ifNull(g1.hugo_gene_symbol, '') AS gene1, ifNull(g2.hugo_gene_symbol, '') AS gene2, + ifNull(sv.class, '') AS class, ifNull(sv.event_info, '') AS eventInfo, sv.breakpoint_type AS breakpointType, sv.connection_type AS connectionType, + sv.site2_effect_on_frame AS frame, sv.site1_description AS site1, sv.site2_description AS site2, + if(sv.site1_position IS NULL, '', concat(ifNull(sv.site1_chromosome, ''), ':', toString(sv.site1_position))) AS pos1, + if(sv.site2_position IS NULL, '', concat(ifNull(sv.site2_chromosome, ''), ':', toString(sv.site2_position))) AS pos2, + sv.length AS length, sv.tumor_variant_count AS tumorVariantCount, sv.tumor_read_count AS tumorReadCount, + sv.dna_support AS dnaSupport, sv.rna_support AS rnaSupport, sv.sv_status AS status, sv.annotation AS svAnnotation, sv.comments AS comments + FROM snapshot_db.structural_variant sv + JOIN snapshot_db.sample smp ON smp.internal_id = sv.sample_id + LEFT JOIN snapshot_db.gene g1 ON g1.entrez_gene_id = sv.site1_entrez_gene_id + LEFT JOIN snapshot_db.gene g2 ON g2.entrez_gene_id = sv.site2_entrez_gene_id + WHERE sv.sample_id IN (SELECT s.internal_id FROM snapshot_db.sample s JOIN snapshot_db.patient p ON p.internal_id = s.patient_id + JOIN snapshot_db.cancer_study cs ON cs.cancer_study_id = p.cancer_study_id + WHERE cs.cancer_study_identifier = 'msk_chord_2024' AND p.stable_id = 'P-0000012') +), +g AS ( + SELECT gene1, gene2, class, eventInfo, pos1, pos2, arrayStringConcat(arraySort(x -> if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], x)), groupUniqArray(sid)), ', ') AS samples, min(if(indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid) = 0, 1000000, indexOf(['P-0000012-T02-IM3', 'P-0000012-T03-IM3'], sid))) AS so, + any(breakpointType) AS breakpointType, any(connectionType) AS connectionType, any(frame) AS frame, any(site1) AS site1, any(site2) AS site2, + any(length) AS length, max(tumorVariantCount) AS tumorVariantCount, max(tumorReadCount) AS tumorReadCount, + any(dnaSupport) AS dnaSupport, any(rnaSupport) AS rnaSupport, any(status) AS status, any(svAnnotation) AS svAnnotation, any(comments) AS comments + FROM s GROUP BY gene1, gene2, class, eventInfo, pos1, pos2 +), +rows AS (SELECT 'Breast' AS cohort, 'msk_chord_2024' AS study, 0 AS ord, 'P-0000012' AS patient, splitByString(', ', g.samples)[1] AS sid, g.* FROM g) +SELECT cohort, study, countIf(1) AS n, count() AS all FROM rows GROUP BY cohort, study diff --git a/test/snapshots/timeline.svg b/test/snapshots/timeline.svg new file mode 100644 index 0000000..8cb6f46 --- /dev/null +++ b/test/snapshots/timeline.svg @@ -0,0 +1,4 @@ + +(no figure) + +(no figure) diff --git a/test/snapshots/timeline.txt b/test/snapshots/timeline.txt new file mode 100644 index 0000000..bc5ff2f --- /dev/null +++ b/test/snapshots/timeline.txt @@ -0,0 +1,290 @@ +Analysis over msk_chord_2024 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Breast: 5,368 patients — CANCER_TYPE in [Breast Cancer] (any sample) + +Patient timeline — patients to choose from: 5,368; the first 25, tab-separated (the web app's view pages and downloads every row, with every column): + cohort patient source samples events span types + Breast P-0014149 this portal (primary) 1 925 6137 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0007146 this portal (primary) 1 800 5211 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0015681 this portal (primary) 1 717 6495 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0041672 this portal (primary) 1 708 4675 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0047755 this portal (primary) 1 694 5302 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0016734 this portal (primary) 1 677 6765 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0057382 this portal (primary) 1 663 7893 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0003958 this portal (primary) 1 655 6883 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0010993 this portal (primary) 1 652 6492 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0011420 this portal (primary) 1 646 7755 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0015568 this portal (primary) 1 642 9729 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0018146 this portal (primary) 1 638 9583 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0008398 this portal (primary) 1 635 3452 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0029771 this portal (primary) 1 632 4634 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0001990 this portal (primary) 1 621 4828 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0007045 this portal (primary) 1 612 3923 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0013915 this portal (primary) 1 609 7004 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0001939 this portal (primary) 1 574 6298 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0025567 this portal (primary) 1 573 5364 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0002531 this portal (primary) 1 571 6504 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0062207 this portal (primary) 1 569 5832 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0022066 this portal (primary) 1 565 3851 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0020130 this portal (primary) 1 561 6233 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0004381 this portal (primary) 1 555 8571 Diagnosis, Lab_Test, Sample acquisition, Sequencing, Surgery, Treatment + Breast P-0020707 this portal (primary) 1 555 11415 Diagnosis, Lab_Test, Pathology, Sample acquisition, Sequencing, Surgery, Treatment + … 5,343 more rows +P-0000012 (msk_chord_2024): 172 events, days from diagnosis; samples: P-0000012-T02-IM3 (Primary), P-0000012-T03-IM3 (Metastasis) + day -9641: Diagnosis — SUBTYPE=Primary, CLINICAL_GROUP=99, SUMMARY=N/A, PATH_GROUP=99, SOURCE=Tumor Registry, DX_DESCRIPTION=INFILTRATING DUCT CARCINOMA | BREAST, NOS (M8500/3 | C509), STAGE_CDM_DERIVED=Stage 1-3 + day -5453: Sample acquisition — SEQ_DATE=48, SAMPLE_ID=P-0000012-T02-IM3 + day -5437–-5369: Treatment — SUBTYPE=Chemo, AGENT=CYCLOPHOSPHAMIDE, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day -5437–-5326: Treatment — SUBTYPE=Chemo, AGENT=FLUOROURACIL, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day -5437–-5327: Treatment — SUBTYPE=Chemo, AGENT=METHOTREXATE, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day -5437: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.8 + day -5307: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=21 + day -5307: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.9 + day -5178: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=16 + day -5178: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.4 + day -4999: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=17 + day -4999: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.5 + day -4849: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=14 + day -4849: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.4 + day -4684: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=14 + day -4684: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.7 + day -4530: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=17 + day -4530: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.2 + day -4362: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=13 + day -4362: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.3 + day -3946: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=14 + day -3946: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.8 + day -3603: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=15 + day -3603: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2.2 + day -3382: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=14 + day -3382: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.9 + day -3165: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=12 + day -3165: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2.2 + day -2990: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=12 + day -2990: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.9 + day -2717: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=13 + day -2717: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2.1 + day -2634: Surgery — SUBTYPE=PROCEDURE + day -2507: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=9 + day -2507: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2 + day -2221: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=8 + day -2221: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=1.8 + day -1891: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=9 + day -1891: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2.4 + day -1408: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=11 + day -1408: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2.2 + day -695: Surgery — SUBTYPE=PROCEDURE + day -685: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=10 + day -685: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=2.9 + day -323: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=15 + day -323: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=3.2 + day -255: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.037178118, PROCEDURE_TYPE=MR, PROGRESSION=N + day -255: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0010828, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day -253: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.38813508, PROCEDURE_TYPE=MR, PROGRESSION=Indeterminate + day -253: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0004522, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day -83: Lab_Test — TEST=CA_15-3, LR_UNIT_MEASURE=Units/ml, RESULT=13 + day -83: Lab_Test — TEST=CEA, LR_UNIT_MEASURE=ng/ml, RESULT=4.6 + day -68: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.284787, PROCEDURE_TYPE=PET, PROGRESSION=Indeterminate + day -68: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.99975103, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=PET + day -68: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Lymph Nodes, CHEST=0, OTHER=1, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day -42: Diagnosis — SUBTYPE=Primary, CLINICAL_GROUP=3B, SUMMARY=Distant, AJCC=IIIB, PATH_GROUP=99, SOURCE=Tumor Registry, DX_DESCRIPTION=ADENOCARCINOMA, NOS | LUNG, NOS (M8140/3 | C349), STAGE_CDM_DERIVED=Stage 1-3 + day 0: Sequencing — SAMPLE_ID=P-0000012-T03-IM3 + day 0: Sample acquisition — SEQ_DATE=0, SAMPLE_ID=P-0000012-T03-IM3 + day 0: Surgery — SUBTYPE=SAMPLE + day 10: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.90068585, PROCEDURE_TYPE=CT, PROGRESSION=Y + day 10: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.8226569, PROCEDURE_TYPE=PET, PROGRESSION=Y + day 10: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.3279463, PROCEDURE_TYPE=MR, PROGRESSION=Indeterminate + day 10: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.9997148, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=PET + day 10: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.0003389, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day 10: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.99968517, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 10: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lymph Nodes, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 10: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Lymph Nodes, CHEST=0, OTHER=1, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 10: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Other, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 33–40: Treatment — SUBTYPE=Chemo, AGENT=CISPLATIN, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day 33–65: Treatment — SUBTYPE=Chemo, AGENT=ETOPOSIDE, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day 33: Treatment — SUBTYPE=Radiation Therapy + day 48: Sequencing — SAMPLE_ID=P-0000012-T02-IM3 + day 61–68: Treatment — SUBTYPE=Chemo, AGENT=CARBOPLATIN, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day 149: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.18018433, PROCEDURE_TYPE=CT, PROGRESSION=N + day 149: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.6276817, ABDOMEN=FALSE, HAS_CANCER=Indeterminate, PROCEDURE_TYPE=CT + day 149: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lymph Nodes, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 159: Diagnosis — SUBTYPE=Performance Status, ECOG=0 + day 251: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.17210542, PROCEDURE_TYPE=CT, PROGRESSION=N + day 251: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.04371244, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 281: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.8392186, PROCEDURE_TYPE=PET, PROGRESSION=Y + day 281: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.99964726, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=PET + day 281: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Intra-Abdominal, CHEST=0, OTHER=1, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 281: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Lymph Nodes, CHEST=0, OTHER=1, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 289: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.2349452, PROCEDURE_TYPE=PET, PROGRESSION=Indeterminate + day 289: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.18626133, PROCEDURE_TYPE=PET, PROGRESSION=N + day 289: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.1163108, ABDOMEN=TRUE, HAS_CANCER=N, PROCEDURE_TYPE=PET + day 289: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.3926556, ABDOMEN=FALSE, HAS_CANCER=Indeterminate, PROCEDURE_TYPE=PET + day 289: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Lymph Nodes, CHEST=0, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 289: Surgery — SUBTYPE=SAMPLE + day 297: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.043223906, PROCEDURE_TYPE=MR, PROGRESSION=N + day 297: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.0004539, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day 306: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.00981985, PROCEDURE_TYPE=CT, PROGRESSION=N + day 306: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.99856204, ABDOMEN=TRUE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 306: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Intra-Abdominal, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=1 + day 306: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Other, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=1 + day 320: Treatment — SUBTYPE=Investigational, AGENT=INVESTIGATIONAL, RX_INVESTIGATIVE=Y, FLAG_OROTOPICAL=0 + day 320: Treatment — SUBTYPE=Investigational, AGENT=INVESTIGATIONAL, RX_INVESTIGATIVE=Y, FLAG_OROTOPICAL=0 + day 334: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.18738739, PROCEDURE_TYPE=CT, PROGRESSION=N + day 334: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.001281, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 335: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.1852476, PROCEDURE_TYPE=MR, PROGRESSION=N + day 335: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.00104094, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day 367: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.002592743, PROCEDURE_TYPE=CT, PROGRESSION=N + day 367: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.97957146, ABDOMEN=TRUE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 367: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lymph Nodes, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=1 + day 409: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.2979155, PROCEDURE_TYPE=CT, PROGRESSION=Indeterminate + day 409: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.9997031, ABDOMEN=TRUE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 409: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lymph Nodes, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=1 + day 499: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.001804908, PROCEDURE_TYPE=CT, PROGRESSION=N + day 499: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.05136776, ABDOMEN=TRUE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 502: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.01994526, PROCEDURE_TYPE=PET, PROGRESSION=N + day 502: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.970199, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=PET + day 502: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Lymph Nodes, CHEST=0, OTHER=1, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 587: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.13669538, PROCEDURE_TYPE=CT, PROGRESSION=N + day 587: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.09822476, PROCEDURE_TYPE=PET, PROGRESSION=N + day 587: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0006456, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=PET + day 587: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0010181, ABDOMEN=TRUE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 691: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.001298996, PROCEDURE_TYPE=CT, PROGRESSION=N + day 691: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.00719047, ABDOMEN=TRUE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 803: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.002349537, PROCEDURE_TYPE=CT, PROGRESSION=N + day 803: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.033495385, PROCEDURE_TYPE=PET, PROGRESSION=N + day 803: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0007946, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=PET + day 803: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.927494, ABDOMEN=TRUE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 980: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.001755151, PROCEDURE_TYPE=CT, PROGRESSION=N + day 980: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.3707743, ABDOMEN=TRUE, HAS_CANCER=Indeterminate, PROCEDURE_TYPE=CT + day 1136: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.07828353, PROCEDURE_TYPE=PET, PROGRESSION=N + day 1136: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.002298566, PROCEDURE_TYPE=CT, PROGRESSION=N + day 1136: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.21760744, ABDOMEN=TRUE, HAS_CANCER=Indeterminate, PROCEDURE_TYPE=CT + day 1136: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0052873, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=PET + day 1317: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.034641445, PROCEDURE_TYPE=PET, PROGRESSION=N + day 1317: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0012883, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=PET + day 1498: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.008373962, PROCEDURE_TYPE=PET, PROGRESSION=N + day 1498: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.00069153, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=PET + day 1681: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.028722772, PROCEDURE_TYPE=CT, PROGRESSION=N + day 1681: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.91513604, ABDOMEN=TRUE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 1681: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lung, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=1 + day 1688: Surgery — SUBTYPE=SAMPLE + day 1700: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.42995712, PROCEDURE_TYPE=MR, PROGRESSION=Indeterminate + day 1700: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.0015915, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day 1702: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.002305086, PROCEDURE_TYPE=PET, PROGRESSION=N + day 1702: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.99966264, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=PET + day 1702: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=PET, TUMOR_SITE=Lung, CHEST=0, OTHER=0, HEAD=1, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 1721: Treatment — SUBTYPE=Radiation Therapy + day 1734–1814: Treatment — SUBTYPE=Immuno, AGENT=NIVOLUMAB, RX_INVESTIGATIVE=N, FLAG_OROTOPICAL=0 + day 1862: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.12809414, PROCEDURE_TYPE=CT, PROGRESSION=N + day 1862: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.1993236, ABDOMEN=TRUE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 1974: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.0156624, PROCEDURE_TYPE=CT, PROGRESSION=N + day 1974: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.9815399, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 1974: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lung, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 2086: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.002995548, PROCEDURE_TYPE=CT, PROGRESSION=N + day 2086: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0402322, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 2269: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.088399045, PROCEDURE_TYPE=CT, PROGRESSION=N + day 2269: Diagnosis — SUBTYPE=HasCancer, PELVIS=TRUE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.99789196, ABDOMEN=TRUE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 2269: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lung, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=1, SOURCE=Radiology Reports (NLP), PELVIS=1 + day 2444: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.111479566, PROCEDURE_TYPE=MR, PROGRESSION=N + day 2444: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=FALSE, HEAD=TRUE, NLP_HAS_CANCER_PROBABILITY=0.0043055, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=MR + day 2445: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.001614616, PROCEDURE_TYPE=CT, PROGRESSION=N + day 2445: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.99383426, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 2627: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.001661092, PROCEDURE_TYPE=CT, PROGRESSION=N + day 2627: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.20430684, ABDOMEN=FALSE, HAS_CANCER=Indeterminate, PROCEDURE_TYPE=CT + day 2809: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.003464612, PROCEDURE_TYPE=CT, PROGRESSION=N + day 2809: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.9919733, ABDOMEN=FALSE, HAS_CANCER=Y, PROCEDURE_TYPE=CT + day 2809: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=CT, TUMOR_SITE=Lung, CHEST=1, OTHER=0, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + day 2998: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.004493397, PROCEDURE_TYPE=CT, PROGRESSION=N + day 2998: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0110871, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 3216: Surgery — SUBTYPE=PROCEDURE + day 3366: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.021393053, PROCEDURE_TYPE=CT, PROGRESSION=N + day 3366: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=TRUE, OTHER=FALSE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.0114738, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 3367: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.17969903, PROCEDURE_TYPE=CT, PROGRESSION=N + day 3367: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.00155187, ABDOMEN=FALSE, HAS_CANCER=N, PROCEDURE_TYPE=CT + day 3377: Diagnosis — SUBTYPE=Progression, NLP_PROGRESSION_PROBABILITY=0.17046168, PROCEDURE_TYPE=MR, PROGRESSION=N + day 3377: Diagnosis — SUBTYPE=HasCancer, PELVIS=FALSE, CHEST=FALSE, OTHER=TRUE, HEAD=FALSE, NLP_HAS_CANCER_PROBABILITY=0.4474247, ABDOMEN=FALSE, HAS_CANCER=Indeterminate, PROCEDURE_TYPE=MR + day 3377: Diagnosis — SUBTYPE=Tumor Sites, SOURCE_SPECIFIC=MR, TUMOR_SITE=Other, CHEST=0, OTHER=1, HEAD=0, ABDOMEN=0, SOURCE=Radiology Reports (NLP), PELVIS=0 + CAVEAT (tell the user): The list is one row per patient of each cohort; event counts and days come from the study's timeline, in days from diagnosis as the study records them. 5,368 patients. Sorted by Events (highest first), missing values last, across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. + METHOD: + - Count the patients per cohort and study: The timeline:counts query above: every patient of each cohort, with their sample count and, from the study's timeline, the number of events, the first and last event day (a range counted to its stop) and the event types — a patient with no timeline is listed with none. + Breast · msk_chord_2024: 5,368 + - Sort them together and take one page: The timeline:rows query above: the patients of every cohort and study combined in one query, sorted by Events descending with missing values last, then patient id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset. + - Read P-0000012's timeline: The timeline:events and timeline:samples queries above: every clinical event recorded for P-0000012 in msk_chord_2024 with all its attributes, and the patient's samples with their SAMPLE_TYPE. Events are drawn as stored, in days from diagnosis; tracks group them by event type (case-folded) and nest them by attribute as cBioPortal's patient view does. + events: 172 + samples: 2 + A listing and one patient's record: no statistic is computed, so there is no script — the queries are the numbers. + +Patient alterations — patients to choose from: 5,368; the first 25, tab-separated (the web app's view pages and downloads every row, with every column): + cohort patient source samples mutations cna sv + Breast P-0000012 this portal (primary) 2 31 3 0 + Breast P-0000015 this portal (primary) 1 7 11 0 + Breast P-0000041 this portal (primary) 1 10 0 0 + Breast P-0000057 this portal (primary) 1 5 0 0 + Breast P-0000058 this portal (primary) 1 1 7 1 + Breast P-0000066 this portal (primary) 1 4 5 0 + Breast P-0000077 this portal (primary) 1 2 8 0 + Breast P-0000081 this portal (primary) 1 6 0 0 + Breast P-0000093 this portal (primary) 1 2 8 0 + Breast P-0000098 this portal (primary) 1 1 0 0 + Breast P-0000102 this portal (primary) 1 4 2 0 + Breast P-0000104 this portal (primary) 1 5 5 0 + Breast P-0000106 this portal (primary) 1 4 7 0 + Breast P-0000107 this portal (primary) 1 4 0 0 + Breast P-0000120 this portal (primary) 1 6 2 0 + Breast P-0000125 this portal (primary) 1 4 0 0 + Breast P-0000126 this portal (primary) 1 5 7 0 + Breast P-0000129 this portal (primary) 1 1 6 0 + Breast P-0000131 this portal (primary) 1 2 5 0 + Breast P-0000138 this portal (primary) 1 33 1 0 + Breast P-0000152 this portal (primary) 1 1 5 0 + Breast P-0000155 this portal (primary) 1 6 0 0 + Breast P-0000158 this portal (primary) 1 2 5 0 + Breast P-0000167 this portal (primary) 1 4 1 0 + Breast P-0000175 this portal (primary) 1 2 0 0 + … 5,343 more rows +P-0000012 (msk_chord_2024); samples: P-0000012-T02-IM3 (Primary), P-0000012-T03-IM3 (Metastasis) +Mutations: 31 rows; the first 25, tab-separated (the web app's view pages and downloads every row, with every column): + cohort samples gene proteinChange annotation mutationType copy freq vaf + Breast P-0000012-T03-IM3 ATRX K983* Likely Oncogenic Nonsense_Mutation 3.3 0.198 + Breast P-0000012-T03-IM3 BLM A363fs Likely Oncogenic Frame_Shift_Del 1.4 0.128 + Breast P-0000012-T03-IM3 FBXW7 G61* Likely Oncogenic · Level 3A Nonsense_Mutation 4.5 0.228 + Breast P-0000012-T03-IM3 FBXW7 X413_splice Likely Oncogenic · Level 3A Splice_Site 4.5 0.255 + Breast P-0000012-T03-IM3 MAP3K1 E302* Likely Oncogenic Nonsense_Mutation 3.1 0.174 + Breast P-0000012-T03-IM3 MAP3K1 X696_splice Likely Oncogenic Splice_Site 3.1 0.201 + Breast P-0000012-T03-IM3 PTPRD E915* Likely Oncogenic Nonsense_Mutation 4.3 0.176 + Breast P-0000012-T03-IM3 PTPRD P1338T Unknown Missense_Mutation 4.3 0.298 + Breast P-0000012-T03-IM3 PTPRT G969V Unknown Missense_Mutation 4.8 0.142 + Breast P-0000012-T03-IM3 PTPRT X1053_splice Likely Oncogenic Splice_Site 4.8 0.051 + Breast P-0000012-T03-IM3 SMARCA4 E1211* Likely Oncogenic · Level 3A Nonsense_Mutation 4.3 0.208 + Breast P-0000012-T02-IM3 TP53 T256P Likely Oncogenic Missense_Mutation 52.4 0.502 + Breast P-0000012-T03-IM3 TP53 P67Qfs*56 Likely Oncogenic Frame_Shift_Del 52.4 0.402 + Breast P-0000012-T03-IM3 ATR R2431M Unknown Missense_Mutation 2.7 0.174 + Breast P-0000012-T03-IM3 AXIN2 I375M Unknown Missense_Mutation 2.1 0.137 + Breast P-0000012-T03-IM3 BRIP1 D393V Unknown Missense_Mutation 1.4 0.146 + Breast P-0000012-T03-IM3 CCNE1 A47V Unknown Missense_Mutation 0.5 0.149 + Breast P-0000012-T03-IM3 CREBBP M2161I Unknown Missense_Mutation 3.4 0.248 + Breast P-0000012-T03-IM3 DOT1L W305C Unknown Missense_Mutation 2.3 0.158 + Breast P-0000012-T03-IM3 FLT4 S293R Unknown Missense_Mutation 2.8 0.179 + Breast P-0000012-T03-IM3 HGF W547Cfs*35 Unknown Frame_Shift_Del 2.2 0.141 + Breast P-0000012-T03-IM3 KDM5A N212I Unknown Missense_Mutation 1.8 0.216 + Breast P-0000012-T03-IM3 KMT2C K3105N Unknown Missense_Mutation 6.5 0.179 + Breast P-0000012-T03-IM3 NSD1 V1780F Unknown Missense_Mutation 2.1 0.194 + Breast P-0000012-T03-IM3 PDGFRA L465M Unknown Missense_Mutation 2.1 0.204 + … 6 more rows +Copy Number Alterations: 3 rows; the first 3, tab-separated (the web app's view pages and downloads every row, with every column): + cohort samples gene cna annotation cytoband freq + Breast P-0000012-T03-IM3 CDK4 AMP Oncogenic · Level 4 12q14.1 1.6 + Breast P-0000012-T02-IM3 MCL1 AMP Oncogenic 1q21.2 1.5 + Breast P-0000012-T02-IM3 RIT1 AMP Unknown 1q22 0.7 +Structural Variants: 0 rows; the first 0, tab-separated (the web app's view pages and downloads every row, with every column): + cohort samples gene1 gene2 class eventInfo breakpointType connectionType + CAVEAT (tell the user): P-0000012 — Mutations: 31 rows; Copy Number Alterations: 3 rows; Structural Variants: 0 rows. Each table lists a variant, a gene's call or an event once however many of the patient's samples carry it (Samples names them); allele frequency and read counts are the highest among those samples. Copy number is the deep calls only (AMP, HOMDEL), as the portal's patient view lists them; Copy # on a mutation is the gene's deep calls anywhere in the patient. Cohort % is the share of the study's samples profiled for the gene by their panel with a mutation in it, or with the same copy-number call. Annotation is OncoKB v7.5 (oncogenicity and its highest sensitivity level); structural variants carry the study's own annotation, not OncoKB's. The patient list: 5,368 patients. Sorted with patients who have any alteration first, then by patient id across the cohort; every page is a slice of that one order, and the download holds every row kept, with every column. + METHOD: + - Count the patients per cohort and study: The alterations:counts query above: every patient of each cohort, with their sample count and how many rows each of the three tables lists for them (a mutation, a gene's deep copy-number call, a structural variant — each counted once however many samples carry it). + Breast · msk_chord_2024: 5,368 + - Sort them together and take one page: The alterations:rows query above: the patients of every cohort and study combined in one query, sorted patients with any alteration first, then by patient id, and the 25 rows of the first page taken. Every other page, and the download, is the same query at another offset. + - Read P-0000012's three tables: The alterations:mutations, alterations:cna and alterations:sv queries above, each paged, searched, filtered and sorted in the database like any table view. Mutations: every called mutation of the patient's samples (uncalled calls left out), one row per variant with the samples carrying it, the highest allele frequency among them (variant / (variant + reference) reads) with that sample's reads, and the gene's deep copy-number calls in the patient (Copy #). Copy-number alterations: the deep calls (AMP, HOMDEL), one row per gene and call. Structural variants: one row per event (both genes and breakpoints, class, event info), the highest read counts among its samples. Cohort % is the share of the study's samples profiled for the gene (by their gene panel) with any mutation in it, or with the same copy-number call; the annotation is the OncoKB v7.5 call for the protein change, or for AMPLIFICATION / DELETION. + Mutations: 31 rows + Copy Number Alterations: 3 rows + Structural Variants: 0 rows + A listing: no statistic is computed, so there is no script — the queries are the numbers. diff --git a/test/snapshots/two-studies-four-views.json b/test/snapshots/two-studies-four-views.json new file mode 100644 index 0000000..12e4b91 --- /dev/null +++ b/test/snapshots/two-studies-four-views.json @@ -0,0 +1,1474 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "TP53 mut": { + "count": 25555, + "text": "OQL[TP53: MUT] — across 2 studies", + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ] + }, + "TP53 wt": { + "count": 24627, + "text": "NOT OQL[TP53:] AND profiled for TP53 MUTATION — across 2 studies", + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ] + } + }, + "views": [ + { + "kind": "compare", + "cohorts": [ + "TP53 mut", + "TP53 wt" + ], + "annotation": "OncoKB v7.5 (pinned)", + "rows": [ + { + "gene": "APC", + "cells": [ + { + "cohort": "TP53 mut", + "profiled": 25555, + "any": 6084, + "driver": 5524, + "anyPct": 23.8, + "driverPct": 21.6, + "byType": { + "mutation": { + "profiled": 25555, + "altered": 5974 + }, + "cna": { + "profiled": 25555, + "altered": 104 + }, + "structuralVariant": { + "profiled": 25555, + "altered": 85 + } + } + }, + { + "cohort": "TP53 wt", + "profiled": 24627, + "any": 2478, + "driver": 2040, + "anyPct": 10.1, + "driverPct": 8.3, + "byType": { + "mutation": { + "profiled": 24627, + "altered": 2383 + }, + "cna": { + "profiled": 24627, + "altered": 84 + }, + "structuralVariant": { + "profiled": 24627, + "altered": 48 + } + } + } + ], + "pAny": 0, + "pDriver": 0, + "qAny": 0, + "qDriver": 0 + }, + { + "gene": "KRAS", + "cells": [ + { + "cohort": "TP53 mut", + "profiled": 25555, + "any": 7678, + "driver": 7622, + "anyPct": 30, + "driverPct": 29.8, + "byType": { + "mutation": { + "profiled": 25555, + "altered": 7315 + }, + "cna": { + "profiled": 25555, + "altered": 508 + }, + "structuralVariant": { + "profiled": 25555, + "altered": 6 + } + } + }, + { + "cohort": "TP53 wt", + "profiled": 24627, + "any": 5345, + "driver": 5299, + "anyPct": 21.7, + "driverPct": 21.5, + "byType": { + "mutation": { + "profiled": 24627, + "altered": 5181 + }, + "cna": { + "profiled": 24627, + "altered": 231 + }, + "structuralVariant": { + "profiled": 24627, + "altered": 2 + } + } + } + ], + "pAny": 3.683367002397097e-101, + "pDriver": 6.541257727317714e-101, + "qAny": 9.208417505992743e-101, + "qDriver": 1.6353144318294285e-100 + }, + { + "gene": "CDKN2A", + "cells": [ + { + "cohort": "TP53 mut", + "profiled": 25555, + "any": 3978, + "driver": 3590, + "anyPct": 15.6, + "driverPct": 14, + "byType": { + "mutation": { + "profiled": 25555, + "altered": 2150 + }, + "cna": { + "profiled": 25555, + "altered": 1774 + }, + "structuralVariant": { + "profiled": 25555, + "altered": 83 + } + } + }, + { + "cohort": "TP53 wt", + "profiled": 24627, + "any": 2401, + "driver": 2207, + "anyPct": 9.7, + "driverPct": 9, + "byType": { + "mutation": { + "profiled": 24627, + "altered": 578 + }, + "cna": { + "profiled": 24627, + "altered": 1759 + }, + "structuralVariant": { + "profiled": 24627, + "altered": 87 + } + } + } + ], + "pAny": 6.348835417681368e-86, + "pDriver": 1.1581233622946001e-71, + "qAny": 1.058139236280228e-85, + "qDriver": 1.9302056038243335e-71 + }, + { + "gene": "PIK3CA", + "cells": [ + { + "cohort": "TP53 mut", + "profiled": 25555, + "any": 3347, + "driver": 3009, + "anyPct": 13.1, + "driverPct": 11.8, + "byType": { + "mutation": { + "profiled": 25555, + "altered": 3077 + }, + "cna": { + "profiled": 25555, + "altered": 354 + }, + "structuralVariant": { + "profiled": 25555, + "altered": 12 + } + } + }, + { + "cohort": "TP53 wt", + "profiled": 24627, + "any": 4218, + "driver": 3951, + "anyPct": 17.1, + "driverPct": 16, + "byType": { + "mutation": { + "profiled": 24627, + "altered": 4168 + }, + "cna": { + "profiled": 24627, + "altered": 76 + }, + "structuralVariant": { + "profiled": 24627, + "altered": 4 + } + } + } + ], + "pAny": 1.6718354038852575e-36, + "pDriver": 1.616742625373624e-43, + "qAny": 2.0897942548565717e-36, + "qDriver": 2.02092828171703e-43 + }, + { + "gene": "EGFR", + "cells": [ + { + "cohort": "TP53 mut", + "profiled": 25555, + "any": 2595, + "driver": 2151, + "anyPct": 10.2, + "driverPct": 8.4, + "byType": { + "mutation": { + "profiled": 25555, + "altered": 2084 + }, + "cna": { + "profiled": 25555, + "altered": 897 + }, + "structuralVariant": { + "profiled": 25555, + "altered": 66 + } + } + }, + { + "cohort": "TP53 wt", + "profiled": 24627, + "any": 1805, + "driver": 1442, + "anyPct": 7.3, + "driverPct": 5.9, + "byType": { + "mutation": { + "profiled": 24627, + "altered": 1667 + }, + "cna": { + "profiled": 24627, + "altered": 215 + }, + "structuralVariant": { + "profiled": 24627, + "altered": 35 + } + } + } + ], + "pAny": 3.4918653939355507e-29, + "pDriver": 6.284452802067991e-29, + "qAny": 3.4918653939355507e-29, + "qDriver": 6.284452802067991e-29 + } + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "msk_met_2021", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ], + "note": "cross-study comparison (msk_chord_2024, msk_met_2021): denominators are per-study panel-aware; patient overlap across studies is NOT deduplicated; counts are POOLED across studies, so the p-value is unstratified — site composition differences can invert a pooled association (Simpson's paradox), and a stratified test (Cochran–Mantel–Haenszel) would be the principled statistic", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count profiled and altered patients per gene", + "detail": "The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105, + "params": [ + [ + "genes", + "5" + ] + ] + }, + { + "kind": "fetch", + "title": "Count profiled and altered patients per gene", + "detail": "The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only.", + "scope": "TP53 mut · msk_met_2021", + "rowsIn": 12450, + "params": [ + [ + "genes", + "5" + ] + ] + }, + { + "kind": "fetch", + "title": "Count profiled and altered patients per gene", + "detail": "The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only.", + "scope": "TP53 wt · msk_chord_2024", + "rowsIn": 11594, + "params": [ + [ + "genes", + "5" + ] + ] + }, + { + "kind": "fetch", + "title": "Count profiled and altered patients per gene", + "detail": "The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only.", + "scope": "TP53 wt · msk_met_2021", + "rowsIn": 13033, + "params": [ + [ + "genes", + "5" + ] + ] + }, + { + "kind": "transform", + "title": "Sum each cohort's counts across its studies", + "detail": "Profiled, altered and driver counts are added study by study, so the denominator stays panel-aware. The test that follows is on the pooled counts, not stratified by study." + }, + { + "kind": "statistic", + "title": "Fisher's exact test per gene", + "detail": "Two-sided, on the 2×2 table of altered vs not altered (profiled − altered) in each cohort — once for any alteration and once for drivers only.", + "params": [ + [ + "genes tested", + "5" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across genes", + "detail": "q-values over the 5 genes tested here, separately for the any-alteration and driver-only families." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg matches statsmodels 0.15.0 multipletests(method=\"fdr_bh\"), to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "compare:APC:p_any": { + "v": 0 + }, + "compare:APC:p_driver": { + "v": 0 + }, + "compare:APC:q_any": { + "v": 0 + }, + "compare:APC:q_driver": { + "v": 0 + }, + "compare:KRAS:p_any": { + "v": 3.683367002397097e-101 + }, + "compare:KRAS:p_driver": { + "v": 6.541257727317714e-101 + }, + "compare:KRAS:q_any": { + "v": 9.208417505992743e-101 + }, + "compare:KRAS:q_driver": { + "v": 1.6353144318294285e-100 + }, + "compare:CDKN2A:p_any": { + "v": 6.348835417681368e-86 + }, + "compare:CDKN2A:p_driver": { + "v": 1.1581233622946001e-71 + }, + "compare:CDKN2A:q_any": { + "v": 1.058139236280228e-85 + }, + "compare:CDKN2A:q_driver": { + "v": 1.9302056038243335e-71 + }, + "compare:PIK3CA:p_any": { + "v": 1.6718354038852575e-36 + }, + "compare:PIK3CA:p_driver": { + "v": 1.616742625373624e-43 + }, + "compare:PIK3CA:q_any": { + "v": 2.0897942548565717e-36 + }, + "compare:PIK3CA:q_driver": { + "v": 2.02092828171703e-43 + }, + "compare:EGFR:p_any": { + "v": 3.4918653939355507e-29 + }, + "compare:EGFR:p_driver": { + "v": 6.284452802067991e-29 + }, + "compare:EGFR:q_any": { + "v": 3.4918653939355507e-29 + }, + "compare:EGFR:q_driver": { + "v": 6.284452802067991e-29 + }, + "compare:KRAS:TP53 mut:profiled": { + "v": 25555, + "abs": 0 + }, + "compare:KRAS:TP53 mut:altered": { + "v": 7678, + "abs": 0 + }, + "compare:KRAS:TP53 mut:driver": { + "v": 7622, + "abs": 0 + }, + "compare:PIK3CA:TP53 mut:profiled": { + "v": 25555, + "abs": 0 + }, + "compare:PIK3CA:TP53 mut:altered": { + "v": 3347, + "abs": 0 + }, + "compare:PIK3CA:TP53 mut:driver": { + "v": 3009, + "abs": 0 + }, + "compare:APC:TP53 mut:profiled": { + "v": 25555, + "abs": 0 + }, + "compare:APC:TP53 mut:altered": { + "v": 6084, + "abs": 0 + }, + "compare:APC:TP53 mut:driver": { + "v": 5524, + "abs": 0 + }, + "compare:EGFR:TP53 mut:profiled": { + "v": 25555, + "abs": 0 + }, + "compare:EGFR:TP53 mut:altered": { + "v": 2595, + "abs": 0 + }, + "compare:EGFR:TP53 mut:driver": { + "v": 2151, + "abs": 0 + }, + "compare:CDKN2A:TP53 mut:profiled": { + "v": 25555, + "abs": 0 + }, + "compare:CDKN2A:TP53 mut:altered": { + "v": 3978, + "abs": 0 + }, + "compare:CDKN2A:TP53 mut:driver": { + "v": 3590, + "abs": 0 + }, + "compare:KRAS:TP53 wt:profiled": { + "v": 24627, + "abs": 0 + }, + "compare:KRAS:TP53 wt:altered": { + "v": 5345, + "abs": 0 + }, + "compare:KRAS:TP53 wt:driver": { + "v": 5299, + "abs": 0 + }, + "compare:PIK3CA:TP53 wt:profiled": { + "v": 24627, + "abs": 0 + }, + "compare:PIK3CA:TP53 wt:altered": { + "v": 4218, + "abs": 0 + }, + "compare:PIK3CA:TP53 wt:driver": { + "v": 3951, + "abs": 0 + }, + "compare:APC:TP53 wt:profiled": { + "v": 24627, + "abs": 0 + }, + "compare:APC:TP53 wt:altered": { + "v": 2478, + "abs": 0 + }, + "compare:APC:TP53 wt:driver": { + "v": 2040, + "abs": 0 + }, + "compare:EGFR:TP53 wt:profiled": { + "v": 24627, + "abs": 0 + }, + "compare:EGFR:TP53 wt:altered": { + "v": 1805, + "abs": 0 + }, + "compare:EGFR:TP53 wt:driver": { + "v": 1442, + "abs": 0 + }, + "compare:CDKN2A:TP53 wt:profiled": { + "v": 24627, + "abs": 0 + }, + "compare:CDKN2A:TP53 wt:altered": { + "v": 2401, + "abs": 0 + }, + "compare:CDKN2A:TP53 wt:driver": { + "v": 2207, + "abs": 0 + } + } + } + }, + { + "kind": "survival", + "cohorts": [ + "TP53 mut", + "TP53 wt" + ], + "curves": [ + { + "cohort": "TP53 mut", + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0, + "s": 0.9982 + }, + { + "t": 0.03, + "s": 0.9981 + }, + { + "t": 0.032876676, + "s": 0.9967 + }, + { + "t": 0.065753353, + "s": 0.9966 + }, + { + "t": 0.07, + "s": 0.9966 + }, + { + "t": 0.098630029, + "s": 0.9965 + }, + { + "t": 0.13, + "s": 0.9964 + }, + { + "t": 0.131506705, + "s": 0.9962 + }, + { + "t": 0.16, + "s": 0.996 + }, + { + "t": 0.164383381, + "s": 0.9957 + }, + { + "t": 0.197260058, + "s": 0.9956 + }, + { + "t": 0.2, + "s": 0.9953 + }, + { + "t": 0.23, + "s": 0.995 + }, + { + "t": 0.230136734, + "s": 0.9947 + }, + { + "t": 0.26, + "s": 0.9944 + }, + { + "t": 0.26301341, + "s": 0.9942 + }, + { + "t": 0.295890087, + "s": 0.9939 + }, + { + "t": 0.3, + "s": 0.9935 + }, + { + "t": 0.328766763, + "s": 0.993 + }, + { + "…": "2979 more", + "sha256": "ffc2d62afcd76b56" + } + ], + "median": 30.64106231, + "n": 25498, + "events": 12607, + "atRisk": [ + 25498, + 24109, + 23357, + 22638, + 21884, + 21187, + 20497, + 19853, + 19250, + 18633, + 17978, + 17317, + 16492, + 15797, + 15094, + 14401, + 13713, + 13063, + 12486, + 11916, + { + "…": "99 more", + "sha256": "65e42ce7c5247805" + } + ], + "missing": 57 + }, + { + "cohort": "TP53 wt", + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0, + "s": 0.9989 + }, + { + "t": 0.03, + "s": 0.9988 + }, + { + "t": 0.032876676, + "s": 0.9982 + }, + { + "t": 0.065753353, + "s": 0.998 + }, + { + "t": 0.07, + "s": 0.9978 + }, + { + "t": 0.098630029, + "s": 0.9977 + }, + { + "t": 0.1, + "s": 0.9976 + }, + { + "t": 0.13, + "s": 0.9975 + }, + { + "t": 0.131506705, + "s": 0.9974 + }, + { + "t": 0.16, + "s": 0.9973 + }, + { + "t": 0.164383381, + "s": 0.9973 + }, + { + "t": 0.197260058, + "s": 0.9972 + }, + { + "t": 0.2, + "s": 0.9971 + }, + { + "t": 0.23, + "s": 0.9969 + }, + { + "t": 0.230136734, + "s": 0.9968 + }, + { + "t": 0.26, + "s": 0.9967 + }, + { + "t": 0.26301341, + "s": 0.9966 + }, + { + "t": 0.295890087, + "s": 0.9964 + }, + { + "t": 0.3, + "s": 0.9961 + }, + { + "…": "3051 more", + "sha256": "28815bef7a1dd109" + } + ], + "median": 68.44924006, + "n": 24570, + "events": 8585, + "atRisk": [ + 24570, + 23454, + 22965, + 22473, + 22046, + 21636, + 21221, + 20770, + 20340, + 19860, + 19420, + 18945, + 18285, + 17677, + 17144, + 16580, + 16020, + 15453, + 14997, + 14522, + { + "…": "96 more", + "sha256": "c627134ccc1ae86f" + } + ], + "missing": 57 + } + ], + "endpoint": "OS", + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "msk_met_2021", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "logrank": { + "chi2": 1594.0863, + "p": 0, + "df": 1, + "observed": [ + 12607, + 8585 + ], + "expected": [ + 9723.3, + 11468.7 + ], + "variance": 5216.6577, + "strata": 2 + }, + "logrankPooled": { + "chi2": 1554.7258, + "p": 0, + "df": 1, + "observed": [ + 12607, + 8585 + ], + "expected": [ + 9754.9, + 11437.1 + ], + "variance": 5232.0787, + "strata": 1 + }, + "caveat": "OS from each study's own baseline (left truncation applies; baselines are NOT harmonized across studies) Status '0:...' treated as censored. The log-rank test is STRATIFIED by study (2 strata contributed events): each study is compared only against itself, so a difference in case mix between studies cannot masquerade as a difference between cohorts. The pooled p is shown alongside — where the two disagree, the stratified one is the honest answer. Every site contributes only (months, event, n) counts; no patient-level survival time crosses an instance boundary.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105, + "rowsOut": 13105, + "params": [ + [ + "count rows", + "4,156" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value.", + "scope": "TP53 mut · msk_met_2021", + "rowsIn": 12450, + "rowsOut": 12393, + "params": [ + [ + "count rows", + "3,164" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value.", + "scope": "TP53 wt · msk_chord_2024", + "rowsIn": 11594, + "rowsOut": 11594, + "params": [ + [ + "count rows", + "4,433" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value.", + "scope": "TP53 wt · msk_met_2021", + "rowsIn": 13033, + "rowsOut": 12976, + "params": [ + [ + "count rows", + "3,444" + ] + ] + }, + { + "kind": "statistic", + "title": "Estimate survival by Kaplan–Meier", + "detail": "The product-limit estimator, one curve per cohort, pooled over its studies. The median is the first time the curve is at or below 0.5.", + "params": [ + [ + "TP53 mut", + "25,498 patients, 12,607 events, median 30.6 months" + ], + [ + "TP53 wt", + "24,570 patients, 8,585 events, median 68.4 months" + ] + ] + }, + { + "kind": "statistic", + "title": "Two-group log-rank test, stratified by study", + "detail": "At each event time, every cohort's observed events against its share of the risk set, with the hypergeometric variance; χ² on 1 df. Each study is its own stratum — compared only against itself — and the strata are summed, so a difference in case mix between studies cannot pass for a difference between cohorts.", + "params": [ + [ + "χ² / df / p", + "1594.0863 / 1 / <1e-300" + ], + [ + "strata with events", + "2" + ], + [ + "pooled, for contrast", + "χ² 1554.7258, p <1e-300" + ] + ] + } + ], + "implementation": { + "functions": [ + "kaplanMeier", + "logRank" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Kaplan–Meier matches lifelines 0.30.3 KaplanMeierFitter (curves are reported to 4 decimals); the log-rank matches statsmodels 0.15.0 survdiff to a relative 1e-6, pooled, stratified, with delayed entry and for k groups (test/survival-golden.test.ts).", + "check": { + "km:TP53 mut:n": { + "v": 25498, + "abs": 0 + }, + "km:TP53 mut:events": { + "v": 12607, + "abs": 0 + }, + "km:TP53 mut:median": { + "v": 30.64106231, + "abs": 1e-9 + }, + "km:TP53 wt:n": { + "v": 24570, + "abs": 0 + }, + "km:TP53 wt:events": { + "v": 8585, + "abs": 0 + }, + "km:TP53 wt:median": { + "v": 68.44924006, + "abs": 1e-9 + }, + "logrank:chi2": { + "v": 1594.0863, + "abs": 0.00005 + }, + "logrank:p": { + "v": 0, + "rel": 0.00001, + "abs": 1e-300 + }, + "logrank:pooled:chi2": { + "v": 1554.7258, + "abs": 0.00005 + }, + "logrank:pooled:p": { + "v": 0, + "rel": 0.00001, + "abs": 1e-300 + } + } + } + }, + { + "kind": "clinical", + "cohorts": [ + "TP53 mut", + "TP53 wt" + ], + "clinical": [ + { + "attribute": "FRACTION_GENOME_ALTERED", + "per": "sample", + "kind": "num", + "q": 0, + "cells": [ + { + "cohort": "TP53 mut", + "n": 25537, + "mean": 0.224, + "sd": 0.198, + "min": 0, + "max": 1, + "median": null, + "q1": null, + "q3": null, + "histogramTruncated": false + }, + { + "cohort": "TP53 wt", + "n": 24565, + "mean": 0.147, + "sd": 0.168, + "min": 0, + "max": 1, + "median": null, + "q1": null, + "q3": null, + "histogramTruncated": false + } + ], + "test": "Welch t", + "statistic": 47.039, + "df": 49327.99, + "p": 0 + }, + { + "attribute": "TMB_NONSYNONYMOUS", + "per": "sample", + "kind": "num", + "q": 1.5375667797084092e-40, + "cells": [ + { + "cohort": "TP53 mut", + "n": 25622, + "mean": 8.693, + "sd": 20.068, + "min": 0, + "max": 654.576457903, + "median": null, + "q1": null, + "q3": null, + "histogramTruncated": false + }, + { + "cohort": "TP53 wt", + "n": 24649, + "mean": 6.555, + "sd": 15.678, + "min": 0, + "max": 549.94798841, + "median": null, + "q1": null, + "q3": null, + "histogramTruncated": false + } + ], + "test": "Welch t", + "statistic": 13.3429, + "df": 48254.11, + "p": 1.5375667797084092e-40 + }, + { + "attribute": "CURRENT_AGE_DEID", + "per": "patient", + "kind": "cat", + "cells": [], + "skipped": "not declared by msk_met_2021" + } + ], + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "msk_met_2021", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "Categorical attributes are compared with a Pearson chi-squared over the full value vocabulary; numeric ones with Welch's unequal-variance t-test (2 cohorts) or Welch's ANOVA (3+) computed from (n, Σx, Σx²) per cohort — those totals are ADDITIVE across sites, so the pooled mean and variance are exact from per-site aggregates and no individual value is ever transmitted. Counting unit follows the attribute: patients for patient-level, samples for sample-level. q-values are Benjamini–Hochberg across the 2 tested attributes. Counts are pooled across 2 studies without harmonizing vocabularies; an attribute the studies type differently is refused rather than merged.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Describe each attribute", + "detail": "The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105 + }, + { + "kind": "fetch", + "title": "Describe each attribute", + "detail": "The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database.", + "scope": "TP53 mut · msk_met_2021", + "rowsIn": 12450 + }, + { + "kind": "fetch", + "title": "Describe each attribute", + "detail": "The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database.", + "scope": "TP53 wt · msk_chord_2024", + "rowsIn": 11594 + }, + { + "kind": "fetch", + "title": "Describe each attribute", + "detail": "The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database.", + "scope": "TP53 wt · msk_met_2021", + "rowsIn": 13033 + }, + { + "kind": "transform", + "title": "Add each cohort's counts and moments across its studies", + "detail": "Value counts, n, Σx and Σx² add exactly. Vocabularies are not harmonized: the same value spelled differently in two studies stays two values. Medians and rank tests need each study's full distribution in one place, so they are not computed for a view that spans studies." + }, + { + "kind": "transform", + "title": "Set aside attributes that cannot be tested", + "detail": "Each is named with its reason rather than dropped.", + "params": [ + [ + "CURRENT_AGE_DEID", + "not declared by msk_met_2021" + ] + ] + }, + { + "kind": "statistic", + "title": "Welch's t-test for each numeric attribute", + "detail": "Unequal-variance t from each cohort's n, mean and variance, with Welch–Satterthwaite degrees of freedom; two-sided. Mean and variance are from the summed moments: variance = (Σx² − (Σx)²/n) / (n − 1).", + "params": [ + [ + "TMB_NONSYNONYMOUS", + "t 13.3429 on 48254.11 df · p 1.54e-40" + ], + [ + "FRACTION_GENOME_ALTERED", + "t 47.039 on 49327.99 df · p <1e-300" + ] + ] + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across attributes", + "detail": "q-values over the 2 tested attributes, from the χ² and Welch p-values together." + } + ], + "implementation": { + "functions": [ + "welchT", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "χ² matches scipy 1.18.1 chi2_contingency; Welch's t scipy ttest_ind(equal_var=False) and Welch's ANOVA statsmodels 0.15.0 anova_generic from the same moments; Mann–Whitney, Kruskal–Wallis and quantiles scipy/numpy on the expanded distribution; Benjamini–Hochberg statsmodels multipletests — all to a relative 1e-6 (test/tables-golden.test.ts, test/moments-golden.test.ts).", + "check": { + "clinical:TMB_NONSYNONYMOUS:p": { + "v": 1.5375667797084092e-40 + }, + "clinical:TMB_NONSYNONYMOUS:q": { + "v": 1.5375667797084092e-40 + }, + "clinical:FRACTION_GENOME_ALTERED:p": { + "v": 0 + }, + "clinical:FRACTION_GENOME_ALTERED:q": { + "v": 0 + } + } + } + }, + { + "kind": "cooccurrence", + "cohorts": [ + "TP53 mut" + ], + "pairs": [ + { + "a": "KRAS", + "b": "APC", + "both": 2253, + "onlyA": 5425, + "onlyB": 3831, + "neither": 14046, + "profiled": 25555, + "log2Odds": 0.607, + "p": 3.781531181941494e-41, + "q": 4.7769702136632874e-36, + "tendency": "co-occurrence", + "pStratified": 7.961617022772145e-37, + "oddsRatioMH": 1.4795, + "strata": 2 + }, + { + "a": "KRAS", + "b": "PIK3CA", + "both": 724, + "onlyA": 6954, + "onlyB": 2623, + "neither": 15254, + "profiled": 25555, + "log2Odds": -0.724, + "p": 1.5284208764989049e-31, + "q": 1.8986041405298755e-29, + "tendency": "mutual exclusivity", + "pStratified": 6.328680468432918e-30, + "oddsRatioMH": 0.6056, + "strata": 2 + }, + { + "a": "PIK3CA", + "b": "APC", + "both": 929, + "onlyA": 2418, + "onlyB": 5155, + "neither": 17053, + "profiled": 25555, + "log2Odds": 0.346, + "p": 1.4753311744155665e-8, + "q": 1.404008613205968e-8, + "tendency": "co-occurrence", + "pStratified": 7.02004306602984e-9, + "oddsRatioMH": 1.2751, + "strata": 2 + }, + { + "a": "TP53", + "b": "KRAS", + "both": 7678, + "onlyA": 17877, + "onlyB": 0, + "neither": 0, + "profiled": 25555, + "log2Odds": -1.219, + "p": 0.9999999999708962, + "q": 1, + "tendency": "mutual exclusivity", + "pStratified": 1, + "oddsRatioMH": null, + "strata": 0 + }, + { + "a": "TP53", + "b": "PIK3CA", + "both": 3347, + "onlyA": 22208, + "onlyB": 0, + "neither": 0, + "profiled": 25555, + "log2Odds": -2.73, + "p": 1, + "q": 1, + "tendency": "mutual exclusivity", + "pStratified": 1, + "oddsRatioMH": null, + "strata": 0 + }, + { + "a": "TP53", + "b": "APC", + "both": 6084, + "onlyA": 19471, + "onlyB": 0, + "neither": 0, + "profiled": 25555, + "log2Odds": -1.678, + "p": 1, + "q": 1, + "tendency": "mutual exclusivity", + "pStratified": 1, + "oddsRatioMH": null, + "strata": 0 + } + ], + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ], + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "msk_met_2021", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "Pairwise co-occurrence within “TP53 mut” (the first cohort in this view; co-occurrence describes one cohort, not a contrast). Denominators are the patients profiled for BOTH genes, computed per study against that study's own panels — a pair is never scored on patients whose panel could not have detected it. With 2 studies the reported test is STRATIFIED by study (Cochran–Mantel–Haenszel): each study contributes a 2×2 and the coordinator combines them, so a pair cannot be manufactured by differing case mix between sites. The pooled Fisher p is shown alongside. q-values are Benjamini–Hochberg across the 6 assessable pairs. Every site returns four counts per pair and nothing else.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count each gene pair's 2×2 table", + "detail": "The pairCounts query above. Of the patients with a sample on a mutation panel covering both genes: how many are altered in both, only the first, only the second, or neither (altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion)). Four counts per pair, nothing else.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105, + "params": [ + [ + "pairs", + "6" + ] + ] + }, + { + "kind": "fetch", + "title": "Count each gene pair's 2×2 table", + "detail": "The pairCounts query above. Of the patients with a sample on a mutation panel covering both genes: how many are altered in both, only the first, only the second, or neither (altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion)). Four counts per pair, nothing else.", + "scope": "TP53 mut · msk_met_2021", + "rowsIn": 12450, + "params": [ + [ + "pairs", + "6" + ] + ] + }, + { + "kind": "statistic", + "title": "Log₂ odds ratio per pair", + "detail": "log₂((both · neither) / (only first · only second)) on the counts summed across studies, with 0.5 added to every cell when any cell is 0. The direction reported (co-occurrence vs mutual exclusivity) follows the Mantel–Haenszel odds ratio below." + }, + { + "kind": "statistic", + "title": "Cochran–Mantel–Haenszel test, stratified by study", + "detail": "Each study's 2×2 is a stratum (one with an empty margin says nothing and is dropped); the test of a common odds ratio of 1, with the 0.5 continuity correction applied when |Σa − ΣE[a]| ≥ 0.5 (as R's mantelhaen.test), on 1 df. This p is the one corrected and ranked; the two-sided Fisher p on the pooled counts is reported alongside." + }, + { + "kind": "statistic", + "title": "Benjamini–Hochberg across pairs", + "detail": "q-values over the 6 assessable pairs, from the stratified p-values." + } + ], + "implementation": { + "functions": [ + "fisherExact", + "cochranMantelHaenszel", + "log2OddsRatio", + "benjaminiHochberg" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Fisher's exact test matches scipy 1.18.1 fisher_exact, the CMH test and Mantel–Haenszel odds ratio statsmodels 0.15.0 StratifiedTable and Benjamini–Hochberg statsmodels 0.15.0 multipletests(method=\"fdr_bh\"), to a relative 1e-6 (test/tables-golden.test.ts).", + "check": { + "cooccurrence:KRAS/APC:p": { + "v": 3.781531181941494e-41 + }, + "cooccurrence:KRAS/APC:q": { + "v": 4.7769702136632874e-36 + }, + "cooccurrence:KRAS/APC:p_cmh": { + "v": 7.961617022772145e-37 + }, + "cooccurrence:KRAS/PIK3CA:p": { + "v": 1.5284208764989049e-31 + }, + "cooccurrence:KRAS/PIK3CA:q": { + "v": 1.8986041405298755e-29 + }, + "cooccurrence:KRAS/PIK3CA:p_cmh": { + "v": 6.328680468432918e-30 + }, + "cooccurrence:PIK3CA/APC:p": { + "v": 1.4753311744155665e-8 + }, + "cooccurrence:PIK3CA/APC:q": { + "v": 1.404008613205968e-8 + }, + "cooccurrence:PIK3CA/APC:p_cmh": { + "v": 7.02004306602984e-9 + }, + "cooccurrence:TP53/KRAS:p": { + "v": 0.9999999999708962 + }, + "cooccurrence:TP53/KRAS:q": { + "v": 1 + }, + "cooccurrence:TP53/KRAS:p_cmh": { + "v": 1 + }, + "cooccurrence:TP53/PIK3CA:p": { + "v": 1 + }, + "cooccurrence:TP53/PIK3CA:q": { + "v": 1 + }, + "cooccurrence:TP53/PIK3CA:p_cmh": { + "v": 1 + }, + "cooccurrence:TP53/APC:p": { + "v": 1 + }, + "cooccurrence:TP53/APC:q": { + "v": 1 + }, + "cooccurrence:TP53/APC:p_cmh": { + "v": 1 + } + } + } + } + ] +} diff --git a/test/snapshots/two-studies-four-views.sql b/test/snapshots/two-studies-four-views.sql new file mode 100644 index 0000000..739ceb4 --- /dev/null +++ b/test/snapshots/two-studies-four-views.sql @@ -0,0 +1,553 @@ +-- cohort TP53 mut +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- msk_met_2021 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort TP53 wt +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))) + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- msk_met_2021 +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_met_2021') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))) + +-- view 0 compare: geneCounts · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene + +-- view 0 compare: geneCounts · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene + +-- view 0 compare: geneCounts · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene + +-- view 0 compare: geneCounts · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_met_2021') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +altered AS ( + SELECT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid, g.variant_type AS vtype, + max(ann.is_driver) AS is_driver + FROM snapshot_db.genomic_event_derived g + LEFT JOIN oncokb_annotation.variant_annotation ann + ON ann.oncokb_version = 'v7.5' AND ann.is_driver + AND ann.hugo_gene_symbol = g.hugo_gene_symbol + AND ((g.variant_type = 'mutation' AND ann.alteration_type = 'MUTATION' AND ann.alteration = g.mutation_variant) + OR (g.variant_type = 'cna' AND ann.alteration_type = 'CNA' AND ann.alteration = if(g.cna_alteration >= 2, 'AMPLIFICATION', 'DELETION')) + OR (g.variant_type = 'structural_variant' AND ann.alteration_type = 'SV' AND ann.alteration = 'Fusion')) + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) + GROUP BY gene, pid, vtype +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid, + multiIf(sp.alteration_type = 'MUTATION_EXTENDED', 'mutation', + sp.alteration_type = 'COPY_NUMBER_ALTERATION', 'cna', 'structural_variant') AS vtype + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('KRAS','PIK3CA','APC','EGFR','CDKN2A') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' + AND sp.alteration_type IN ('MUTATION_EXTENDED','COPY_NUMBER_ALTERATION','STRUCTURAL_VARIANT') + AND replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) +), +raw AS ( + SELECT gene, pid, vtype, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM ( + SELECT gene, pid, vtype, 1 AS is_alt, is_driver > 0 AS is_drv FROM altered + UNION ALL + SELECT gene, pid, vtype, 0 AS is_alt, 0 AS is_drv FROM covered + ) + GROUP BY gene, pid, vtype +), +perPatient AS ( + SELECT gene, pid, max(is_alt) AS is_alt, max(is_drv) AS is_drv + FROM raw GROUP BY gene, pid +) +SELECT gene, vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM raw GROUP BY gene, vtype +UNION ALL +SELECT gene, 'any' AS vtype, + uniqExact(pid) AS profiled, uniqExactIf(pid, is_alt = 1) AS altered, uniqExactIf(pid, is_drv = 1) AS driver +FROM perPatient GROUP BY gene + +-- view 1 survival: survivalCounts:OS · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 1 survival: survivalCounts:OS · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 1 survival: survivalCounts:OS · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_met_2021' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 1 survival: survivalCounts:OS · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_met_2021') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_met_2021' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 2 clinical: clinicalMoments · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))) +SELECT a, per, count() AS n, sum(x) AS sx, sum(x * x) AS sxx, min(x) AS mn, max(x) AS mx +FROM ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' + AND attribute_name IN ('CURRENT_AGE_DEID','TMB_NONSYNONYMOUS','FRACTION_GENOME_ALTERED') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +) +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per + +-- view 2 clinical: clinicalMoments · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))) +SELECT a, per, count() AS n, sum(x) AS sx, sum(x * x) AS sxx, min(x) AS mn, max(x) AS mx +FROM ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' + AND attribute_name IN ('CURRENT_AGE_DEID','TMB_NONSYNONYMOUS','FRACTION_GENOME_ALTERED') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +) +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per + +-- view 2 clinical: clinicalMoments · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))) +SELECT a, per, count() AS n, sum(x) AS sx, sum(x * x) AS sxx, min(x) AS mn, max(x) AS mx +FROM ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_met_2021' + AND attribute_name IN ('TMB_NONSYNONYMOUS','FRACTION_GENOME_ALTERED') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) +) +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per + +-- view 2 clinical: clinicalMoments · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_met_2021') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))) +SELECT a, per, count() AS n, sum(x) AS sx, sum(x * x) AS sxx, min(x) AS mn, max(x) AS mx +FROM ( + SELECT attribute_name AS a, type AS per, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS x + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_met_2021' + AND attribute_name IN ('TMB_NONSYNONYMOUS','FRACTION_GENOME_ALTERED') + AND attribute_value != '' + AND replaceOne(patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) +) +WHERE x IS NOT NULL AND isFinite(x) +GROUP BY a, per + +-- view 3 cooccurrence: pairCounts · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +altered AS ( + SELECT DISTINCT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol IN ('TP53','KRAS','PIK3CA','APC') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('TP53','KRAS','PIK3CA','APC') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) +), +pp AS ( + SELECT pid, + groupUniqArrayIf(gene, k = 1) AS alt, + groupUniqArrayIf(gene, k = 0) AS cov + FROM (SELECT gene, pid, 1 AS k FROM altered UNION ALL SELECT gene, pid, 0 AS k FROM covered) + GROUP BY pid +) +SELECT ga, gb, + countIf(has(cov, ga) AND has(cov, gb)) AS profiled, + countIf(has(cov, ga) AND has(cov, gb) AND has(alt, ga) AND has(alt, gb)) AS both, + countIf(has(cov, ga) AND has(cov, gb) AND has(alt, ga) AND NOT has(alt, gb)) AS only_a, + countIf(has(cov, ga) AND has(cov, gb) AND NOT has(alt, ga) AND has(alt, gb)) AS only_b +FROM pp +ARRAY JOIN ['TP53','TP53','TP53','KRAS','KRAS','PIK3CA'] AS ga, ['KRAS','PIK3CA','APC','PIK3CA','APC','APC'] AS gb +GROUP BY ga, gb + +-- view 3 cooccurrence: pairCounts · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +altered AS ( + SELECT DISTINCT g.hugo_gene_symbol AS gene, replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol IN ('TP53','KRAS','PIK3CA','APC') AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2) + AND replaceOne(g.patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) +), +covered AS ( + SELECT DISTINCT pg.gene AS gene, replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.gene_panel_to_gene_derived pg ON pg.gene_panel_id = sp.gene_panel_id AND pg.gene IN ('TP53','KRAS','PIK3CA','APC') + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) +), +pp AS ( + SELECT pid, + groupUniqArrayIf(gene, k = 1) AS alt, + groupUniqArrayIf(gene, k = 0) AS cov + FROM (SELECT gene, pid, 1 AS k FROM altered UNION ALL SELECT gene, pid, 0 AS k FROM covered) + GROUP BY pid +) +SELECT ga, gb, + countIf(has(cov, ga) AND has(cov, gb)) AS profiled, + countIf(has(cov, ga) AND has(cov, gb) AND has(alt, ga) AND has(alt, gb)) AS both, + countIf(has(cov, ga) AND has(cov, gb) AND has(alt, ga) AND NOT has(alt, gb)) AS only_a, + countIf(has(cov, ga) AND has(cov, gb) AND NOT has(alt, ga) AND has(alt, gb)) AS only_b +FROM pp +ARRAY JOIN ['TP53','TP53','TP53','KRAS','KRAS','PIK3CA'] AS ga, ['KRAS','PIK3CA','APC','PIK3CA','APC','APC'] AS gb +GROUP BY ga, gb diff --git a/test/snapshots/two-studies-four-views.svg b/test/snapshots/two-studies-four-views.svg new file mode 100644 index 0000000..f99beb2 --- /dev/null +++ b/test/snapshots/two-studies-four-views.svg @@ -0,0 +1,8 @@ + +Altered %, by cohort — TP53 mut, TP53 wtAltered %, by cohortTP53 mutTP53 wtAPCq < 1e-300TP53 mut — APC: 23.8% (6,084 of 25,555 profiled)23.8%TP53 wt — APC: 10.1% (2,478 of 24,627 profiled)10.1%KRASq = 9.2e-101TP53 mut — KRAS: 30.0% (7,678 of 25,555 profiled)30.0%TP53 wt — KRAS: 21.7% (5,345 of 24,627 profiled)21.7%CDKN2Aq = 1.1e-85TP53 mut — CDKN2A: 15.6% (3,978 of 25,555 profiled)15.6%TP53 wt — CDKN2A: 9.7% (2,401 of 24,627 profiled)9.7%0%5%10%15%20%25%30%altered, % of profiledPIK3CAq = 2.1e-36TP53 mut — PIK3CA: 13.1% (3,347 of 25,555 profiled)13.1%TP53 wt — PIK3CA: 17.1% (4,218 of 24,627 profiled)17.1%EGFRq = 3.5e-29TP53 mut — EGFR: 10.2% (2,595 of 25,555 profiled)10.2%TP53 wt — EGFR: 7.3% (1,805 of 24,627 profiled)7.3%0%5%10%15%20%25%30%altered, % of profiledcross-study comparison (msk_chord_2024, msk_met_2021): denominators are per-study panel-aware; patient overlap across studies is NOT deduplicated;counts are POOLED across studies, so the p-value is unstratified — site composition differences can invert a pooled association (Simpson's paradox), and astratified test (Cochran–Mantel–Haenszel) would be the principled statistic. The q under each gene compares its altered share across the cohorts. + +Kaplan–Meier — TP53 mut, TP53 wt0%25%50%75%100%Survival probability024487296MonthsNumber at riskTP53 mutTP53 mut: 25,498 at risk at 0 months25,498TP53 mut: 9,604 at risk at 24 months9,604TP53 mut: 3,615 at risk at 48 months3,615TP53 mut: 977 at risk at 72 months977TP53 mut: 129 at risk at 96 months129TP53 wtTP53 wt: 24,570 at risk at 0 months24,570TP53 wt: 12,411 at risk at 24 months12,411TP53 wt: 5,548 at risk at 48 months5,548TP53 wt: 1,687 at risk at 72 months1,687TP53 wt: 240 at risk at 96 months240TP53 mutmedian 30.6 mo · n = 25,498 · 12,607 eventsTP53 wtmedian 68.4 mo · n = 24,570 · 8,585 eventslog-rank χ² = 1,594 (1 df) · p < 1e-300 · stratified by study, 2 strata · pooled p < 1e-300OS from each study's own baseline (left truncation applies; baselines are NOT harmonized across studies) Status '0:...' treated as censored. The log-rank testis STRATIFIED by study (2 strata contributed events): each study is compared only against itself, so a difference in case mix between studies cannotmasquerade as a difference between cohorts. The pooled p is shown alongside — where the two disagree, the stratified one is the honest answer. Every sitecontributes only (months, event, n) counts; no patient-level survival time crosses an instance boundary. + +Clinical comparison — −log₁₀ qClinical comparison — −log₁₀ qq < 0.05not significantFRACTION_GENOME_ALTEREDWelch t · q < 1e-300TMB_NONSYNONYMOUSWelch t · q = 1.5e-40CURRENT_AGE_DEIDnot tested: not declared by msk_met_2021q = 0.0501020304050−log₁₀ q (Benjamini–Hochberg) — longer is stronger evidence of a difference−log₁₀ q (Benjamini–Hochberg) — longer is stronger evidence of…Categorical attributes are compared with a Pearson chi-squared over the full value vocabulary; numeric ones with Welch's unequal-variance t-test (2cohorts) or Welch's ANOVA (3+) computed from (n, Σx, Σx²) per cohort — those totals are ADDITIVE across sites, so the pooled mean and variance are exactfrom per-site aggregates and no individual value is ever transmitted. Counting unit follows the attribute: patients for patient-level, samples for sample-level.q-values are Benjamini–Hochberg across the 2 tested attributes. Counts are pooled across 2 studies without harmonizing vocabularies; an attribute thestudies type differently is refused rather than merged. 1 bar runs past the axis and ends in an arrow; the number beside it is exact. + +Co-occurrence — log₂ odds ratioCo-occurrence — log₂ odds ratioco-occur, q < 0.05mutually exclusive, q < 0.05not significantKRAS / APCKRAS / APC: both 2,253, KRAS only 5,425, APC only 3,831, neither 14,046 · stratified p = 8e-370.565 · q = 4.8e-36KRAS / PIK3CAKRAS / PIK3CA: both 724, KRAS only 6,954, PIK3CA only 2,623, neither 15,254 · stratified p = 6.3e-30−0.724 · q = 1.9e-29PIK3CA / APCPIK3CA / APC: both 929, PIK3CA only 2,418, APC only 5,155, neither 17,053 · stratified p = 7e-90.351 · q = 1.4e-8TP53 / KRASTP53 / KRAS: both 7,678, TP53 only 17,877, KRAS only 0, neither 0 · stratified p = 1.00−1.22 · q = 1.00TP53 / PIK3CATP53 / PIK3CA: both 3,347, TP53 only 22,208, PIK3CA only 0, neither 0 · stratified p = 1.00−2.73 · q = 1.00TP53 / APCTP53 / APC: both 6,084, TP53 only 19,471, APC only 0, neither 0 · stratified p = 1.00−1.68 · q = 1.00−3−2−10123log₂ odds ratio — left: mutually exclusive, right: co-occurringPairwise co-occurrence within “TP53 mut” (the first cohort in this view; co-occurrence describes one cohort, not a contrast). Denominators are the patientsprofiled for BOTH genes, computed per study against that study's own panels — a pair is never scored on patients whose panel could not have detected it.With 2 studies the reported test is STRATIFIED by study (Cochran–Mantel–Haenszel): each study contributes a 2×2 and the coordinator combines them, so apair cannot be manufactured by differing case mix between sites. The pooled Fisher p is shown alongside. q-values are Benjamini–Hochberg across the 6assessable pairs. Every site returns four counts per pair and nothing else. diff --git a/test/snapshots/two-studies-four-views.txt b/test/snapshots/two-studies-four-views.txt new file mode 100644 index 0000000..3834cb9 --- /dev/null +++ b/test/snapshots/two-studies-four-views.txt @@ -0,0 +1,87 @@ +Analysis over msk_chord_2024 + msk_met_2021 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- TP53 mut: 25,555 patients — OQL[TP53: MUT] — across 2 studies +- TP53 wt: 24,627 patients — NOT OQL[TP53:] AND profiled for TP53 MUTATION — across 2 studies + +Compare (driver%/any%, panel-aware denominators; annotation OncoKB v7.5 (pinned)): + APC: TP53 mut 21.6%/23.8% | TP53 wt 8.3%/10.1% p=0.0e+0 + KRAS: TP53 mut 29.8%/30% | TP53 wt 21.5%/21.7% p=3.7e-101 + CDKN2A: TP53 mut 14%/15.6% | TP53 wt 9%/9.7% p=6.3e-86 + PIK3CA: TP53 mut 11.8%/13.1% | TP53 wt 16%/17.1% p=1.7e-36 + EGFR: TP53 mut 8.4%/10.2% | TP53 wt 5.9%/7.3% p=3.5e-29 + cross-study comparison (msk_chord_2024, msk_met_2021): denominators are per-study panel-aware; patient overlap across studies is NOT deduplicated; counts are POOLED across studies, so the p-value is unstratified — site composition differences can invert a pooled association (Simpson's paradox), and a stratified test (Cochran–Mantel–Haenszel) would be the principled statistic + METHOD: + - Count profiled and altered patients per gene [TP53 mut · msk_chord_2024]: The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only. + genes: 5 + - Count profiled and altered patients per gene [TP53 mut · msk_met_2021]: The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only. + genes: 5 + - Count profiled and altered patients per gene [TP53 wt · msk_chord_2024]: The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only. + genes: 5 + - Count profiled and altered patients per gene [TP53 wt · msk_met_2021]: The geneCounts query above. Per gene: patients with a sample on a gene panel that covers the gene (profiled — the denominator, so a gene a panel omits is not counted as wild-type), altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion), and driver: an alteration OncoKB calls oncogenic, from the OncoKB release pinned for this run (v7.5). Counts only. + genes: 5 + - Sum each cohort's counts across its studies: Profiled, altered and driver counts are added study by study, so the denominator stays panel-aware. The test that follows is on the pooled counts, not stratified by study. + - Fisher's exact test per gene: Two-sided, on the 2×2 table of altered vs not altered (profiled − altered) in each cohort — once for any alteration and once for drivers only. + genes tested: 5 + - Benjamini–Hochberg across genes: q-values over the 5 genes tested here, separately for the any-alteration and driver-only families. + Fisher's exact test matches scipy 1.18.1 fisher_exact and Benjamini–Hochberg matches statsmodels 0.15.0 multipletests(method="fdr_bh"), to a relative 1e-6 (test/tables-golden.test.ts). + +Survival (KM, OS): + TP53 mut: median 30.6mo (n=25498, 12607 events, 57 missing OS) + TP53 wt: median 68.4mo (n=24570, 8585 events, 57 missing OS) + log-rank p=<1e-300 (stratified by study) +CAVEAT (tell the user): OS from each study's own baseline (left truncation applies; baselines are NOT harmonized across studies) Status '0:...' treated as censored. The log-rank test is STRATIFIED by study (2 strata contributed events): each study is compared only against itself, so a difference in case mix between studies cannot masquerade as a difference between cohorts. The pooled p is shown alongside — where the two disagree, the stratified one is the honest answer. Every site contributes only (months, event, n) counts; no patient-level survival time crosses an instance boundary. + METHOD: + - Count patients by time and status [TP53 mut · msk_chord_2024] (13,105 → 13,105 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value. + count rows: 4,156 + - Count patients by time and status [TP53 mut · msk_met_2021] (12,450 → 12,393 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value. + count rows: 3,164 + - Count patients by time and status [TP53 wt · msk_chord_2024] (11,594 → 11,594 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value. + count rows: 4,433 + - Count patients by time and status [TP53 wt · msk_met_2021] (13,033 → 12,976 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value. + count rows: 3,444 + - Estimate survival by Kaplan–Meier: The product-limit estimator, one curve per cohort, pooled over its studies. The median is the first time the curve is at or below 0.5. + TP53 mut: 25,498 patients, 12,607 events, median 30.6 months + TP53 wt: 24,570 patients, 8,585 events, median 68.4 months + - Two-group log-rank test, stratified by study: At each event time, every cohort's observed events against its share of the risk set, with the hypergeometric variance; χ² on 1 df. Each study is its own stratum — compared only against itself — and the strata are summed, so a difference in case mix between studies cannot pass for a difference between cohorts. + χ² / df / p: 1594.0863 / 1 / <1e-300 + strata with events: 2 + pooled, for contrast: χ² 1554.7258, p <1e-300 + Kaplan–Meier matches lifelines 0.30.3 KaplanMeierFitter (curves are reported to 4 decimals); the log-rank matches statsmodels 0.15.0 survdiff to a relative 1e-6, pooled, stratified, with delayed entry and for k groups (test/survival-golden.test.ts). + +Clinical comparison across cohorts: + FRACTION_GENOME_ALTERED [sample, num]: TP53 mut mean 0.22 sd 0.20 (n=25,537) | TP53 wt mean 0.15 sd 0.17 (n=24,565) Welch t p=<1e-300 q=<1e-300 + TMB_NONSYNONYMOUS [sample, num]: TP53 mut mean 8.69 sd 20.07 (n=25,622) | TP53 wt mean 6.55 sd 15.68 (n=24,649) Welch t p=1.5e-40 q=1.5e-40 + CURRENT_AGE_DEID [patient, cat]: SKIPPED: not declared by msk_met_2021 + Categorical attributes are compared with a Pearson chi-squared over the full value vocabulary; numeric ones with Welch's unequal-variance t-test (2 cohorts) or Welch's ANOVA (3+) computed from (n, Σx, Σx²) per cohort — those totals are ADDITIVE across sites, so the pooled mean and variance are exact from per-site aggregates and no individual value is ever transmitted. Counting unit follows the attribute: patients for patient-level, samples for sample-level. q-values are Benjamini–Hochberg across the 2 tested attributes. Counts are pooled across 2 studies without harmonizing vocabularies; an attribute the studies type differently is refused rather than merged. + METHOD: + - Describe each attribute [TP53 mut · msk_chord_2024]: The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database. + - Describe each attribute [TP53 mut · msk_met_2021]: The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database. + - Describe each attribute [TP53 wt · msk_chord_2024]: The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database. + - Describe each attribute [TP53 wt · msk_met_2021]: The attributeStats query above. A categorical attribute comes back as a count per value; a numeric one as n, Σx and Σx² (from which the mean and variance are exact, and which add across studies). Patients for a patient-level attribute, samples for a sample-level one. No individual value leaves the database. + - Add each cohort's counts and moments across its studies: Value counts, n, Σx and Σx² add exactly. Vocabularies are not harmonized: the same value spelled differently in two studies stays two values. Medians and rank tests need each study's full distribution in one place, so they are not computed for a view that spans studies. + - Set aside attributes that cannot be tested: Each is named with its reason rather than dropped. + CURRENT_AGE_DEID: not declared by msk_met_2021 + - Welch's t-test for each numeric attribute: Unequal-variance t from each cohort's n, mean and variance, with Welch–Satterthwaite degrees of freedom; two-sided. Mean and variance are from the summed moments: variance = (Σx² − (Σx)²/n) / (n − 1). + TMB_NONSYNONYMOUS: t 13.3429 on 48254.11 df · p 1.54e-40 + FRACTION_GENOME_ALTERED: t 47.039 on 49327.99 df · p <1e-300 + - Benjamini–Hochberg across attributes: q-values over the 2 tested attributes, from the χ² and Welch p-values together. + χ² matches scipy 1.18.1 chi2_contingency; Welch's t scipy ttest_ind(equal_var=False) and Welch's ANOVA statsmodels 0.15.0 anova_generic from the same moments; Mann–Whitney, Kruskal–Wallis and quantiles scipy/numpy on the expanded distribution; Benjamini–Hochberg statsmodels multipletests — all to a relative 1e-6 (test/tables-golden.test.ts, test/moments-golden.test.ts). + +Co-occurrence (2x2 per pair, among patients profiled for BOTH genes): + KRAS/APC: both 2,253, KRAS only 5,425, APC only 3,831, neither 14,046 (of 25,555 profiled) log2OR=0.61 (co-occur) p=3.8e-41 q=4.8e-36 stratified p=8.0e-37 + KRAS/PIK3CA: both 724, KRAS only 6,954, PIK3CA only 2,623, neither 15,254 (of 25,555 profiled) log2OR=-0.72 (mutually exclusive) p=1.5e-31 q=1.9e-29 stratified p=6.3e-30 + PIK3CA/APC: both 929, PIK3CA only 2,418, APC only 5,155, neither 17,053 (of 25,555 profiled) log2OR=0.35 (co-occur) p=1.5e-8 q=1.4e-8 stratified p=7.0e-9 + TP53/KRAS: both 7,678, TP53 only 17,877, KRAS only 0, neither 0 (of 25,555 profiled) log2OR=-1.22 (mutually exclusive) p=1.0000 q=1.0000 stratified p=1.0000 + TP53/PIK3CA: both 3,347, TP53 only 22,208, PIK3CA only 0, neither 0 (of 25,555 profiled) log2OR=-2.73 (mutually exclusive) p=1.0000 q=1.0000 stratified p=1.0000 + TP53/APC: both 6,084, TP53 only 19,471, APC only 0, neither 0 (of 25,555 profiled) log2OR=-1.68 (mutually exclusive) p=1.0000 q=1.0000 stratified p=1.0000 + Pairwise co-occurrence within “TP53 mut” (the first cohort in this view; co-occurrence describes one cohort, not a contrast). Denominators are the patients profiled for BOTH genes, computed per study against that study's own panels — a pair is never scored on patients whose panel could not have detected it. With 2 studies the reported test is STRATIFIED by study (Cochran–Mantel–Haenszel): each study contributes a 2×2 and the coordinator combines them, so a pair cannot be manufactured by differing case mix between sites. The pooled Fisher p is shown alongside. q-values are Benjamini–Hochberg across the 6 assessable pairs. Every site returns four counts per pair and nothing else. + METHOD: + - Count each gene pair's 2×2 table [TP53 mut · msk_chord_2024]: The pairCounts query above. Of the patients with a sample on a mutation panel covering both genes: how many are altered in both, only the first, only the second, or neither (altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion)). Four counts per pair, nothing else. + pairs: 6 + - Count each gene pair's 2×2 table [TP53 mut · msk_met_2021]: The pairCounts query above. Of the patients with a sample on a mutation panel covering both genes: how many are altered in both, only the first, only the second, or neither (altered: any mutation or structural variant, or a copy-number change of ±2 (amplification or deep deletion)). Four counts per pair, nothing else. + pairs: 6 + - Log₂ odds ratio per pair: log₂((both · neither) / (only first · only second)) on the counts summed across studies, with 0.5 added to every cell when any cell is 0. The direction reported (co-occurrence vs mutual exclusivity) follows the Mantel–Haenszel odds ratio below. + - Cochran–Mantel–Haenszel test, stratified by study: Each study's 2×2 is a stratum (one with an empty margin says nothing and is dropped); the test of a common odds ratio of 1, with the 0.5 continuity correction applied when |Σa − ΣE[a]| ≥ 0.5 (as R's mantelhaen.test), on 1 df. This p is the one corrected and ranked; the two-sided Fisher p on the pooled counts is reported alongside. + - Benjamini–Hochberg across pairs: q-values over the 6 assessable pairs, from the stratified p-values. + Fisher's exact test matches scipy 1.18.1 fisher_exact, the CMH test and Mantel–Haenszel odds ratio statsmodels 0.15.0 StratifiedTable and Benjamini–Hochberg statsmodels 0.15.0 multipletests(method="fdr_bh"), to a relative 1e-6 (test/tables-golden.test.ts). diff --git a/test/snapshots/two-studies-plot.json b/test/snapshots/two-studies-plot.json new file mode 100644 index 0000000..61434bb --- /dev/null +++ b/test/snapshots/two-studies-plot.json @@ -0,0 +1,873 @@ +{ + "study": "luad_tcga_pan_can_atlas_2018", + "cohorts": { + "Lung (TCGA)": { + "count": 1053, + "text": "all patients in the study — across 2 studies", + "studies": [ + "luad_tcga_pan_can_atlas_2018", + "lusc_tcga_pan_can_atlas_2018" + ] + }, + "KRAS mut": { + "count": 175, + "text": "OQL[KRAS: MUT] — across 2 studies", + "studies": [ + "luad_tcga_pan_can_atlas_2018", + "lusc_tcga_pan_can_atlas_2018" + ] + }, + "TP53 mut": { + "count": 699, + "text": "OQL[TP53: MUT] — across 2 studies", + "studies": [ + "luad_tcga_pan_can_atlas_2018", + "lusc_tcga_pan_can_atlas_2018" + ] + } + }, + "views": [ + { + "kind": "plot", + "plot": { + "shape": "scatter", + "n": 968, + "x": { + "label": "AGE", + "kind": "num" + }, + "y": { + "label": "TMB_NONSYNONYMOUS", + "kind": "num" + }, + "extent": { + "x0": 33, + "x1": 90, + "y0": 0, + "y1": 67.2 + }, + "grid": [ + 240, + 160 + ], + "bins": [ + { + "bx": 37, + "by": 11, + "n": 1 + }, + { + "bx": 181, + "by": 8, + "n": 1 + }, + { + "bx": 105, + "by": 31, + "n": 1 + }, + { + "bx": 134, + "by": 14, + "n": 2 + }, + { + "bx": 134, + "by": 29, + "n": 1 + }, + { + "bx": 113, + "by": 19, + "n": 3 + }, + { + "bx": 227, + "by": 15, + "n": 1 + }, + { + "bx": 202, + "by": 26, + "n": 1 + }, + { + "bx": 138, + "by": 8, + "n": 1 + }, + { + "bx": 164, + "by": 27, + "n": 2 + }, + { + "bx": 122, + "by": 0, + "n": 3 + }, + { + "bx": 164, + "by": 8, + "n": 1 + }, + { + "bx": 168, + "by": 14, + "n": 4 + }, + { + "bx": 71, + "by": 31, + "n": 1 + }, + { + "bx": 176, + "by": 2, + "n": 1 + }, + { + "bx": 155, + "by": 8, + "n": 2 + }, + { + "bx": 155, + "by": 14, + "n": 1 + }, + { + "bx": 75, + "by": 31, + "n": 1 + }, + { + "bx": 151, + "by": 8, + "n": 2 + }, + { + "bx": 143, + "by": 4, + "n": 1 + }, + { + "…": "707 more", + "sha256": "b764315ea2e5f343" + } + ], + "stats": { + "pearson": -0.1312, + "spearman": null, + "slope": -0.12815725764648467, + "intercept": 18.373049900699872, + "pPearson": 0.000042245416729427556, + "pSpearman": null + }, + "note": "2 studies pooled (luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Each site reports six sums (n, Σx, Σy, Σxy, Σx², Σy²), exact and additive, for Pearson's r and the regression line; the bin grid uses one shared scale (each site's own extent, pooled) so cells sum correctly. Spearman rank correlation is not reported for a federated plot: it needs the pooled GLOBAL ranking, which per-site aggregates cannot reconstruct exactly.", + "coverage": { + "total": 1053, + "nx": 971, + "ny": 1050, + "multi": 0 + }, + "layers": [ + { + "kind": "cohort", + "label": "KRAS mut", + "color": "#D55E00", + "name": "KRAS mut", + "patients": 175, + "inPlot": 175, + "n": 158, + "shown": "points", + "points": [ + { + "id": "TCGA-MP-A4T7", + "x": 75, + "y": 4.166666667 + }, + { + "id": "TCGA-91-6836", + "x": 52, + "y": 15.33333333 + }, + { + "id": "TCGA-69-8253", + "x": 59, + "y": 4.366666667 + }, + { + "id": "TCGA-64-5778", + "x": 60, + "y": 14.26666667 + }, + { + "id": "TCGA-95-A4VP", + "x": 66, + "y": 3.766666667 + }, + { + "id": "TCGA-99-8032", + "x": 61, + "y": 12.26666667 + }, + { + "id": "TCGA-78-7145", + "x": 52, + "y": 6.266666667 + }, + { + "id": "TCGA-05-4417", + "x": 51, + "y": 9.633333333 + }, + { + "id": "TCGA-97-8176", + "x": 63, + "y": 4.6 + }, + { + "id": "TCGA-78-7166", + "x": 84, + "y": 6.466666667 + }, + { + "id": "TCGA-73-4670", + "x": 69, + "y": 10.96666667 + }, + { + "id": "TCGA-44-3917", + "x": 33, + "y": 6.666666667 + }, + { + "id": "TCGA-95-7039", + "x": 54, + "y": 40.36666667 + }, + { + "id": "TCGA-62-A46R", + "x": 54, + "y": 5.666666667 + }, + { + "id": "TCGA-49-4506", + "x": 68, + "y": 3.9 + }, + { + "id": "TCGA-50-7109", + "x": 60, + "y": 8 + }, + { + "id": "TCGA-NJ-A4YI", + "x": 87, + "y": 13.16666667 + }, + { + "id": "TCGA-50-5933", + "x": 72, + "y": 16.5 + }, + { + "id": "TCGA-55-8090", + "x": 80, + "y": 2.566666667 + }, + { + "id": "TCGA-95-7562", + "x": 71, + "y": 13.1 + }, + { + "…": "138 more", + "sha256": "d53b61b911fb2f10" + } + ], + "drawn": 158 + }, + { + "kind": "cohort", + "label": "TP53 mut", + "color": "#0072B2", + "name": "TP53 mut", + "patients": 699, + "inPlot": 699, + "n": 652, + "shown": "points", + "points": [ + { + "id": "TCGA-71-8520", + "x": 60, + "y": 2.666666667 + }, + { + "id": "TCGA-49-4490", + "x": 45, + "y": 1.6 + }, + { + "id": "TCGA-78-7150", + "x": 59, + "y": 12.26666667 + }, + { + "id": "TCGA-05-4402", + "x": 57, + "y": 4.033333333 + }, + { + "id": "TCGA-62-A471", + "x": 64, + "y": 3.033333333 + }, + { + "id": "TCGA-44-7662", + "x": 61, + "y": 36.23333333 + }, + { + "id": "TCGA-53-A4EZ", + "x": 63, + "y": 15.13333333 + }, + { + "id": "TCGA-55-8085", + "x": 64, + "y": 7.5 + }, + { + "id": "TCGA-55-6980", + "x": 56, + "y": 1 + }, + { + "id": "TCGA-95-7043", + "x": 63, + "y": 34.16666667 + }, + { + "id": "TCGA-55-A4DG", + "x": 71, + "y": 20.9 + }, + { + "id": "TCGA-49-AAQV", + "x": 63, + "y": 2.233333333 + }, + { + "id": "TCGA-05-4410", + "x": 62, + "y": 33.8 + }, + { + "id": "TCGA-44-7670", + "x": 47, + "y": 67.2 + }, + { + "id": "TCGA-55-1594", + "x": 68, + "y": 5.6 + }, + { + "id": "TCGA-MP-A4T9", + "x": 54, + "y": 1.033333333 + }, + { + "id": "TCGA-55-6968", + "x": 61, + "y": 15.4 + }, + { + "id": "TCGA-86-8672", + "x": 59, + "y": 8.766666666999999 + }, + { + "id": "TCGA-38-6178", + "x": 70, + "y": 2.233333333 + }, + { + "id": "TCGA-55-8511", + "x": 73, + "y": 17.16666667 + }, + { + "…": "574 more", + "sha256": "95e1b03d778f70ae" + } + ], + "drawn": 594, + "shared": [ + { + "id": "TCGA-91-6836", + "x": 52, + "y": 15.33333333 + }, + { + "id": "TCGA-64-5778", + "x": 60, + "y": 14.26666667 + }, + { + "id": "TCGA-95-7039", + "x": 54, + "y": 40.36666667 + }, + { + "id": "TCGA-62-A46R", + "x": 54, + "y": 5.666666667 + }, + { + "id": "TCGA-05-4433", + "x": 82, + "y": 1.1 + }, + { + "id": "TCGA-83-5908", + "x": 59, + "y": 7.2 + }, + { + "id": "TCGA-55-8094", + "x": 51, + "y": 13.23333333 + }, + { + "id": "TCGA-MN-A4N5", + "x": 63, + "y": 13.5 + }, + { + "id": "TCGA-44-6144", + "x": 58, + "y": 13.1 + }, + { + "id": "TCGA-55-7576", + "x": 54, + "y": 24.26666667 + }, + { + "id": "TCGA-44-8117", + "x": 54, + "y": 22.7 + }, + { + "id": "TCGA-55-7914", + "x": 71, + "y": 5.366666667 + }, + { + "id": "TCGA-44-7661", + "x": 69, + "y": 18.16666667 + }, + { + "id": "TCGA-MP-A4TK", + "x": 56, + "y": 10.5 + }, + { + "id": "TCGA-55-7726", + "x": 72, + "y": 3.7 + }, + { + "id": "TCGA-99-8025", + "x": 72, + "y": 14.63333333 + }, + { + "id": "TCGA-69-7980", + "x": 70, + "y": 24.56666667 + }, + { + "id": "TCGA-05-4415", + "x": 57, + "y": 6.233333333 + }, + { + "id": "TCGA-55-8514", + "x": 70, + "y": 8.333333333 + }, + { + "id": "TCGA-55-7283", + "x": 76, + "y": 14.06666667 + }, + { + "…": "38 more", + "sha256": "a8eb0df5226d320c" + } + ], + "sharedOwners": [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + { + "…": "38 more", + "sha256": "e25d6ef7100931ea" + } + ] + } + ] + }, + "cohorts": [ + "Lung (TCGA)" + ], + "studies": [ + "luad_tcga_pan_can_atlas_2018", + "lusc_tcga_pan_can_atlas_2018" + ], + "participation": { + "studies": [ + { + "study": "luad_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "lusc_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "968 of 1,053 patients have a value on both axes (82 have no AGE; 3 have no TMB_NONSYNONYMOUS); only those are drawn. 2 studies pooled (luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Each site reports six sums (n, Σx, Σy, Σxy, Σx², Σy²), exact and additive, for Pearson's r and the regression line; the bin grid uses one shared scale (each site's own extent, pooled) so cells sum correctly. Spearman rank correlation is not reported for a federated plot: it needs the pooled GLOBAL ranking, which per-site aggregates cannot reconstruct exactly. Point layers — “KRAS mut”: 175 patients, 158 patients drawn as points; “TP53 mut”: 699 patients, 652 patients drawn as points (58 drawn by an earlier layer). The statistics are over the whole plotted cohort." + }, + { + "kind": "plot", + "plot": { + "shape": "box", + "n": 996, + "x": { + "label": "SEX", + "kind": "cat" + }, + "y": { + "label": "TMB_NONSYNONYMOUS", + "kind": "num" + }, + "groups": [ + { + "g": "Female", + "n": 402, + "lo": 0, + "hi": 67.2, + "q1": 3.4337479268034823, + "median": 6.917744610159204, + "q3": 12.18067993243781, + "loWhisker": 0, + "hiWhisker": 25.3010779408893 + }, + { + "g": "Male", + "n": 594, + "lo": 0, + "hi": 53.36666667, + "q1": 4.387598204329966, + "median": 7.345566778835017, + "q3": 12.602132434124579, + "loWhisker": 0, + "hiWhisker": 24.923933778816497 + } + ], + "overlay": "points", + "note": "2 studies pooled (luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Counts and extremes per group sum exactly; the quartiles are a size-weighted approximation across sites (it can shift where an outlier bar falls, never a count). A federated box does not draw a density behind it — that needs the same shared-scale binning a scatter does, not yet built for this shape — so points are shown when an entitled site has few enough to draw.", + "points": [ + { + "id": "TCGA-NJ-A7XG", + "g": "Male", + "v": 0.9 + }, + { + "id": "TCGA-91-6836", + "g": "Female", + "v": 15.33333333 + }, + { + "id": "TCGA-62-8397", + "g": "Female", + "v": 0.8 + }, + { + "id": "TCGA-64-5778", + "g": "Male", + "v": 14.26666667 + }, + { + "id": "TCGA-95-A4VP", + "g": "Female", + "v": 3.766666667 + }, + { + "id": "TCGA-49-4490", + "g": "Female", + "v": 1.6 + }, + { + "id": "TCGA-99-AA5R", + "g": "Female", + "v": 1.8 + }, + { + "id": "TCGA-05-4402", + "g": "Female", + "v": 4.033333333 + }, + { + "id": "TCGA-62-A471", + "g": "Male", + "v": 3.033333333 + }, + { + "id": "TCGA-78-7159", + "g": "Female", + "v": 10.2 + }, + { + "id": "TCGA-44-7662", + "g": "Male", + "v": 36.23333333 + }, + { + "id": "TCGA-95-7039", + "g": "Female", + "v": 40.36666667 + }, + { + "id": "TCGA-78-7537", + "g": "Male", + "v": 4.466666667 + }, + { + "id": "TCGA-55-8085", + "g": "Male", + "v": 7.5 + }, + { + "id": "TCGA-69-7761", + "g": "Male", + "v": 0.966666667 + }, + { + "id": "TCGA-95-7043", + "g": "Female", + "v": 34.16666667 + }, + { + "id": "TCGA-NJ-A55R", + "g": "Male", + "v": 7.7 + }, + { + "id": "TCGA-69-8453", + "g": "Male", + "v": 0 + }, + { + "id": "TCGA-55-A4DG", + "g": "Male", + "v": 20.9 + }, + { + "id": "TCGA-75-7025", + "g": "Male", + "v": 1.033333333 + }, + { + "…": "976 more", + "sha256": "178485cca72f6fe3" + } + ], + "pointSet": { + "rule": "all", + "drawn": 996 + }, + "coverage": { + "total": 1053, + "nx": 999, + "ny": 1050, + "multi": 0 + }, + "layers": [ + { + "kind": "cohort", + "label": "KRAS mut", + "color": "#D55E00", + "name": "KRAS mut", + "patients": 175, + "inPlot": 175, + "n": 164, + "shown": "points", + "points": [ + { + "id": "TCGA-MP-A4T7", + "g": "Female", + "v": 4.166666667 + }, + { + "id": "TCGA-91-6836", + "g": "Female", + "v": 15.33333333 + }, + { + "id": "TCGA-69-8253", + "g": "Female", + "v": 4.366666667 + }, + { + "id": "TCGA-64-5778", + "g": "Male", + "v": 14.26666667 + }, + { + "id": "TCGA-95-A4VP", + "g": "Female", + "v": 3.766666667 + }, + { + "id": "TCGA-99-8032", + "g": "Male", + "v": 12.26666667 + }, + { + "id": "TCGA-78-7145", + "g": "Female", + "v": 6.266666667 + }, + { + "id": "TCGA-05-4417", + "g": "Female", + "v": 9.633333333 + }, + { + "id": "TCGA-97-8176", + "g": "Male", + "v": 4.6 + }, + { + "id": "TCGA-78-7166", + "g": "Male", + "v": 6.466666667 + }, + { + "id": "TCGA-73-4670", + "g": "Female", + "v": 10.96666667 + }, + { + "id": "TCGA-44-3917", + "g": "Female", + "v": 6.666666667 + }, + { + "id": "TCGA-95-7039", + "g": "Female", + "v": 40.36666667 + }, + { + "id": "TCGA-62-A46R", + "g": "Female", + "v": 5.666666667 + }, + { + "id": "TCGA-49-4506", + "g": "Female", + "v": 3.9 + }, + { + "id": "TCGA-50-7109", + "g": "Male", + "v": 8 + }, + { + "id": "TCGA-NJ-A4YI", + "g": "Female", + "v": 13.16666667 + }, + { + "id": "TCGA-50-5933", + "g": "Male", + "v": 16.5 + }, + { + "id": "TCGA-55-8090", + "g": "Male", + "v": 2.566666667 + }, + { + "id": "TCGA-95-7562", + "g": "Male", + "v": 13.1 + }, + { + "…": "144 more", + "sha256": "1cf2834cffb46c2d" + } + ], + "drawn": 164 + } + ] + }, + "cohorts": [ + "Lung (TCGA)" + ], + "studies": [ + "luad_tcga_pan_can_atlas_2018", + "lusc_tcga_pan_can_atlas_2018" + ], + "participation": { + "studies": [ + { + "study": "luad_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "lusc_tcga_pan_can_atlas_2018", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "note": "996 of 1,053 patients have a value on both axes (54 have no SEX; 3 have no TMB_NONSYNONYMOUS); only those are drawn. 2 studies pooled (luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Counts and extremes per group sum exactly; the quartiles are a size-weighted approximation across sites (it can shift where an outlier bar falls, never a count). A federated box does not draw a density behind it — that needs the same shared-scale binning a scatter does, not yet built for this shape — so points are shown when an entitled site has few enough to draw. Point layers — “KRAS mut”: 175 patients, 164 patients drawn as points. The statistics are over the whole plotted cohort." + } + ] +} diff --git a/test/snapshots/two-studies-plot.sql b/test/snapshots/two-studies-plot.sql new file mode 100644 index 0000000..71ca4cb --- /dev/null +++ b/test/snapshots/two-studies-plot.sql @@ -0,0 +1,713 @@ +-- cohort Lung (TCGA) +-- luad_tcga_pan_can_atlas_2018 +SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- lusc_tcga_pan_can_atlas_2018 +SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + +-- cohort KRAS mut +-- luad_tcga_pan_can_atlas_2018 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- lusc_tcga_pan_can_atlas_2018 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort TP53 mut +-- luad_tcga_pan_can_atlas_2018 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- lusc_tcga_pan_can_atlas_2018 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- view 0 plot: plot:bins · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + pair AS (SELECT xs.v AS x, ys.v AS y FROM xs INNER JOIN ys ON ys.id = xs.id) +, e AS (SELECT 33 AS x0, 90 AS x1, 0 AS y0, 67.2 AS y1) +SELECT least(239, toUInt32(floor((x - x0) / nullIf(x1 - x0, 0) * 240))) AS bx, + least(159, toUInt32(floor((y - y0) / nullIf(y1 - y0, 0) * 160))) AS by, + count() AS n +FROM pair, e GROUP BY bx, by + +-- view 0 plot: plot:bins · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + pair AS (SELECT xs.v AS x, ys.v AS y FROM xs INNER JOIN ys ON ys.id = xs.id) +, e AS (SELECT 33 AS x0, 90 AS x1, 0 AS y0, 67.2 AS y1) +SELECT least(239, toUInt32(floor((x - x0) / nullIf(x1 - x0, 0) * 240))) AS bx, + least(159, toUInt32(floor((y - y0) / nullIf(y1 - y0, 0) * 160))) AS by, + count() AS n +FROM pair, e GROUP BY bx, by + +-- view 0 plot: plot:coverage · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + cases AS (SELECT pid AS id FROM cohort), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT count() AS total, countIf(id IN (SELECT id FROM xs)) AS nx, countIf(id IN (SELECT id FROM ys)) AS ny, + (SELECT count() FROM (SELECT patient_unique_id FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY patient_unique_id HAVING count() > 1)) AS multi FROM cases + +-- view 0 plot: plot:coverage · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + cases AS (SELECT pid AS id FROM cohort), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT count() AS total, countIf(id IN (SELECT id FROM xs)) AS nx, countIf(id IN (SELECT id FROM ys)) AS ny, + (SELECT count() FROM (SELECT patient_unique_id FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY patient_unique_id HAVING count() > 1)) AS multi FROM cases + +-- view 0 plot: plot:extent · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + pair AS (SELECT xs.v AS x, ys.v AS y FROM xs INNER JOIN ys ON ys.id = xs.id) +SELECT count() AS n, min(x) AS x0, max(x) AS x1, min(y) AS y0, max(y) AS y1 FROM pair + +-- view 0 plot: plot:extent · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + pair AS (SELECT xs.v AS x, ys.v AS y FROM xs INNER JOIN ys ON ys.id = xs.id) +SELECT count() AS n, min(x) AS x0, max(x) AS x1, min(y) AS y0, max(y) AS y1 FROM pair + +-- view 0 plot: plot:highlight:count · luad_tcga_pan_can_atlas_2018 +SELECT count() AS n FROM (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))) + +-- view 0 plot: plot:highlight:count · luad_tcga_pan_can_atlas_2018 +SELECT count() AS n FROM (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))) + +-- view 0 plot: plot:highlight:count · lusc_tcga_pan_can_atlas_2018 +SELECT count() AS n FROM (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))) + +-- view 0 plot: plot:highlight:count · lusc_tcga_pan_can_atlas_2018 +SELECT count() AS n FROM (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))) + +-- view 0 plot: plot:highlight:points · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT xs.id AS id, xs.v AS x, ys.v AS y +FROM xs INNER JOIN ys ON ys.id = xs.id +LIMIT 10001 + +-- view 0 plot: plot:highlight:points · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT xs.id AS id, xs.v AS x, ys.v AS y +FROM xs INNER JOIN ys ON ys.id = xs.id +LIMIT 9843 + +-- view 0 plot: plot:highlight:points · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT xs.id AS id, xs.v AS x, ys.v AS y +FROM xs INNER JOIN ys ON ys.id = xs.id +LIMIT 10001 + +-- view 0 plot: plot:highlight:points · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT xs.id AS id, xs.v AS x, ys.v AS y +FROM xs INNER JOIN ys ON ys.id = xs.id +LIMIT 9843 + +-- view 0 plot: plot:moments · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + pair AS (SELECT xs.v AS x, ys.v AS y FROM xs INNER JOIN ys ON ys.id = xs.id) +SELECT count() AS n, sum(x) AS sx, sum(y) AS sy, sum(x * y) AS sxy, sum(x * x) AS sxx, sum(y * y) AS syy +FROM pair + +-- view 0 plot: plot:moments · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'AGE' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + pair AS (SELECT xs.v AS x, ys.v AS y FROM xs INNER JOIN ys ON ys.id = xs.id) +SELECT count() AS n, sum(x) AS sx, sum(y) AS sy, sum(x * y) AS sxy, sum(x * x) AS sxx, sum(y * y) AS syy +FROM pair + +-- view 1 plot: plot:box · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT gs.v AS g, count() AS n, min(vs.v) AS lo, max(vs.v) AS hi, + quantilesExact(0.25, 0.5, 0.75)(vs.v) AS q +FROM vs INNER JOIN gs ON gs.id = vs.id +GROUP BY g ORDER BY n DESC LIMIT 151 + +-- view 1 plot: plot:box · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT gs.v AS g, count() AS n, min(vs.v) AS lo, max(vs.v) AS hi, + quantilesExact(0.25, 0.5, 0.75)(vs.v) AS q +FROM vs INNER JOIN gs ON gs.id = vs.id +GROUP BY g ORDER BY n DESC LIMIT 151 + +-- view 1 plot: plot:coverage · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + cases AS (SELECT pid AS id FROM cohort), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT count() AS total, countIf(id IN (SELECT id FROM xs)) AS nx, countIf(id IN (SELECT id FROM ys)) AS ny, + (SELECT count() FROM (SELECT patient_unique_id FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY patient_unique_id HAVING count() > 1)) AS multi FROM cases + +-- view 1 plot: plot:coverage · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + cases AS (SELECT pid AS id FROM cohort), + xs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + ys AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT count() AS total, countIf(id IN (SELECT id FROM xs)) AS nx, countIf(id IN (SELECT id FROM ys)) AS ny, + (SELECT count() FROM (SELECT patient_unique_id FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + GROUP BY patient_unique_id HAVING count() > 1)) AS multi FROM cases + +-- view 1 plot: plot:highlight:count · luad_tcga_pan_can_atlas_2018 +SELECT count() AS n FROM (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))) + +-- view 1 plot: plot:highlight:count · lusc_tcga_pan_can_atlas_2018 +SELECT count() AS n FROM (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))) + +-- view 1 plot: plot:highlight:points · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT vs.id AS id, gs.v AS g, vs.v AS v +FROM vs INNER JOIN gs ON gs.id = vs.id +LIMIT 10001 + +-- view 1 plot: plot:highlight:points · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT pid FROM (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018') WHERE pid IN (SELECT pid FROM (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' + AND g.hugo_gene_symbol = 'KRAS' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))))), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT vs.id AS id, gs.v AS g, vs.v AS v +FROM vs INNER JOIN gs ON gs.id = vs.id +LIMIT 10001 + +-- view 1 plot: plot:points · luad_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'luad_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'luad_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT vs.id AS id, gs.v AS g, vs.v AS v +FROM vs INNER JOIN gs ON gs.id = vs.id +LIMIT 10001 + +-- view 1 plot: plot:points · lusc_tcga_pan_can_atlas_2018 +WITH cohort AS (SELECT DISTINCT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018'), + vs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), avgIf(v, pref = 0)) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'TMB_NONSYNONYMOUS' AND attribute_value != '' AND if(isFinite(ifNull(toFloat64OrNull(attribute_value), nan)), toFloat64OrNull(attribute_value), NULL) IS NOT NULL + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id), + gs AS (SELECT id, if(countIf(pref = 1) > 0, anyIf(v, pref = 1), if(uniqExactIf(v, pref = 0) > 1, 'Multiple', anyIf(v, pref = 0))) AS v FROM ( +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 1 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'patient' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) + UNION ALL +SELECT replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') AS id, attribute_value AS v, 0 AS pref + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'lusc_tcga_pan_can_atlas_2018' AND attribute_name = 'SEX' AND attribute_value != '' + AND type = 'sample' AND replaceOne(patient_unique_id, 'lusc_tcga_pan_can_atlas_2018_', '') IN (SELECT pid FROM cohort) +) GROUP BY id) +SELECT vs.id AS id, gs.v AS g, vs.v AS v +FROM vs INNER JOIN gs ON gs.id = vs.id +LIMIT 10001 diff --git a/test/snapshots/two-studies-plot.svg b/test/snapshots/two-studies-plot.svg new file mode 100644 index 0000000..f219e9c --- /dev/null +++ b/test/snapshots/two-studies-plot.svg @@ -0,0 +1,4 @@ + +Plot — TMB_NONSYNONYMOUS against AGEPearson r = −0.13 (p = 4.2e-5)0102030405060TMB_NONSYNONYMOUS405060708090AGEpoint layersKRAS mut (158)TP53 mut (652)968 of 1,053 patients have a value on both axes (82 have no AGE; 3 have no TMB_NONSYNONYMOUS); only those are drawn. 2 studies pooled(luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Each site reports six sums (n, Σx, Σy, Σxy, Σx², Σy²), exact and additive, for Pearson's r and theregression line; the bin grid uses one shared scale (each site's own extent, pooled) so cells sum correctly. Spearman rank correlation is not reported for a federated plot:it needs the pooled GLOBAL ranking, which per-site aggregates cannot reconstruct exactly. Point layers — “KRAS mut”: 175 patients, 158 patients drawn as points;“TP53 mut”: 699 patients, 652 patients drawn as points (58 drawn by an earlier layer). The statistics are over the whole plotted cohort. Darker is more cases; the shade islogarithmic. The dashed line is the least-squares fit over every case. + +Plot — TMB_NONSYNONYMOUS by SEX01020304050TMB_NONSYNONYMOUSFemale: median 6.92, quartiles 3.43–12.2, n = 402Male: median 7.35, quartiles 4.39–12.6, n = 594Female (402)Male (594)SEXpoint layersKRAS mut (164)996 of 1,053 patients have a value on both axes (54 have no SEX; 3 have no TMB_NONSYNONYMOUS); only those are drawn. 2 studies pooled(luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Counts and extremes per group sum exactly; the quartiles are a size-weighted approximation acrosssites (it can shift where an outlier bar falls, never a count). A federated box does not draw a density behind it — that needs the same shared-scale binning a scatter does,not yet built for this shape — so points are shown when an entitled site has few enough to draw. Point layers — “KRAS mut”: 175 patients, 164 patients drawn as points.The statistics are over the whole plotted cohort. Box: quartiles with Tukey whiskers, computed over every case in the group; each name carries its count. Every value isdrawn over its box; the jitter is fixed per case. 5 values lie more than a whisker span past the whiskers and are drawn as a triangle at the frame's edge. diff --git a/test/snapshots/two-studies-plot.txt b/test/snapshots/two-studies-plot.txt new file mode 100644 index 0000000..0b3299a --- /dev/null +++ b/test/snapshots/two-studies-plot.txt @@ -0,0 +1,16 @@ +Analysis over luad_tcga_pan_can_atlas_2018 + lusc_tcga_pan_can_atlas_2018 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- Lung (TCGA): 1,053 patients — all patients in the study — across 2 studies +- KRAS mut: 175 patients — OQL[KRAS: MUT] — across 2 studies +- TP53 mut: 699 patients — OQL[TP53: MUT] — across 2 studies + +Plot (scatter): AGE vs TMB_NONSYNONYMOUS — 968 patients, binned onto a 240x160 grid (the payload is bins, never points). + Pearson r=-0.131 p=4.2e-5; Spearman rho=—; least-squares slope -0.128 + 968 of 1,053 patients have a value on both axes (82 have no AGE; 3 have no TMB_NONSYNONYMOUS); only those are drawn. 2 studies pooled (luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Each site reports six sums (n, Σx, Σy, Σxy, Σx², Σy²), exact and additive, for Pearson's r and the regression line; the bin grid uses one shared scale (each site's own extent, pooled) so cells sum correctly. Spearman rank correlation is not reported for a federated plot: it needs the pooled GLOBAL ranking, which per-site aggregates cannot reconstruct exactly. Point layers — “KRAS mut”: 175 patients, 158 patients drawn as points; “TP53 mut”: 699 patients, 652 patients drawn as points (58 drawn by an earlier layer). The statistics are over the whole plotted cohort. + +Plot (box): TMB_NONSYNONYMOUS by SEX — 996 patients. + Female: median 6.92 (IQR 3.43–12.18, whiskers 0.00–25.30, n=402) + Male: median 7.35 (IQR 4.39–12.60, whiskers 0.00–24.92, n=594) + Values are drawn as individual points. + 996 of 1,053 patients have a value on both axes (54 have no SEX; 3 have no TMB_NONSYNONYMOUS); only those are drawn. 2 studies pooled (luad_tcga_pan_can_atlas_2018, lusc_tcga_pan_can_atlas_2018). Counts and extremes per group sum exactly; the quartiles are a size-weighted approximation across sites (it can shift where an outlier bar falls, never a count). A federated box does not draw a density behind it — that needs the same shared-scale binning a scatter does, not yet built for this shape — so points are shown when an entitled site has few enough to draw. Point layers — “KRAS mut”: 175 patients, 164 patients drawn as points. The statistics are over the whole plotted cohort. diff --git a/test/snapshots/two-studies-survival.json b/test/snapshots/two-studies-survival.json new file mode 100644 index 0000000..3422602 --- /dev/null +++ b/test/snapshots/two-studies-survival.json @@ -0,0 +1,467 @@ +{ + "study": "msk_chord_2024", + "cohorts": { + "TP53 mut": { + "count": 25555, + "text": "OQL[TP53: MUT] — across 2 studies", + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ] + }, + "TP53 wt": { + "count": 24627, + "text": "NOT OQL[TP53:] AND profiled for TP53 MUTATION — across 2 studies", + "studies": [ + "msk_chord_2024", + "msk_met_2021" + ] + } + }, + "views": [ + { + "kind": "survival", + "cohorts": [ + "TP53 mut", + "TP53 wt" + ], + "curves": [ + { + "cohort": "TP53 mut", + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0, + "s": 0.9982 + }, + { + "t": 0.03, + "s": 0.9981 + }, + { + "t": 0.032876676, + "s": 0.9967 + }, + { + "t": 0.065753353, + "s": 0.9966 + }, + { + "t": 0.07, + "s": 0.9966 + }, + { + "t": 0.098630029, + "s": 0.9965 + }, + { + "t": 0.13, + "s": 0.9964 + }, + { + "t": 0.131506705, + "s": 0.9962 + }, + { + "t": 0.16, + "s": 0.996 + }, + { + "t": 0.164383381, + "s": 0.9957 + }, + { + "t": 0.197260058, + "s": 0.9956 + }, + { + "t": 0.2, + "s": 0.9953 + }, + { + "t": 0.23, + "s": 0.995 + }, + { + "t": 0.230136734, + "s": 0.9947 + }, + { + "t": 0.26, + "s": 0.9944 + }, + { + "t": 0.26301341, + "s": 0.9942 + }, + { + "t": 0.295890087, + "s": 0.9939 + }, + { + "t": 0.3, + "s": 0.9935 + }, + { + "t": 0.328766763, + "s": 0.993 + }, + { + "…": "2979 more", + "sha256": "ffc2d62afcd76b56" + } + ], + "median": 30.64106231, + "n": 25498, + "events": 12607, + "atRisk": [ + 25498, + 24109, + 23357, + 22638, + 21884, + 21187, + 20497, + 19853, + 19250, + 18633, + 17978, + 17317, + 16492, + 15797, + 15094, + 14401, + 13713, + 13063, + 12486, + 11916, + { + "…": "99 more", + "sha256": "65e42ce7c5247805" + } + ], + "missing": 57 + }, + { + "cohort": "TP53 wt", + "points": [ + { + "t": 0, + "s": 1 + }, + { + "t": 0, + "s": 0.9989 + }, + { + "t": 0.03, + "s": 0.9988 + }, + { + "t": 0.032876676, + "s": 0.9982 + }, + { + "t": 0.065753353, + "s": 0.998 + }, + { + "t": 0.07, + "s": 0.9978 + }, + { + "t": 0.098630029, + "s": 0.9977 + }, + { + "t": 0.1, + "s": 0.9976 + }, + { + "t": 0.13, + "s": 0.9975 + }, + { + "t": 0.131506705, + "s": 0.9974 + }, + { + "t": 0.16, + "s": 0.9973 + }, + { + "t": 0.164383381, + "s": 0.9973 + }, + { + "t": 0.197260058, + "s": 0.9972 + }, + { + "t": 0.2, + "s": 0.9971 + }, + { + "t": 0.23, + "s": 0.9969 + }, + { + "t": 0.230136734, + "s": 0.9968 + }, + { + "t": 0.26, + "s": 0.9967 + }, + { + "t": 0.26301341, + "s": 0.9966 + }, + { + "t": 0.295890087, + "s": 0.9964 + }, + { + "t": 0.3, + "s": 0.9961 + }, + { + "…": "3051 more", + "sha256": "28815bef7a1dd109" + } + ], + "median": 68.44924006, + "n": 24570, + "events": 8585, + "atRisk": [ + 24570, + 23454, + 22965, + 22473, + 22046, + 21636, + 21221, + 20770, + 20340, + 19860, + 19420, + 18945, + 18285, + 17677, + 17144, + 16580, + 16020, + 15453, + 14997, + 14522, + { + "…": "96 more", + "sha256": "c627134ccc1ae86f" + } + ], + "missing": 57 + } + ], + "endpoint": "OS", + "participation": { + "studies": [ + { + "study": "msk_chord_2024", + "mode": "patient-level", + "instance": "primary", + "source": 0 + }, + { + "study": "msk_met_2021", + "mode": "patient-level", + "instance": "primary", + "source": 0 + } + ], + "requiresPatientLevel": false, + "aggregateOnly": [] + }, + "logrank": { + "chi2": 1594.0863, + "p": 0, + "df": 1, + "observed": [ + 12607, + 8585 + ], + "expected": [ + 9723.3, + 11468.7 + ], + "variance": 5216.6577, + "strata": 2 + }, + "logrankPooled": { + "chi2": 1554.7258, + "p": 0, + "df": 1, + "observed": [ + 12607, + 8585 + ], + "expected": [ + 9754.9, + 11437.1 + ], + "variance": 5232.0787, + "strata": 1 + }, + "caveat": "OS from each study's own baseline (left truncation applies; baselines are NOT harmonized across studies) Status '0:...' treated as censored. The log-rank test is STRATIFIED by study (2 strata contributed events): each study is compared only against itself, so a difference in case mix between studies cannot masquerade as a difference between cohorts. The pooled p is shown alongside — where the two disagree, the stratified one is the honest answer. Every site contributes only (months, event, n) counts; no patient-level survival time crosses an instance boundary.", + "method": { + "steps": [ + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value.", + "scope": "TP53 mut · msk_chord_2024", + "rowsIn": 13105, + "rowsOut": 13105, + "params": [ + [ + "count rows", + "4,156" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value.", + "scope": "TP53 mut · msk_met_2021", + "rowsIn": 12450, + "rowsOut": 12393, + "params": [ + [ + "count rows", + "3,164" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value.", + "scope": "TP53 wt · msk_chord_2024", + "rowsIn": 11594, + "rowsOut": 11594, + "params": [ + [ + "count rows", + "4,433" + ] + ] + }, + { + "kind": "fetch", + "title": "Count patients by time and status", + "detail": "The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value.", + "scope": "TP53 wt · msk_met_2021", + "rowsIn": 13033, + "rowsOut": 12976, + "params": [ + [ + "count rows", + "3,444" + ] + ] + }, + { + "kind": "statistic", + "title": "Estimate survival by Kaplan–Meier", + "detail": "The product-limit estimator, one curve per cohort, pooled over its studies. The median is the first time the curve is at or below 0.5.", + "params": [ + [ + "TP53 mut", + "25,498 patients, 12,607 events, median 30.6 months" + ], + [ + "TP53 wt", + "24,570 patients, 8,585 events, median 68.4 months" + ] + ] + }, + { + "kind": "statistic", + "title": "Two-group log-rank test, stratified by study", + "detail": "At each event time, every cohort's observed events against its share of the risk set, with the hypergeometric variance; χ² on 1 df. Each study is its own stratum — compared only against itself — and the strata are summed, so a difference in case mix between studies cannot pass for a difference between cohorts.", + "params": [ + [ + "χ² / df / p", + "1594.0863 / 1 / <1e-300" + ], + [ + "strata with events", + "2" + ], + [ + "pooled, for contrast", + "χ² 1554.7258, p <1e-300" + ] + ] + } + ], + "implementation": { + "functions": [ + "kaplanMeier", + "logRank" + ], + "file": "lib/stats.ts", + "commit": null + }, + "verification": "Kaplan–Meier matches lifelines 0.30.3 KaplanMeierFitter (curves are reported to 4 decimals); the log-rank matches statsmodels 0.15.0 survdiff to a relative 1e-6, pooled, stratified, with delayed entry and for k groups (test/survival-golden.test.ts).", + "check": { + "km:TP53 mut:n": { + "v": 25498, + "abs": 0 + }, + "km:TP53 mut:events": { + "v": 12607, + "abs": 0 + }, + "km:TP53 mut:median": { + "v": 30.64106231, + "abs": 1e-9 + }, + "km:TP53 wt:n": { + "v": 24570, + "abs": 0 + }, + "km:TP53 wt:events": { + "v": 8585, + "abs": 0 + }, + "km:TP53 wt:median": { + "v": 68.44924006, + "abs": 1e-9 + }, + "logrank:chi2": { + "v": 1594.0863, + "abs": 0.00005 + }, + "logrank:p": { + "v": 0, + "rel": 0.00001, + "abs": 1e-300 + }, + "logrank:pooled:chi2": { + "v": 1554.7258, + "abs": 0.00005 + }, + "logrank:pooled:p": { + "v": 0, + "rel": 0.00001, + "abs": 1e-300 + } + } + } + } + ] +} diff --git a/test/snapshots/two-studies-survival.sql b/test/snapshots/two-studies-survival.sql new file mode 100644 index 0000000..5412169 --- /dev/null +++ b/test/snapshots/two-studies-survival.sql @@ -0,0 +1,155 @@ +-- cohort TP53 mut +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- msk_met_2021 +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation')) + +-- cohort TP53 wt +-- msk_chord_2024 +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))) + +-- combined at the analysis layer: each study is evaluated separately against its own +-- instance and the counts are ADDED; patient overlap across studies is not deduplicated. + +-- msk_met_2021 +((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_met_2021') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53'))) + +-- view 0 survival: survivalCounts:OS · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 0 survival: survivalCounts:OS · msk_chord_2024 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_chord_2024') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_chord_2024' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_chord_2024_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_chord_2024' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_chord_2024_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_chord_2024' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_chord_2024_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 0 survival: survivalCounts:OS · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND g.variant_type = 'mutation'))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_met_2021' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m + +-- view 0 survival: survivalCounts:OS · msk_met_2021 +WITH cohort AS (((SELECT DISTINCT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid FROM snapshot_db.sample_derived + WHERE cancer_study_identifier = 'msk_met_2021') +EXCEPT DISTINCT +((SELECT DISTINCT replaceOne(g.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.genomic_event_derived g + WHERE g.cancer_study_identifier = 'msk_met_2021' + AND g.hugo_gene_symbol = 'TP53' + AND g.mutation_status != 'UNCALLED' AND (g.variant_type != 'cna' OR abs(g.cna_alteration) >= 2)))) +INTERSECT DISTINCT +(SELECT DISTINCT replaceOne(sd.patient_unique_id, 'msk_met_2021_', '') AS pid + FROM snapshot_db.sample_to_gene_panel_derived sp + JOIN snapshot_db.sample_derived sd ON sd.sample_unique_id = sp.sample_unique_id + WHERE sp.cancer_study_identifier = 'msk_met_2021' AND sp.alteration_type = 'MUTATION_EXTENDED' + AND (sp.gene_panel_id = 'WES' OR sp.gene_panel_id IN ( + SELECT gene_panel_id FROM snapshot_db.gene_panel_to_gene_derived WHERE gene = 'TP53')))), +os AS ( + SELECT replaceOne(patient_unique_id, 'msk_met_2021_', '') AS pid, + anyIf(attribute_value, attribute_name='OS_MONTHS') AS months, + anyIf(attribute_value, attribute_name='OS_STATUS') AS status + FROM snapshot_db.clinical_data_derived + WHERE cancer_study_identifier = 'msk_met_2021' AND type='patient' + AND attribute_name IN ('OS_MONTHS','OS_STATUS') + AND replaceOne(patient_unique_id, 'msk_met_2021_', '') IN (SELECT pid FROM cohort) + GROUP BY pid +) +SELECT if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) AS m, if(status LIKE '1%', 1, 0) AS ev, count() AS n +FROM os WHERE if(isFinite(ifNull(toFloat64OrNull(months), nan)), toFloat64OrNull(months), NULL) IS NOT NULL +GROUP BY m, ev ORDER BY m diff --git a/test/snapshots/two-studies-survival.svg b/test/snapshots/two-studies-survival.svg new file mode 100644 index 0000000..807cd0b --- /dev/null +++ b/test/snapshots/two-studies-survival.svg @@ -0,0 +1,2 @@ + +Kaplan–Meier — TP53 mut, TP53 wt0%25%50%75%100%Survival probability024487296MonthsNumber at riskTP53 mutTP53 mut: 25,498 at risk at 0 months25,498TP53 mut: 9,604 at risk at 24 months9,604TP53 mut: 3,615 at risk at 48 months3,615TP53 mut: 977 at risk at 72 months977TP53 mut: 129 at risk at 96 months129TP53 wtTP53 wt: 24,570 at risk at 0 months24,570TP53 wt: 12,411 at risk at 24 months12,411TP53 wt: 5,548 at risk at 48 months5,548TP53 wt: 1,687 at risk at 72 months1,687TP53 wt: 240 at risk at 96 months240TP53 mutmedian 30.6 mo · n = 25,498 · 12,607 eventsTP53 wtmedian 68.4 mo · n = 24,570 · 8,585 eventslog-rank χ² = 1,594 (1 df) · p < 1e-300 · stratified by study, 2 strata · pooled p < 1e-300OS from each study's own baseline (left truncation applies; baselines are NOT harmonized across studies) Status '0:...' treated as censored. The log-rank testis STRATIFIED by study (2 strata contributed events): each study is compared only against itself, so a difference in case mix between studies cannotmasquerade as a difference between cohorts. The pooled p is shown alongside — where the two disagree, the stratified one is the honest answer. Every sitecontributes only (months, event, n) counts; no patient-level survival time crosses an instance boundary. diff --git a/test/snapshots/two-studies-survival.txt b/test/snapshots/two-studies-survival.txt new file mode 100644 index 0000000..2693df7 --- /dev/null +++ b/test/snapshots/two-studies-survival.txt @@ -0,0 +1,28 @@ +Analysis over msk_chord_2024 + msk_met_2021 — OncoKB pin v7.5 — (time)ms. + +Cohorts: +- TP53 mut: 25,555 patients — OQL[TP53: MUT] — across 2 studies +- TP53 wt: 24,627 patients — NOT OQL[TP53:] AND profiled for TP53 MUTATION — across 2 studies + +Survival (KM, OS): + TP53 mut: median 30.6mo (n=25498, 12607 events, 57 missing OS) + TP53 wt: median 68.4mo (n=24570, 8585 events, 57 missing OS) + log-rank p=<1e-300 (stratified by study) +CAVEAT (tell the user): OS from each study's own baseline (left truncation applies; baselines are NOT harmonized across studies) Status '0:...' treated as censored. The log-rank test is STRATIFIED by study (2 strata contributed events): each study is compared only against itself, so a difference in case mix between studies cannot masquerade as a difference between cohorts. The pooled p is shown alongside — where the two disagree, the stratified one is the honest answer. Every site contributes only (months, event, n) counts; no patient-level survival time crosses an instance boundary. + METHOD: + - Count patients by time and status [TP53 mut · msk_chord_2024] (13,105 → 13,105 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value. + count rows: 4,156 + - Count patients by time and status [TP53 mut · msk_met_2021] (12,450 → 12,393 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value. + count rows: 3,164 + - Count patients by time and status [TP53 wt · msk_chord_2024] (11,594 → 11,594 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. Every cohort patient had a value. + count rows: 4,433 + - Count patients by time and status [TP53 wt · msk_met_2021] (13,033 → 12,976 rows): The survivalCounts:OS query above: patients grouped by identical OS_MONTHS, event, returned as counts — no patient identifier leaves the database. Event: OS_STATUS starting with “1”; any other value is censored. 57 cohort patients had no OS_MONTHS value. + count rows: 3,444 + - Estimate survival by Kaplan–Meier: The product-limit estimator, one curve per cohort, pooled over its studies. The median is the first time the curve is at or below 0.5. + TP53 mut: 25,498 patients, 12,607 events, median 30.6 months + TP53 wt: 24,570 patients, 8,585 events, median 68.4 months + - Two-group log-rank test, stratified by study: At each event time, every cohort's observed events against its share of the risk set, with the hypergeometric variance; χ² on 1 df. Each study is its own stratum — compared only against itself — and the strata are summed, so a difference in case mix between studies cannot pass for a difference between cohorts. + χ² / df / p: 1594.0863 / 1 / <1e-300 + strata with events: 2 + pooled, for contrast: χ² 1554.7258, p <1e-300 + Kaplan–Meier matches lifelines 0.30.3 KaplanMeierFitter (curves are reported to 4 decimals); the log-rank matches statsmodels 0.15.0 survdiff to a relative 1e-6, pooled, stratified, with delayed entry and for k groups (test/survival-golden.test.ts). diff --git a/test/view-snapshots.test.ts b/test/view-snapshots.test.ts new file mode 100644 index 0000000..77e3809 --- /dev/null +++ b/test/view-snapshots.test.ts @@ -0,0 +1,229 @@ +// Every view kind's output, pinned: one gallery example per kind (and a few that combine studies) +// runs through the whole engine (cohort compiler, runner, statistics, figure, results text) with +// the warehouse replaced by answers recorded from it. Four files per case in test/snapshots/ are +// compared byte for byte: +// .sql each cohort's compiled SQL and each view's queries, by label and study +// .json what each view computed (its result, without timings or the queries above; a long +// array, or an object of more than 50 keys, as its first 20 items, then the rest's +// count and digest) +// .svg each view's figure; .txt the results text MCP clients and the AI tools read +// A change to shared code that moves another view's numbers, figure, text or queries fails here, +// named by the case. A changed query has no recorded answer, so it fails as "not recorded". +// Each case runs twice, its answers delivered in the order its queries were sent and then in the +// reverse, and the two runs must agree exactly: output that depends on which query finished first +// fails as such. (A view's +// queries are listed sorted in .sql: independent queries form a set, and the snapshot pins +// which are sent, not the order they happen to be sent in.) +// +// UPDATE_SNAPSHOTS=1 npm test output changed on purpose, queries did not: rewrite the four files +// RECORD_SNAPSHOTS=1 node --env-file=.env.local --test test/view-snapshots.test.ts +// queries changed: re-ask the warehouse, then rewrite everything +// Recording reads the public warehouse only (the second instance is unset first); the answers are +// stored gzipped in test/snapshots/answers/, keyed by statement, under the database name below. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { createHash } from "node:crypto"; +import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"; +import { gunzipSync, gzipSync } from "node:zlib"; +import { join } from "node:path"; + +const RECORD = !!process.env.RECORD_SNAPSHOTS; +const UPDATE = RECORD || !!process.env.UPDATE_SNAPSHOTS; +/** the database name every snapshot is written under, whatever the recording ran against */ +const SNAPSHOT_DB = "snapshot_db"; +const realDb = (process.env.CLICKHOUSE_DB || "").replace(/[^A-Za-z0-9_]/g, ""); +if (RECORD) { + for (const k of Object.keys(process.env)) if (k.startsWith("CLICKHOUSE2_") || k === "LOOPBACK_PEER") delete process.env[k]; + if (!realDb) throw new Error("RECORD_SNAPSHOTS needs the warehouse: run with node --env-file=.env.local"); +} else { + process.env.CLICKHOUSE_DB = SNAPSHOT_DB; + for (const k of Object.keys(process.env)) if (k.startsWith("CLICKHOUSE2_")) delete process.env[k]; +} + +const { setChTransport } = await import("../lib/ch.ts"); +const { EXAMPLES } = await import("../lib/dsl-reference.ts"); +const { runAnalysis } = await import("../lib/analysis.ts"); +const { withRequestCustomData } = await import("../lib/custom-data-server.ts"); +const { viewToSvg } = await import("../lib/view-svg.ts"); +const { analysisText } = await import("../lib/result-text.ts"); +import type { AnalysisDoc, AnalysisResult } from "../lib/types.ts"; + +/** + * One case per view kind: the smallest gallery example that draws it (the oncoprint is pinned by + * test/oncoprint-svg.test.ts); then examples that combine studies, where a view adds up answers + * from several databases. + */ +const CASES: Record = { + compare: "A missing alteration type is disclosed, never a false negative", + survival: "A non-standard survival endpoint, named directly", + cox: "Cox with a gene-SET covariate: any of three genes, one term", + logistic: "Logistic regression: does APC status predict MSI-high status", + course: "The clinical course: who is still on treatment, and when", + sequence: "What comes after what: lines of therapy, and what ending a path means", + hotspots: "Lollipop plot: mutations by protein position", + plot: "Plot axes from the study's own profiles", + coexpression: "Co-expression from sums alone", + clinical: "Median/IQR and a rank-sum test, single-study only", + cooccurrence: "Co-occurrence and mutual exclusivity in NSCLC", + attrition: "Cohort attrition: which criterion removed whom", + genome: "Genome-wide copy number: colorectal against breast", + pathways: "Oncogenic signalling pathways: colorectal against pancreatic", + diffexpr: "Differential expression and enrichment", + paired: "Paired samples: what differs between a patient's primary and", + clonality: "Clonality, LOH and genome doubling from FACETS", + incidence: "Brain metastasis, with death as a competing risk", + labs: "PSA response to hormone therapy, by TP53 status", + riskmodel: "A survival risk model from mutated genes in lung cancer", + cancertypes: "Cancer types summary: RAS genes across 50,000 tumours", + overlap: "Cohort overlap: how four groups share their patients", + enrichment: "Alteration enrichment: what separates colorectal from pancreatic", + assays: "Mutational signatures: what UV light and tobacco leave behind", + composition: "Composition: T and NK cell states by mutational signature", + correlates: "Co-expression: the genes that rise and fall with ESR1", + table: "Clinical data: every pancreatic cancer sample, oldest patients first", + timeline: "A patient's timeline: treatments, diagnoses, samples and lab", + mutations: "KRAS codon 12/13 mutations in colorectal cancer", + alterations: "A patient's mutations, copy-number alterations and structural", + "two-studies-survival": "Study-stratified survival across two studies", + "two-studies-four-views": "Federated end to end: two studies, four views", + "two-studies-plot": "Point layers across two studies", + "pooled-paired": "Before and after treatment, pooled across studies", +}; + +const DIR = join(import.meta.dirname, "snapshots"); +const ANSWERS = join(DIR, "answers"); +const toSnapshotDb = (s: string) => realDb ? s.replaceAll(realDb + ".", SNAPSHOT_DB + ".").replaceAll("'" + realDb + "'", "'" + SNAPSHOT_DB + "'") : s; + +/** a statement's key: the instance, the format, the text and every table sent with it */ +async function keyOf(st: { conn: { id: string }; format: string; query: string; externals: { name: string; structure: string; blob: Blob }[] }): Promise { + const h = createHash("sha256").update(st.conn.id + "\n" + st.format + "\n" + toSnapshotDb(st.query)); + for (const e of st.externals) h.update("\n" + e.name + "\n" + e.structure + "\n" + await e.blob.text()); + return h.digest("hex").slice(0, 32); +} + +/** a ClickHouse answer without its timing statistics, which differ on every run */ +function steady(text: string): string { + try { const j = JSON.parse(text); delete j.statistics; return JSON.stringify(j); } catch { return text; } +} + +/** + * A long array (or an object keyed by gene, by value, …) keeps its first items in full and stands in + * for the rest by their count and digest, so a change anywhere still fails the comparison while the + * file stays small enough to review. + */ +const KEEP = 20, KEEP_KEYS = 50; +function compact(x: unknown): unknown { + if (Array.isArray(x)) { + const head = x.slice(0, KEEP).map(compact); + if (x.length <= KEEP) return head; + return [...head, { "…": x.length - KEEP + " more", sha256: createHash("sha256").update(JSON.stringify(x.slice(KEEP))).digest("hex").slice(0, 16) }]; + } + if (x && typeof x === "object") { + const entries = Object.entries(x); + const head = entries.slice(0, entries.length > KEEP_KEYS ? KEEP : entries.length).map(([k, v]) => [k, compact(v)]); + if (entries.length > KEEP_KEYS) head.push(["…", { more: entries.length - KEEP, sha256: createHash("sha256").update(JSON.stringify(entries.slice(KEEP))).digest("hex").slice(0, 16) }]); + return Object.fromEntries(head); + } + return x; +} +const json = (x: unknown) => JSON.stringify(compact(x), null, 2) + "\n"; + +/** the four files of one case */ +function render(doc: AnalysisDoc, r: AnalysisResult): Record { + const sql: string[] = []; + for (const [name, c] of Object.entries(r.cohorts)) sql.push("-- cohort " + name + "\n" + toSnapshotDb(String((c as { sql?: string }).sql ?? ""))); + // a view's independent queries form a set (see this file's header) + r.views.forEach((v, i) => sql.push(...(v.queries || []).map((q) => + "-- view " + i + " " + v.kind + ": " + q.label + " · " + q.study + (q.remote ? " · remote" : "") + "\n" + toSnapshotDb(q.sql)).sort())); + const views = r.views.map(({ ms: _ms, renderMs: _r, queries: _q, method, ...v }) => + ({ ...v, ...(method ? { method: { ...method, python: undefined } } : {}) })); + const cohorts = Object.fromEntries(Object.entries(r.cohorts).map(([n, c]) => { + const { sql: _sql, ...rest } = c as { sql?: string }; + return [n, rest]; + })); + const svg = r.views.map((v, i) => "\n" + (viewToSvg(v, { theme: "light" }) ?? "(no figure)")).join("\n") + "\n"; + return { + sql: sql.join("\n\n") + "\n", + json: json({ study: r.study, cohorts, splits: r.splits, views }), + svg, + txt: analysisText(doc, r).join("\n\n").replace(/ — \d+ms\./, " — (time)ms.") + "\n", + }; +} + +if (UPDATE) mkdirSync(ANSWERS, { recursive: true }); + +/** + * Every case's recorded answers, pooled: what the engine asks once per process (which database + * holds a study, a study's profiles) is recorded by whichever case asked it first, so a case run + * alone finds it in another case's file. + */ +const POOL: Record = {}; +if (!RECORD) for (const name of Object.keys(CASES)) { + const f = join(ANSWERS, name + ".json.gz"); + if (existsSync(f)) Object.assign(POOL, JSON.parse(gunzipSync(readFileSync(f)).toString("utf8"))); +} + +/** + * One thread per statement while recording: ClickHouse otherwise adds floats across threads in + * whatever order they finish, and returns rows of a query without ORDER BY in no fixed order, so + * a re-recorded case would differ from the last recording where nothing changed. + */ +const RECORD_SETTINGS = "max_threads=1"; + +/** + * Delivery in a chosen order: answers that are waiting together are held for a moment, then + * released in the order their statements were sent ("sent") or the reverse ("reversed"). Two runs + * in opposite orders give any two concurrent answers opposite arrival orders, so output that depends + * on which arrived first differs between them, every time. + */ +type Delivery = "sent" | "reversed"; +let waiting: (() => void)[] = []; +function arrive(order: Delivery): Promise { + return new Promise((release) => { + waiting.push(release); + if (waiting.length === 1) setTimeout(() => { + const batch = order === "reversed" ? waiting.reverse() : waiting; + waiting = []; + for (const r of batch) r(); + }, 1); + }); +} + +/** run the example once: live while recording, else from the pool, delivered in `order` */ +async function runCase(ex: (typeof EXAMPLES)[number], recorded: Record, order: Delivery | null): Promise { + setChTransport(async (st, send) => { + const key = await keyOf(st); + if (RECORD) return (recorded[key] = toSnapshotDb(steady(await send(RECORD_SETTINGS)))); + if (!(key in POOL)) throw new Error("not recorded (a query changed; RECORD_SNAPSHOTS=1, see this file's header):\n" + toSnapshotDb(st.query).slice(0, 2000)); + if (order) await arrive(order); + return POOL[key]; + }); + try { return await withRequestCustomData(ex.customData, () => runAnalysis(ex.doc as unknown as AnalysisDoc, { oncoprint: "spec" })); } + finally { setChTransport(null); } +} + +for (const [kind, title] of Object.entries(CASES)) { + test("snapshot: " + kind, async () => { + const ex = EXAMPLES.find((e) => e.title.startsWith(title)); + assert.ok(ex, "no gallery example titled “" + title + "…”"); + const answersFile = join(ANSWERS, kind + ".json.gz"); + const recorded: Record = {}; + const result = await runCase(ex, recorded, RECORD ? null : "sent"); + const failed = result.views.filter((v) => v.error && /not recorded/.test(v.error)); + assert.deepEqual(failed.map((v) => v.error), [], "a view asked something the recording never answered"); + if (RECORD) writeFileSync(answersFile, gzipSync(JSON.stringify(Object.fromEntries(Object.entries(recorded).sort())), { level: 9 })); + const out = render(ex.doc as unknown as AnalysisDoc, result); + if (!RECORD) { + const again = render(ex.doc as unknown as AnalysisDoc, await runCase(ex, recorded, "reversed")); + for (const ext of Object.keys(out)) + assert.equal(again[ext], out[ext], kind + "." + ext + " depends on the order database answers arrive: combine a view's answers " + + "after they are all in, in a fixed order (askEachSite in lib/views/shared.ts), not as each one lands"); + } + for (const [ext, text] of Object.entries(out)) { + const file = join(DIR, kind + "." + ext); + if (UPDATE) { writeFileSync(file, text); continue; } + assert.ok(existsSync(file), file + " is missing — RECORD_SNAPSHOTS=1, see this file's header"); + assert.equal(text, readFileSync(file, "utf8"), kind + "." + ext + " changed — review the diff; if intended, UPDATE_SNAPSHOTS=1 npm test"); + } + }); +}