Skip to main content

Toolkit to read and preprocess MALDI-TOF mass-spectra for AMR analyses.

Project description

MaldiAMRKit

MaldiAMRKit

Toolkit to read and preprocess MALDI-TOF mass-spectra for AMR analyses

🚀 Installation

pip install maldiamrkit

🏃 Quick Start

from maldiamrkit.spectrum import MaldiSpectrum
from maldiamrkit.dataset import MaldiSet
from maldiamrkit.peak_detector import MaldiPeakDetector

# Load and preprocess a single spectrum
spec = MaldiSpectrum("data/1s.txt").preprocess() # smoothing, baseline removal, normalisation
spec.bin(3) # [optional] bin width 3 Da
spec.plot(binned=True) # plot

# Build a dataset from a directory of spectra + metadata CSV
data = MaldiSet.from_directory(
  "data/", "data/metadata/metadata.csv",
  aggregate_by=dict(antibiotic="Drug"),
  bin_width=3
)
X, y = data.X, data.y["Drug"]

# Machine learning pipeline
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression

pipe = Pipeline([
    ("peaks", MaldiPeakDetector(binary=False, prominence=0.05)),
    ("scaler", StandardScaler()),
    ("clf", LogisticRegression(max_iter=500))
])
pipe.fit(X, y)

For further details please see the quick guide.

🤝 Contributing

Pull requests, bug reports, and feature ideas are welcome: feel free to open a PR!

📝 License

This project is licensed under the MIT License. See the LICENSE file for details.

🙏 Acknowledgements

This pipeline is based on the methodology described in the following publication and aims to facilitate the application of similar approaches on MALDI-TOF spectra for AMR prediction in a machine learning context:

Weis, C., Cuénod, A., Rieck, B., et al. (2022). Direct antimicrobial resistance prediction from clinical MALDI-TOF mass spectra using machine learning. Nature Medicine, 28, 164–174. https://doi.org/10.1038/s41591-021-01619-9

Please consider citing this work if you find MaldiAMRKit useful.

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

maldiamrkit-0.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

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

maldiamrkit-0.2.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file maldiamrkit-0.2.0.tar.gz.

File metadata

  • Download URL: maldiamrkit-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for maldiamrkit-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2000ea2bc39770180d19d0ca15541706fc0878bacdd9acb243fe6c586707b01f
MD5 2baf8450866e120dcf0db518b29d9d8b
BLAKE2b-256 99de3e74d993e3eaa8030eed79d3f4a8b01515eaf22caf1e0cfde981a2374bc1

See more details on using hashes here.

File details

Details for the file maldiamrkit-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: maldiamrkit-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for maldiamrkit-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b219d3e6b94347d49d1bbefab774c25be0a75f11b5af650eb7f4e6d605ac4cb
MD5 57e2a8bf96897ace01e769a520ae5773
BLAKE2b-256 5ca51f2b92abe4a284c3e82f3b72de8d544339c59d9d759e2ae2e9c72ec90f66

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