Skip to main content

MSIverse 0.1.0

MSIverse is a pure-Python port of the user-facing analysis, plotting, and interactive functions in SpaMTP 1.1.0.9000. Single-modality data use AnnData; aligned spatial metabolomics/transcriptomics use MuData.

The imzML reader and public-axis matrix construction are pure-Python ports of Cardinal 3.14.0, CardinalIO 1.10.0, and matter 2.14.0. There is no R/rpy2 runtime dependency.

Install

Run these commands from the project directory containing pyproject.toml.

python -m pip install -e .
python -m pip install -e '.[all]'
python -m pip install -e '.[ms1-id]'

Python 3.10–3.12 is supported. pyimzML is installed for imzML writing; Plotting/Notebook controls, METASPACE, Pillow, and pygoslin remain optional extras so importing the core analysis package stays lightweight.

Data conventions

  • adata.X: current analysis matrix.
  • adata.layers["counts"]: unnormalised intensity loaded from the source.
  • adata.var["mz"]: common m/z feature axis.
  • adata.obsm["spatial"]: x/y coordinates.
  • adata.obsm, adata.varm, and adata.obsp: reductions, loadings, and graphs.
  • adata.uns["msi"]: schema and input/spectrum modes.
  • adata.uns["read_imzml"], ["peak_align"], ["bin_spectra"]: input and common-axis records.
  • adata.uns["normalize"], ["pca"], ["spatial_pca"], etc.: functional records with params, provenance, outputs, optional resolved, and function-specific results.
  • adata.uns["mz_annotation"]: base candidates; ["annotation_evidence"]: candidates augmented with MS1-ID support. Evidence integration preserves the ["ms1_id"] run record.
  • mdata.mod["spm"] / mdata.mod["spt"]: metabolomic/transcriptomic modalities.

Object-transforming functions modify in place by default and accept copy=True when a separate object is required.

Named runs use key_added; readers select inputs explicitly (for example annotation_key="anno_hmdb"). Normalization stores a custom run in both uns[key_added] and layers[key_added]; PCA retains X_<key_added> and <key_added>_loadings. Existing defaults and explicit matrix/column arguments remain supported. Reusing a key replaces that run; unrelated operation keys are rejected. These records are named results, not an automatic history log.

Old objects remain readable through package adapters. To convert their metadata explicitly, use io.migrate_uns(adata, copy=True, drop_legacy=False). Add return_report=True to return (converted, report). Migration is atomic on conflicts and preserves unknown fields; it does not rewrite saved files. Direct notebook access to old paths must be updated to the new layout.

Modules

Module SpaMTP-derived capabilities
msiverse.io Cardinal-compatible imzML parsing/alignment/binning, table loading, and output
msiverse.preprocess normalization, TMM, subsetting, segmentation labels
msiverse.annotate SpaMTP indexed annotation, isotope/adduct-network scoring, MALDI rules, FMP10, and official MS1-ID integration
msiverse.analysis PCA, spatial KNN/GraphPCA, k-means, Cardinal-compatible unsupervised SSC, correlation and spatial variability
msiverse.differential deterministic pseudo-bulk and moderated differential analysis
msiverse.spatial coordinate mapping, precomputed/landmark affine and STalign LDDMM transforms, interactive alignment, ROI selection, images
msiverse.multiomics modality merging and weighted-nearest-neighbour integration
msiverse.pathway Fisher, regional, GESECA, pathway scoring, annotation statistics, pathway plots
msiverse.network pathway topology construction and interactive HTML rendering
msiverse.plotting spatial, spectrum, distribution, heatmap, density, and 3D plots
msiverse.metaspace GraphQL annotations, ion images, feature matrices, and AnnData loading
from msiverse import annotate, io, preprocess, analysis

adata = io.read_imzml("sample.imzML", as_="annData")
preprocess.normalize(adata, method="tic")
analysis.run_pca(adata, n_components=20)
result = annotate.annotate(adata, polarity="negative", ppm=5, maldi_matrix="9-AA")

from msiverse import plotting
figure = plotting.image_mz_plot(adata, mzs=[400.2], pixel=True)
interactive = plotting.density_map(adata, output_html="density.html")

To specify the spectrum representation explicitly, use spectrum_mode:

adata = io.read_imzml("sample.imzML", as_="annData", spectrum_mode="centroid")
# For profile spectra, use spectrum_mode="profile".

The default spectrum_mode="auto" uses file-level or spectrum-level declarations. For non-continuous data, only a detected centroid declaration selects peak alignment; profile or undeclared spectra use a regular axis with linear resampling. Explicit "centroid"/"profile" overrides the declaration for either output type. Continuous data still uses its existing shared m/z axis. parse_only=True returns the original declarations, even when an explicit mode is supplied.

For large processed imzML files, keep the binary arrays lazy and materialize only the pixels needed for an exploratory comparison. The reference m/z axis is still estimated from a uniform sample of the full acquisition.

arrays = io.read_imzml(
    "sample.imzML", memory=False, as_="arrays", spectrum_mode="centroid"
)
adata = io.convert_arrays_to_experiment(
    arrays, guess_max=1000, pixel_indices=range(min(1000, len(arrays)))
)

See MSIverse_User_Guide.md for usage and SPAMTP_PARITY.md for the complete SpaMTP API map.

Bundled data and licensing

The Python-native Parquet snapshots were converted from SpaMTP's bundled reference resources. They retain their upstream restrictions, including non-commercial/academic conditions for HMDB and KEGG-derived content. Review THIRD_PARTY_NOTICES.md before redistribution.

Metadata

Release files for msiverse 0.1.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 msiverse 0.1.0
File Size Uploaded Provenance Actions
msiverse-0.1.0.tar.gz 82.1 MB Without provenance Details for msiverse-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 164.1 MB

Release files / msiverse-0.1.0.tar.gz

Download URL msiverse-0.1.0.tar.gz
Size 82.1 MB
Tags Source
SHA-256 checksum
How to use checksums
c63ae8afa2b54e782238bb96e80def1cdb64e5ac0c82374bcd40259c4c1166cb
BLAKE2b-256 checksum
How to use checksums
f3d62eb49aa02d6bed58b364d08ea378ef5adfac3e6d0676892465cf5555ffc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Release files / msiverse-0.1.0-py3-none-any.whl

Download URL msiverse-0.1.0-py3-none-any.whl
Size 82.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
7bd2146a210f234a91dc498b09dcbef7d50762747f3ecf1c5b2e27f95cdf11a3
BLAKE2b-256 checksum
How to use checksums
4f97dbb26470a376f4f5c8f28697b422f30f05d03b3ac33d1d125af32af41b67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.20

Security for msiverse 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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