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

treedata object: cannot join on data column other than "node" #32

Open
nick-youngblut opened this issue Dec 20, 2022 · 2 comments
Open
Assignees

Comments

@nick-youngblut
Copy link

Works:

library(ape)
data(woodmouse)
d <- dist.dna(woodmouse)
tr <- nj(d)
bp <- boot.phylo(tr, woodmouse, function(x) nj(dist.dna(x)))
bp2 <- tibble(X=1:Nnode(tr) + Ntip(tr), bootstrap = bp)
full_join(tr, bp2, by=c('node'='X'))

Does not work:

library(ape)
data(woodmouse)
d <- dist.dna(woodmouse)
tr <- nj(d)
bp <- boot.phylo(tr, woodmouse, function(x) nj(dist.dna(x)))
bp2 <- tibble(X=1:Nnode(tr) + Ntip(tr), bootstrap = bp)
full_join(as.treedata(tr), bp2, by=c('node'='X'))

Error:

Error in match.arg(by, c("node", "label")) : 
  'arg' should be one of “node”, “label”

It appears that full_join() on a treedata object does not work with the standard dplyr UI of by=c('columnX'='columnY'), but instead, one MUST use by=c('node').

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] heatmaply_1.4.0       viridis_0.6.2         viridisLite_0.4.1     tidygraph_1.2.2       ggrepel_0.9.2        
 [6] ggtree_3.6.2          tidytree_0.4.1        treeio_1.22.0         ape_5.6-2             data.tree_1.0.0      
[11] lubridate_1.9.0       timechange_0.1.1      memoise_2.0.1         tidytable_0.9.1       data.table_1.14.6    
[16] plotly_4.10.1         ggplot2_3.4.0         visNetwork_2.1.2      reactable_0.3.0       collapsibleTree_0.1.7
[21] shinyTree_0.2.7       shinyWidgets_0.7.5    shinycssloaders_1.0.0 shinyBS_0.61.1        jsonlite_1.8.3       
[26] paws_0.1.12           styler_1.8.1          lintr_3.0.2           languageserver_0.3.14 dbplyr_2.2.1         
[31] dplyr_1.0.10          RPostgres_1.4.4       DBI_1.1.3             shiny_1.7.3           aws.signature_0.6.0  
[36] aws.s3_0.3.21         httr_1.4.4           

loaded via a namespace (and not attached):
 [1] colorspace_2.0-3              ellipsis_0.3.2                rsconnect_0.8.28             
 [4] rprojroot_2.0.3               base64enc_0.1-3               aplot_0.1.8                  
 [7] paws.security.identity_0.1.12 rstudioapi_0.14               farver_2.1.1                 
[10] remotes_2.4.2                 bit64_4.0.5                   fansi_1.0.3                  
[13] xml2_1.3.3                    codetools_0.2-18              R.methodsS3_1.8.2            
[16] cachem_1.0.6                  R.oo_1.25.0                   BiocManager_1.30.19          
[19] compiler_4.2.1                assertthat_0.2.1              fastmap_1.1.0                
[22] lazyeval_0.2.2                cli_3.4.1                     later_1.3.0                  
[25] htmltools_0.5.3               tools_4.2.1                   igraph_1.3.5                 
[28] gtable_0.3.1                  glue_1.6.2                    reshape2_1.4.4               
[31] Rcpp_1.0.9                    jquerylib_0.1.4               vctrs_0.5.1                  
[34] nlme_3.1-157                  iterators_1.0.14              crosstalk_1.2.0              
[37] paws.common_0.5.1             stringr_1.4.1                 ps_1.7.2                     
[40] mime_0.12                     lifecycle_1.0.3               renv_0.15.5                  
[43] dendextend_1.16.0             ca_0.71.1                     scales_1.2.1                 
[46] TSP_1.2-1                     hms_1.1.2                     promises_1.2.0.1             
[49] rex_1.2.1                     parallel_4.2.1                RColorBrewer_1.1-3           
[52] yaml_2.3.6                    curl_4.3.3                    gridExtra_2.3                
[55] ggfun_0.0.9                   yulab.utils_0.0.5             sass_0.4.2                   
[58] stringi_1.7.8                 desc_1.4.2                    foreach_1.5.2                
[61] seriation_1.4.0               cyclocomp_1.1.0               rlang_1.0.6                  
[64] pkgconfig_2.0.3               lattice_0.20-45               fontawesome_0.4.0            
[67] purrr_0.3.5                   patchwork_1.1.2               htmlwidgets_1.5.4            
[70] labeling_0.4.2                bit_4.0.5                     processx_3.8.0               
[73] tidyselect_1.2.0              plyr_1.8.8                    magrittr_2.0.3               
[76] R6_2.5.1                      generics_0.1.3                pillar_1.8.1                 
[79] withr_2.5.0                   tibble_3.1.8                  crayon_1.5.2                 
[82] utf8_1.2.2                    grid_4.2.1                    reactR_0.4.4                 
[85] blob_1.2.3                    callr_3.7.3                   webshot_0.5.4                
[88] digest_0.6.30                 xtable_1.8-4                  R.cache_0.16.0               
[91] tidyr_1.2.1                   httpuv_1.6.6                  gridGraphics_0.5-1           
[94] R.utils_2.12.2                munsell_0.5.0                 registry_0.5-1               
[97] ggplotify_0.1.0               bslib_0.4.1 
@nick-youngblut
Copy link
Author

Also, the docs at https://yulab-smu.top/treedata-book/chapter2.html#link-external-data do not explicitly state whether other joins (e.g., left_join()) can be used instead of full_join()

@nick-youngblut
Copy link
Author

It would also be helpful to include explicit docs/examples of joining on "label" instead of "node" at https://yulab-smu.top/treedata-book/chapter2.html#link-external-data, especially given that most users probably will be joining on tip labels versus the node numbers.

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