Skip to main content

spatialsnake logo

Spatialsnake workflow features

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.4.tar.gz (251.1 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.4-py3-none-any.whl (287.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spatialsnake-0.0.4.tar.gz
  • Upload date:
  • Size: 251.1 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.4.tar.gz
Algorithm Hash digest
SHA256 a78a6fd076b2bda11485fc4f36f94239347e7790d94e10a4d98c12ecd9d5e512
MD5 9fda8af757c25f2d9610723ef47ad6d9
BLAKE2b-256 888336a959a951775ba2bad6e4c591b132447fd8e7a620d701f9a9845e70aa3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spatialsnake-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 287.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e9b28e337c7d1d4f31b562c7293a7cee8bf689cf0a81c752efe6ada895433542
MD5 c3e0ace864edfb5dc42c0cf530af5fb8
BLAKE2b-256 9fc2b3f1c77f03f5b7ab24f157a029eed60da356b2d78d7a9e7cf5971cabd4a6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

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