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".
In this repository8 other files it gives its agents.
- cell-dynamicsSkill
- cell-interactionSkill
- differential-analysisSkill
- functional-analysisSkill
- publication-readySkill
- spatial-analysisSkill
- spatial-patternsSkill
- troubleshootSkill
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
- Very specific: line 115
Use deconvolve_data tool with:
- Very specific: line 140
Use visualize_data with plot_type="deconvolution".
- Distinctive: line 183
Use these results for:
≈ “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.
Files
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 workflowDeconvolution Method Selection
Quick Reference Table
| Your Scenario | Recommended Method | Why |
| Quick exploration | FlashDeconv | Fastest, good accuracy |
| Publication quality | RCTD (doublet mode) | Gold standard, well-validated |
| Large dataset (>50k spots) | Cell2location | Scalable, GPU-accelerated |
| Need spatial imputation | CARD | Can impute cell-type-specific expression |
| No matched reference | Tangram | More flexible with reference |
| Deep learning preference | DestVI/Stereoscope | Variational 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 Visiummulti: 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 insteadStep 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 treereference_data_id: Loaded reference datasetcell_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:
- Spatial pie charts: Overall composition per spot
- Individual cell type maps: Spatial distribution of each type
- Dominant cell type: Which type is most abundant at each spot
- 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 labelsOption B: Marker-Based
1. Define marker genes per cell type
2. Use annotate_cell_types with method="cellassign" or "marker"
3. Validate against known markersOption C: LLM-Assisted (Experimental)
1. Identify cluster marker genes
2. Use mLLMCelltype for LLM-based annotation
3. Verify with domain knowledgeCommon Issues and Solutions
| Problem | Likely Cause | Solution |
| All spots same composition | Poor reference match | Try different reference or method |
| Missing expected cell types | Low gene overlap | Check shared genes, try Tangram |
| Unrealistic proportions | Normalization mismatch | Ensure consistent normalization |
| Method fails | Dependency issue | Check 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
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
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.

