Repository navigation
Support per-source recombination rates in matching - #1208
Merged
Merged
Conversation
The matching HMM used a constant recombination probability for every pair of adjacent sites, with no way to account for distance between sites or a varying genetic map. Port recombination_rate from tsinfer 0.5.1, without mismatch_ratio, as a per-source match parameter. - [match.sources.<name>] accepts recombination_rate, either a constant rate per bp or the path to a HapMap genetic map. Genetic distances between adjacent inference sites are converted to probabilities with Haldane's map function. It cannot be combined with recombination. - likelihood_threshold is passed through to the matcher, and the existing recombination and mismatch keys are documented. - The mismatch probability is set directly; it is not derived from the recombination rate. - HMM parameters are computed once per source in match() and passed to Matcher, so map files are not re-read for each group.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1208 +/- ##
==========================================
+ Coverage 92.59% 92.66% +0.07%
==========================================
Files 16 16
Lines 4845 4910 +65
Branches 766 783 +17
==========================================
+ Hits 4486 4550 +64
Misses 254 254
- Partials 105 106 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
added 2 commits
October 28, 2026 13:17
Add dedicated tests for read_genetic_map and recombination_probabilities covering nominal values, corner cases (map flanks, single-row maps, zero rate regions, empty site arrays, int32 extremes, saturation at 0.5) and randomised comparisons against msprime.RateMap as an oracle. Writing these showed that malformed input was silently accepted, so read_genetic_map now raises ValueError for an empty map, positions that are not strictly increasing, or a decreasing map column, and a negative constant recombination rate is rejected. Previously these gave an IndexError, wrong interpolated positions, or negative probabilities.
test_constant_rate_matches_rate_map failed on macOS CI. The msprime oracle computes distances by differencing cumulative masses of up to ~1, losing ~1e-16 in absolute terms, which is a large relative error for small distances. Use atol=1e-15 as in the other oracle comparisons.
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.
The matching HMM used a constant recombination probability for every pair of adjacent sites, with no way to account for distance between sites or a varying genetic map. Port recombination_rate from tsinfer 0.5.1, without mismatch_ratio, as a per-source match parameter.
This is an interrim API; the full API will be reviewed later on when all the functionality is complete.
Closes #1199