YuLab-SMU / enrichplot

Visualization of Functional Enrichment Result
https://yulab-smu.top/biomedical-knowledge-mining-book/
234 stars 65 forks source link

unexpected change of default colors/theme with enrichplot #268

Open adalgarno opened 10 months ago

adalgarno commented 10 months ago

I am having a similar issue to the one described here (https://support.bioconductor.org/p/9155167/#9155178). The default theme for the dotplots, etc. seems to have changed. Is there a way to revert it to the older theme? I tried the fix mentioned in the post but it had no effect.

Thanks!

guidohooiveld commented 10 months ago

This is also a relevant question for me, especially on how to get the dots in the legend (representing the count) filled again...

@huerqiang , @GuangchuangYu : would you mind explaining? Thanks!

Setting/reverting the color scale can thus be done by adding this line before you call the dotplot function.: options(enrichplot.colours = c("red","blue"))

... but how to revert to have the dots in the legend 'filled' again? Which options-argument to set for that?

huerqiang commented 10 months ago

@adalgarno As guidohooiveld said, options(enrichplot.colours = c("red","blue")) can be used to change back to the default color. @guidohooiveld I don't quite understand the meaning of this sentence "how to revert to have the dots in the legend 'filled' again" . Can you explain it in more detail?

guidohooiveld commented 10 months ago

@huerqiang : thanks for your prompt response!

To illustrate my point I have included 2 graphs below.

The first (combined) one has been generated using the current versions of R/Bioconductor and enrichplot. Changing back the colors indeed works, but the dots in the legend ("Count") do not get filled. See arrow.

The second plot has been generated using old versions of R/Bioconductor and enrichplot. Note that the colors indeed do match with the current version (when the old colors are selected), but that the dots in the legend are also filled. That is what I meant.

> ## using current versions of R/Bioconductor and enrichplot.
> p1 <- dotplot(edo, showCategory=10) + ggtitle("dotplot new colors")
> 
> options(enrichplot.colours = c("red","blue")) 
> p2 <- dotplot(edo, showCategory=10) + ggtitle("dotplot old colors")
>
> R.Version()$version.string
[1] "R version 4.3.0 (2023-04-21 ucrt)"
> BiocManager::version()
[1] ‘3.18’
> packageVersion("enrichplot")
[1] ‘1.23.1’
> 

current_version

> ## using old versions of R/Bioconductor and enrichplot.
> p1 <- dotplot(edo, showCategory=10) + ggtitle("dotplot old version R/BioC")
> 
> R.Version()$version.string
[1] "R version 3.6.3 (2020-02-29)"
> BiocManager::version()
[1] ‘3.10’
> packageVersion("enrichplot")
[1] ‘1.7.1’
> 

oldR

huerqiang commented 10 months ago

That is beacuse we changed the default shape of the point from solid to hollow. If you want to change the original shape, you can set it like this:

library(ggplot2)
library(DOSE)
data(geneList)
de <- names(geneList)[1:100]
x <- enrichDO(de)
dotplot(x) + 
    aes(shape = I(16)) + 
    aes(color = p.adjust) + 
    set_enrichplot_color(type = "color", name = "p.adjust")
guidohooiveld commented 10 months ago

Yep, that code is indeed doing what I was looking for.

Thanks for the explanation and quick reply!

adalgarno commented 10 months ago

Yes, this code seems to have reverted the plots. Thank you for your help!

DarioS commented 8 months ago

My supervisor hates default R colours and likes pastels like those used in Nature journal plots. The new default is liked by her.