oldPar <- par(mfrow = c(3, 1), mar = rep(0.5, 4))
tree <- as.phylo(898, 7)
tree$edge.length <- 11:22
plot(tree)
nodelabels()
edgelabels()
edgelabels(round(tree$edge.length, 2),
cex = 0.6, frame = "n", adj = c(1, -1))
# Collapse by node number
newTree <- CollapseNode(tree, c(12, 13))
plot(newTree)
nodelabels()
edgelabels(round(newTree$edge.length, 2),
cex = 0.6, frame = "n", adj = c(1, -1))
# Collapse by edge number
newTree <- CollapseEdge(tree, c(2, 4))
plot(newTree)
par(oldPar)
Run the code above in your browser using DataLab