Skip to content

fix(import-rna): wire --diploid-parx-genome and make it effective#1108

Merged
etal merged 1 commit into
masterfrom
fix-cnvkit-d68-import-rna-diploid-parx-genome
Jun 15, 2026
Merged

fix(import-rna): wire --diploid-parx-genome and make it effective#1108
etal merged 1 commit into
masterfrom
fix-cnvkit-d68-import-rna-diploid-parx-genome

Conversation

@etal

@etal etal commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

The import-rna command accepted no --diploid-parx-genome flag, so the pseudo-autosomal-region-aware re-centering already implemented in do_import_rna was unreachable from the command line. This change registers the shared flag on the import-rna parser and forwards args.diploid_parx_genome into the do_import_rna call.

Wiring the flag alone is insufficient. cnvlib/rna.py:correct_cnr applies GC- and transcript-length window correction (enabled by default), which is invariant to a uniform pre-shift of the log2 values. The first center_all(diploid_parx_genome=...) only changes a global centering constant; that contribution is absorbed by the window correction and then overwritten by a second, unconditional center_all() that omitted the flag. As a result, the flag changed output only under --no-gc --no-txlen. The second center_all now also carries diploid_parx_genome, so PAR-aware centering takes effect on the default path.

Clinical impact

Enabling --diploid-parx-genome changes chromosome-X / PAR log2 output for the named genome (e.g. grch38). The default path — flag omitted, diploid_parx_genome=None — is bit-exact with prior output, since center_all(None) resolves to autosomes(None) exactly as before. No change to .cnr output for existing default invocations.

Tests

  • DiploidParxPlumbingTests — AST-level guards that _cmd_import_rna forwards diploid_parx_genome to do_import_rna, that the CLI registers --diploid-parx-genome, and that the signature default is None. 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_all fix), and is inert when no PAR bins are present (confirming it touches only PAR-X).

Full suite: 457 passed. ruff and mypy clean.

Docs

New "Pseudo-autosomal regions on chromosome X" subsection in doc/rna.rst.

Closes cnvkit-d68.

🤖 Generated with Claude Code

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

codecov Bot commented Jun 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.76%. Comparing base (849a32b) to head (ff4edf6).

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           
Flag Coverage Δ
unittests 70.76% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@etal etal merged commit fc65941 into master Jun 15, 2026
13 checks passed
@etal etal deleted the fix-cnvkit-d68-import-rna-diploid-parx-genome branch June 15, 2026 07:04
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