diff --git a/DESCRIPTION b/DESCRIPTION index 8f244607b..a9c7ba23f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 2.1.1.9230 -Date: 2025-03-28 +Version: 2.1.1.9231 +Date: 2025-03-29 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index f099af1da..ed703d661 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9230 +# AMR 2.1.1.9231 *(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](https://msberends.github.io/AMR/#latest-development-version).)* diff --git a/_pkgdown.yml b/_pkgdown.yml index 7457307f9..a33ea9097 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -94,7 +94,7 @@ navbar: - text: "Work with WHONET Data" icon: "fa-globe-americas" href: "articles/WHONET.html" - - text: "Apply Eucast Rules" + - text: "Apply EUCAST Rules" icon: "fa-exchange-alt" href: "articles/EUCAST.html" - text: "Get Taxonomy of a Microorganism" diff --git a/data-raw/gpt_training_text_v2.1.1.9230.txt b/data-raw/gpt_training_text_v2.1.1.9231.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9230.txt rename to data-raw/gpt_training_text_v2.1.1.9231.txt index fb77f69a1..7581903a3 100644 --- a/data-raw/gpt_training_text_v2.1.1.9230.txt +++ b/data-raw/gpt_training_text_v2.1.1.9231.txt @@ -1,6 +1,6 @@ This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. -First and foremost, you are trained on version 2.1.1.9230. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9231. Remember this whenever someone asks which AMR package version you’re at. Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens. ---------------------------------------------------------------------------------------------------- @@ -9277,12 +9277,12 @@ knitr::opts_chunk$set( > This page was entirely written by our [AMR for R Assistant](https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant), a ChatGPT manually-trained model able to answer any question about the AMR package. ---- +Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions 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 in two examples. ## Example 1: Using Antimicrobial Selectors -Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions 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. - By leveraging the power of `tidymodels` and the `AMR` package, we’ll build a reproducible machine learning workflow to predict the Gramstain of the microorganism to two important antibiotic classes: aminoglycosides and beta-lactams. ### **Objective** @@ -9582,9 +9582,9 @@ metrics_time - `predict()`: Generates resistance predictions. - `metrics()`: Evaluates model performance. -### **Visualizing Predictions** +### **Visualising Predictions** -We plot resistance trends over time for Amoxicillin. +We plot resistance trends over time for amoxicillin. ```{r} library(ggplot2) @@ -9599,7 +9599,7 @@ ggplot(predictions_time, aes(x = year)) + theme_minimal() ``` -Additionally, we can visualise resistance trends in `ggplot2` and directly adding linear models there: +Additionally, we can visualise resistance trends in `ggplot2` and directly add linear models there: ```{r} ggplot(data_time, aes(x = year, y = res_AMX, color = gramstain)) + @@ -9652,51 +9652,49 @@ library(AMR) ## Introduction -What are EUCAST rules? The European Committee on Antimicrobial Susceptibility Testing (EUCAST) states [on their website](https://www.eucast.org/expert_rules_and_intrinsic_resistance/): +What are EUCAST rules? The European Committee on Antimicrobial Susceptibility Testing (EUCAST) states [on their website](https://www.eucast.org/expert_rules_and_expected_phenotypes): -> *EUCAST expert rules are a tabulated collection of expert knowledge on intrinsic resistances, exceptional resistance phenotypes and interpretive rules that may be applied to antimicrobial susceptibility testing in order to reduce errors and make appropriate recommendations for reporting particular resistances.* +> *EUCAST expert rules (see below) are a tabulated collection of expert knowledge on interpretive rules, expected resistant phenotypes and expected susceptible phenotypes which should be applied to antimicrobial susceptibility testing in order to reduce testing, reduce errors and make appropriate recommendations for reporting particular resistances.* -In Europe, a lot of medical microbiological laboratories already apply these rules ([Brown *et al.*, 2015](https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008)). Our package features their latest insights on intrinsic resistance and unusual phenotypes (`r AMR:::EUCAST_VERSION_EXPERT_RULES[[length(AMR:::EUCAST_VERSION_EXPERT_RULES)]]$version_txt`, `r AMR:::EUCAST_VERSION_EXPERT_RULES[[length(AMR:::EUCAST_VERSION_EXPERT_RULES)]]$year`). - -Moreover, the `eucast_rules()` function we use for this purpose can also apply additional rules, like forcing ampicillin = R in isolates when amoxicillin/clavulanic acid = R. +In Europe, a lot of medical microbiological laboratories already apply these rules ([Brown *et al.*, 2015](https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008)). Our package features their latest insights on expected resistant phenotypes (`r AMR:::EUCAST_VERSION_EXPECTED_PHENOTYPES[[1]]$version_txt`, `r AMR:::EUCAST_VERSION_EXPECTED_PHENOTYPES[[1]]$year`). ## Examples -These rules can be used to discard impossible bug-drug combinations in your data. For example, *Klebsiella* produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of *Klebsiella* is resistant to ampicillin. +These rules can be used to discard improbable bug-drug combinations in your data. For example, *Klebsiella* produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of *Klebsiella* is resistant to ampicillin. -Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, *Klebsiella*). EUCAST expert rules solve this, that can be applied using `eucast_rules()`: +Sometimes, laboratory data can still contain such strains with *Klebsiella* being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification. The `eucast_rules()` function resolves this, by applying the latest `r AMR:::EUCAST_VERSION_EXPECTED_PHENOTYPES[[1]]$title` guideline: ```{r, warning = FALSE, message = FALSE} -oops <- data.frame( +oops <- tibble::tibble( mo = c( - "Klebsiella", - "Escherichia" + "Klebsiella pneumoniae", + "Escherichia coli" ), - ampicillin = "S" + ampicillin = as.sir("S") ) oops -eucast_rules(oops, info = FALSE) +eucast_rules(oops, info = FALSE, overwrite = TRUE) ``` A more convenient function is `mo_is_intrinsic_resistant()` that uses the same guideline, but allows to check for one or more specific microorganisms or antimicrobials: ```{r, warning = FALSE, message = FALSE} mo_is_intrinsic_resistant( - c("Klebsiella", "Escherichia"), + c("Klebsiella pneumoniae", "Escherichia coli"), "ampicillin" ) mo_is_intrinsic_resistant( - "Klebsiella", + "Klebsiella pneumoniae", c("ampicillin", "kanamycin") ) ``` -EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called *interpretive reading*, is basically a form of imputation, and is part of the `eucast_rules()` function as well: +EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called *interpretive reading*, and is basically a form of imputation: ```{r, warning = FALSE, message = FALSE} -data <- data.frame( +data <- tibble::tibble( mo = c( "Staphylococcus aureus", "Enterococcus faecalis", @@ -9710,8 +9708,7 @@ data <- data.frame( CAZ = "-", # Ceftazidime CXM = "-", # Cefuroxime PEN = "S", # Benzylenicillin - FOX = "S", # Cefoxitin - stringsAsFactors = FALSE + FOX = "S" # Cefoxitin ) ``` ```{r, eval = FALSE} @@ -9721,10 +9718,10 @@ data knitr::kable(data, align = "lccccccc") ``` ```{r, warning = FALSE, eval = FALSE} -eucast_rules(data) +eucast_rules(data, overwrite = TRUE) ``` ```{r, warning = FALSE, echo = FALSE, message = FALSE} -knitr::kable(eucast_rules(data), align = "lccccccc") +knitr::kable(eucast_rules(data, overwrite = TRUE), align = "lccccccc") ``` diff --git a/vignettes/AMR_with_tidymodels.Rmd b/vignettes/AMR_with_tidymodels.Rmd index be67713fe..15c33b958 100644 --- a/vignettes/AMR_with_tidymodels.Rmd +++ b/vignettes/AMR_with_tidymodels.Rmd @@ -24,12 +24,12 @@ knitr::opts_chunk$set( > This page was entirely written by our [AMR for R Assistant](https://chatgpt.com/g/g-M4UNLwFi5-amr-for-r-assistant), a ChatGPT manually-trained model able to answer any question about the AMR package. ---- +Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions 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 in two examples. ## Example 1: Using Antimicrobial Selectors -Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions 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. - By leveraging the power of `tidymodels` and the `AMR` package, we’ll build a reproducible machine learning workflow to predict the Gramstain of the microorganism to two important antibiotic classes: aminoglycosides and beta-lactams. ### **Objective** @@ -329,9 +329,9 @@ metrics_time - `predict()`: Generates resistance predictions. - `metrics()`: Evaluates model performance. -### **Visualizing Predictions** +### **Visualising Predictions** -We plot resistance trends over time for Amoxicillin. +We plot resistance trends over time for amoxicillin. ```{r} library(ggplot2) @@ -346,7 +346,7 @@ ggplot(predictions_time, aes(x = year)) + theme_minimal() ``` -Additionally, we can visualise resistance trends in `ggplot2` and directly adding linear models there: +Additionally, we can visualise resistance trends in `ggplot2` and directly add linear models there: ```{r} ggplot(data_time, aes(x = year, y = res_AMX, color = gramstain)) + diff --git a/vignettes/EUCAST.Rmd b/vignettes/EUCAST.Rmd index 87b0c2a0a..e6fea7c7a 100644 --- a/vignettes/EUCAST.Rmd +++ b/vignettes/EUCAST.Rmd @@ -24,51 +24,49 @@ library(AMR) ## Introduction -What are EUCAST rules? The European Committee on Antimicrobial Susceptibility Testing (EUCAST) states [on their website](https://www.eucast.org/expert_rules_and_intrinsic_resistance/): +What are EUCAST rules? The European Committee on Antimicrobial Susceptibility Testing (EUCAST) states [on their website](https://www.eucast.org/expert_rules_and_expected_phenotypes): -> *EUCAST expert rules are a tabulated collection of expert knowledge on intrinsic resistances, exceptional resistance phenotypes and interpretive rules that may be applied to antimicrobial susceptibility testing in order to reduce errors and make appropriate recommendations for reporting particular resistances.* +> *EUCAST expert rules (see below) are a tabulated collection of expert knowledge on interpretive rules, expected resistant phenotypes and expected susceptible phenotypes which should be applied to antimicrobial susceptibility testing in order to reduce testing, reduce errors and make appropriate recommendations for reporting particular resistances.* -In Europe, a lot of medical microbiological laboratories already apply these rules ([Brown *et al.*, 2015](https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008)). Our package features their latest insights on intrinsic resistance and unusual phenotypes (`r AMR:::EUCAST_VERSION_EXPERT_RULES[[length(AMR:::EUCAST_VERSION_EXPERT_RULES)]]$version_txt`, `r AMR:::EUCAST_VERSION_EXPERT_RULES[[length(AMR:::EUCAST_VERSION_EXPERT_RULES)]]$year`). - -Moreover, the `eucast_rules()` function we use for this purpose can also apply additional rules, like forcing ampicillin = R in isolates when amoxicillin/clavulanic acid = R. +In Europe, a lot of medical microbiological laboratories already apply these rules ([Brown *et al.*, 2015](https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008)). Our package features their latest insights on expected resistant phenotypes (`r AMR:::EUCAST_VERSION_EXPECTED_PHENOTYPES[[1]]$version_txt`, `r AMR:::EUCAST_VERSION_EXPECTED_PHENOTYPES[[1]]$year`). ## Examples -These rules can be used to discard impossible bug-drug combinations in your data. For example, *Klebsiella* produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of *Klebsiella* is resistant to ampicillin. +These rules can be used to discard improbable bug-drug combinations in your data. For example, *Klebsiella* produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of *Klebsiella* is resistant to ampicillin. -Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, *Klebsiella*). EUCAST expert rules solve this, that can be applied using `eucast_rules()`: +Sometimes, laboratory data can still contain such strains with *Klebsiella* being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification. The `eucast_rules()` function resolves this, by applying the latest `r AMR:::EUCAST_VERSION_EXPECTED_PHENOTYPES[[1]]$title` guideline: ```{r, warning = FALSE, message = FALSE} -oops <- data.frame( +oops <- tibble::tibble( mo = c( - "Klebsiella", - "Escherichia" + "Klebsiella pneumoniae", + "Escherichia coli" ), - ampicillin = "S" + ampicillin = as.sir("S") ) oops -eucast_rules(oops, info = FALSE) +eucast_rules(oops, info = FALSE, overwrite = TRUE) ``` A more convenient function is `mo_is_intrinsic_resistant()` that uses the same guideline, but allows to check for one or more specific microorganisms or antimicrobials: ```{r, warning = FALSE, message = FALSE} mo_is_intrinsic_resistant( - c("Klebsiella", "Escherichia"), + c("Klebsiella pneumoniae", "Escherichia coli"), "ampicillin" ) mo_is_intrinsic_resistant( - "Klebsiella", + "Klebsiella pneumoniae", c("ampicillin", "kanamycin") ) ``` -EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called *interpretive reading*, is basically a form of imputation, and is part of the `eucast_rules()` function as well: +EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called *interpretive reading*, and is basically a form of imputation: ```{r, warning = FALSE, message = FALSE} -data <- data.frame( +data <- tibble::tibble( mo = c( "Staphylococcus aureus", "Enterococcus faecalis", @@ -82,8 +80,7 @@ data <- data.frame( CAZ = "-", # Ceftazidime CXM = "-", # Cefuroxime PEN = "S", # Benzylenicillin - FOX = "S", # Cefoxitin - stringsAsFactors = FALSE + FOX = "S" # Cefoxitin ) ``` ```{r, eval = FALSE} @@ -93,8 +90,8 @@ data knitr::kable(data, align = "lccccccc") ``` ```{r, warning = FALSE, eval = FALSE} -eucast_rules(data) +eucast_rules(data, overwrite = TRUE) ``` ```{r, warning = FALSE, echo = FALSE, message = FALSE} -knitr::kable(eucast_rules(data), align = "lccccccc") +knitr::kable(eucast_rules(data, overwrite = TRUE), align = "lccccccc") ```