Changelogs#
Python#
[1.0.0b3] - 2025-10-15#
Breaking Changes
TreeSequence.tablesnow returns a zero-copy immutable view of the tables. To get a mutable copy, useTreeSequence.dump_tables(). (@benjeffery, #3288, #760)For a tree sequence to be valid mutation parents in the table collection must be correct and consistent with the topology of the tree at each mutation site.
TableCollection.tree_sequence()will raise a_tskit.LibraryErrorif this is not the case. (@benjeffery, #2729, #2732, #3212).Drop Python 3.9 support, require Python >= 3.10 (#3267, @benjeffery)
Features
Add
tskit.jit.numba.jitwrapandNumbaTreeSequenceto allow simplified use and development of numba-jitted functions with tree sequences. See the documentation for details. (@andrewkern, #3295, #3294)TreeSequence.map_to_vcf_modelnow also returns the transformed positions and contig length. (@benjeffery, #3174, #3173)draw_svg()methods now associate tree branches with edge IDs (@hyanwong, #3193, #557)draw_svg()methods now allow the y-axis to be placed on the right-hand side usingy_axis="right"(@hyanwong, #3201)Add
contig_idandisolated_as_missingtoVcfModelMapping(@benjeffery, #3219, #3177)Add
TreeSequence.mutations_edgewhich returns the edge ID for each mutation’s edge. (@benjeffery, #3226, #3189)Add
TreeSequence.sites_ancestral_state,TreeSequence.mutations_derived_stateandTreeSequence.mutations_inherited_stateproperties to return the ancestral state of sites, derived state of mutations and inherited state of mutations as NumPy arrays of the new numpy 2.0 StringDType. (@benjeffery, #3228, #2632, #3276, #2631)Tskit now distributes with a requirement of numpy version 2 or greater. However, you can still use tskit with numpy 1.X by building tskit from source with numpy 1.X using
pip install tskit --no-binary tskit. With numpy 1.X, any use of the new StringDType properties will result in aRuntimeError. If you try to use another python module that was compiled against numpy 1.X with numpy 2.X you may see the error “A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.0 as it may crash.”. If no newer version of the module is available you will have to use the Numpy 1.X build as above.Add
Mutation.inherited_stateproperty which returns the inherited state for a single mutation. (@benjeffery, #3277, #2631)Add
all_mutationsandall_edgesoptions toTreeSequence.union, allowing greater flexibility in “disjoint union” situations. (@hyanwong, @petrelharp, #3181)
Bugfixes
In some tables with mutations out-of-order
TableCollection.sortdid not re-order the mutations so they formed a valid TreeSequence.TableCollection.sortandTableCollection.canonicalisenow sort mutations by site, then time (if known), then the mutation’s node’s time, then number of descendant mutations (ensuring that parent mutations occur before children), then node, then their original order in the tables. (@benjeffery, #3257, #3253)- Fix bug in
TreeSequence.genetic_relatedness_vectorthat previously ignored span_normalise: previously,span_normalisewas always set toFalse; now the default isTruein agreement with other statistics, so the returned values will change. (@petrelharp, #3300, #3241)
- Fix bug in
Fix bug in
TreeSequence.pair_coalescence_countswhenspan_normalise=Trueand a window breakpoint falls within an internal missing interval. (@nspope, #3176, #3175)Fix metadata schemas that are equal but have different byte representations not being equal when using
TableCollection.assert_equalsandTable.assert_equals. (@benjeffery, #3246, #3244)k-way statistics no longer require k sample sets, allowing in particular “self” comparisons for
TreeSequence.genetic_relatedness. This changes the error code returned in some situations. (@andrewkern, @petrelharp, #3235, #3055)Fix
UnboundLocalErrorindraw_svg()when using numericmax_timevalues with mutations over roots. (@benjeffery, #3274, #3273)Prevent iterating over a
TopologyCounter(@benjeffery , #3202, #1462)Fix
TreeSequence.concatenate()to work with internal samples by using theall_mutationsandall_edgesparameters inunion()(@hyanwong, #3283, #3181)
Breaking changes
[0.6.4] - 2025-05-21#
Features
Add
TreeSequence.sample_nodes_by_ploidymethod to return the sample nodes in a tree sequence, grouped by a ploidy value. (@benjeffery, #3157)Add
TreeSequence.individuals_nodesattribute to return the nodes associated with each individual as a numpy array. (@benjeffery, #3153)Add
shiftmethod to bothTableCollectionandTreeSequenceclasses allowing the coordinate system to be shifted, andTreeSequence.concatenateso a set of tree sequence can be added to the right of an existing one. (@hyanwong, #3165, #3164)Add
TreeSequence.map_to_vcf_modelmethod to return a mapping of the tree sequence to the VCF model. (@benjeffery, #3163)Use a thin space as the thousands separator in HTML output, and a comma in CLI output. (@hossam26644, #3167, #2951)
Fixes
Correct assertion message when tables are compared with metadata ignored. (@benjeffery, #3162, #3161)
Breaking changes
TreeSequence.write_vcfnow filters non-sample nodes from individuals by default, instead of raising an error. These nodes can be included using the newinclude_non_sample_nodesargument. By default individual names (sample IDs) in VCF output are now of the formtsk_{individual.id}Previously these were always"tsk_{j}" for j in range(num_individuals). This may break some downstream code if individuals are specified. To fix, manually specifyindividual_namesto the required pattern. (@benjeffery, #3163)
[0.6.3] - 2025-04-28#
Bugfixes
TreeSequence.draw_svg(path=...)was failing due to a missing import xml.dom.minidom (@petrelharp, #3144, #3145)
[0.6.2] - 2025-04-01#
Bugfixes
Metadata.schema was returning a modified schema, this is fixed to return a copy of the original schema instead (@benjeffery, #3129, #3130)
Breaking Changes
Legacy formats from msprime<0.6 (HDF5 formats) support is dropped. This includes the support for
tskit upgrade(@hossam26644, #2812, #3138)
[0.6.1] - 2025-03-31#
Bugfixes
Fix to
TreeSequence.pair_coalescence_countsoutput dimension when provided with time windows containing no nodes (@nspope, #3046, #3058)Fix to
TreeSequence.pair_coalescence_countsto normalise by non-missing span ifspan_normalise=True. This resolves a bug whereTreeSequence.pair_coalescence_rateswould return incorrect values for intervals with missing trees. (@natep, #3053, #3059)Fix to
TreeSequence.pair_coalescence_ratescausing an assertion to be triggered by floating point error, when all coalescence events are inside a single time window (@natep, #3035, #3038)
Features
Add support for fixed-length arrays in metadata struct codec using the
lengthproperty. (@benjeffery, #3088,:pr:3090)Add a new
TreeSequence.pcamethod that uses randomized linear algebra to find the top eigenvectors/values of the genetic relatedness matrix (@hanbin973, @petrelharp, #3008)Add methods on TreeSequence to efficiently get table metadata as a numpy structured array. (@benjeffery, #3098)
Add Python 3.13 support (@benjeffery, #3107)
Add a preamble argument to draw_svg() methods to allow adding arbitrary extra graphics (e.g. legends) to SVG plots (@hyanwong, issue:`3086, #3121)
[0.6.0] - 2024-10-16#
Breaking Changes
The definition of
TreeSequence.genetic_relatednessandTreeSequence.genetic_relatedness_weightedare changed to average over sample sets, rather than summing over them. For computation with diploid sample sets, this will change the result by a factor of four; for larger sample sets it will now produce sensible values that are comparable between sample sets of different sizes. The default for these methods is also changed topolarised=True, but the output is unchanged forcentre=True(the default). See the documentation for these methods for more discussion. (@petrelharp, @mmosmond, #1623)
Bugfixes
Fix to
TreeSequence.genetic_relatednesswithindexes=Noneandproportion=True. (@petrelharp, #2984, #1623)Fix to
TreeSequence.general_statwhen using non-strict summary functions in the presence of non-ancestral material (very rare). (@petrelharp, #2983, #1623)Printing
tskit.MetadataSchema(schema=None)now shows"Null_schema"rather thanNone, to avoid confusion (@hyanwong, #2720)Limit output HTML when a tree sequence is displayed that has a large amount of metadata. (@benjeffery, #2999)
Fix warning in draw_svg to use correct warnings module. (@duncanMR, #2870, #2871)
Features
Add the
centreoption toTreeSequence.genetic_relatednessandTreeSequence.genetic_relatedness_weighted. (@petrelharp, @mmosmond, #1623)Edges now have an
.intervalattribute returning atskit.Intervalobject. (@hyanwong, #2531)Variants now have a states() method that returns the genotypes as an (inefficient) array of strings, rather than integer indexes, to aid comparison of genetic variation (@hyanwong, #2617)
Added
distance_betweenthat calculates the total distance between two nodes in a tree. (@Billyzhang1229, #2771)Added
genetic_relatedness_matrixmethod to compute pairwise genetic relatedness between sample sets. (@jeromekelleher, @petrelharp, #2823)Add
TreeSequence.extend_haplotypesmethod that extends ancestral haplotypes using recombination information, leading to unary nodes in many trees and fewer edges. (@petrelharp, @hfr1tz3, :user: nspope, @avabamf, #2651, #2938)Add
Table.drop_metadatato make clearing metadata from tables easy. (@jeromekelleher, #2944)Add
Interval.midandTree.midproperties to return the midpoint of the interval. (@currocam, #2960)Added
genetic_relatedness_vectormethod to compute product of genetic relatedness matrix and weight vector. (@petrelharp, #2980)Added
pair_coalescence_countsmethod to calculate coalescence events per node or time interval,pair_coalescence_quantilesmethod to estimate quantiles of pair coalescence times using empirical CDF inversion, andpair_coalescence_ratesmethod to estimate instantaneous rates of pair coalescence within time intervals from the empirical CDF. (@nspope, #2915, #2976, #2985)Add provenance information to the HTML notebook representation of a tree sequence. (@benjeffery, #3001)
The
.draw_svg()methods can add annotated genomic regions (e.g. genes) to the x-axis. (@hyanwong, #3002)Added a
node_titlesand amutation_titlesparameter to.draw_svg()methods which assigns a string to node and mutation symbols, commonly shown on mouseover. This can reduce label clutter while retaining useful info (@hyanwong, #3007)Added (currently undocumented) use of the order parameter in
Tree.draw_svg()to pass a subset of nodes, so subtrees can be visually collapsed. Additionally, an optionpack_untracked_polytomiesallows large polytomies involving untracked samples to be summarised as a dotted line (@hyanwong, #3011 #3010, #3012)Added a
titleparameter to.draw_svg()methods (@hyanwong, #3015)Add comma separation to all display numbers. (@benjeffery, #3017, #3018)
Add
resourcessection to provenance schema. (@benjeffery, #3016)Add
Tree.rf_distancemethod to calculate the unweighted Robinson-Foulds distance between two trees. (@Billyzhang1229, #995, #2643, #3032)
[0.5.8] - 2024-06-27#
Add support for numpy 2 (@jeromekelleher, @benjeffery, #2964)
[0.5.7] - 2024-06-17#
Breaking Changes
The VCF writing methods (ts.write_vcf, ts.as_vcf) now error if a site with position zero is encountered. The VCF spec does not allow zero position sites. Suppress this error with the allow_position_zero argument. (@benjeffery, #2901, #2838)
Bugfixes
Fix to the folded, expected allele frequency spectrum (i.e., TreeSequence.allele_frequency_spectrum(mode=”branch”, polarised=False), which was half as big as it should have been. (@petrelharp, @nspope, #2933)
[0.5.6] - 2023-10-10#
Breaking Changes
tskit now requires Python 3.8, as Python 3.7 became end-of-life on 2023-06-27
Features
Tree.trmca now accepts >2 nodes and returns nicer errors (@hyanwong, :pr:2808, #2801, #2070, #2611)
Add
TreeSequence.genetic_relatedness_weightedstats method. (@petrelharp, @brieuclehmann, @jeromekelleher, #2785, #1246)Add
TreeSequence.impute_unknown_mutations_timemethod to return an array of mutation times based on the times of associated nodes (@duncanMR, #2760, #2758)Add
asdictto all dataclasses. These are returned when you access a row or other tree sequence object. (@benjeffery, #2759, #2719)
Bugfixes
Fix incompatibility with
jsonschema>4.18.6which causedAttributeError: module jsonschema has no attribute _validators(@benjeffery, #2844, #2840)
[0.5.5] - 2023-05-17#
Performance improvements
Methods like ts.at() which seek to a specified position on the sequence from a new Tree instance are now much faster (@molpopgen, #2661).
Features
Add
__repr__for variants to return a string representation of the raw data without spewing megabytes of text (@chriscrsmith, #2695, #2694)
Breaking Changes
Bugfixes
Fix UnicodeDecodeError when calling Variant.alleles on the emscripten platform. (@benjeffery, #2754, #2737)
[0.5.4] - 2023-01-13#
Features
A new
Tree.is_rootmethod avoids the need to to search the potentially large list ofTree.roots(@hyanwong, #2669, #2620)The
TreeSequenceobject now has the attributesmin_timeandmax_time, which are the minimum and maximum among the node times and mutation times, respectively. (@szhan, #2612, #2271)The
draw_svgmethods now have amax_num_treesparameter to truncate the total number of trees shown, giving a readable display for tree sequences with many trees (@hyanwong, #2652)The
draw_svgmethods now accept acanvas_sizeparameter to allow extra room on the canvas e.g. for long labels or repositioned graphical elements (@hyanwong, #2646, #2645)The
msprime.RateMapclass has been ported into tskit: functionality should be identical to the version in msprime, apart from minor changes in the formatting of tabular text output (@hyanwong, @jeromekelleher, #2678)Tskit now supports and has wheels for Python 3.11. This Python version has a significant performance boost (@benjeffery, #2624, #2248)
Add the update_sample_flags option to simplify which ensures no node sample flags are changed to allow calling code to manage sample status. (@jeromekelleher, #2662, #2663).
Breaking Changes
[0.5.3] - 2022-10-03#
Fixes
Features
The
ts.nodesmethod now takes anorderparameter so that nodes can be visited in time order (@hyanwong, #2471, #2370)Add
samplesargument toTreeSequence.genotype_matrix. Default isNone, where all the sample nodes are selected. (@szhan, #2493, #678)
ts.drawand thedraw_svgmethods now have an optionalomit_sitesparameter, aiding drawing large trees with many sites and mutations (@hyanwong, #2519, #2516)
Breaking Changes
Single statistics computed with
TreeSequence.general_statare now returned as numpy scalars if windows=None, AND; samples is a single list or None (for a 1-way stat), OR indexes is None or a single list of length k (instead of a list of length-k lists). (@gtsambos, #2417, #2308)Accessor methods such as ts.edge(n) and ts.node(n) now allow negative indexes (@hyanwong, #2478, #1008)
ts.subset()produces valid tree sequences even if nodes are shuffled out of time order (@hyanwong, #2479, #2473), and the same fortables.subset()(@hyanwong, #2489). This involves sorting the returned tables, potentially changing the returned edge order.
Performance improvements
[0.5.2] - 2022-07-29#
Fixes
Iterating over
ts.variants()could cause a segfault in tree sequences with large numbers of alleles or very long alleles (@jeromekelleher, #2437, #2429).Various circular references fixed, lowering peak memory usage (@jeromekelleher, #2424, #2423, #2427).
Fix bugs in VCF output when there isn’t a 1-1 mapping between individuals and sample nodes (@jeromekelleher, #2442, #2257, #2446, #2448).
Performance improvements
TreeSequence.site position search performance greatly improved, with much lower memory overhead (@jeromekelleher, #2424).
TreeSequence.samples time/population search performance greatly improved, with much lower memory overhead (@jeromekelleher, #2424, #1916).
The
timeascandtimedescorders forTree.nodeshave much improved performance and lower memory overhead (@jeromekelleher, #2424, #2423).
Features
Variant objects now have a
.num_missingattribute and.counts()and.frequenciesmethods (@hyanwong, #2390 #2393).Add the Tree.num_lineages(t) method to return the number of lineages present at time t in the tree (@jeromekelleher, #386, #2422)
Efficient array access to table data now provided via attributes like TreeSequence.nodes_time, etc (@jeromekelleher, #2424).
Breaking Changes
Previously, accessing (e.g.)
tables.edgesreturned a different instance of EdgeTable each time. This has been changed to return the same instance for the lifetime of a given TableCollection instance. This is technically a breaking change, although it’s difficult to see how code would depend on the property that (e.g.)tables.edges is not tables.edges. (@jeromekelleher, #2441, #2080).
[0.5.1] - 2022-07-14#
Fixes
Copies of a Variant object would cause a segfault when
.sampleswas accessed. (@benjeffery, #2400, #2401)
Changes
Tables in a table collection can be replaced using the replace_with method (@hyanwong, #1489 #2389)
SVG drawing routines now return a special string object that is automatically rendered in a Jupyter notebook (@hyanwong, #2377)
Features
[0.5.0] - 2022-06-22#
Changes
A
min_timeparameter indraw_svgenables the youngest node as the y axis min value, allowing negative times. (@hyanwong, #2197, #2215)VcfWriter.writenow prints the site ID of variants in the ID field of the output VCF files. (@roohy, #2103, #2107)Make dumping of tables and tree sequences to disk a zero-copy operation. (@benjeffery, #2111, #2124)
Add
copyargument toTreeSequence.variantswhich if False reuses the returnedVariantobject for improved performance. Defaults to True. (@benjeffery, #605, #2172)tree.mrcanow takes 2 or more arguments and gives the common ancestor of them all. (@savitakartik, #1340, #2121)Add a
edgeattribute to theMutationclass that gives the ID of the edge that the mutation falls on. (@jeromekelleher, #685, #2279).Add the
TreeSequence.split_edgesoperation which inserts nodes into edges at a specific time. (@jeromekelleher, #2276, #2296).Add the
TreeSequence.decapitate(and closely relatedTableCollection.delete_older) operation to remove topology and mutations older than a give time. (@jeromekelleher, #2236, #2302, #2331).Add the
TreeSequence.individuals_timeandTreeSequence.individuals_populationmethods to return arrays of per-individual times and populations, respectively. (@petrelharp, #1481, #2298).Add the
sample_maskandsite_masktowrite_vcfto allow parts of an output VCF to be omitted or marked as missing data. Also add theas_vcfconvenience function, to return VCF as a string. (@jeromekelleher, #2300).Add support for missing data to
write_vcf, and add theisolated_as_missingargument. (@jeromekelleher, #2329, #447).Add
Tree.num_children_arrayandTree.num_children. Returns the counts of the number of child nodes for each or a single node in the tree respectively. (@GertjanBisschop, #2318, #2319, #2332)Add
Tree.path_length. (@jeremyguez, #2249, #2259).Add B1 tree balance index. (@jeremyguez, @jeromekelleher, #2251, #2281, #2346).
Add B2 tree balance index. (@jeremyguez, @jeromekelleher, #2252, #2353, #2354).
Add Sackin tree imbalance index. (@jeremyguez, @jeromekelleher, #2246, #2258).
Add Colless tree imbalance index. (@jeremyguez, @jeromekelleher, #2250, #2266, #2344).
Add
directionargument toTreeSequence.edge_diffs, allowing iteration over diffs in the reverse direction. NOTE: this comes with a ~10% performance regression as the implementation was moved from C to Python for simplicity and maintainability. Please open an issue if this affects your application. (@jeromekelleher, @benjeffery, #2120).Add
Tree.edge_arrayandTree.edge. Returns the edge id of the edge encoding the relationship of each node with its parent. (@GertjanBisschop, #2361, #2357)Add
positionargument toTreeSequence.site. Returns aSiteobject if there is one at the specified position. If not, it raisesValueError. (@szhan, #2234, #2235)
Breaking Changes
The JSON metadata codec now interprets the empty string as an empty object. This means that applying a schema to an existing table will no longer necessitate modifying the existing rows. (@benjeffery, #2064, #2104)
Remove the previously deprecated
as_bytesargument toTreeSequence.variants. If you need genotypes in byte form this can be done following the code in theto_macsmethod on line5573oftrees.py. This argument was initially deprecated more than 3 years ago when the code was part ofmsprime. (@benjeffery, #605, #2172)Arguments after
ploidyinwrite_vcfmarked as keyword only (@jeromekelleher, #2329, #2315).When metadata equal to
b''is printed to text or HTML tables it will render as an empty string rather than"b''". (@hyanwong, #2349, #2351)
[0.4.1] - 2022-01-11#
Changes
TableCollection.name_maphas been deprecated in favour oftable_name_map. (@benjeffery, #1981, #2086)
Fixes
TreeSequence.dump_textnow prints decoded metadata if there is a schema. (@benjeffery, #1860, #1527)Add missing
ReferenceSequence.__eq__method. (@benjeffery, #2063, #2085)
[0.4.0] - 2021-12-10#
Breaking changes
The
Tree.num_nodesmethod is now deprecated with a warning, because it confusingly returns the number of nodes in the entire tree sequence, rather than in the tree. Text summaries of trees (e.g.str(tree)) now return the number of nodes in the tree, not in the entire tree sequence (@hyanwong, #1966 #1968)The CLI
infocommand now gives more detailed information on the tree sequence (@benjeffery, #1611)64 bits are now used to store the sizes of ragged table columns such as metadata, allowing them to hold more data. This change is fully backwards and forwards compatible for all tree-sequences whose ragged column sizes fit into 32 bits. New tree-sequences with large offset arrays that require 64 bits will fail to load in previous versions with error
_tskit.FileFormatError: An incompatible type for a column was found in the file. (@jeromekelleher, #343, #1527, #1528, #1530, #1554, #1573, #1589,:issue:1598,:issue:1628, #1571, #1579, #1585, #1590, #1602, #1618, #1620, #1652).The Tree class now conceptually has an extra node, the “virtual root” whose children are the roots of the tree. The quintuply linked tree arrays (parent_array, left_child_array, right_child_array, left_sib_array and right_sib_array) all have one extra element. (@jeromekelleher, #1691, #1704).
Tree traversal orders returned by the
nodesmethod have changed when there are multiple roots. Previously orders were defined locally for each root, but are now globally across all roots. (@jeromekelleher, #1704).Individuals are no longer guaranteed or required to be topologically sorted in a tree sequence.
TableCollection.sortno longer sorts individuals. (@benjeffery, #1774, #1789)Metadata encoding errors now raise
MetadataEncodingError(@benjeffery, #1505, #1827).For
TreeSequence.samplesall arguments afterpopulationare now keyword only (@benjeffery, #1715, #1831).Remove the method
TreeSequence.to_nexusand replace withTreeSequence.as_nexus. As the old method was not generating standards-compliant output, it seems unlikely that it was used by anyone. Calls toto_nexuswill result in a NotImplementedError, informing users of the change. See below for details onas_nexus.Change default value for
missing_data_charin theTreeSequence.haplotypesmethod from “-” to “N”. This is a more idiomatic usage to indicate missing data rather than a gap in an alignment. (@jeromekelleher, #1893, #1894)
Features
Add the
ibd_segmentsmethod and associated classes to compute, summarise and store segments of identity by descent from a tree sequence (@gtsambos, @jeromekelleher).Allow skipping of site and mutation tables in
TableCollection.sort(@benjeffery, #1475, #1826).Add
TableCollection.sort_individualsto sort the individuals as this is no longer done by the default sort (@benjeffery, #1774, #1789).Add
__setitem__to all tables allowing single rows to be updated. For exampletables.nodes[0] = tables.nodes[0].replace(flags=tskit.NODE_IS_SAMPLE)(@jeromekelleher, @benjeffery, #1545, #1600).Added a new parameter
timetoTreeSequence.samples()allowing to select samples at a specific time point or time interval. (@mufernando, @petrelharp, #1692, #1700)Add
table.metadata_vectorto all table classes to allow easy extraction of a single metadata key into an array (@petrelharp, #1676, #1690).Add
time_unitstoTreeSequenceto describe the units of the time dimension of the tree sequence. This is then used to generate an error iftime_unitsisuncalibratedwhen using the branch lengths in statistics. (@benjeffery, #1644, #1760, #1832)Add the
virtual_rootproperty to the Tree class (@jeromekelleher, #1704).Add the
num_edgesproperty to the Tree class (@jeromekelleher, #1704).Improved performance for tree traversal methods in the
nodesiterator. Roughly a 10X performance increase for “preorder”, “postorder”, “timeasc” and “timedesc” (@jeromekelleher, #1704).Substantial performance improvement for
Tree.total_branch_length(@jeromekelleher, #1794 #1799)Add the
discrete_genomeproperty to the TreeSequence class which is true if all coordinates are discrete (@jeromekelleher, #1144, #1819)Add a
random_nucleotidesfunction. (user:jeromekelleher, #1825)Add the
TreeSequence.alignmentsmethod. (user:jeromekelleher, #1825)Add alignment export in the FASTA and nexus formats using the
TreeSequence.write_nexusandTreeSequence.write_fastamethods. (@jeromekelleher, @hyanwong, #1894)Add the
discrete_timeproperty to the TreeSequence class which is true if all time coordinates are discrete or unknown (@benjeffery, #1839, #1890)Add the
skip_tablesoption toloadto support only loading top-level information from a file. Also add theignore_tablesoption toTableCollection.equalsandTableCollection.assert_equalsto compare only top-level information. (@clwgg, #1882, #1854).Add the
skip_reference_sequenceoption toload. Also add theignore_reference_sequenceoptionequalsto compare two table collections without comparing their reference sequence. (@clwgg, #2019, #1971).tskit now supports python 3.10 (@benjeffery, #1895, #1949)
Fixes
dump_tables omitted individual parents. (@benjeffery, #1828, #1884)
Add the
Tree.as_newickmethod and deprecateTree.newick. Theas_newickmethod by default labels samples with the pattern"n{node_id}"which is much more useful that the behaviour ofTree.newick(which mimicsmsoutput). (@jeromekelleher, #1671, #1838.)Add the
as_nexusandwrite_nexusmethods to the TreeSequence class, replacing the brokento_nexusmethod (see above). This uses the same sample labelling pattern asas_newick. (@jeetsukumaran, @jeromekelleher, #1785, #1835, #1836, #1838)load_text created additional populations even if the population table was specified, and didn’t strip newlines from input text (@hyanwong, #1909, #1910)
[0.3.7] - 2021-07-08#
Features
map_mutationsnow allows the ancestral state to be specified (@hyanwong, @jeromekelleher, #1542, #1550)
[0.3.6] - 2021-05-14#
Breaking changes
Mutation.positionandMutation.indexwhich were deprecated in 0.2.2 (Sep ‘19) have been removed.
Features
Add direct, copy-free access to the arrays representing the quintuply-linked structure of
Tree(e.g.left_child_array). Allows performant algorithms over the tree structure using, for example, numba (@jeromekelleher, #1299, #1320).Add fancy indexing to tables. E.g.
table[6:86]returns a new table with the specified rows. Supports slices, index arrays and boolean masks (@benjeffery, #1221, #1348, #1342).Add
Table.appendmethod for adding rows from classes such asSiteTableRowandSite(@benjeffery, #1111, #1254).SVG visualization of a tree sequence can be restricted to displaying between left and right genomic coordinates using the
x_limparameter. The default settings now mean that if the left or right flanks of a tree sequence are entirely empty, these regions will not be plotted in the SVG (@hyanwong, #1288).SVG visualization of a single tree allows all mutations on an edge to be plotted via the
all_edge_mutationsparam (@hyanwong,:issue:1253, #1258).Entity classes such as
Mutation,Nodeare now python dataclasses (@benjeffery, #1261).Metadata decoding for table row access is now lazy (@benjeffery, #1261).
Add html notebook representation for
Treeand changeTree.__str__from dict representation to info table. (@benjeffery, #1269, #1304).Improve display of tables when
print``ed, limiting lines set via ``tskit.set_print_options(@benjeffery,:issue:1270, #1300).Add
Table.assert_equalsandTableCollection.assert_equalswhich give an exact report of any differences. (@benjeffery,:issue:1076, #1328)
Changes
In drawing methods
max_tree_heightandtree_height_scalehave been deprecated in favour ofmax_timeandtime_scale(@benjeffery,:issue:1262, #1331).
Fixes
Tree sequences were not properly init’d after unpickling (@benjeffery, #1297, #1298)
[0.3.5] - 2021-03-16#
Features
SVG visualization plots mutations at the correct time, if it exists, and a y-axis, with label can be drawn. Both x- and y-axes can be plotted on trees as well as tree sequences (@hyanwong,:issue:840, #580, #1236)
SVG visualization now uses squares for sample nodes and red crosses for mutations, with the site/mutation positions marked on the x-axis. Additionally, an x-axis label can be set (@hyanwong,:issue:1155, #1194, #1182, #1213)
Add
parentscolumn to the individual table to allow recording of pedigrees (@ivan-krukov, @benjeffery, #852, #1125, #866, #1153, #1177, #1192 #1199).Added
Tree.generate_random_binarystatic method to create random binary trees (@hyanwong, @jeromekelleher, #1037).Change the default behaviour of Tree.split_polytomies to generate the shortest possible branch lengths instead of a fixed epsilon of 1e-10. (@jeromekelleher, #1089, #1090)
Default value metadata in
add_rowfunctions is now schema-dependant, so thatmetadata={}is no longer needed as an argument when a schema is present (@benjeffery, #1084).defaultin metadata schemas is used to fill in missing values when encoding for the struct codec. (@benjeffery, #1073, #1116).Added
canonicaloption to table collection sorting (@mufernando, @petrelharp, #705)Added various arguments to
TreeSequence.subset, to allow for stable population indexing and lossless node reordering with subset. (@petrelharp, #1097)
Changes
Allow mutations that have the same derived state as their parent mutation. (@benjeffery, #1180, #1233)
File minor version change to support individual parents
Breaking changes
tskit now requires Python 3.7 (@benjeffery, #1235)
[0.3.4] - 2020-12-02#
Minor bugfix release.
Bugfixes
Reinstate the unused zlib_compression option to tskit.dump, as msprime < 1.0 still uses it (@jeromekelleher, #1067).
[0.3.3] - 2020-11-27#
Features
Add
TreeSequence.genetic_relatednessfor calculating genetic relatedness between pairs of sets of nodes (@brieuclehmann, #1021, #1023, #974, #973, #898).Expose
TreeSequence.coiterate()method to allow iteration over 2 sequences simultaneously, aiding comparison of trees from two sequences (@jeromekelleher, @hyanwong, #1021, #1022).tskit is now supported on, and has wheels for, python3.9 (@benjeffery, #982, #907).
Tree.newick()now has extra optioninclude_branch_lengthsto allow branch lengths to be omitted (@hyanwong, #931).Added
Tree.generate_starstatic method to create star-topologies (@hyanwong, #934).Added
Tree.generate_combandTree.generate_balancedmethods to create example trees. (@jeromekelleher, #1026).Added
equalsmethod to TreeSequence, TableCollection and each of the tables which provides more flexible equality comparisons, for example, allowing users to ignore metadata or provenance in the comparison (@mufernando, @jeromekelleher, #896, #897, #913, #917).Added
__eq__to TreeSequence (@benjeffery, #1011, #1020).ts.dumpandtskit.loadnow support reading and writing file objects such as FIFOs and sockets (@benjeffery, #657, #909).Added
tskit.write_msfor writing to MS format (@saurabhbelsare, #727, #854).Added
TableCollection.indexesfor access to the edge insertion/removal order indexes (@benjeffery, #4, #916).The dictionary representation of a TableCollection now contains its index (@benjeffery, #870, #921).
Added
TreeSequence._repr_html_for use in jupyter notebooks (@benjeffery, #872, #923).Added
TreeSequence.__str__to display a summary for terminal usage (@benjeffery, #938, #985).Added
TableCollection.dumpandTableCollection.load. This allows table collections that are not valid tree sequences to be manipulated (@benjeffery, #14, #986).Added
nbytesmethod to tables,TableCollectionandTreeSequencewhich reports the size in bytes of those objects (@jeromekelleher, @benjeffery, #54, #871).Added
TableCollection.clearto clear data table rows and optionally provenances, table schemas and tree-sequence level metadata and schema (@benjeffery, #929, #1001).
Bugfixes
LightWeightTableCollection.asdictandTableCollection.asdictnow return copies of arrays (@benjeffery, #1025, #1029).The
map_mutationsmethod previously used the Fitch parsimony method, but this does not produce parsimonious results on non-binary trees. We now now use the Hartigan parsimony algorithm, which does (@jeromekelleher, #987, #1030).The
flagargument to tables’add_rowwas treating the value as signed (@benjeffery, #1027, #1031).
Breaking changes
The argument to
ts.dumpandtskit.loadhas been renamed file from path.All arguments to
Tree.newick()except precision are now keyword-only.Renamed
ts.trait_regressiontots.trait_linear_model.
[0.3.2] - 2020-09-29#
Breaking changes
The argument order of
Tree.unrankandcombinatorics.num_labellingsnow positions the number of leaves before the tree rank (@daniel-goldstein, #950, #978)Change several methods (
simplify(),trees(),Tree()) so most parameters are keyword only, not positional. This allows reordering of parameters, so that deprecated parameters can be moved, and the parameter order in similar functions, e.g.TableCollection.simplifyandTreeSequence.simplify()can be made consistent (@hyanwong, #374, #846, #851)
Features
Add
split_polytomiesmethod to the Tree class (@hyanwong, @jeromekelleher, #809, #815)Tree accessor functions (e.g.
ts.first(),ts.at()pass extra parameters such assample_indexesto the underlyingTreeconstructor; alsoroot_thresholdcan be specified when callingts.trees()(@hyanwong, #847, #848)Genomic intervals returned by python functions are now namedtuples, allowing
.left.rightand.spanusage (@hyanwong, #784, #786, #811)Added
include_terminalparameter to edge diffs iterator, to output the last edges at the end of a tree sequence (@hyanwong, #783, #787)#832 - Add
metadata_bytesmethod to allow access to raw TableCollection metadata (@benjeffery, #842)tskit.is_unknown_timecan now check arrays. (@benjeffery, #857).
[0.3.1] - 2020-09-04#
Bugfixes
#823 - Fix mutation time error when using
simplify(keep_input_roots=True)(@petrelharp, #823).#821 - Fix mutation rows with unknown time never being equal (@petrelharp, #822).
[0.3.0] - 2020-08-27#
Major feature release for metadata schemas, set-like operations, mutation times, SVG drawing improvements and many others.
Breaking changes
The default display order for tree visualisations has been changed to
minlex(see below) to stabilise the node ordering and to make trees more readily comparable. The old behaviour is still available withorder="tree".File system operations such as dump/load now raise an appropriate OSError instead of
tskit.FileFormatError. Loading from an empty file now raises andEOFError.Bad tree topologies are detected earlier, so that it is no longer possible to create a
TreeSequenceobject which contains a parent with contradictory children on an interval. Previously an error was thrown when some operation building the trees was attempted (@jeromekelleher, #709).The
TableCollection objectno longer implements the iterator protocol. Previouslylist(tables)returned a sequence of (table_name, table_instance) tuples. This has been replaced with the more intuitive and future-proofTableCollection.name_mapandTreeSequence.tables_dictattributes, which perform the same function (@jeromekelleher, #500, #694).The arguments to
TreeSequence.genotype_matrix,TreeSequence.haplotypesandTreeSequence.variantsmust now be keyword arguments, not positional. This is to support the change fromimpute_missing_datatoisolated_as_missingin the arguments to these methods. (@benjeffery, #716, #794)
New features
New methods to perform set operations on TableCollections and TreeSequences.
TableCollection.subsetsubsets and reorders table collections by nodes (@mufernando, @petrelharp, #663, #690).TableCollection.unionforms the node-wise union of two table collections (@mufernando, @petrelharp, #381 #623).Mutations now have an optional double-precision floating-point
timecolumn. If not specified, this defaults to a particularNaNvalue (tskit.UNKNOWN_TIME) indicating that the time is unknown. For a tree sequence to be considered valid it must meet new criteria for mutation times, see Mutation requirements. Also added functionTableCollection.compute_mutation_times. Table sorting orders mutations by non-increasing time per-site, which is also a requirement for a valid tree sequence (@benjeffery, #672).Add support for trees with internal samples for the Kendall-Colijn tree distance metric. (@daniel-goldstein, #610)
Add background shading to SVG tree sequences to reflect tree position along the sequence (@hyanwong, #563).
Tables with a metadata column now have a
metadata_schemathat is used to validate and encode metadata that is passed toadd_rowand decode metadata on calls totable[j]and e.g.tree_sequence.node(j)See Metadata (@benjeffery, #491, #542, #543, #601).The tree-sequence now has top-level metadata with a schema (@benjeffery, #666, #644, #642).
Add classes to SVG drawings to allow easy adjustment and styling, and document the new
tskit.Tree.draw_svg()andtskit.TreeSequence.draw_svg()methods. This also fixes #467 for duplicate SVG entityids in Jupyter notebooks (@hyanwong, #555).Add a
to_nexusfunction that outputs a tree sequence in Nexus format (@saunack, #550).Add extension of Kendall-Colijn tree distance metric for tree sequences computed by
TreeSequence.kc_distance(@daniel-goldstein, #548).Add an optional node traversal order in
tskit.Treethat uses the minimum lexicographic order of leaf nodes visited. This ordering ("minlex_postorder") adds more determinism because it constraints the order in which children of a node are visited (@brianzhang01, #411).Add an
orderargument to the tree visualisation functions which supports two node orderings:"tree"(the previous default) and"minlex"which stabilises the node ordering (making it easier to compare trees). The default node ordering is changed to"minlex"(@brianzhang01, @jeromekelleher, #389, #566).Add
_repr_html_to tables, so that jupyter notebooks render them as html tables (@benjeffery, #514).Remove support for
kc_distanceon trees with unary nodes (@daniel-goldstein, #508).Improve Kendall-Colijn tree distance algorithm to operate in O(n^2) time instead of O(n^2 * log(n)) where n is the number of samples (@daniel-goldstein, #490).
Add a metadata column to the migrations table. Works similarly to existing metadata columns on other tables (@benjeffery, #505).
Add a metadata column to the edges table. Works similarly to existing metadata columns on other tables (@benjeffery, #496).
Allow sites with missing data to be output by the
haplotypesmethod, by default replacing with-. Errors are no longer raised for missing data withisolated_as_missing=True; the error types returned for bad alleles (e.g. multiletter or non-ascii) have also changed from_tskit.LibraryErrorto TypeError, or ValueError if the missing data character clashes (@hyanwong, #426).Access the number of children of a node in a tree directly using
tree.num_children(u)(@hyanwong, #436).User specified allele mapping for genotypes in
variantsandgenotype_matrix(@jeromekelleher, #430).New
root_thresholdoption for the Tree class, which allows us to efficiently iterate over ‘real’ roots when we have missing data (@jeromekelleher, #462).Add
tree.as_dict_of_dicts()function to enable use with networkx. See Networkx (@winni2k, #457).Add
tree_sequence.to_macs()function to convert tree sequence to MACS format (@winni2k, #727)Add a
keep_input_rootsoption to simplify which, if enabled, adds edges from the MRCAs of samples in the simplified tree sequence back to the roots in the input tree sequence (@jeromekelleher, #775, #782).
Bugfixes
#453 - Fix LibraryError when
tree.newick()is called with large node time values (@jeromekelleher, #637).#777 - Mutations over isolated samples were incorrectly decoded as missing data. (@jeromekelleher, #778)
#776 - Fix a segfault when a partial list of samples was provided to the
variantsiterator. (@jeromekelleher, #778)
Deprecated
The
sample_countsfeature has been deprecated and is now ignored. Sample counts are now always computed.For
TreeSequence.genotype_matrix,TreeSequence.haplotypesandTreeSequence.variantstheimpute_missing_dataargument is deprecated and replaced withisolated_as_missing. Note that to get the same behaviourimpute_missing_data=Trueshould be replaced withisolated_as_missing=False. (@benjeffery, #716, #794)
[0.2.3] - 2019-11-22#
Minor feature release, providing a tree distance metric and various method to manipulate tree sequence data.
New features
Kendall-Colijn tree distance metric computed by
Tree.kc_distance(@awohns, #172).New “timeasc” and “timedesc” orders for tree traversals (@benjeffery, #246, #399).
Up to 2X performance improvements to tree traversals (@benjeffery, #400).
Add
trim,delete_sites,keep_intervalsanddelete_intervalsmethods to edit tree sequence data. (@hyanwong, #364, #372, #377, #390).Various documentation improvements (@hyanwong, @jeromekelleher, @petrelharp).
Rename the
map_ancestorsfunction tolink_ancestors(@hyanwong, @gtsambos; #406, #262). The original function is retained as an deprecated alias.
Bugfixes
Fix height scaling issues with SVG tree drawing (@jeromekelleher, #407, #383, #378).
Do not reuse buffers in
LdCalculator(@jeromekelleher). See #397 and #396.
[0.2.2] - 2019-09-01#
Minor bugfix release.
Relaxes overly-strict input requirements on individual location data that caused some SLiM tree sequences to fail loading in version 0.2.1 (see #351).
New features
Add log_time height scaling option for drawing SVG trees (@marianne-aspbury). See #324 and #303.
Bugfixes
Allow 4G metadata columns (@jeromekelleher). See #342 and #341.
[0.2.1] - 2019-08-23#
Major feature release, adding support for population genetic statistics, improved VCF output and many other features.
Note: Version 0.2.0 was skipped because of an error uploading to PyPI which could not be undone.
Breaking changes
Genotype arrays returned by
TreeSequence.variantsandTreeSequence.genotype_matrixhave changed from unsigned 8 bit values to signed 8 bit values to accomodate missing data (see #144 for discussion). Specifically, the dtype of the genotypes arrays have changed from numpy “u8” to “i8”. This should not affect client code in any way unless it specifically depends on the type of the returned numpy array.The VCF written by the
write_vcfis no longer compatible with previous versions, which had significant shortcomings. Position values are now rounded to the nearest integer by default, REF and ALT values are derived from the actual allelic states (rather than always being A and T). Sample names are now of the formtsk_jfor sample ID j. Most of the legacy behaviour can be recovered with new options, however.The positional parameter
reference_setsingenealogical_nearest_neighboursandmean_descendantsTreeSequence methods has been renamed tosample_sets.
New features
Support for general windowed statistics. Implementations of diversity, divergence, segregating sites, Tajima’s D, Fst, Patterson’s F statistics, Y statistics, trait correlations and covariance, and k-dimensional allele frequency specra (@petrelharp, @jeromekelleher, @molpopgen).
Add the
keep_unaryoption to simplify (@gtsambos). See #1 and #143.Add the
map_ancestorsmethod to TableCollection (user:gtsambos). See #175.Add the
squashmethod to EdgeTable (@gtsambos). See #59 and #285.Add support for individuals to VCF output, and fix major issues with output format (@jeromekelleher). Position values are transformed in a much more straightforward manner and output has been generalised substantially. Adds
individual_namesandposition_transformarguments. See #286, and issues #2, #30 and #73.Control height scale in SVG trees using ‘tree_height_scale’ and ‘max_tree_height’ (@hyanwong, @jeromekelleher). See #167, #168. Various other improvements to tree drawing (#235, #241, #242, #252, #259).
Add
Tree.max_root_timeproperty (@hyanwong, @jeromekelleher). See #170.Improved input checking on various methods taking numpy arrays as parameters (@hyanwong). See #8 and #185.
Define the branch length over roots in trees to be zero (previously raise an error; @jeromekelleher). See #188 and #191.
Implementation of the genealogical nearest neighbours statistic (@hyanwong, @jeromekelleher).
New
delete_intervalsandkeep_intervalsmethod for the TableCollection to allow slicing out of topology from specific intervals (@hyanwong, @andrewkern, @petrelharp, @jeromekelleher). See #225 and #261.Support for missing data via a topological definition (@jeromekelleher). See #270 and #272.
Add ability to set columns directly in the Tables API (@jeromekelleher). See #12 and #307.
Various documentation improvements from @brianzhang01, @hyanwong, @petrelharp and @jeromekelleher.
Deprecated
Deprecate
Tree.lengthin favour ofTree.span(@hyanwong). See #169.Deprecate
TreeSequence.pairwise_diversityin favour of the newdiversitymethod. See #215, #312.
Bugfixes
[0.1.5] - 2019-03-27#
This release removes support for Python 2, adds more flexible tree access and a
new tskit command line interface.
New features
More flexible tree API (#121). Adds
TreeSequence.atandTreeSequence.at_indexmethods to find specific trees, and efficient support for backwards traversal usingreversed(ts.trees()).Add initial
tskitCLI (#80)Add
tskit infoCLI command (#66)Enable drawing SVG trees with coloured edges (@hyanwong; #149).
Add
Tree.is_descendantmethod (#120)Add
Tree.copymethod (#122)
Bugfixes
[0.1.4] - 2019-02-01#
Minor feature update. Using the C API 0.99.1.
New features
Add interface for setting TableCollection.sequence_length: tskit-dev/tskit#107
Add support for building and dropping TableCollection indexes: tskit-dev/tskit#108
[0.1.3] - 2019-01-14#
Bugfix release.
Bugfixes
Fix missing provenance schema: tskit-dev/tskit#81
[0.1.2] - 2019-01-14#
Bugfix release.
Bugfixes
Fix memory leak in table collection. tskit-dev/tskit#76
[0.1.1] - 2019-01-11#
Fixes broken distribution tarball for 0.1.0.
[0.1.0] - 2019-01-11#
Initial release after separation from msprime 0.6.2. Code that reads tree sequence files and processes them should be able to work without changes.
Breaking changes
Removal of the previously deprecated
sort_tables,simplify_tablesandload_tablesfunctions. All code should change to using corresponding TableCollection methods.Rename
SparseTreeclass toTree.
[1.1.0a1] - 2019-01-10#
Initial alpha version posted to PyPI for bootstrapping.
[0.0.0] - 2019-01-10#
Initial extraction of tskit code from msprime. Relicense to MIT.
Code copied at hash 29921408661d5fe0b1a82b1ca302a8b87510fd23
C API#
[1.2.0] - 2025-09-24#
Breaking changes
Remove
tsk_diff_iter_tand associated functions. (@benjeffery, #3221, #2797).tsk_treeseq_initnow requires that mutation parents in the table collection are correct and consistent with the topology of the tree at each mutation site. ReturnsTSK_ERR_BAD_MUTATION_PARENTif this is not the case, orTSK_ERR_MUTATION_PARENT_AFTER_CHILDif the mutations are not in an order compatible with the correct mutation parent. (@benjeffery, #2729, #2732, #3212).
Features
Add
TSK_TS_INIT_COMPUTE_MUTATION_PARENTStotsk_treeseq_initto compute mutation parents from the tree sequence topology. Note that the mutations must be in the correct order. (@benjeffery, #2757, #3212).Add
TSK_CHECK_MUTATION_PARENTSoption totsk_table_collection_check_integrityto check that mutation parents are consistent with the tree sequence topology. This option impliesTSK_CHECK_TREES. (@benjeffery, #2729, #2732, #3212).Add the
TSK_NO_CHECK_INTEGRITYoption totsk_table_collection_compute_mutation_parentsto skip the integrity checks that are normally run when computing mutation parents. This is useful for speeding up the computation of mutation parents when the tree sequence is certainly known to be valid. (@benjeffery, #3212).Mutations returned by
tsk_treeseq_get_mutationnow include pre-computedinherited_stateandinherited_state_lengthfields. The inherited state is computed during tree sequence initialization and represents the state that existed at the site before each mutation occurred (either the ancestral state if the mutation is the root mutation or the derived state of the parent mutation). Note that this breaks ABI compatibility due to the addition of these fields to thetsk_mutation_tstruct. (@benjeffery, #3277, #2631).
[1.1.4] - 2025-03-31#
Changes
Added the TSK_TRACE_ERRORS macro to enable tracing of errors in the C library. This is useful for debugging as errors will print to stderr when set. (@jeromekelleher, #3095).
[1.1.3] - 2024-10-16#
Features
Add the tsk_treeseq_extend_haplotypes method that can compress a tree sequence by extending edges into adjacent trees and thus creating unary nodes in those trees (@petrelharp, @hfr1tze, @avabamf, #2651, #2938).
[1.1.2] - 2023-05-17#
Performance improvements
tsk_tree_seek is now much faster at seeking to arbitrary points along the sequence from the null tree (@molpopgen, #2661).
Features
The struct
tsk_treeseq_tnow has the variablesmin_timeandmax_time, which are the minimum and maximum among the node times and mutation times, respectively.min_timeandmax_timecan be accessed using the functionstsk_treeseq_get_min_timeandtsk_treeseq_get_max_time, respectively. (@szhan, #2612, #2271)Add the TSK_SIMPLIFY_NO_FILTER_NODES option to simplify to allow unreferenced nodes be kept in the output (@jeromekelleher, @hyanwong, #2606, #2619).
Add the TSK_SIMPLIFY_NO_UPDATE_SAMPLE_FLAGS option to simplify which ensures no node sample flags are changed to allow calling code to manage sample status. (@jeromekelleher, #2662, #2663).
Guarantee that unfiltered tables are not written to unnecessarily during simplify (@jeromekelleher, #2619).
Add x_table_keep_rows methods to provide efficient in-place table subsetting (@jeromekelleher, #2700).
Add tsk_tree_seek_index function
[1.1.1] - 2022-07-29#
Bug fixes
Fix segfault in tsk_variant_restricted_copy in tree sequences with large numbers of alleles or very long alleles (@jeromekelleher, #2437, #2429).
[1.1.0] - 2022-07-14#
Features
Add
num_childrentotsk_tree_tan array which contains counts of the number of child nodes of each node in the tree. (@GertjanBisschop, #2274, #2316)Add
edgetotsk_tree_tan array which contains theedge_idof the edge encoding the relationship between the child node and its parent for each (child) node in the tree. (@GertjanBisschop, #2304, #2340)
Changes
Reduce the maximum number of rows in a table by 1. This removes edge cases so that a
tsk_id_tcan be used to count the number of rows. (@benjeffery, #2336, #2337)Samples are now copied by
tsk_variant_restricted_copy. (@benjeffery, #2400, #2401)
[1.0.0] - 2022-05-24#
This major release marks the point at which the documented API becomes stable and supported.
Breaking changes
Change the type of genotypes to
int32_t, removing the TSK_16_BIT_GENOTYPES flag option. (@benjeffery, #463, #2108)tsk_variant_tnow includes itstsk_site_trather than pointing to it. (@benjeffery, #2161, #2162)Rename
TSK_TAKE_TABLEStoTSK_TAKE_OWNERSHIP. (@benjeffery, #2221, #2222)TSK_DEBUG,TSK_NO_INIT,TSK_NO_CHECK_INTEGRITYandTSK_TAKE_OWNERSHIPhave moved tocore.h(@benjeffery, #2218, #2230))- Rename several flags:
All flags to
simplifyfor exampleTSK_KEEP_INPUT_ROOTSbecomesTSK_SIMPLIFY_KEEP_INPUT_ROOTS.All flags to
subsetfor exampleTSK_KEEP_UNREFERENCEDbecomesTSK_SUBSET_KEEP_UNREFERENCED.TSK_BUILD_INDEXES->TSK_TS_INIT_BUILD_INDEXESTSK_NO_METADATA->TSK_TABLE_NO_METADATATSK_NO_EDGE_METADATA->TSK_TC_NO_EDGE_METADATA
(@benjeffery, #1720, #2226, #2229, #2224)
Remove the generic
TSK_ERR_OUT_OF_BOUNDS- replacing with specific errors. RemoveTSK_ERR_NON_SINGLE_CHAR_MUTATIONwhich was unused. (@benjeffery, #2260)Reorder stats API methods to place
resultas the last argument. (@benjeffery, #2292, #2285)
Features
Make dumping of tables and tree sequences to disk a zero-copy operation. (@benjeffery, #2111, #2124)
Add
edgeattribute tomutation_tstruct and make available in tree sequence. (@jeromekelleher, #685, #2279)Reduce peak memory usage in
tsk_treeseq_simplify. (@jeromekelleher, #2287, #2288)
[0.99.15] - 2021-12-07#
Breaking changes
The
tablesargument totsk_treeseq_initis no longerconst, to allow for future no-copy tree sequence creation. (@benjeffery, #1718, #1719)Additional consistency checks for mutation tables are now run by
tsk_table_collection_check_integrityeven whenTSK_CHECK_MUTATION_ORDERINGis not passed in. (@petrelharp, #1713, #1722)num_tracked_samplesandnum_samplesintsk_tree_tare now typed astsk_size_t(@benjeffery, #1723, #1727)The previously deprecated option
TSK_SAMPLE_COUNTShas been removed. (@benjeffery, #1744, #1761).Individuals are no longer guaranteed or required to be topologically sorted in a tree sequence.
tsk_table_collection_sortno longer sorts individuals. (@benjeffery, #1774, #1789)The
tsk_tree_t.left_rootmember has been removed. Client code can be updated most easily by using the equivalenttsk_tree_get_left_rootfunction. However, it may be worth considering updating code to use either the standard traversal functions (which automatically iterate over roots) or to use thevirtual_rootmember (which may lead to more concise code). (@jeromekelleher, #1796, #1862)Rename
tsk_tree_t.leftandtsk_tree_t.rightmembers totsk_tree_t.interval.leftandtsk_tree_t.interval.rightrespectively. (@jeromekelleher, #1686, #1913)kastoreis now vendored into this repo instead of being a git submodule. Developers need to rungit submodule update. (@jeromekelleher, #1687, #1973)Treearrays such asleft_sib,right_childetc. now have an additional “virtual root” node at the end. (@jeromekelleher, #1691, #1704)markedandmarkhave been removed fromtsk_tree_t. (@jeromekelleher, #1936)
Features
Add
tsk_table_collection_individual_topological_sortto sort the individuals as this is no longer done by the default sort. (@benjeffery, #1774, #1789)The default behaviour for table size growth is now to double the current size of the table, up to a threshold. To keep the previous behaviour, use (e.g.)
tsk_edge_table_set_max_rows_increment(tables->edges, 1024), which results in adding space for 1024 additional rows each time we run out of space in the edge table. (@benjeffery, #5, #1683)tsk_table_collection_check_integritynow has aTSK_CHECK_MIGRATION_ORDERINGflag. (@petrelharp, #1722)The default behaviour for ragged column growth is now to double the current size of the column, up to a threshold. To keep the previous behaviour, use (e.g.)
tsk_node_table_set_max_metadata_length_increment(tables->nodes, 1024), which results in adding space for 1024 additional entries each time we run out of space in the ragged column. (@benjeffery, #1703, #1709)Support for compiling the C library on Windows using msys2 (@jeromekelleher, #1742).
Add
time_unitstotsk_table_collection_tto describe the units of the time dimension of the tree sequence. This is then used to geerate an error iftime_unitsisuncalibratedwhen using the branch lengths in statistics. (@benjeffery, #1644, #1760)Add the
TSK_LOAD_SKIP_TABLESoption to load just the top-level information from a file. Also add theTSK_CMP_IGNORE_TABLESoption to compare only the top-level information in two table collections. (@clwgg, #1882, #1854).Add reference sequence. (@jeromekelleher, @benjeffery, #146, #1911, #1944, #1911)
Add the
TSK_LOAD_SKIP_REFERENCE_SEQUENCEoption to load a table collection without the reference sequence. Also add the TSK_CMP_IGNORE_REFERENCE_SEQUENCE option to compare two table collections without comparing their reference sequence. (@clwgg, #2019, #1971).Add a “virtual root” to
Treearrays such asleft_sib,right_childetc. The virtual root is appended to each array, has all real roots as its children, but is not the parent of any node. Simplifies traversal algorithms. (@jeromekelleher, #1691, #1704)Add
num_edgestotsk_tree_tto count the edges that define the topology of the tree. (@jeromekelleher, #1704)Add the
tsk_tree_get_size_boundfunction which returns an upper bound on the number of nodes reachable from the roots of a tree. Useful for tree stack allocations (@jeromekelleher, #1704).Add
MetadataSchema.permissive_jsonfor an easy way to get the simplest schema.
[0.99.14] - 2021-09-03#
Breaking changes
64 bits are now used to store the sizes of ragged table columns such as metadata, allowing them to hold more data. As such
tsk_size_tis now 64 bits wide. This change is fully backwards and forwards compatible for all tree-sequences whose ragged column sizes fit into 32 bits. New tree-sequences with large offset arrays that require 64 bits will fail to load in previous versions with errorTSK_ERR_BAD_COLUMN_TYPE. (@jeromekelleher, #343, #1527, #1528, #1530, #1554, #1573, #1589,:issue:1598,:issue:1628, #1571, #1579, #1585, #1590, #1602, #1618, #1620, #1652).
Features
Add tsk_X_table_update_row methods which allow modifying single rows of tables (@jeromekelleher, #1545, #1552).
[0.99.13] - 2021-07-08#
Fixes
Fix segfault when very large columns overflow (@bhaller, @benjeffery, #1509, #1511).
[0.99.12] - 2021-05-14#
Breaking changes
Removed
TSK_NO_BUILD_INDEXES. Not building indexes is now the default behaviour of tsk_table_collection_dump and related functions. (@molpopgen, #1327, #1337).
Features
Add
tsk_*_table_extendmethods to append to a table from another (@benjeffery, #1271, #1287).
Fixes
[0.99.11] - 2021-03-16#
Features
Add
parentsto the individual table to enable recording of pedigrees (@ivan-krukov, @benjeffery, #852, #1125, #866, #1153, #1177, #1199).Added a
tsk_table_collection_canonicalisemethod, that allows checking for equality between tables that are equivalent up to reordering (@petrelharp, @mufernando, #1108).Removed a previous requirement on
tsk_table_collection_union, allowing for unioning of new information both above and below shared history (@petrelharp, @mufernando, #1108).Support migrations in tsk_table_collection_sort. (@jeromekelleher, #22, #117, #1131).
Breaking changes
Method
tsk_individual_table_add_rowhas an extra argumentsparentsandparents_length.Add an
optionsargument totsk_table_collection_subset(@petrelharp, #1108), to allow for retaining the order of populations.Mutation error codes have changed
Changes
Allow mutations that have the same derived state as their parent mutation. (@benjeffery, #1180, #1233)
File minor version change to support individual parents
[0.99.10] - 2021-01-25#
Minor bugfix on internal APIs
[0.99.9] - 2021-01-22#
Features
[0.99.8] - 2020-11-27#
Features
Add
tsk_treeseq_genetic_relatednessfor calculating genetic relatedness between pairs of sets of nodes (@brieuclehmann, #1021, #1023, #974, #973, #898).Exposed
tsk_table_collection_set_indexesto the API (@benjeffery, #870, #921).
Breaking changes
Added an
optionsargument totsk_table_collection_equalsand table equality methods to allow for more flexible equality criteria (e.g., ignore top-level metadata and schema or provenance tables). Existing code should add an extra final parameter0to retain the current behaviour (@mufernando, @jeromekelleher, #896, #897, #913, #917).Changed default behaviour of
tsk_table_collection_clearto not clear provenances and addedoptionsargument to optionally clear provenances and schemas (@benjeffery, #929, #1001).Renamed
ts.trait_regressiontots.trait_linear_model.
[0.99.7] - 2020-09-29#
Added
TSK_INCLUDE_TERMINALoption totsk_diff_iter_initto output the last edges at the end of a tree sequence (@hyanwong, #783, #787).Added
tsk_bug_assertfor assertions that should be compiled into release binaries (@benjeffery, #860).
[0.99.6] - 2020-09-04#
Bugfixes
#823 - Fix mutation time error when using
tsk_table_collection_simplifywithTSK_SIMPLIFY_KEEP_INPUT_ROOTS(@petrelharp, #823).
[0.99.5] - 2020-08-27#
Breaking changes
The macro
TSK_IMPUTE_MISSING_DATAis renamed toTSK_ISOLATED_NOT_MISSING(@benjeffery, #716, #794)
New features
Add a
TSK_SIMPLIFY_KEEP_INPUT_ROOTSoption to simplify which, if enabled, adds edges from the MRCAs of samples in the simplified tree sequence back to the roots in the input tree sequence (@jeromekelleher, #775, #782).
Bugfixes
#777 - Mutations over isolated samples were incorrectly decoded as missing data. (@jeromekelleher, #778)
#776 - Fix a segfault when a partial list of samples was provided to the
variantsiterator. (@jeromekelleher, #778)
[0.99.4] - 2020-08-12#
Note
The
TSK_VERSION_PATCHmacro was incorrectly set to4for 0.99.3, so both 0.99.4 and 0.99.3 have the same value.
Changes
Mutation times can be a mixture of known and unknown as long as for each individual site they are either all known or all unknown (@benjeffery, #761).
Bugfixes
Fix for including core.h under C++ (@petrelharp, #755).
[0.99.3] - 2020-07-27#
Breaking changes
tsk_mutation_table_add_rowhas an extratimeargument. If the time is unknownTSK_UNKNOWN_TIMEshould be passed. (@benjeffery, #672)Change genotypes from unsigned to signed to accommodate missing data (see #144 for discussion). This only affects users of the
tsk_vargen_tclass. Genotypes are now stored as int8_t and int16_t types rather than the former unsigned types. The field names in the genotypes union of thetsk_variant_tstruct returned bytsk_vargen_nexthave been renamed toi8andi16accordingly; care should be taken when updating client code to ensure that types are correct. The number of distinct alleles supported by 8 bit genotypes has therefore dropped from 255 to 127, with a similar reduction for 16 bit genotypes.Change the
tsk_vargen_initmethod to take an extra parameteralleles. To keep the current behaviour, set this parameter to NULL.Edges can now have metadata. Hence edge methods now take two extra arguments: metadata and metadata length. The file format has also changed to accommodate this, but is backwards compatible. Edge metadata can be disabled for a table collection with the TSK_NO_EDGE_METADATA flag. (@benjeffery, #496, #712)
Migrations can now have metadata. Hence migration methods now take two extra arguments: metadata and metadata length. The file format has also changed to accommodate this, but is backwards compatible. (@benjeffery, #505)
The text dump of tables with metadata now includes the metadata schema as a header. (@benjeffery, #493)
Bad tree topologies are detected earlier, so that it is no longer possible to create a tsk_treeseq_t object which contains a parent with contradictory children on an interval. Previously an error occured when some operation building the trees was attempted (@jeromekelleher, #709).
New features
New methods to perform set operations on table collections.
tsk_table_collection_subsetsubsets and reorders table collections by nodes (@mufernando, @petrelharp, #663, #690).tsk_table_collection_unionforms the node-wise union of two table collections (@mufernando, @petrelharp, #381, #623).Mutations now have an optional double-precision floating-point
timecolumn. If not specified, this defaults to a particular NaN value (TSK_UNKNOWN_TIME) indicating that the time is unknown. For a tree sequence to be considered valid it must meet new criteria for mutation times, see Mutation requirements. Addtsk_table_collection_compute_mutation_timesand new flag totsk_table_collection_check_integrity:TSK_CHECK_MUTATION_TIME. Table sorting orders mutations by non-increasing time per-site, which is also a requirement for a valid tree sequence. (@benjeffery, #672)Add
metadataandmetadata_schemafields to table collection, with accessors on tree sequence. These store arbitrary bytes and are optional in the file format. (:user: benjeffery, #641)Add the
TSK_SIMPLIFY_KEEP_UNARYoption to simplify (@gtsambos). See #1 and #143.Add a
set_root_thresholdoption to tsk_tree_t which allows us to set the number of samples a node must be an ancestor of to be considered a root (#462).Change the semantics of tsk_tree_t so that sample counts are always computed, and add a new
TSK_NO_SAMPLE_COUNTSoption to turn this off (#462).Tables with metadata now have an optional metadata_schema field that can contain arbitrary bytes. (@benjeffery, #493)
Tables loaded from a file can now be edited in the same way as any other table collection (@jeromekelleher, #536, #530.
Support for reading/writing to arbitrary file streams with the loadf/dumpf variants for tree sequence and table collection load/dump (@jeromekelleher, @grahamgower, #565, #599).
Add low-level sorting API and
TSK_NO_CHECK_INTEGRITYflag (@jeromekelleher, #627, #626).Add extension of Kendall-Colijn tree distance metric for tree sequences computed by
tsk_treeseq_kc_distance(@daniel-goldstein, #548)
Deprecated
The
TSK_SAMPLE_COUNTSoptions is now ignored and will print out a warning if used (#462).
[0.99.2] - 2019-03-27#
Bugfix release. Changes:
Fix incorrect errors on tbl_collection_dump (#132)
Catch table overflows (#157)
[0.99.1] - 2019-01-24#
Refinements to the C API as we move towards 1.0.0. Changes:
Change the
_tbl_abbreviation to_table_to improve readability. Hence, we now have, e.g.,tsk_node_table_tetc.Change
tsk_tbl_size_ttotsk_size_t.Standardise public API to use
tsk_size_tandtsk_id_tas appropriate.Add
tsk_flags_ttypedef and consistently use this as the type used to encode bitwise flags. To avoid confusion, functions now have anoptionsparameter.Rename
tsk_table_collection_position_ttotsk_bookmark_t.Rename
tsk_table_collection_reset_positiontotsk_table_collection_truncateandtsk_table_collection_record_positiontotsk_table_collection_record_num_rows.Generalise
tsk_table_collection_sortto take a bookmark as start argument.Relax restriction that nodes in the
samplesargument to simplify must currently be marked as samples. (tskit-dev/tskit#72)Allow
tsk_table_collection_simplifyto take a NULL samples argument to specify “all samples in the current tables”.Add support for building as a meson subproject.
[0.99.0] - 2019-01-14#
Initial alpha version of the tskit C API tagged. Version 0.99.x represents the series of releases leading to version 1.0.0 which will be the first stable release. After 1.0.0, semver rules regarding API/ABI breakage will apply; however, in the 0.99.x series arbitrary changes may happen.
[0.0.0] - 2019-01-10#
Initial extraction of tskit code from msprime. Relicense to MIT. Code copied at hash 29921408661d5fe0b1a82b1ca302a8b87510fd23