ggtree
ggtree copied to clipboard
How to reroot the tree?
Dear professor, I want to re root the tree according to the out group assigned. I use the FigTree Reroot function, the results is good. However I use R package of ape, the branch of length of rerooted tree is 0. I want to get the binary tree after rerooted as FigTree did. How to manipulated use ggtree? Thank you!
You can use the reroot
function in phytools to get better control of the rooted tree's branch lengths. To outgroup by the 4th tip:
library(phytools)
library(ape)
set.seed(1)
tree <- unroot(rtree(5))
len <- tree$edge.length[tree$edge[, 2] == 4]
rooted_tree <- reroot(tree, 4, len / 2)