Question: Difference between ape::root, ggtree::reroot and phytools::reroot in R
1
gravatar for Michael
11 months ago by
Michael20
Michael20 wrote:

Hi all,

I have been using R to create and manipulate phylogenetic trees for a while, but I was wondering what the differences are between the rooting functions in different packages, ape::root, ggtree::reroot and phytools::reroot.

I have attached an example. Every tree looks slightly different, and the tree created by ggtree::reroot seems best to me. Could anyone explain the differences?

tree <- read.tree(text = "(t6:0.3806255851,(t7:0.5440872659,(t5:0.6203179485,t1:0.7089423968):0.3421749519):0.2618428892,((t4:0.5886056426,t3:0.8614832051):0.09094934678,(t8:0.6766210056,t2:0.1412485428):0.4451906278):0.2356684168);")

par(mfcol=c(2,2), mar=c(0.5,0.5,1.3,0.5))

plot(tree)
nodelabels()
title("original")

tree1 <- ape::root(tree, node = 11)
plot(tree1)
nodelabels()
title("ape::root")

tree2 <- ggtree::reroot(tree, 11)
plot(tree2)
nodelabels()
title("ggtree::reroot")

tree3 <- phytools::reroot(tree, 11)
plot(tree3)
nodelabels()
title("phytools::reroot")

Example

Any explanation would be greatly appreciated.

Best wishes,

Michael

ape ggtree phytools phylogenetics R • 1.6k views
ADD COMMENTlink modified 11 months ago • written 11 months ago by Michael20

I don't see any difference between the rooted trees. What are the differences?

ADD REPLYlink written 11 months ago by h.mon26k
5
gravatar for liam.revell
11 months ago by
liam.revell100
liam.revell100 wrote:

ggtree::reroot is not re-rooting the tree at node 11, but on the edge connecting nodes 10 & 11, so is incorrect since the position used along this edge (its midpoint?) is arbitrary. If desired this can be done using phytools::reroot by specifying the position at which the tree should be re-rooted. (I suspect it can also now be done by ape::root.)

ADD COMMENTlink written 11 months ago by liam.revell100

currently ggtree::reroot call phytools::reroot by specifying the position at the middle of the edge.

ADD REPLYlink written 11 months ago by Guangchuang Yu2.2k

Thanks so much for the clarification, Liam and Guangchuang.

ADD REPLYlink written 11 months ago by Michael20

The ggtree::reroot seems to be moved to the treeio package and it no longer called phytools::reroot for making the root as the midpoint of the branch. Instead, it called ape::root.phylo to root the tree. Is there anyone knowing why making this change? What's the rationale behind it? By using the new function, the re-rooted tree looks different from the tree re-rooted using FigTree. I was wondering which rooting method is better for making a publication figure? Thanks.

ADD REPLYlink written 15 days ago by Michael20
4
gravatar for liam.revell
11 months ago by
liam.revell100
liam.revell100 wrote:

Just to clarify, the reason the tree from ggtree 'looks' better is because it is still bifurcating - but a bifurcating tree rooted at an internal node should contain a trifurcation at the root (as do the trees from phytools & ape). To obtain a bifurcating tree from rerooting an existing bifurcating tree we must position the root along an edge - but an edge is defined by two nodes, not one. Furthermore, we also need to specify where on the edge the rerooting must take place. In phytools this can be done using the argument position, or by selecting it interactively by setting interactive=TRUE (in which case we can click on the position along the edge where we would like the tree to be rooted).

ADD COMMENTlink written 11 months ago by liam.revell100
1

Hi Liam, So can I say that ape::root and phytools::reroot do the similar thing for rerooting the tree, except phytools also creates a new node (node 15) and a root.edge of length 0 (between nodes 9 and 15), which makes the tree really rooted? Many thanks, Michael

ADD REPLYlink written 11 months ago by Michael20
1

Ooh. Excellent observation. Yes, phytools::reroot & ape::root both (by default) root at the node, but reroot by placing the root zero distance below the node & root at the node. Consequently, phytools::reroot = ape::root(...,resolve.root=TRUE) when all other defaults are used.

ADD REPLYlink written 11 months ago by liam.revell100
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 641 users visited in the last hour