bio-pathway-gsea
БесплатноБез исполняемых скриптовНе проверенGene Set Enrichment Analysis using clusterProfiler gseGO and gseKEGG. Use when analyzing ranked gene lists to find coordinated expression changes in gene sets…
от gabrielmoreira★ 23 звезды на GitHubОб этом скилле
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_nameto 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.
When to Use GSEA vs ORA
| Scenario | Preferred | Why |
|---|---|---|
| Have ranked DE results for all genes | GSEA | Uses full information; no arbitrary cutoff |
| Biological signal involves many modest but coordinated changes | GSEA | Core strength -- detects "distributed enrichment" ORA misses |
| Gene list NOT from ranking (co-expression module, GWAS hits) | ORA | No meaningful ranking exists |
| Few total measured genes, cannot construct meaningful ranking | ORA | GSEA needs large ranked lists to be powerful |
In benchmarks, GSEA-family methods outperform ORA by ~35% higher F1 score on simulated data. GSEA is strictly preferred for DE-derived analyses.
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.
library(clusterProfiler)
library(org.Hs.eg.db)
de_results <- read.csv('de_results.csv')
# Create named vector: values = statistic, names = gene IDs
gene_list <- de_results$log2FoldChange
names(gene_list) <- de_results$gene_id
# Sort in decreasing order (REQUIRED)
gene_list <- sort(gene_list, decreasing = TRUE)
Convert Gene IDs for GSEA
Goal: Map gene symbols to Entrez IDs while preserving the ranked statistic values.
Approach: Use bitr for ID conversion, then rebuild the named sorted vector with Entrez IDs as names.
# Convert symbols to Entrez IDs
gene_ids <- bitr(names(gene_list), fromType = 'SYMBOL', toType = 'ENTREZID', OrgDb = org.Hs.eg.db)
# Create ranked list with Entrez IDs
gene_list_entrez <- gene_list[names(gene_list) %in% gene_ids$SYMBOL]
names(gene_list_entrez) <- gene_ids$ENTREZID[match(names(gene_list_entrez), gene_ids$SYMBOL)]
gene_list_entrez <- sort(gene_list_entrez, decreasing = TRUE)
Ranking Metric Selection
Goal: Choose a ranking metric that balances magnitude and significance for GSEA.
Approach: The ranking metric choice matters enormously. Match the metric to the DE tool used.
| DE Tool | Recommended Metric | Column | Why |
|---|---|---|---|
| DESeq2 | Wald statistic | stat |
Combines effect size + variance; best overall for RNA-seq |
| DESeq2 (shrunk) | Shrunken log2FC | log2FoldChange |
Use type='apeglm' or type='ashr'; NOT type='normal' (deprecated) |
| limma/voom | Moderated t-statistic | t |
Borrows strength across genes |
| edgeR | Signed p-value | sign(logFC) * -log10(PValue) |
edgeR has no Wald-equivalent column |
# DESeq2 Wald statistic (default recommendation)
gene_list <- de_results$stat
names(gene_list) <- de_results$gene_id
gene_list <- sort(gene_list[!is.na(gene_list)], decreasing = TRUE)
# Signed p-value (for edgeR or when Wald stat unavailable)
# Replace p=0 with small value to avoid Inf
pvals <- pmax(de_results$pvalue, 1e-300)
gene_list <- -log10(pvals) * sign(de_results$log2FoldChange)
names(gene_list) <- de_results$gene_id
gene_list <- sort(gene_list[!is.na(gene_list)], decreasing = TRUE)
Never use: shrunken log2FC from lfcShrink(type='normal') -- the prior distorts rankings. Also: lfcShrink() with type='apeglm'/'ashr' drops the stat column, so pull stat from unshrunk results(dds) if needed.
GSEA with GO
Goal: Detect coordinated expression changes across GO gene sets without requiring a significance cutoff.
Approach: Run gseGO on a ranked gene list, testing whether GO term members are enriched at the top or bottom of the list.
gse_go <- gseGO(
geneList = gene_list_entrez,
OrgDb = org.Hs.eg.db,
ont = 'BP', # BP, MF, CC, or ALL
minGSSize = 10,
maxGSSize = 500,
pvalueCutoff = 0.05,
verbose = FALSE,
pAdjustMethod = 'BH'
)
# Make readable
gse_go <- setReadable(gse_go, OrgDb = org.Hs.eg.db, keyType = 'ENTREZID')
GSEA with KEGG
Goal: Identify KEGG pathways with coordinated expression changes across all genes.
Approach: Run gseKEGG on the ranked gene list using KEGG pathway definitions.
gse_kegg <- gseKEGG(
geneList = gene_list_entrez,
Установить bio-pathway-gsea в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bio-pathway-gsea?
Gene Set Enrichment Analysis using clusterProfiler gseGO and gseKEGG. Use when analyzing ranked gene lists to find coordinated expression changes in gene sets without arbitrary significance cutoffs. Detects subtle but coordinated expression changes.
Как установить скилл bio-pathway-gsea?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bio-pathway-gsea запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic