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

# 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.

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.1.0.tar.gz (8.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.1.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for maldiamrkit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79896c5bb76e22083b6b48cc9afadb2c9b9f9baa2b10df4e9b5a3a814ac6bef8
MD5 5d230939fba5a3013cd1bee47aad43ed
BLAKE2b-256 8bc4436236b5ed3e5ed46a4a8245899a99008f30e800449c8a7cd8962c695eab

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for maldiamrkit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b27ca77c7036d2994e4ed018c522a7a1bfe2ff71861c04fd8855116285dc7ca
MD5 6d13e72d498bbae3d0b8cb20aa1adc73
BLAKE2b-256 c823b7c5ec47452205922806d5c316b4d9152c429084076a0baa1d53b181e4ee

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