emmanuelparadis / ape

analysis of phylogenetics and evolution
http://ape-package.ird.fr/
GNU General Public License v2.0
52 stars 11 forks source link

Confused about results of dist.nodes on BEAST output tree #107

Closed katherinermartin closed 7 months ago

katherinermartin commented 7 months ago

I've run dist.nodes on a tree that's output from BEAST2 (attached). Can you help me understand where the numbers in the resulting matrix are coming from or how they're being computed? I'm used to genetic or phylogenetic distance pairwise comparisons being less than one, but these are greater than one. My understanding is that dist.nodes and cophenetic.phylo are computing pairwise distances between nodes based on branch lengths; perhaps these are some form of raw branch length?

Here's the code (just a note, the tree is rather large and so is the resulting matrix, but it should run just fine):

# read in BEAST tree from Phillips et al. 2022
beasttree <- read.mrbayes("run2_treeannotator_Yule_uniform.txt")
beasttree <- as.phylo(beasttree)
phylo_dist <- as.data.frame(dist.nodes((beasttree)))

Thank you 😃 [run2_treeannotator_Yule_uniform.txt] (https://github.com/emmanuelparadis/ape/files/14126806/run2_treeannotator_Yule_uniform.txt)

emmanuelparadis commented 7 months ago

dist.nodes uses the branch lengths as given in the tree, so depending on the unit of these branch lengths, adding them could very well be > 1.

katherinermartin commented 7 months ago

Okay that makes sense! So just to confirm,dist.nodes is calculating a sum of the branch lengths between any given pair of nodes, correct? Thanks so much!

emmanuelparadis commented 7 months ago

yes!

katherinermartin commented 7 months ago

Thank you 😃