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?

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.)

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).

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

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.