Skip to content

Tsls integration - #637

Merged
jeromekelleher merged 5 commits into
mainfrom
tsls-integration
Oct 30, 2026
Merged

jeromekelleher merged 5 commits into
mainfrom
tsls-integration

Conversation

@jeromekelleher

Copy link
Copy Markdown
Member

No description provided.

Jerome Kelleher added 5 commits October 30, 2026 13:44
Replace tsinfer's TreeSequenceBuilder and AncestorMatcher with the tsls
HMM, and drop the tsinfer dependency.

- tsls matches against the tree sequence directly, with the alleles
  ACGT- (indexed as in core.IUPAC_ALLELES), so the site-index coordinate
  map is gone and paths are in genome coordinates.
- sc2ts's model, in which a recombination costs k mismatches, is tsls's
  model with r = tsls.model.recombination_probability(rho, n). With
  deletions as missing data, the mismatch probability for 5 alleles has
  the odds of mu with 4.
- The matching passes use exact prune thresholds (cost_threshold, from
  tsls.model.path_threshold), so a match costing at most the pass's
  bound is optimal. The first two passes of match_samples bound the cost
  by k + 1, the cost they accept; the final pass by the cost of the
  previous match.
- tsls can copy the vestigial root, node 0, which ties with the
  reference, node 1, so paths copy node 1 wherever tsls copies node 0
  (check_vestigial_root, copy_node1_for_node0).
- characterise_recombinants finds the interval between the sites where
  the parents differ on either side of a breakpoint, wherever the
  breakpoint is in it, as tsls doesn't specify where it places a switch
  among equally likely positions.
- match_tsinfer is renamed match_tsls.

All test results are unchanged. The ARGs that the test fixtures build
are identical up to 2020-02-11; on 2020-02-13 one sample has a different
match of the same cost (four mutations, parent 47 rather than 39), which
changes metadata but not the topology.

tsls is a dependency from GitHub until it's released. The lockfile needs
to be regenerated once tsls's main branch has the new layout.
tests/test_tsls_contract.py calls tsls with the parameters that sc2ts
computes, so that changes in tsls that would break sc2ts are caught:
the allele encoding, including deletions and missing data; the tie
between the vestigial root and the reference; isolated (future) nodes
not being copied; one recombination costing k mismatches, with and
without deletions as missing data; the exactness of the cost
thresholds; the path format; and sharing a tsls tree sequence between
threads.
tsls now exports its whole API from the tsls namespace, rather than
from tsls.model.
tsls's main branch now has the version sc2ts uses (a32ce06). tsinfer
and the dependencies only it needed (daiquiri, lmdb, sortedcontainers
and others) are no longer locked.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.92308% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.72%. Comparing base (0a01e09) to head (26f4315).

Files with missing lines Patch % Lines
sc2ts/inference.py 96.92% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #637      +/-   ##
==========================================
+ Coverage   88.64%   88.72%   +0.08%     
==========================================
  Files          12       12              
  Lines        4323     4336      +13     
  Branches      622      624       +2     
==========================================
+ Hits         3832     3847      +15     
+ Misses        362      361       -1     
+ Partials      129      128       -1     
Flag Coverage Δ
python-tests 88.72% <96.92%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jeromekelleher

Copy link
Copy Markdown
Member Author

According to the benchmarks here this should be a major performance improvement for sc2ts, dropping the time and memory required for difficult matches by 10X or more.

@jeromekelleher
jeromekelleher merged commit 5737fdf into main Oct 30, 2026
9 checks passed
@jeromekelleher
jeromekelleher deleted the tsls-integration branch October 30, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants