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

Phylopic image background is coloured when using circular tree layout #587

Closed
dr-budd opened this issue Sep 7, 2023 · 2 comments
Closed

Comments

@dr-budd
Copy link

dr-budd commented Sep 7, 2023

Hi Dr. Yu,

Using your example from "Data Integration, Manipulation and Visualization of Phylogenetic Trees" Section "8.2 Annotating Tree with Phylopic" to illustrate my issue. When I plot the tree as it is in the example it looks great:

library(viridis)
library(ggtree)
library(ggimage)

newick <- "((Pongo_abelii,(Gorilla_gorilla_gorilla,(Pan_paniscus,Pan_troglodytes)Pan,Homo_sapiens)Homininae)Hominidae,Nomascus_leucogenys)Hominoidea;"

tree <- read.tree(text=newick)

d <- ggimage::phylopic_uid(tree$tip.label)
d$body_mass = c(52, 114, 47, 45, 58, 6)

p <- ggtree(tree) %<+% d + geom_tiplab(aes(image=uid, colour=body_mass), geom="phylopic", offset=2.5) + geom_tiplab(aes(label=label), offset = .2) + xlim(NA, 7) + scale_color_viridis_c()
p

p

However, when I attempt to use the circular layout, the image backgrounds become coloured:

pc <- ggtree(tree, layout="circular") %<+% d + geom_tiplab(aes(image=uid, colour=body_mass), geom="phylopic", offset=2.5) + geom_tiplab(aes(label=label), offset = .2) + xlim(NA, 7) + scale_color_viridis_c()
pc

pc

I recently updated ggimage to 0.3.3 to fix the image distortion that previously occurred. This is an excellent fix for the distortion. However, I don't recall the background issue happening before the update. If I should post this in ggimage instead, my apologies and please let me know.

Thank you for making such excellent and useful packages!

Here's my session info:

sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS 13.2.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/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] ggimage_0.3.3 ggplot2_3.4.3 ggtree_3.2.1 viridis_0.6.2 viridisLite_0.4.2

loaded via a namespace (and not attached):
[1] Rcpp_1.0.9 pillar_1.9.0 compiler_4.1.3 yulab.utils_0.0.6 tools_4.1.3
[6] aplot_0.2.0 digest_0.6.31 tidytree_0.4.2 jsonlite_1.8.4 lifecycle_1.0.3
[11] tibble_3.2.1 gtable_0.3.4 nlme_3.1-161 lattice_0.20-45 pkgconfig_2.0.3
[16] rlang_1.1.1 DBI_1.1.3 cli_3.6.1 ggplotify_0.1.0 rstudioapi_0.14
[21] patchwork_1.1.3 magick_2.7.4 curl_5.0.2 parallel_4.1.3 treeio_1.23.0
[26] gridExtra_2.3 withr_2.5.0 dplyr_1.1.3 generics_0.1.3 vctrs_0.6.3
[31] gridGraphics_0.5-1 grid_4.1.3 tidyselect_1.2.0 glue_1.6.2 R6_2.5.1
[36] fansi_1.0.4 farver_2.1.1 purrr_1.0.2 tidyr_1.3.0 magrittr_2.0.3
[41] scales_1.2.1 colorspace_2.1-0 ape_5.7-1 rsvg_2.4.0 labeling_0.4.2
[46] utf8_1.2.3 lazyeval_0.2.2 munsell_0.5.0 ggfun_0.1.2

@xiangpin
Copy link
Member

xiangpin commented Sep 7, 2023

please specify angle = 0 when layout is circular geom is image.

geom_tiplab(aes(image=uid, colour=body_mass), geom="phylopic", angle = 0 )

@dr-budd
Copy link
Author

dr-budd commented Sep 7, 2023

That works perfectly, thank you so much for your quick and helpful response!

pc2 <- ggtree(tree, layout="circular") %<+% d + geom_tiplab(aes(image=uid, colour=body_mass), geom="phylopic", angle=0, offset=2.5) + geom_tiplab(aes(label=label), offset = .2) + xlim(NA, 7) + scale_color_viridis_c()
pc2

pc2

@dr-budd dr-budd closed this as completed Sep 7, 2023
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