feat: regional-plot backend (cis_associations, ld_r2, JSON endpoints)#25
Open
boxiangliu wants to merge 3 commits into
Open
feat: regional-plot backend (cis_associations, ld_r2, JSON endpoints)#25boxiangliu wants to merge 3 commits into
boxiangliu wants to merge 3 commits into
Conversation
Backend half of the LocuszoomZ-style regional plot (design in #23). No UI yet — the Plotly frontend waits for Liu Fei's design sign-off. - repository.py: cis_associations() (all cis variants for a gene in one tissue), ld_r2() (r² to a lead from the 1000G LD tables; symmetric-pair UNION, rsID<->int bridge, NA/non-rs skipping), tissues_with_signal() (drives the future body map); _ld_table() with chrom/pop whitelists. - viz.py: frozen LocusZoom LD color scheme (r2_color / ld_legend) + neg_log10_p. - web.py: GET /api/gene/{key}/regional (variants + r² to default lead) and GET /api/ld (r² map for click-to-recolor). - 100% coverage, mypy strict. Verified live: TP53 -> 5442 variants + r² in ~0.5s. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 6, 2026
Closes #27. Wires the #25 backend into the gene page as a LocusZoom-style Plotly plot, styled to Liu Fei's mockup (#23). - gene.html: blue/slate palette; tissue + LD-population selectors; a Plotly scattergl of position vs −log10(p) colored by r² (first paint from /api/gene/{key}/regional); click a point to re-pick the lead (/api/ld, client-side re-color); genome-wide-significance line; LD legend + caveat. - viz.py: lead marker -> orange #f97316 (per Liu Fei), was purple. - web.py: gene page passes the tissue list to the selector. - Template-render tested; 100% coverage. Verified live: /gene/TP53 renders the plot UI with 25 real tissues. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
feat: regional plot frontend — Plotly Locus View on the gene page (#27)
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
The backend for the LocusZoom-style regional plot (design: #23 /
docs/design/gene-page-visualizations.md). No UI — the Plotly frontend waits for the design sign-off.repository.py:cis_associations(all cis variants for a gene × tissue),ld_r2(r² to a lead from the 1000G LD tables — symmetric-pair UNION, rsID↔int bridge, skips non-rs/NA),tissues_with_signal(for the future body map);_ld_tablewith chrom/population whitelists.viz.py: frozen LocusZoom LD color scheme +−log₁₀(p)helper.web.py:GET /api/gene/{key}/regionalandGET /api/ld.Why
Pure data plumbing, no design decisions → safe to build while Liu Fei reviews the design. When she signs off, wiring the Plotly frontend is quick.
How it was tested
ruff/mypy --strict/pytestgreen; 100% coverage; hermetic (fake repo + fake DB connection). Verified live (read-only): TP53 → 5,442 variants with r² to the lead in ~0.5s; the/api/gene/.../regionalendpoint returns correctly (LD partners coloured, non-partners grey = no-LD).Note re the LD index (issue for @gaojunbin)
The design flagged a covering index as a perf need, but the live LD query ran in 0.2s without it — so it's a nice-to-have, not urgent.
Checklist