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

as.treedata creating label.x and label.y columns in some cases #87

Open
nick-youngblut opened this issue Oct 7, 2022 · 0 comments
Open
Assignees

Comments

@nick-youngblut
Copy link

The expected result of using as.treedata, according to the example in the function docs:

library(ape)
library(dplyr)
set.seed(2017)
tree <- rtree(4)
d <- tibble(label = paste0('t', 1:4),
            trait = rnorm(4))
x <- as_tibble(tree)
full_join(x, d, by = 'label') %>% 
  as.treedata

Output:

'treedata' S4 object'.

...@ phylo:

Phylogenetic tree with 4 tips and 3 internal nodes.

Tip labels:
  t4, t1, t3, t2

Rooted; includes branch lengths.

with the following features available:
  'trait'.

# The associated data tibble abstraction: 7 × 4
# The 'node', 'label' and 'isTip' are from the phylo tree.
   node label isTip  trait
  <int> <chr> <lgl>  <dbl>
1     1 t4    TRUE   0.943
2     2 t1    TRUE  -0.171
3     3 t3    TRUE   0.570
4     4 t2    TRUE  -0.283
5     5 NA    FALSE NA    
6     6 NA    FALSE NA    
7     7 NA    FALSE NA   

reprex of the issue

library(treeio, warn.conflicts = FALSE)
library(ggtree, warn.conflicts = FALSE)

df = data.frame(parent = c(5,7,7,6,5,5,6),
                node = c(1,2,3,4,5,6,7),
                label = c('t4','t1','t3','t2',NA,NA,NA))
as.treedata(df)

Output:

'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:
  'label'.

# The associated data tibble abstraction: 7 × 4
# The 'node', 'label' and 'isTip' are from the phylo tree.
   node label.x isTip label.y
  <int> <chr>   <lgl> <chr>  
1     1 1       TRUE  t4     
2     2 4       TRUE  t2     
3     3 2       TRUE  t1     
4     4 3       TRUE  t3     
5     5 5       FALSE NA     
6     6 6       FALSE NA     
7     7 7       FALSE NA 

sessionInfo

R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] treeio_1.20.2   ggtree_3.4.4    RPostgres_1.4.4

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9         pillar_1.8.1       compiler_4.2.1     yulab.utils_0.0.5 
 [5] tools_4.2.1        digest_0.6.29      bit_4.0.4          aplot_0.1.7       
 [9] viridisLite_0.4.1  jsonlite_1.8.2     tidytree_0.4.1     lifecycle_1.0.2   
[13] tibble_3.1.8       nlme_3.1-157       gtable_0.3.1       lattice_0.20-45   
[17] pkgconfig_2.0.3    rlang_1.0.6        cli_3.4.1          DBI_1.1.3         
[21] ggplotify_0.1.0    patchwork_1.1.2    parallel_4.2.1     fastmap_1.1.0     
[25] httr_1.4.4         dplyr_1.0.10       htmlwidgets_1.5.4  hms_1.1.2         
[29] generics_0.1.3     vctrs_0.4.2        gridGraphics_0.5-1 DT_0.25           
[33] bit64_4.0.5        grid_4.2.1         tidyselect_1.1.2   data.table_1.14.2 
[37] glue_1.6.2         R6_2.5.1           plotly_4.10.0      fansi_1.0.3       
[41] blob_1.2.3         ggplot2_3.3.6      purrr_0.3.4        tidyr_1.2.1       
[45] magrittr_2.0.3     htmltools_0.5.3    ellipsis_0.3.2     scales_1.2.1      
[49] assertthat_0.2.1   ape_5.6-2          colorspace_2.0-3   renv_0.15.5       
[53] utf8_1.2.2         lazyeval_0.2.2     munsell_0.5.0      ggfun_0.0.7
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

2 participants