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.1.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.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: maldiamrkit-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 efbed91fec7fd3364f216fe732037749b7c3dead49d0f6785160ec2b82dec3ed
MD5 7e5d2dc9322c6dbe196f81c1a77b89a3
BLAKE2b-256 6c1c8adcfaf4a70f569f370f1dd1854dd1e93435a96dcc53db90d7702901987f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: maldiamrkit-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c214687e61adf7f76eeefa5c7f57ef09224ff0e3706796f51be111542e499cd
MD5 a461cf29dc9ce9c48f3ba396392e0cd3
BLAKE2b-256 e66dcfa8076b72cb4fb43e7098ef4cd1c78af2bfc323bf5a94732361f91f4dfe

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