Application of a Neural Network
for Classification of Antibiotic Resistances
using MALDI-TOF Mass Spectrometry

(Version: August 2025)

Background


The World Health Organization (WHO) declared antimicrobial resistance (AMR) one of the ten greatest global threats to public health in 2019. Early detection of a pathogen's resistance is crucial for effective treatment, which can save lives and reduce costs.

Current methods for species identification using MALDI-TOF mass spectrometry allow for determination on the day of sample collection. However, determining antibiotic resistance typically requires several days of pathogen cultivation. The use of more rapidly available mass spectrometry data for resistance determination therefore represents a significant advantage.

Machine Learning (ML) and Artificial Intelligence (AI) methods are already established for classifying large amounts of data and have also been successfully applied to MALDI-TOF data to classify pathogens and their antimicrobial resistances.

This application example serves as a proof-of-concept to demonstrate the fundamental suitability of the method for classifying MALDI-TOF data. The method is flexible and can be extended to other species or antibiotics.

Application


Data

For this application example, a subset of a publicly available dataset on antibiotic resistance of human pathogenic bacteria is used. This dataset is published and accessible online.

The primary interest was in detecting antibiotic resistance of a human pathogenic bacterial strain from a clinical setting using MALDI-TOF data. For this purpose, samples were specifically extracted from the overall dataset for which corresponding information on antibiotic resistance was available in the metadata. The resulting subset comprises almost 4,900 samples and is thus sufficiently large for the application of a Neural Network (NN).

Analysis of the data distribution shows that both overall and at the individual sample origins (DRIAMS-A, DRIAMS-B, DRIAMS-C), significantly more susceptible (S) than resistant (R) samples were present. The abbreviation DRIAMS stands for "Database of Resistant Isolate Archives for MALDI-TOF Spectra". The sample origins DRIAMS-B and DRIAMS-C were sampled exclusively in 2018, while DRIAMS-A also includes samples from 2015 to 2017, which explains the higher number of samples from this location. The number of resistant samples remained largely constant from 2016 to 2018, while the number of susceptible samples increased.

DRIAMS-data distribution

Preprocessing

To prepare the raw data for input into the Neural Network, a specific sequence of preprocessing steps was applied. These steps are based on the methodology described in the original publication of the dataset, but have been adapted with regard to the algorithms and the number of bins. The preprocessing is designed as a modular pipeline, allowing different algorithms to be chosen for each step to ensure optimal feature extraction.

The preprocessing included the following steps:

  1. Transformation: Intensity values were normalized using square root transformation to stabilize variance and make the data more manageable for subsequent steps.
  2. Smoothing: A Savitzky-Golay filter was used for noise reduction. This algorithm is particularly suitable for smoothing spectra as it preserves the signal shape well.
  3. Baseline Correction: Baseline correction was performed using the SNIP algorithm to remove non-specific background signals that overlay the spectral peaks.
  4. Calibration: Intensity values were calibrated by division by the Total-Ion-Current (TIC) to ensure comparability of spectra recorded with different intensities.
  5. Trimming: The m/z range of the spectra was trimmed to 2,000 to 20,000 m/z, as this range contains the most relevant signals.
  6. Binning: The preprocessed m/z and intensity data were divided into 6,000 bins of 2 Da each. The intensities within each bin were summed, which allows for a reduction in data volume while preserving the most important spectral information for the NN.

Principal Component Analysis (PCA)

To evaluate the suitability of the preprocessed spectra for training the Neural Network, a Principal Component Analysis (PCA) of the spectra was performed. PCA serves as a statistical method for dimensionality reduction and visualization by transforming the complex spectra into a few principal components that represent the greatest variability in the dataset.

DRIAMS-data_PCA1

The first six principal components explain 53.6% of the total variance in this dataset, which is considered a relatively low value. The samples were colored in a scatter plot of the first principal components according to their metadata (resistance class, sample origin, and year). The analysis shows no clear separation between resistant (1) and non-resistant (0) samples. Similarly, no clear separation can be observed regarding sample origin or year.

DRIAMS-data_PCA2

This result indicates that the main sources of variability in the dataset do not correlate with the biological classification features. PCA, as a linear method, was unable to capture the complex, non-linear relationships in the data. This justifies the choice of a more complex model such as the Neural Network, which has the ability to recognize such non-linear patterns.

Neural Network (NN)


In this application example, the Neural Network was implemented in Keras/TensorFlow. A relatively simple Neural Network was chosen for the present classification problem. The input layer reflects the 6000 bins of the dataset. The subsequent hidden layers are fully connected (Dense) and uniformly use the ReLU activation function. Finally, a binary output layer decides whether antibiotic resistance is present or not. Here, the Softmax function was used as the activation function.

Model Structure

The Adam optimizer was used for training the network. Categorical cross-entropy was used as the loss function, as this function ideally measures the discrepancy between predicted probabilities and actual labels for binary classification problems. The metric to be maximized was accuracy, defined as the percentage of correctly predicted samples. The dataset was divided into 60% training data and 20% each for validation and test data. To ensure representativeness, a stratified split was performed, keeping the distribution of resistance classes, sample origins, and years equal across all three subsets.

Training of the network typically stopped after about 30 epochs if the loss function on the validation dataset did not improve for 10 epochs. This stopping criterion served to prevent overfitting of the NN to the dataset and thus increase its generalization ability.

Model Evaluation

After successful training of the Neural Network, inference was performed to classify the antibiotic resistance of the samples. The raw numerical outputs of the model were converted into interpretable labels: a prediction of 0 stood for the susceptible class (S) and 1 for the resistant class (R).

After evaluation, the accuracy values were as follows:

  • Training data: Accuracy of 0.97 with a loss of 0.10
  • Validation data: Accuracy of 0.91 with a loss of 0.28
  • Test data: Accuracy of 0.92 with a loss of 0.24

Using this simple Neural Network, approximately 92% of the test samples could be correctly predicted. These high probabilites of correctly classifying samples underlines the potential of MALDI-TOF data to be used in practice for resistance classification. This could significantly improve the treatment of infections in clinical and animal health settings.

Conclusion and Outlook


This application example demonstrates the feasibility and potential of Machine Learning for the rapid and precise classification of antibiotic resistances based on MALDI-TOF mass spectrometry data. The integration of these technologies into routine diagnostics could enable faster and more targeted therapy and thus make an important contribution to the fight against antimicrobial resistance.

References


  1. [1] K. Asakura et al.: Rapid and easy detection of low-level resistance to vancomycin in methicillin-resistant Staphylococcus aureus by matrix-assisted laser desorption ionization time-of-flight mass spectrometry. In: PLoS ONE, 13(3):e0194212, 2018. doi: 10.1371/journal.pone.0194212
  2. [2] H.-Y. Wang et al.: Efficiently Predicting Vancomycin Resistance of Enterococcus Faecium From MALDI-TOF MS Spectra Using a Deep Learning-Based Approach. In: Front. Microbiol., 13:821233, 2022. doi: 10.3389/fmicb.2022.821233
  3. [3] C. Weis et al.: Direct antimicrobial resistance prediction from clinical MALDI-TOF mass spectra using machine learning. In: Nat. Med., 28:164–174, 2022. doi: 10.1038/s41591-021-01619-9