Metadata-Version: 2.4
Name: mantpy
Version: 0.2.0rc3
Summary: A framework for extracellular matrix analysis in spatial proteomics
Project-URL: Documentation, https://mantpy.readthedocs.io/
Project-URL: Homepage, https://github.com/moeghaf/Mantpy
Project-URL: Issues, https://github.com/moeghaf/Mantpy/issues
Project-URL: Source, https://github.com/moeghaf/Mantpy
Author: Mohamed Ghafoor
Maintainer-email: Mohamed Ghafoor <moeghaf@gmail.com>
License: MIT License
        
        Copyright (c) 2026, Mohamed Ghafoor
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: AnnData,extracellular matrix,graph,scverse,spatial proteomics
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.11
Requires-Dist: anndata>=0.12
Requires-Dist: dask[array]>=2024.10
Requires-Dist: igraph>=0.10
Requires-Dist: joblib>=1.3
Requires-Dist: leidenalg>=0.10
Requires-Dist: matplotlib>=3.8
Requires-Dist: networkx>=3.2
Requires-Dist: numpy>=1.24
Requires-Dist: pandas>=2.1
Requires-Dist: pillow>=10
Requires-Dist: pooch>=1.8
Requires-Dist: requests>=2.28
Requires-Dist: scanpy<1.13,>=1.10
Requires-Dist: scikit-image>=0.21
Requires-Dist: scikit-learn>=1.4
Requires-Dist: scipy>=1.11
Requires-Dist: seaborn>=0.13
Requires-Dist: squidpy>=1.8.2
Requires-Dist: tifffile[zarr]<2026.4.11,>=2025.5.21; python_version < '3.12'
Requires-Dist: tifffile[zarr]>=2026.5.2; python_version >= '3.12'
Requires-Dist: tqdm>=4.66
Requires-Dist: zarr<3.2,>=3.1; python_version < '3.12'
Provides-Extra: gnn
Requires-Dist: captum>=0.7; extra == 'gnn'
Requires-Dist: torch-geometric>=2.5; extra == 'gnn'
Requires-Dist: torch>=2.3; extra == 'gnn'
Provides-Extra: patch
Requires-Dist: pytorch-lightning>=2.2; extra == 'patch'
Requires-Dist: torch>=2.3; extra == 'patch'
Provides-Extra: segment
Requires-Dist: cellpose>=4; extra == 'segment'
Provides-Extra: spatial
Requires-Dist: spatialdata>=0.1; extra == 'spatial'
Provides-Extra: topology
Requires-Dist: gudhi>=3.13; extra == 'topology'
Description-Content-Type: text/markdown

<p align="center">
  <img src="docs/_static/mantpy_logo.png" alt="mantpy" width="320"/>
</p>

# Mantpy: extracellular-matrix analysis for spatial proteomics

[![Tests][badge-tests]][tests]
[![Documentation][badge-docs]][documentation]

[badge-tests]: https://img.shields.io/github/actions/workflow/status/moeghaf/Mantpy/test.yaml?branch=main
[badge-docs]: https://img.shields.io/readthedocs/mantpy

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:

```bash
pip install mantpy
```

Optional extras add heavier dependencies only when needed:

```bash
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

```python
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](https://doi.org/10.5281/zenodo.21538382). Data are
cached outside the package and reused offline:

```python
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:

```python
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:

```python
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][tutorials]. 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][].

[scverse discourse]: https://discourse.scverse.org/
[tutorials]: https://github.com/moeghaf/mantpy_reproducibility
[issue tracker]: https://github.com/moeghaf/Mantpy/issues
[tests]: https://github.com/moeghaf/Mantpy/actions/workflows/test.yaml
[documentation]: https://mantpy.readthedocs.io
[changelog]: https://mantpy.readthedocs.io/en/latest/changelog.html
[api documentation]: https://mantpy.readthedocs.io/en/latest/api.html
