Skip to main content

Preprocessing and augmentation utilities for MALDI-TOF spectra.

Project description

MALDIDA

MALDIDA provides lightweight preprocessing and augmentation utilities for MALDI-TOF spectra. It includes a simple dataset reader, common preprocessing steps, augmentation helpers, and two bundled MARISMA samples so you can try the pipeline without additional data.

Features

  • Spectrum loader (SpectrumObject) with Bruker (acqu/fid) and TSV readers
  • Composable preprocessing (variance stabilisation, smoothing, baseline correction, trimming, binning, normalisation, noise filters)
  • Data augmentation helpers to simulate experimental variability
  • Dataset parser with optional HDF5 persistence
  • Bundled MARISMA samples plus ready-to-run example and tests

Installation

From PyPI:

pip install maldida

From source (editable):

pip install -e .

Python 3.8+ is recommended. Dependencies install automatically.

Quickstart with the bundled MARISMA samples

from MALDIDA import (
    BaselineCorrecter,
    Binner,
    DataAugmenter,
    MaldiDataset,
    Normalizer,
    SequentialPreprocessor,
    SpectrumObject,
    Smoother,
    Trimmer,
    VarStabilizer,
    get_sample_data_path,
)

# Locate the two MARISMA example spectra shipped with the package
sample_root = get_sample_data_path()

preprocess_pipeline = SequentialPreprocessor(
    VarStabilizer(method="sqrt"),
    Smoother(halfwindow=5),
    BaselineCorrecter(method="SNIP", snip_n_iter=5),
    Normalizer(sum=1.0),
    Trimmer(min=2000, max=20000),
    Binner(step=3),
)

dataset = MaldiDataset(sample_root, preprocess_pipeline=preprocess_pipeline, n_samples=2)
dataset.parse_dataset()
print(f"Loaded {len(dataset)} spectra")

# Grab the first processed spectrum and augment it
first = dataset.get_data()[0]["spectrum"]
augmenter = DataAugmenter(random_state=0)
augmented = augmenter.proportional_shifting(
    SpectrumObject(mz=first.mz.copy(), intensity=first.intensity.copy()), p0=0.3
)
print(f"Original peaks: {len(first)}, Augmented peaks: {len(augmented)}")

Build spectra manually

You can also construct a spectrum directly:

import numpy as np
from MALDIDA import SpectrumObject, SequentialPreprocessor, Binner, Normalizer

toy = SpectrumObject(
    mz=np.array([100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]),
    intensity=np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100]),
)

pipeline = SequentialPreprocessor(
    Normalizer(sum=1.0),
    Binner(step=50),
)
processed = pipeline(toy)

Examples and tests

  • Run the ready-to-use MARISMA example:
    python examples/marisma_example.py
    
  • Execute the tests (requires pytest):
    pip install pytest
    pytest
    

Citation

If you use MALDIDA in academic work, please cite:
https://www.biorxiv.org/content/10.1101/2024.10.29.620907v3

License

Licensed under the GNU Lesser General Public License v3.0 or later (see LICENSE).

Contact

For feedback or questions, open an issue or reach out at aguerrero@imm.uzh.ch.

Project details


Download files

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

Source Distribution

maldida-0.2.1.tar.gz (148.7 kB view details)

Uploaded Source

Built Distribution

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

maldida-0.2.1-py3-none-any.whl (163.8 kB view details)

Uploaded Python 3

File details

Details for the file maldida-0.2.1.tar.gz.

File metadata

  • Download URL: maldida-0.2.1.tar.gz
  • Upload date:
  • Size: 148.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for maldida-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3fd75e5db27dcf5be73898f84c1285bc6d3acf1b2a3215b05b2d299cdc33332d
MD5 aabb66ef17df0c45773abfca7b7f0dd8
BLAKE2b-256 5592b7361d30e689f7e81ebb5d641f7026be46710947ad42a97a1dad864a8ba9

See more details on using hashes here.

File details

Details for the file maldida-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: maldida-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 163.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for maldida-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ea928c62205b9d9b53d6dbb49f53ee92de46460020a715fe015fa3c8fbc540e
MD5 e38511efd22198f1d2b745f5d41d345f
BLAKE2b-256 0f3f37f46373160d6024eb2efeceae495377b54d48611263ef100520323bb184

See more details on using hashes here.

Supported by

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