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)
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 atryCatch
function that tries different image UIDs until it successfully downloads one that exists?Reprex
Many thanks, Brian
Session info