ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

How to reroot the tree?

Open liufuyan2016 opened this issue 4 years ago • 1 comments

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!

liufuyan2016 avatar Mar 01 '20 05:03 liufuyan2016

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)

brj1 avatar Mar 02 '20 18:03 brj1