Exclude unmapped calls from CpG summaries - #650
Open
SuhasSrinivasan wants to merge 1 commit into
Open
Conversation
SuhasSrinivasan
marked this pull request as ready for review
August 5, 2026 05:56
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.
Fixes #649.
Summary
summary --cpgresults, matching the documented--motif CG 0behaviorRoot cause and impact
The indexed summary path correctly constructs a
CGmotif for--cpg, but the later guard that skips unmapped-record collection checked onlymapped_only,matched_only, and an explicitmotif. Because the CpG shorthand flag was omitted, all unmapped modification calls were merged into the mapped reference-CpG histogram.On the mapped-plus-unmapped fixture from #649, modkit 0.6.4 reports 20 reads and 186 C calls under
--cpg, versus 10 reads and 77 calls under--motif CG 0. With this change, both forms report the same scientific counts.Regression
The test copies the existing 10 mapped test records and appends an unmapped
CCCCrecord with:MM:Z:C+m?,0,0,0,0;MN:i:4It runs the actual CLI, normalizes TSV key/value ordering, and requires the mixed result to equal the mapped-only control with
total_reads_used=10,count_reads_C=10, andC_total_mod_calls=77.Validation
total_reads_usedis11instead of10cargo test -p modkit --test test_summary test_summary_cpg_excludes_unmapped_calls -- --exactcargo test -p modkit --test test_summary(5passed)cargo test -p modkit --test test_pileup -- --test-threads=1(16passed,10ignored)cargo test --workspace --quiet -- --test-threads=1rustfmt --check --edition 2021 modkit-core/src/modbam_util/subcommands.rs modkit/tests/test_summary.rsgit diff --check20 / 186becomes10 / 77and matches explicit--motif CG 0An initial default-parallel package run exposed an existing integration-test collision:
test_pileup_no_filtandtest_pileup_with_headerboth write/tmp/test_pileup_nofilt.bed. The pileup target and full workspace pass when run serially; this branch does not touch pileup.