Skip to content

OncoPrint clinical legend in the portal's order: alphabetical, "No data" last, signed number key - #216

Merged
alisman merged 2 commits into
masterfrom
session/oncoprint-clinical-legend
Nov 14, 2026
Merged

alisman merged 2 commits into
masterfrom
session/oncoprint-clinical-legend

Conversation

@alisman

@alisman alisman commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Stacked on #215. Until #215 merges, its commit shows here too; this PR's own change is the top commit.

The clinical legend now follows the portal: values in alphabetical order, "No data" last, and a number key coloured by the sign of its range (ONC-ST-4).

Case table (legacy oncoprintjs: oncoprintlegendrenderer.ts, oncoprintruleset.ts)

# Case Expected Before
L1 Zeta ×3, Beta ×2, Alpha ×1 Alpha, Beta, Zeta (localeCompare, LR 103-157) most frequent first
L2 "1", "10", "2" 1, 10, 2 frequency
L3 "b", "B", "a" a, b, B frequency
L4 some columns have no value "No data" last (RS 700-709, order +Infinity) missing
L5 every column has a value no "No data" —
L6 a value only hidden columns have not listed (only active rules are shown); the server SVG draws every column, so it lists it listed
L7 swatches each value's own colour, unchanged by the reorder —
L8 reserved values alphabetical with the rest —
L9 more than 8 values the first 8 in the portal's order, then "+N more" (ours; the portal lists all) first 8 by frequency
L10–L12 a bar track over 0…8 / −3…8 / −5…−1 green / red and green / red (getValueRangeType 866-876) always green
L13 range labels 2 decimals 1 decimal
L14 the SVG and the page one rule (clinicalLegend) for both two copies

The test writer also checked the table against the legacy source:

  • Rows L10–L12: the colour comes from getValueRangeType.
  • Ranges set by the track: for example fraction genome altered is drawn on 0–1. Our engine already gives each bar track its own range, and the key reads it.

Checks

  • Golden SVG: the legend changes and the cells don't. CANCER_TYPE now reads Breast, Colon, Lung, and STAGE reads I, II, III, IV, then No data.
  • Checked in the browser on msk_impact_2017 with SAMPLE_TYPE and SEX:
    • SAMPLE_TYPE reads Metastasis, Mixed, Primary;
    • SEX reads Female, Male;
    • there are no page errors.
  • Planted bugs, all caught:
    • legend-frequency-order
    • legend-no-data-missing
    • legend-hidden-values
    • legend-number-one-colour
  • npm test: 4,270 pass. The Python figure has no clinical legend, so the Python port is unaffected.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q3ezTZRWoR5xpTndPddHAe

alisman and others added 2 commits November 14, 2026 20:39
A merged row or a patient column can hold several copy-number calls. The portal counts them by
kind — driver amplification, VUS amplification, driver deep deletion, VUS deep deletion, each
apart (DataUtils fillGeneticTrackDatum) — and shows and sorts by the kind with the most calls:
its render priorities tie for amplification and deep deletion and are missing for the driver
kinds, so every comparison in selectDisplayValue comes down to the count. The cell's copy number
is a driver only when that kind is. Ours OR'd every call into the cell, so it kept both glyphs,
drew and sorted the amplification, and called the copy number a driver if any call was.

In the warehouse 40,845 patient–gene pairs in 28 studies hold both an amplification and a deep
deletion; in 563 the deletions outnumber the amplifications.

Ours alone, recorded in PORTAL-PARITY: on equal counts the portal takes the first call's kind, in
an order we do not have; ours takes a driver before a VUS, then an amplification. A driver call
that loses on count still makes the column driver-altered for the gutter's driver %.

Tests from a case table of the legacy source, written by an agent that did not see the change
(test/oncoprint-cna-calls.test.ts, python/tests/test_cna_calls.py: engine, browser re-sort,
drawing, Python), seen failing first; the staircase audit's D8 and D9, marked todo for this, now
pass. Three planted bugs caught, and the same three by hand in Python. npm test 4256 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q3ezTZRWoR5xpTndPddHAe
…ta" last, signed number key

A clinical track's legend listed its values in the order they take colours (most frequent first).
oncoprintjs sorts the rules it shows by localeCompare of their labels (oncoprintlegendrenderer
103-157), lists only the values the drawn columns use, and puts "No data" — the NA rule, order
+Infinity — last when a drawn column has no value (oncoprintruleset 700-709). A bar track's key
is green when its range is not negative, red when not positive, both when it spans 0
(getValueRangeType 866-876, legend 257-305), its ends to 2 decimals; ours was always green.

One rule, clinicalLegend in lib/oncoprint-style.ts, draws both the server SVG's legend and the
page's (which passes the drawn columns, so Show unaltered off drops a value only hidden columns
have). A value keeps its colour; only the order changes. Ours alone: at most 8 values, "+N more".

The golden SVG's legend changes accordingly (CANCER_TYPE Breast, Colon, Lung; STAGE I, II, III,
IV, No data); its cells do not.

Tests from a case table of the legacy source, written by an agent that did not see the change
(test/oncoprint-clinical-legend.test.ts), seen failing first. Four planted bugs caught. The page
legend looked at on msk_impact_2017 with SAMPLE_TYPE and SEX: Metastasis, Mixed, Primary;
Female, Male; no page errors. npm test 4270 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q3ezTZRWoR5xpTndPddHAe
@vercel

vercel Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cbiolab-genie Ready Ready Preview Nov 14, 2026 9:00pm UTC
cbiolab-new Ready Ready Preview Nov 14, 2026 9:00pm UTC
cohort-lab Ready Ready Preview Nov 14, 2026 9:00pm UTC

Request Review

@alisman
alisman merged commit 0e6a3cb into master Nov 14, 2026
26 of 28 checks passed
@alisman
alisman deleted the session/oncoprint-clinical-legend branch November 14, 2026 23:08

This branch was successfully deployed

1 active deployment
Preview – cohort-lab — 51975dc6 Deployed Nov 14, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant