Unable to reroot RAxML tree with ggtree
0
0
Entering edit mode
@kevinliamkeegan-14862
Last seen 6.2 years ago

Hello,

I'm having trouble rerooting a RAxML tree. Here's the code I am using:

tree <- read.newick("RAxML_bipartitions.result")
outgroup <- findMRCA(tree, c("species_1", "species_2"))
tree <- reroot(tree, outgroup)

The last line produces the error:

Error in UseMethod("root") : 
  no applicable method for 'root' applied to an object of class "list"
In addition: Warning message:
In drop.tip(tree, tip, trim.internal = FALSE) :
  drop all tips of the tree: returning NULL

Any ideas on how to fix this error? Using read.tree or read.RAxML does not fix the problem.

Thanks!

Here's my session info:

 

R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               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    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

other attached packages:
 [1] abind_1.4-5         stringi_1.1.6       stringr_1.2.0       ggrepel_0.7.0       phytools_0.6-44     maps_3.2.0         
 [7] ggtree_1.10.2       treeio_1.2.1        ggplot2_2.2.1       Biostrings_2.46.0   XVector_0.18.0      IRanges_2.12.0     
[13] S4Vectors_0.16.0    BiocGenerics_0.24.0 ape_5.0            

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.15            pillar_1.1.0            compiler_3.4.3          plyr_1.8.4              tools_3.4.3            
 [6] zlibbioc_1.24.0         jsonlite_1.5            tibble_1.4.2            nlme_3.1-131            gtable_0.2.0           
[11] lattice_0.20-35         pkgconfig_2.0.1         rlang_0.1.6             fastmatch_1.1-0         igraph_1.1.2           
[16] Matrix_1.2-12           rvcheck_0.0.9           yaml_2.1.16             expm_0.999-2            mvtnorm_1.0-6          
[21] coda_0.19-1             combinat_0.0-8          scatterplot3d_0.3-40    grid_3.4.3              glue_1.2.0             
[26] plotrix_3.7             survival_2.41-3         phangorn_2.3.1          animation_2.5           tidyr_0.7.2            
[31] purrr_0.2.4             magrittr_1.5            scales_0.5.0            MASS_7.3-48             splines_3.4.3          
[36] mnormt_1.5-5            colorspace_1.3-2        numDeriv_2016.8-1       quadprog_1.5-5          lazyeval_0.2.1         
[41] munsell_0.4.3           msm_1.6.5               clusterGeneration_1.3.4
ggtree raxml reroot tree • 3.4k views
ADD COMMENT
0
Entering edit mode

I just encountered the same problem myself and was not able to find any mention of this issue anywhere else on the internet except here. The problem appears to be caused by ggtree and/or treeio; when I cleared my environment and started a new R session and ran everything except those packages, I was able to perform a similar operation to the one you describe without any more problems. One of these packages must be modifying the way that tree files are handled in a way that is not compatible with phytools' reroot function (which is integral in a number of other functions, e.g. phylomorphospace). So: if in doubt, try detaching those two packages and try again. If that doesn't work, remove all packages and reload all but those (I guess it could be in their dependencies too).

ADD REPLY
0
Entering edit mode

I too had this problem, though I am dealing with MrBayes tree, which I too imported using treeio. I think the problem is that treeio creates an object of the treedata class, while reroot function operates with class phylo. I used ape::as.phylo function, and everything worked.

outgroup <- findMRCA(as.phylo(tree), c("species1", "species2")) rooted_tree <- reroot(as.phylo(tree), outgroup)

ADD REPLY
0
Entering edit mode

treeio does extend root to work with treedata. It would be better to use the root.treedata method as it will adjust associated data according to the change of tree structure.

ADD REPLY

Login before adding your answer.

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