Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set range of p.adjust in dotplot? #285

Open
agriswold76 opened this issue Aug 13, 2024 · 2 comments
Open

How to set range of p.adjust in dotplot? #285

agriswold76 opened this issue Aug 13, 2024 · 2 comments

Comments

@agriswold76
Copy link

Running simple dotplot on enrichGO object. Plot is generally fine, but want to range the p.adjust from 0 to 1 (at present it seems to only scale from the highest and lowest p.adjust of the categories being used). Is there a parameter or option to make the range go from 0 to 1? Thanks for any help

@guidohooiveld
Copy link

guidohooiveld commented Aug 16, 2024

AFAIK there is no build-in option to do this.

Yet, since the output of dotplot is a ggplot2-object, it is relatively easy to tweak the resulting plot.

For example, if you would like to have:
a) the color ranging from 0 to 0.5,
b) with a break at 0.25,
c) and using a color-gradient from green-white-red,
d) together with a new label ("adjusted p-values") for the legend,

you could do/add this to p1 (= the 'original' output from dotplot):

p2 <- p1 + scale_fill_gradientn(name = "adjusted p-values",
           colours = c("green", "white", "red"),
           limits= c(0, 0.5), 
           breaks=c(0, 0.25, 0.5) )

Full code chunk:

> library(clusterProfiler)
> library(enrichplot)
> library(ggplot2)
> library(org.Hs.eg.db)
> 
> data(geneList, package="DOSE")
> genes <- names(geneList)[abs(geneList) > 2]
> 
> 
> ego <- enrichGO(gene          = genes,
+                 universe      = names(geneList),
+                 OrgDb         = org.Hs.eg.db,
+                 ont           = "ALL",
+                 pAdjustMethod = "BH",
+                 pvalueCutoff  = 0.01,
+                 qvalueCutoff  = 0.05,
+                 readable      = TRUE)
> 
> p1 <- dotplot(ego)
> print(p1)
> 

image

> ## customize plot
> p2 <- p1 + scale_fill_gradientn(name = "adjusted p-values",
+            colours = c("green", "white", "red"),
+            limits= c(0, 0.5), 
+            breaks=c(0, 0.25, 0.5) )
Scale for fill is already present.
Adding another scale for fill, which will replace the existing scale.
> print(p2)
>

image

@DarioS
Copy link

DarioS commented Sep 25, 2024

I think p-values colour scale should be discrete by default (significant or not). In statistics, a p-value is used to reject a null hypothesis or not. If a p-value is smaller than the threshold value, the test is significant because the null hypothesis is rejected. If it is bigger than the threshold, it is not significant. There should not be a colour scale ranging from blue to red with a numeric range such as 0.001 to 0.01 because it encourages people to say "significant" and "very significant", which is not right.

color: variable that used to color enriched terms, e.g. 'pvalue', 'p.adjust' or 'qvalue'

This should have a value isSignif and be the default to be more statistically rigorous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants