diff --git a/DESCRIPTION b/DESCRIPTION index 86f86803..0778ca2a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.9.0.9024 -Date: 2020-02-14 +Version: 0.9.0.9025 +Date: 2020-02-16 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), @@ -28,7 +28,9 @@ Authors@R: c( person(role = "ctb", family = "Ny", given = "Sofia", email = "sofia.ny@folkhalsomyndigheten.se"), person(role = "ctb", - family = "Souverein", given = "Dennis", email = "d.souvereing@streeklabhaarlem.nl")) + family = "Souverein", given = "Dennis", email = "d.souvereing@streeklabhaarlem.nl"), + person(role = "fnd", + given = "Stichting Certe Medische Diagnostiek en Advies", email = "medischedataanalyse@certe.nl")) Description: Functions to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods, like those defined by Leclercq et al. (2013) diff --git a/NEWS.md b/NEWS.md index 3bb51ede..86f4ac81 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,8 @@ -# AMR 0.9.0.9024 -## Last updated: 14-Feb-2020 +# AMR 0.9.0.9025 +## Last updated: 16-Feb-2020 ### New -* Support for the newest EUCAST Clinical Breakpoint Tables v.10.0, valid from 2020-01-01 (use `as.rsi()` to transform MICs or disk zones) +* Support for the newest [EUCAST Clinical Breakpoint Tables v.10.0](http://www.eucast.org/clinical_breakpoints/), valid from 2020-01-01 (use `as.rsi()` to transform MICs and disk zones) * The repository of this package now contains a clean version of the EUCAST and CLSI guidelines from 2011-2020 to translate MIC and disk diffusion values to R/SI: https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt. This **allows for machine reading these guidelines**, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file is updated automatically. * Support for LOINC and SNOMED codes * Support for LOINC codes in the `antibiotics` data set. Use `ab_loinc()` to retrieve LOINC codes, or use a LOINC code for input in any `ab_*` function: diff --git a/R/ab.R b/R/ab.R index 2850fb41..45e60781 100755 --- a/R/ab.R +++ b/R/ab.R @@ -57,9 +57,9 @@ #' #' # spelling from different languages and dyslexia are no problem #' ab_atc("ceftriaxon") -#' ab_atc("cephtriaxone") -#' ab_atc("cephthriaxone") -#' ab_atc("seephthriaaksone") +#' ab_atc("cephtriaxone") # small spelling error +#' ab_atc("cephthriaxone") # or a bit more severe +#' ab_atc("seephthriaaksone") # and even this works #' #' # use ab_* functions to get a specific properties (see ?ab_property); #' # they use as.ab() internally: diff --git a/R/misc.R b/R/misc.R index 0d7c3cb1..d3a05203 100755 --- a/R/misc.R +++ b/R/misc.R @@ -30,21 +30,24 @@ addin_insert_like <- function() { } check_dataset_integrity <- function() { - if (!all(colnames(microorganisms) %in% c("mo", "fullname", "kingdom", "phylum", - "class", "order", "family", "genus", - "species", "subspecies", "rank", - "col_id", "species_id", "source", - "ref", "prevalence", "snomed"), - na.rm = TRUE) | - NROW(microorganisms) != NROW(microorganismsDT) | - !all(colnames(antibiotics) %in% c("ab", "atc", "cid", "name", "group", - "atc_group1", "atc_group2", "abbreviations", - "synonyms", "oral_ddd", "oral_units", - "iv_ddd", "iv_units", "loinc"), - na.rm = TRUE)) { + tryCatch({ + check_microorganisms <- all(c("mo", "fullname", "kingdom", "phylum", + "class", "order", "family", "genus", + "species", "subspecies", "rank", + "col_id", "species_id", "source", + "ref", "prevalence", "snomed") %in% colnames(microorganisms), + na.rm = TRUE) & NROW(microorganisms) == NROW(microorganismsDT) + check_antibiotics <- all(c("ab", "atc", "cid", "name", "group", + "atc_group1", "atc_group2", "abbreviations", + "synonyms", "oral_ddd", "oral_units", + "iv_ddd", "iv_units", "loinc") %in% colnames(antibiotics), + na.rm = TRUE) + }, error = function(e) + stop('Please use the command \'library("AMR")\' before using this function, to load the needed reference data.', call. = FALSE) + ) + if (!check_microorganisms | !check_antibiotics) { stop("Data set `microorganisms` or data set `antibiotics` is overwritten by your global environment and prevents the AMR package from working correctly. Please rename your object before using this function.", call. = FALSE) } - invisible(TRUE) } diff --git a/R/rsi.R b/R/rsi.R index 21c86959..17541092 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -39,7 +39,7 @@ #' #' The function [is.rsi.eligible()] returns `TRUE` when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and `FALSE` otherwise. The threshold of 5% can be set with the `threshold` parameter. #' @section Interpretation of R and S/I: -#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations". +#' In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (). #' #' - **R = Resistant**\cr #' A microorganism is categorised as *Resistant* when there is a high likelihood of therapeutic failure even when there is increased exposure. Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection. @@ -56,14 +56,9 @@ #' @seealso [as.mic()] #' @inheritSection AMR Read more on our website! #' @examples -#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370))) -#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370), "A", "B", "C")) -#' is.rsi(rsi_data) -#' -#' # this can also coerce combined MIC/RSI values: -#' as.rsi("<= 0.002; S") # will return S -#' -#' # interpret MIC values +#' # For INTERPRETING disk diffusion and MIC values ----------------------- +#' +#' # single values #' as.rsi(x = as.mic(2), #' mo = as.mo("S. pneumoniae"), #' ab = "AMP", @@ -73,21 +68,36 @@ #' mo = "Strep pneu", # `mo` will be coerced with as.mo() #' ab = "ampicillin", # and `ab` with as.ab() #' guideline = "EUCAST") +#' +#' # a whole data set, even with combined MIC values and disk zones +#' df <- data.frame(microorganism = "E. coli", +#' AMP = as.mic(12), +#' GEN = as.disk(18)) +#' as.rsi(df) #' +#' +#' # For CLEANING existing R/SI values ------------------------------------ +#' +#' as.rsi(c("S", "I", "R", "A", "B", "C")) +#' as.rsi("<= 0.002; S") # will return "S" +#' +#' rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370))) +#' is.rsi(rsi_data) #' plot(rsi_data) # for percentages #' barplot(rsi_data) # for frequencies #' freq(rsi_data) # frequency table with informative header #' -#' # using dplyr's mutate #' library(dplyr) #' example_isolates %>% #' mutate_at(vars(PEN:RIF), as.rsi) #' -#' -#' # fastest way to transform all columns with already valid AB results to class `rsi`: +#' # fastest way to transform all columns with already valid AMR results to class `rsi`: #' example_isolates %>% -#' mutate_if(is.rsi.eligible, -#' as.rsi) +#' mutate_if(is.rsi.eligible, as.rsi) +#' +#' # note: from dplyr 1.0.0 on, this will be: +#' # example_isolates %>% +#' # mutate(across(is.rsi.eligible, as.rsi)) #' #' # default threshold of `is.rsi.eligible` is 5%. #' is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid @@ -310,7 +320,7 @@ as.rsi.data.frame <- function(x, col_mo = NULL, guideline = "EUCAST", ...) { message(red(paste0("Unknown drug: `", bold(ab_cols[i]), "`. Rename this column to a drug name or code, and check the output with as.ab()."))) next } - message(blue(paste0("Interpreting column `", bold(ab_cols[i]), "` (", + message(blue(paste0("Interpreting MIC values of column `", bold(ab_cols[i]), "` (", ifelse(ab_col_coerced != ab_cols[i], paste0(ab_col_coerced, ", "), ""), ab_name(ab_col_coerced, tolower = TRUE), ")...")), appendLF = FALSE) @@ -331,7 +341,7 @@ as.rsi.data.frame <- function(x, col_mo = NULL, guideline = "EUCAST", ...) { message(red(paste0("Unknown drug: `", bold(ab_cols[i]), "`. Rename this column to a drug name or code, and check the output with as.ab()."))) next } - message(blue(paste0("Interpreting column `", bold(ab_cols[i]), "` (", + message(blue(paste0("Interpreting disk zones of column `", bold(ab_cols[i]), "` (", ifelse(ab_col_coerced != ab_cols[i], paste0(ab_col_coerced, ", "), ""), ab_name(ab_col_coerced, tolower = TRUE), ")...")), appendLF = FALSE) diff --git a/docs/404.html b/docs/404.html index 9729dc6f..7c553f0a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0.9024 + 0.9.0.9025 @@ -240,7 +240,7 @@ Content not found. Please use links in the navbar.