ggtree icon indicating copy to clipboard operation
ggtree copied to clipboard

outgroup

Open huangl07 opened this issue 7 years ago • 4 comments

dear yu

is there anyway to set an outgroup for draw a tree?

thanyou!

huangl07 avatar Nov 17 '17 02:11 huangl07

You can use the package, ape, to root the tree with respect to an outgroup.

library(ape)
library(ggtree)
tree <- read.tree(text="(((A, B),(C,D)),E);")
ggtree(tree) + geom_tiplab()
rooted.tree <- root(tree, which(tree$tip.label == "C"))
ggtree(rooted.tree) + geom_tiplab() # rooted by the outgroup C
rooted.tree <- root(tree, which(tree$tip.label %in% c("C","D")))
ggtree(rooted.tree) + geom_tiplab() # rooted by the outgroup (C, D)

brj1 avatar Nov 29 '17 21:11 brj1

dear yu, I import a tree file produced by RAxML, and then to use the method of root() to reroot my tree. However, there are some problems happened with the object. It seems that this method only support an object of the 'multiphylo' and 'phylo' class. How to solve this problem? there are the output error default default I tried to coerce the class of the object, but there still are some problems. default How to fix this problem? thanks a lot.

ghost avatar Aug 23 '18 14:08 ghost

I think you need to apply root to ml not the ggtree object (ml_1).

tkdspace avatar Aug 05 '20 15:08 tkdspace

I import a tree file produced by RAxML, and then to use the method of root() to reroot my tree. However, there are some problems happened with the object. It seems that this method only support an object of the 'multiphylo' and 'phylo' class. How to solve this problem? there are the output error

@MeiyuanJi:

I had this problem too, and the as.phylo() command (ape) seemed to help. Run this immediately after reading the tree with read.raxml and I believe the following ape commands such as ape::root() should work, as this will convert it to a "phylo" object

twohrdrive avatar Oct 09 '20 10:10 twohrdrive