PHD-MS: Persistent Homology for Domains at Multiple Scales
Multiscale domain identification for spatial transcriptomic data.
PHD-MS clusters a tissue at several resolutions, links overlapping clusters across resolutions into a cluster graph, and uses 0-dimensional persistent homology on that graph to find multiscale domains: groups of clusters that stay together over a wide range of overlap thresholds. Each domain comes with a persistence (how robust it is) and a per-spot coreness score.
Installation
pip install phd_ms
Or from source, in this directory:
pip install .
Quick start
We assume a spatially aware embedding (e.g. from GraphST) is stored in adata.obsm.
import numpy as np
import scanpy as sc
import phd_ms
adata = sc.read_h5ad('adata_151673.h5ad')
# 1. Leiden clusterings at several resolutions (returns keys, coarse to fine)
keys = phd_ms.pp.leiden(adata, resolutions=np.linspace(0.15, 0.95, 8), use_rep='X_gst')
# 2. Multiscale domains -> adata.obsm['multiscale'], adata.uns['multiscale']
domains = phd_ms.tl.multiscale(adata, keys, index='containment')
# 3. Plots
phd_ms.pl.persistence_diagram(domains)
phd_ms.pl.domains(adata, indices=range(10)) # the 10 most persistent domains
phd_ms.pl.heterogeneity(adata)
Other useful entry points:
phd_ms.tl.assign_domains(adata, [0, 2, 5]) |
hard clustering from selected domains |
phd_ms.bm.benchmark(adata.obs['cluster'], domains, adata.obsm['spatial']) |
Wasserstein / NMI against a ground truth |
phd_ms.interactive.point_click(adata) |
click a spot to see the domains containing it |
phd_ms.core.ClusterGraph.from_labelings([...]) |
build the cluster graph from any clusterings (NumPy only) |
Or run point_and_click.py (set DATA to your file first) for the clickable interface.
Notebook tutorials are in the examples folder: mouse_brain_v2.ipynb (finding multiscale
domains) and visium_benchmark_v2.ipynb (benchmarking against annotated DLPFC layers).
The 1.x notebooks, with their original outputs, are in examples/v1.
How coreness is defined
Every cluster r founds a domain that lives from its birth until it merges into an older domain (its death). A spot enters the domain at the first overlap threshold at which one of its clusters has joined r's component. Its coreness is the fraction of the domain's lifetime during which it belongs:
coreness = (death - entry) / (death - birth), and 0 if the spot never enters.
Upgrading from 1.x
The 1.x functions (phd_ms.tl.preprocess_leiden, cluster_filtration,
map_multiscale, ...) still work but emit a DeprecationWarning; see
CHANGELOG.md for the new equivalents. Coreness values differ
from 1.x (see the changelog).
Metadata
Release files for phd-ms 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phd_ms-2.0.0.tar.gz | 26.0 kB | Without provenance | Details for phd_ms-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phd_ms-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for phd_ms-2.0.0-py3-none-any.whl |
Total release size: 49.7 kB
Release files / phd_ms-2.0.0.tar.gz
| Download URL | phd_ms-2.0.0.tar.gz |
|---|---|
| Size | 26.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fa108b0b8e764bcc2b567ed6f478a61734876e6d3cc49acc2651b8e5580050e
|
|
BLAKE2b-256 checksum How to use checksums |
d9b917d38e1e887ed1735bed46f10c0475f232d402dc5014be91a34d036b343f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / phd_ms-2.0.0-py3-none-any.whl
| Download URL | phd_ms-2.0.0-py3-none-any.whl |
|---|---|
| Size | 23.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03b56540204602e20594e4d46d89f41a46cc2a49b534a34b70a68d922dfe022f
|
|
BLAKE2b-256 checksum How to use checksums |
8c8984564fb80755a0c07ae10b9972c0e32c3b9a0d2b89518049c5cff2c40d3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for phd-ms 2.0.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.