From f2edac3b6713b4ae806f13585942f51ced034f5f Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Wed, 11 Nov 2020 18:54:03 +0100 Subject: [PATCH] (v1.4.0.9018) reference_data in as.rsi() --- .github/workflows/check.yaml | 3 ++- DESCRIPTION | 2 +- NEWS.md | 4 ++-- R/rsi.R | 33 +++++++++++++++++++++++++-------- docs/404.html | 2 +- docs/LICENSE-text.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 2 +- docs/index.html | 2 +- docs/news/index.html | 10 +++++----- docs/pkgdown.yml | 2 +- docs/reference/as.rsi.html | 6 +++--- docs/reference/index.html | 2 +- docs/survey.html | 2 +- man/as.rsi.Rd | 4 ++-- 15 files changed, 48 insertions(+), 30 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index ee254152..06e62421 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -64,7 +64,8 @@ jobs: - {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - {os: ubuntu-16.04, r: '3.4', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - {os: ubuntu-16.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - + - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} diff --git a/DESCRIPTION b/DESCRIPTION index a8bdfcdc..a0a824a1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.4.0.9017 +Version: 1.4.0.9018 Date: 2020-11-11 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 3de30742..5796406a 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.4.0.9017 +# AMR 1.4.0.9018 ## Last updated: 11 November 2020 ### New @@ -11,7 +11,7 @@ * Functions `%not_like%` and `%not_like_case%` as wrappers around `%like%` and `%like_case%`. The RStudio addin to insert the text " %like% " as provided in this package now iterates over all like variants. So if you have defined the keyboard shortcut Ctrl/Cmd + L to this addin, it will first insert ` %like% ` and by pressing it again it will be replaced with ` %not_like% `, etc. ### Changed -* Reference data used for `as.rsi()` can now be set by the user, using the `reference_data` parameter. +* Reference data used for `as.rsi()` can now be set by the user, using the `reference_data` parameter. This allows for using own interpretation guidelines. * For all function parameters in the code, it is now defined what the exact type of user input should be (inspired by the [`typed`](https://github.com/moodymudskipper/typed) package). If the user input for a certain function does not meet the requirements for a specific parameter (such as the class or length), an informative error will be thrown. This makes the package more robust and the use of it more reproducible and reliable. In total, more than 400 arguments were defined. * Deprecated function `p_symbol()` that not really fits the scope of this package. It will be removed in a future version. See [here](https://github.com/msberends/AMR/blob/v1.4.0/R/p_symbol.R) for the source code to preserve it. * Better determination of disk zones and MIC values when running `as.rsi()` on a data.frame diff --git a/R/rsi.R b/R/rsi.R index 190e74d5..6f47999c 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -36,7 +36,7 @@ #' @param guideline defaults to the latest included EUCAST guideline, see Details for all options #' @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 'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes', version `r EUCAST_VERSION_EXPERT_RULES`. -#' @param reference_data a [data.frame] to be used for interpretation, which defaults to the [rsi_translation] data set. Changing this parameter allows for using own interpretation guidelines. This parameter 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' column in this data set must contain values set in the 'guideline' parameter of [as.rsi()]. +#' @param reference_data a [data.frame] to be used for interpretation, which defaults to the [rsi_translation] data set. Changing this parameter allows for using own interpretation guidelines. This parameter 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` parameter will be ignored when `reference_data` is manually set. #' @param threshold maximum fraction of invalid antimicrobial interpretations of `x`, please see *Examples* #' @param ... for using on a [data.frame]: names of columns to apply [as.rsi()] on (supports tidy selection like `AMX:VAN`). Otherwise: parameters passed on to methods. #' @details @@ -67,7 +67,7 @@ #' #' For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the `guideline` parameter are: `r paste0('"', sort(unique(AMR::rsi_translation$guideline)), '"', collapse = ", ")`. #' -#' Simply using `"CLSI"` or `"EUCAST"` as input will automatically select the latest version of that guideline. You can set your own data set using the `reference_data` parameter. +#' Simply using `"CLSI"` or `"EUCAST"` as input will automatically select the latest version of that guideline. You can set your own data set using the `reference_data` parameter. The `guideline` parameter will then be ignored. #' #' ## After interpretation #' @@ -359,7 +359,10 @@ as.rsi.mic <- function(x, message_("=> Interpreting MIC values of `", font_bold(ab), "` (", ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""), ab_name(ab_coerced, tolower = TRUE), ")", mo_var_found, - " according to ", font_bold(guideline_coerced), " ... ", + " according to ", ifelse(identical(reference_data, AMR::rsi_translation), + font_bold(guideline_coerced), + "manually defined 'reference_data'"), + " ... ", appendLF = FALSE, as_note = FALSE) @@ -445,9 +448,14 @@ as.rsi.disk <- function(x, message_("=> Interpreting disk zones of `", font_bold(ab), "` (", ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""), - ab_name(ab_coerced, tolower = TRUE), ") using guideline ", font_bold(guideline_coerced), " ... ", - appendLF = FALSE, + ab_name(ab_coerced, tolower = TRUE), ")", mo_var_found, + " according to ", ifelse(identical(reference_data, AMR::rsi_translation), + font_bold(guideline_coerced), + "manually defined 'reference_data'"), + " ... ", + appendLF = FALSE, as_note = FALSE) + result <- exec_as.rsi(method = "disk", x = x, mo = mo_coerced, @@ -622,6 +630,9 @@ as.rsi.data.frame <- function(x, } get_guideline <- function(guideline, reference_data) { + if (!identical(reference_data, AMR::rsi_translation)) { + return(guideline) + } guideline_param <- toupper(guideline) if (guideline_param %in% c("CLSI", "EUCAST")) { guideline_param <- rev(sort(subset(reference_data, guideline %like% guideline_param)$guideline))[1L] @@ -646,7 +657,8 @@ exec_as.rsi <- function(method, guideline, uti, conserve_capped_values, - add_intrinsic_resistance) { + add_intrinsic_resistance, + reference_data) { metadata_mo <- get_mo_failures_uncertainties_renamed() @@ -687,8 +699,13 @@ exec_as.rsi <- function(method, new_rsi <- rep(NA_character_, length(x)) ab_param <- ab - trans <- reference_data %pm>% - subset(guideline == guideline_coerced & method == method_param & ab == ab_param) + if (identical(reference_data, AMR::rsi_translation)) { + trans <- reference_data %pm>% + subset(guideline == guideline_coerced & method == method_param & ab == ab_param) + } else { + trans <- reference_data %pm>% + subset(method == method_param & ab == ab_param) + } trans$lookup <- paste(trans$mo, trans$ab) lookup_mo <- paste(mo, ab) diff --git a/docs/404.html b/docs/404.html index 821aae93..084c01ad 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index eda3eed9..ec497a83 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018 diff --git a/docs/articles/index.html b/docs/articles/index.html index 92312efb..14b8ebdd 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018 diff --git a/docs/authors.html b/docs/authors.html index e4129903..06637ef5 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018 diff --git a/docs/index.html b/docs/index.html index 0cd46e1e..12f1ef0e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018 diff --git a/docs/news/index.html b/docs/news/index.html index 65adace5..37818183 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018 @@ -236,9 +236,9 @@ Source: NEWS.md -
-

-AMR 1.4.0.9017 Unreleased +
+

+AMR 1.4.0.9018 Unreleased

@@ -262,7 +262,7 @@

Changed

    -
  • Reference data used for as.rsi() can now be set by the user, using the reference_data parameter.
  • +
  • Reference data used for as.rsi() can now be set by the user, using the reference_data parameter. This allows for using own interpretation guidelines.
  • For all function parameters in the code, it is now defined what the exact type of user input should be (inspired by the typed package). If the user input for a certain function does not meet the requirements for a specific parameter (such as the class or length), an informative error will be thrown. This makes the package more robust and the use of it more reproducible and reliable. In total, more than 400 arguments were defined.
  • Deprecated function p_symbol() that not really fits the scope of this package. It will be removed in a future version. See here for the source code to preserve it.
  • Better determination of disk zones and MIC values when running as.rsi() on a data.frame
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index b27f64e8..c0e26ecb 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2020-11-11T15:44Z +last_built: 2020-11-11T17:53Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index 154b4ec9..c2ba7f7f 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018
@@ -327,7 +327,7 @@ list(version_txt = "v3.2", year = 2020, title = "EUCAST Expert Rules / EUCAST In reference_data -

a data.frame to be used for interpretation, which defaults to the rsi_translation data set. Changing this parameter allows for using own interpretation guidelines. This parameter 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' column in this data set must contain values set in the 'guideline' parameter of as.rsi().

+

a data.frame to be used for interpretation, which defaults to the rsi_translation data set. Changing this parameter allows for using own interpretation guidelines. This parameter 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 parameter will be ignored when reference_data is manually set.

col_mo @@ -365,7 +365,7 @@ list(version_txt = "v3.2", year = 2020, title = "EUCAST Expert Rules / EUCAST In

For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the guideline parameter are: "CLSI 2010", "CLSI 2011", "CLSI 2012", "CLSI 2013", "CLSI 2014", "CLSI 2015", "CLSI 2016", "CLSI 2017", "CLSI 2018", "CLSI 2019", "EUCAST 2011", "EUCAST 2012", "EUCAST 2013", "EUCAST 2014", "EUCAST 2015", "EUCAST 2016", "EUCAST 2017", "EUCAST 2018", "EUCAST 2019", "EUCAST 2020".

-

Simply using "CLSI" or "EUCAST" as input will automatically select the latest version of that guideline. You can set your own data set using the reference_data parameter.

+

Simply using "CLSI" or "EUCAST" as input will automatically select the latest version of that guideline. You can set your own data set using the reference_data parameter. The guideline parameter will then be ignored.

After interpretation

diff --git a/docs/reference/index.html b/docs/reference/index.html index 7a25ff29..70ff4980 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018
diff --git a/docs/survey.html b/docs/survey.html index 9a753eff..f2c52645 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0.9017 + 1.4.0.9018

diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index b5038e3e..f0a94b64 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -70,7 +70,7 @@ is.rsi.eligible(x, threshold = 0.05) \item{add_intrinsic_resistance}{\emph{(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 \emph{Klebsiella} species. Determination is based on the \link{intrinsic_resistant} data set, that itself is based on 'EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes', version list(version_txt = "v3.1", year = 2016, title = "EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes") list(version_txt = "v3.2", year = 2020, title = "EUCAST Expert Rules / EUCAST Intrinsic Resistance and Unusual Phenotypes").} -\item{reference_data}{a \link{data.frame} to be used for interpretation, which defaults to the \link{rsi_translation} data set. Changing this parameter allows for using own interpretation guidelines. This parameter must contain a data set that is equal in structure to the \link{rsi_translation} data set (same column names and column types). Please note that the 'guideline' column in this data set must contain values set in the 'guideline' parameter of \code{\link[=as.rsi]{as.rsi()}}.} +\item{reference_data}{a \link{data.frame} to be used for interpretation, which defaults to the \link{rsi_translation} data set. Changing this parameter allows for using own interpretation guidelines. This parameter must contain a data set that is equal in structure to the \link{rsi_translation} data set (same column names and column types). Please note that the \code{guideline} parameter will be ignored when \code{reference_data} is manually set.} \item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.} } @@ -107,7 +107,7 @@ your_data \%>\% mutate(across(where(is.disk), as.rsi)) # since dplyr 1.0.0 For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the \code{guideline} parameter are: "CLSI 2010", "CLSI 2011", "CLSI 2012", "CLSI 2013", "CLSI 2014", "CLSI 2015", "CLSI 2016", "CLSI 2017", "CLSI 2018", "CLSI 2019", "EUCAST 2011", "EUCAST 2012", "EUCAST 2013", "EUCAST 2014", "EUCAST 2015", "EUCAST 2016", "EUCAST 2017", "EUCAST 2018", "EUCAST 2019", "EUCAST 2020". -Simply using \code{"CLSI"} or \code{"EUCAST"} as input will automatically select the latest version of that guideline. You can set your own data set using the \code{reference_data} parameter. +Simply using \code{"CLSI"} or \code{"EUCAST"} as input will automatically select the latest version of that guideline. You can set your own data set using the \code{reference_data} parameter. The \code{guideline} parameter will then be ignored. } \subsection{After interpretation}{