agentleFS
cafferychen777cafferychen777/ChatSpatial/.agents/skills/cell-composition/SKILL.md

cell-composition

Skill45 starsChanged 3 months agoMITView on GitHub

Determine cell type composition at each spatial location through deconvolution or annotation. Use when user wants to know what cell types exist, their proportions, or where specific cells are located. Triggers: "cell type composition", "deconvolution", "what cells are here", "cell type proportions", "estimate cell types", "annotate cells", "which cell types".

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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. Very specific:

    Use deconvolve_data tool with:

    line 115
  2. Very specific:

    Use visualize_data with plot_type="deconvolution".

    line 140
  3. Distinctive:

    Use these results for:

    line 183

≈ “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

Cell Composition Analysis

Overview

This skill answers the fundamental question: What cell types exist at each spatial location, and in what proportions?

For spot-based data (Visium), this requires deconvolution to estimate cell type mixtures. For single-cell resolution data (Xenium/MERFISH), this requires direct cell type annotation.

Decision Tree: Which Approach?

START: User wants cell type information
    │
    ├─ Q: What is the data resolution?
    │   │
    │   ├─ Spot-based (Visium, Slide-seq)
    │   │   └─ Q: Do you have a reference scRNA-seq dataset?
    │   │       ├─ YES → Deconvolution (see below)
    │   │       └─ NO → Q: Do you have marker genes?
    │   │           ├─ YES → Marker-based annotation
    │   │           └─ NO → Use public atlas as reference
    │   │
    │   └─ Single-cell (Xenium, MERFISH, CosMx)
    │       └─ Q: Do you have a reference dataset?
    │           ├─ YES → Transfer learning (Tangram/scANVI)
    │           └─ NO → Marker-based or LLM annotation
    │
    └─ Execute appropriate workflow

Deconvolution Method Selection

Quick Reference Table

Your ScenarioRecommended MethodWhy
Quick explorationFlashDeconvFastest, good accuracy
Publication qualityRCTD (doublet mode)Gold standard, well-validated
Large dataset (>50k spots)Cell2locationScalable, GPU-accelerated
Need spatial imputationCARDCan impute cell-type-specific expression
No matched referenceTangramMore flexible with reference
Deep learning preferenceDestVI/StereoscopeVariational inference

Detailed Method Guide

FlashDeconv (Recommended Default)

  • Speed: Fastest (~seconds to minutes)
  • Accuracy: Good for most applications
  • When to use: Initial exploration, iterative analysis
  • Limitations: Less accurate for rare cell types

RCTD (Publication Standard)

  • Speed: Moderate (~minutes)
  • Accuracy: Excellent, especially with doublet mode
  • When to use: Final results, manuscript figures
  • Modes:
    • doublet: High-resolution platforms (Visium HD, Slide-seq)
    • full: Standard Visium
    • multi: When spots may contain >2 cell types
  • Note: R-based, requires rpy2

Cell2location (Large Scale)

  • Speed: Slow but scalable (~hours)
  • Accuracy: Excellent for complex tissues
  • When to use: Large datasets, need uncertainty estimates
  • Requirements: GPU recommended, scvi-tools

CARD (Spatial Imputation)

  • Speed: Moderate
  • Accuracy: Good
  • Unique feature: Can impute cell-type-specific gene expression
  • When to use: Need spatial expression patterns per cell type
  • Note: R-based

Workflow: Deconvolution

Step 1: Prepare Reference Data

Requirements for reference scRNA-seq:

  • Cell type annotations in adata.obs
  • Sufficient cells per type (>50 recommended)
  • Matching species and tissue type
  • Quality-controlled and normalized
If no reference available:
1. Check CellxGene for public atlases
2. Use Tabula Sapiens (human) or Tabula Muris (mouse)
3. Consider marker-based annotation instead

Step 2: Validate Reference

Before deconvolution, verify:

  • Cell type labels are present and clean
  • No ambiguous categories (remove "unknown", "doublet")
  • Sufficient cells per type
  • Gene overlap with spatial data

Step 3: Run Deconvolution

Use deconvolve_data tool with:

  • method: Selected method from decision tree
  • reference_data_id: Loaded reference dataset
  • cell_type_key: Column name with cell type labels

Step 4: Validate Results

Quality checks:

  • Proportions sum to approximately 1
  • Spatial patterns make biological sense
  • Known cell type distributions match literature

Red flags:

  • One cell type dominates everywhere → check reference quality
  • Proportions don't vary spatially → possible normalization issue
  • Expected cell types missing → check gene overlap

Step 5: Visualize

Essential visualizations:

  1. Spatial pie charts: Overall composition per spot
  2. Individual cell type maps: Spatial distribution of each type
  3. Dominant cell type: Which type is most abundant at each spot
  4. Diversity index: Cellular heterogeneity across tissue

Use visualize_data with plot_type="deconvolution".

Workflow: Direct Annotation (Single-Cell Resolution)

For Xenium/MERFISH data:

Option A: Transfer from Reference

1. Load reference scRNA-seq with cell type labels
2. Use annotate_cell_types with method="tangram" or "scanvi"
3. Validate transferred labels

Option B: Marker-Based

1. Define marker genes per cell type
2. Use annotate_cell_types with method="cellassign" or "marker"
3. Validate against known markers

Option C: LLM-Assisted (Experimental)

1. Identify cluster marker genes
2. Use mLLMCelltype for LLM-based annotation
3. Verify with domain knowledge

Common Issues and Solutions

ProblemLikely CauseSolution
All spots same compositionPoor reference matchTry different reference or method
Missing expected cell typesLow gene overlapCheck shared genes, try Tangram
Unrealistic proportionsNormalization mismatchEnsure consistent normalization
Method failsDependency issueCheck R packages installed (rpy2)

Output Interpretation

Deconvolution produces:

  • Proportions matrix: Cell type fractions per spot (stored in adata.obsm)
  • Spatial patterns: Where each cell type is enriched
  • Biological context: Cell type organization in tissue architecture

Use these results for:

  • Understanding tissue composition
  • Identifying cell type niches
  • Downstream cell-cell communication analysis

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.