ggtree
ggtree copied to clipboard
outgroup
dear yu
is there anyway to set an outgroup for draw a tree?
thanyou!
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)
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
I tried to coerce the class of the object, but there still are some problems.
How to fix this problem?
thanks a lot.
I think you need to apply root
to ml
not the ggtree object (ml_1
).
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