How to root a tree in R with a polytomy at the root
2
0
Entering edit mode
6.8 years ago
hyanwong ▴ 70

In R, I have a phylogenetic tree like this, with a polytomy at the root:

library(ape)
t1 = read.tree(text="[&R] (1:1.250,2:1.250,(3:0.750,(4:0.500,5:0.500):0.250):0.500);")

But it is treated as unrooted:

> is.rooted(t1)
[1] FALSE

How can I force it to be rooted at the polytomy?

R phylogenetics • 5.2k views
ADD COMMENT
0
Entering edit mode

What exactly do you want to do with this if you force to to be rooted? One option is to randomly resolve the polytomy, but that is dangerous if you're doing further downstream analysis?

ADD REPLY
0
Entering edit mode

I want to compare this tree with an alternative (in this example, strictly bifurcating) tree, as (1:0.833,(2:0.225,(3:0.209,(4:0.114,5:0.114):0.095):0.016):0.608);, and calculate distance metrics between them. This is not strictly defined for some common stats, such as the Robinson-Foulds distance, but is for e.g. the Kendall-Colijn metric (treeDist from the treescape package)

ADD REPLY
1
Entering edit mode
6.8 years ago
hyanwong ▴ 70

Emmanuel Paradis has pointed out that the solution is simple - the tree is treated as unrooted because the deepest node has no length. So all I have to do is to place ":0" before the terminal semicolon, and the tree should be treated as rooted.

ADD COMMENT
0
Entering edit mode

Glad that you got it sorted out.

ADD REPLY
1
Entering edit mode

Cheers. Always good to get advice from the author of the library :)

ADD REPLY
0
Entering edit mode
6.8 years ago

You can root it yourself like this (here we set 1 as the root):

library(ape)

t1 = read.tree(text="[&R] (1:1.250,2:1.250,(3:0.750,(4:0.500,5:0.500):0.250):0.500);")

t1 <- root(t1, outgroup=1, resolve.root=TRUE)

is.rooted(t1)
[1] TRUE

par(mfrow=c(1,2))
plot(t1, type="cladogram", main="Rooted at 1")
plot(t1, type="unrooted", main="Unrooted")

Captura_de_tela_de_2018_01_19_15_21_26

ADD COMMENT
0
Entering edit mode

Does that maintain the polytomy? I.e. is this the same tree as if it were rooted at 2? From a casual inspection it seems not:

> t1 = read.tree(text="[&R] (1:1.250,2:1.250,(3:0.750,(4:0.500,5:0.500):0.250):0.500);")
> t2 <- root(t1, outgroup=1, resolve.root=TRUE)
> t3 <- root(t1, outgroup=2, resolve.root=TRUE)
> RF.dist(t2,t3, rooted=TRUE)
[1] 2
ADD REPLY

Login before adding your answer.

Traffic: 719 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6