YuLab-SMU / ggtree

:christmas_tree:Visualization and annotation of phylogenetic trees
https://yulab-smu.top/treedata-book/
833 stars 173 forks source link

`phylopic_uid`: Error in download_url(path) : Failed to download #482

Closed bschilder closed 2 years ago

bschilder commented 2 years ago

Each species usually has several image UIDs associated with them in phylopic. Unfortunately, not all those image UIDs seem to be references to valid PNGs. This is true even when the species UID is indeed valid.

This means that ggtree::phylopic_uid will pick 1 image UID per species, but each image UID is not guaranteed to be valid. Could you build in some additional checks to ensure each image file exists before selecting it to download? Or have a tryCatch function that tries different image UIDs until it successfully downloads one that exists?

Reprex

tree <- ape::rtree(1, tip.label = "Mus_musculus")
d <- ggimage::phylopic_uid(name = "Mus_musculus")
d$body_size <- 1
p <- ggtree(tree) %<+% d + 
  geom_tiplab(aes(image=uid, colour=body_size),
              geom="phylopic", offset=2.5) +
  geom_tiplab(aes(label=label), offset = .2) + xlim(NA, 7) +
  scale_color_viridis_c()
p
Warning: Removed 7 rows containing missing values (geom_image).
Error in download_url(path) : 
  Failed to download http://phylopic.org/assets/images/submissions/c8f71c27-71db-4b34-ac2d-e97fea8762cf.256.png (HTTP 404)

Many thanks, Brian

Session info

``` R version 4.1.0 (2021-05-18) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Big Sur 11.4 Matrix products: default LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] orthogene_1.1.2 aphylo_0.2-1 ape_5.6-1 dplyr_1.0.8 ggplot2_3.3.5 [6] ggtree_3.2.1 loaded via a namespace (and not attached): [1] nlme_3.1-155 httr_1.4.2 rprojroot_2.0.2 [4] numDeriv_2016.8-1.1 tools_4.1.0 backports_1.4.1 [7] utf8_1.2.2 R6_2.5.1 DBI_1.1.2 [10] lazyeval_0.2.2 colorspace_2.0-2 withr_2.4.3 [13] tidyselect_1.1.1 mnormt_2.0.2 phangorn_2.8.1 [16] fmcmc_0.5-1 curl_4.3.2 compiler_4.1.0 [19] cli_3.2.0 expm_0.999-6 xml2_1.3.3 [22] desc_1.4.0 plotly_4.10.0 labeling_0.4.2 [25] scales_1.1.1 quadprog_1.5-8 digest_0.6.29 [28] yulab.utils_0.0.4 rmarkdown_2.11 pkgconfig_2.0.3 [31] htmltools_0.5.2 plotrix_3.8-2 fastmap_1.1.0 [34] maps_3.4.0 htmlwidgets_1.5.4 rlang_1.0.1 [37] rstudioapi_0.13 farver_2.1.0 gridGraphics_0.5-1 [40] generics_0.1.2 combinat_0.0-8 jsonlite_1.7.3 [43] car_3.0-12 homologene_1.4.68.19.3.27 magrittr_2.0.2 [46] ggplotify_0.1.0 GenomeInfoDbData_1.2.7 patchwork_1.1.1 [49] Matrix_1.4-0 Rcpp_1.0.8 munsell_0.5.0 [52] fansi_1.0.2 abind_1.4-5 babelgene_21.4 [55] lifecycle_1.0.1 yaml_2.2.2 scatterplot3d_0.3-41 [58] carData_3.0-5 clusterGeneration_1.3.7 MASS_7.3-55 [61] brio_1.1.3 grid_4.1.0 parallel_4.1.0 [64] crayon_1.5.0 lattice_0.20-45 magick_2.7.3 [67] tmvnsim_1.0-2 knitr_1.37 pillar_1.7.0 [70] igraph_1.2.11 ggpubr_0.4.0 ggsignif_0.6.3 [73] codetools_0.2-18 pkgload_1.2.4 fastmatch_1.1-3 [76] glue_1.6.1 gprofiler2_0.2.1 evaluate_0.14 [79] ggimage_0.3.0 ggfun_0.0.5 data.table_1.14.2 [82] remotes_2.4.2 BiocManager_1.30.16 vctrs_0.3.8 [85] treeio_1.18.1 testthat_3.1.2 gtable_0.3.0 [88] purrr_0.3.4 tidyr_1.2.0 assertthat_0.2.1 [91] xfun_0.29 broom_0.7.12 phytools_1.0-1 [94] tidytree_0.3.7 coda_0.19-4 rstatix_0.7.0 [97] viridisLite_0.4.0 tibble_3.1.6 aplot_0.1.2 [100] ellipsis_0.3.2 ```
bschilder commented 2 years ago

More specifically, seems to be related to download_phylopic.