fix: don't count mutations at masked sites towards branch length #1779
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 refine
has the mode--divergence-units mutations
in 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 isN
everywhere), 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.