{"id":24739,"library":"tskit","title":"tskit","description":"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.","status":"active","version":"1.0.2","language":"python","source_language":"en","source_url":"https://github.com/tskit-dev/tskit/","tags":["tree-sequence","population-genetics","coalescent","genealogy"],"install":[{"cmd":"pip install tskit","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"tskit is a single module; there is no subpackage import.","symbol":"tskit","correct":"import tskit"}],"quickstart":{"code":"import tskit\nimport msprime\n\n# Simulate a tree sequence using msprime\nts = msprime.simulate(10, length=1e4, recombination_rate=1e-8, random_seed=1)\nprint(ts.num_trees)\nprint(ts.num_samples)\n\n# Load a tree sequence from a file (if available)\n# ts = tskit.load('example.trees')\n\n# Basic statistics\nprint(ts.diversity())","lang":"python","description":"Simulate a small tree sequence with msprime and compute basic statistics."},"warnings":[{"fix":"Replace ts.tables with ts.dump_tables() if you need to mutate.","message":"TreeSequence.tables now returns a zero-copy immutable view (since 1.0.0b3). To modify tables, use TreeSequence.dump_tables() first.","severity":"breaking","affected_versions":">=1.0.0b3"},{"fix":"Use population IDs (integers) or map names to IDs first.","message":"ts.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).","severity":"deprecated","affected_versions":">=1.0.1"},{"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).","message":"Mutation parents must be consistent with tree topology. Invalid mutation parent relationships cause LibraryError when constructing TreeSequence from tables.","severity":"gotcha","affected_versions":">=1.0.0b1"},{"fix":"If you need non-sample nodes, pass include_non_sample_nodes=True to write_vcf().","message":"When 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.","severity":"gotcha","affected_versions":">=0.6.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use tskit.load('file.trees')","cause":"You typed tskit.load instead of tskit.load. The correct function is tskit.load (lowercase L).","error":"AttributeError: module 'tskit' has no attribute 'load'"},{"fix":"Check and correct mutation.parent column in tables. Ensure parent mutation appears earlier in the mutation table or is a valid ancestor.","cause":"Mutation parent inconsistencies: parent mutation is not ancestral to child mutation at the same site or has a different position.","error":"_tskit.LibraryError: Bad mutation parent"},{"fix":"Use integer IDs: population_id = ts.population('pop_name').id or set population=0.","cause":"Passing a population name string to ts.samples(population='pop_name')","error":"ValueError: The population ID must be an integer, not a string"},{"fix":"Ensure node table has the correct number of nodes and that edges reference existing nodes.","cause":"Attempting to load a tree sequence from tables with missing or extra nodes (e.g., node table not sorted correctly).","error":"ValueError: The number of nodes does not match"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}