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 was referenced Aug 6, 2026
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 processing.valid_coverage >= min_coverage, before offset aggregation.Severity
Severity: High — scientific correctness
Rationale: The accepted option previously had no effect, silently allowing excluded low-coverage records to change localized scientific counts and percentages.
Root cause
EntryLocalize::runassigned and loggedself.min_coveragebut did not pass it intoGenomeRegion::into_localized_mod_counts. The aggregation therefore folded every fetched bedMethyl row inton_validandn_modregardless of the requested threshold.Implementation
Pass the minimum coverage into localized counting and filter each bedMethyl record before aggregation using the inclusive predicate
valid_coverage >= min_coverage. The CLI regression uses two records that aggregate into the same output bin, with(valid coverage, modified count)values(1,1)and(23,2).Preserved behavior
Non-goals
--batch-sizebehavior.Behavior before and after
--min-coverage 1--min-coverage 3Testing
Test environment
57c61c561a44addafe04f9b44dfd6de01cff5f95e476b271f2bba441f9933c1894a16bf7b5d51096; clean at final verification5cecc3fb3a9336068d9e3c68d5c08d678153dd2c24 / 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_localizecargo 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.rs;git diff --checkThe serial workspace mode avoids an existing unrelated collision between pileup integration tests that share a temporary output filename.
Tests not performed
Scientific validation
valid_coverage >= min_coverage.(1,1)+(23,2)to(24,3); threshold 3 retains(23,2)only.Output and compatibility
Reviewer guide
GenomeRegion::into_localized_mod_counts.cargo test -p modkit --test test_localize test_localize_min_coverage_filters_before_aggregation -- --exact.cargo test -p modkit --test test_localizeas the affected integration canary.Checklist