Repository navigation
fix(duplex-metrics): pair duplex UMI halves by /A,/B strand family - #1031
Conversation
duplex-metrics oriented each read's RX halves by R1 strand before calling the per-position UMI consensus. For a duplex whose mates map in the same orientation (FF/RR: inversions and most inter-chromosomal chimeras), R1 is on the same strand in both the /A and /B families, so the /B reads were left unswapped and the two halves were mixed into one consensus (e.g. AAA with CAG -> NAN). This inflated raw_observations_with_errors and invented N-containing UMIs in umi_counts.txt, and corrupted the duplex UMI key in duplex_umi_counts.txt. Pair the halves by the MI /A,/B suffix, as fgbio does per single-strand family (CollectDuplexSeqMetrics.scala:407-408), and keep orienting the reported duplex UMI by R1 strand (DXM-02).
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.
WalkthroughDuplex metrics now pair UMI halves by MI suffix and select reported orientation using R1 strand information. Test fixtures support mates on different references, and new tests cover duplex UMI accounting across read orientations and inter-chromosomal pairs. ChangesDuplex UMI metrics
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The duplex UMI pairing change has no identified issue requiring a fix before merge. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Comment |
|
@coderabbitai pause |
✅ Action performedReviews paused. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1031 +/- ##
==========================================
- Coverage 96.47% 96.45% -0.03%
==========================================
Files 299 299
Lines 152214 152273 +59
==========================================
+ Hits 146854 146880 +26
- Misses 5360 5393 +33 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary of changes
duplex-metricsoriented each read'sRXhalves by R1 strand before calling the per-position UMI consensus. For a duplex whose mates map in the same orientation (FF/RR: inversions and most inter-chromosomal chimeras), R1 is on the same strand in both the/Aand/Bfamilies, so the/Breads were left unswapped and the two halves were mixed into one consensus.Before: a single FF duplex family with
AAA-CAG/A+CAG-AAA/Bproducedumi_counts.txt=NAN 4 raw / 4 with errors / 2 uniqueandduplex_umi_counts.txt=NAN-NAN. This inflatesraw_observations_with_errorsand invents N-containing UMIs (most visible with short UMIs).After:
AAAandCAG, each2 raw / 0 with errors / 1 unique, and a single duplex UMIAAA-CAG.The fix pairs the halves by the MI
/A,/Bstrand family (an unsuffixed MI is treated as/A, matching the existing AB-strand counting), as fgbio does per single-strand family (CollectDuplexSeqMetrics.scala:407-408). The reported duplex UMI induplex_umi_counts.txtis still oriented by R1 strand (DXM-02), leading with the half a positive-strand R1 reads first.Family-size, yield, grouping and consensus outputs are unaffected. FR/RF pairs produce identical output to before.
Issue(s) addressed by this PR
No separate issue; the bug is described above.
Reviewer guidance
record_duplex_umi_metrics/record_duplex_coordinate_groupinsrc/lib/commands/shared_metrics.rs. That function is shared by the standaloneduplex-metricscommand and the inline consensus-metrics path, so both get the fix. It now receives&TemplateMetadata(which already carriesis_b_strand) instead of an(mi, rx, r1_positive)tuple, so the strand classification is not re-derived.duplex_umi_counts.txtdepends on which single-strand familygroupBy(MI)iterates first (JVM hash order of the MI strings). fgumi deterministically leads with the/Aleading half for FF and the/Atrailing half for RR. A probe of 300 synthetic molecules per orientation against fgbio 4.1.0 showedumi_counts.txtandduplex_family_sizes.txtidentical for FR/RF/FF/RR, andduplex_umi_counts.txtidentical for FR/RF; for FF/RR about half the duplex UMI keys are reported in the opposite orientation, as expected from the above.test_duplex_umi_halves_paired_by_strand_family(FR, RF, FF, RR, and inter-chromosomal FF/RR; the FF/RR cases fail onmain) andtest_duplex_umi_orientation_of_b_only_family(pins the/B-only orientation branches). The test helperbuild_test_pairnow delegates tobuild_test_pair_on_refsso mates can sit on different references.Does this introduce a breaking change?
✔️ Checklist
README.mdanddocs/*)