Repository navigation
Cohorts are sets of samples, as on cBioPortal - #85
Merged
Merged
Conversation
A cohort compiled to a set of patients, and every view joined its tables on `<patient> IN (SELECT pid FROM cohort)`. A sample-level clause therefore took every other sample of the patients it matched: the NSCLC cohort of msk_chord_2024 held 7,876 samples (67 of them colorectal, breast, pancreatic, …), and its gene frequencies counted mutations from those samples (TP53 4,020 vs cBioPortal's 4,005, APC 327 vs 312). Semantics (cBioPortal's): - every clause compiles to rows (pid, sid) of the study's samples. Sample-level clauses (sample attributes, OQL alterations, sample lists, profiled, genomicData, proteinPosition, caseList) select the matching samples; patient-level ones (patient attributes, events, derived, patient lists, the held-out split) every sample of the matching patients. all/any/not are intersection, union and complement over samples. - a clinical attribute is matched at the level each study records it, so one clause works over a study that records GRADE per sample and one that records it per patient. `per` is removed from the DSL and refused by name. - a cohort's patients are the owners of its samples. Two helpers in lib/cohort2.ts are the one join rule: inCohortSamples for sample-keyed tables, inCohortPatients for patient-keyed ones; all 127 hand-written joins go through them. Gene counts, pair counts, co-expression and differential expression count samples, as the portal does; patient-unit views derive a patient's genomic state from its in-cohort samples only. - locks freeze the cohort's samples (a sample-level id set, arms as parts); drift is measured in samples. Splits are decided per sample and conserved in samples. - Explore's draft is a sample set: totals, gene tables, facets and gene-state counts follow it. The oncoprint's patient columns are built from the cohort's samples, shipped once as an external table. Verified: - check:portal 724/724 against cbioportal.org, including new sections: sample-level selections (NSCLC, SAMPLE_TYPE = Primary, Metastasis + SEX, GRADE = IV in difg_glass_2019, OQL TP53: MUT) compared by sizes, Explore's gene tables and the views' gene counts, and pancan_pcawg_2020 + lihc_tcga under GRADE = G3, sample-level in one and patient-level in the other (75 + 125 samples). These failed 75 of 83 before the change. - check:cohorts 41/41: the reference evaluator is now over sample ids. - check:mutants 21/21, two new planted bugs bring the leak back (a sample-level clause taking whole patients; gene counts joined on patients). - unit, postgres, view snapshots (re-recorded and reviewed), examples and method scripts, lint. Example counts re-pinned: mutant cohorts shrink to the portal's numbers (KRAS-mutant NSCLC 2,194 -> 2,183), wild-type ones grow. - performance recorded in docs/PERFORMANCE.md: the gallery is ~7% slower end to end, the oncoprint bench neutral-to-better. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTZdin1WVnUH8kzqcMC
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
The compiler refuses a clinical clause carrying per (the level is each study's own); the browser suites and scripts/figure-stress.json still wrote it, so their documents answered 400 and ten e2e checks failed or timed out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTZdin1WVnUH8kzqcMC
…ider step A lock freezes samples, so a sample new since the lock is one the definition's drift already reports as entered; newSamples counted the frozen patients' other samples instead, and reported a just-locked sample cohort as changed. The lock e2e check reads n and nPatients; the risk-groups slider check asserts a step of at least one whole percentile rather than a value pinned to the old scores. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTZdin1WVnUH8kzqcMC
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTZdin1WVnUH8kzqcMC
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q3ezTZdin1WVnUH8kzqcMC
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
A cohort compiled to a set of patients, and every view joined on
<patient> IN (SELECT pid FROM cohort). A sample-level clause therefore pulled in every other sample of the patients it matched. The gallery's NSCLC cohort (msk_chord_2024) held 7,876 samples, 67 of them colorectal, breast, pancreatic and so on, and its gene frequencies counted mutations found only in those samples:check:portalnever saw it: it compared filtered cohorts only by patient count, which is right by construction, and compared gene tables only under a patient-level filter (SEX = Female) and only through Explore's code path.What this changes (cBioPortal's semantics)
(pid, sid)rows of the study's samples.profiled,genomicData,proteinPosition,caseList.event,derived, patient lists, the held-outsplit.all/any/notare intersection, union and complement over samples.GRADEis sample-level in pancan_pcawg_2020 and patient-level in lihc_tcga, and one clause now matches each study its own way.peris removed from the DSL and refused by name. No backward compatibility, as agreed.inCohortSamplesandinCohortPatients(lib/cohort2.ts) replace all 127 hand-written joins.Verification
check:portal: 724/724 agree with cbioportal.org. Two new sections:SAMPLE_TYPE = Primary;Metastasis+SEX = Female;GRADE = IVin difg_glass_2019, where 56 patients have samples of different grades; OQLTP53: MUT. Each is compared on sizes, every row of Explore's gene tables, and the views' gene counts.GRADE = G3, giving 75 + 125 samples.check:cohorts: 41/41. The reference evaluator now works over sample ids.check:mutants: 21/21. Two new planted bugs bring the leak back, and both are caught:check:cohorts);check:portal).scripts/gate.sh: everything up to e2e passed: lint, build, unit, Postgres, access, Python conformance, the splitBy cost check, and the warehouse checks. The e2e stage was still running when this PR was opened. Please don't merge until it, or CI, is green.Performance (
docs/PERFORMANCE.md)Base commit and this branch, run back to back and interleaved, uncached:
sample_derived, and patient-unit views join on in-cohort samples. Two suspected causes were measured and ruled out; details are in the doc.Left for follow-up
drivernegativekeeps patients as its unit, built from in-cohort samples. cBioPortal's group comparison would count samples.?sampleId=mode (session/patient) will need an optional sample filter onalterationSource,patientSamplesSourceandpatientEventsSql.bench.mjsimported./lib/oncoprint.jsand could not run. Fixed here.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q3ezTZdin1WVnUH8kzqcMC