Question: Rooting phylogenetic trees in R using Ape's root function: Trees don't seem to root.
0
gravatar for spiral01
3.3 years ago by
spiral0180
spiral0180 wrote:

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 • 9.7k views
ADD COMMENTlink modified 3.3 years ago • written 3.3 years ago by spiral0180
1

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 REPLYlink written 3.3 years ago by fanli.gcb670

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 REPLYlink written 3.3 years ago by moranr250

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 REPLYlink written 3.3 years ago by spiral0180

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 REPLYlink written 3.3 years ago by spiral0180
2
gravatar for spiral01
3.3 years ago by
spiral0180
spiral0180 wrote:

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 COMMENTlink written 3.3 years ago by spiral0180

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 REPLYlink modified 3.3 years ago • written 3.3 years ago by fanli.gcb670
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: 1448 users visited in the last hour