Skip to main content

mantpy

Mantpy: extracellular-matrix analysis for spatial proteomics

Tests Documentation Preprint

Mantpy is a scverse-based framework for graph analysis of the extracellular matrix (ECM) in spatial proteomics. It represents cells and ECM patches as distinct, linked node types, so matrix structure can be analysed on its own or together with cellular context. Mantpy works with AnnData and interoperates with Scanpy, Squidpy, and other single-cell and spatial tools.

Mantpy overview: input, graph construction, applications and interoperability

Installation

Mantpy requires Python 3.11 or newer. CPU workflows run on Windows, Linux and macOS. GPU training additionally requires a compatible PyTorch installation; the package does not require a GPU for graph construction or descriptive analysis.

pip install mantpy

Optional extras add heavier dependencies only when needed:

pip install "mantpy[gnn]"      # graph learning and explainability
pip install "mantpy[patch]"    # learned image-patch features
pip install "mantpy[spatial]"  # SpatialData integration
pip install "mantpy[segment]"  # Cellpose segmentation

Quick start

toy_ecm_roi synthesises a small region of interest in memory, so there is nothing to download:

import mantpy as mt

# A small synthetic ROI: image stack, channel panel, cell table.
roi = mt.datasets.toy_ecm_roi()

# Read multiplexed imaging and a cell table into AnnData.
adata = mt.io.read_imc(
    roi.image, panel=roi.panel, cells=roi.cells,
    sample_id="toy", condition="ctrl",
)

# Normalise channels and segment the ECM into patch nodes.
mt.pp.normalize(adata)
mt.pp.extract_ecm_patches(
    adata,
    roi.image,
    ecm_channel="ColIV",
    ecm_K="auto",
    features=["mean"],
)

# Build cell, ECM, and joint cell-ECM graph layers.
mt.gr.build_graph(adata, mode="cell")
mt.gr.build_graph(adata, mode="ecm")
mt.gr.build_graph(adata, mode="cell_ecm")

# Quantify spatial organisation.
mt.tl.cell_ecm_enrichment(adata, cell_type="B")
mt.tl.neighbourhood_clustering(adata, n_clusters=4)

# Visualise results.
mt.pl.cell_ecm_graph(adata)
mt.pl.neighbourhood_clusters(adata)

Point mt.io.read_imc at your own files to run the same pipeline on real data:

adata = mt.io.read_imc("image.tiff", panel="panel.csv", cells="cells.csv")

The toy ROI is synthetic — its clusters and statistics describe the generator, not biology. Use it to learn the API, then move to real data.

Tutorials

Step-by-step guides, each executed when the documentation is built:

The full analyses behind the preprint use real cohorts in the reproducibility repository. Follow its pinned review-candidate installation and input instructions; the current paper notebooks have been checked on Windows CPU, with Colab execution still unvalidated.

Public datasets

One-line, checksummed loaders for every tutorial dataset, cached outside the package and reused offline:

intestine = mt.datasets.coliv_intestine()   #  93 MB
lung = mt.datasets.balbc_pbs_lung()         #  71 MB
liver = mt.datasets.schistosoma_ecm()       #  38 MB

Loaders return a Bunch with the files, images, metadata and provenance available for that dataset. The synthetic single-ROI example and the real cohorts have different contents; see the dataset documentation and paper notebooks for the appropriate workflow. The bundles are frozen under CC BY 4.0 in an immutable Zenodo record.

The liver archive's historical_best_k describes its older analysis metadata. The current paper notebooks use their documented frozen K=6 partition; the loader does not recommend or fit a cluster count.

Documentation

Documentation · API reference · Changelog

Citation

If you use Mantpy, please cite the preprint:

Ghafoor M, Parkinson JE, Pham T, Georgaka S, Haley MJ, Jokl E, Piper Hanley K, Allen JE, Sutherland TE, Rattray M. Mantpy: a framework for extracellular matrix analysis in spatial proteomics. bioRxiv (2026). doi: 10.1101/2025.06.04.657781

Machine-readable citation metadata is in CITATION.cff (GitHub's "Cite this repository" button). The tutorial datasets have their own Zenodo DOI.

Contact

For questions and help requests, use the scverse discourse. To report a bug, use the issue tracker.

Metadata

Release files for mantpy 1.0.2

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

Source distribution (sdist)

Source distribution for mantpy 1.0.2
File Size Uploaded Provenance Actions
mantpy-1.0.2.tar.gz 1.7 MB With provenance Details for mantpy-1.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 1.9 MB

Release files / mantpy-1.0.2.tar.gz

Download URL mantpy-1.0.2.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
bb4f1b4bb9a6ac767da1f07b566ccc7e300b47b37ee1d0585cc55ce13ce736c8
BLAKE2b-256 checksum
How to use checksums
bdc38bd7792be9331b3300a431ba9b3c2b9b8a8267995182e27db9cdb2c38613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Release files / mantpy-1.0.2-py3-none-any.whl

Download URL mantpy-1.0.2-py3-none-any.whl
Size 266.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a5fe5cea5fc54b9134251d60d5e3bc1d79badca8207fb425ec3c018edde39f43
BLAKE2b-256 checksum
How to use checksums
7b0b7cadcc88a98b27835a45edad2ce6581090a6d2281ed44805e8a74f4fdd44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

Security for mantpy 1.0.2

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mantpy-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 27, 2026.

Transparency log

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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