diff --git a/DESCRIPTION b/DESCRIPTION index 21ee5516..85f4fffb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.8.1.9008 -Date: 2022-05-11 +Version: 1.8.1.9009 +Date: 2022-05-16 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 c1ded113..ee9b6b3a 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.8.1.9008 -## Last updated: 11 mei 2022 +# `AMR` 1.8.1.9009 +## Last updated: 16 May 2022 ### New * EUCAST 2022 and CLSI 2022 guidelines have been added for `as.rsi()`. EUCAST 2022 is now the new default guideline for all MIC and disks diffusion interpretations. @@ -10,6 +10,7 @@ * `droplevels()` on MIC will now return a common `factor` at default and will lose the `` class. Use `droplevels(..., as.mic = TRUE)` to keep the `` class. * Small fix for using `ab_from_text()` * Fixes for reading in text files using `set_mo_source()`, which now also allows the source file to contain valid taxonomic names instead of only valid microorganism ID of this package +* Using any `random_*()` function (such as `random_mic()`) is now possible by directly calling the package without loading it first: `AMR::random_mic(10)` # `AMR` 1.8.1 diff --git a/R/data.R b/R/data.R index 971d3f12..9e91c6a0 100755 --- a/R/data.R +++ b/R/data.R @@ -251,7 +251,14 @@ #' - `breakpoint_S`\cr Lowest MIC value or highest number of millimetres that leads to "S" #' - `breakpoint_R`\cr Highest MIC value or lowest number of millimetres that leads to "R" #' - `uti`\cr A [logical] value (`TRUE`/`FALSE`) to indicate whether the rule applies to a urinary tract infection (UTI) -#' @details The repository of this `AMR` package contains a file comprising this exact data set: . This file **allows for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically and the `mo` and `ab` columns have been transformed to contain the full official names instead of codes. +#' @details +#' Overview of the data set: +#' +#' ```{r} +#' head(rsi_translation) +#' ``` +#' +#' The repository of this `AMR` package contains a file comprising this exact data set: . This file **allows for machine reading EUCAST and CLSI guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically and the `mo` and `ab` columns have been transformed to contain the full official names instead of codes. #' @inheritSection AMR Reference Data Publicly Available #' @inheritSection AMR Read more on Our Website! #' @seealso [intrinsic_resistant] diff --git a/R/random.R b/R/random.R index a10f1c45..cb8a64e5 100644 --- a/R/random.R +++ b/R/random.R @@ -34,7 +34,7 @@ #' @param ... ignored, only in place to allow future extensions #' @details The base \R function [sample()] is used for generating values. #' -#' Generated values are based on the latest EUCAST guideline implemented in the [rsi_translation] data set. To create specific generated values per bug or drug, set the `mo` and/or `ab` argument. +#' Generated values are based on the EUCAST `r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))` guideline as implemented in the [rsi_translation] data set. To create specific generated values per bug or drug, set the `mo` and/or `ab` argument. #' @return class `` for [random_mic()] (see [as.mic()]) and class `` for [random_disk()] (see [as.disk()]) #' @name random #' @rdname random @@ -89,6 +89,7 @@ random_rsi <- function(size = NULL, prob_RSI = c(0.33, 0.33, 0.33), ...) { } random_exec <- function(type, size, mo = NULL, ab = NULL) { + check_dataset_integrity() df <- rsi_translation %pm>% pm_filter(guideline %like% "EUCAST") %pm>% pm_arrange(pm_desc(guideline)) %pm>% diff --git a/R/rsi.R b/R/rsi.R index cb097f58..1b86ee7e 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -33,7 +33,7 @@ #' @param ab any (vector of) text that can be coerced to a valid antimicrobial code with [as.ab()] #' @param uti (Urinary Tract Infection) A vector with [logical]s (`TRUE` or `FALSE`) to specify whether a UTI specific interpretation from the guideline should be chosen. For using [as.rsi()] on a [data.frame], this can also be a column containing [logical]s or when left blank, the data set will be searched for a column 'specimen', and rows within this column containing 'urin' (such as 'urine', 'urina') will be regarded isolates from a UTI. See *Examples*. #' @inheritParams first_isolate -#' @param guideline defaults to the latest included EUCAST guideline, supports EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`), see *Details* +#' @param guideline defaults to EUCAST `r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))` (the latest implemented EUCAST guideline in the [rsi_translation] data set), supports EUCAST (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "EUCAST")$guideline)))`) and CLSI (`r min(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`-`r max(as.integer(gsub("[^0-9]", "", subset(rsi_translation, guideline %like% "CLSI")$guideline)))`), see *Details* #' @param conserve_capped_values a [logical] to indicate that MIC values starting with `">"` (but not `">="`) must always return "R" , and that MIC values starting with `"<"` (but not `"<="`) must always return "S" #' @param add_intrinsic_resistance *(only useful when using a EUCAST guideline)* a [logical] to indicate whether intrinsic antibiotic resistance must also be considered for applicable bug-drug combinations, meaning that e.g. ampicillin will always return "R" in *Klebsiella* species. Determination is based on the [intrinsic_resistant] data set, that itself is based on `r format_eucast_version_nr(3.3)`. #' @param reference_data a [data.frame] to be used for interpretation, which defaults to the [rsi_translation] data set. Changing this argument allows for using own interpretation guidelines. This argument must contain a data set that is equal in structure to the [rsi_translation] data set (same column names and column types). Please note that the `guideline` argument will be ignored when `reference_data` is manually set. diff --git a/R/sysdata.rda b/R/sysdata.rda index e8969779..7cae28f2 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 08007d7d..71b442fa 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/404.html b/docs/404.html index cc17e6e7..c87b28f2 100644 --- a/docs/404.html +++ b/docs/404.html @@ -43,7 +43,7 @@ AMR (for R) - 1.8.1.9008 + 1.8.1.9009 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index f38d68c5..4e5d23a5 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9008 + 1.8.1.9009 diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 406f7dd4..6061c91c 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -44,7 +44,7 @@ AMR (for R) - 1.8.1.9008 + 1.8.1.9009 @@ -190,7 +190,7 @@ diff --git a/docs/news/index.html b/docs/news/index.html index 17453146..48525451 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9008 + 1.8.1.9009 @@ -157,16 +157,16 @@
- +
-

Last updated: 11 mei 2022

+

Last updated: 16 May 2022

-

New

+

New

  • EUCAST 2022 and CLSI 2022 guidelines have been added for as.rsi(). EUCAST 2022 is now the new default guideline for all MIC and disks diffusion interpretations.
-

Changed

+

Changed

  • Fix for as.rsi() on certain EUCAST breakpoints for MIC values
  • Removed as.integer() for MIC values, since MIC are not integer values and running table() on MIC values consequently failed for not being able to retrieve the level position (as that’s how normally as.integer() on factors work)
  • @@ -174,6 +174,8 @@
  • Small fix for using ab_from_text()
  • Fixes for reading in text files using set_mo_source(), which now also allows the source file to contain valid taxonomic names instead of only valid microorganism ID of this package
  • +
  • Using any random_*() function (such as random_mic()) is now possible by directly calling the package without loading it first: AMR::random_mic(10) +
@@ -1693,7 +1695,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
 
 thousands_of_E_colis <- rep("E. coli", 25000)
-microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
+microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
 # Unit: seconds
 #         min       median         max  neval
 #  0.01817717  0.01843957  0.03878077    100
diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index 0c0a817e..9f2d429b 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9002 + 1.8.1.9009 diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index e5b3678d..288f1f68 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9007 + 1.8.1.9009 @@ -225,7 +225,7 @@
ab

any (vector of) text that can be coerced to a valid antimicrobial code with as.ab()

guideline
-

defaults to the latest included EUCAST guideline, supports EUCAST (2011-2022) and CLSI (2011-2022), see Details

+

defaults to EUCAST 2022 (the latest implemented EUCAST guideline in the rsi_translation data set), supports EUCAST (2011-2022) and CLSI (2011-2022), see Details

uti

(Urinary Tract Infection) A vector with logicals (TRUE or FALSE) to specify whether a UTI specific interpretation from the guideline should be chosen. For using as.rsi() on a data.frame, this can also be a column containing logicals or when left blank, the data set will be searched for a column 'specimen', and rows within this column containing 'urin' (such as 'urine', 'urina') will be regarded isolates from a UTI. See Examples.

conserve_capped_values
diff --git a/docs/reference/g.test.html b/docs/reference/g.test.html index b100a4ba..06f8aaa6 100644 --- a/docs/reference/g.test.html +++ b/docs/reference/g.test.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9007 + 1.8.1.9009 @@ -180,7 +180,7 @@

a numeric vector; ignored if x is a matrix. If x is a factor, y should be a factor of the same length.

p
-

a vector of probabilities of the same length of x. +

a vector of probabilities of the same length as x. An error is given if any entry of p is negative.

rescale.p

a logical scalar; if TRUE then p is rescaled diff --git a/docs/reference/index.html b/docs/reference/index.html index 86b39403..5b35de2c 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9007 + 1.8.1.9009 diff --git a/docs/reference/intrinsic_resistant.html b/docs/reference/intrinsic_resistant.html index 3fb0667a..0c288287 100644 --- a/docs/reference/intrinsic_resistant.html +++ b/docs/reference/intrinsic_resistant.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9002 + 1.8.1.9009 diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 07d1c156..a0388fdc 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9002 + 1.8.1.9009 diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index f99c6b87..82052174 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9002 + 1.8.1.9009 diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index af843bed..6398c3a6 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -18,7 +18,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p AMR (for R) - 1.8.1.9003 + 1.8.1.9009 diff --git a/docs/reference/random.html b/docs/reference/random.html index b0a630c6..72a9be45 100644 --- a/docs/reference/random.html +++ b/docs/reference/random.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9007 + 1.8.1.9009 @@ -189,7 +189,7 @@

Details

The base R function sample() is used for generating values.

-

Generated values are based on the latest EUCAST guideline implemented in the rsi_translation data set. To create specific generated values per bug or drug, set the mo and/or ab argument.

+

Generated values are based on the EUCAST 2022 guideline as implemented in the rsi_translation data set. To create specific generated values per bug or drug, set the mo and/or ab argument.

Stable Lifecycle

diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html index cf66d757..9bd589e0 100644 --- a/docs/reference/rsi_translation.html +++ b/docs/reference/rsi_translation.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9007 + 1.8.1.9009
@@ -181,7 +181,22 @@

Details

-

The repository of this AMR package contains a file comprising this exact data set: https://github.com/msberends/AMR/blob/main/data-raw/rsi_translation.txt. This file allows for machine reading EUCAST and CLSI guidelines, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically and the mo and ab columns have been transformed to contain the full official names instead of codes.

+

Overview of the data set:

head(rsi_translation)

##     guideline method site           mo rank_index  ab     ref_tbl disk_dose
+## 1 EUCAST 2022    MIC <NA> F_ASPRG_MGTS          2 AMB Aspergillus      <NA>
+## 2 EUCAST 2022    MIC <NA> F_ASPRG_NIGR          2 AMB Aspergillus      <NA>
+## 3 EUCAST 2022    MIC <NA>      F_CANDD          3 AMB     Candida      <NA>
+## 4 EUCAST 2022    MIC <NA> F_CANDD_ALBC          2 AMB     Candida      <NA>
+## 5 EUCAST 2022    MIC <NA> F_CANDD_DBLN          2 AMB     Candida      <NA>
+## 6 EUCAST 2022    MIC <NA> F_CANDD_KRUS          2 AMB     Candida      <NA>
+##   breakpoint_S breakpoint_R   uti
+## 1            1            1 FALSE
+## 2            1            1 FALSE
+## 3            1            1 FALSE
+## 4            1            1 FALSE
+## 5            1            1 FALSE
+## 6            1            1 FALSE
+ +

The repository of this AMR package contains a file comprising this exact data set: https://github.com/msberends/AMR/blob/main/data-raw/rsi_translation.txt. This file allows for machine reading EUCAST and CLSI guidelines, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically and the mo and ab columns have been transformed to contain the full official names instead of codes.

Reference Data Publicly Available

diff --git a/docs/survey.html b/docs/survey.html index c1bd3ef5..022eb7a2 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -17,7 +17,7 @@ AMR (for R) - 1.8.1.9008 + 1.8.1.9009
diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index ef2715e5..e72e7fee 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -68,7 +68,7 @@ is.rsi.eligible(x, threshold = 0.05) \item{ab}{any (vector of) text that can be coerced to a valid antimicrobial code with \code{\link[=as.ab]{as.ab()}}} -\item{guideline}{defaults to the latest included EUCAST guideline, supports EUCAST (2011-2022) and CLSI (2011-2022), see \emph{Details}} +\item{guideline}{defaults to EUCAST 2022 (the latest implemented EUCAST guideline in the \link{rsi_translation} data set), supports EUCAST (2011-2022) and CLSI (2011-2022), see \emph{Details}} \item{uti}{(Urinary Tract Infection) A vector with \link{logical}s (\code{TRUE} or \code{FALSE}) to specify whether a UTI specific interpretation from the guideline should be chosen. For using \code{\link[=as.rsi]{as.rsi()}} on a \link{data.frame}, this can also be a column containing \link{logical}s or when left blank, the data set will be searched for a column 'specimen', and rows within this column containing 'urin' (such as 'urine', 'urina') will be regarded isolates from a UTI. See \emph{Examples}.} diff --git a/man/g.test.Rd b/man/g.test.Rd index 78c9d003..b815c8d9 100644 --- a/man/g.test.Rd +++ b/man/g.test.Rd @@ -21,7 +21,7 @@ g.test(x, y = NULL, p = rep(1/length(x), length(x)), rescale.p = FALSE) \item{y}{a numeric vector; ignored if \code{x} is a matrix. If \code{x} is a factor, \code{y} should be a factor of the same length.} -\item{p}{a vector of probabilities of the same length of \code{x}. +\item{p}{a vector of probabilities of the same length as \code{x}. An error is given if any entry of \code{p} is negative.} \item{rescale.p}{a logical scalar; if TRUE then \code{p} is rescaled diff --git a/man/random.Rd b/man/random.Rd index 55a7b123..d176073b 100644 --- a/man/random.Rd +++ b/man/random.Rd @@ -33,7 +33,7 @@ These functions can be used for generating random MIC values and disk diffusion \details{ The base \R function \code{\link[=sample]{sample()}} is used for generating values. -Generated values are based on the latest EUCAST guideline implemented in the \link{rsi_translation} data set. To create specific generated values per bug or drug, set the \code{mo} and/or \code{ab} argument. +Generated values are based on the EUCAST 2022 guideline as implemented in the \link{rsi_translation} data set. To create specific generated values per bug or drug, set the \code{mo} and/or \code{ab} argument. } \section{Stable Lifecycle}{ diff --git a/man/rsi_translation.Rd b/man/rsi_translation.Rd index fc157fce..65ea385c 100644 --- a/man/rsi_translation.Rd +++ b/man/rsi_translation.Rd @@ -27,6 +27,23 @@ rsi_translation Data set containing reference data to interpret MIC and disk diffusion to R/SI values, according to international guidelines. Currently implemented guidelines are EUCAST (2011-2022) and CLSI (2011-2022). Use \code{\link[=as.rsi]{as.rsi()}} to transform MICs or disks measurements to R/SI values. } \details{ +Overview of the data set:\if{html}{\out{
}}\preformatted{head(rsi_translation) +}\if{html}{\out{
}}\preformatted{## guideline method site mo rank_index ab ref_tbl disk_dose +## 1 EUCAST 2022 MIC F_ASPRG_MGTS 2 AMB Aspergillus +## 2 EUCAST 2022 MIC F_ASPRG_NIGR 2 AMB Aspergillus +## 3 EUCAST 2022 MIC F_CANDD 3 AMB Candida +## 4 EUCAST 2022 MIC F_CANDD_ALBC 2 AMB Candida +## 5 EUCAST 2022 MIC F_CANDD_DBLN 2 AMB Candida +## 6 EUCAST 2022 MIC F_CANDD_KRUS 2 AMB Candida +## breakpoint_S breakpoint_R uti +## 1 1 1 FALSE +## 2 1 1 FALSE +## 3 1 1 FALSE +## 4 1 1 FALSE +## 5 1 1 FALSE +## 6 1 1 FALSE +} + The repository of this \code{AMR} package contains a file comprising this exact data set: \url{https://github.com/msberends/AMR/blob/main/data-raw/rsi_translation.txt}. This file \strong{allows for machine reading EUCAST and CLSI guidelines}, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. The file is updated automatically and the \code{mo} and \code{ab} columns have been transformed to contain the full official names instead of codes. } \section{Reference Data Publicly Available}{