Turning a tree sequence into a networkx graph #2061
hyanwong
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
There's information in the tutorials about turning a tree into a networkx graph, but some complications with doing it for an entire tree sequence (see #1296). But in case anyone else wants to do it for a tree sequence rather than a tree, here the most efficient way I've found to do this, via a pandas DataFrame. This adds the time and flags as a node attribute. We could add other attributes too, even metadata.
Note that we need
nx.MultiDiGraph
because we could have 2 edges connecting the same nodes (at different genomic locations)Beta Was this translation helpful? Give feedback.
All reactions