slide.nodes | R Documentation |
Stretches a phylogenetic tree at a particular node
slide.nodes(nodes, tree, slide, allow.negative.root = FALSE)
nodes |
A list of the ID nodes to slide ( |
tree |
a |
slide |
the sliding value. |
allow.negative.root |
logical, whether to allow negative branch lengths and moving the root node ( |
The sliding works by subtracting the slide value to the branch leading to the node and adding it to the descendant branches. Note that the slide value can be negative to slide nodes the other way (up); the only requirement is that the slide does not lead to negative branch length values.
A "phylo"
object.
Thomas Guillerme
remove.zero.brlen
set.seed(42)
## Generating a coalescent tree
tree <- rcoal(5)
## Stretching node 8 up and down
tree_slide_up <- slide.nodes(8, tree, slide = 0.075)
tree_slide_down <- slide.nodes(8, tree, slide = -0.075)
## Display the results
par(mfrow = c(3,1))
plot(tree) ; axisPhylo() ; nodelabels()
plot(tree_slide_up) ; axisPhylo() ; nodelabels()
plot(tree_slide_down) ; axisPhylo() ; nodelabels()
## Stretching many nodes
set.seed(42)
tree <- rtree(50)
move_nodes <- c(99, 93, 53, 86, 58, 63, 60, 84)
tree_slided <- slide.nodes(move_nodes, tree, slide = 0.07)
## Display the results
par(mfrow = c(2, 1))
node_colors <- c("lightblue", "orange")[((1:Nnode(tree))+Ntip(tree)) %in% move_nodes + 1]
plot(tree, show.tip.label = FALSE) ; axisPhylo()
nodelabels(bg = node_colors, cex = 0.5)
plot(tree_slided, show.tip.label = FALSE) ; axisPhylo()
nodelabels(bg = node_colors, cex = 0.5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.