Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

DOI Ask DeepWiki

InSituPy: A framework for histology-guided, multi-sample analysis of single-cell spatial transcriptomics data

InSituPy is a Python package designed to facilitate the analysis of single-cell spatial transcriptomics data. With InSituPy, you can easily load, visualize, and analyze the data, enabling and simplifying the comprehensive exploration of spatial gene expression patterns within tissue sections and across multiple samples. Currently the analysis is focused on data from the Xenium In Situ methodology but a broader range of reading functions will be implemented in the future.

Latest changes

!!!Warning: This repository is under very active development and it cannot be ruled out that changes might impair backwards compatibility. If you observe any such thing, please feel free to contact us to solve the problem. Thanks!

For the latest developments check out the releases.

Getting started

Overall data structure

A key feature of InSituPy is its hierarchical data structure, centered around the InSituExperiment and InSituData objects:

  • InSituData: Represents and manages at the individual sample level. It integrates all modalities of spatial omics datasets, including cellular readouts, cellular boundaries, images, transcripts, regions, and annotations.
  • InSituExperiment: Aggregates multiple InSituData instances and links them with associated metadata, enabling cross-sample analysis and organization.

AI Assistant Integration (MCP Server)

InSituPy ships an MCP server that gives AI assistants live access to the API, source code, and workflow examples. Supported clients include Claude Desktop, Claude Code, Cursor, Windsurf, Continue.dev, and Cline.

The easiest way to activate the server in Claude Desktop is to add the following to your claude_desktop_config.json — no separate installation or repository clone required:

{
  "mcpServers": {
    "insitupy": {
      "command": "uvx",
      "args": ["--python", "3.12", "--from", "insitupy-spatial[mcp]", "insitupy-mcp"]
    }
  }
}

uvx (part of uv) handles downloading and running the server automatically in an isolated environment. Install uv first if you haven't already (curl -LsSf https://astral.sh/uv/install.sh | sh on macOS/Linux, or see installation options).

See MCP_TUTORIAL.md for step-by-step setup instructions for all supported clients.

Documentation

For detailed instructions on using InSituPy, refer to the official documentation.

InSituPy works best within Jupyter Lab or Jupyter Notebook sessions. If you are not familiar with these platforms, see the documentation of Project Jupyter.

Installation

Make sure you have Conda installed on your system before proceeding with these steps. If not, you can install Miniconda or Anaconda from https://docs.conda.io/en/latest/miniconda.html.

Create and activate a conda environment:

When using InSituPy with SpatialData, python version 3.13 is mandatory. Otherwise all python version >=3.12 should work.

conda create --name insitupy python=3.13
conda activate insitupy

Install from PyPi:

pip install insitupy-spatial

This base installation includes napari and related visualization dependencies.

InSituPy currently requires zarr>=3.0.0 and targets the zarr v3 format. Legacy zarr v2 workflows are only partially supported and not tested.

Optional: install with SpatialData support (spatialdata>=0.7.2):

pip install insitupy-spatial[spatialdata]

To ensure that the InSituPy package is available as a kernel in Jupyter notebooks within your conda environment, you can follow the instructions here.

For alternative installation strategies see the documentation.

Features

  • Data storage: Store data on both the single sample level and the multi-sample level using the InSituData and InSituExperiment objects.
  • Data Preprocessing: InSituPy provides functions for normalizing, filtering, and transforming raw in situ transcriptomics data.
  • Interactive Visualization: Create interactive plots using napari to easily explore spatial gene expression patterns.
  • Annotation: Annotate Xenium In Situ data in the napari viewer or import annotations from external tools like QuPath.
  • Multi-sample analysis: Perform analysis on an experiment-level, i.e. with multiple samples at once.

QuPath

We try to develop InSituPy alongside the Bioimage Analysis tool QuPath. QuPath has great functionalities to visualize whole slide image data, add annotations, generate segmentations or analyze signal intensities. Scripts to simplify the connection between QuPath and InSituPy, we collect here. This includes:

  • Export of annotations as GEOJSON from QuPath
  • Export of images as OME-TIFF from QuPath
  • Collected export of data from a multiplexed IF image to be imported into InSituPy. Import can be performed using either read_qupath or read_qupath_project. For cell and nucleus segmentation of multiplexed IF images we recommend using Instanseg.

Contributing

Contributions are welcome! If you find any issues or have suggestions for new features, please open an issue, submit a pull request or contact us via our zulip chat.

Citation

If you use InSituPy in your work, please cite the preprint as follows:

InSituPy – A Framework for Histology-Guided, Multi-Sample Analysis of Single-Cell Spatial Transcriptomics Data.
Wirth, Johannes, Anna Chernysheva, Birthe Lemke, Isabel Giray, Aitana Egea Lavandera, and Katja Steiger.
bioRxiv, March 12, 2025. https://doi.org/10.1101/2025.03.07.641860.

License

InSituPy is licensed under the BSD-3-Clause.


InSituPy is developed and maintained by Johannes Wirth and Anna Chernysheva. Feedback is highly appreciated and hopefully InSituPy helps you with your analysis of spatial transcriptomics data. The package is thought to be a starting point to simplify the analysis of in situ sequencing data in Python and it would be exciting to integrate functionalities for larger and more comprehensive data structures. Currently, the framework focuses on the analysis of Xenium In Situ data but it is planned to integrate more methodologies and any support on this is highly welcomed.

Metadata

Release files for insitupy-spatial 0.12.0b6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for insitupy-spatial 0.12.0b6
File Size Uploaded
insitupy_spatial-0.12.0b6.tar.gz 422.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for insitupy-spatial 0.12.0b6
File Interpreter ABI Platform
insitupy_spatial-0.12.0b6-py3-none-any.whl Python 3 none any Details

Total release size: 900.5 kB

Release files / insitupy_spatial-0.12.0b6.tar.gz

Download URL insitupy_spatial-0.12.0b6.tar.gz
Size 422.0 kB
Tags Source
SHA-256 checksum
How to use checksums
22e6d3acd8762aa00974b59d8ebc1e0ce2e216b2498a6e9f992e0e8cb71352a3
BLAKE2b-256 checksum
How to use checksums
de0c758492791572019f2fe2cc93b6c52bf58add3dc0104c422fc85348d8591b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.14 Linux/6.17.0-1018-azure

Release files / insitupy_spatial-0.12.0b6-py3-none-any.whl

Download URL insitupy_spatial-0.12.0b6-py3-none-any.whl
Size 478.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cefa1d38f5fdad574414ddb984dcce083e22a6826a3a0402274ba04a812179f
BLAKE2b-256 checksum
How to use checksums
b7121fec223b2f5abb0e2f974db28b7d2d12de7e19c878ad7526e877af3276b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.14 Linux/6.17.0-1018-azure

Release history Release notifications | RSS feed

This release

0.12.0b6 This release

2 release files

0.11.5

2 release files

0.11.4

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.9

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release 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