Skip to content
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

tbl_tree object to phylo object lost bootstrap column #49

Open
ypchan opened this issue Mar 10, 2021 · 2 comments
Open

tbl_tree object to phylo object lost bootstrap column #49

ypchan opened this issue Mar 10, 2021 · 2 comments

Comments

@ypchan
Copy link

ypchan commented Mar 10, 2021

Dear author and users,

axmlng_phylo <-  read.newick('concatenate_raxmlng_addoutgroup.raxml.support', node.label='support')
raxmlng_tibble <- as_tibble(raxmlng_phylo)
raxmlng_phylo_again < as.phylo(raxmlng_tibble )
raxmlng_phylo_tibble <- as_tibble(raxmlng_phylo_again)

the latter tibble lost the column bootstrap, how to avoid this?

@brj1
Copy link
Contributor

brj1 commented Mar 10, 2021

Dropping the support column is the desired behaviour of as.phylo. This is because as.phylo returns a phylo object that cannot contain data. One way to fix this would be to join the tibbles.

@GuangchuangYu maybe you should add a way to get from a tibble to treedata

@xiangpin
Copy link
Member

you can convert tbl_tree to treedata class, which contains phylo class and annotation data ..., using as.treedata, since tbl_tree contained support information. If you convert it to phylo class using as.phylo, it will not extract support or other annotation information, just return phylo class, because standard phylo class does not contain attributes to save annotation data information.

> library(treeio)
> library(tidytree)
> raxml_file <- system.file("extdata/RAxML", "RAxML_bipartitionsBranchLabels.H3", package="treeio")
> tr <- read.raxml(raxml_file)
> tab1 <- as_tibble(tr)
> tr
'treedata' S4 object that stored information of
        '/mnt/d/UbuntuApps/R/4.0.3/lib/R/library/treeio/extdata/RAxML/RAxML_bipartitionsBranchLabels.H3'.

...@ phylo:
Phylogenetic tree with 64 tips and 62 internal nodes.

Tip labels:
  A_Hokkaido_M1_2014_H3N2_2014, A_Czech_Republic_1_2014_H3N2_2014, FJ532080_A_California_09_2008_H3N2_2008, EU199359_A_Pennsylvania_05_2007_H3N2_2007, EU857080_A_Hong_Kong_CUHK69904_2006_H3N2_2006, EU857082_A_Hong_Kong_CUHK7047_2005_H3N2_2005, ...

Unrooted; includes branch lengths.

with the following features available:
        'bootstrap'.
> tab1
# A tibble: 126 x 5
   parent  node branch.length label                                    bootstrap
    <int> <int>         <dbl> <chr>                                        <dbl>
 1     66     1     0.00418   A_Hokkaido_M1_2014_H3N2_2014                    NA
 2     66     2     0.00239   A_Czech_Republic_1_2014_H3N2_2014               NA
 3     74     3     0.00601   FJ532080_A_California_09_2008_H3N2_2008         NA
 4     76     4     0.00594   EU199359_A_Pennsylvania_05_2007_H3N2_20…        NA
 5     77     5     0.00469   EU857080_A_Hong_Kong_CUHK69904_2006_H3N…        NA
 6     80     6     0.00234   EU857082_A_Hong_Kong_CUHK7047_2005_H3N2…        NA
 7     82     7     0.0000786 YGSIV1046_Sw_Binh_Duong_03_10_2010              NA
 8     82     8     0.00111   YGSIV1044_Sw_Binh_Duong_03_08_2010              NA
 9     85     9     0.00604   YGSIV1522_SW_HK_1071_2012                       NA
10     85    10     0.00362   YGSIV1534_SW_HK_2454_2012                       NA
# … with 116 more rows
> tr2 <- as.treedata(tab1)
> tr2
'treedata' S4 object'.

...@ phylo:
Phylogenetic tree with 64 tips and 62 internal nodes.

Tip labels:
  A_Hokkaido_M1_2014_H3N2_2014, A_Czech_Republic_1_2014_H3N2_2014, FJ532080_A_California_09_2008_H3N2_2008, EU199359_A_Pennsylvania_05_2007_H3N2_2007, EU857080_A_Hong_Kong_CUHK69904_2006_H3N2_2006, EU857082_A_Hong_Kong_CUHK7047_2005_H3N2_2005, ...

Unrooted; includes branch lengths.

with the following features available:
        'bootstrap'.
> as_tibble(tr2)
# A tibble: 126 x 5
   parent  node branch.length label                                    bootstrap
    <int> <int>         <dbl> <chr>                                        <dbl>
 1     66     1     0.00418   A_Hokkaido_M1_2014_H3N2_2014                    NA
 2     66     2     0.00239   A_Czech_Republic_1_2014_H3N2_2014               NA
 3     74     3     0.00601   FJ532080_A_California_09_2008_H3N2_2008         NA
 4     76     4     0.00594   EU199359_A_Pennsylvania_05_2007_H3N2_20…        NA
 5     77     5     0.00469   EU857080_A_Hong_Kong_CUHK69904_2006_H3N…        NA
 6     80     6     0.00234   EU857082_A_Hong_Kong_CUHK7047_2005_H3N2…        NA
 7     82     7     0.0000786 YGSIV1046_Sw_Binh_Duong_03_10_2010              NA
 8     82     8     0.00111   YGSIV1044_Sw_Binh_Duong_03_08_2010              NA
 9     85     9     0.00604   YGSIV1522_SW_HK_1071_2012                       NA
10     85    10     0.00362   YGSIV1534_SW_HK_2454_2012                       NA
# … with 116 more rows

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

No branches or pull requests

3 participants