enrichGOFunction: Perform GO Enrichment Analysis and Visualization

View source: R/GO_analysis.R

enrichGOFunctionR Documentation

Perform GO Enrichment Analysis and Visualization

Description

This function performs Gene Ontology (GO) enrichment analysis using 'clusterProfiler::enrichGO()' and optionally generates a ggplot-based visualization of the results.

Usage

enrichGOFunction(
  gene_set,
  title,
  title_suffix,
  gene_universe,
  p.adjust.thr = 0.05,
  returnPlot = T,
  qrhub,
  labsize = 3,
  fontsize = 0.25,
  base_size = 18,
  max.overlaps = 20,
  MaxNsig = 30,
  legend.position = "bottom"
)

Arguments

gene_set

A character vector of gene symbols to be analyzed.

title

A character string specifying the plot title.

title_suffix

A character string to be appended to the title.

gene_universe

A character vector of all possible genes for enrichment analysis.

p.adjust.thr

Numeric; threshold for adjusted p-values to highlight significant terms in the plot. Default is '0.05'.

returnPlot

Logical; if 'TRUE', returns both the enrichment result and a ggplot visualization. Default is 'TRUE'.

qrhub

The OrgDb object specifying the organism database (e.g., '"org.Hs.eg.db"' for human, '"org.Mmu.eg.db"' for mouse).

labsize

Numeric; text label size for GO terms in the plot. Default is '3'.

fontsize

Numeric; font size scaling factor for ggplot. Default is '0.25'.

base_size

Numeric; base font size for ggplot theme. Default is '18'.

max.overlaps

Integer; controls the maximum number of overlapping labels in 'geom_label_repel()'. Default is '20'.

MaxNsig

Integer; maximum number of significant GO terms to label in the plot. Default is '30'.

Value

If 'returnPlot = TRUE', returns a list containing:

  • 'ggGO' - A ggplot object visualizing the GO enrichment results.

  • 'ego' - The 'enrichGO()' result object.

If 'returnPlot = FALSE', only the 'enrichGO()' result object is returned.

Examples

## Not run: 
library(clusterProfiler)
library(org.Hs.eg.db)
gene_set <- c("TP53", "BRCA1", "EGFR", "MYC", "PTEN") # Example genes
gene_universe <- unique(keys(org.Hs.eg.db, keytype = "SYMBOL"))
results <- enrichGOFunction(gene_set, title = "GO Enrichment", title_suffix = " - Example",
                            gene_universe = gene_universe, qrhub = org.Hs.eg.db)
print(results[[1]]) # Plot

## End(Not run)

eisascience/scCustFx documentation built on June 2, 2025, 3:59 a.m.