I am looking for a way in R to convert a phylogenetic tree (Newick format or class "phylo") into a dataframe. The goal is to get a nice overview of which tips descent from every node of the tree. Does anyone have experience with this problem?
I can get all tip labels from a phylogenetic tree, or get all descendant nodes from a node, but I don't manage to get the tip labels that belong to a certain node.
#for a random tree x
x <- rtree(10, tip.label = LETTERS[1:10])
#get all tip labels by asking for tree information
> x
Phylogenetic tree with 10 tips and 9 internal nodes.
Tip labels:
H, G, D, B, I, C, ...
Rooted; includes branch lengths.
#descendant nodes from a node
test <- phytools::getDescendants(x, node=5, curr=NULL)
#the package ggphylo seemed to have the answer to my problem, but it is no longer supported (last updates were in 2012)
ggphylo::tree.as.data.frame(x)
(I think conversion to a dataframe is the easiest way but if you know another approach to get descendant tips from a node, I am open to every possible solution)