YuLab-SMU / enrichplot

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

The shape of the point changed when combining two dotplot figures into one figure. #273

Open ppdpg opened 4 months ago

ppdpg commented 4 months ago

When I combine two dotplot figures of the KEGG pathway and GO enrichment results (p1 and p2) into one figure using both patchwork and cowplot::plot_grid, the shape of the point changed from hollow to solid (p3) in the legend of the combined figure.

image image image

ppdpg commented 4 months ago

@huerqiang

guidohooiveld commented 4 months ago

Without showing any code it is impossible to give some help, but maybe this post (from huerqiang) is of relevance: https://github.com/YuLab-SMU/enrichplot/issues/268#issuecomment-1916709290

ppdpg commented 4 months ago

Here is the code for the dotplot p1<- dotplot(upkegg,x = "GeneRatio",color="qvalue",font.size=10, showCategory = 20, label_format = 40,orderBy="qvalue",decreasing = F, title = 'KEGG Pathway enrichment of up-regulated EmuH-liver vs EmuL-liver')+ theme(plot.title = element_text(hjust = 0.5))

p2<- dotplot(downkegg2,x = "GeneRatio",color="qvalue",font.size=10, showCategory = 20,label_format = 40,orderBy="qvalue",decreasing = F, title = 'KEGG Pathway enrichment of down-regulated EmuH-liver vs EmuL-liver')+ theme(plot.title = element_text(hjust = 0.5))

Put p1 and p2 into one figure

keggall<- cowplot::plot_grid(p1, p2, labels=c("A", "B"), rel_widths=c(1, 1))

guidohooiveld commented 4 months ago

I can reproduce your problem, but unfortunately I don't have a solution for it. It seems it is being caused by the function plot_grid.... Maybe, when calling plot_grid, some additional arguments could be given to prevent this change from happening?

> library(clusterProfiler)
> library(enrichplot)
> 
> ## load example data 
> data(geneList, package="DOSE")
> 
> genes.up <- names(geneList)[abs(geneList) > 2]
> genes.down <- names(geneList)[abs(geneList) < 2]
> 
> 
> upkegg   <- enrichKEGG(gene         = genes.up,
+                        organism     = 'hsa',
+                        pvalueCutoff = 0.05)
> 
> downkegg <- enrichKEGG(gene         = genes.down,
+                        organism     = 'hsa',
+                        pvalueCutoff = 0.05)
> 
> library(ggplot2)
> 
> ## note: showCategory limited to 5
> p1 <- dotplot(upkegg, x = "GeneRatio",color="qvalue",font.size=10,
+               showCategory = 5, label_format = 40,orderBy="qvalue",decreasing = FALSE,
+               title = 'KEGG Pathway enrichment of up-regulated EmuH-liver vs EmuL-liver') + 
+               theme(plot.title = element_text(hjust = 0.5))
> 
> p2 <- dotplot(downkegg, x = "GeneRatio",color="qvalue",font.size=10,
+               showCategory = 5,label_format = 40,orderBy="qvalue",decreasing = FALSE,
+               title = 'KEGG Pathway enrichment of down-regulated EmuH-liver vs EmuL-liver') + 
+               theme(plot.title = element_text(hjust = 0.5))
> 
> 
> #Put p1 and p2 into one figure
> keggall <- cowplot::plot_grid(p1, p2, labels=c("A", "B"), rel_widths=c(1, 1))
> 
> 
> print(p1)
> 
> print(p2)
> 
> print(keggall)
>

p1: image

p2: image

keggall: image