fix(import-rna): wire --diploid-parx-genome and make it effective#1108
Merged
Conversation
The import-rna CLI accepted no --diploid-parx-genome flag, so PAR-aware re-centering (already supported by do_import_rna) was unreachable from the command line. Register the shared flag on P_import_rna and forward args.diploid_parx_genome into the do_import_rna call. Wiring the flag alone is insufficient: correct_cnr applies GC/transcript- length window correction (on by default), which is invariant to a uniform pre-shift. The first center_all(diploid_parx_genome=...) only changes a global centering constant, so its effect is absorbed by the bias correction and then overwritten by a second, unconditional center_all() that omitted the flag. The net result was that the flag changed output only under --no-gc --no-txlen. Propagate diploid_parx_genome to the second center_all so PAR-aware centering takes effect in the default path. Clinical impact: enabling --diploid-parx-genome now changes chrX/PAR log2 for the named genome (e.g. grch38). The default (flag omitted / None) path is bit-exact with prior output, since center_all(None) calls autosomes(None) as before. Tests (test/test_rna.py): - DiploidParxPlumbingTests: AST guard that _cmd_import_rna forwards diploid_parx_genome to do_import_rna; CLI registers --diploid-parx-genome; signature default is None. - DiploidParxCenteringTests: the flag shifts PAR centering under the default GC/txlen corrections (guards the second-center_all fix); the flag is inert when no PAR bins are present, confirming it touches only PAR-X. Docs: new "Pseudo-autosomal regions on chromosome X" subsection in doc/rna.rst. Closes cnvkit-d68. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1108 +/- ##
=======================================
Coverage 70.75% 70.76%
=======================================
Files 73 73
Lines 7951 7952 +1
Branches 1407 1407
=======================================
+ Hits 5626 5627 +1
Misses 1881 1881
Partials 444 444
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
The
import-rnacommand accepted no--diploid-parx-genomeflag, so the pseudo-autosomal-region-aware re-centering already implemented indo_import_rnawas unreachable from the command line. This change registers the shared flag on theimport-rnaparser and forwardsargs.diploid_parx_genomeinto thedo_import_rnacall.Wiring the flag alone is insufficient.
cnvlib/rna.py:correct_cnrapplies GC- and transcript-length window correction (enabled by default), which is invariant to a uniform pre-shift of the log2 values. The firstcenter_all(diploid_parx_genome=...)only changes a global centering constant; that contribution is absorbed by the window correction and then overwritten by a second, unconditionalcenter_all()that omitted the flag. As a result, the flag changed output only under--no-gc --no-txlen. The secondcenter_allnow also carriesdiploid_parx_genome, so PAR-aware centering takes effect on the default path.Clinical impact
Enabling
--diploid-parx-genomechanges chromosome-X / PARlog2output for the named genome (e.g.grch38). The default path — flag omitted,diploid_parx_genome=None— is bit-exact with prior output, sincecenter_all(None)resolves toautosomes(None)exactly as before. No change to.cnroutput for existing default invocations.Tests
DiploidParxPlumbingTests— AST-level guards that_cmd_import_rnaforwardsdiploid_parx_genometodo_import_rna, that the CLI registers--diploid-parx-genome, and that the signature default isNone. These fail at collection if the kwarg is dropped, at no fixture cost.DiploidParxCenteringTests— behavior tests on an hg38-style fixture: the flag shifts PAR centering under the default GC/txlen corrections (guarding the second-center_allfix), and is inert when no PAR bins are present (confirming it touches only PAR-X).Full suite: 457 passed.
ruffandmypyclean.Docs
New "Pseudo-autosomal regions on chromosome X" subsection in
doc/rna.rst.Closes cnvkit-d68.
🤖 Generated with Claude Code