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
pip install -e .
Python 3.8+ is recommended. Dependencies are installed automatically from setup.py.
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
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 alguerre@pa.uc3m.es.
Project details
Release history Release notifications | RSS feed
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 maldida-0.2.0.tar.gz.
File metadata
- Download URL: maldida-0.2.0.tar.gz
- Upload date:
- Size: 148.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6349c8571d6cc2aa30efbb170f2d675982e83af6d3bbd2a0ae1af590fc5ed6a6
|
|
| MD5 |
37f9f880c8cb9b6eb080d1e468c5f353
|
|
| BLAKE2b-256 |
965aa603979ae82f9933973d10b5632295e5aad0b5dfb55615f98a45c14bd997
|
File details
Details for the file maldida-0.2.0-py3-none-any.whl.
File metadata
- Download URL: maldida-0.2.0-py3-none-any.whl
- Upload date:
- Size: 163.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e1c72aca6824e506a1c4e93a251a828f3a568c4129dc967533028f1d5194124
|
|
| MD5 |
eddd9d535199b9b5fe11c542cd414b06
|
|
| BLAKE2b-256 |
1837f1bd0c78615fe94a679c00fe3d14107ca9fa63d0b72b6a4ea88fdd78ee3f
|