Label only requested genes in scatter -g, not co-binned neighbors (gh#458)#1078
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1078 +/- ##
=======================================
Coverage 67.81% 67.81%
=======================================
Files 74 74
Lines 7686 7686
Branches 1366 1366
=======================================
Hits 5212 5212
Misses 2034 2034
Partials 440 440
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…#458)
CNVkit stores gene annotation inside each bin's `gene` column rather than
separately, so a single bin label can pack several genes (e.g.
"ERBB2,MIR4728"). gene_coords_by_name() matched bins by the requested
name correctly, but then reconstructed each region's label from the union
of *all* gene names found in those bins -- surfacing co-binned neighbors
the user never asked for. Hence `scatter -c chr17:... -g ERBB2` also
labeled MIR4728, contradicting the documented behavior in doc/plots.rst
("Any other genes ... will not be shown unless also specified with -g").
Restrict the reconstructed label to the requested names. When multiple
genes are requested and share bins, all requested names still appear.
Plotting-label fix only; no change to .cnr/.cns/.cnn/SEG/VCF output.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
f47b2d3 to
c9d5845
Compare
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.
Summary
cnvkit scatter -c chr17:37850000-37890000 -g ERBB2also labeled MIR4728 — a gene the user never requested — contradicting the documented behavior (doc/plots.rst: "Any other genes in the plotted region will not be shown unless also specified with -g").Root cause
CNVkit stores gene annotation inside each bin's
genecolumn rather than as a separate track, so one bin label can pack several comma-joined genes (e.g."ERBB2,MIR4728"). Incnvlib/plots.py::gene_coords_by_name, bins were selected correctly by the requested name, but the region's label was then reconstructed from the union of all gene names appearing in those bins — leaking co-binned neighbors.Fix
Restrict the reconstructed label to the requested names:
When several genes are requested and happen to share bins, all requested names still appear. Because every selected bin necessarily contains the requested
name, no region can become unlabeled.Tests
CNATests::test_gene_coords_by_name(intest/test_cnvlib.py): asserts-g ERBB2against a bin labeled"ERBB2,MIR4728"yields onlyERBB2, and that requesting both names surfaces both. The test fails against the old code ('ERBB2,MIR4728' != 'ERBB2') and passes with the fix.test_cnvlib.py(30) andtest_commands.py(73) pass;mypyandruffclean.Notes
.cnr/.cns/.cnn/SEG/VCF output, so no impact on downstream clinical pipelines.Closes #458.
🤖 Generated with Claude Code