Fix wrong denominator in max_missing_an fraction filter (closes #998)#1000
Merged
jonbrenas merged 4 commits intomalariagen:masterfrom Mar 2, 2026
Merged
Conversation
Contributor
Author
|
@jonbrenas hey 👋 can you please review this |
jonbrenas
approved these changes
Mar 2, 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.
What
When
max_missing_anis passed as a float, the missingness fraction was computed by dividing byan(called alleles) instead of total alleles. This made the filter consistently more restrictive than intended.Why it's wrong
A SNP with exactly 5% missing data in 100 diploid samples (10 missing out of 200 total) would compute
10 / 190 = 0.0526and fail amax_missing_an=0.05threshold — even though 5% ≤ 5% should pass. At high missingness levels the formula produces values greater than 1.0, which is not a valid fraction.Change
Before:
After:
I also updated the tests for
tests/anoph/test_snp_data.pyNotes
max_missing_anasint) is unaffected.min_minor_acfloat path below this usesan(called alleles) as denominator which is correct for allele frequency — that path is unchanged.closes #998