Skip to main content

spatialsnake logo

Documentation PyPI Snakemake

A Snakemake workflow for spatial transcriptomics powered by the spatialdata framework.

spatialsnake is an automated pipeline for spatial transcriptomics analysis. Implemented in Python on top of the scverse ecosystem, it uses SpatialData to convert datasets from multiple spatial transcriptomics platforms into a unified zarr-based object format. This design supports a consistent workflow spanning data ingestion, preprocessing, clustering, annotation, and downstream analysis through a command-line interface with workflow-based parameter control.

Project at a Glance

Item Summary
Official Documentation spatialsnake Documentation
Tutorial Article Core Analysis Tutorial
Workflow Modes single_analysis, compare_analysis
Utility Entry Points useful_tool, produce-file, install-packages
Main Analysis Options integrate, preprocess, clustering, reclustering, annotation_help, annotation, advance_analysis, compare_stage
Supported Input Types visium, visium_segment, visium_HD, xenium, Merfish, stereo_seq

Core Functions

  • Standardize raw spatial transcriptomics data into a unified object during Ingesting.
  • Run preprocess for quality control, filtering, normalization, and dimensionality reduction preparation.
  • Perform clustering and visualization, followed by annotation_help and annotation.
  • Carry out reclustering and reannotation for clusters of interest.
  • Execute advance_analysis for downstream analyses and compare_stage for cross-sample comparison.
  • Use auxiliary utilities for splitting, merge, and transform.

Available Platforms

Sequencing-based

  • visium: 10x Genomics spatial transcriptomics data
  • visium_HD: high-resolution 10x Genomics spatial transcriptomics data
  • visium_segment: cell segmentation outputs from 10x Genomics Space Ranger
  • stereo_seq: BGI Stereo-seq spatial transcriptomics data, including different bin sizes, cellbin, and adjusted cellbin data types

Imaging-based

  • xenium: image-based 10x Genomics Xenium spatial transcriptomics data
  • Merfish: Vizgen MERFISH spatial transcriptomics data

Basic Installation

1. Create the base conda environment

conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge
conda create -n spatialsnake_env python=3.12.11 snakemake-minimal=9.8.1 r-base=4.4.0 -y
conda activate spatialsnake_env

2. Install the documented core dependencies

conda install -c conda-forge r-optparse r-tidyverse r-future r-jsonlite r-rcolorbrewer r-patchwork r-cowplot r-pheatmap r-seurat r-remotes r-biocmanager r-presto r-nmf r-circlize
conda install -c bioconda bioconductor-annotationdbi bioconductor-complexheatmap bioconductor-clusterprofiler bioconductor-edger bioconductor-org.hs.eg.db bioconductor-org.mm.eg.db bioconductor-rhdf5 bioconductor-biocneighbors
conda install -c conda-forge bbknn cython

3. Install spatialsnake

Option 1. Install from PyPI

pip install spatialsnake
spatialsnake --version

Option 2. Install from conda

Use this as a fresh conda-native install path instead of the manual dependency steps above:

conda create -n spatialsnake_env -c conda-forge -c bioconda spatialsnake -y
conda activate spatialsnake_env
spatialsnake --version
spatialsnake install-packages

Option 3. Install from source code

git clone https://github.com/zhenghlin/spatialsnake.git
cd spatialsnake
python -m pip install .
python -m pip install ".[extended]"
spatialsnake --version

4. Optional extended package step

For PyPI or source installs:

pip install "spatialsnake[extended]"
spatialsnake install-packages

For conda installs:

spatialsnake install-packages --extended

With the minimal installation, the documented workflow includes integrate, preprocess, clustering, reclustering, annotation_help, annotation, reannotation, and utility operations for merge and split. For conda installs, spatialsnake install-packages completes the minimal pip-only core packages; spatialsnake install-packages --extended adds downstream Python packages, pybanksy, and R/GitHub packages for documented extended components including compare_stage, transform, banksy, and cellchat-related workflows. For PyPI installs, keep using pip install "spatialsnake[extended]" before spatialsnake install-packages.

Working Directory

Prepare the working directory before running the main workflow:

project_root/
├── data/
├── sample.txt
├── results/
└── <analysis_option>.yaml
mkdir -p project_root/data project_root/results
touch project_root/sample.txt

sample.txt is the required sample information table for every module in the main workflow. In the working directory, data/ stores raw input data, results/ stores analysis outputs generated by the workflow, and <analysis_option>.yaml is an optional configuration file.

Minimal Usage

The command-line interface provides the following documented entry points:

spatialsnake <command> <INPUT> <TYPE> [--option=<analysis_option>] [options]
spatialsnake useful_tool [--option=<ways>] <INPUT> [options]
spatialsnake produce-file [--option=<analysis_option>]
spatialsnake install-packages [--extended] [--dry-run]
spatialsnake (-h | --help)
spatialsnake --version

Main workflow selection:

  • <command>: choose single_analysis or compare_analysis
  • <TYPE>: choose from visium, visium_segment, visium_HD, xenium, Merfish, and stereo_seq
  • --option=<analysis_option>: choose from integrate, preprocess, clustering, reclustering, annotation_help, annotation, advance_analysis, and compare_stage

Configuration files can be generated with:

spatialsnake produce-file --option=<analysis_option>

The generated YAML template can then be applied with --configfile. Parameters provided directly on the command line take priority over parameters defined in the YAML file.

Further Reading

Reference

Köster, J., Mölder, F., Jablonski, K. P., Letcher, B., Hall, M. B., Tomkins-Tinch, C. H., Sochat, V., Forster, J., Lee, S., Twardziok, S. O., Kanitz, A., Wilm, A., Holtgrewe, M., Rahmann, S., and Nahnsen, S. Sustainable data analysis with Snakemake. F1000Research, 10:33, 2021. https://doi.org/10.12688/f1000research.29032.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spatialsnake-0.0.2.tar.gz (250.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spatialsnake-0.0.2-py3-none-any.whl (287.5 kB view details)

Uploaded Python 3

File details

Details for the file spatialsnake-0.0.2.tar.gz.

File metadata

  • Download URL: spatialsnake-0.0.2.tar.gz
  • Upload date:
  • Size: 250.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for spatialsnake-0.0.2.tar.gz
Algorithm Hash digest
SHA256 50f7493303a91f4404397da2f5bf1525f99b5bef3f0b5e858c6a7819923e0cee
MD5 ac6bb36ae3ef14b3fb1223b5500d0fb4
BLAKE2b-256 3a05365d990a8427c2ce51897c3576bd8502534f9123a400405de7a6eeb2d9c1

See more details on using hashes here.

File details

Details for the file spatialsnake-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: spatialsnake-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 287.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for spatialsnake-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1459a2104c1cfc06861ff6de6ba139d593e2e04a66a82f79d5ddd3c3d63c2e42
MD5 fc7c244d803e5baec9ef011cc1017949
BLAKE2b-256 62765fc8177249fe8aa4bc15c3f0ce41d9b51b523134cf324b3c0a489fc6c0e8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.4

2 files

0.0.3

2 files

This release

0.0.2 This release

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page