Health and life sciences

Machine learning for microbiologists

Microbiologists use machine learning to predict antimicrobial resistance from bacterial genomes, classify microbial communities from sequencing data, and model growth or response from assay measurements. Laboratory susceptibility testing provides the labels and the independent check.

How microbiologists use machine learning

Predicting resistance from bacterial genomes

A model learns which genes or variants are present in sequenced isolates and predicts the laboratory susceptibility result. Features are usually presence and absence of genes, with population structure kept as a covariate.

Real exampleResistance prediction in E. coli (Moradigaravand et al., 2018)Predicted antibiotic resistance from whole genome sequencing data for E. coli using gene presence and absence, population structure and isolation year, reporting average precision of 0.92 and recall of 0.83 in that study.

Predicting resistance from mass spectra

Routine identification spectra already collected in clinical microbiology laboratories can be used as model inputs, which avoids waiting for culture-based testing. The labels come from linked susceptibility phenotypes.

Real exampleResistance from MALDI-TOF spectra (Weis et al., 2022)Trained classifiers on a public database combining more than 300,000 mass spectra with more than 750,000 antimicrobial resistance phenotypes from four medical institutions, reporting areas under the ROC curve of 0.80, 0.74 and 0.74 for S. aureus, E. coli and K. pneumoniae.

Linking microbial communities to a phenotype

Metagenomic profiles give relative abundances of many taxa, and classifiers learn which combinations separate groups. The hard part is showing the model transfers to a cohort it was not trained on.

Real exampleMetagenomic meta-analysis (Pasolli et al., 2016)Assessed metagenomics-based prediction across 2424 samples from eight studies and six diseases, comparing strategies and testing how well models generalise between cohorts.

Finding new antibacterial compounds

Graph neural networks trained on compounds tested for antibacterial activity rank libraries that have never been screened, and explanation methods point to the substructures behind each prediction. The shortlist is then tested in the laboratory.

Real exampleExplainable deep learning for antibiotics (Wong et al., 2024)Measured antibiotic activity and human cell cytotoxicity for 39,312 compounds, predicted both for over 12 million compounds with graph neural networks, and used explainable algorithms to identify substructure rationales that were then tested empirically.

Can microbiologists learn machine learning?

Yes. Microbiologists are well placed because they own the isolates, the assays and the labels that any model needs. Learn Python and data handling, then statistics for compositional and imbalanced data, then classical machine learning, adding deep learning only when sequence or image models are called for.

  1. Python and sequence data handlingScript the steps you now do by hand: parse genome annotations, build gene presence and absence tables, and join them to susceptibility results.Learn it in Python
  2. Statistics for microbial dataLearn compositional data analysis, class imbalance and confidence intervals, since community counts are relative and resistant isolates are often rare.Learn it in Statistics
  3. Classical machine learningFit logistic regression and random forests on genome or abundance features, and validate across strains, studies and batches rather than random rows.Learn it in Machine Learning
  4. InterpretationCheck which features drive predictions and compare them with known resistance mechanisms, so a model does not simply learn the sampling site.
  5. Deep learning when it fitsAdd neural networks for raw sequence, spectra or colony images once a simple model has set the baseline.Learn it in Deep Learning

Moving from microbiology into machine learning

If you already work in the field

Microbiologists already have isolates, protocols and curated phenotypes, which is the scarcest part of any project. Add Python and model evaluation, then build a resistance or growth model on your own collection and test it on isolates gathered later or from another site.

If you come from data science or ML

Data scientists should learn how isolates are cultured, how susceptibility is measured and why closely related strains make random splits meaningless. Work on public genome collections, and ask a microbiologist to review which features the model relies on.

Roles that do this workClinical microbiology bioinformaticianComputational microbiologistBioinformatics scientistData scientist, infectious disease research

Tools you will use

ToolWhat you use it for
AMRFinderPlusIdentify antimicrobial resistance genes and point mutations in bacterial genome assemblies.
QIIME 2Process amplicon sequencing reads into feature tables and taxonomy for microbiome studies.
scikit-bioCompute diversity metrics, distances and compositional transforms on microbial count tables.
scikit-learnTrain and cross-validate resistance and community classifiers with grouped splits.

Public data to practise on

Your first project

Download E. coli isolates with ciprofloxacin results from the NCBI AST Browser, predict resistance from AMRFinderPlus gene and mutation calls with logistic regression, and compare it with a rule that flags any known quinolone resistance determinant using balanced accuracy.

Common questions

Can machine learning replace susceptibility testing?

No. Published work is research into faster prediction, and culture-based testing remains the reference standard that produces the labels these models are trained and judged against.

Why not split genome data randomly?

Isolates from the same outbreak or lineage share nearly all their genome, so random splits put near-duplicates in training and test sets. Split by lineage, study or collection date instead.

What is the smallest useful project?

Take a public set of sequenced isolates with susceptibility labels, build a gene presence and absence table, and compare logistic regression with a random forest on a lineage-aware split.

Do you need a cluster for this work?

Assembly and annotation benefit from a server, but the modelling itself usually runs on a laptop once genomes are summarised into feature tables.

Courses for these skills

New to programming or maths? Start with Python, or follow the machine learning path in order. Published lessons are free to read; compare Free and Pro.