oncodsl / Read docs /PROMPT_modules_highlight_symbols.md
govindbalki's picture
Upload folder using huggingface_hub
0fff343 verified
|
Raw
History Blame Contribute Delete
3.5 kB
# Prompt — colour-code reference genes in Coordinated modules + fix missing symbols
Two presentation fixes to the Coordinated-modules table. Verified against the code: `_compute_module_ranking` (api/app.py ~lines 1244–1457) returns each module as `{gene_ids (opaque), size, combined_holdout, coherence, per_gene:[{id,single_gene_metric,rank,total}]}`**opaque IDs only, no symbols and no reference-set flag**. The table's "—" cells are module genes that were never revealed (e.g. `g09647` = LIG1); they resolve fine (HNSC reuses the single colorectal sealed map, its genes a subset), they're just not fetched. Read the current `_compute_module_ranking` and the modules UI component first. Airgap stays absolute; `pytest`/`tsc` after.
## 1. Flag + colour-code reference-set membership on EVERY module row (so no expanding needed)
- In `_compute_module_ranking`, resolve the **active dataset's reference sets** to opaque IDs ONCE (HNSC → `p16`={CDKN2A}, `cell_cycle`=the 20-gene set; CRC → `MMR`, `immune`). Reuse the existing reference→opaque resolution already used by `/diagnostic/full-rank` (its `reference_marks`) / the highlighted-genes table — don't re-implement. This is a bounded reveal of a known small set, not the whole map.
- For each module add `ref_sets: list[str]` = the reference-set names whose opaque IDs intersect that module's `gene_ids` (e.g. `["cell_cycle"]`, `["p16","cell_cycle"]`, or `[]`).
- Frontend modules table: on each **collapsed** row, render a small badge per matched set and tint the row using the existing three-way colour scheme (winner accent / p16 deep-gold / cell_cycle muted-amber — the same palette the highlighted-genes table uses). A module containing a p16 or cell_cycle gene must be scannable in the ranked list without expanding it.
- Airgap note: only a boolean membership (derived from the bounded reference reveal) crosses the wire here — no module gene NAMES are sent for the collapsed list.
## 2. Fix the missing symbols ("—") on expand
- The per-gene `symbol` is blank because module genes outside the already-revealed subset are never translated. When a module is **expanded**, reveal that module's `gene_ids` via the existing `/reveal` endpoint (bounded — only that module's ~2–5 genes) and show the symbol on each per-gene row. `g09647` should then read **LIG1**.
- Reveal **lazily, per expanded module only**. Do NOT reveal all modules' genes up front — there are ~2,900 modules and that would approach translating the whole map (airgap violation).
- Keep the per-gene single-gene AUROC / rank already returned; just add the revealed symbol alongside. Where a gene has no rank (not in the diagnostic series) leave its metric blank but still show its symbol.
## CONSTRAINTS
- Airgap: reference-membership flag = bounded reference-set reveal; per-module symbols = bounded on-expand reveal. Never translate the full map; the collapsed ranking stays opaque + scores + ref_sets booleans.
- No change to module harvesting, scoring, or sorting — purely additive (ref_sets field + lazy symbol reveal + row colouring).
## Checkpoint
- Collapsed module rows show a p16 / cell_cycle (or MMR / immune) badge and matching row tint wherever the module contains such a gene — visible without expanding.
- Expanding any module shows a symbol for every gene (e.g. LIG1), no "—".
- Ranking payload stays opaque + ref_sets booleans; symbols revealed only for expanded modules; airgap tests green; `tsc`/`pytest` clean.