Metadata-Version: 2.4
Name: MaldiAMRKit
Version: 0.1.0
Summary: Toolkit to read and preprocess MALDI-TOF mass-spectra for AMR analyses.
Author-email: Ettore Rocchi <ettoreroc@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/EttoreRocchi/MaldiAMRKit
Project-URL: Documentation, https://github.com/EttoreRocchi/MaldiAMRKit#readme
Project-URL: Source, https://github.com/EttoreRocchi/MaldiAMRKit
Project-URL: Issues, https://github.com/EttoreRocchi/MaldiAMRKit/issues
Keywords: MALDI,mass-spectrometry,machine-learning,scikit-learn
Classifier: Development Status :: 3 - Alpha
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Chemistry
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: scipy
Requires-Dist: scikit-learn
Requires-Dist: pybaselines
Requires-Dist: matplotlib
Requires-Dist: seaborn
Dynamic: license-file

# MaldiAMRKit

<p align="center">
  <img src="docs/maldiamrkit.png" alt="MaldiAMRKit" width="250"/>
</p>
<p align="center">
  <strong>Toolkit to read and preprocess MALDI-TOF mass-spectra for AMR analyses</strong>
</p>

## 🚀 Installation

```bash
pip install maldiamrkit
```

## 🏃 Quick Start

```python
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](docs/quick_guide.ipynb).

## 🤝 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](LICENSE) file for details.
