Skip to contents

Overview

AMRgen

AMRgen is an open-source R package designed to bridge the gap between genotypic and phenotypic antimicrobial resistance (AMR) data. Developed as an extension to the AMR R package, it provides tools to interpret AMR genes, integrate these findings with antimicrobial susceptibility test (AST) data, and calculate genotype-phenotype associations.

This package is developed in collaboration with the ESGEM-AMR Working Group and is tailored for researchers and healthcare professionals tackling AMR globally.

The AMRgen website has full function documentation and a Vignette working through analysing geno/pheno data using key functions.


Key Features

  • Import Genotype and Phenotype Data: Import from common formats (NCBI or EBI antibiogram format for phenotypes; AMRFinderPlus and hAMRonization for genotypes
  • Genotype-Phenotype Integration: Links AMR gene presence with phenotypic resistance profiles, enabling deeper insights into resistance mechanisms.
  • Automated EUCAST MIC Distribution Integration: Fetch MIC distribution data directly from EUCAST for seamless comparison with local susceptibility data.
  • Visualisation: Generate powerful UpSet plots to identify intersections of AMR gene presence and phenotypic resistance, highlighting multidrug resistance patterns.
  • Modular and Extensible: Leverages the robust foundation of the AMR package, including antibiotic selectors and clinical breakpoint interpretations.

Planned for development:

  • NCBI-Compliant Export: Export phenotype data to NCBI-compliant antibiogram format.
  • Expanded Data Import: Import and parse phenotype data from other tools (e.g. CARD, ResFinder).

Getting Started

To install and explore the package, follow the instructions below:

Installation

It is best to restart R before running the installation to prevent issues.

Install the latest version of this package with:

install.packages("remotes") # if you haven't already
remotes::install_github("AMRverse/AMRgen")

All required packages, including the AMR package if you don’t have it already, will be installed automatically.

If you have issues, we recommend you install the latest version of the AMR package directly, then try again to install AMRgen:

install.packages("remotes") # if you haven't already
remotes::install_github("msberends/AMR")
remotes::install_github("AMRverse/AMRgen")

If you still have trouble with installation please post an issue here! The package is new and we want to make it as accessible as possible for new users.

Quick Usage Examples

Investigate ciprofloxacin resistance vs quinolone genotype markers, via solo PPV and upset plots

# Example public E. coli AST data from NCBI
#  (already imported via import_ncbi_ast() and re-interpreted with as.sir())
ecoli_ast

# Import matching E. coli AMRFinderPlus data from AllTheBacteria
ecoli_geno <- import_amrfp(ecoli_geno_raw, "Name")

# Calculate solo positive predictive value for ciprofloxacin resistance, for individual markers found solo
#  (for all quinolone-associated genotype markers)
soloPPV_cipro <- solo_ppv_analysis(ecoli_geno, ecoli_ast, antibiotic="Ciprofloxacin", drug_class_list=c("Quinolones"), sir_col="pheno_clsi")

# Do upset plot of ciprofloxacin MIC vs quinolone genotype marker combinations
#  (for combinations observed at least 5 times)
cip_upset <- amr_upset(binary_matrix=soloPPV_cipro$amr_binary, min_set_size=5, assay="mic")

# Calculate positive predictive value for individual markers and combinations
cip_ppv <- ppv(binary_matrix=soloPPV_cipro$amr_binary, min_set_size=5)

# Do logistic regression of ciprofloxacin resistance as a function of presence/absence of quinolone-associated markers
#  (for markers observed at least 10 times)
models <- amr_logistic(binary_matrix=soloPPV_cipro$amr_binary, maf=10)

Download reference MIC distribution from eucast.org and compare to example data

# Get MIC reference distribution for ciprofloxacin in E. coli
ecoli_cip_mic_data <- get_eucast_mic_distribution("cipro", "E. coli")

# Plot the reference distribution 
mics <- rep(ecoli_cip_mic_data$mic, ecoli_cip_mic_data$count)
ggplot2::autoplot(mics, ab = "cipro", mo = "E. coli", title = "E. coli cipro reference distribution")

# Compare reference distribution to example E. coli data
ecoli_cip <- ecoli_ast$mic[ecoli_ast$drug_agent=="CIP"]
comparison <- compare_mic_with_eucast(ecoli_cip, ab = "cipro", mo = "E. coli")
comparison
ggplot2::autoplot(comparison)

Download phenotype or genotype data from EBI’s AMR portal

# Get phenotype data for ciprofloxacin in E. coli
ebi_pheno_ecoli_cip <- download_ebi(species = "Escherichia coli", antibiotic="Cipro", reformat=T)

# Check how many observations we have for MIC data
ebi_pheno_ecoli_cip %>% filter(!is.na(mic)) %>% nrow()

# Plot MIC distribution, stratified by platform
assay_by_var(ebi_pheno_ecoli_cip, measure="mic", colour_by = "pheno_provided", facet_var = "platform")

# Compare MIC values with reference distribution from EUCAST
compare_mics <- compare_mic_with_eucast(ebi_pheno_ecoli_cip$mic, ab = "cipro", mo = "E. coli")
compare_mics
ggplot2::autoplot(compare_mics)

# Compare disk diffusion zone values with reference distribution from EUCAST
compare_disk <- compare_disk_with_eucast(ebi_pheno_ecoli_cip$disk, ab = "cipro", mo = "E. coli")
compare_disk
ggplot2::autoplot(compare_disk)

# Get genotype data for ciprofloxacin in E. coli
ebi_geno <- download_ebi(data="genotype", species = "Escherichia coli", geno_subclass="QUINOLONE", reformat=T)

# Do upset plot of ciprofloxacin MIC vs quinolone genotype marker combinations
#  (for combinations observed at least 5 times)
cip_upset_ebi_mic <- amr_upset(geno_table=ecoli_geno, pheno_table=ebi_pheno_ecoli_cip, antibiotic="Ciprofloxacin", drug_class_list=c("Quinolones"), sir_col="pheno_provided", min_set_size=5, assay="mic", order="value")

Download phenotype data from NCBI BioSample

# Get all available phenotype data for Klebsiella quasipneumoniae
# (note this is a small example with <100 samples, as this function queries NCBI BioSample via rentrez and is quite slow)
ast <- download_ncbi_ast(
  "Klebsiella quasipneumoniae",
  reformat = TRUE
)

# Plot MIC distribution, stratified by platform
assay_by_var(ast, measure="mic", colour_by = "pheno_provided", facet_var = "platform")

# The downloaded S/I/R calls look odd, so re-interpret direct with latest EUCAST breakpoints and review
ast <- interpret_ast(ast, interpret_eucast = T, interpret_clsi=T)
assay_by_var(ast, measure="mic", colour_by = "pheno_eucast", facet_var = "platform")
assay_by_var(ast, measure="mic", colour_by = "pheno_clsi", facet_var = "platform")

Import and export

# Import phenotype data in NCBI, EBI, Vitek, Sensititre, MicroScan, WHOnet formats
?import_ast

# Export phenotype data in NCBI or EBI formats
?export_ast

For more see the Vignette.

Contributions

Contributions are welcome! If you encounter issues or wish to suggest new features, please open an issue or submit a pull request.

Licence

This package is distributed under the GNU GPL-3.0 Licence. See LICENSE for details.