Skip to content

GRG ->TS conversion - #160

Merged
dcdehaas merged 3 commits into
mainfrom
grg2ts
Aug 17, 2026
Merged

dcdehaas merged 3 commits into
mainfrom
grg2ts

Conversation

@dcdehaas

Copy link
Copy Markdown
Member

Naive algorithm for converting from GRG to tskit TreeSequence. The multi-tree is traversed in Mutation order (lowest BP to highest BP) and the subtree below each mutation is copied to the current coalescent tree. When an edge violates the tree property (more than one parent), we delete the edge ("recombination").

This functionality is for experimental purposes only - it will likely change and the value of it is unclear (so it may go away).

Can now convert in both directions. The algorithm is pretty simple,
but could be made simpler (at least in the code) in how it manages
state. The GRG is traversed according to mutations in left-to-
right order, and each such subtree below a mutation is added to
the current coalescent tree. If adding that subtree will break
the tree property (i.e., making it a multi-tree) then the
offending parent edges are deleting from coalescent tree. Each
coalescent tree is rooted by a single node, which sometimes
requires the creation of synthetic nodes (ones not found in the
GRG). The node times are fake, and just represent a topological
order of the nodes.
When --no-simplify is provided, prevent simplification of the
graph at every stage of construction.
Remove some debugging code, add the Python API. Add a simple
end-to-end test.

The Python API docs include a warning that this functionality is
experimental and subject to change.
@dcdehaas
dcdehaas merged commit b914c36 into main Aug 17, 2026
7 checks passed
@dcdehaas
dcdehaas deleted the grg2ts branch August 17, 2026 12:54
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.

1 participant