pharmolix/openbiomed/spatial-transcriptomics-spatial-data-io
Claude Code and agent skill by pharmolix/openbiomed
- community
Checking that the SKILL.md file is still in the repository.
Load spatial transcriptomics data from Visium, Xenium, MERFISH, Slide-seq, and other platforms using Squidpy and SpatialData. Use this skill when: (1) Loading Visium spatial transcriptomics data from Space Ranger output, (2) Loading Xenium single-cell resolution spatial data, (3) Loading MERFISH, CosMx, or other spatial platforms, (4) Converting between SpatialData and AnnData formats.
Install
npx vskill@latest install pharmolix/openbiomed/spatial-transcriptomics-spatial-data-ioSKILL.md
The same SKILL.md was published earlier as pharmolix/openbiomed/spatial-transcriptomics-spatial-data-io.
Spatial Transcriptomics Data I/O
Load spatial transcriptomics data from Visium, Xenium, MERFISH, Slide-seq, and other platforms using Squidpy and SpatialData. Read Space Ranger outputs, convert formats, and access spatial coordinates. Use when loading Visium, Xenium, MERFISH, or other spatial data.
What it does
- Takes your platform-specific spatial data directory (e.g., Space Ranger output) as input.
- Identifies and parses the correct platform format (Visium, Xenium, MERFISH, Slide-seq, CosMx, Stereo-seq).
- Reads the raw expression matrix (spot-level or single-cell resolution).
- Automatically loads and scales spatial coordinates (
x,ypixels or physical distances). - Ingests accompanying tissue images and spatial scale factors directly into the data object structure.
- Returns a standardized
AnnDataorSpatialDataobject, binding expression data, shapes, and images together for immediate downstream analysis.
Why this exists
- Uses
squidpyandspatialdata_io, the gold-standard parsers for spatial data. - Automatically handles platform-specific quirks (e.g., Xenium single-cell vs. Visium spot resolution).
- Safely nests coordinates in
obsm['spatial']and images/scale factors inuns['spatial']to ensure compatibility with all major spatial plotting tools. - Provides future-proof integration by offering
SpatialData(Zarr) representations for modern, multi-modal spatial projects.
Usage
"Load my Visium spatial data" → Read spatial transcriptomics outputs (Visium, Xenium, MERFISH, Slide-seq) into AnnData objects with spatial coordinates and tissue images.
- Python:
squidpy.read.visium('spaceranger_out/'),spatialdata.read_zarr()
Load and work with spatial transcriptomics data from various platforms.
Required Imports
Load 10X Visium Data
Goal: Load Visium spatial transcriptomics data from Space Ranger output into an AnnData object.
Approach: Use Squidpy's read.visium to parse the output directory, which loads expression, spatial coordinates, and tissue images.
Load Visium with Scanpy
Goal: Load Visium data using Scanpy's built-in reader as an alternative to Squidpy.
Approach: Use sc.read_visium to parse Space Ranger output, then access images and scale factors from adata.uns['spatial'].
Load 10X Xenium Data
Goal: Load single-cell resolution Xenium spatial data.
Approach: Use Squidpy's read.xenium to parse Xenium output, yielding per-cell expression and coordinates.
Load with SpatialData (Recommended for New Projects)
Goal: Load spatial data into SpatialData objects for unified multi-modal representation.
Approach: Use spatialdata-io readers per platform, which organize expression, shapes, and images into a single object.
Load MERFISH Data
Goal: Load MERFISH (Vizgen MERSCOPE) spatial data.
Approach: Use spatialdata-io or Squidpy readers to parse MERSCOPE output with cell-by-gene counts and metadata.
Load Slide-seq Data
Load Nanostring CosMx
Load Stereo-seq Data
Load from H5AD with Spatial Coordinates
Create Spatial AnnData from Scratch
Goal: Construct a spatial AnnData object from raw expression and coordinate arrays.
Approach: Build an AnnData with spatial coordinates in obsm['spatial'] and minimal metadata in uns['spatial'] for Squidpy compatibility.
Access Spatial Coordinates
Access Tissue Images
Convert Between Formats
Goal: Convert spatial data between SpatialData and AnnData representations.
Approach: Extract tables and coordinate arrays from SpatialData, then save as h5ad or zarr.
Load Multiple Samples
Goal: Load and merge spatial data from multiple Visium samples into a single AnnData.
Approach: Iterate over sample directories, tag each with a sample label, then concatenate with ad.concat.
Subset by Spatial Region
Goal: Extract spots within a rectangular spatial region of interest.
Approach: Apply coordinate-based boolean masking on obsm['spatial'] to filter spots by x/y bounds.
Example Output
Requirements
| Requirement | Version | |
|---|---|---|
| Python | 3.9+ | |
| squidpy | 1.3+ | |
| spatialdata | 0.1+ | |
| spatialdata_io | latest | |
| scanpy | 1.10+ | |
| anndata | 0.10+ | |
| numpy | 1.26+ | |
| pandas | 2.2+ |
Inputs
| Name | Type | Format | Description | |
|---|---|---|---|---|
| data_dir | directory | - | Path to the platform-specific output directory (e.g., Space Ranger out, Xenium out) | |
| platform | string | - | Specify the platform (visium, xenium, merscope, slideseq, cosmx, stereoseq) |
Outputs
| Name | Type | Format | Description | |
|---|---|---|---|---|
| adata | object | h5ad | AnnData object containing expression, spatial coordinates, and tissue images | |
| sdata | object | zarr | SpatialData object for unified multi-modal representation |
Citations
https://github.com/FreedomIntelligence/OpenClaw-Medical-Skills/blob/main/skills/bio-spatial-transcriptomics-spatial-data-io
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/spatial-transcriptomics-spatial-data-io/SKILL.md
Popularity
- Repository stars
- 1,105
- Repository forks
- 132
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pharmolix/openbiomed/spatial-transcriptomics-spatial-data-io)