Skip to main content

PyPI

stimwrap - a python interface for STIM

stimwrap is a Python wrapper for the spatial transcriptomics library STIM. It provides an interface for running STIM commands from python, as well as for extracting datasets and their attributes from n5 containers (backed by n5 or AnnData) that are created by STIM.

stimwrap is created and maintained by Nikos Karaiskos and Daniel León-Periñán.

Quick start

We provide an example notebook under notebooks/openst_example.ipynb, and also a Google Colab notebook

These will walk you through downloading Open-ST data, running STIM in a Python notebook (via stimwrap bindings), and seamlessly running some downstream analyses.

We provide another notebook under notebooks/visium_example.ipynb, and also a 2nd Google Colab notebook showcasing the 10x Visium adult mouse brain dataset showcased in all our tutorials.

Installation

To install the stimwrap try:

pip install stimwrap

or if you do not have sudo rights:

pip install --user stimwrap

Check if the library is successfully installed:

python -c import stimwrap as sw

If installation fails due to conflicting dependencies, create a dedicated environment with python>=3.9 and try again to install stimwrap as above.

Usage

The following assumes that the file container.n5 contains the datasets and their attributes as created by STIM:

import stimwrap as sw
pucks = sw.Container('/path/to/container.n5')

Print the names of the datasets:

print(pucks.get_dataset_names())

Focus on a specific puck and extract the relevant information:

puck_name = pucks.get_dataset_names()[0]
puck = pucks.get_dataset(puck_name)

Get the puck locations either directly from the puck:

locations = puck['locations']

or fetch them from the container:

locations = pucks.get_dataset(puck_name)['locations']

The examples above assume that the dataset is N5-backed. For AnnData-backed datasets, the key for the puck locations might be:

locations = pucks.get_dataset(puck_name)['spatial']

which will try to access the obsm/spatial variable from the dataset. Alternatively, we recommend using the official AnnData package for handling these files.

Fetch gene expression

It is possible to get the expression vector of a single gene:

hpca_vec = pucks.get_dataset(puck_name).get_gene_expression(gene='Hpca')

or the whole gene expression matrix:

dge = pucks.get_dataset(puck_name).get_gene_expression()

Fetch dataset attributes

STIM stores the dataset attributes in the n5 container. These can be directly accessed with stimwrap:

puck.get_attribute(attribute='geneList')

In N5-backed STIM, available options might also include: barcodeList and metadataList.

Fetch aligned locations

In the case where multiple consecutive sections are obtained and aligned with STIM, the aligned locations can be obtained with:

aligned_locations = puck.get_aligned_locations(transformation='model_sift')

Store aligned locations

The aligned locations can be stored in the N5 or AnnData-backed object, for seamless downstream analysis:

aligned_locations = puck.apply_save_transform(transformation='model_sift')

Metadata

Release files for stimwrap 0.3.0

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

Source distribution (sdist)

Source distribution for stimwrap 0.3.0
File Size Uploaded Provenance
stimwrap-0.3.0.tar.gz 14.4 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for stimwrap 0.3.0
File Interpreter ABI Platform
stimwrap-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / stimwrap-0.3.0.tar.gz

Download URL stimwrap-0.3.0.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6c79241966e7df8784b54f7dce5cf7dca1849c160ad9911a9707568976e7f422
BLAKE2b-256 checksum
How to use checksums
bdbe0a6514a615751f1d5256db1beb6a45ebdeb1506808cdf6497f31c1e924ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.10

Release files / stimwrap-0.3.0-py3-none-any.whl

Download URL stimwrap-0.3.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af3ff4efa0d71a97067fdafaaf8bab487fc5ad0f9ab6216c1911cf254beff891
BLAKE2b-256 checksum
How to use checksums
f8ae2250c89e82564cb4c5af0042f4933353e38e99ea9711de347d3f1d34f28a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.10

Security for stimwrap 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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