API Reference#
Complete reference for all public classes and functions in MaldiAMRKit, organized by module.
Core Data Structures#
A single MALDI-TOF spectrum. |
|
A collection of MALDI-TOF spectra with metadata. |
Filters#
Base filter with operator overloading. |
|
Filter by species name(s). |
|
Filter by antibiotic resistance status. |
|
Filter by quality metrics stored in metadata columns. |
|
Filter by arbitrary metadata column condition. |
Preprocessing#
Composable pipeline of preprocessing steps for MALDI-TOF spectra. |
|
Apply preprocessing pipeline to a raw MALDI-TOF spectrum. |
|
Bin spectrum intensities into m/z intervals. |
|
Generate bin metadata from edges. |
|
Supported binning methods. |
|
Estimate signal-to-noise ratio of a spectrum. |
|
Comprehensive quality assessment for MALDI-TOF spectra. |
|
Quality metrics report for a single MALDI-TOF spectrum. |
|
Method for estimating the signal level in SNR computation. |
|
Merge replicate spectra into a single consensus spectrum. |
|
Identify outlier replicates using correlation with the median spectrum. |
|
Supported replicate merging methods. |
Transformers#
Clip negative intensity values to zero. |
|
Variance-stabilizing square root transformation. |
|
Log1p intensity transformation (alternative to sqrt). |
|
Savitzky-Golay smoothing filter. |
|
Moving-average smoothing filter. |
|
SNIP (Statistics-sensitive Non-linear Iterative Peak-clipping) baseline correction. |
|
Morphological top-hat baseline subtraction. |
|
Parameter-free baseline from the lower convex hull of the spectrum. |
|
Rolling-median baseline subtraction. |
|
Trim spectrum to a specified m/z range. |
|
Total Ion Current normalization (intensities sum to 1). |
|
Normalize intensities by median value. |
|
Probabilistic Quotient Normalization. |
|
Keep only specific m/z ranges from the spectrum. |
Alignment#
Align MALDI-TOF spectra to a reference using different strategies. |
|
Align MALDI-TOF spectra using raw (full resolution) data. |
|
Create input DataFrame for RawWarping from a directory of spectrum files. |
|
Base class for alignment strategies. |
|
Supported alignment/warping methods. |
Peak Detection#
Peak detector for MALDI-TOF spectra with local maxima and topological methods. |
|
Supported peak detection methods. |
Evaluation#
Metrics#
Very Major Error rate: resistant isolates classified as susceptible. |
|
Major Error rate: susceptible isolates classified as resistant. |
|
Sensitivity (recall) for the resistant class. |
|
Specificity (true negative rate) for the susceptible class. |
|
Categorical agreement (accuracy) as reported in AST studies. |
Reports#
Full AMR classification report. |
|
Compute MIC regression metrics on log2-MIC predictions. |
|
AMR classification report for multiple antibiotics. |
|
VME and ME rates at varying decision thresholds. |
Scorers#
|
|
|
Splitting#
Stratified train/test split preserving species-drug label distributions. |
|
Train/test split keeping all samples from the same patient together. |
|
K-fold cross-validation with species-drug stratification. |
|
K-fold cross-validation keeping patient cases together and stratified by |
Susceptibility#
MIC encoding, clinical breakpoint tables, and R/I/S label encoding.
Encode MIC strings into log2 numeric values and optional S/I/R labels. |
|
Clinical breakpoint table for MIC interpretation. |
|
Result of applying a clinical breakpoint to a single MIC value. |
|
Encode R/I/S resistance labels to binary (0/1). |
|
Strategy for handling intermediate (I) resistance labels. |
Similarity#
Compute distance between two spectra. |
|
Supported spectral distance/similarity metrics. |
|
Compute an n x n symmetric distance matrix. |
|
Cluster spectra from a precomputed distance matrix. |
|
Agglomerative hierarchical clustering on a precomputed distance matrix. |
|
HDBSCAN clustering on a precomputed distance matrix. |
|
K-medoids clustering using the PAM algorithm. |
|
Silhouette score for a clustering on a precomputed distance matrix. |
|
Evaluate clustering agreement with known metadata labels. |
|
Supported clustering algorithms for |
|
Initialization strategy for |
|
Plot a pairwise distance matrix as a heatmap. |
|
Plot a dendrogram from a hierarchical clustering linkage matrix. |
Differential Analysis#
Analysis#
Plots#
Volcano plot of log2 fold change vs. -log10 adjusted p-value. |
|
Manhattan plot along the m/z axis. |
|
Visualise a multi-drug differential-peak comparison matrix. |
|
Rendering kind for |
Drift Monitoring#
Monitor#
Monitor spectral drift over time using baseline-anchored metrics. |
Plots#
Line plot of reference-similarity distance over time. |
|
PCA centroid trajectory colored by time. |
|
Line plot of peak-selection Jaccard stability over time. |
|
Multi-line plot of per-peak Cohen's d over time. |
Visualization#
Plot a single MALDI-TOF spectrum with real m/z axis. |
|
Display a pseudogel heatmap of the spectra. |
|
Plot detected peaks overlaid on original spectra. |
|
Plot comparison of original vs aligned spectra against reference. |
|
Scatter plot of a PCA embedding colored by metadata. |
|
Scatter plot of a t-SNE embedding colored by metadata. |
|
Scatter plot of a UMAP embedding colored by metadata. |
Dataset Building & Loading#
Builder#
Build a standardised dataset from any supported input layout. |
|
Define an additional processing output folder. |
|
Summary of a dataset build. |
Input Layouts#
Abstract adapter for discovering spectra and metadata. |
|
Flat directory of pre-exported text spectrum files + metadata CSV. |
|
Hierarchical directory tree containing raw Bruker binary data. |
Loader#
Load a dataset into a |
Dataset Layouts#
Abstract adapter for navigating and loading from a dataset. |
|
Navigate a DRIAMS-like dataset structure. |
|
Navigate a dataset of raw Bruker spectra organised in a tree. |
Duplicate Handling#
Strategy for handling duplicate spectrum identifiers. |
I/O#
Read a raw spectrum file into a DataFrame. |
|
Parse a column of MIC strings into numeric values and qualifiers. |