Skip to content

As.phylo as.treedata #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 12, 2021
Merged

Conversation

xiangpin
Copy link
Member

Description

The original as.phylo and as.treedata can not convert the data.frame which contained the parent and children of tbl_tree.
They just supported converting the edge matrix of phylo class.

Related Issue

#59

Example

> library(treeio)
treeio v1.17.1.991  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(2017)
> a <- rtree(4) %>% as_tibble() %>% as.data.frame()
> a
  parent node branch.length label
1      5    1   0.434905600    t4
2      7    2   0.674331481    t1
3      7    3   0.002020766    t3
4      6    4   0.025093514    t2
5      5    5            NA  <NA>
6      5    6   0.472166386  <NA>
7      6    7   0.273833123  <NA>
> class(a)
[1] "data.frame"
> a %>% as.treedata()
'treedata' S4 object'.

...@ phylo:
Phylogenetic tree with 4 tips and 3 internal nodes.

Tip labels:
  1, 4, 2, 3
Node labels:
  5, 6, 7

Rooted; no branch lengths.

with the following features available:
        'branch.length',        'label'.
> a %>% as.phylo(length="branch.length")

Phylogenetic tree with 4 tips and 3 internal nodes.

Tip labels:
  1, 4, 2, 3
Node labels:
  5, 6, 7

Rooted; includes branch lengths.
> a %>% as.treedata(length="branch.length")
'treedata' S4 object'.

...@ phylo:
Phylogenetic tree with 4 tips and 3 internal nodes.

Tip labels:
  1, 4, 2, 3
Node labels:
  5, 6, 7

Rooted; includes branch lengths.

with the following features available:
        'label'.

@GuangchuangYu GuangchuangYu merged commit e689ab8 into YuLab-SMU:master Jun 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants