Rooting phylogenetic trees in R using Ape's root function: Trees don't seem to root.
1
0
Entering edit mode
8.6 years ago
spiral01 ▴ 110

Hi, I have a dataset of roughly 7000 trees in newick format that I have loaded into R. Each tree has 5 tips, each representing a species. As the trees are not rooted, I am trying to root the trees using one of the species (AGAP) as the outgroup. However, when I run the root function like so:

x <- root(nh.tree.list[[1]], outgroup = "AGAP")

The tree does indeed shift so that the node below the tip AGAP is at the base of the tree, but the tree remains unrooted (which I can confirm using the is.rooted command). This tree in question in newick format is:

(AMEM:0.06608854676,AARA:0.05958550382((AGAP:0.08235019885,AQUA:0.05921768275):0.0120129681,AMEC:0.06541441488):0.007929218113);

I need to root the trees as the analysis I intend to do requires rooted trees. In case it helps, these trees were created from multiple sequence alignment fasta files, using neighbour joining methods (njs function). I cannot fathom why the trees aren't being rooted. Can anyone shed any light on this? Thanks.

phylogenetics R • 27k views
ADD COMMENT
2
Entering edit mode

That tree shows up as rooted for me:

> tree = read.tree()
1: (AMEM:0.06608854676,AARA:0.05958550382((AGAP:0.08235019885,AQUA:0.05921768275):0.0120129681,AMEC:0.06541441488):0.007929218113);
2: 
> tree

Phylogenetic tree with 4 tips and 3 internal nodes.

Tip labels:
[1] "AMEM" "AARA" "AGAP" ""    
Node labels:
[1] ""     "AMEC" "AQUA"

Rooted; includes branch lengths.
ADD REPLY
0
Entering edit mode

I got the same as Fanli.gcb when i ran on Ape too. Plot the tree, you will see if its rooted or not. Maybe there is a problem with function to check rooting or something.

ADD REPLY
0
Entering edit mode

This is very strange. I am still getting:

Phylogenetic tree with 5 tips and 3 internal nodes.

Tip labels:
[1] "AMEM" "AARA" "AGAP" "AQUA" "AMEC"

Unrooted; includes branch lengths.

When I plotted it is still not rooted. I tried to read in the tree independently from the same information I have given you and I still got the above message, using no arguments other than file for read.tree. The fact that two of you got the same means there's something wrong my end, though I am not sure what it might be.

ADD REPLY
1
Entering edit mode

Ok I think I know what my issue is. I was using read.tree(file = "filename") which seems to result in an unrooted tree. You guys did read.tree(), and then entered tree details on the next line, as fanli.gcb already showed. However, how can I do this if I need to read in 7000 files? To be clear, I am talking about the difference between this:

tree <- read.tree(file = "species_tree_align_0.fasta.nh")

Which produces an unrooted tree, and this:

> tree3 = read.tree()
1:(AMEM:0.06608854676,AARA:0.05958550382((AGAP:0.08235019885,AQUA:0.05921768275):0.0120129681,AMEC:0.06541441488):0.007929218113);
2:

Which produces the rooted tree. What I need to know is how to achieve the latter tree when reading in multiple files?

ADD REPLY
3
Entering edit mode
8.6 years ago
spiral01 ▴ 110

Apologies for the multiple posting, but have resolved this issue by using the root function, and the resolve.root argument set to true as per the below:

x <- root(nh.tree.list[[1]], outgroup = "AGAP", resolve.root = TRUE)

Thanks for all the help!

ADD COMMENT
1
Entering edit mode

Glad to see you figured it out, but I'm still a bit worried that your read.tree seems to give an unrooted tree. I don't think it's due to differences in reading from file versus command line:

> tree=read.tree(file="tree.nh")
> tree

Phylogenetic tree with 4 tips and 3 internal nodes.

Tip labels: [1] "AMEM" "AARA" "AGAP" ""     Node labels: [1] ""    
"AMEC" "AQUA"

Rooted; includes branch lengths.

What version of ape are you using?

> sessionInfo()
R version 3.2.3 Patched (2015-12-22 r69809)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: openSUSE 13.1 (Bottle) (x86_64)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] ape_3.4

loaded via a namespace (and not attached):
[1] nlme_3.1-126    grid_3.2.3      lattice_0.20-33
ADD REPLY

Login before adding your answer.

Traffic: 2945 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