our_data_1st%>%
-select(date, aminoglycosides())
+select(date, aminoglycosides())#> ℹ For aminoglycosides() using column 'GEN' (gentamicin)#> # A tibble: 2,724 × 2#> date GEN
@@ -537,7 +537,7 @@ in:
#> # ℹ 2,714 more rowsour_data_1st%>%
-select(bacteria, betalactams())
+select(bacteria, betalactams())#> ℹ For betalactams() using columns 'AMX' (amoxicillin) and 'AMC'#> (amoxicillin/clavulanic acid)#> # A tibble: 2,724 × 3
@@ -574,7 +574,7 @@ in:
# filtering using AB selectors is also possible:our_data_1st%>%
-filter(any(aminoglycosides()=="R"))
+filter(any(aminoglycosides()=="R"))#> ℹ For aminoglycosides() using column 'GEN' (gentamicin)#> # A tibble: 981 × 9#> patient_id hospital date bacteria AMX AMC CIP GEN first
@@ -592,7 +592,7 @@ in:
#> # ℹ 971 more rowsour_data_1st%>%
-filter(all(betalactams()=="R"))
+filter(all(betalactams()=="R"))#> ℹ For betalactams() using columns 'AMX' (amoxicillin) and 'AMC'#> (amoxicillin/clavulanic acid)#> # A tibble: 462 × 9
@@ -611,7 +611,7 @@ in:
#> # ℹ 452 more rows# even works in base R (since R 3.0):
-our_data_1st[all(betalactams()=="R"), ]
+our_data_1st[all(betalactams()=="R"), ]#> ℹ For betalactams() using columns 'AMX' (amoxicillin) and 'AMC'#> (amoxicillin/clavulanic acid)#> # A tibble: 462 × 9
@@ -693,7 +693,7 @@ should be used. The antibiotics argument in the
previously mentioned antibiotic class selectors:
antibiogram(example_isolates,
- antibiotics =c(aminoglycosides(), carbapenems()))
+ antibiotics =c(aminoglycosides(), carbapenems()))#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)#> ℹ For carbapenems() using columns 'IPM' (imipenem) and 'MEM' (meropenem)
@@ -821,7 +821,7 @@ language to be Spanish using the language argument:
antibiogram(example_isolates, mo_transform ="gramstain",
- antibiotics =aminoglycosides(),
+ antibiotics =aminoglycosides(), ab_transform ="name", language ="es")#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'
@@ -939,7 +939,7 @@ argument must be used. This can be any column in the data, or e.g. an
ifelse() with calculations based on certain columns:
antibiogram(example_isolates,
- antibiotics =c(aminoglycosides(), carbapenems()),
+ antibiotics =c(aminoglycosides(), carbapenems()), syndromic_group ="ward")#> ℹ For aminoglycosides() using columns 'GEN' (gentamicin), 'TOB'#> (tobramycin), 'AMK' (amikacin), and 'KAN' (kanamycin)
diff --git a/articles/AMR_for_Python.html b/articles/AMR_for_Python.html
index b72bb965f..8da38e7bc 100644
--- a/articles/AMR_for_Python.html
+++ b/articles/AMR_for_Python.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/AMR_with_tidymodels.html b/articles/AMR_with_tidymodels.html
index 3fc58d16d..40ae9c1ba 100644
--- a/articles/AMR_with_tidymodels.html
+++ b/articles/AMR_with_tidymodels.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
@@ -95,7 +95,7 @@ question about the AMR package.
understanding resistance patterns is crucial for managing effective
treatments. The AMR R package provides robust tools for
analysing AMR data, including convenient antibiotic selector functions
-like aminoglycosides() and betalactams(). In
+like aminoglycosides() and betalactams(). In
this post, we will explore how to use the tidymodels
framework to predict resistance patterns in the
example_isolates dataset.
@@ -112,7 +112,7 @@ antibiotic classes: aminoglycosides and beta-lactams.
microorganism based on microbial data. We will:
Define a logistic regression model for prediction.
Use a structured tidymodels workflow to preprocess,
train, and evaluate the model.
@@ -142,7 +142,7 @@ package.
#> ✖dplyr::filter() masks stats::filter()#> ✖dplyr::lag() masks stats::lag()#> ✖recipes::step() masks stats::step()
-#> • Dig deeper into tidy modeling with R at https://www.tmwr.org
+#> • Search for functions across packages at https://www.tidymodels.org/find/library(AMR)# For AMR data analysis# Load the example_isolates dataset
@@ -151,7 +151,7 @@ package.
# Select relevant columns for predictiondata<-example_isolates%>%# select AB results dynamically
-select(mo, aminoglycosides(), betalactams())%>%
+select(mo, aminoglycosides(), betalactams())%>%# replace NAs with NI (not-interpretable)mutate(across(where(is.sir),~replace_na(.x, "NI")),
@@ -173,7 +173,7 @@ package.
drop_na() ensures the model receives complete cases for
@@ -193,7 +193,7 @@ three steps: preprocessing, model specification, and fitting.
# Define the recipe for data preprocessingresistance_recipe<-recipe(mo~., data =data)%>%
-step_corr(c(aminoglycosides(), betalactams()), threshold =0.9)
+step_corr(c(aminoglycosides(), betalactams()), threshold =0.9)resistance_recipe#> #> ──Recipe──────────────────────────────────────────────────────────────────────
@@ -355,7 +355,7 @@ antibiotics. The ROC curve looks like this:
In this post, we demonstrated how to build a machine learning
pipeline with the tidymodels framework and the
AMR package. By combining selector functions like
-aminoglycosides() and betalactams() with
+aminoglycosides() and betalactams() with
tidymodels, we efficiently prepared data, trained a model,
and evaluated its performance.
This workflow is extensible to other antibiotic classes and
diff --git a/articles/EUCAST.html b/articles/EUCAST.html
index 5c6988472..48d3c8db6 100644
--- a/articles/EUCAST.html
+++ b/articles/EUCAST.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/MDR.html b/articles/MDR.html
index e5ea5a0b7..79f7560a5 100644
--- a/articles/MDR.html
+++ b/articles/MDR.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/PCA.html b/articles/PCA.html
index 3b9a3c46e..efcfa5406 100644
--- a/articles/PCA.html
+++ b/articles/PCA.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/WHONET.html b/articles/WHONET.html
index 44849d34d..d87976f39 100644
--- a/articles/WHONET.html
+++ b/articles/WHONET.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/datasets.html b/articles/datasets.html
index 05b2d0e35..000c02741 100644
--- a/articles/datasets.html
+++ b/articles/datasets.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/index.html b/articles/index.html
index 36f49a6a4..c07704743 100644
--- a/articles/index.html
+++ b/articles/index.html
@@ -7,7 +7,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/resistance_predict.html b/articles/resistance_predict.html
index 00773a955..5cc30a1c4 100644
--- a/articles/resistance_predict.html
+++ b/articles/resistance_predict.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/articles/welcome_to_AMR.html b/articles/welcome_to_AMR.html
index 173f594b6..fb534aa28 100644
--- a/articles/welcome_to_AMR.html
+++ b/articles/welcome_to_AMR.html
@@ -31,7 +31,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/authors.html b/authors.html
index f20a6eb89..cc37dcca8 100644
--- a/authors.html
+++ b/authors.html
@@ -7,7 +7,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
diff --git a/index.html b/index.html
index 6c5c4e595..11e055f91 100644
--- a/index.html
+++ b/index.html
@@ -34,7 +34,7 @@
AMR (for R)
- 2.1.1.9150
+ 2.1.1.9151
@@ -127,7 +127,7 @@
Filtering and selecting data
-
One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called antimicrobial class selectors, which work in base R, dplyr and data.table:
+
One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called antimicrobial selectors, which work in base R, dplyr and data.table.
This base R code will work in any version of R since April 2013 (R-3.0). Moreover, this code works identically with the data.table package, only by starting with:
Like many other functions in this package, antibiogram() comes with support for 20 languages that are often detected automatically based on system language:
-
+
antibiogram(example_isolates, antibiotics =c("cipro", "tobra", "genta"), # any arbitrary name or code will work mo_transform ="gramstain", ab_transform ="name", language ="uk")# Ukrainian
-
-
-
-
-
-
Збудник
Гентаміцин
@@ -433,24 +417,57 @@
Грамнегативні
-
96% (659/684)
-
96% (658/686)
-
91% (621/684)
+
96% (95-98%)
+
96% (94-97%)
+
91% (88-93%)
Грампозитивні
-
63% (740/1170)
-
34% (228/665)
-
77% (560/724)
+
63% (60-66%)
+
34% (31-38%)
+
77% (74-80%)
+
Interpreting and plotting MIC and SIR values
+
+
The AMR package allows interpretation of MIC and disk diffusion values based on CLSI and EUCAST. Moreover, the ggplot2 package is extended with new scale functions, to allow plotting of log2-distributed MIC values and SIR values.
+
+library(ggplot2)
+library(AMR)
+
+# generate some random values
+some_mic_values<-random_mic(size =100)
+some_groups<-sample(LETTERS[1:5], 20, replace =TRUE)
+interpretation<-as.sir(some_mic_values,
+ guideline ="EUCAST 2024",
+ mo ="E. coli", # or any code or name resembling a known species
+ ab ="Cipro")# or any code or name resembling an antibiotic
+
+# create the plot
+ggplot(data.frame(mic =some_mic_values,
+ group =some_groups,
+ sir =interpretation),
+aes(x =group, y =mic, colour =sir))+
+theme_minimal()+
+geom_boxplot(fill =NA, colour ="grey")+
+geom_jitter(width =0.25)+
+
+# NEW scale function: plot MIC values to x, y, colour or fill
+scale_y_mic()+
+
+# NEW scale function: write out S/I/R in any of the 20 supported languages
+# and set colourblind-friendly colours
+scale_colour_sir()
+
+
+
Calculating resistance per group
For a manual approach, you can use the resistance or susceptibility() function:
It will be downloaded and installed automatically. For RStudio, click on the menu Tools > Install Packages… and then type in “AMR” and press Install.
Note: Not all functions on this website may be available in this latest release. To use all functions and data sets mentioned on this website, install the latest development version.
@@ -680,13 +697,13 @@
Manually, using:
-
+
install.packages("remotes")# if you haven't alreadyremotes::install_github("msberends/AMR")
After this, you can install and update this AMR package like any official release (e.g., using install.packages("AMR") or in RStudio via Tools > Check for Package Updates…).
(this beta version will eventually become v3.0. We’re happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using the instructions here.)
-
A New Milestone: AMR v3.0 with One Health Support (= Human + Veterinary + Environmental)
+
A New Milestone: AMR v3.0 with One Health Support (= Human + Veterinary + Environmental)
This package now supports not only tools for AMR data analysis in clinical settings, but also for veterinary and environmental microbiology. This was made possible through a collaboration with the University of Prince Edward Island’s Atlantic Veterinary College, Canada. To celebrate this great improvement of the package, we also updated the package logo to reflect this change.
-
Breaking
+
Breaking
Removed all functions and references that used the deprecated rsi class, which were all replaced with their sir equivalents two years ago
-
New
+
New
One Health implementation
Function as.sir() now has extensive support for veterinary breakpoints from CLSI. Use breakpoint_type = "animal" and set the host argument to a variable that contains animal species names.
@@ -101,7 +101,7 @@
Support for tidymodels
-
All antimicrobial selectors (such as aminoglycosides() and betalactams()) are now supported in tidymodels packages such as recipe and parsnip. See for more info our tutorial on using these AMR functions for predictive modelling.
+
All antimicrobial selectors (such as aminoglycosides() and betalactams()) are now supported in tidymodels packages such as recipe and parsnip. See for more info our tutorial on using these AMR functions for predictive modelling.
Other
@@ -110,7 +110,7 @@
-
Changed
+
Changed
SIR interpretation
It is now possible to use column names for argument ab, mo, and uti: as.sir(..., ab = "column1", mo = "column2", uti = "column3"). This greatly improves the flexibility for users.
Users can now set their own criteria (using regular expressions) as to what should be considered S, I, R, SDD, and NI.
@@ -124,19 +124,19 @@
The ab_transform argument now defaults to "name", displaying antibiotic column names instead of codes
‘Antibiotic selectors’ are now called ‘antimicrobial selectors’ since their scope is broader than just antibiotics. All documentation have been updated, and ab_class() and ab_selector() have been replaced with amr_class() and amr_selector(). The old functions are now deprecated and will be removed in a future version.
‘Antibiotic selectors’ are now called ‘antimicrobial selectors’ since their scope is broader than just antibiotics. All documentation have been updated, and ab_class() and ab_selector() have been replaced with amr_class() and amr_selector(). The old functions are now deprecated and will be removed in a future version.
When using antimicrobial selectors that exclude non-treatable drugs (such as gentamicin-high when using aminoglycosides()), the function now always returns a warning that these can be included using only_treatable = FALSE
+
When using antimicrobial selectors that exclude non-treatable drugs (such as gentamicin-high when using aminoglycosides()), the function now always returns a warning that these can be included using only_treatable = FALSE
Added a new argument return_all to all selectors, which defaults to TRUE to include any match. With FALSE, the old behaviour, only the first hit for each unique antimicrobial is returned.
All selectors can now be run as a separate command to retrieve a vector of all possible antimicrobials that the selector can select
-
The selectors lincosamides() and macrolides() do not overlap anymore - each antibiotic is now classified as either of these and not both
+
The selectors lincosamides() and macrolides() do not overlap anymore - each antibiotic is now classified as either of these and not both
antibiotics data set
-
Added “clindamycin inducible screening” as CLI1. Since clindamycin is a lincosamide, the antimicrobial selector lincosamides() now contains the argument only_treatable = TRUE (similar to other antibiotic selectors that contain non-treatable drugs)
-
Added Amorolfine (AMO, D01AE16), which is now also part of the antifungals() selector
+
Added “clindamycin inducible screening” as CLI1. Since clindamycin is a lincosamide, the antimicrobial selector lincosamides() now contains the argument only_treatable = TRUE (similar to other antibiotic selectors that contain non-treatable drugs)
+
Added Amorolfine (AMO, D01AE16), which is now also part of the antifungals() selector
Added Efflux (EFF), to allow mapping to AMRFinderPlus
Added Tigemonam (TNM), a monobactam
@@ -179,7 +179,7 @@
Added console colours support of sir class for Positron
-
Other
+
Other
Added Dr. Larisse Bolton as contributor for her fantastic implementation of WISCA in a mathematically solid way
Added Matthew Saab, Dr. Jordan Stull, and Prof. Javier Sanchez as contributors for their tremendous input on veterinary breakpoints and interpretations
Greatly improved vctrs integration, a Tidyverse package working in the background for many Tidyverse functions. For users, this means that functions such as dplyr’s bind_rows(), rowwise() and c_across() are now supported for e.g. columns of class mic. Despite this, this AMR package is still zero-dependent on any other package, including dplyr and vctrs.
@@ -187,7 +187,7 @@
Stopped support for SAS (.xpt) files, since their file structure and extremely inefficient and requires more disk space than GitHub allows in a single commit.
-
Older Versions
+
Older Versions
This changelog only contains changes from AMR v3.0 (February 2025) and later.