phylotastic / datelife

R package containing datelife's core functionality
http://phylotastic.org/datelife/
13 stars 11 forks source link

Summarising chronograms fails #81

Open irmoodie opened 1 year ago

irmoodie commented 1 year ago

Using any of the functions to summarise chronograms currently fails on the CRAN release.

The error seems to be associated with this line of code. I would try to fix it myself but for some reason the github version of the package fails to install for me: https://github.com/phylotastic/datelife/blob/0ee199af40aa259618bb8dd37fb8c813be9cad23/R/opentree_taxonomy.R#L93

Reproducible example using documentation example species list:

install.packages("datelife")
library(datelife)

datelifeQuery <- make_datelife_query(input = c("Delphinus_delphis",
                                               "Gallus gallus",
                                               "elephas Maximus",
                                               "felis_catus",
                                               "homo-sapiens"))

datelifeSearch <- datelife_search(datelifeQuery, summary_format = "phylo_median") # fails with any _median or _sdm

Output:

> install.packages("datelife")
trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.2/datelife_0.6.6.tgz'
Content type 'application/x-gzip' length 4106977 bytes (3.9 MB)
==================================================
downloaded 3.9 MB

The downloaded binary packages are in
    /var/folders/44/cwblklps305_5z72cp5d1z5w0000gn/T//RtmprtSRBc/downloaded_packages
> 
> library(datelife)
> 
> datelifeQuery <- make_datelife_query(input = c("Delphinus_delphis",
+                                                "Gallus gallus",
+                                                "elephas Maximus",
+                                                "felis_catus",
+                                                "homo-sapiens"))
---> Phylo-processing 'input'.
* 'input' is not a phylogeny.
---> Making a DateLife query.
---> Runnning TNRS to match input names to reference taxonomy (OTT).
  |====================================================================================================================================================================================================================================| 100%
---> Working with the following 5 taxa: Delphinus delphis | Gallus gallus | Elephas maximus | Felis silvestris | Homo sapiens.
DateLife query done!

> 
> datelifeSearch <- datelife_search(datelifeQuery, summary_format = "phylo_median")
... Running a DateLife search.
... Searching DateLife's OpenTree chronogram database version v2022.01.28
Search done!

Input taxon names were found in 17 chronograms.
Trying with overlap = 2

Success!

... Calculating a median summary chronogram.
... No target_tree was provided, obtaining a tree topology from Open Tree synthetic phylogeny.
  |====================================================================================================================================================================================================================================| 100%
Error in if (is.numeric(input$ott_id) & !is.na(input$ott_id)) { : 
  the condition has length > 1

Session info:

> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.1

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 utils     datasets  methods   base     

other attached packages:
[1] datelife_0.6.6

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.9          rstudioapi_0.14     magrittr_2.0.3      hms_1.1.2           progress_1.2.2      rotl_3.0.14         ape_5.6-2           lattice_0.20-45     R6_2.5.1            rlang_1.0.6         stringr_1.5.0      
[12] rentrez_1.2.3       httr_1.4.4          tools_4.2.2         parallel_4.2.2      grid_4.2.2          compare_0.2-6       data.table_1.14.6   nlme_3.1-160        cli_3.6.0           ellipsis_0.3.2      abind_1.4-5        
[23] lifecycle_1.0.3     crayon_1.5.2        BiocManager_1.30.19 vctrs_0.5.1         curl_5.0.0          glue_1.6.2          stringi_1.7.12      compiler_4.2.2      prettyunits_1.1.1   rncl_0.8.7          XML_3.99-0.13      
[34] jsonlite_1.8.4      pkgconfig_2.0.3    
LunaSare commented 1 year ago

Thanks for the bug report and the reproducible example! Working on it...

snacktavish commented 10 months ago

Fixed in 40d87d4fbec9a9baaf6ecbf45e21d62837f2c34c We'll run tests and merge soon!