Hello.
I am seeking a way to find the immediate descendants of the root node in a phylogenetic tree such as with the function
get.desc.of.node()
from auteur or geiger libraries in R. However, this function doesn't seem to exist anymore, and I have struggled and failed to find ways to use the function from earlier versions.
For the immediate descendants, I eventually need to get the names of all the terminals in the two or more descendant clades. However, I can work up to that from something else, such as the node numbers, a list of all descendant node numbers on either side of the root, or something else.
I can think of plenty of rather forced ways to get what I want, such as finding the smallest node number in R, and then the next smallest two. This would work for bifurcating trees most of the time, though I am a little nervous about node numbers in R and worry that the smallest would not always be the root. Moreover, it would not work for trees that are not bifurcating at the root, unless I already knew how many nodes to expect.
I could also get a list of terminals in all clades using biopython and try to use the terminals within the largest clade to find its sister, where those terminals (and only those) should be missing. However that would not work if the tree is not bifurcating from the root.
I would like a way that's not so forced and more easily applicable to a wide breath of tree types.
Any help is appreciated, and thanks in advance.
Can't speak for R (though I imagine
ape
orphangorn
will cut it), but you should be able to do this withdendropy
in python fairly easily.Finding the root node first should be fairly trivial, then you can feed that information to a descendent finding function easily enough I would imagine. I'll look in to some code, but that'll probably get you going in the mean time..
Thanks a lot. I agree that finding the root -should- be fairly easy. I've bveen invested in R for the last few hours. Maybe I'll put that on hold and try dendropy.
It's getting late here so I don't have a full code solution for you but it seems with dendropy its as simple as reading a tree in then accessing the 'seed node'
e.g.
The
.seed_node
object has a lot of methods and data associated with it, so there's bound to be something in there you can use: http://dendropy.org/prerelease/library/treemodel.html?highlight=seed_nodeThere will be methods for accessing the child nodes.
Thanks again. I was also just playing around with seed_node. I can probably make that work. Your help in pointing me to dendropy is appreciated.