YuLab-SMU / clusterProfiler

:bar_chart: A universal enrichment tool for interpreting omics data
https://yulab-smu.top/biomedical-knowledge-mining-book/
967 stars 246 forks source link

heatplot function; color scale is switched #676

Open zellerivo opened 3 months ago

zellerivo commented 3 months ago

library(DOSE)
data(geneList)
de <- names(geneList)[abs(geneList) > 2]
edo <- enrichDGN(de)
## convert gene ID to Symbol
edox <- setReadable(edo, 'org.Hs.eg.db', 'ENTREZID')

p1 <- heatplot(edox, showCategory=5)
p2 <- heatplot(edox, foldChange=geneList, showCategory=5)
cowplot::plot_grid(p1, p2, ncol=1, labels=LETTERS[1:2])

Hello, the color scale red/blue seems to be switched in version ‘4.11.0.1’ . Positive vaues are assigned blue and negative ones red. image

guidohooiveld commented 3 months ago

Yep, I agree that in heatmaps positive values are usually assigned red, and negative values blue.

As you likely will know, since September the default colors have been changed: (2023-09-13, Wed): change default color: from c("red", "blue") to c("#e06663", "#327eba")

Somehow this change apparently also resulted in reversing the order of the Fold Change in the legend of the heatplot (i.e. negative values [-2] are now at the top, positive values [4] at the bottom). This is opposite on how it used to be... For that see e.g. Fig 15.6 here: https://yulab-smu.top/biomedical-knowledge-mining-book/enrichplot.html#heatmap-like-functional-classification

Heatplot-1 Fig 15.6.

@huerqiang ; @GuangchuangYu : would you mind having a look at this? So that by default negative values in the heatplot are blue, and positive values red again? So the old behavior is restored?

For now a quick fix for the heatplot colors could be that manually the colors are reversed before generating the heatplot: options(enrichplot.colours = c("#327eba","#e06663")) ##these are the new colors


> library(DOSE)
> library(enrichplot)
> 
> data(geneList)
> de <- names(geneList)[abs(geneList) > 2]
> edo <- enrichDGN(de)
> ## convert gene ID to Symbol
> edox <- setReadable(edo, 'org.Hs.eg.db', 'ENTREZID')
> 
> 
> ## using the new default pastel colors
> p1 <- heatplot(edox, showCategory=5)
> p2 <- heatplot(edox, foldChange=geneList, showCategory=5)
> cowplot::plot_grid(p1, p2, ncol=1, labels=LETTERS[1:2])
> 
> 

image

> ## apply fix; reverse colors
> options(enrichplot.colours = c("#327eba","#e06663")) 
> p3 <- heatplot(edox, showCategory=5)
> p4 <- heatplot(edox, foldChange=geneList, showCategory=5)
> cowplot::plot_grid(p3, p4, ncol=1, labels=LETTERS[1:2])
>
> 

image

Finally, please note that the heatplot is a ggplot2, so if assigned to an object you can easily further fine-tune the plot. See for example here to get some inspiration: https://github.com/YuLab-SMU/clusterProfiler/issues/667#issuecomment-1953867201