Error when loading multiclass tree

169 views
Skip to first unread message

Pepijn Kooij

unread,
Apr 30, 2021, 2:36:54 PM4/30/21
to ggtree

For some analyses I had to manipulate the tree to become ultrametric using the chronos function in the package ape. Doing this changed my class from 'phylo' into 'chronos phylo'

> class(phy)
[1] "phylo"
> class(phy_ultra)
[1] "chronos" "phylo" 

this doesn't seem to give any problems with further analyses of the tree in other packages, however, when I try to load my tree in with ggtree I get the following error

Error in UseMethod("as.phylo") :
  no applicable method for 'as.phylo' applied to an object of class "c('chronos', 'phylo')"

Is there a way to circumvent calling as.phylo()? Or is there another way to solve this?

Cheers
Pepijn

Huan Fan

unread,
Dec 23, 2021, 3:35:19 AM12/23/21
to ggtree
Hi Pepijn,

In case you haven't solved this, you can get around it by writing your chronos object out and read it in. 

e.g.
> write.tree(phy_ultra, 'my_ultra.tre')
> phy_ultra.p <- ape::read.tree('my_ultra.tre')

Hope this helps,
Huan
Reply all
Reply to author
Forward
0 new messages