Repository navigation
Support multiple alleles and mutations per site - #1200
Merged
Merged
Conversation
Port the multi-allele support from the tsls copy of the HMM engine. matcher_indexes_alloc now takes optional per-site ancestral state and per-mutation derived state arrays (defaulting to 0 and 1), and sites may carry multiple mutations, with later mutations in tskit order taking precedence. The Python MatcherIndexes wrapper gains an alleles argument that encodes states via the new encode_alleles function.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1200 +/- ##
==========================================
+ Coverage 91.55% 91.64% +0.09%
==========================================
Files 16 16
Lines 4651 4716 +65
Branches 740 751 +11
==========================================
+ Hits 4258 4322 +64
+ Misses 281 280 -1
- Partials 112 114 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Matcher now takes the AlleleMapper and encodes each mutation's derived state in the reference tree sequence to its per-site allele code, so the HMM sees the correct allele for multiallelic sites and for back mutations to the ancestral state. Previously every mutation was treated as derived state 1. Genotype roundtrip checks now include multiallelic inference sites, with new JC69 simulations including samples matched in two groups.
infer_ancestors previously collapsed all derived alleles to code 1, so ancestors at multiallelic sites represented "not ancestral" and were labelled with the first derived allele, and sites whose ancestral allele was absent from the data were silently dropped. It now raises a ValueError naming the site when any ancestor-source genotype is not 0, 1 or missing. Sites with an unknown ancestral allele are skipped with a log message. Multiallelic data remains supported at the matching stage, where samples not used for ancestor generation can carry other alleles. Tests cover the error cases and these matching scenarios (separate sources, sample subsets of one store, simulated data); simulation helpers now default to biallelic mutations.
jeromekelleher
enabled auto-merge
October 16, 2026 12:44
jeromekelleher
disabled auto-merge
October 16, 2026 12:44
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.
Closes #1186