YuLab-SMU / treeio

:seedling: Base Classes and Functions for Phylogenetic Tree Input and Output
https://yulab-smu.top/treedata-book/
94 stars 24 forks source link

add new as.phylo method for chronos class #54

Closed xiangpin closed 3 years ago

xiangpin commented 3 years ago

Description

when the phylo tree was processed, the new class c("chronos", "phylo") will return. Although ggtree provided fortify.phylo can process it, but as.phylo in the internal of this function cannot process this object.

Related Issue

https://groups.google.com/g/bioc-ggtree/c/9h3f8D3nlVs/m/0pBbzIoVAwAJ

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

Example

> library(ape)
> library(treeio)
treeio v1.15.7  For help: https://yulab-smu.top/treedata-book/

If you use treeio in published research, please cite:

LG Wang, TTY Lam, S Xu, Z Dai, L Zhou, T Feng, P Guo, CW Dunn, BR Jones, T Bradley, H Zhu, Y Guan, Y Jiang, G Yu. treeio: an R package for phylogenetic tree input and output with richly annotated and associated data. Molecular Biology and Evolution 2020, 37(2):599-603. doi: 10.1093/molbev/msz240

> set.seed(123)
> tr <- rtree(10)
> chr <- chronos(tr)

Setting initial dates...
Fitting in progress... get a first set of estimates
         (Penalised) log-lik = -14.9003 
Optimising rates... dates... -14.9003 

log-Lik = -14.75905 
PHIIC = 81.7 
> class(chr)
[1] "chronos" "phylo"  
> library(ggtree)
ggtree v2.4.2  For help: https://yulab-smu.top/treedata-book/

If you use ggtree in published research, please cite the most appropriate paper(s):

1. Guangchuang Yu. Using ggtree to visualize data on tree-like structures. Current Protocols in Bioinformatics, 2020, 69:e96. doi:10.1002/cpbi.96
2. Guangchuang Yu, Tommy Tsan-Yuk Lam, Huachen Zhu, Yi Guan. Two methods for mapping and visualizing associated data on phylogeny using ggtree. Molecular Biology and Evolution 2018, 35(12):3041-3043. doi:10.1093/molbev/msy194
3. Guangchuang Yu, David Smith, Huachen Zhu, Yi Guan, Tommy Tsan-Yuk Lam. ggtree: an R package for visualization and annotation of phylogenetic trees with their covariates and other associated data. Methods in Ecology and Evolution 2017, 8(1):28-36. doi:10.1111/2041-210X.12628

> ggtree(chr)
屏幕快照 2021-05-01 23 33 15
GuangchuangYu commented 3 years ago

should be fixed in ape, see https://github.com/emmanuelparadis/ape/pull/10.

GuangchuangYu commented 3 years ago

fixed in https://github.com/emmanuelparadis/ape/commit/b362e4245b09132c5ed7f9afff0cb4425f3c6e42