name: 'nicheformer-spatial-agent'
description: 'Foundation model-powered spatial transcriptomics analysis leveraging 53M+ spatially resolved cells for cellular architecture modeling and tissue niche discovery.'
measurable_outcome: Execute skill workflow successfully with valid output within 15 minutes.
allowed-tools:
- read_file
- run_shell_command
Nicheformer Spatial Agent
The Nicheformer Spatial Agent leverages the Nicheformer foundation model, trained on over 53 million spatially resolved cells, to model cellular architecture and tissue microenvironments with unprecedented accuracy. It enables spatial context-aware cell type annotation, niche discovery, and tissue organization analysis.
When to Use This Skill
- When analyzing spatial transcriptomics requiring deep cellular context understanding.
- For identifying tissue niches and cellular neighborhoods.
- To predict cell-cell interactions based on spatial proximity.
- When transferring annotations from atlases to new spatial data.
- For studying tissue architecture and organization patterns.
Core Capabilities
Spatial Context Embeddings: Generate embeddings that capture both gene expression and spatial context.
Niche Discovery: Identify recurrent cellular neighborhoods across tissues.
Zero-Shot Cell Type Annotation: Transfer cell type labels without retraining.
Spatial Perturbation Prediction: Predict effects of removing cell types from niches.
Cross-Tissue Transfer: Apply models trained on one tissue to another.
Tissue Architecture Analysis: Quantify spatial organization patterns.
Model Architecture
| Component |
Description |
Parameters |
| Expression Encoder |
Gene expression transformer |
~100M |
| Spatial Encoder |
Neighborhood graph attention |
~50M |
| Fusion Layer |
Cross-attention expression + spatial |
~30M |
| Pretraining Data |
53M+ spatially resolved cells |
Multi-tissue |
Supported Spatial Technologies
| Platform |
Coverage |
Resolution |
| 10x Xenium |
Full support |
Subcellular |
| MERFISH |
Full support |
Subcellular |
| CosMx |
Full support |
Subcellular |
| Visium |
Supported |
55 μm spot |
| Slide-seq |
Supported |
10 μm bead |
| seqFISH+ |
Supported |
Subcellular |
| STARmap |
Supported |
Subcellular |
Workflow
Input: Spatial transcriptomics data with coordinates.
Preprocessing: Normalize, filter, construct spatial graphs.
Embedding Generation: Compute Nicheformer embeddings per cell/spot.
Niche Clustering: Identify spatial domains and niches.
Annotation Transfer: Map cell types from reference atlases.
Interaction Analysis: Predict cell-cell communication in niches.
Output: Annotated spatial data, niche assignments, interaction networks.
Example Usage
User: "Use Nicheformer to identify cellular niches in this tumor spatial transcriptomics dataset."
Agent Action:
python3 Skills/Genomics/Nicheformer_Spatial_Agent/nicheformer_analysis.py \
--spatial_data xenium_tumor.h5ad \
--model_weights nicheformer_pretrained.pt \
--k_neighbors 15 \
--niche_resolution 0.5 \
--reference_atlas tabula_sapiens.h5ad \
--output tumor_niches_analysis/
Niche Analysis Outputs
| Output |
Description |
Format |
| Cell Embeddings |
Spatial-aware embeddings |
.h5ad obsm |
| Niche Labels |
Cluster assignments |
.csv |
| Niche Signatures |
Defining gene programs |
.csv |
| Spatial Maps |
Visualizations |
.png, .pdf |
| Interaction Network |
Cell-cell edges |
.graphml |
| Architecture Metrics |
Tissue organization scores |
.json |
Niche Types Detected
| Niche Category |
Examples |
Markers |
| Immune Aggregates |
TLS, germinal centers |
CD20, CD3, PD1 |
| Tumor Core |
Hypoxic, proliferative |
HIF1A, MKI67 |
| Invasion Front |
EMT, matrix remodeling |
VIM, MMP9 |
| Stromal |
Fibroblast niches |
COL1A1, ACTA2 |
| Vascular |
Perivascular zones |
PECAM1, VWF |
| Neural |
Nerve-associated |
NCAM1, NGF |
AI/ML Components
Foundation Model:
- Transformer backbone with spatial attention
- Pretrained on 53M cells across tissues
- Self-supervised contrastive learning
Spatial Graph Construction:
- Delaunay triangulation
- k-NN with distance threshold
- Hierarchical multi-scale graphs
Transfer Learning:
- Zero-shot annotation via embedding similarity
- Few-shot fine-tuning for novel cell types
- Domain adaptation for new tissues
Performance Benchmarks
| Task |
Metric |
Performance |
| Cell Type Annotation |
Accuracy |
92-96% |
| Niche Recovery |
ARI |
0.85-0.92 |
| Cross-Tissue Transfer |
F1 |
0.88-0.94 |
| Batch Integration |
kBET |
0.90+ |
Prerequisites
- Python 3.10+
- PyTorch 2.0+, PyTorch Geometric
- Scanpy, Squidpy
- Nicheformer pretrained weights
- GPU with 16GB+ VRAM recommended
Related Skills
- SIMO_Multiomics_Integration_Agent - For multi-omics spatial integration
- scGPT_Agent - For single-cell foundation models
- Cell_Cell_Communication - For ligand-receptor analysis
- Spatial_Epigenomics_Agent - For spatial epigenomics
Spatial Architecture Metrics
| Metric |
Description |
Interpretation |
| Moran's I |
Spatial autocorrelation |
Clustering degree |
| Ripley's K |
Point pattern analysis |
Aggregation vs dispersion |
| Neighborhood Enrichment |
Cell type co-occurrence |
Preferential associations |
| Connectivity |
Graph topology |
Tissue organization |
Special Considerations
- Gene Panel Overlap: Ensure sufficient overlap with training data genes
- Tissue Context: Model performance varies by tissue type
- Resolution Effects: Aggregate for spot-based technologies
- GPU Memory: Batch processing for large datasets
- Validation: Compare with known tissue architecture
Applications
| Domain |
Application |
| Oncology |
Tumor microenvironment niches |
| Immunology |
Tertiary lymphoid structures |
| Development |
Organ patterning and morphogenesis |
| Neuroscience |
Brain region architecture |
| Pathology |
Disease-specific spatial signatures |
Author
AI Group - Biomedical AI Platform
1---2name: nicheformer-spatial-agent3description: <!--4---5<!--6# COPYRIGHT NOTICE7# This file is part of the "Universal Biomedical Skills" project.8# Copyright (c) 2026 MD BABU MIA, PhD <md.babu.mia@mssm.edu>9# All Rights Reserved.10#11# This code is proprietary and confidential.12# Unauthorized copying of this file, via any medium is strictly prohibited.13#14# Provenance: Authenticated by MD BABU MIA1516-->1718---19name: 'nicheformer-spatial-agent'20description: 'Foundation model-powered spatial transcriptomics analysis leveraging 53M+ spatially resolved cells for cellular architecture modeling and tissue niche discovery.'21measurable_outcome: Execute skill workflow successfully with valid output within 15 minutes.22allowed-tools:23 - read_file24 - run_shell_command25---262728# Nicheformer Spatial Agent2930The **Nicheformer Spatial Agent** leverages the Nicheformer foundation model, trained on over 53 million spatially resolved cells, to model cellular architecture and tissue microenvironments with unprecedented accuracy. It enables spatial context-aware cell type annotation, niche discovery, and tissue organization analysis.3132## When to Use This Skill3334* When analyzing spatial transcriptomics requiring deep cellular context understanding.35* For identifying tissue niches and cellular neighborhoods.36* To predict cell-cell interactions based on spatial proximity.37* When transferring annotations from atlases to new spatial data.38* For studying tissue architecture and organization patterns.3940## Core Capabilities41421. **Spatial Context Embeddings**: Generate embeddings that capture both gene expression and spatial context.43442. **Niche Discovery**: Identify recurrent cellular neighborhoods across tissues.45463. **Zero-Shot Cell Type Annotation**: Transfer cell type labels without retraining.47484. **Spatial Perturbation Prediction**: Predict effects of removing cell types from niches.49505. **Cross-Tissue Transfer**: Apply models trained on one tissue to another.51526. **Tissue Architecture Analysis**: Quantify spatial organization patterns.5354## Model Architecture5556| Component | Description | Parameters |57|-----------|-------------|------------|58| Expression Encoder | Gene expression transformer | ~100M |59| Spatial Encoder | Neighborhood graph attention | ~50M |60| Fusion Layer | Cross-attention expression + spatial | ~30M |61| Pretraining Data | 53M+ spatially resolved cells | Multi-tissue |6263## Supported Spatial Technologies6465| Platform | Coverage | Resolution |66|----------|----------|------------|67| 10x Xenium | Full support | Subcellular |68| MERFISH | Full support | Subcellular |69| CosMx | Full support | Subcellular |70| Visium | Supported | 55 μm spot |71| Slide-seq | Supported | 10 μm bead |72| seqFISH+ | Supported | Subcellular |73| STARmap | Supported | Subcellular |7475## Workflow76771. **Input**: Spatial transcriptomics data with coordinates.78792. **Preprocessing**: Normalize, filter, construct spatial graphs.80813. **Embedding Generation**: Compute Nicheformer embeddings per cell/spot.82834. **Niche Clustering**: Identify spatial domains and niches.84855. **Annotation Transfer**: Map cell types from reference atlases.86876. **Interaction Analysis**: Predict cell-cell communication in niches.88897. **Output**: Annotated spatial data, niche assignments, interaction networks.9091## Example Usage9293**User**: "Use Nicheformer to identify cellular niches in this tumor spatial transcriptomics dataset."9495**Agent Action**:96```bash97python3 Skills/Genomics/Nicheformer_Spatial_Agent/nicheformer_analysis.py \98 --spatial_data xenium_tumor.h5ad \99 --model_weights nicheformer_pretrained.pt \100 --k_neighbors 15 \101 --niche_resolution 0.5 \102 --reference_atlas tabula_sapiens.h5ad \103 --output tumor_niches_analysis/104```105106## Niche Analysis Outputs107108| Output | Description | Format |109|--------|-------------|--------|110| Cell Embeddings | Spatial-aware embeddings | .h5ad obsm |111| Niche Labels | Cluster assignments | .csv |112| Niche Signatures | Defining gene programs | .csv |113| Spatial Maps | Visualizations | .png, .pdf |114| Interaction Network | Cell-cell edges | .graphml |115| Architecture Metrics | Tissue organization scores | .json |116117## Niche Types Detected118119| Niche Category | Examples | Markers |120|----------------|----------|---------|121| Immune Aggregates | TLS, germinal centers | CD20, CD3, PD1 |122| Tumor Core | Hypoxic, proliferative | HIF1A, MKI67 |123| Invasion Front | EMT, matrix remodeling | VIM, MMP9 |124| Stromal | Fibroblast niches | COL1A1, ACTA2 |125| Vascular | Perivascular zones | PECAM1, VWF |126| Neural | Nerve-associated | NCAM1, NGF |127128## AI/ML Components129130**Foundation Model**:131- Transformer backbone with spatial attention132- Pretrained on 53M cells across tissues133- Self-supervised contrastive learning134135**Spatial Graph Construction**:136- Delaunay triangulation137- k-NN with distance threshold138- Hierarchical multi-scale graphs139140**Transfer Learning**:141- Zero-shot annotation via embedding similarity142- Few-shot fine-tuning for novel cell types143- Domain adaptation for new tissues144145## Performance Benchmarks146147| Task | Metric | Performance |148|------|--------|-------------|149| Cell Type Annotation | Accuracy | 92-96% |150| Niche Recovery | ARI | 0.85-0.92 |151| Cross-Tissue Transfer | F1 | 0.88-0.94 |152| Batch Integration | kBET | 0.90+ |153154## Prerequisites155156* Python 3.10+157* PyTorch 2.0+, PyTorch Geometric158* Scanpy, Squidpy159* Nicheformer pretrained weights160* GPU with 16GB+ VRAM recommended161162## Related Skills163164* SIMO_Multiomics_Integration_Agent - For multi-omics spatial integration165* scGPT_Agent - For single-cell foundation models166* Cell_Cell_Communication - For ligand-receptor analysis167* Spatial_Epigenomics_Agent - For spatial epigenomics168169## Spatial Architecture Metrics170171| Metric | Description | Interpretation |172|--------|-------------|----------------|173| Moran's I | Spatial autocorrelation | Clustering degree |174| Ripley's K | Point pattern analysis | Aggregation vs dispersion |175| Neighborhood Enrichment | Cell type co-occurrence | Preferential associations |176| Connectivity | Graph topology | Tissue organization |177178## Special Considerations1791801. **Gene Panel Overlap**: Ensure sufficient overlap with training data genes1812. **Tissue Context**: Model performance varies by tissue type1823. **Resolution Effects**: Aggregate for spot-based technologies1834. **GPU Memory**: Batch processing for large datasets1845. **Validation**: Compare with known tissue architecture185186## Applications187188| Domain | Application |189|--------|-------------|190| Oncology | Tumor microenvironment niches |191| Immunology | Tertiary lymphoid structures |192| Development | Organ patterning and morphogenesis |193| Neuroscience | Brain region architecture |194| Pathology | Disease-specific spatial signatures |195196## Author197198AI Group - Biomedical AI Platform199200201<!-- AUTHOR_SIGNATURE: 9a7f3c2e-MD-BABU-MIA-2026-MSSM-SECURE -->