MaldiAMRKit 0.22.0__tar.gz → 0.22.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2/MaldiAMRKit.egg-info}/PKG-INFO +51 -39
  2. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/MaldiAMRKit.egg-info/SOURCES.txt +3 -0
  3. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/MaldiAMRKit.egg-info/requires.txt +1 -0
  4. {maldiamrkit-0.22.0/MaldiAMRKit.egg-info → maldiamrkit-0.22.2}/PKG-INFO +51 -39
  5. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/README.md +49 -38
  6. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/__init__.py +1 -1
  7. maldiamrkit-0.22.2/maldiamrkit/alignment/_dtw.py +82 -0
  8. maldiamrkit-0.22.2/maldiamrkit/alignment/_versioning.py +87 -0
  9. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/alignment/peak_align.py +9 -4
  10. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/alignment/raw_warping.py +117 -13
  11. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/alignment/strategies.py +56 -23
  12. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/alignment/warping.py +23 -3
  13. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/cli.py +19 -1
  14. maldiamrkit-0.22.2/maldiamrkit/data/_metadata.py +33 -0
  15. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/builder.py +1 -1
  16. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/dataset_layouts.py +168 -53
  17. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/duplicates.py +35 -21
  18. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/input_layouts.py +15 -4
  19. maldiamrkit-0.22.2/maldiamrkit/data/loader.py +405 -0
  20. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/dataset.py +164 -46
  21. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/detection/peak_detector.py +21 -8
  22. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/detection/peaklist.py +74 -18
  23. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/differential/analysis.py +14 -0
  24. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/drift/monitor.py +27 -5
  25. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/drift/peak_drift.py +9 -2
  26. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/evaluation/metrics.py +103 -29
  27. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/evaluation/mic_regression.py +18 -7
  28. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/evaluation/splitting.py +149 -25
  29. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/filters.py +15 -8
  30. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/io/readers.py +36 -4
  31. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/binning.py +16 -9
  32. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/merging.py +11 -8
  33. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/quality.py +24 -20
  34. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/transformers.py +7 -5
  35. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/susceptibility/breakpoint.py +22 -6
  36. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/susceptibility/label_encoder.py +15 -1
  37. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/susceptibility/mic_encoder.py +28 -6
  38. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/requirements.txt +3 -0
  39. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/tests/test_peak_detector.py +44 -0
  40. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/tests/test_peaklist.py +119 -0
  41. maldiamrkit-0.22.0/maldiamrkit/data/loader.py +0 -250
  42. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/LICENSE +0 -0
  43. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/MaldiAMRKit.egg-info/dependency_links.txt +0 -0
  44. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/MaldiAMRKit.egg-info/entry_points.txt +0 -0
  45. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/MaldiAMRKit.egg-info/top_level.txt +0 -0
  46. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/_compat.py +0 -0
  47. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/_registry.py +0 -0
  48. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/alignment/__init__.py +0 -0
  49. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/__init__.py +0 -0
  50. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/README.md +0 -0
  51. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v1.0.yaml +0 -0
  52. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v1.1.yaml +0 -0
  53. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v1.2.yaml +0 -0
  54. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v1.3.yaml +0 -0
  55. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v10.0.yaml +0 -0
  56. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v11.0.yaml +0 -0
  57. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v12.0.yaml +0 -0
  58. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v13.1.yaml +0 -0
  59. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v14.0.yaml +0 -0
  60. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v15.0.yaml +0 -0
  61. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v16.0.yaml +0 -0
  62. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v2.0.yaml +0 -0
  63. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v4.0.yaml +0 -0
  64. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v5.0.yaml +0 -0
  65. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v6.0.yaml +0 -0
  66. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v7.1.yaml +0 -0
  67. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v8.0.yaml +0 -0
  68. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v8.1.yaml +0 -0
  69. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/eucast/eucast_v9.0.yaml +0 -0
  70. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/breakpoints/example.yaml +0 -0
  71. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/data/site_info.py +0 -0
  72. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/detection/__init__.py +0 -0
  73. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/differential/__init__.py +0 -0
  74. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/differential/plots.py +0 -0
  75. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/differential/stats.py +0 -0
  76. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/drift/__init__.py +0 -0
  77. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/drift/pca_drift.py +0 -0
  78. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/drift/plots.py +0 -0
  79. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/drift/reference.py +0 -0
  80. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/evaluation/__init__.py +0 -0
  81. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/io/__init__.py +0 -0
  82. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/io/mic.py +0 -0
  83. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/io/writers.py +0 -0
  84. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/__init__.py +0 -0
  85. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/pipeline.py +0 -0
  86. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/preprocessing/preprocessing_pipeline.py +0 -0
  87. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/py.typed +0 -0
  88. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/similarity/__init__.py +0 -0
  89. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/similarity/clustering.py +0 -0
  90. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/similarity/metrics.py +0 -0
  91. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/similarity/pairwise.py +0 -0
  92. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/similarity/plots.py +0 -0
  93. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/spectrum.py +0 -0
  94. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/susceptibility/__init__.py +0 -0
  95. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/visualization/__init__.py +0 -0
  96. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/visualization/_common.py +0 -0
  97. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/visualization/alignment_plots.py +0 -0
  98. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/visualization/exploratory_plots.py +0 -0
  99. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/visualization/peak_plots.py +0 -0
  100. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/maldiamrkit/visualization/spectrum_plots.py +0 -0
  101. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/pyproject.toml +0 -0
  102. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/requirements-batch.txt +0 -0
  103. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/requirements-dev.txt +0 -0
  104. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/requirements-docs.txt +0 -0
  105. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/requirements-formats.txt +0 -0
  106. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/setup.cfg +0 -0
  107. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/tests/test_compat.py +0 -0
  108. {maldiamrkit-0.22.0 → maldiamrkit-0.22.2}/tests/test_numerical_edge_cases.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MaldiAMRKit
3
- Version: 0.22.0
3
+ Version: 0.22.2
4
4
  Summary: A comprehensive toolkit for MALDI-TOF mass spectrometry data preprocessing for antimicrobial resistance (AMR) prediction purposes
5
5
  Author-email: Ettore Rocchi <ettore.rocchi3@unibo.it>
6
6
  License-Expression: MIT
@@ -31,6 +31,7 @@ Requires-Dist: seaborn>=0.11.0
31
31
  Requires-Dist: pybaselines>=1.0.0
32
32
  Requires-Dist: gudhi>=3.5.0
33
33
  Requires-Dist: tslearn>=0.6.0
34
+ Requires-Dist: numba>=0.55
34
35
  Requires-Dist: pyyaml>=6.0
35
36
  Requires-Dist: pyarrow>=14.0.0
36
37
  Requires-Dist: typer>=0.9.0
@@ -70,13 +71,20 @@ Dynamic: license-file
70
71
  [![License](https://img.shields.io/github/license/EttoreRocchi/MaldiAMRKit)](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/LICENSE)
71
72
 
72
73
  <p align="center">
73
- <img src="docs/maldiamrkit.png" alt="MaldiAMRKit" width="320"/>
74
+ <picture>
75
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/EttoreRocchi/MaldiAMRKit/main/docs/maldiamrkit_dark.png">
76
+ <img src="https://raw.githubusercontent.com/EttoreRocchi/MaldiAMRKit/main/docs/maldiamrkit.png" alt="MaldiAMRKit" width="320"/>
77
+ </picture>
74
78
  </p>
75
79
 
76
80
  <p align="center">
77
81
  <strong>A comprehensive toolkit for MALDI-TOF mass spectrometry data preprocessing for antimicrobial resistance (AMR) prediction purposes</strong>
78
82
  </p>
79
83
 
84
+ <p align="center">
85
+ <img src="https://raw.githubusercontent.com/EttoreRocchi/MaldiAMRKit/main/docs/preprocessing_pipeline.svg" alt="Animated MaldiAMRKit pipeline: a raw MALDI-TOF spectrum is smoothed, baseline-corrected, peak-detected and binned into a feature vector that predicts antimicrobial resistance (R/S)" width="720"/>
86
+ </p>
87
+
80
88
  <p align="center">
81
89
  <a href="#installation">Installation</a> •
82
90
  <a href="#features">Features</a> •
@@ -105,13 +113,13 @@ pip install maldisuite
105
113
 
106
114
  Visit the **MaldiSuite** landing page at <https://ettorerocchi.github.io/MaldiSuite/>.
107
115
 
108
- ### Optional: Batch Correction & UMAP
116
+ ### Optional: UMAP & combatlearn
109
117
 
110
118
  ```bash
111
119
  pip install maldiamrkit[batch]
112
120
  ```
113
121
 
114
- Installs [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) for ComBat-based batch effect correction and `umap-learn` for UMAP exploratory plots.
122
+ MaldiAMRKit has no batch corrector of its own. This extra adds `umap-learn` for UMAP exploratory plots, and [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) to use ComBat directly on a feature matrix. For batch correction built for MALDI-TOF spectra, see [MaldiBatchKit](https://github.com/EttoreRocchi/MaldiBatchKit).
115
123
 
116
124
  ### Optional: extended mzML/mzXML support
117
125
 
@@ -121,7 +129,7 @@ pip install maldiamrkit[formats]
121
129
 
122
130
  `.mzML` and `.mzXML` files are read out of the box (zlib-compressed or uncompressed arrays). This extra installs [`pyteomics`](https://pyteomics.readthedocs.io/) with `lxml`, `psims`, and `pynumpress`, which additionally handle numpress-compressed arrays. `pynumpress` ships no wheels for Python 3.10, so numpress arrays need Python 3.11 or newer.
123
131
 
124
- ### Development Installation
132
+ ### Development installation
125
133
 
126
134
  ```bash
127
135
  git clone https://github.com/EttoreRocchi/MaldiAMRKit.git
@@ -132,18 +140,18 @@ pip install -e .[dev]
132
140
  ## Features
133
141
 
134
142
  ### Preprocessing
135
- - **Composable Pipeline**: Build custom `PreprocessingPipeline` from individual transformers (smoothing, baseline correction, normalization, trimming), serializable to JSON/YAML
143
+ - **Composable Pipeline**: Build custom `PreprocessingPipeline` from individual transformers (smoothing, baseline correction, normalisation, trimming), serialisable to JSON/YAML
136
144
  - **Smoothing**: Savitzky-Golay and moving-average filters
137
145
  - **Baseline Correction**: SNIP, morphological top-hat, lower-convex-hull, and iterative rolling-median baselines
138
146
  - **Multiple Binning Strategies**: Uniform, proportional, adaptive, and custom bin edges
139
147
  - **Quality Metrics**: SNR estimation, MAD-based noise estimation, comprehensive quality reports, and alignment assessment
140
148
  - **Replicate Merging**: Mean/median/weighted merging with correlation-based outlier detection
141
149
 
142
- ### Alignment & Detection
143
- - **Spectral Alignment**: Shift, linear, piecewise, DTW, quadratic, cubic, and LOWESS warping for both binned and raw full-resolution spectra. Spectra are first shifted and then aligned to the reference of the shifted spectra, a non-rigid warp is kept only when the matched peaks support it, and resampling preserves the total intensity; spectra of several species are best aligned one species at a time
150
+ ### Alignment & detection
151
+ - **Spectral Alignment**: Shift, linear, piecewise, DTW, quadratic, cubic, and LOWESS warping for both binned and raw full-resolution spectra. Spectra are first shifted and then aligned to the reference of the shifted spectra, a non-rigid warp is kept only when the matched peaks support it, and resampling preserves the total intensity (neither applies to DTW); spectra of several species are best aligned one species at a time
144
152
  - **Peak Detection**: Local maxima and persistent homology methods
145
153
  - **Peak Sets**: `PeakSet` / `PeakList` represent each spectrum as a variable-length `(m/z, intensity)` set for peak-set models, via `MaldiPeakDetector.transform_peaklist()` on binned spectra or `create_peakset_input()` at full m/z resolution; extraction is stateless per spectrum, so results are cacheable without leakage
146
- - **Fit-Free Peak Alignment**: `align_peaks()` warps a peak set onto caller-supplied reference peaks, so the reference stays fitted on the training split
154
+ - **Fit-Free Peak Alignment**: `align_peaks()` warps a peak set onto caller-supplied reference peaks, which the caller estimates on the training split (for example `RawWarping(...).fit(X_train).ref_peaks_mz_`; a reference built with test spectra leaks)
147
155
 
148
156
  ### Extensibility
149
157
  - **Component Registries**: Plug your own components into the name-dispatched machinery - `register_spectral_metric()` for distance metrics (usable in `spectral_distance`, `pairwise_distances`, and `DriftMonitor`), `register_transformer()` to make `PreprocessingPipeline` configs holding custom transformers round-trip through JSON/YAML, and `register_binning_method()` for custom bin edges
@@ -157,19 +165,23 @@ pip install -e .[dev]
157
165
 
158
166
  ### Susceptibility (MIC encoding & breakpoints)
159
167
  - **`MICEncoder`**: Convert raw MIC strings into `log2(MIC)` regression targets plus S/I/R categories and ATU flags in a single pass
160
- - **`BreakpointTable`**: Clinical breakpoint tables (EUCAST v1.0-v16.0 bundled) loaded by version, year, latest, or custom YAML
168
+ - **`BreakpointTable`**: Clinical breakpoint tables (19 EUCAST versions between v1.0 and v16.0 bundled) loaded by version, year, latest, or custom YAML
161
169
  - **`LabelEncoder`**: Map R/I/S to binary with configurable intermediate handling (moved from `maldiamrkit.evaluation` in v0.15)
162
170
 
163
- ### Differential Analysis
171
+ ### Differential analysis
164
172
  - **`DifferentialAnalysis`**: Per-bin statistical testing (Mann-Whitney U, Welch's t-test) between resistant and susceptible groups, with multiple-testing correction, log2 fold change, and Cohen's d effect size
165
- - **Peak Selection**: `top_peaks()` by adjusted p-value, `significant_peaks()` with fold-change and p-value thresholds, `compare_drugs()` for multi-drug boolean significance matrices
173
+ - **Peak Ranking**: `top_peaks()` by adjusted p-value, `significant_peaks()` with fold-change and p-value thresholds, `compare_drugs()` for multi-drug boolean significance matrices (to select features for a classifier, rank peaks inside each training fold)
166
174
  - **AMR-Aware Plots**: `plot_volcano()`, `plot_manhattan()` along the m/z axis, and `plot_drug_comparison()` with binary heatmap or UpSet-style intersection view
167
175
 
168
- ### Drift Monitoring
176
+ ### Drift monitoring
169
177
  - **`DriftMonitor`**: Anchor a baseline on early timestamps (default: first 20%) and track temporal drift via three complementary views - reference similarity of per-window median spectra, PCA centroid trajectory in a baseline-fitted PCA space, and Jaccard stability of top-k differential peaks over time
170
178
  - **Trajectory Plots**: `plot_reference_drift`, `plot_pca_drift`, `plot_peak_stability`, `plot_effect_size_drift`
171
179
 
172
- ### Data Management
180
+ ### Spectral similarity
181
+ - **Distances & Clustering**: `spectral_distance` and `pairwise_distances` with built-in or registered metrics, `cluster_spectra` with hierarchical, HDBSCAN, and k-medoids methods, silhouette scores, and metadata concordance
182
+ - **Plots**: `plot_distance_heatmap` and `plot_dendrogram`
183
+
184
+ ### Data management
173
185
  - **Dataset Building & Loading**: `DatasetBuilder` and `DatasetLoader` with pluggable layout adapters (`FlatLayout`, `BrukerTreeLayout`, `DRIAMSLayout`, `MARISMaLayout`)
174
186
  - **Replicate Collapsing**: `DRIAMSLayout(collapse_replicates=True)` merges technical replicates (`_MALDI<N>`) to one row per isolate at load time via the active `duplicate_strategy`
175
187
  - **Bruker Format Support**: Read Bruker flexAnalysis binary data (fid/1r + acqus) natively via `read_spectrum()` on directories
@@ -178,9 +190,9 @@ pip install -e .[dev]
178
190
  - **Composable Filters**: `SpeciesFilter`, `DrugFilter`, `QualityFilter`, `MetadataFilter` combinable with `&`/`|`/`~` operators
179
191
  - **Spectrum Export**: Save spectra to CSV, TXT, or mzML via `MaldiSpectrum.save()` and `MaldiSet.save_spectra()`
180
192
 
181
- ### Visualization & Tools
182
- - **Exploratory Plots**: PCA, t-SNE, and UMAP scatter plots colored by species, resistance phenotype, or any metadata column
183
- - **Batch Effect Correction**: Multi-site/multi-instrument correction via [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) (`pip install maldiamrkit[batch]`)
193
+ ### Visualisation & tools
194
+ - **Exploratory Plots**: PCA, t-SNE, and UMAP scatter plots coloured by species, resistance phenotype, or any metadata column
195
+ - **Batch Effect Correction**: Not part of this package. Use [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) directly (`pip install maldiamrkit[batch]`) or [MaldiBatchKit](https://github.com/EttoreRocchi/MaldiBatchKit)
184
196
  - **CLI**: `maldiamrkit preprocess`, `maldiamrkit quality`, and `maldiamrkit build` for batch processing
185
197
  - **Parallel Processing**: Multi-core support via `n_jobs` parameter
186
198
  - **ML-Ready**: Direct integration with scikit-learn pipelines
@@ -189,9 +201,9 @@ pip install -e .[dev]
189
201
 
190
202
  Full documentation is available at [maldiamrkit.readthedocs.io](https://maldiamrkit.readthedocs.io/).
191
203
 
192
- ## Quick Start
204
+ ## Quick start
193
205
 
194
- ### Load and Preprocess a Single Spectrum
206
+ ### Load and preprocess a single spectrum
195
207
 
196
208
  ```python
197
209
  from maldiamrkit import MaldiSpectrum
@@ -210,7 +222,7 @@ from maldiamrkit.visualization import plot_spectrum
210
222
  plot_spectrum(spec, stage="binned")
211
223
  ```
212
224
 
213
- ### Build a Dataset from Multiple Spectra
225
+ ### Build a dataset from multiple spectra
214
226
 
215
227
  ```python
216
228
  from maldiamrkit import MaldiSet
@@ -228,7 +240,7 @@ X = data.X # Feature matrix
228
240
  y = data.get_y_single("Drug") # Target labels
229
241
  ```
230
242
 
231
- ### Machine Learning Pipeline
243
+ ### Machine learning pipeline
232
244
 
233
245
  ```python
234
246
  from sklearn.pipeline import Pipeline
@@ -240,13 +252,13 @@ from maldiamrkit.detection import MaldiPeakDetector
240
252
 
241
253
  # Create ML pipeline
242
254
  pipe = Pipeline([
243
- ("peaks", MaldiPeakDetector(binary=False, prominence=0.05)),
255
+ ("peaks", MaldiPeakDetector(binary=False, prominence=1e-4)),
244
256
  ("warp", Warping(method="shift")),
245
257
  ("scaler", StandardScaler()),
246
258
  ("clf", RandomForestClassifier(n_estimators=100, random_state=42))
247
259
  ])
248
260
 
249
- # Cross-validation
261
+ # Cross-validation (with replicates, use StratifiedGroupKFold and groups=data.groups)
250
262
  scores = cross_val_score(pipe, X, y, cv=5, scoring="accuracy")
251
263
  print(f"CV Accuracy: {scores.mean():.3f} +/- {scores.std():.3f}")
252
264
  ```
@@ -259,32 +271,32 @@ For more examples covering alignment, filtering, evaluation, CLI usage, and more
259
271
 
260
272
  For more detailed examples, see the notebooks:
261
273
 
262
- - [Quick Start](notebooks/01_quick_start.ipynb) - Loading, preprocessing, binning, and quality assessment
263
- - [Peak Detection](notebooks/02_peak_detection.ipynb) - Local maxima and persistent homology methods
264
- - [Alignment](notebooks/03_alignment.ipynb) - Warping methods and alignment quality
265
- - [Evaluation](notebooks/04_evaluation.ipynb) - AMR metrics, label encoding, and stratified splitting
266
- - [Exploration](notebooks/05_exploration.ipynb) - PCA, t-SNE, UMAP visualizations and batch correction
267
- - [Differential Analysis](notebooks/06_differential_analysis.ipynb) - R vs. S peak testing, volcano/Manhattan plots, and multi-drug comparison
268
- - [Drift Monitoring](notebooks/07_drift_monitoring.ipynb) - Baseline-anchored drift detection: reference similarity, PCA trajectory, peak stability, and effect-size drift
269
- - [Susceptibility](notebooks/08_susceptibility.ipynb) - `MICEncoder` + `BreakpointTable` for log2(MIC) regression targets, S/I/R categorisation with ATU, and `mic_regression_report` evaluation
270
- - [Peak Sets](notebooks/09_peak_sets.ipynb) - `PeakSet` / `PeakList` extraction, ranking and padding, caching, and fit-free peak alignment
271
- - [Custom Components](notebooks/10_custom_components.ipynb) - registering a custom distance metric and a custom transformer end-to-end
274
+ - [Quick Start](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/01_quick_start.ipynb) - Loading, preprocessing, binning, and quality assessment
275
+ - [Peak Detection](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/02_peak_detection.ipynb) - Local maxima and persistent homology methods
276
+ - [Alignment](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/03_alignment.ipynb) - Warping methods and alignment quality
277
+ - [Evaluation](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/04_evaluation.ipynb) - AMR metrics, label encoding, and stratified splitting
278
+ - [Exploration](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/05_exploration.ipynb) - PCA, t-SNE, and UMAP visualisations, spectral similarity, and clustering
279
+ - [Differential Analysis](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/06_differential_analysis.ipynb) - R vs. S peak testing, volcano/Manhattan plots, and multi-drug comparison
280
+ - [Drift Monitoring](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/07_drift_monitoring.ipynb) - Baseline-anchored drift detection: reference similarity, PCA trajectory, peak stability, and effect-size drift
281
+ - [Susceptibility](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/08_susceptibility.ipynb) - `MICEncoder` + `BreakpointTable` for log2(MIC) regression targets, S/I/R categorisation with ATU, and `mic_regression_report` evaluation
282
+ - [Peak Sets](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/09_peak_sets.ipynb) - `PeakSet` / `PeakList` extraction, ranking and padding, caching, and fit-free peak alignment
283
+ - [Custom Components](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/10_custom_components.ipynb) - registering a custom distance metric and a custom transformer end-to-end
272
284
 
273
- Notebooks `01`-`03` and `08`-`10` run on the small example dataset bundled under [`data/`](data/) or are fully self-contained. Notebooks `04`-`07` need more samples and pull the real **MALDI-Kleb-AI** archive (Rocchi *et al.*, 2026; [Zenodo DOI 10.5281/zenodo.17405072](https://zenodo.org/records/17405072)) via the [`demo`](notebooks/_demo.py) helper. By default the helper restricts the dataset to the **Rome sub-cohort** (~470 spectra, single acquisition centre, no batch correction required); the 370 MB tarball is cached under `~/.cache/maldiamrkit/` on first use.
285
+ Notebooks `01`-`03` and `08`-`10` run on the small example dataset bundled under [`data/`](https://github.com/EttoreRocchi/MaldiAMRKit/tree/main/data) or are fully self-contained. Notebooks `04`-`07` need more samples and pull the real **MALDI-Kleb-AI** archive (Rocchi *et al.*, 2026; [Zenodo DOI 10.5281/zenodo.17405072](https://zenodo.org/records/17405072)) via the [`demo`](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/_demo.py) helper. By default the helper restricts the dataset to the **Rome sub-cohort** (~470 spectra, single acquisition centre, no batch correction required); the 370 MB tarball is cached under `~/.cache/maldiamrkit/` on first use.
274
286
 
275
- ## MaldiSuite Ecosystem
287
+ ## MaldiSuite ecosystem
276
288
 
277
- MaldiAMRKit is the data-model and preprocessing package of the **MaldiSuite** ecosystem:
289
+ MaldiAMRKit is one of the three packages of the **MaldiSuite** ecosystem:
278
290
 
279
291
  - **MaldiAMRKit** (this package) - data model (`MaldiSpectrum`, `MaldiSet`), preprocessing, alignment, peak detection, differential analysis, and AMR-aware evaluation.
280
292
  - **[MaldiBatchKit](https://github.com/EttoreRocchi/MaldiBatchKit)** - batch-effect correction and harmonisation for multi-centre / multi-instrument MALDI-TOF spectra.
281
293
  - **[MaldiDeepKit](https://github.com/EttoreRocchi/MaldiDeepKit)** - sklearn-compatible deep learning classifiers (MLP, CNN, ResNet, Transformer).
282
294
 
283
- The three packages share the `MaldiSet` / `MaldiSpectrum` data model and are designed to compose in a single end-to-end pipeline. Install the full suite with `pip install maldisuite`. Landing page: [MaldiSuite](<https://ettorerocchi.github.io/MaldiSuite/>).
295
+ The three packages share the `MaldiSet` data model. Each can be used on its own, or combined with the others. Install the full suite with `pip install maldisuite`. Landing page: [MaldiSuite](<https://ettorerocchi.github.io/MaldiSuite/>).
284
296
 
285
297
  ## Contributing
286
298
 
287
- Pull requests, bug reports, and feature ideas are welcome. See the [Contributing Guide](CONTRIBUTING.md) for how to get started.
299
+ Pull requests, bug reports, and feature ideas are welcome. See the [Contributing Guide](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/CONTRIBUTING.md) for how to get started.
288
300
 
289
301
  ## Citing
290
302
 
@@ -296,7 +308,7 @@ See the [full publications list](https://maldiamrkit.readthedocs.io/en/latest/pa
296
308
 
297
309
  ## License
298
310
 
299
- This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
311
+ This project is licensed under the **MIT License**. See the [LICENSE](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/LICENSE) file for details.
300
312
 
301
313
  ## Acknowledgements
302
314
 
@@ -21,11 +21,14 @@ maldiamrkit/filters.py
21
21
  maldiamrkit/py.typed
22
22
  maldiamrkit/spectrum.py
23
23
  maldiamrkit/alignment/__init__.py
24
+ maldiamrkit/alignment/_dtw.py
25
+ maldiamrkit/alignment/_versioning.py
24
26
  maldiamrkit/alignment/peak_align.py
25
27
  maldiamrkit/alignment/raw_warping.py
26
28
  maldiamrkit/alignment/strategies.py
27
29
  maldiamrkit/alignment/warping.py
28
30
  maldiamrkit/data/__init__.py
31
+ maldiamrkit/data/_metadata.py
29
32
  maldiamrkit/data/builder.py
30
33
  maldiamrkit/data/dataset_layouts.py
31
34
  maldiamrkit/data/duplicates.py
@@ -7,6 +7,7 @@ seaborn>=0.11.0
7
7
  pybaselines>=1.0.0
8
8
  gudhi>=3.5.0
9
9
  tslearn>=0.6.0
10
+ numba>=0.55
10
11
  pyyaml>=6.0
11
12
  pyarrow>=14.0.0
12
13
  typer>=0.9.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: MaldiAMRKit
3
- Version: 0.22.0
3
+ Version: 0.22.2
4
4
  Summary: A comprehensive toolkit for MALDI-TOF mass spectrometry data preprocessing for antimicrobial resistance (AMR) prediction purposes
5
5
  Author-email: Ettore Rocchi <ettore.rocchi3@unibo.it>
6
6
  License-Expression: MIT
@@ -31,6 +31,7 @@ Requires-Dist: seaborn>=0.11.0
31
31
  Requires-Dist: pybaselines>=1.0.0
32
32
  Requires-Dist: gudhi>=3.5.0
33
33
  Requires-Dist: tslearn>=0.6.0
34
+ Requires-Dist: numba>=0.55
34
35
  Requires-Dist: pyyaml>=6.0
35
36
  Requires-Dist: pyarrow>=14.0.0
36
37
  Requires-Dist: typer>=0.9.0
@@ -70,13 +71,20 @@ Dynamic: license-file
70
71
  [![License](https://img.shields.io/github/license/EttoreRocchi/MaldiAMRKit)](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/LICENSE)
71
72
 
72
73
  <p align="center">
73
- <img src="docs/maldiamrkit.png" alt="MaldiAMRKit" width="320"/>
74
+ <picture>
75
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/EttoreRocchi/MaldiAMRKit/main/docs/maldiamrkit_dark.png">
76
+ <img src="https://raw.githubusercontent.com/EttoreRocchi/MaldiAMRKit/main/docs/maldiamrkit.png" alt="MaldiAMRKit" width="320"/>
77
+ </picture>
74
78
  </p>
75
79
 
76
80
  <p align="center">
77
81
  <strong>A comprehensive toolkit for MALDI-TOF mass spectrometry data preprocessing for antimicrobial resistance (AMR) prediction purposes</strong>
78
82
  </p>
79
83
 
84
+ <p align="center">
85
+ <img src="https://raw.githubusercontent.com/EttoreRocchi/MaldiAMRKit/main/docs/preprocessing_pipeline.svg" alt="Animated MaldiAMRKit pipeline: a raw MALDI-TOF spectrum is smoothed, baseline-corrected, peak-detected and binned into a feature vector that predicts antimicrobial resistance (R/S)" width="720"/>
86
+ </p>
87
+
80
88
  <p align="center">
81
89
  <a href="#installation">Installation</a> •
82
90
  <a href="#features">Features</a> •
@@ -105,13 +113,13 @@ pip install maldisuite
105
113
 
106
114
  Visit the **MaldiSuite** landing page at <https://ettorerocchi.github.io/MaldiSuite/>.
107
115
 
108
- ### Optional: Batch Correction & UMAP
116
+ ### Optional: UMAP & combatlearn
109
117
 
110
118
  ```bash
111
119
  pip install maldiamrkit[batch]
112
120
  ```
113
121
 
114
- Installs [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) for ComBat-based batch effect correction and `umap-learn` for UMAP exploratory plots.
122
+ MaldiAMRKit has no batch corrector of its own. This extra adds `umap-learn` for UMAP exploratory plots, and [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) to use ComBat directly on a feature matrix. For batch correction built for MALDI-TOF spectra, see [MaldiBatchKit](https://github.com/EttoreRocchi/MaldiBatchKit).
115
123
 
116
124
  ### Optional: extended mzML/mzXML support
117
125
 
@@ -121,7 +129,7 @@ pip install maldiamrkit[formats]
121
129
 
122
130
  `.mzML` and `.mzXML` files are read out of the box (zlib-compressed or uncompressed arrays). This extra installs [`pyteomics`](https://pyteomics.readthedocs.io/) with `lxml`, `psims`, and `pynumpress`, which additionally handle numpress-compressed arrays. `pynumpress` ships no wheels for Python 3.10, so numpress arrays need Python 3.11 or newer.
123
131
 
124
- ### Development Installation
132
+ ### Development installation
125
133
 
126
134
  ```bash
127
135
  git clone https://github.com/EttoreRocchi/MaldiAMRKit.git
@@ -132,18 +140,18 @@ pip install -e .[dev]
132
140
  ## Features
133
141
 
134
142
  ### Preprocessing
135
- - **Composable Pipeline**: Build custom `PreprocessingPipeline` from individual transformers (smoothing, baseline correction, normalization, trimming), serializable to JSON/YAML
143
+ - **Composable Pipeline**: Build custom `PreprocessingPipeline` from individual transformers (smoothing, baseline correction, normalisation, trimming), serialisable to JSON/YAML
136
144
  - **Smoothing**: Savitzky-Golay and moving-average filters
137
145
  - **Baseline Correction**: SNIP, morphological top-hat, lower-convex-hull, and iterative rolling-median baselines
138
146
  - **Multiple Binning Strategies**: Uniform, proportional, adaptive, and custom bin edges
139
147
  - **Quality Metrics**: SNR estimation, MAD-based noise estimation, comprehensive quality reports, and alignment assessment
140
148
  - **Replicate Merging**: Mean/median/weighted merging with correlation-based outlier detection
141
149
 
142
- ### Alignment & Detection
143
- - **Spectral Alignment**: Shift, linear, piecewise, DTW, quadratic, cubic, and LOWESS warping for both binned and raw full-resolution spectra. Spectra are first shifted and then aligned to the reference of the shifted spectra, a non-rigid warp is kept only when the matched peaks support it, and resampling preserves the total intensity; spectra of several species are best aligned one species at a time
150
+ ### Alignment & detection
151
+ - **Spectral Alignment**: Shift, linear, piecewise, DTW, quadratic, cubic, and LOWESS warping for both binned and raw full-resolution spectra. Spectra are first shifted and then aligned to the reference of the shifted spectra, a non-rigid warp is kept only when the matched peaks support it, and resampling preserves the total intensity (neither applies to DTW); spectra of several species are best aligned one species at a time
144
152
  - **Peak Detection**: Local maxima and persistent homology methods
145
153
  - **Peak Sets**: `PeakSet` / `PeakList` represent each spectrum as a variable-length `(m/z, intensity)` set for peak-set models, via `MaldiPeakDetector.transform_peaklist()` on binned spectra or `create_peakset_input()` at full m/z resolution; extraction is stateless per spectrum, so results are cacheable without leakage
146
- - **Fit-Free Peak Alignment**: `align_peaks()` warps a peak set onto caller-supplied reference peaks, so the reference stays fitted on the training split
154
+ - **Fit-Free Peak Alignment**: `align_peaks()` warps a peak set onto caller-supplied reference peaks, which the caller estimates on the training split (for example `RawWarping(...).fit(X_train).ref_peaks_mz_`; a reference built with test spectra leaks)
147
155
 
148
156
  ### Extensibility
149
157
  - **Component Registries**: Plug your own components into the name-dispatched machinery - `register_spectral_metric()` for distance metrics (usable in `spectral_distance`, `pairwise_distances`, and `DriftMonitor`), `register_transformer()` to make `PreprocessingPipeline` configs holding custom transformers round-trip through JSON/YAML, and `register_binning_method()` for custom bin edges
@@ -157,19 +165,23 @@ pip install -e .[dev]
157
165
 
158
166
  ### Susceptibility (MIC encoding & breakpoints)
159
167
  - **`MICEncoder`**: Convert raw MIC strings into `log2(MIC)` regression targets plus S/I/R categories and ATU flags in a single pass
160
- - **`BreakpointTable`**: Clinical breakpoint tables (EUCAST v1.0-v16.0 bundled) loaded by version, year, latest, or custom YAML
168
+ - **`BreakpointTable`**: Clinical breakpoint tables (19 EUCAST versions between v1.0 and v16.0 bundled) loaded by version, year, latest, or custom YAML
161
169
  - **`LabelEncoder`**: Map R/I/S to binary with configurable intermediate handling (moved from `maldiamrkit.evaluation` in v0.15)
162
170
 
163
- ### Differential Analysis
171
+ ### Differential analysis
164
172
  - **`DifferentialAnalysis`**: Per-bin statistical testing (Mann-Whitney U, Welch's t-test) between resistant and susceptible groups, with multiple-testing correction, log2 fold change, and Cohen's d effect size
165
- - **Peak Selection**: `top_peaks()` by adjusted p-value, `significant_peaks()` with fold-change and p-value thresholds, `compare_drugs()` for multi-drug boolean significance matrices
173
+ - **Peak Ranking**: `top_peaks()` by adjusted p-value, `significant_peaks()` with fold-change and p-value thresholds, `compare_drugs()` for multi-drug boolean significance matrices (to select features for a classifier, rank peaks inside each training fold)
166
174
  - **AMR-Aware Plots**: `plot_volcano()`, `plot_manhattan()` along the m/z axis, and `plot_drug_comparison()` with binary heatmap or UpSet-style intersection view
167
175
 
168
- ### Drift Monitoring
176
+ ### Drift monitoring
169
177
  - **`DriftMonitor`**: Anchor a baseline on early timestamps (default: first 20%) and track temporal drift via three complementary views - reference similarity of per-window median spectra, PCA centroid trajectory in a baseline-fitted PCA space, and Jaccard stability of top-k differential peaks over time
170
178
  - **Trajectory Plots**: `plot_reference_drift`, `plot_pca_drift`, `plot_peak_stability`, `plot_effect_size_drift`
171
179
 
172
- ### Data Management
180
+ ### Spectral similarity
181
+ - **Distances & Clustering**: `spectral_distance` and `pairwise_distances` with built-in or registered metrics, `cluster_spectra` with hierarchical, HDBSCAN, and k-medoids methods, silhouette scores, and metadata concordance
182
+ - **Plots**: `plot_distance_heatmap` and `plot_dendrogram`
183
+
184
+ ### Data management
173
185
  - **Dataset Building & Loading**: `DatasetBuilder` and `DatasetLoader` with pluggable layout adapters (`FlatLayout`, `BrukerTreeLayout`, `DRIAMSLayout`, `MARISMaLayout`)
174
186
  - **Replicate Collapsing**: `DRIAMSLayout(collapse_replicates=True)` merges technical replicates (`_MALDI<N>`) to one row per isolate at load time via the active `duplicate_strategy`
175
187
  - **Bruker Format Support**: Read Bruker flexAnalysis binary data (fid/1r + acqus) natively via `read_spectrum()` on directories
@@ -178,9 +190,9 @@ pip install -e .[dev]
178
190
  - **Composable Filters**: `SpeciesFilter`, `DrugFilter`, `QualityFilter`, `MetadataFilter` combinable with `&`/`|`/`~` operators
179
191
  - **Spectrum Export**: Save spectra to CSV, TXT, or mzML via `MaldiSpectrum.save()` and `MaldiSet.save_spectra()`
180
192
 
181
- ### Visualization & Tools
182
- - **Exploratory Plots**: PCA, t-SNE, and UMAP scatter plots colored by species, resistance phenotype, or any metadata column
183
- - **Batch Effect Correction**: Multi-site/multi-instrument correction via [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) (`pip install maldiamrkit[batch]`)
193
+ ### Visualisation & tools
194
+ - **Exploratory Plots**: PCA, t-SNE, and UMAP scatter plots coloured by species, resistance phenotype, or any metadata column
195
+ - **Batch Effect Correction**: Not part of this package. Use [`combatlearn`](https://github.com/EttoreRocchi/combatlearn) directly (`pip install maldiamrkit[batch]`) or [MaldiBatchKit](https://github.com/EttoreRocchi/MaldiBatchKit)
184
196
  - **CLI**: `maldiamrkit preprocess`, `maldiamrkit quality`, and `maldiamrkit build` for batch processing
185
197
  - **Parallel Processing**: Multi-core support via `n_jobs` parameter
186
198
  - **ML-Ready**: Direct integration with scikit-learn pipelines
@@ -189,9 +201,9 @@ pip install -e .[dev]
189
201
 
190
202
  Full documentation is available at [maldiamrkit.readthedocs.io](https://maldiamrkit.readthedocs.io/).
191
203
 
192
- ## Quick Start
204
+ ## Quick start
193
205
 
194
- ### Load and Preprocess a Single Spectrum
206
+ ### Load and preprocess a single spectrum
195
207
 
196
208
  ```python
197
209
  from maldiamrkit import MaldiSpectrum
@@ -210,7 +222,7 @@ from maldiamrkit.visualization import plot_spectrum
210
222
  plot_spectrum(spec, stage="binned")
211
223
  ```
212
224
 
213
- ### Build a Dataset from Multiple Spectra
225
+ ### Build a dataset from multiple spectra
214
226
 
215
227
  ```python
216
228
  from maldiamrkit import MaldiSet
@@ -228,7 +240,7 @@ X = data.X # Feature matrix
228
240
  y = data.get_y_single("Drug") # Target labels
229
241
  ```
230
242
 
231
- ### Machine Learning Pipeline
243
+ ### Machine learning pipeline
232
244
 
233
245
  ```python
234
246
  from sklearn.pipeline import Pipeline
@@ -240,13 +252,13 @@ from maldiamrkit.detection import MaldiPeakDetector
240
252
 
241
253
  # Create ML pipeline
242
254
  pipe = Pipeline([
243
- ("peaks", MaldiPeakDetector(binary=False, prominence=0.05)),
255
+ ("peaks", MaldiPeakDetector(binary=False, prominence=1e-4)),
244
256
  ("warp", Warping(method="shift")),
245
257
  ("scaler", StandardScaler()),
246
258
  ("clf", RandomForestClassifier(n_estimators=100, random_state=42))
247
259
  ])
248
260
 
249
- # Cross-validation
261
+ # Cross-validation (with replicates, use StratifiedGroupKFold and groups=data.groups)
250
262
  scores = cross_val_score(pipe, X, y, cv=5, scoring="accuracy")
251
263
  print(f"CV Accuracy: {scores.mean():.3f} +/- {scores.std():.3f}")
252
264
  ```
@@ -259,32 +271,32 @@ For more examples covering alignment, filtering, evaluation, CLI usage, and more
259
271
 
260
272
  For more detailed examples, see the notebooks:
261
273
 
262
- - [Quick Start](notebooks/01_quick_start.ipynb) - Loading, preprocessing, binning, and quality assessment
263
- - [Peak Detection](notebooks/02_peak_detection.ipynb) - Local maxima and persistent homology methods
264
- - [Alignment](notebooks/03_alignment.ipynb) - Warping methods and alignment quality
265
- - [Evaluation](notebooks/04_evaluation.ipynb) - AMR metrics, label encoding, and stratified splitting
266
- - [Exploration](notebooks/05_exploration.ipynb) - PCA, t-SNE, UMAP visualizations and batch correction
267
- - [Differential Analysis](notebooks/06_differential_analysis.ipynb) - R vs. S peak testing, volcano/Manhattan plots, and multi-drug comparison
268
- - [Drift Monitoring](notebooks/07_drift_monitoring.ipynb) - Baseline-anchored drift detection: reference similarity, PCA trajectory, peak stability, and effect-size drift
269
- - [Susceptibility](notebooks/08_susceptibility.ipynb) - `MICEncoder` + `BreakpointTable` for log2(MIC) regression targets, S/I/R categorisation with ATU, and `mic_regression_report` evaluation
270
- - [Peak Sets](notebooks/09_peak_sets.ipynb) - `PeakSet` / `PeakList` extraction, ranking and padding, caching, and fit-free peak alignment
271
- - [Custom Components](notebooks/10_custom_components.ipynb) - registering a custom distance metric and a custom transformer end-to-end
274
+ - [Quick Start](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/01_quick_start.ipynb) - Loading, preprocessing, binning, and quality assessment
275
+ - [Peak Detection](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/02_peak_detection.ipynb) - Local maxima and persistent homology methods
276
+ - [Alignment](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/03_alignment.ipynb) - Warping methods and alignment quality
277
+ - [Evaluation](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/04_evaluation.ipynb) - AMR metrics, label encoding, and stratified splitting
278
+ - [Exploration](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/05_exploration.ipynb) - PCA, t-SNE, and UMAP visualisations, spectral similarity, and clustering
279
+ - [Differential Analysis](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/06_differential_analysis.ipynb) - R vs. S peak testing, volcano/Manhattan plots, and multi-drug comparison
280
+ - [Drift Monitoring](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/07_drift_monitoring.ipynb) - Baseline-anchored drift detection: reference similarity, PCA trajectory, peak stability, and effect-size drift
281
+ - [Susceptibility](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/08_susceptibility.ipynb) - `MICEncoder` + `BreakpointTable` for log2(MIC) regression targets, S/I/R categorisation with ATU, and `mic_regression_report` evaluation
282
+ - [Peak Sets](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/09_peak_sets.ipynb) - `PeakSet` / `PeakList` extraction, ranking and padding, caching, and fit-free peak alignment
283
+ - [Custom Components](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/10_custom_components.ipynb) - registering a custom distance metric and a custom transformer end-to-end
272
284
 
273
- Notebooks `01`-`03` and `08`-`10` run on the small example dataset bundled under [`data/`](data/) or are fully self-contained. Notebooks `04`-`07` need more samples and pull the real **MALDI-Kleb-AI** archive (Rocchi *et al.*, 2026; [Zenodo DOI 10.5281/zenodo.17405072](https://zenodo.org/records/17405072)) via the [`demo`](notebooks/_demo.py) helper. By default the helper restricts the dataset to the **Rome sub-cohort** (~470 spectra, single acquisition centre, no batch correction required); the 370 MB tarball is cached under `~/.cache/maldiamrkit/` on first use.
285
+ Notebooks `01`-`03` and `08`-`10` run on the small example dataset bundled under [`data/`](https://github.com/EttoreRocchi/MaldiAMRKit/tree/main/data) or are fully self-contained. Notebooks `04`-`07` need more samples and pull the real **MALDI-Kleb-AI** archive (Rocchi *et al.*, 2026; [Zenodo DOI 10.5281/zenodo.17405072](https://zenodo.org/records/17405072)) via the [`demo`](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/notebooks/_demo.py) helper. By default the helper restricts the dataset to the **Rome sub-cohort** (~470 spectra, single acquisition centre, no batch correction required); the 370 MB tarball is cached under `~/.cache/maldiamrkit/` on first use.
274
286
 
275
- ## MaldiSuite Ecosystem
287
+ ## MaldiSuite ecosystem
276
288
 
277
- MaldiAMRKit is the data-model and preprocessing package of the **MaldiSuite** ecosystem:
289
+ MaldiAMRKit is one of the three packages of the **MaldiSuite** ecosystem:
278
290
 
279
291
  - **MaldiAMRKit** (this package) - data model (`MaldiSpectrum`, `MaldiSet`), preprocessing, alignment, peak detection, differential analysis, and AMR-aware evaluation.
280
292
  - **[MaldiBatchKit](https://github.com/EttoreRocchi/MaldiBatchKit)** - batch-effect correction and harmonisation for multi-centre / multi-instrument MALDI-TOF spectra.
281
293
  - **[MaldiDeepKit](https://github.com/EttoreRocchi/MaldiDeepKit)** - sklearn-compatible deep learning classifiers (MLP, CNN, ResNet, Transformer).
282
294
 
283
- The three packages share the `MaldiSet` / `MaldiSpectrum` data model and are designed to compose in a single end-to-end pipeline. Install the full suite with `pip install maldisuite`. Landing page: [MaldiSuite](<https://ettorerocchi.github.io/MaldiSuite/>).
295
+ The three packages share the `MaldiSet` data model. Each can be used on its own, or combined with the others. Install the full suite with `pip install maldisuite`. Landing page: [MaldiSuite](<https://ettorerocchi.github.io/MaldiSuite/>).
284
296
 
285
297
  ## Contributing
286
298
 
287
- Pull requests, bug reports, and feature ideas are welcome. See the [Contributing Guide](CONTRIBUTING.md) for how to get started.
299
+ Pull requests, bug reports, and feature ideas are welcome. See the [Contributing Guide](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/CONTRIBUTING.md) for how to get started.
288
300
 
289
301
  ## Citing
290
302
 
@@ -296,7 +308,7 @@ See the [full publications list](https://maldiamrkit.readthedocs.io/en/latest/pa
296
308
 
297
309
  ## License
298
310
 
299
- This project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.
311
+ This project is licensed under the **MIT License**. See the [LICENSE](https://github.com/EttoreRocchi/MaldiAMRKit/blob/main/LICENSE) file for details.
300
312
 
301
313
  ## Acknowledgements
302
314