0

I'm working with ape package currently. My idea is to extract tip labels corresponding to each node and also distances in between the nodes. How can I do this?

Thanks a lot for your help

1 Answers1

0

Here is how to interpret distances between nodes/tips in a phylo object (note that for dispRity::tree.age you'll need to install dispRity from GitHub https://github.com/TGuillerme/dispRity):

set.seed(1)
tree <- rtree(5)
tree$node.label <- paste0("n", 6:9)
plot(tree)
nodelabels(tree$node.labe)
axisPhylo()

## The distance between each tip
cophenetic(tree)

## The height of each tip and node
library(dispRity)
dispRity::tree.age(tree, order = "present")

## The distance between each nodes/tips
distances <- cbind(tree$edge, tree$edge.length)
colnames(distances) <- c("from", "to", "distance")
distances

This distance table reads as from element (tip/node) n to element (tip/node) m. The numbering works as follow: 1 is the first tip in the tree (tree$tip.label[1]), 2 is the second etc... 6 (number of tips + 1) is the first node in the tree (tree$node.label[1]), etc.

Thomas Guillerme
  • 1,747
  • 4
  • 16
  • 23