Apply localize minimum coverage before aggregation - #652
Open
SuhasSrinivasan wants to merge 1 commit into
Open
Conversation
SuhasSrinivasan
marked this pull request as ready for review
August 5, 2026 06:09
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 #651.
Summary
--min-coverageinto localize record processingvalid_coverage >= min_coverage, before offset aggregationRoot cause and impact
EntryLocalize::runassigned and loggedself.min_coverage, but did not pass it intoGenomeRegion::into_localized_mod_counts. The aggregation therefore folded every fetched bedMethyl row inton_validandn_mod, regardless of the requested threshold.Filtering must happen per bedMethyl record before aggregation. Applying the threshold after summing offsets would allow multiple individually under-covered loci to combine and pass.
Regression
The test uses two records from the existing indexed bedMethyl resource that localize to the same output bin:
At
--min-coverage 1, the exact aggregate remains 24 valid / 3 modified / 12.5%. At--min-coverage 3, the first record is excluded and the exact result is 23 valid / 2 modified / 8.695652%.Validation
24 / 3 / 12.5instead of23 / 2 / 8.695652cargo test -p modkit --test test_localize test_localize_min_coverage_filters_before_aggregation -- --exactcargo test -p modkit --test test_localize(2passed)cargo test --workspace --quiet -- --test-threads=1rustfmt --check --edition 2021 modkit-core/src/localise/subcommand.rs modkit-core/src/localise/util.rs modkit/tests/test_localize.rsgit diff --checkThe serial workspace mode avoids an existing unrelated collision between pileup integration tests that share a temporary output filename.