SI

single2spatial-spatial-mapping

Maps single-cell transcriptomics data onto spatial profiles using deep-forest models and omicverse.

Install

mkdir -p .claude/skills/single2spatial-spatial-mapping && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2425" && unzip -o skill.zip -d .claude/skills/single2spatial-spatial-mapping && rm skill.zip

Installs to .claude/skills/single2spatial-spatial-mapping

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Map scRNA-seq atlases onto spatial transcriptomics slides using omicverse's Single2Spatial workflow for deep-forest training, spot-level assessment, and marker visualisation.
174 charsno explicit “when” trigger
Advanced

Key capabilities

  • Map scRNA-seq atlases to spatial slides
  • Train deep-forest models for spatial data
  • Reconstruct spot-level cell proportions
  • Visualize marker gene expression
  • Assess spatial data quality

How it works

It uses a deep-forest model to learn the mapping between single-cell references and spatial transcriptomics spots to predict cell-type compositions.

Inputs & outputs

You give it
scRNA-seq and spatial AnnData objects
You get back
Reconstructed spatial AnnData and plots

When to use single2spatial-spatial-mapping

  • Map scRNA-seq to spatial slides
  • Visualize marker expression
  • Train deep-forest models for spatial data
  • Reconstruct spot-level proportions

About this skill

Single2Spatial spatial mapping

Overview

Apply this skill when converting single-cell references into spatially resolved profiles. It follows t_single2spatial.ipynb, demonstrating how Single2Spatial trains on PDAC scRNA-seq and Visium data, reconstructs spot-level proportions, and visualises marker expression.

Instructions

  1. Import dependencies and style
    • Load omicverse as ov, scanpy as sc, anndata, pandas as pd, numpy as np, and matplotlib.pyplot as plt.
    • Call ov.utils.ov_plot_set() (or ov.plot_set() in older versions) to align plots with omicverse styling.
  2. Load single-cell and spatial datasets
    • Read processed matrices with pd.read_csv(...) then create AnnData objects (anndata.AnnData(raw_df.T)).
    • Attach metadata: single_data.obs = pd.read_csv(...)[['Cell_type']] and spatial_data.obs = pd.read_csv(... ) containing coordinates and slide metadata.
  3. Initialise Single2Spatial
    • Instantiate ov.bulk2single.Single2Spatial(single_data=single_data, spatial_data=spatial_data, celltype_key='Cell_type', spot_key=['xcoord','ycoord'], gpu=0).
    • Note that inputs should be normalised/log-scaled scRNA-seq matrices; ensure spot_key matches spatial coordinate columns.
  4. Train the deep-forest model
    • Execute st_model.train(spot_num=500, cell_num=10, df_save_dir='...', df_save_name='pdac_df', k=10, num_epochs=1000, batch_size=1000, predicted_size=32) to fit the mapper and generate reconstructed spatial AnnData (sp_adata).
    • Explain that spot_num defines sampled pseudo-spots per iteration and cell_num controls per-spot cell draws.
  5. Load pretrained weights
    • Use st_model.load(modelsize=14478, df_load_dir='.../pdac_df.pth', k=10, predicted_size=32) when checkpoints already exist to skip training.
  6. Assess spot-level outputs
    • Call st_model.spot_assess() to compute aggregated spot AnnData (sp_adata_spot) for QC.
    • Plot marker genes with sc.pl.embedding(sp_adata, basis='X_spatial', color=['REG1A', 'CLDN1', ...], frameon=False, ncols=4).
  7. Visualise proportions and cell-type maps
    • Use sc.pl.embedding(sp_adata_spot, basis='X_spatial', color=['Acinar cells', ...], frameon=False) to highlight per-spot cell fractions.
    • Plot sp_adata coloured by Cell_type with palette=ov.utils.ov_palette()[11:] to show reconstructed assignments.
  8. Export results
    • Encourage saving generated AnnData objects (sp_adata.write_h5ad(...), sp_adata_spot.write_h5ad(...)) and derived CSV summaries for downstream reporting.
  9. Defensive validation
    # Before Single2Spatial: verify spatial coordinates exist
    for col in spot_key:
        assert col in spatial_data.obs.columns, f"Spatial coordinate column '{col}' not found in spatial_data.obs"
    # Verify scRNA-seq is log-normalized (max should be <~15, not hundreds/thousands)
    if single_data.X.max() > 50:
        print("WARNING: scRNA-seq data may not be log-normalized. Raw counts cause scale mismatches.")
    # Verify cell type column exists
    assert celltype_key in single_data.obs.columns, f"Cell type column '{celltype_key}' not found"
    
  10. Troubleshooting tips
  • If training diverges, reduce learning_rate via keyword arguments or decrease predicted_size to stabilise the forest.
  • Ensure scRNA-seq inputs are log-normalised; raw counts can lead to scale mismatches and poor spatial predictions.
  • Verify GPU availability when gpu is non-zero; fallback to CPU by omitting the argument or setting gpu=-1.

Examples

  • "Train Single2Spatial on PDAC scRNA-seq and Visium slides, then visualise REG1A and CLDN1 spatial expression."
  • "Load a saved Single2Spatial checkpoint to regenerate spot-level cell-type proportions for reporting."
  • "Plot reconstructed cell-type maps with omicverse palettes to compare against histology."

References

When not to use it

  • With non-spatial transcriptomics data
  • When scRNA-seq data is not log-normalized

Prerequisites

omicversescanpyscRNA-seq and spatial datasets

Limitations

  • Requires log-normalized scRNA-seq input
  • Training can be resource-intensive

How it compares

It provides a specialized workflow for spatial reconstruction compared to generic single-cell analysis tools.

Compared to similar skills

single2spatial-spatial-mapping side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
single2spatial-spatial-mapping (this skill)15moNo flagsAdvanced
quant-analyst1032moNo flagsAdvanced
umap-learn62moReviewIntermediate
embedding-strategies82moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

quant-analyst

zenobi-us

Expert quantitative analyst specializing in financial modeling, algorithmic trading, and risk analytics. Masters statistical methods, derivatives pricing, and high-frequency trading with focus on mathematical rigor, performance optimization, and profitable strategy development.

103355

umap-learn

K-Dense-AI

UMAP dimensionality reduction. Fast nonlinear manifold learning for 2D/3D visualization, clustering preprocessing (HDBSCAN), supervised/parametric UMAP, for high-dimensional data.

6100

embedding-strategies

wshobson

Select and optimize embedding models for semantic search and RAG applications. Use when choosing embedding models, implementing chunking strategies, or optimizing embedding quality for specific domains.

890

building-automl-pipelines

jeremylongshore

Build automated machine learning pipelines, including feature engineering, model selection, and performance evaluation.

688

model-compare

rawwerks

Compare 3D CAD models using boolean operations (IoU, Dice, precision/recall). Use when evaluating generated models against gold references, diffing CAD revisions, or computing similarity metrics for ML training. Triggers on: model diff, compare models, IoU, intersection over union, model similarity, CAD comparison, STEP diff, 3D evaluation, gold reference, generated model, precision recall 3D.

783

matchms

davila7

Mass spectrometry analysis. Process mzML/MGF/MSP, spectral similarity (cosine, modified cosine), metadata harmonization, compound ID, for metabolomics and MS data processing.

674

Search skills

Search the agent skills registry