Registry / data / tskit
library1.0.3pypypi✓ verified 85d ago

tskit is the tree sequence toolkit for storing, manipulating, and analyzing genealogical trees and genetic variation. Current version is 1.0.2. Originally developed in the TSKIT project, it has a slow release cadence with maintenance releases as needed. Requires Python >=3.11 since version 1.0.2.

pip install tskit
INSTALL
IMPORT
SIG · TSKIT
T
tskit
datapythonv1.0.3
Install
4.7s avg
Import
699ms
Disk
97MB
Pass rate
8/ 10
Env Coverage8 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 5.1s
py 3.11
✓ —
✓ 4.6s
py 3.12
✓ —
✓ 4.3s
py 3.13
✓ —
✓ 4.2s
py 3.9
✕ build_error
✓ 5.5s
97MB installed
● package 97MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tskit
import tskit
tskit is a single module; there is no subpackage import.

Simulate a small tree sequence with msprime and compute basic statistics.

import tskit import msprime # Simulate a tree sequence using msprime ts = msprime.simulate(10, length=1e4, recombination_rate=1e-8, random_seed=1) print(ts.num_trees) print(ts.num_samples) # Load a tree sequence from a file (if available) # ts = tskit.load('example.trees') # Basic statistics print(ts.diversity())
Debug
Known issues
breakingTreeSequence.tables now returns a zero-copy immutable view (since 1.0.0b3). To modify tables, use TreeSequence.dump_tables() first.
fix
Replace ts.tables with ts.dump_tables() if you need to mutate.
affects: >=1.0.0b3
deprecatedts.samples(population=...) now raises ValueError if the population ID is a string (e.g. population name) instead of silently returning no samples (since 1.0.1).
fix
Use population IDs (integers) or map names to IDs first.
affects: >=1.0.1
gotchaMutation parents must be consistent with tree topology. Invalid mutation parent relationships cause LibraryError when constructing TreeSequence from tables.
fix
Ensure mutation.parent column is valid (parent mutation must occur at an earlier position or same position and be an ancestor in the tree).
affects: >=1.0.0b1
gotchaWhen writing VCF with individuals, default node filtering changed: non-sample nodes from individuals are now excluded by default (since 0.6.4). Use include_non_sample_nodes=True to include them.
fix
If you need non-sample nodes, pass include_non_sample_nodes=True to write_vcf().
affects: >=0.6.4
Errors
Common errors & fixes
AttributeError: module 'tskit' has no attribute 'load'
You typed tskit.load instead of tskit.load. The correct function is tskit.load (lowercase L).
fix
Use tskit.load('file.trees')
_tskit.LibraryError: Bad mutation parent
Mutation parent inconsistencies: parent mutation is not ancestral to child mutation at the same site or has a different position.
fix
Check and correct mutation.parent column in tables. Ensure parent mutation appears earlier in the mutation table or is a valid ancestor.
ValueError: The population ID must be an integer, not a string
Passing a population name string to ts.samples(population='pop_name')
fix
Use integer IDs: population_id = ts.population('pop_name').id or set population=0.
ValueError: The number of nodes does not match
Attempting to load a tree sequence from tables with missing or extra nodes (e.g., node table not sorted correctly).
fix
Ensure node table has the correct number of nodes and that edges reference existing nodes.
Upgrade
Version history
1.0.3latest on PyPI · released May 14, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
42 hits · last 30 days
node
38
OpenAI (training)
1
Resources
tskit — pip install tskit · libregistry