-
Hi all, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 6 replies
-
There isn't a function to do it currently in tskit @stsmall, and I guess we probably should add it. In the mean time, this will work: import tskit
import functools
tree = tskit.Tree.generate_balanced(9, arity=2)
print(tree.draw_text())
nodes = [0, 2, 3]
mrca = functools.reduce(tree.mrca, nodes)
print(mrca) gives:
This works because we can successively apply We should probably add this to the documentation, since it's such a neat and simple recipe. |
Beta Was this translation helpful? Give feedback.
-
@gtsambos had a good suggestion also - to use
which produces
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the question @stsmall - we've added an issue #1340 that will bring this functionality into tskit! If you're motivated to do so you could author the pull request yourself and get credit as a contributor. Guides to do so are at https://tskit.dev/tskit/docs/stable/development.html . You'll only need to touch the python code so ignore sections of that document that refer to the C API. |
Beta Was this translation helpful? Give feedback.
-
Hi All, |
Beta Was this translation helpful? Give feedback.
-
This can now be done by https://tskit.dev/tskit/docs/stable/python-api.html#tskit.Tree.mrca. This should probably be selected as the "correct" answer now. |
Beta Was this translation helpful? Give feedback.
This can now be done by https://tskit.dev/tskit/docs/stable/python-api.html#tskit.Tree.mrca. This should probably be selected as the "correct" answer now.