topGO
Dependencies & Environment
Package-intrinsic requirements from the Bioconductor landing page — reproduce in any R environment.
- Version: 2.64.0 · Bioconductor: 3.23 · R: ≥ 4.6
- Depends: BiocGenerics, graph, Biobase, GO.db, AnnotationDbi, SparseM
- Imports: lattice, matrixStats, DBI
- Install:
BiocManager::install("topGO")
When to Use
- Performing Gene Ontology (GO) enrichment analysis using the
runTestfunction on gene lists derived from differential expression. - Accounting for the hierarchical structure and dependencies of the GO DAG using algorithms like
elim,weight, orweight01. - Testing enrichment using continuous statistical tests (e.g., Kolmogorov-Smirnov via
statistic = "ks") on gene scores rather than just binary gene lists. - Visualizing the subgraph induced by the most significant GO terms using
showSigOfNodes.
When NOT to Use
- For pathway databases other than Gene Ontology (e.g., KEGG, Reactome) (use
clusterProfilerbecausetopGOis strictly designed for GO graph topologies). - For fast, simple over-representation analysis without graph-topology correction (use
gprofiler2orenrichRbecausetopGObuilds complex local graph structures which takes more time).
Data Requirements
- A named vector of gene identifiers with associated scores (e.g., p-values) or a binary factor (0/1) indicating interesting genes.
- A mapping between gene identifiers and GO terms (e.g., via a Bioconductor annotation package like
hgu95av2.db, or custom mappings read byreadMappings).
Key Parameters
- ontology ("BP"): Character string specifying the ontology of interest; must be "BP", "MF", or "CC".
- allGenes (none): Named vector of type numeric or factor defining the gene universe and their scores/status.
- geneSelectionFun (none): Function to specify which genes are interesting based on the gene scores (e.g.,
topDiffGenes). - nodeSize (10): Integer used to prune the GO hierarchy from terms which have fewer than this many annotated genes.
- annot (annFUN.db): Function which maps gene identifiers to GO terms (e.g.,
annFUN.db,annFUN.gene2GO,annFUN.org). - algorithm ("weight01"): Method for dealing with the GO graph structure in
runTest(e.g., "classic", "elim", "weight", "parentchild"). - statistic ("fisher"): The test statistic to use in
runTest(e.g., "fisher", "ks", "t").
Best Practices
- Filter out genes with low expression or small variability using
genefilterbefore defining the gene universe to improve computational efficiency. - Compare results from multiple algorithms (e.g.,
classicvselim) usingGenTableto see how topology correction affects the significance of parent/child terms. - Use
inverseListto easily transform custom mappings from gene-to-GOs to GO-to-genes when preparing custom annotations. - Use
scoreto extract p-values from atopGOresultobject for custom plotting or comparisons.
Common Pitfalls
- Providing custom annotations with excessive redundancy: Slows down the analysis significantly. Fix: Provide only the most specific GO annotations in the custom mapping file;
topGOhandles the ancestor propagation. - Assuming all input genes are used: Not all genes in the provided
allGeneslist can be annotated to GO. Fix: Check thetopGOdatasummary to see the actual number of "feasible genes" used in the analysis. - Using incompatible algorithms and statistics: Some statistical tests do not work with every method (e.g.,
kswithparentchild). Fix: Consult the compatibility matrix and use supported combinations likeelimwithksorclassicwithfisher.
Alternatives
- clusterProfiler: For versatile enrichment analysis supporting multiple databases (GO, KEGG, MSigDB) and rich visualizations.
- goseq: For GO enrichment of RNA-seq data while correcting for gene length bias.
- enrichR: For fast, web-based enrichment analysis across dozens of gene set libraries.
Citations
- Alexa A, Rahnenführer J, Lengauer T (2006). "Improved scoring of functional groups from gene expression data by decorrelating GO graph structure." Bioinformatics.
- Grossmann et al. (2007). "Improved detection of overrepresentation of Gene-Ontology annotations with parent child intersection." Bioinformatics.
References
- Homepage: https://bioconductor.org/packages/topGO
- Vignette: https://bioconductor.org/packages/release/bioc/vignettes/topGO/inst/doc/topGO.pdf
Run this on BioMate
This skill is the knowledge layer — when, why, and how to use topgo. To run this analysis on your own data with managed compute, automated QC, and reproducible outputs, use BioMate — free to start.


