This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract Divergence Times and Corresponding Node Numbers from a Time Tree

I need to extract divergence times and their corresponding node numbers for every node in a time tree (ultrametric), basically to create a table with one column for node numbers and one for the divergence time at that node. I've been trying to use phytools/ape/geiger , but I can't figure out how the phylo object stores the order of edge lengths from a tree. The divergence times from the time tree are being read into R as branch lengths, so I can't just print them as node labels. This is such a simple task, I think I'm missing something basic in extracting information from phylogenies.

phylogeny r ape phytools phylogenetics

1 answer

ggtree and treeio help here.

library("ggtree")
library("treeio")
beast_file <- system.file("examples/MCC_FluA_H3.tree", 
                          package="ggtree")
beast_tree <- read.beast(beast_file)
beast_tree@data %>% select(node,height)

Log in to answer this question.