This source did not publish a separate summary. Review SKILL.md before using the skill.
SKILL.md
Version Compatibility
Reference examples tested with: DESeq2 1.42+
Before using code patterns, verify installed versions match. If versions differ:
R: packageVersion('<pkg>') then ?function_name to verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Gene Set Enrichment Analysis (GSEA)
Core Concept
GSEA uses all genes ranked by a statistic (log2FC, signed p-value) rather than a subset of significant genes. It finds gene sets where members are enriched at the top or bottom of the ranked list.
Prepare Ranked Gene List
Goal: Create a sorted named vector of gene-level statistics suitable for GSEA input.
Approach: Extract fold changes (or other statistics) from DE results, name by gene ID, and sort in decreasing order.
"Run GSEA on my differential expression results" → Rank all genes by expression statistic and test whether predefined gene sets cluster toward the extremes of the ranked list.
Goal: Save GSEA results and extract leading edge genes for downstream analysis.
Approach: Convert enrichment object to data frame, export to CSV, and parse core_enrichment for driving genes.
results_df <- as.data.frame(gse_go)
write.csv(results_df, 'gsea_go_results.csv', row.names = FALSE)
# Get leading edge genes for a term
leading_edge <- strsplit(results_df$core_enrichment[1], '/')[[1]]
Notes
Must be sorted - gene list must be sorted in decreasing order
Named vector - names are gene IDs, values are statistics
No arbitrary cutoffs - uses all genes, not just significant ones
NES sign matters - positive = upregulated enrichment
Leading edge - core_enrichment contains driving genes
Related Skills
go-enrichment - Over-representation analysis for GO
kegg-pathways - Over-representation analysis for KEGG