Skip to main content
Pre-release

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

mantpy

Mantpy: extracellular-matrix analysis for spatial proteomics

Tests Documentation

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

Installation

Mantpy requires Python 3.11 or newer. Install it from PyPI with:

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

For development from a source checkout, replace mantpy with . in those commands.

Quick start

import mantpy as mt

# Read multiplexed imaging and a cell table into AnnData.
adata = mt.io.read_imc("image.tiff", panel="panel.csv", cells="cells.csv")

# Normalise channels and segment the ECM into patch nodes.
mt.pp.normalize(adata)
mt.pp.extract_ecm_patches(
    adata,
    ecm_channel="Collagen",
    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="Macrophage")
mt.tl.neighbourhood_clustering(adata, n_clusters=4)

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

Public tutorial data

The complete inputs for each worked tutorial are available through one-line, checksummed loaders from the immutable Zenodo version record. Data are cached outside the package and reused offline:

intestine = mt.datasets.coliv_intestine()
lung = mt.datasets.balbc_pbs_lung()
liver = mt.datasets.schistosoma_ecm()
prostate = mt.datasets.prostate_he_visium()

AnnData and image containers

Mantpy stores the image-container payload in an H5AD-safe form. Convert that payload back to the object interface whenever you need direct image access:

image = mt.im.as_image_container(adata.uns["image_container"])
image.layers

The conversion accepts both a serialized mapping restored from H5AD and a live mt.im.ImageContainer created in memory.

Plot styling

Importing Mantpy does not change Matplotlib defaults. Apply the generic, export-friendly preset explicitly when desired:

mt.style.apply_publication_style()

Features

  • Graph-based ECM modelling with cell, ECM, and joint cell-ECM layers
  • Cell-ECM enrichment and interaction testing
  • Spatial neighbourhood clustering
  • Label-free spatial-domain discovery
  • Optional graph embeddings, node classification, and denoising
  • Native AnnData interoperability throughout the workflow

API overview

Module Selected public API
mt.io mt.io.read_imc(), mt.io.read_codex(), mt.io.read_ecm_image()
mt.im mt.im.ImageContainer, mt.im.as_image_container()
mt.pp mt.pp.normalize(), mt.pp.extract_ecm_patches(), mt.pp.preprocess_ecm()
mt.gr mt.gr.build_graph(), mt.gr.build_patch_graph(), mt.gr.to_pyg()
mt.tl mt.tl.interaction_test(), mt.tl.neighbourhood_clustering(), mt.tl.cell_ecm_enrichment(), mt.tl.select_n_domains()
mt.pl mt.pl.cell_graph(), mt.pl.ecm_graph(), mt.pl.cell_ecm_graph(), mt.pl.neighbourhood_clusters()
mt.nn mt.nn.GraphMAE, mt.nn.NodeClassifier, mt.nn.PatchEncoder
mt.datasets Verified one-line loaders for all public tutorial datasets
mt.fetch Public-source matrix annotations and example spatial data
mt.style mt.style.apply_publication_style()

The final worked tutorials are maintained in the Mantpy reproducibility repository. See the documentation and API documentation for complete signatures and examples.

Release notes

See the changelog.

Contact

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

Download files

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

Source Distribution

mantpy-0.2.0rc3.tar.gz (421.1 kB view details)

Uploaded Source

Built Distribution

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

mantpy-0.2.0rc3-py3-none-any.whl (264.5 kB view details)

Uploaded Python 3

File details

Details for the file mantpy-0.2.0rc3.tar.gz.

File metadata

  • Download URL: mantpy-0.2.0rc3.tar.gz
  • Upload date:
  • Size: 421.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for mantpy-0.2.0rc3.tar.gz
Algorithm Hash digest
SHA256 5ab278bb53af642f39e55113c4d0841f51806b67ec9fced0124c9fda711203a7
MD5 817830e923bc9fa0b99fdd76f212005f
BLAKE2b-256 653e8930227190d140bf1daac66ac19b76e720c617dffaaa4b96f352eda3162d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mantpy-0.2.0rc3.tar.gz:

Publisher: release.yaml on moeghaf/Mantpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mantpy-0.2.0rc3-py3-none-any.whl.

File metadata

  • Download URL: mantpy-0.2.0rc3-py3-none-any.whl
  • Upload date:
  • Size: 264.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for mantpy-0.2.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 7649ba408d7d31eadaa4efc8821e314014e2f11a66d36dcdc6af6973fdbc90ac
MD5 1e6d719510627c710bcb06af36bf583f
BLAKE2b-256 b7a19e8a13d17d6525ba7530431777bc34cb35ba618632c24d39afa7d548c81c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mantpy-0.2.0rc3-py3-none-any.whl:

Publisher: release.yaml on moeghaf/Mantpy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.0.1

2 files

0.2.0

2 files

This release

0.2.0rc3 This release

2 files

Supported by

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