MCPInstall

tooluniverse-spatial-transcriptomics

Spatial transcriptomics analysis — Visium, MERFISH, seqFISH, Slide-seq. Maps gene expression to tissue architecture, identifies spatially variable genes (SVGs), tissue-domain segmentation, and cell-cell interaction inference. Use for spatial gene-expression questions, tissue architecture analysis, and SVG identification.

Installs
409
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/mims-harvard/tooluniverse --skill tooluniverse-spatial-transcriptomics
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads tooluniverse-spatial-transcriptomics automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Spatial Transcriptomics Analysis

Comprehensive analysis of spatially-resolved transcriptomics data to understand gene expression patterns in tissue architecture context. Combines expression profiling with spatial coordinates to reveal tissue organization, cell-cell interactions, and spatially variable genes.

LOOK UP, DON'T GUESS

When uncertain about any scientific fact, SEARCH databases first rather than reasoning from memory. A database-verified answer is always more reliable than a guess.

When to Use This Skill

Triggers:

  • User has spatial transcriptomics data (Visium, MERFISH, seqFISH, etc.)
  • User has only an H&E histology image and no spatial assay at all -- DeepSpotM_predict_gene_expression (local model, no API/key) predicts spatial gene expression for a 224x224 H&E tile directly, a virtual readout when no real spatial data exists yet. Treat its output as a model prediction to guide follow-up (e.g. which region to actually assay), not a substitute for the platforms above when real spatial data is the goal.
  • Questions about tissue architecture or spatial organization
  • Spatial gene expression pattern analysis
  • Cell-cell proximity or neighborhood analysis requests
  • Tumor microenvironment spatial structure questions
  • Integration of spatial with single-cell data
  • Spatial domain identification
  • Tissue morphology correlation with expression

Example Questions:

  1. "Analyze this 10x Visium dataset to identify spatial domains"
  2. "Which genes show spatially variable expression in this tissue?"
  3. "Map the tumor microenvironment spatial organization"
  4. "Find genes enriched at tissue boundaries"
  5. "Identify cell-cell interactions based on spatial proximity"
  6. "Integrate spatial transcriptomics with scRNA-seq annotations"

Core Capabilities

  • Data Import: 10x Visium, MERFISH, seqFISH, Slide-seq, STARmap, Xenium formats
  • Quality Control: Spot/cell QC, spatial alignment verification, tissue coverage
  • Normalization: Spatial-aware normalization accounting for tissue heterogeneity
  • Spatial Clustering: Identify spatial domains with similar expression profiles
  • Spatial Variable Genes: Find genes with non-random spatial patterns
  • Neighborhood Analysis: Cell-cell proximity, spatial neighborhoods, niche identification
  • Integration: Merge with scRNA-seq for cell type mapping (Cell2location, Tangram, SPOTlight)
  • Ligand-Receptor Spatial: Map cell communication in tissue context via OmniPath

Supported Platforms

  • 10x Visium: 55um spots (~50 cells/spot), genome-wide, includes H&E image — most common
  • MERFISH/seqFISH: Single-cell resolution, 100-10,000 targeted genes, imaging-based
  • Slide-seq/V2: 10um beads, genome-wide — higher resolution than Visium
  • Xenium: Single-cell/subcellular, 300+ targeted genes (10x platform)

Workflow Overview

Input: Spatial Transcriptomics Data + Tissue Image
    |
    v
Phase 1: Data Import & QC
    |-- Load spatial coordinates + expression matrix
    |-- Load tissue histology image
    |-- Quality control per spot/cell (min 200 genes, 500 UMI, <20% MT)
    |-- Align spatial coordinates to tissue
    |
    v
Phase 2: Preprocessing
    |-- Normalization (spatial-aware methods)
    |-- Highly variable gene selection (top 2000)
    |-- Dimensionality reduction (PCA)
    |-- Spatial lag smoothing (optional)
    |
    v
Phase 3: Spatial Clustering
    |-- Build spatial neighbor graph (squidpy)
    |-- Graph-based clustering with spatial constraints (Leiden)
    |-- Annotate domains with marker genes (Wilcoxon)
    |-- Visualize domains on tissue
    |
    v
Phase 4: Spatial Variable Genes
    |-- Test spatial autocorrelation (Moran's I, Geary's C)
    |-- Filter significant spatial genes (FDR < 0.05)
    |-- Classify pattern types (gradient, hotspot, boundary, periodic)
    |
    v
Phase 5: Neighborhood Analysis
    |-- Define spatial neighborhoods (k-NN, radius)
    |-- Calculate neighborhood composition (squidpy nhood_enrichment)
    |-- Identify interaction zones between domains
    |
    v
Phase 6: Integration with scRNA-seq
    |-- Cell type deconvolution (Cell2location, Tangram, SPOTlight)
    |-- Map cell types to spatial locations
    |-- Validate with marker genes
    |
    v
Phase 7: Spatial Cell Communication
    |-- Identify proximal cell type pairs
    |-- Query ligand-receptor database (OmniPath)
    |-- Score spatial interactions (squidpy ligrec)
    |-- Map communication hotspots
    |
    v
Phase 8: Generate Spatial Report
    |-- Tissue overview with domains
    |-- Spatially variable genes
    |-- Cell type spatial maps
    |-- Interaction networks in tissue context

Phase Summaries

Phase 1: Data Import & QC

Load platform-specific data (scanpy read_visium for Visium). Apply QC filters: min 200 genes/spot, min 500 UMI/spot, max 20% mitochondrial. Verify spatial alignment with tissue image overlay.

Phase 2: Preprocessing

Normalize to median total counts, log-transform, select top 2000 HVGs. Optional spatial smoothing via neighbor averaging (useful for noisy data but blurs boundaries).

Phase 3: Spatial Clustering

PCA (50 components) followed by spatial neighbor graph construction (squidpy). Leiden clustering with spatial constraints yields spatial domains. Find domain markers via Wilcoxon rank-sum test.

Phase 4: Spatially Variable Genes

Moran's I statistic tests spatial autocorrelation: I > 0 = clustering, I ~ 0 = random, I < 0 = checkerboard. Filter by FDR < 0.05. Classify patterns as gradient, hotspot, boundary, or periodic.

Phase 5: Neighborhood Analysis

Neighborhood enrichment analysis (squidpy) tests whether cell types/domains are co-localized beyond random expectation. Identify interaction zones at domain boundaries using k-NN spatial graphs.

Phase 6: scRNA-seq Integration

Cell type deconvolution maps single-cell annotations to spatial spots. Methods: Cell2location (recommended for Visium), Tangram, SPOTlight. Produces cell type fraction estimates per spot.

Phase 7: Spatial Cell Communication

Combine spatial proximity with ligand-receptor databases. Key ToolUniverse tools:

  • OmniPath_get_ligand_receptor_interactions — 14,000+ L-R pairs from CellPhoneDB, CellChatDB, etc. Use partners param for specific genes.
  • OmniPath_get_intercell_roles — classify proteins as ligand/receptor/ECM. Use proteins param.
  • OmniPath_get_cell_communication_annotations — CellPhoneDB/CellChatDB pathway annotations. Use proteins param.
  • OmniPath_get_signaling_interactions — intracellular signaling downstream of receptors.

Score interactions by co-expression of L-R pairs in proximal cells. Map hotspots where interaction scores peak.

Phase 7.5: Data Discovery & Gene Context (ToolUniverse API tools)

For dataset discovery and gene annotation (API-based, no local computation needed):

  • geo_search_datasets / OmicsDI_search_datasets / NCBI_SRA_search_runs — find spatial TX datasets
  • UniProt_get_function_by_accession — protein function for stroma/immune markers
  • STRING_get_network — protein interaction networks for key markers
  • kegg_search_pathway / kegg_get_pathway_info — relevant metabolic/signaling pathways
  • DGIdb_get_drug_gene_interactions — druggable targets in the spatial context
  • PubMed_search_articles — literature for spatial biology context

API tools vs. local computation: Phases 1-2 (data import, QC) and Phases 3-6 (clustering, SVGs, neighborhoods, deconvolution) require local Python with squidpy/scanpy. Phase 7 L-R databases and Phase 7.5 gene context use ToolUniverse API tools.

Phase 8: Report Generation

See report_template.md for full example output.


Integration with ToolUniverse Skills

  • tooluniverse-single-cell: scRNA-seq reference for deconvolution (Phase 6) and L-R database (Phase 7)
  • tooluniverse-gene-enrichment: Pathway enrichment for spatial domain marker genes (Phase 3)
  • tooluniverse-multi-omics-integration: Integration with other omics layers (Phase 8)

ToolUniverse Data Retrieval Tools

HuBMAP Spatial Atlas Tools

Use HuBMAP tools to discover published spatial biology datasets for reference, validation, or cross-study comparison.

Availability Note: HuBMAP_search_datasets, HuBMAP_list_organs, and HuBMAP_get_dataset may not be registered in your ToolUniverse instance. Verify with tu.list_tools() before use. If unavailable, use OmicsDI (OmicsDI_search_datasets(query="spatial transcriptomics kidney")) or CELLxGENE (CELLxGENE_get_cell_metadata) as reliable alternatives for spatial dataset discovery.

  • HuBMAP_search_datasets: Search published datasets by organ (code, e.g. "LK"=Left Kidney, "BR"=Brain), dataset_type, query, limit
  • HuBMAP_list_organs: List all organs with codes and UBERON IDs (no required params)
  • HuBMAP_get_dataset: Get detailed metadata for a specific hubmap_id (e.g. "HBM626.FHJD.938")

Organ codes: LK/RK=Kidney, LI=Large Intestine, SI=Small Intestine, HT=Heart, LV=Liver, LU=Lung, SP=Spleen, BR=Brain, PA=Pancreas, SK=Skin.

HuBMAP biospecimen + spatial-registration layer (Samples & Donors)

Below the dataset level, HuBMAP indexes the physical tissue Samples (anatomical blocks/sections/organs/suspensions) and the human Donors. Use these to inspect CCF/RUI spatial registration and donor demographics — context the dataset tools do not expose.

  • HuBMAP_search_samples: Find tissue Samples by organ (2-letter code), sample_category ("block"/"section"/"organ"/"suspension"), registered_only (only CCF/RUI-registered specimens), limit. Each result flags spatially_registered and links the parent donor.
  • HuBMAP_get_sample: Full record for one Sample hubmap_id (e.g. "HBM658.BXNB.873"), including parsed rui_location — the CCF placement_target reference organ, x/y/z dimensions + units, and ccf_annotations (UBERON/FMA structures the block overlaps).
  • HuBMAP_search_donors: Find Donors by group_name (e.g. "Stanford") or free-text query, with normalized demographics (age, sex, race, body_mass_index, cause_of_death) extracted from UMLS/SNOMED-coded metadata. Use to build demographically-matched tissue cohorts.
# Spatially-registered kidney blocks (carry CCF coordinates)
blocks = tu.tools.HuBMAP_search_samples(organ="LK", sample_category="block", registered_only=True, limit=5)

# Inspect the CCF spatial registration of one block
s = tu.tools.HuBMAP_get_sample(hubmap_id="HBM658.BXNB.873")
# s["data"]["rui_location"] -> {placement_target: ...VHMLung..., x/y/z_dimension, dimension_units, ccf_annotations:[UBERON...]}

# Demographically-matched donor cohort
donors = tu.tools.HuBMAP_search_donors(group_name="Stanford", limit=10)
# donors["data"]["donors"][i]["demographics"] -> {age, sex, race, body_mass_index, ...}

When to use:

  • Finding reference spatial datasets for a given organ/tissue
  • Identifying available spatial assay types (Visium, CODEX, MERFISH) for a tissue
  • Cross-referencing donor metadata (age, sex) for spatial datasets
  • Retrieving DOI links for published spatial atlas datasets

Fallback if HuBMAP tools unavailable:

# Use OmicsDI for spatial dataset discovery
result = tu.tools.OmicsDI_search_datasets(query="spatial transcriptomics kidney Visium")

# Use CELLxGENE for cell-level expression context
# obs_value_filter is required (unfiltered Census queries time out)
result = tu.tools.CELLxGENE_get_cell_metadata(
    obs_value_filter='tissue_general == "kidney"',
    column_names=["cell_type", "tissue", "disease"],
)
# Example: Find spatial datasets for kidney (if HuBMAP tools available)
result = tu.tools.HuBMAP_search_datasets(organ="LK", limit=5)
# Returns: {data: {total, returned, datasets: [{hubmap_id, title, dataset_type, organ, doi_url, ...}]}}

# Example: Get all available organs
organs = tu.tools.HuBMAP_list_organs()
# Returns: {data: {total, organs: [{code, term, organ_uberon, rui_supported}]}}

Example Use Cases

Use Case 1: Tumor Microenvironment Mapping

Question: "Map the spatial organization of tumor, immune, and stromal cells" Workflow: Load Visium -> QC -> Spatial clustering -> Deconvolution -> Interaction zones -> L-R analysis -> Report

Use Case 2: Developmental Gradient Analysis

Question: "Identify spatial gene expression gradients in developing tissue" Workflow: Load spatial data -> SVG analysis -> Classify gradient patterns -> Map morphogens -> Correlate with cell fate -> Report

Use Case 3: Brain Region Identification

Question: "Automatically segment brain tissue into anatomical regions" Workflow: Load Visium brain -> High-resolution clustering -> Match to known regions -> Validate with Allen Brain Atlas -> Report


Quantified Minimums

  • At least 500 spatial locations after QC
  • Filter low-quality spots (min 200 genes, min 500 UMI, <20% MT) and verify alignment
  • At least one spatial clustering method (graph-based with spatial constraints)
  • Spatially variable genes tested with Moran's I or equivalent (FDR < 0.05)
  • Spatial plots on tissue images for all major findings
  • Report covers: domains, spatial genes, cell type maps, key interactions

Reasoning Framework

Starting Point: What Is the Spatial Question?

Spatial data adds location to expression. The key question: is the spatial pattern driven by cell type composition (trivial) or by spatially-regulated gene expression within the same cell type (interesting)? Deconvolution helps distinguish these.

Before interpreting any spatially variable gene (SVG), ask:

  1. Does this gene simply mark a cell type that is spatially restricted? (e.g., a T-cell marker enriched in immune infiltrate zones — expected, not informative)
  2. Or is the gene differentially expressed within the same cell type depending on its spatial position? (e.g., a fibroblast gene upregulated at the tumor-stroma boundary — spatially regulated, biologically interesting)

To distinguish these: (a) run deconvolution (Cell2location, Tangram) to get cell type fractions per spot; (b) regress SVG expression against cell type fraction; (c) if the spatial pattern persists after controlling for cell type composition, it reflects genuine spatial regulation. Always look up the gene's known biology before interpreting — check UniProt function and STRING interactions rather than guessing.

Evidence Grading

  • T1: Validated by orthogonal method (IHC, smFISH, known anatomy) — e.g., spatial domain matches histology-confirmed tumor margin
  • T2: Statistically significant, biologically consistent — SVG with Moran's I > 0.3 and FDR < 0.01 in expected tissue region
  • T3: Computationally identified, awaiting validation — novel spatial domain from clustering with no histological correlate
  • T4: Exploratory or artifact-prone — low-UMI edge spots, domains driven by batch effects

Interpretation Guidance

Spatial domains: Domains represent regions of coherent gene expression, often corresponding to tissue architecture (tumor core, stroma, immune infiltrate, necrosis). A domain is biologically meaningful when its marker genes align with known cell type signatures. Domains at tissue boundaries (e.g., tumor-stroma interface) are particularly informative for microenvironment studies.

Cell-cell proximity significance: Neighborhood enrichment z-scores > 2 indicate cell types co-localize more than expected by chance. Negative z-scores indicate spatial avoidance. Interpret in biological context: immune cell enrichment near tumor cells may indicate active immune response or immunosuppressive niche depending on the cell types involved (e.g., CD8+ T cells vs. Tregs).

Spatially variable genes (SVGs): Moran's I > 0.3 with FDR < 0.05 indicates strong spatial patterning. Classify SVGs by pattern: gradients (morphogen signaling, e.g., WNT along crypt-villus axis), hotspots (focal expression in immune aggregates), boundary genes (enriched at domain interfaces, e.g., epithelial-mesenchymal transition markers). SVGs with known spatial biology roles (e.g., tissue polarity genes) are higher confidence than novel candidates.

Synthesis Questions

A complete spatial transcriptomics report should answer:

  1. What spatial domains were identified, and do they correspond to known tissue architecture?
  2. Which genes show significant spatial variability, and what pattern types do they exhibit?
  3. Are specific cell type pairs enriched or depleted in spatial proximity?
  4. What ligand-receptor interactions are active at domain boundaries or cell-cell interfaces?
  5. How do spatial findings compare to bulk or single-cell data from the same tissue type?

Programmatic Access (Beyond Tools)

When ToolUniverse tools return metadata but you need the actual expression matrices:

import scanpy as sc, pandas as pd, requests, io

# Load h5ad (most common format for spatial/single-cell)
adata = sc.read_h5ad("spatial_data.h5ad")

# Load 10X Visium output directory
adata = sc.read_visium("path/to/spaceranger_output/")

# Download from GEO supplementary files
geo_id = "GSE123456"
# Check for h5ad or MTX in supplementary files
url = f"https://www.ncbi.nlm.nih.gov/geo/query/acc.cgi?acc={geo_id}&targ=gsm&view=data"

# Load 10X MTX format (matrix + barcodes + features)
adata = sc.read_10x_mtx("filtered_feature_bc_matrix/", var_names="gene_symbols")

# HuBMAP data portal
# Search at https://portal.hubmapconsortium.org/search then download via globus or direct link
# Human Cell Atlas: https://data.humancellatlas.org/ — download h5ad/loom files

See tooluniverse-data-wrangling skill for format cookbook and bulk download patterns.


Limitations

  • Resolution: Visium spots contain multiple cells (not single-cell)
  • Gene coverage: Imaging methods have limited gene panels
  • 3D structure: Most platforms are 2D sections
  • Tissue quality: Requires well-preserved tissue for imaging
  • Computational: Large datasets require significant memory
  • Reference dependency: Deconvolution quality depends on scRNA-seq reference

References

Methods:

Platforms:


Reference Files

  • code_examples.md - Python code for all phases (scanpy, squidpy, cell2location)
  • report_template.md - Full example report (breast cancer TME)

FAQ

What does the tooluniverse-spatial-transcriptomics skill do?

Spatial transcriptomics analysis — Visium, MERFISH, seqFISH, Slide-seq. Maps gene expression to tissue architecture, identifies spatially variable genes (SVGs), tissue-domain segmentation, and cell-cell interaction inference. Use for spatial gene-expression questions, tissue architecture analysis, and SVG identification.

How do I install tooluniverse-spatial-transcriptomics?

Run npx skills add https://github.com/mims-harvard/tooluniverse --skill tooluniverse-spatial-transcriptomics in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/tooluniverse-spatial-transcriptomics/ (personal) or .claude/skills/tooluniverse-spatial-transcriptomics/ (project).

Which AI agents can use tooluniverse-spatial-transcriptomics?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is tooluniverse-spatial-transcriptomics safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains tooluniverse-spatial-transcriptomics?

It is published by mims-harvard in mims-harvard/tooluniverse. It has 409 recorded installs.

More from mims-harvard/tooluniverse

View all →

tooluniverse-sequence-retrieval

mims-harvard/tooluniverse

Retrieve DNA/RNA/protein sequences from NCBI and ENA with disambiguation. Quality hierarchy: RefSeq (NM/NP) RefSeq predicted (XM/XP) GenBank submissions. Use for fetching specific sequences by accession, gene-symbol-to-sequence lookup, transcript-isoform retrieval, and curated-vs-raw-submission preference.

1.7K installs

tooluniverse-literature-deep-research

mims-harvard/tooluniverse

Deep literature review — PubMed, EuropePMC, bioRxiv preprints, citation networks, evidence synthesis. Disambiguates queries, runs collision-aware searches, grades evidence T1-T4, and produces structured reports. Use for systematic literature review, meta-analysis evidence collection, and detailed answer-with-citations workflows.

tooluniverse-image-analysis

mims-harvard/tooluniverse

Microscopy and quantitative imaging analysis — colony morphometry, fluorescence intensity quantification, cell-count statistics, dose-response curves, and ANOVA/Dunnett on image-derived measurements. Uses pandas/numpy/scipy/scikit-image. Use for analyzing tabular outputs from CellProfiler/ImageJ, image-derived measurement statistics, and image-based assay quantification.

Media & Creative655 installs

tooluniverse-clinical-guidelines

mims-harvard/tooluniverse

Search and retrieve clinical practice guidelines from 12+ authoritative sources — NICE, WHO, NCCN, AHA, ADA, SIGN, USPSTF, IDSA, NIH consensus, ESMO/ESC/EASL European societies, and US specialty associations. Use for evidence-graded treatment recommendations, dosing protocols, screening guidance, and authoritative-source-prioritized clinical guidance (NICE/WHO ranked above society guidelines).

492 installs

tooluniverse

mims-harvard/tooluniverse

ToolUniverse plugin router. STEP 1 BEFORE ANY ANALYSIS: if the data folder contains executed.ipynb, run tu run readexecutednotebook '{"datafolder":" ","search":" "}' to extract its cell outputs and apply EVERY filter/sample-exclusion the notebook used — even when the question says 'Using DESeq2/Run X/Compute Y' (this describes the METHOD the notebook used, not a request to rerun). The notebook's cell outputs are the only published authoritative answers; reimplementing or reading stale pre-computed CSVs in the data folder produces different numbers because of outlier-sample removal, library version, and filter steps you don't see by skimming. STEP 2 routing — pick a sub-skill name from this exact list (never invent): tooluniverse-rnaseq-deseq2 (RNA/miRNA-seq DE, correlation, PCA, clustering, dispersion), tooluniverse-gene-enrichment (GO/KEGG/Reactome/GSEA/pathway enrichment), tooluniverse-statistical-modeling (regression, ANOVA, ordinal/logistic, chi-square, correl

Testing & QA481 installs

tooluniverse-drug-research

mims-harvard/tooluniverse

Comprehensive drug profiling — mechanism, primary/secondary targets, drug interactions, clinical-trial status, adverse events (FAERS), pharmacogenomics, and approval history. Use for full drug investigation reports, 'tell me about drug X' queries, and assembling drug profiles for clinicians, researchers, or regulatory work.

Popular code quality & workflow skills

View category →

grill-me

mattpocock/skills

A relentless interview to sharpen a plan or design.

Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.

handoff

mattpocock/skills

Compact the current conversation into a handoff document for another agent to pick up.

domain-modeling

mattpocock/skills

Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.

codebase-design

mattpocock/skills

Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.

diagnosing-bugs

mattpocock/skills

Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.