Skip to main content

mantpy

Mantpy: extracellular-matrix analysis for spatial proteomics

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

  • 2026: Accepted poster presentation, ML4SpatialBio workshop at NeurIPS.
  • 2026: Flash talk, scverse conference.
  • 2025: Top Poster Award, British Society for Matrix Biology conference.

Mantpy overview (manuscript Fig. 1): 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

The current release is 1.2.0 (PyPI, GitHub release v1.2.0); the changelog lists what changed between releases.

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

System requirements

Tested on Windows 11 (Python 3.11) and Ubuntu (Python 3.11 and 3.14); no special hardware is needed. Dependency versions are listed in pyproject.toml. Installing takes about 3 minutes and the quick start below about 20 seconds on a desktop computer. Notebooks that run online in Google Colab are in the reproducibility repository.

Quick start

toy_ecm_roi synthesises a small region of interest in memory, so there is nothing to download. The example draws two figures: the joint cell-ECM graph and the neighbourhood clusters.

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:

Paper reproducibility

The paper reproducibility repository contains tutorials, full experiment notebooks and figure plotting code.

Public datasets

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

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

Contact

For questions, contact moeghaf@gmail.com or mohamed.ghafoor@postgrad.manchester.ac.uk. To report a bug, use the issue tracker.

Metadata

Release files for mantpy 1.2.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 mantpy 1.2.0
File Size Uploaded Provenance Actions
mantpy-1.2.0.tar.gz 1.1 MB With provenance Details for mantpy-1.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 1.4 MB

Release files / mantpy-1.2.0.tar.gz

Download URL mantpy-1.2.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
6b6f2507bee304ca8ecb51f8f7a10d8469b261c528bb61872f230ae950d2988f
BLAKE2b-256 checksum
How to use checksums
8ba13b7cf9e6fdd7d62787e80e617ecac56a0fbf489a25624c8a920bb790027f
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 Nov 9, 2026.

Transparency log

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

Download URL mantpy-1.2.0-py3-none-any.whl
Size 317.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
84f79beaf80f1994afdba513ca21c483113c78bc13e456979cffbbc7508c27cc
BLAKE2b-256 checksum
How to use checksums
0df55640a0d3957d43c16c7d00eee793f77a060478340ce04a1b8cd47ac8ec27
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 Nov 9, 2026.

Transparency log

Security for mantpy 1.2.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.

Full provenance

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

Select from 2 files

Attestation for mantpy-1.2.0.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 Nov 9, 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