fix: don't count mutations at masked sites towards branch length#1779
Merged
fix: don't count mutations at masked sites towards branch length#1779
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1779 +/- ##
==========================================
+ Coverage 73.21% 73.23% +0.02%
==========================================
Files 79 79
Lines 8395 8402 +7
Branches 1713 1715 +2
==========================================
+ Hits 6146 6153 +7
Misses 1960 1960
Partials 289 289 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Adds a functional test for augur refine's behavior when one or more columns in the alignment are all Ns. In this case, the columns should get ignored in the final branch length calculations as ambiguous positions. This test adds an alternate version of the Zika alignment and the expected branch lengths JSON where the third column of the alignment has been changed to all Ns. Since this column originally had a variant in one sample that would have changed the overall branch lengths, this change produces different a node data JSON output with a shorter branch length.
Adds a comment to clarify why we can break from the loop through all positions in TreeTime's compressed alignment data structure. For people who are not familiar with that data structure, the appearance of a break in the for loop could appear to be a bug.
Member
Author
|
Thanks, @huddlej |
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.
augur refinehas the mode--divergence-units mutationsin which case branch length are given as number of mutations in an ancestral reconstruction. We ignore gaps and ambiguous sites in this calculation as we should, but in the edge case when there is no information at all (site isNeverywhere), we count a large number of spurious mutations. This happens when the root state is picked by from the probability distribution at random, and other states are set to the most likely state. @corneliusroemer discovered this in the case of mpox where about 10k sites are masked. The probability distribution for these 10k states in[0.2, 0.2, 0.2, 0.2, 0.2]. The root was picked at random, other states vianp.argmax([0.2, 0.2, 0.2, 0.2, 0.2]). If these differed, this generated 10k unwanted mutations.This PR excludes those sites from the branch length calculation. A list of all these sites is anyway available within treetime.