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 @@
NEWS.md
-
as.rsi()
can now be set by the user, using the reference_data
parameter.as.rsi()
can now be set by the user, using the reference_data
parameter. This allows for using own interpretation guidelines.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.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.as.rsi()
on a data.framea 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.
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.