YuLab-SMU / enrichplot

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

Customizable color scales #4

Closed paulklemm closed 2 years ago

paulklemm commented 6 years ago

Awesome package so far, I really like it.

I do not fancy the default color scales though. Can you make them customizable?

GuangchuangYu commented 6 years ago

yes, use ggplot2.

e.g.

require(DOSE)
require(enrichplot)
require(viridis)
data(geneList)
x = enrichDO(names(geneList)[1:100])
dotplot(x) + scale_color_viridis()

If you have any bettor color scale scheme, don't hesitate to let me know. I may change the default color scale if I agree with you. :)

paulklemm commented 6 years ago

I have a couple of suggestions.

Mind sequential and diverging scales

I would strongly argue against using a diverging color scale sequential ranges. For example, the diverging color scale for the emaplot shows three colors whereas it should be a gradient between two colors. screen shot 2018-02-09 at 16 28 41

I would change it to the default colors of scale_color_gradient . screen shot 2018-02-09 at 16 48 10

Edit: If showing the p value we should actually reverse the scale since we want to highlight the small values: scale_color_gradient(low = "#56B1F7", high = "#132B43")

screen shot 2018-02-09 at 17 04 40

Only use default scale_color_gradient for sequential scales

Currently for the dotplot actually shows a sequential scale for the sequential p-value (which is also mapped in emaplot to color so however you decide, you should keep the color consistent) from red to blue. I would keep scale_color_gradient because it's easier to understand since it doesn't mix colors.

Mind color blind people

You currently use a sequential color scale from green → red for the cnetplot. I would change it to a diverging color scale since fold change is on a diverging scale. I would suggest blue → black → red. Green → black → red is not recommended since it cannot be distinguished with the most common type of color blindness.

paulklemm commented 6 years ago

If you want to I can make a pull request with reworked color scales.

GuangchuangYu commented 6 years ago

PR is welcome @paulklemm .

nitishkumarmishra commented 6 years ago

Hi, I am getting this error for enrichmap, ReactomePA and clusterProfiler

Error : object 'scale_type' is not exported by 'namespace:ggplot2' ERROR: lazy loading failed for package 'enrichplot'

GuangchuangYu commented 6 years ago
> scale_type
function (x)
UseMethod("scale_type")
<bytecode: 0x7ff3d45d3968>
<environment: namespace:ggplot2>

pls check your installation.

BS2018 commented 5 years ago

I want to increase the size of the text of the emapplot object. I know that with geom_node_text function I can edit the text. However, I am unable to remove the original text that comes with the emapplot function. Any advice will be highly helpful:)

nikofleischer commented 3 years ago

Setting scale_color_viridis for dotplot() works fine but seems to be ignored for heatplot. it is really difficult to distinguish slightly up- and downregulated genes using the default color scheme :(

angiachino commented 3 years ago

Having the same issue as @sparsepix : heatplot is not affected by _scale_colorviridis and other _scalecolor functions. Here is a minimum working example (notice that the two graphs look identical even though they should not):

library(DOSE)

library(enrichplot)

library(ggplot2)

data(geneList)

de <- names(geneList)[abs(geneList) > 2]

edo <- enrichDGN(de)

edox <- setReadable(edo, 'org.Hs.eg.db', 'ENTREZID')

p1 <- heatplot(edox, foldChange=geneList)

p2 <- heatplot(edox, foldChange=geneList) + viridis::scale_color_viridis()

cowplot::plot_grid(p1, p2, ncol=1, labels=LETTERS[1:2])

bar

huerqiang commented 3 years ago

@sparsepix You should use viridis::scale_fill_viridis

p2 <- heatplot(edox, foldChange=geneList) + viridis::scale_fill_viridis()