This release is a pre-release and may not be stable for production use.
Mantpy: extracellular-matrix analysis for spatial proteomics
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
AnnDatainteroperability 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ab278bb53af642f39e55113c4d0841f51806b67ec9fced0124c9fda711203a7
|
|
| MD5 |
817830e923bc9fa0b99fdd76f212005f
|
|
| BLAKE2b-256 |
653e8930227190d140bf1daac66ac19b76e720c617dffaaa4b96f352eda3162d
|
Provenance
The following attestation bundles were made for mantpy-0.2.0rc3.tar.gz:
Publisher:
release.yaml on moeghaf/Mantpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mantpy-0.2.0rc3.tar.gz -
Subject digest:
5ab278bb53af642f39e55113c4d0841f51806b67ec9fced0124c9fda711203a7 - Sigstore transparency entry: 2249857650
- Sigstore integration time:
-
Permalink:
moeghaf/Mantpy@ec06f6aab062206e41bd0dc33fa4557a45401ddb -
Branch / Tag:
refs/tags/v0.2.0rc3 - Owner: https://github.com/moeghaf
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ec06f6aab062206e41bd0dc33fa4557a45401ddb -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7649ba408d7d31eadaa4efc8821e314014e2f11a66d36dcdc6af6973fdbc90ac
|
|
| MD5 |
1e6d719510627c710bcb06af36bf583f
|
|
| BLAKE2b-256 |
b7a19e8a13d17d6525ba7530431777bc34cb35ba618632c24d39afa7d548c81c
|
Provenance
The following attestation bundles were made for mantpy-0.2.0rc3-py3-none-any.whl:
Publisher:
release.yaml on moeghaf/Mantpy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mantpy-0.2.0rc3-py3-none-any.whl -
Subject digest:
7649ba408d7d31eadaa4efc8821e314014e2f11a66d36dcdc6af6973fdbc90ac - Sigstore transparency entry: 2249857966
- Sigstore integration time:
-
Permalink:
moeghaf/Mantpy@ec06f6aab062206e41bd0dc33fa4557a45401ddb -
Branch / Tag:
refs/tags/v0.2.0rc3 - Owner: https://github.com/moeghaf
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ec06f6aab062206e41bd0dc33fa4557a45401ddb -
Trigger Event:
release
-
Statement type: