Skip to main content

Package introducing the InSituPy framework to analyze single-cell spatial transcriptomics data.

Project description

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.

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.10 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.

Project details


Download files

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

Source Distribution

insitupy_spatial-0.11.2.tar.gz (300.2 kB view details)

Uploaded Source

Built Distribution

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

insitupy_spatial-0.11.2-py3-none-any.whl (346.9 kB view details)

Uploaded Python 3

File details

Details for the file insitupy_spatial-0.11.2.tar.gz.

File metadata

  • Download URL: insitupy_spatial-0.11.2.tar.gz
  • Upload date:
  • Size: 300.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.13.12 Linux/6.17.0-1008-azure

File hashes

Hashes for insitupy_spatial-0.11.2.tar.gz
Algorithm Hash digest
SHA256 833d3a1b141a50ebcb62dd336533fb850be69022f6b34c6c5642d8863a5b556a
MD5 ce49a6dac1a937d3283d73d743ee5242
BLAKE2b-256 0dd71f1cd049906f44d7e95ded9b6cd5fd134c31c74368158b5003a52d2b856d

See more details on using hashes here.

File details

Details for the file insitupy_spatial-0.11.2-py3-none-any.whl.

File metadata

  • Download URL: insitupy_spatial-0.11.2-py3-none-any.whl
  • Upload date:
  • Size: 346.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.3 CPython/3.13.12 Linux/6.17.0-1008-azure

File hashes

Hashes for insitupy_spatial-0.11.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6ffe965929f2e64e417468e863c852490424f39160d288527a15ceed8eea2aa7
MD5 b485435876dd9758db225b30531db860
BLAKE2b-256 7cb1375ad200bddc748ecd2117e0edc65aa478216e86cf87e4b6aacdb6f58086

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page