#simulation with an example non-ultrametric tree
tree <- rtree(20)
# randomly replace edges with ZLBs
# similar to multi2di output
tree <- degradeTree(tree,0.3,
leave.zlb = TRUE)
tree2 <- minBranchLength(tree,0.1)
layout(1:2)
plot(tree)
axisPhylo()
plot(tree2)
axisPhylo()
layout(1)
#now let's try it with an ultrametric case
# get a random tree
tree <- rtree(30)
# randomly replace edges with ZLBs
# similar to multi2di output
tree <- degradeTree(tree,0.5,leave.zlb = TRUE)
# now randomly resolve
tree <- di2multi(tree)
# give branch lengths so its ultrametric
tree <- compute.brlen(tree)
# and we have an ultrametric tree with polytomies, yay!
plot(tree)
# now randomly resolve
tree2 <- multi2di(tree)
# get new branch lengths as would with real data
tree2 <- minBranchLength(tree2,0.1)
layout(1:2)
plot(tree,show.tip.label = FALSE)
axisPhylo()
plot(tree2,show.tip.label = FALSE)
axisPhylo()
layout(1)
# check that root ages aren't being left unmodified
# create a tree with lots of ZBLs at the root
x <- stree(10)
x$edge.length <- runif(Nedge(x))
x <- multi2di(x)
# give it a root age
x$root.time <- max(node.depth.edgelength(x))
z <- minBranchLength(tree = x, mbl = 1)
plot(z)
Run the code above in your browser using DataLab