tree <- BalancedTree(10)
# Add a leaf below an internal node
plot(tree)
ape::nodelabels()
node <- 15
ape::nodelabels(bg = ifelse(NodeNumbers(tree) == node, "green", "grey"))
plot(AddTip(tree, 15, "NEW_TIP"))
# Add edge lengths for an ultrametric tree
tree$edge.length <- rep(c(rep(1, 5), 2, 1, 2, 2), 2)
# Add a leaf to an external edge
leaf <- 5
plot(tree)
ape::tiplabels(bg = ifelse(seq_len(NTip(tree)) == leaf, "green", "grey"))
plot(AddTip(tree, 5, "NEW_TIP", edgeLength = NULL))
# Set up multi-panel plot
oldPar <- par(mfrow = c(2, 4), mar = rep(0.3, 4), cex = 0.9)
# Add leaf to each edge on a tree in turn
backbone <- BalancedTree(4)
# Treating the position of the root as instructive:
additions <- AddTipEverywhere(backbone, includeRoot = TRUE)
xx <- lapply(additions, plot)
par(mfrow = c(2, 3))
# Don't treat root edges as distinct:
additions <- AddTipEverywhere(backbone, includeRoot = FALSE)
xx <- lapply(additions, plot)
# Restore original plotting parameters
par(oldPar)
Run the code above in your browser using DataLab