agentleFS
cafferychen777cafferychen777/ChatSpatial/.agents/skills/functional-analysis/SKILL.md

functional-analysis

Skill45 starsChanged 3 months agoMITView on GitHub

Understand the biological meaning of gene sets through pathway and functional enrichment analysis. Use when user has gene lists (DEGs, markers, SVGs) and wants to know what pathways or functions they represent. Triggers: "pathway analysis", "enrichment", "GSEA", "GO terms", "what pathways", "biological function", "gene set", "KEGG", "Reactome", "functional annotation".

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. mmondora/claude-skills★ 1same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository8 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 7 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Over-representation Analysis (ORA): Test if genes are enriched in pathways

    line 20
  2. Distinctive:

    Gene Set Enrichment Analysis (GSEA): Use full ranked gene list

    line 21
  3. Very specific:

    Use analyze_enrichment tool with:

    line 79
  4. Distinctive:

    No arbitrary threshold for "significant" genes

    line 113
  5. Very specific:

    Use visualize_data with plot_type="enrichment".

    line 201
  6. Distinctive:

    Consistent IDs: Use symbols or Ensembl, not mixed

    line 255
  7. Distinctive:

    Appropriate background: All expressed genes, not all genes

    line 256
  8. Distinctive:

    Always use adjusted p-values

    line 261
  9. Distinctive:

    Consider redundancy in GO terms

    line 263

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Functional Analysis

Overview

This skill answers: What biological processes/pathways are represented by this gene set?

Two main approaches:

  1. Over-representation Analysis (ORA): Test if genes are enriched in pathways
  2. Gene Set Enrichment Analysis (GSEA): Use full ranked gene list

Plus specialized analysis: 3. CNV Analysis: Copy number variation in spatial context (tumor analysis)

Decision Tree: Which Method?

Q: What type of gene list do you have?
│
├─ Discrete gene list (DEGs, markers)
│   └─ Over-Representation Analysis (ORA)
│       ├─ Input: Gene list (up/down regulated)
│       ├─ Tests: Hypergeometric / Fisher's exact
│       └─ Output: Enriched pathways with p-values
│
├─ Ranked gene list (all genes with scores)
│   └─ Gene Set Enrichment Analysis (GSEA)
│       ├─ Input: All genes ranked by fold change/statistic
│       ├─ Tests: Running sum statistic
│       └─ Output: Enrichment scores, leading edge genes
│
└─ Spatial tumor data
    └─ CNV Analysis
        ├─ Infer copy number from expression
        ├─ Map CNV spatially
        └─ Identify subclones

Over-Representation Analysis (ORA)

When to Use

  • You have a discrete gene list (e.g., significant DEGs)
  • Want to know what pathways are enriched
  • Quick, interpretable results needed

Databases

DatabaseContentBest For
GO (Gene Ontology)BP, MF, CC termsBroad functional annotation
KEGGMetabolic/signaling pathwaysPathway diagrams
ReactomeCurated pathwaysDetailed mechanisms
MSigDBHallmarks, curated setsCancer, immunology
WikiPathwaysCommunity pathwaysSpecific processes

Workflow

Step 1: Prepare Gene List

Requirements:

  • Gene symbols or IDs (consistent naming)
  • Typically 50-500 genes works best
  • Separate up/down regulated if directional

Step 2: Run ORA

Use analyze_enrichment tool with:

  • gene_list: Your genes of interest
  • database: "GO_BP", "KEGG", "Reactome", etc.
  • background: All detected genes (important!)

Step 3: Interpret Results

Key outputs:

  • term: Pathway/GO term name
  • pvalue / padj: Significance
  • odds_ratio: Enrichment strength
  • gene_count: Genes in overlap
  • genes: Specific overlapping genes

Significance criteria:

Typically significant:
- padj < 0.05
- gene_count >= 3 (robust overlap)
- odds_ratio > 2 (meaningful enrichment)

Gene Set Enrichment Analysis (GSEA)

When to Use

  • You have scores for all genes (not just significant ones)
  • Want to detect subtle but coordinated changes
  • Directional enrichment matters (up vs down)

Advantages over ORA

  • Uses information from all genes
  • Detects subtle coordinated changes
  • No arbitrary threshold for "significant" genes
  • Better statistical properties

Workflow

Step 1: Rank Genes

Rank all genes by:

  • Log fold change (signed)
  • -log10(p) × sign(logFC) (recommended)
  • Test statistic

Step 2: Run GSEA

Use analyze_enrichment tool with:

  • method: "gsea"
  • ranking: Pre-computed gene ranking
  • database: Gene set database

Step 3: Interpret Results

Key outputs:

  • NES: Normalized Enrichment Score
    • Positive: Enriched in highly ranked genes
    • Negative: Enriched in lowly ranked genes
  • pvalue / padj: Significance
  • leading_edge: Core genes driving enrichment

Enrichment plot interpretation:

  • Running enrichment score curve
  • Peaks show where gene set is concentrated
  • Leading edge = genes before peak

CNV Analysis (Tumor Spatial Data)

Purpose

Infer copy number variations from spatial transcriptomics for:

  • Tumor heterogeneity mapping
  • Clone identification
  • Spatial organization of subclones

Methods

MethodApproachBest For
inferCNVReference-basedscRNA-seq, validated
CopyKATReference-freeNo normal reference
SCEVANFast, integratedLarge datasets

Workflow

Step 1: Define Reference

For CNV inference, need:

  • Normal cells as reference (from annotation)
  • Or use reference-free method

Step 2: Run CNV Analysis

Use analyze_cnv tool with:

  • method: "infercnv", "copykat", or "scevan"
  • reference_group: Normal cell label (if applicable)

Step 3: Interpret Results

CNV outputs:

  • cnv_score: Per-cell CNV intensity
  • clone_id: Inferred subclone assignment
  • Chromosome-level gains/losses

Spatial visualization:

  • Map CNV scores spatially
  • Identify clone spatial organization
  • Correlate with histology

Visualization

Enrichment Visualizations

Plot TypeUse Case
Bar plotTop enriched terms
Dot plotSignificance + gene count
NetworkTerm relationships
GSEA plotEnrichment curve
HeatmapGene-pathway matrix

Use visualize_data with plot_type="enrichment".

CNV Visualizations

Plot TypeUse Case
HeatmapCNV across chromosomes
SpatialCNV score on tissue
Clone mapSubclone distribution

Common Analysis Scenarios

Scenario 1: Understand DEG Function

Goal: What pathways are activated in disease?
1. Get DEG list from differential analysis
2. Split into up/down regulated
3. Run ORA on each separately
4. Compare enriched pathways

Scenario 2: Pathway-Level Changes

Goal: Are cancer hallmarks affected?
1. Rank all genes by fold change
2. Run GSEA with MSigDB Hallmarks
3. Identify significantly enriched hallmarks
4. Examine leading edge genes

Scenario 3: Tumor Clone Mapping

Goal: Map tumor heterogeneity spatially
1. Annotate normal cells (if present)
2. Run CNV inference
3. Cluster by CNV profile to identify clones
4. Map clones spatially
5. Correlate with histology

Scenario 4: Immune Signature Analysis

Goal: What immune processes are active where?
1. Define immune gene signatures
2. Score each spot for signatures
3. Map signature scores spatially
4. Correlate with cell composition

Best Practices

Gene List Quality

  • Remove duplicates: Each gene counted once
  • Consistent IDs: Use symbols or Ensembl, not mixed
  • Appropriate background: All expressed genes, not all genes
  • Reasonable size: 50-500 genes typically best for ORA

Multiple Testing

  • Always use adjusted p-values
  • Report number of tests performed
  • Consider redundancy in GO terms

Interpretation Caution

  • Enrichment ≠ causation
  • Multiple pathways may overlap
  • Validate key findings experimentally

Troubleshooting

IssueCauseSolution
No significant termsGene list too small/diverseUse GSEA, check gene IDs
Too many termsLoose thresholdTighten padj, filter redundant
Unexpected resultsWrong backgroundUse detected genes as background
Missing expected pathwayGene naming mismatchCheck ID format (symbol vs Ensembl)

Output Summary

Successful functional analysis provides:

  • Enriched pathways: Ranked by significance
  • Gene-pathway mapping: Which genes in which pathways
  • Biological interpretation: What processes are affected
  • CNV landscape: Tumor heterogeneity map (if applicable)
  • Downstream hypotheses: Mechanisms to investigate

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.