This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Measuring Evolutionary Distance Between Species from Chronogram

I have a chronogram from a published paper. It has the time scale in millions of years and all the species. I wanted to know how I can measure the evolutionary distance (in millions of years) between any 2 species on the chronogram. There are associated nexus files. Would it be possible to read the files into let's say R and extract that information?

phylogenetics

1 answer

If I've interpreted correctly, you want the time to the most recent common ancestor of any two species in the tree? If so, something like the following works:

library("ggtree")
library("treeio")
require("dplyr")

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

# choose some random tips for the purpose of this answer
tip1 <- beast_tree@phylo$tip.label[1]
tip2 <- beast_tree@phylo$tip.label[47]
mrca <- MRCA(beast_tree,tip1,tip2)
time_of_mrca <- beast_tree@data %>% dplyr::filter(node == mrca) %>% dplyr::select(height)

# use a function instead
get_mrca_height = function(tree,tip1,tip2){
  mrca_node <- MRCA(tree,tip1,tip2)
  mrca_height <- tree@data %>% dplyr::filter(node == mrca_node) %>% dplyr::pull(height)
  result <- dplyr::tibble(tip1=tip1, tip2=tip2, mrca_node_number=mrca_node,mrca_height=mrca_height)
  return(result)
}

get_mrca_height(beast_tree,tip1,tip2)

Output of the last function:

> get_mrca_height(beast_tree,tip1,tip2)
# A tibble: 1 × 4
  tip1                   tip2                          mrca_node_number mrca_height
  <chr>                  <chr>                                    <int>       <dbl>
1 A/Hokkaido/30-1-a/2013 A/Swine/Binh_Duong/03_10/2010               96        9.16

Log in to answer this question.