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

pairwise_termsim Throws Error if No Significant Gene Sets #269

Open
DarioS opened this issue Mar 15, 2024 · 4 comments
Open

pairwise_termsim Throws Error if No Significant Gene Sets #269

DarioS opened this issue Mar 15, 2024 · 4 comments

Comments

@DarioS
Copy link

DarioS commented Mar 15, 2024

Error in pairwise_termsim.enrichResult(x, method = method, semData = semData: no enriched term found...

My supervisor has asked me to plot the top ten ranked sets if none are significant, but that does not seem to be possible.

@guidohooiveld
Copy link

guidohooiveld commented Mar 17, 2024

Could you please add the upstream-code that results in this error?
Related to this, to reproduce the error, would it be possible to share your input data (as R-object)? Also a little more context would be appreciated.

@DarioS
Copy link
Author

DarioS commented Mar 17, 2024

Yes, certainly. I thought this was by design and expected. To me, it is undesirable and rigid. I show a self-contained example.

library(enrichplot)
library(DOSE)
library(clusterProfiler)
library(msigdbr)
library("org.Hs.eg.db", character.only = TRUE)

hallmarks <- msigdbr(category = "H")
hallmarks <- split(hallmarks[["gene_symbol"]], hallmarks[["gs_name"]])
geneSet <- hallmarks[["HALLMARK_ANDROGEN_RESPONSE"]]
all <- unlist(hallmarks)
result <- enrichGO(gene = geneSet, ont = "BP", keyType = "SYMBOL", universe = all, OrgDb = "org.Hs.eg.db")
similarities <- pairwise_termsim(result)

This causes Error in pairwise_termsim.enrichResult(x, method = method, semData = semData,: no enriched term found .... Not good for plotting in R Markdown report in a loop. It necessitates the use of tryCatch but some plot would be nicer to see.

@guidohooiveld
Copy link

Thanks for providing the code. I could reproduce the error.

> result
#
# over-representation test
#
#...@organism    Homo sapiens 
#...@ontology    BP 
#...@keytype     SYMBOL 
#...@gene        chr [1:100] "ABCC4" "ABHD2" "ACSL3" "ACTN1" "ADAMTS1" "ADRM1" "AKAP12" ...
#...pvalues adjusted by 'BH' with cutoff <0.05 
#...0 enriched terms found
#...Citation
 T Wu, E Hu, S Xu, M Chen, P Guo, Z Dai, T Feng, L Zhou, W Tang, L Zhan, X Fu, S Liu, X Bo, and G Yu.
 clusterProfiler 4.0: A universal enrichment tool for interpreting omics data.
 The Innovation. 2021, 2(3):100141 

> similarities <- pairwise_termsim(result)
Error in pairwise_termsim.enrichResult(x, method = method, semData = semData,  : 
  no enriched term found...
>

On one hand I do understand that because of reasons of automation/scripting you would like that pairwise_termsim, but also the functions for subsequent generation of plots, are able to handle empty inputs (i.e. 0 enriched terms found).
On the other hand, if there are no gene sets present in the input, then pairwise_termsim can obviously not calculate any similarity values (nor can plots be made).

To be honest, I cannot think of an easy way to have enrichplot taking care of empty result files.

@huerqiang : do you have any ideas on this?

@DarioS
Copy link
Author

DarioS commented Mar 19, 2024

The input is not empty. It is not a case of "no gene sets present in the input". There are many present.

> head(result@result)
        ID                                    Description GeneRatio  BgRatio       pvalue p.adjust qvalue
GO:0070972  protein localization to endoplasmic reticulum     5/100  24/4306 0.0001828789 0.308324 0.303
GO:0003006 developmental process involved in reproduction    17/100 302/4306 0.0004847255 0.308324 0.303
GO:0008299                isoprenoid biosynthetic process     4/100  17/4306 0.0005166236 0.308324 0.303
GO:0030521            androgen receptor signaling pathway     4/100  19/4306 0.0008118204 0.308324 0.303
GO:0000003                                   reproduction    22/100 480/4306 0.0011720568 0.308324 0.303
GO:0008610                     lipid biosynthetic process    15/100 269/4306 0.0011891493 0.308324 0.303

pairwise_termsim simply refuses to calculate anything when none of the sets have a signficant adjusted p-value.

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

2 participants