diff --git a/DESCRIPTION b/DESCRIPTION index d33ffc3f..964942bd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.6.0.9006 -Date: 2021-04-16 +Version: 1.6.0.9007 +Date: 2021-04-20 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 325ef464..f73246ac 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.6.0.9006 -## Last updated: 16 April 2021 +# AMR 1.6.0.9007 +## Last updated: 20 April 2021 ### New * Function `custom_eucast_rules()` that brings support for custom AMR rules in `eucast_rules()` @@ -15,6 +15,7 @@ * `first_isolate()` can now take a vector of values for `col_keyantibiotics` and can have an episode length of `Inf` * `like()` (and `%like%`) now checks if `pattern` is a *valid* regular expression * Fixed an installation error on R-3.0 +* Added `info` argument to `as.mo()` to turn on/off the progress bar # AMR 1.6.0 diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 084e0d35..f261159b 100755 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -932,8 +932,8 @@ font_stripstyle <- function(x) { gsub("(?:(?:\\x{001b}\\[)|\\x{009b})(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\\x{001b}[A-M]", "", x, perl = TRUE) } -progress_ticker <- function(n = 1, n_min = 0, ...) { - if (!interactive() || n < n_min) { +progress_ticker <- function(n = 1, n_min = 0, print = TRUE, ...) { + if (print == FALSE || n < n_min) { pb <- list() pb$tick <- function() { invisible() diff --git a/R/ab.R b/R/ab.R index 09e15e53..1f3d454a 100755 --- a/R/ab.R +++ b/R/ab.R @@ -29,7 +29,7 @@ #' @inheritSection lifecycle Stable Lifecycle #' @param x character vector to determine to antibiotic ID #' @param flag_multiple_results logical to indicate whether a note should be printed to the console that probably more than one antibiotic code or name can be retrieved from a single input value. -#' @param info logical to indicate whether a progress bar should be printed +#' @param info a [logical] to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode #' @param ... arguments passed on to internal functions #' @rdname as.ab #' @inheritSection WHOCC WHOCC @@ -90,7 +90,7 @@ #' rename_with(as.ab, where(is.rsi)) #' #' } -as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) { +as.ab <- function(x, flag_multiple_results = TRUE, info = interactive(), ...) { meet_criteria(x, allow_class = c("character", "numeric", "integer", "factor"), allow_NA = TRUE) meet_criteria(flag_multiple_results, allow_class = "logical", has_length = 1) meet_criteria(info, allow_class = "logical", has_length = 1) @@ -155,8 +155,7 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) { } if (initial_search == TRUE) { - progress <- progress_ticker(n = length(x), - n_min = ifelse(isTRUE(info) & isFALSE(fast_mode), 25, length(x) + 1)) # start if n >= 25 + progress <- progress_ticker(n = length(x), n_min = 25, print = info) # start if n >= 25 on.exit(close(progress)) } diff --git a/R/ab_from_text.R b/R/ab_from_text.R index 4422cad1..6ed992c7 100644 --- a/R/ab_from_text.R +++ b/R/ab_from_text.R @@ -32,6 +32,7 @@ #' @param collapse character to pass on to `paste(, collapse = ...)` to only return one character per element of `text`, see *Examples* #' @param translate_ab if `type = "drug"`: a column name of the [antibiotics] data set to translate the antibiotic abbreviations to, using [ab_property()]. Defaults to `FALSE`. Using `TRUE` is equal to using "name". #' @param thorough_search logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to `TRUE` will take considerably more time than when using `FALSE`. At default, it will turn `TRUE` when all input elements contain a maximum of three words. +#' @param info logical to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode #' @param ... arguments passed on to [as.ab()] #' @details This function is also internally used by [as.ab()], although it then only searches for the first drug name and will throw a note if more drug names could have been returned. Note: the [as.ab()] function may use very long regular expression to match brand names of antimicrobial agents. This may fail on some systems. #' @@ -92,6 +93,7 @@ ab_from_text <- function(text, collapse = NULL, translate_ab = FALSE, thorough_search = NULL, + info = interactive(), ...) { if (missing(type)) { type <- type[1L] @@ -102,12 +104,13 @@ ab_from_text <- function(text, meet_criteria(collapse, has_length = 1, allow_NULL = TRUE) meet_criteria(translate_ab, allow_NULL = FALSE) # get_translate_ab() will be more informative about what's allowed meet_criteria(thorough_search, allow_class = "logical", has_length = 1, allow_NULL = TRUE) + meet_criteria(info, allow_class = "logical", has_length = 1) type <- tolower(trimws(type)) text <- tolower(as.character(text)) text_split_all <- strsplit(text, "[ ;.,:\\|]") - progress <- progress_ticker(n = length(text_split_all), n_min = 5) + progress <- progress_ticker(n = length(text_split_all), n_min = 5, print = info) on.exit(close(progress)) if (type %like% "(drug|ab|anti)") { diff --git a/R/custom_eucast_rules.R b/R/custom_eucast_rules.R index 486103a8..4ba6c372 100644 --- a/R/custom_eucast_rules.R +++ b/R/custom_eucast_rules.R @@ -23,17 +23,76 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -#' Create Custom EUCAST Rules +#' Define Custom EUCAST Rules #' -#' @inheritSection lifecycle Experimental Lifecycle +#' Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in [eucast_rules()]. +#' @inheritSection lifecycle Maturing Lifecycle #' @param ... rules in formula notation, see *Examples* #' @details -#' This documentation page will be updated shortly. **This function is experimental.** +#' Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the [eucast_rules()] function. #' #' @section How it works: -#' .. #' -#' It is also possible to define antibiotic groups instead of single antibiotics. The following groups are allowed (case-insensitive): `r vector_and(tolower(DEFINED_AB_GROUPS), quote = "``")`. +#' ### Basics +#' +#' If you are familiar with the [`case_when()`][dplyr::case_when()] function of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule itself is written *before* the tilde (`~`) and the consequence of the rule is written *after* the tilde: +#' +#' ``` +#' x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S", +#' TZP == "R" ~ aminopenicillins == "R") +#' ``` +#' +#' These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work: +#' +#' ``` +#' x +#' #> A set of custom EUCAST rules: +#' #> +#' #> 1. If TZP is S then set to S: +#' #> amoxicillin (AMX), ampicillin (AMP) +#' #> +#' #> 2. If TZP is R then set to R: +#' #> amoxicillin (AMX), ampicillin (AMP) +#' ``` +#' +#' The rules (the part *before* the tilde, in above example `TZP == "S"` and `TZP == "R"`) must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column `TZP` must exist. We will create a sample data set and test the rules set: +#' +#' ``` +#' df <- data.frame(mo = c("E. coli", "K. pneumoniae"), +#' TZP = "R", +#' amox = "", +#' AMP = "") +#' df +#' #> mo TZP amox AMP +#' #> 1 E. coli R +#' #> 2 K. pneumoniae R +#' +#' eucast_rules(df, rules = "custom", custom_rules = x) +#' #> mo TZP amox AMP +#' #> 1 E. coli R R R +#' #> 2 K. pneumoniae R R R +#' ``` +#' +#' ### Using taxonomic properties in rules +#' +#' There is one exception in variables used for the rules: all column names of the [microorganisms] data set can also be used, but do not have to exist in the data set. These column names are: `r vector_and(colnames(microorganisms), quote = "``", sort = FALSE)`. Thus, this next example will work as well, despite the fact that the `df` data set does not contain a column `genus`: +#' +#' ``` +#' y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S", +#' TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R") +#' +#' eucast_rules(df, rules = "custom", custom_rules = y) +#' #> mo TZP amox AMP +#' #> 1 E. coli R +#' #> 2 K. pneumoniae R R R +#' ``` +#' +#' ### Usage of antibiotic group names +#' +#' It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part *after* the tilde. In above examples, the antibiotic group `aminopenicillins` is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the antibiotic agents that will be matched when running the rule. +#' +#' `r paste0(" * ", sapply(DEFINED_AB_GROUPS, function(x) paste0("``", tolower(x), "``\\cr(", paste0(sort(ab_name(eval(parse(text = x), envir = asNamespace("AMR")), language = NULL, tolower = TRUE)), collapse = ", "), ")"), USE.NAMES = FALSE), "\n", collapse = "")` +#' @returns A [list] containing the custom rules #' @export #' @examples #' x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R", diff --git a/R/data.R b/R/data.R index 61b4e686..37ded8f7 100755 --- a/R/data.R +++ b/R/data.R @@ -98,7 +98,7 @@ #' @details #' Please note that entries are only based on the Catalogue of Life and the LPSN (see below). Since these sources incorporate entries based on (recent) publications in the International Journal of Systematic and Evolutionary Microbiology (IJSEM), it can happen that the year of publication is sometimes later than one might expect. #' -#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the AMR package returns 2007 for `mo_year("S. pettenkoferi")`. +#' For example, *Staphylococcus pettenkoferi* was described for the first time in Diagnostic Microbiology and Infectious Disease in 2002 (\doi{10.1016/s0732-8893(02)00399-1}), but it was not before 2007 that a publication in IJSEM followed (\doi{10.1099/ijs.0.64381-0}). Consequently, the `AMR` package returns 2007 for `mo_year("S. pettenkoferi")`. #' #' ## Manual additions #' For convenience, some entries were added manually: diff --git a/R/first_isolate.R b/R/first_isolate.R index 28613b5d..5c106549 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -42,7 +42,7 @@ #' @param type type to determine weighed isolates; can be `"keyantibiotics"` or `"points"`, see *Details* #' @param ignore_I logical to indicate whether antibiotic interpretations with `"I"` will be ignored when `type = "keyantibiotics"`, see *Details* #' @param points_threshold points until the comparison of key antibiotics will lead to inclusion of an isolate when `type = "points"`, see *Details* -#' @param info print progress +#' @param info a [logical] to indicate whether a progress bar should be printed, defaults to `TRUE` only in interactive mode #' @param include_unknown logical to indicate whether 'unknown' microorganisms should be included too, i.e. microbial code `"UNKNOWN"`, which defaults to `FALSE`. For WHONET users, this means that all records with organism code `"con"` (*contamination*) will be excluded at default. Isolates with a microbial ID of `NA` will always be excluded as first isolate. #' @param include_untested_rsi logical to indicate whether also rows without antibiotic results are still eligible for becoming a first isolate. Use `include_untested_rsi = FALSE` to always return `FALSE` for such rows. This checks the data set for columns of class `` and consequently requires transforming columns with antibiotic results using [as.rsi()] first. #' @param ... arguments passed on to [first_isolate()] when using [filter_first_isolate()], or arguments passed on to [key_antibiotics()] when using [filter_first_weighted_isolate()] diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 6a49f2b5..a390ffe0 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -314,10 +314,8 @@ key_antibiotics_equal <- function(y, result <- logical(length(x)) - if (info_needed == TRUE) { - p <- progress_ticker(length(x)) - on.exit(close(p)) - } + p <- progress_ticker(length(x), print = info_needed) + on.exit(close(p)) for (i in seq_len(length(x))) { @@ -375,8 +373,8 @@ key_antibiotics_equal <- function(y, } } } - if (info_needed == TRUE) { - close(p) - } + + + close(p) result } diff --git a/R/like.R b/R/like.R index edd135d1..d70a13f1 100755 --- a/R/like.R +++ b/R/like.R @@ -35,18 +35,17 @@ #' @rdname like #' @export #' @details -#' This `%like%` function: -#' * Is case-insensitive (use `%like_case%` for case-sensitive matching) -#' * Supports multiple patterns -#' * Checks if `pattern` is a valid regular expression and sets `fixed = TRUE` if not, to greatly improve speed (vectorised over `pattern`) -#' * Always uses compatibility with Perl unless `fixed = TRUE`, to greatly improve speed +#' These [like()] and `%like%` functions: +#' * Are case-insensitive (use `%like_case%` for case-sensitive matching) +#' * Support multiple patterns +#' * Check if `pattern` is a valid regular expression and sets `fixed = TRUE` if not, to greatly improve speed (vectorised over `pattern`) +#' * Always use compatibility with Perl unless `fixed = TRUE`, to greatly improve speed #' #' Using RStudio? The text `%like%` can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like `Ctrl+Shift+L` or `Cmd+Shift+L` (see `Tools` > `Modify Keyboard Shortcuts...`). #' @source Idea from the [`like` function from the `data.table` package](https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R), although altered as explained in *Details*. #' @seealso [grepl()] #' @inheritSection AMR Read more on Our Website! #' @examples -#' # simple test #' a <- "This is a test" #' b <- "TEST" #' a %like% b @@ -65,12 +64,12 @@ #' #> TRUE FALSE FALSE #' #' # get isolates whose name start with 'Ent' or 'ent' -#' \donttest{ +#' example_isolates[which(mo_name() %like% "^ent"), ] +#' #' if (require("dplyr")) { #' example_isolates %>% #' filter(mo_name() %like% "^ent") #' } -#' } like <- function(x, pattern, ignore.case = TRUE) { meet_criteria(x, allow_NA = TRUE) meet_criteria(pattern, allow_NA = FALSE) diff --git a/R/mdro.R b/R/mdro.R index d5d128ff..76f95bdb 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -78,7 +78,7 @@ #' #' Custom guidelines can be set with the [custom_mdro_guideline()] function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data. #' -#' If you are familiar with `case_when()` of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation': +#' If you are familiar with the [`case_when()`][dplyr::case_when()] function of the `dplyr` package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation'. The rule is written *before* the tilde (`~`) and the consequence of the rule is written *after* the tilde: #' #' ``` #' custom <- custom_mdro_guideline(CIP == "R" & age > 60 ~ "Elderly Type A", diff --git a/R/mo.R b/R/mo.R index c7f949fa..b36fb5ef 100755 --- a/R/mo.R +++ b/R/mo.R @@ -38,6 +38,7 @@ #' @param reference_df a [data.frame] to be used for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation). #' @param ignore_pattern a regular expression (case-insensitive) of which all matches in `x` must return `NA`. This can be convenient to exclude known non-relevant input and can also be set with the option `AMR_ignore_pattern`, e.g. `options(AMR_ignore_pattern = "(not reported|contaminated flora)")`. #' @param language language to translate text like "no growth", which defaults to the system language (see [get_locale()]) +#' @param info a [logical] to indicate if a progress bar should be printed if more than 25 items are to be coerced, defaults to `TRUE` only in interactive mode #' @param ... other arguments passed on to functions #' @rdname as.mo #' @aliases mo @@ -161,6 +162,7 @@ as.mo <- function(x, reference_df = get_mo_source(), ignore_pattern = getOption("AMR_ignore_pattern"), language = get_locale(), + info = interactive(), ...) { meet_criteria(x, allow_class = c("mo", "data.frame", "list", "character", "numeric", "integer", "factor"), allow_NA = TRUE) meet_criteria(Becker, allow_class = c("logical", "character"), has_length = 1) @@ -169,7 +171,8 @@ as.mo <- function(x, meet_criteria(reference_df, allow_class = "data.frame", allow_NULL = TRUE) meet_criteria(ignore_pattern, allow_class = "character", has_length = 1, allow_NULL = TRUE) meet_criteria(language, has_length = 1, is_in = c(LANGUAGES_SUPPORTED, ""), allow_NULL = TRUE, allow_NA = TRUE) - + meet_criteria(info, allow_class = "logical", has_length = 1) + check_dataset_integrity() if (tryCatch(all(x[!is.na(x)] %in% MO_lookup$mo) @@ -227,6 +230,7 @@ as.mo <- function(x, reference_df = reference_df, ignore_pattern = ignore_pattern, language = language, + info = info, ...) } @@ -253,6 +257,7 @@ exec_as.mo <- function(x, Lancefield = FALSE, allow_uncertain = TRUE, reference_df = get_mo_source(), + info = interactive(), property = "mo", initial_search = TRUE, dyslexia_mode = FALSE, @@ -600,7 +605,7 @@ exec_as.mo <- function(x, } if (initial_search == TRUE) { - progress <- progress_ticker(n = length(x[!already_known]), n_min = 25) # start if n >= 25 + progress <- progress_ticker(n = length(x[!already_known]), n_min = 25, print = info) # start if n >= 25 on.exit(close(progress)) } diff --git a/R/zzz.R b/R/zzz.R index 0a6d3de9..95d4be79 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -61,20 +61,3 @@ pkg_env$mo_failed <- character(0) } }, silent = TRUE) } - -.onAttach <- function(...) { - # show notice in 10% of cases in interactive session - if (!interactive() || stats::runif(1) > 0.1 || isTRUE(as.logical(getOption("AMR_silentstart", FALSE)))) { - return() - } - packageStartupMessage(word_wrap("Thank you for using the AMR package! ", - "If you have a minute, please anonymously fill in this short questionnaire to improve the package and its functionalities: ", - font_blue("https://msberends.github.io/AMR/survey.html\n"), - "[prevent his notice with ", - font_bold("suppressPackageStartupMessages(library(AMR))"), - " or use ", - font_bold("options(AMR_silentstart = TRUE)"), "]")) -} - - - diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 1e92413e..3c9f865e 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 e5d1f5ea..162642f5 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 316cd71f..db6fcf6c 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 diff --git a/docs/articles/index.html b/docs/articles/index.html index 012ace23..182bff7d 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 diff --git a/docs/authors.html b/docs/authors.html index 5e4a4508..2faf7b0d 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 diff --git a/docs/index.html b/docs/index.html index 95628616..d57ebb31 100644 --- a/docs/index.html +++ b/docs/index.html @@ -42,7 +42,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 diff --git a/docs/news/index.html b/docs/news/index.html index c91eeb77..802e366c 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 @@ -236,13 +236,13 @@ Source: NEWS.md -
-

-AMR 1.6.0.9006 Unreleased +
+

+AMR 1.6.0.9007 Unreleased

-
+

-Last updated: 16 April 2021 +Last updated: 20 April 2021

@@ -273,6 +273,7 @@
  • like() (and %like%) now checks if pattern is a valid regular expression
  • Fixed an installation error on R-3.0
  • +
  • Added info argument to as.mo() to turn on/off the progress bar
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 24decc8b..0ac57443 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: 2021-04-16T12:59Z +last_built: 2021-04-20T08:46Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/ab_from_text.html b/docs/reference/ab_from_text.html index 23af775b..16981d6d 100644 --- a/docs/reference/ab_from_text.html +++ b/docs/reference/ab_from_text.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9040 + 1.6.0.9007
    @@ -248,6 +248,7 @@ collapse = NULL, translate_ab = FALSE, thorough_search = NULL, + info = interactive(), ... ) @@ -274,6 +275,10 @@ thorough_search

    logical to indicate whether the input must be extensively searched for misspelling and other faulty input values. Setting this to TRUE will take considerably more time than when using FALSE. At default, it will turn TRUE when all input elements contain a maximum of three words.

    + + info +

    logical to indicate whether a progress bar should be printed, defaults to TRUE only in interactive mode

    + ...

    arguments passed on to as.ab()

    diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index ecd7947a..8453ad58 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9016 + 1.6.0.9007
    @@ -242,7 +242,7 @@

    Use this function to determine the antibiotic code of one or more antibiotics. The data set antibiotics will be searched for abbreviations, official names and synonyms (brand names).

    -
    as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...)
    +    
    as.ab(x, flag_multiple_results = TRUE, info = interactive(), ...)
     
     is.ab(x)
    @@ -259,7 +259,7 @@ info -

    logical to indicate whether a progress bar should be printed

    +

    a logical to indicate whether a progress bar should be printed, defaults to TRUE only in interactive mode

    ... diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 1b34e620..ff6a9eb8 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9003 + 1.6.0.9007 @@ -250,6 +250,7 @@ reference_df = get_mo_source(), ignore_pattern = getOption("AMR_ignore_pattern"), language = get_locale(), + info = interactive(), ... ) @@ -294,6 +295,10 @@ language

    language to translate text like "no growth", which defaults to the system language (see get_locale())

    + + info +

    a logical to indicate if a progress bar should be printed if more than 25 items are to be coerced, defaults to TRUE only in interactive mode

    + ...

    other arguments passed on to functions

    diff --git a/docs/reference/custom_eucast_rules.html b/docs/reference/custom_eucast_rules.html index a8ecd7da..90709a21 100644 --- a/docs/reference/custom_eucast_rules.html +++ b/docs/reference/custom_eucast_rules.html @@ -6,7 +6,7 @@ -Create Custom EUCAST Rules — custom_eucast_rules • AMR (for R) +Define Custom EUCAST Rules — custom_eucast_rules • AMR (for R) @@ -48,8 +48,8 @@ - - + + @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9001 + 1.6.0.9007 @@ -233,13 +233,13 @@
    -

    Create Custom EUCAST Rules

    +

    Define custom EUCAST rules for your organisation or specific analysis and use the output of this function in eucast_rules().

    custom_eucast_rules(...)
    @@ -253,21 +253,97 @@ +

    Value

    + +

    A list containing the custom rules

    Details

    -

    This documentation page will be updated shortly. This function is experimental.

    +

    Some organisations have their own adoption of EUCAST rules. This function can be used to define custom EUCAST rules to be used in the eucast_rules() function.

    How it works

    -

    ..

    -

    It is also possible to define antibiotic groups instead of single antibiotics. The following groups are allowed (case-insensitive): aminoglycosides, aminopenicillins, betalactams, carbapenems, cephalosporins, cephalosporins_1st, cephalosporins_2nd, cephalosporins_3rd, cephalosporins_except_caz, fluoroquinolones, glycopeptides, glycopeptides_except_lipo, lincosamides, lipoglycopeptides, macrolides, oxazolidinones, penicillins, polymyxins, streptogramins, tetracyclines, tetracyclines_except_tgc and ureidopenicillins.

    -

    Experimental Lifecycle

    +

    Basics

    + + +

    If you are familiar with the case_when() function of the dplyr package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation'. The rule itself is written before the tilde (~) and the consequence of the rule is written after the tilde:

    x <- custom_eucast_rules(TZP == "S" ~ aminopenicillins == "S",
    +                         TZP == "R" ~ aminopenicillins == "R")
    +
    + +

    These are two custom EUCAST rules: if TZP (piperacillin/tazobactam) is "S", all aminopenicillins (ampicillin and amoxicillin) must be made "S", and if TZP is "R", aminopenicillins must be made "R". These rules can also be printed to the console, so it is immediately clear how they work:

    x
    +#> A set of custom EUCAST rules:
    +#> 
    +#>   1. If TZP is S then set to S:
    +#>      amoxicillin (AMX), ampicillin (AMP)
    +#> 
    +#>   2. If TZP is R then set to R:
    +#>      amoxicillin (AMX), ampicillin (AMP)
    +
    + +

    The rules (the part before the tilde, in above example TZP == "S" and TZP == "R") must be evaluable in your data set: it should be able to run as a filter in your data set without errors. This means for the above example that the column TZP must exist. We will create a sample data set and test the rules set:

    df <- data.frame(mo = c("E. coli", "K. pneumoniae"),
    +                 TZP = "R",
    +                 amox = "",
    +                 AMP = "")
    +df
    +#>              mo TZP amox AMP
    +#> 1       E. coli   R         
    +#> 2 K. pneumoniae   R         
    +                 
    +eucast_rules(df, rules = "custom", custom_rules = x)
    +#>              mo TZP amox AMP
    +#> 1       E. coli   R    R   R     
    +#> 2 K. pneumoniae   R    R   R  
    +
    + + +

    Using taxonomic properties in rules

    + + +

    There is one exception in variables used for the rules: all column names of the microorganisms data set can also be used, but do not have to exist in the data set. These column names are: mo, fullname, kingdom, phylum, class, order, family, genus, species, subspecies, rank, ref, species_id, source, prevalence and snomed. Thus, this next example will work as well, despite the fact that the df data set does not contain a column genus:

    y <- custom_eucast_rules(TZP == "S" & genus == "Klebsiella" ~ aminopenicillins == "S",
    +                         TZP == "R" & genus == "Klebsiella" ~ aminopenicillins == "R")
    +
    +eucast_rules(df, rules = "custom", custom_rules = y)
    +#>              mo TZP amox AMP
    +#> 1       E. coli   R         
    +#> 2 K. pneumoniae   R    R   R
    +
    + + +

    Usage of antibiotic group names

    + + +

    It is possible to define antibiotic groups instead of single antibiotics for the rule consequence, the part after the tilde. In above examples, the antibiotic group aminopenicillins is used to include ampicillin and amoxicillin. The following groups are allowed (case-insensitive). Within parentheses are the antibiotic agents that will be matched when running the rule.

      +
    • aminoglycosides
      (amikacin, amikacin/fosfomycin, amphotericin B-high, apramycin, arbekacin, astromicin, bekanamycin, dibekacin, framycetin, gentamicin, gentamicin-high, habekacin, hygromycin, isepamicin, kanamycin, kanamycin-high, kanamycin/cephalexin, micronomicin, neomycin, netilmicin, pentisomicin, plazomicin, propikacin, ribostamycin, sisomicin, streptoduocin, streptomycin, streptomycin-high, tobramycin, tobramycin-high)

    • +
    • aminopenicillins
      (amoxicillin, ampicillin)

    • +
    • betalactams
      (amoxicillin, amoxicillin/clavulanic acid, amoxicillin/sulbactam, ampicillin, ampicillin/sulbactam, apalcillin, aspoxicillin, avibactam, azidocillin, azlocillin, aztreonam, aztreonam/avibactam, bacampicillin, benzathine benzylpenicillin, benzathine phenoxymethylpenicillin, benzylpenicillin, biapenem, cadazolid, carbenicillin, carindacillin, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, ciclacillin, clometocillin, cloxacillin, dicloxacillin, doripenem, epicillin, ertapenem, flucloxacillin, hetacillin, imipenem, imipenem/EDTA, imipenem/relebactam, latamoxef, lenampicillin, loracarbef, mecillinam (Amdinocillin), meropenem, meropenem/nacubactam, meropenem/vaborbactam, metampicillin, methicillin, mezlocillin, mezlocillin/sulbactam, nacubactam, nafcillin, oxacillin, panipenem, penamecillin, penicillin/novobiocin, penicillin/sulbactam, phenethicillin, phenoxymethylpenicillin, piperacillin, piperacillin/sulbactam, piperacillin/tazobactam, piridicillin, pivampicillin, pivmecillinam, procaine benzylpenicillin, propicillin, razupenem, ritipenem, ritipenem acoxil, sarmoxicillin, sulbactam, sulbenicillin, sultamicillin, talampicillin, tazobactam, tebipenem, temocillin, ticarcillin, ticarcillin/clavulanic acid)

    • +
    • carbapenems
      (biapenem, doripenem, ertapenem, imipenem, imipenem/EDTA, imipenem/relebactam, meropenem, meropenem/nacubactam, meropenem/vaborbactam, panipenem, razupenem, ritipenem, ritipenem acoxil, tebipenem)

    • +
    • cephalosporins
      (cadazolid, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, latamoxef, loracarbef)

    • +
    • cephalosporins_1st
      (cefacetrile, cefadroxil, cefaloridine, cefatrizine, cefazedone, cefazolin, cefroxadine, ceftezole, cephalexin, cephalothin, cephapirin, cephradine)

    • +
    • cephalosporins_2nd
      (cefaclor, cefamandole, cefmetazole, cefonicid, ceforanide, cefotetan, cefotiam, cefoxitin, cefoxitin screening, cefprozil, cefuroxime, cefuroxime axetil, loracarbef)

    • +
    • cephalosporins_3rd
      (cadazolid, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefetamet, cefetamet pivoxil, cefixime, cefmenoxime, cefodizime, cefoperazone, cefoperazone/sulbactam, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotiam hexetil, cefovecin, cefpimizole, cefpiramide, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefsulodin, ceftazidime, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftriaxone, latamoxef)

    • +
    • cephalosporins_except_caz
      (cadazolid, cefacetrile, cefaclor, cefadroxil, cefaloridine, cefamandole, cefatrizine, cefazedone, cefazolin, cefcapene, cefcapene pivoxil, cefdinir, cefditoren, cefditoren pivoxil, cefepime, cefepime/clavulanic acid, cefepime/tazobactam, cefetamet, cefetamet pivoxil, cefetecol (Cefcatacol), cefetrizole, cefixime, cefmenoxime, cefmetazole, cefodizime, cefonicid, cefoperazone, cefoperazone/sulbactam, ceforanide, cefoselis, cefotaxime, cefotaxime/clavulanic acid, cefotaxime/sulbactam, cefotetan, cefotiam, cefotiam hexetil, cefovecin, cefoxitin, cefoxitin screening, cefozopran, cefpimizole, cefpiramide, cefpirome, cefpodoxime, cefpodoxime proxetil, cefpodoxime/clavulanic acid, cefprozil, cefquinome, cefroxadine, cefsulodin, cefsumide, ceftaroline, ceftaroline/avibactam, ceftazidime/avibactam, ceftazidime/clavulanic acid, cefteram, cefteram pivoxil, ceftezole, ceftibuten, ceftiofur, ceftizoxime, ceftizoxime alapivoxil, ceftobiprole, ceftobiprole medocaril, ceftolozane/enzyme inhibitor, ceftolozane/tazobactam, ceftriaxone, cefuroxime, cefuroxime axetil, cephalexin, cephalothin, cephapirin, cephradine, latamoxef, loracarbef)

    • +
    • fluoroquinolones
      (ciprofloxacin, enoxacin, fleroxacin, gatifloxacin, gemifloxacin, grepafloxacin, levofloxacin, lomefloxacin, moxifloxacin, norfloxacin, ofloxacin, pazufloxacin, pefloxacin, prulifloxacin, rufloxacin, sparfloxacin, temafloxacin, trovafloxacin)

    • +
    • glycopeptides
      (avoparcin, dalbavancin, norvancomycin, oritavancin, ramoplanin, teicoplanin, teicoplanin-macromethod, telavancin, vancomycin, vancomycin-macromethod)

    • +
    • glycopeptides_except_lipo
      (avoparcin, norvancomycin, ramoplanin, teicoplanin, teicoplanin-macromethod, vancomycin, vancomycin-macromethod)

    • +
    • lincosamides
      (clindamycin, lincomycin, pirlimycin)

    • +
    • lipoglycopeptides
      (dalbavancin, oritavancin, telavancin)

    • +
    • macrolides
      (azithromycin, clarithromycin, dirithromycin, erythromycin, flurithromycin, josamycin, midecamycin, miocamycin, oleandomycin, rokitamycin, roxithromycin, spiramycin, telithromycin, troleandomycin)

    • +
    • oxazolidinones
      (cycloserine, linezolid, tedizolid, thiacetazone)

    • +
    • penicillins
      (amoxicillin, amoxicillin/clavulanic acid, amoxicillin/sulbactam, ampicillin, ampicillin/sulbactam, apalcillin, aspoxicillin, avibactam, azidocillin, azlocillin, aztreonam, aztreonam/avibactam, bacampicillin, benzathine benzylpenicillin, benzathine phenoxymethylpenicillin, benzylpenicillin, carbenicillin, carindacillin, ciclacillin, clometocillin, cloxacillin, dicloxacillin, epicillin, flucloxacillin, hetacillin, lenampicillin, mecillinam (Amdinocillin), metampicillin, methicillin, mezlocillin, mezlocillin/sulbactam, nacubactam, nafcillin, oxacillin, penamecillin, penicillin/novobiocin, penicillin/sulbactam, phenethicillin, phenoxymethylpenicillin, piperacillin, piperacillin/sulbactam, piperacillin/tazobactam, piridicillin, pivampicillin, pivmecillinam, procaine benzylpenicillin, propicillin, sarmoxicillin, sulbactam, sulbenicillin, sultamicillin, talampicillin, tazobactam, temocillin, ticarcillin, ticarcillin/clavulanic acid)

    • +
    • polymyxins
      (colistin, polymyxin B, polymyxin B/polysorbate 80)

    • +
    • streptogramins
      (pristinamycin, quinupristin/dalfopristin)

    • +
    • tetracyclines
      (chlortetracycline, clomocycline, demeclocycline, doxycycline, eravacycline, lymecycline, metacycline, minocycline, oxytetracycline, penimepicycline, rolitetracycline, tetracycline, tigecycline)

    • +
    • tetracyclines_except_tgc
      (chlortetracycline, clomocycline, demeclocycline, doxycycline, eravacycline, lymecycline, metacycline, minocycline, oxytetracycline, penimepicycline, rolitetracycline, tetracycline)

    • +
    • ureidopenicillins
      (azlocillin, mezlocillin, piperacillin, piperacillin/tazobactam)

    • +
    + + +

    Maturing Lifecycle

    -


    -The lifecycle of this function is experimental. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this AMR package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.

    +


    +The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. Since this function needs wider usage and more extensive testing, you are very welcome to suggest changes at our repository or write us an email (see section 'Contact Us').

    Examples

    x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
    diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html
    index 867cbede..035f2330 100644
    --- a/docs/reference/eucast_rules.html
    +++ b/docs/reference/eucast_rules.html
    @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
           
           
             AMR (for R)
    -        1.6.0.9006
    +        1.6.0.9007
           
         
    diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 64e276ea..d8a18b5f 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9003 + 1.6.0.9007
    @@ -346,7 +346,7 @@ info -

    print progress

    +

    a logical to indicate whether a progress bar should be printed, defaults to TRUE only in interactive mode

    include_unknown diff --git a/docs/reference/index.html b/docs/reference/index.html index 14f4d9ef..b4fd26c9 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.6.0.9006 + 1.6.0.9007 @@ -455,7 +455,7 @@

    custom_eucast_rules()

    -

    Create Custom EUCAST Rules

    +

    Define Custom EUCAST Rules

    diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index c9c4b9ae..64b1c99a 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.5.0.9040 + 1.6.0.9007 @@ -325,7 +325,7 @@ info -

    print progress

    +

    a logical to indicate whether a progress bar should be printed, defaults to TRUE only in interactive mode

    diff --git a/docs/reference/like.html b/docs/reference/like.html index affe9389..31a1d6e4 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -82,7 +82,7 @@ AMR (for R) - 1.6.0.9003 + 1.6.0.9007 @@ -273,11 +273,11 @@

    A logical vector

    Details

    -

    This %like% function: