Hi,
I've been using enrichR to perform enrichment analysis (GO and pathway terms) on several differentially expressed gene lists of interest. Currently, I use the plotEnrich() function to export a PDF plot of the top 30 terms based on adjusted p-values.
However, I’ve noticed that some biologically relevant GO terms or pathways—those that align well with our research findings are ranked lower (e.g., within the top 100 or even top 450), and thus don’t appear in the default plots.
Is there a way to select and visualize only specific GO terms or pathways of interest, rather than relying on the top N terms? Alternatively, do you have suggestions for custom plotting a selected list of terms (with their counts and adjusted p-values) as a bar plot?
library(enrichR)
dbs <- c("GO_Biological_Process_2023",
"Reactome_Pathways_2024")
## Input gene list
genes.input <- DEGs_list$geneSymbol
enrich_results <- enrichr(genes.input, dbs)
## Plot
pdf("plotEnrich_GO_BP.pdf", height = 7,width = 7)
plotEnrich(
enrich_results$GO_Biological_Process_2023,
showTerms = 30,
numChar = 50,
y = "Count",
orderBy = "Adjusted.P.value",
title = "GO_Biological_Process_2023"
)
dev.off()
pdf("plotEnrich_Reactome.pdf", height = 7,width = 7)
plotEnrich(
enrich_results$Reactome_Pathways_2024,
showTerms = 30,
numChar = 40,
y = "Count",
orderBy = "Adjusted.P.value",
title = "Reactome_Pathways_2024"
)
dev.off()
Thanks in advance for your help!
Best regards,
Toufiq
1 answer
Yes, this should be quite a simple task, you'll just need to be able to manipulate dataframes and use the library ggplot2. The plotEnrich function returns a ggplot2 object, so I'm guessing it's just a wrapper for a fairly rigid ggplot() command.
Here is an example output from a small toy dataset:
results <- enrichr(genes, dbs)
head(results[["GO_Biological_Process_2023"]])
Term Overlap P.value Adjusted.P.value Old.P.value Old.Adjusted.P.value Odds.Ratio Combined.Score Genes
1 Positive Regulation Of miRNA Transcription (GO:1902895) 3/43 3.696784e-08 8.938765e-06 0 0 1496.7000 25613.353 MYC;TP53;EGFR
2 Positive Regulation Of miRNA Metabolic Process (GO:2000630) 3/49 5.517756e-08 8.938765e-06 0 0 1301.0870 21744.688 MYC;TP53;EGFR
3 Regulation Of miRNA Transcription (GO:1902893) 3/59 9.732465e-08 1.051106e-05 0 0 1068.2143 17246.548 MYC;TP53;EGFR
4 Response To Ionizing Radiation (GO:0010212) 3/72 1.784632e-07 1.445552e-05 0 0 866.3913 13462.754 MYC;BRCA1;TP53
5 Response To UV (GO:0009411) 3/100 4.833589e-07 2.823835e-05 0 0 615.4330 8949.938 MYC;TP53;EGFR
6 Positive Regulation Of Nucleic Acid-Templated Transcription (GO:1903508) 4/557 5.952515e-07 2.823835e-05 0 0 77772.0000 1114805.767 MYC;BRCA1;TP53;EGFR
To create a similar plot to plotEnrich(), you'll need to manipulate the following columns into a barplot: Term, Overlap, and Adjusted.P.value. That's all. A good resource for example plots with base R and ggplot2 is the R-Graph-Gallery.
Log in to answer this question.