YuLab-SMU / clusterProfiler

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

size = qvalue does not work with ridgeplot function() #704

Closed CharlineJnnt closed 3 months ago

CharlineJnnt commented 4 months ago

Hello,

I have performed a GSEA enrichment analysis using data from the DOSE library, then, I ran the ridgeplot() function by changing values in the fill argument. I have tested the 3 available values, fill = "pvalue", fill = "p.adjust" and fill = "qvalue". It worked for the 2 first values but not for the last one.

My code is

>library(DOSE)
>data(geneList)
>edo2 <- gseDO(geneList)
>ridgeplot(edo2, fill = "pvalue")
>ridgeplot(edo2, fill = "p.adjust")
>ridgeplot(edo2, fill = "qvalue")
Erreur dans ridgeplot.gseaResult(x, showCategory = showCategory, fill = fill,  :
'fill' variable not available ...

image

image

Can you help me ?

guidohooiveld commented 4 months ago

I can reproduce your problem!

It is a bug in the code of the ridgeplot function (that actually is part of the enrichplot library).

Specifically these 2 lines:

    if (fill == "qvalue") {
        fill <- "qvalues"
    }
    if (!fill %in% colnames(x@result)) {
        stop("'fill' variable not available ...")

https://github.com/YuLab-SMU/enrichplot/blob/cc0980f2f49291bbd3ac4e0820e6646c58e86612/R/ridgeplot.R#L30-L34

Basically, when calling the ridgeplot function, if you define the argument fill = "qvalue", then within the function the argument "qvalue" is renamed to "qvalues" (thus with an s).

Yet, in the output there is NO column present named qvalues, but only qvalue (without an s), This throws the error...

A quick fix is to manually rename in the output the corresponding column to qvalues (thus with an s).

@GuangchuangYu : could you please fix this bug?

> library(DOSE)
> data(geneList)
> edo2 <- gseDO(geneList)
using 'fgsea' for GSEA analysis, please cite Korotkevich et al (2019).

preparing geneSet collections...
GSEA analysis...
leading edge analysis...
done...
>
> ## reported error is reproducible!
> 
> ridgeplot(edo2, fill = "qvalue")
Error in ridgeplot.gseaResult(x, showCategory = showCategory, fill = fill,  : 
  'fill' variable not available ...
> 
> ## check column names of the results
> ## note that the 8th column contains the qvalue.
> colnames(edo2@result)
 [1] "ID"              "Description"     "setSize"         "enrichmentScore"
 [5] "NES"             "pvalue"          "p.adjust"        "qvalue"         
 [9] "rank"            "leading_edge"    "core_enrichment"
> colnames(edo2@result)[8]
[1] "qvalue"
>
> ## renames 'qvalue' to 'qvalues' (thus with an s)
> colnames(edo2@result)[8] <- "qvalues"
>
> ## check
> colnames(edo2@result)[8]
[1] "qvalues"
>
> ## create ridgplot based on qvalue
> ## works!
>
> ridgeplot(edo2, fill = "qvalue")
Picking joint bandwidth of 0.225
>

image

CharlineJnnt commented 4 months ago

Thank you ! This fixes my bug !

GuangchuangYu commented 3 months ago

fixed and thanks, see https://github.com/YuLab-SMU/enrichplot/commit/c7d162c84ef7fc6ac9942fee10ef4f7f50be43ca.