YuLab-SMU / enrichplot

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

Ridgeplot Draws Empty Rows #288

Open DarioS opened 2 months ago

DarioS commented 2 months ago

geom_density_ridges requires a minimum of three values. But, sometimes a core gene set has only two.

image

ridgeplot should automatically filter out such uninformative gene sets and not display them as blank rows.

> result[, c(1:6, 10:11)] # core gene set has only PLAU and APOE genes in it.
                   ID                     Description setSize enrichmentScore     NES
GO:0030193 GO:0030193 regulation of blood coagulation      10        0.695895 1.60145
GO:0050818 GO:0050818       regulation of coagulation      10        0.695895 1.60145
GO:1900046 GO:1900046        regulation of hemostasis      10        0.695895 1.60145
           pvalue                  leading_edge core_enrichment
GO:0030193  0.027 tags=20%, list=4%, signal=20%       PLAU/APOE
GO:0050818  0.027 tags=20%, list=4%, signal=20%       PLAU/APOE
GO:1900046  0.027 tags=20%, list=4%, signal=20%       PLAU/APOE
GuangchuangYu commented 2 months ago

A reproducible example pls.

DarioS commented 2 months ago

I show the core issue. I subset the dataset so Virginica has only two samples.

library(ggridges)
ggplot(iris[1:102, ], aes(x = Sepal.Length, y = Species)) + geom_density_ridges() # However, 1:103 is fine.

image

Claus Wilke replied:

If you don't have at least 20-50 points, density estimates are useless.

So, he doesn't think that ggridges should support drawing a row with two observations.