diff --git a/DESCRIPTION b/DESCRIPTION index 0155ba3f6..787648ad3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.6.1.9002 -Date: 2019-04-11 +Version: 0.6.1.9003 +Date: 2019-05-10 Title: Antimicrobial Resistance Analysis Authors@R: c( person( @@ -53,6 +53,7 @@ Imports: knitr (>= 1.0.0), microbenchmark, rlang (>= 0.3.1), + scales, tidyr (>= 0.7.0) Suggests: covr (>= 3.0.1), diff --git a/NAMESPACE b/NAMESPACE index 8efd6b60c..7363cf913 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,11 +1,16 @@ # Generated by roxygen2: do not edit by hand +S3method(as.data.frame,ab) S3method(as.data.frame,atc) S3method(as.data.frame,frequency_tbl) S3method(as.data.frame,mo) S3method(as.double,mic) S3method(as.integer,mic) S3method(as.numeric,mic) +S3method(as.rsi,data.frame) +S3method(as.rsi,default) +S3method(as.rsi,disk) +S3method(as.rsi,mic) S3method(as.vector,frequency_tbl) S3method(as_tibble,frequency_tbl) S3method(barplot,mic) @@ -22,14 +27,17 @@ S3method(plot,frequency_tbl) S3method(plot,mic) S3method(plot,resistance_predict) S3method(plot,rsi) +S3method(print,ab) S3method(print,atc) S3method(print,catalogue_of_life_version) +S3method(print,disk) S3method(print,frequency_tbl) S3method(print,mic) S3method(print,mo) S3method(print,mo_renamed) S3method(print,mo_uncertainties) S3method(print,rsi) +S3method(pull,ab) S3method(pull,atc) S3method(pull,mo) S3method(select,frequency_tbl) @@ -41,24 +49,26 @@ S3method(summary,mo) S3method(summary,rsi) export("%like%") export(ab_atc) -export(ab_certe) +export(ab_atc_group1) +export(ab_atc_group2) +export(ab_cid) +export(ab_ddd) +export(ab_group) export(ab_name) export(ab_official) export(ab_property) +export(ab_synonyms) export(ab_tradenames) -export(ab_trivial_nl) -export(ab_umcg) export(abname) export(age) export(age_groups) export(anti_join_microorganisms) +export(as.ab) export(as.atc) +export(as.disk) export(as.mic) export(as.mo) export(as.rsi) -export(atc_certe) -export(atc_ddd) -export(atc_groups) export(atc_name) export(atc_official) export(atc_online_ddd) @@ -67,7 +77,6 @@ export(atc_online_property) export(atc_property) export(atc_tradenames) export(atc_trivial_nl) -export(atc_umcg) export(availability) export(brmo) export(catalogue_of_life_version) @@ -109,7 +118,9 @@ export(ggplot_rsi_predict) export(guess_ab_col) export(header) export(inner_join_microorganisms) +export(is.ab) export(is.atc) +export(is.disk) export(is.mic) export(is.mo) export(is.rsi) @@ -156,7 +167,6 @@ export(ratio) export(read.4D) export(resistance_predict) export(right_join_microorganisms) -export(rsi) export(rsi_predict) export(scale_rsi_colours) export(scale_y_percent) @@ -165,6 +175,7 @@ export(set_mo_source) export(skewness) export(theme_rsi) export(top_freq) +exportMethods(as.data.frame.ab) exportMethods(as.data.frame.atc) exportMethods(as.data.frame.frequency_tbl) exportMethods(as.data.frame.mo) @@ -187,14 +198,17 @@ exportMethods(kurtosis.matrix) exportMethods(plot.frequency_tbl) exportMethods(plot.mic) exportMethods(plot.rsi) +exportMethods(print.ab) exportMethods(print.atc) exportMethods(print.catalogue_of_life_version) +exportMethods(print.disk) exportMethods(print.frequency_tbl) exportMethods(print.mic) exportMethods(print.mo) exportMethods(print.mo_renamed) exportMethods(print.mo_uncertainties) exportMethods(print.rsi) +exportMethods(pull.ab) exportMethods(pull.atc) exportMethods(pull.mo) exportMethods(select.frequency_tbl) diff --git a/NEWS.md b/NEWS.md index 9b275950c..356bce49d 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,24 @@ # AMR 0.6.1.9001 **Note: latest development version** +#### New +* Support for translation of disk diffusion and MIC values to RSI values (i.e. antimicrobial interpretations). Supported guidelines are EUCAST (2011 to 2019) and CLSI (2011 to 2019). Use `as.rsi()` on an MIC value (created with `as.mic()`), a disk diffusion value (created with the new `as.disk()`) or on a complete date set containing columns with MIC or disk diffusion values. + #### Changed -* Removed deprecated functions `guess_mo()`, `guess_atc()`, `EUCAST_rules()`, `interpretive_reading()` +* Completely reworked the `antibiotics` data set: + * All entries now have 3 different identifiers: a human readable EARS-Net code (`ab`, used by ECDC and WHONET), an ATC code (`atc`, used by WHO), and a CID code (`cid`, Compound ID, used by PubChem) + * Based on the Compound ID, more than a thousand official brand names have been added from many different countries + * All references to antibiotics in our package now use EARS-Net codes, like `AMX` for amoxicillin + * Functions `atc_certe`, `ab_umcg` and `atc_trivial_nl` have been removed + * All `atc_*` functions are superceded by `ab_*` functions + * All output will be translated by using an included, local translation file that can be found after install with: + ```r + system.file("translations.tsv", package = "AMR") + ``` + Please create an issue in one of our repositories if you want additions in this file. +* Improved intelligence of looking up antibiotic tables in data set using `guess_ab_col()` * Added ~5,000 more old taxonomic names to the `microorganisms.old` data set, which leads to better results finding when using the `as.mo()` function +* Removed deprecated functions `guess_mo()`, `guess_atc()`, `EUCAST_rules()`, `interpretive_reading()`, `rsi()` * Frequency tables of microbial IDs speed improvement * Removed all hardcoded EUCAST rules and replaced them with a new reference file: `./inst/eucast/eucast.tsv`. * Added ceftazidim intrinsic resistance to *Streptococci* @@ -11,6 +26,7 @@ * Fix for `freq()` for when all values are `NA`. #### Other +* Support for R 3.6.0 * Prevented [staged install](https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html) in R 3.6.0 and later by adding `StagedInstall: false` to the DESCRIPTION file # AMR 0.6.1 diff --git a/R/ab.R b/R/ab.R new file mode 100755 index 000000000..62fd2074a --- /dev/null +++ b/R/ab.R @@ -0,0 +1,242 @@ +# ==================================================================== # +# TITLE # +# Antimicrobial Resistance (AMR) Analysis # +# # +# SOURCE # +# https://gitlab.com/msberends/AMR # +# # +# LICENCE # +# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # +# # +# This R package is free software; you can freely use and distribute # +# it for both personal and commercial purposes under the terms of the # +# GNU General Public License version 2.0 (GNU GPL-2), as published by # +# the Free Software Foundation. # +# # +# This R package was created for academic research and was publicly # +# released in the hope that it will be useful, but it comes WITHOUT # +# ANY WARRANTY OR LIABILITY. # +# Visit our website for more info: https://msberends.gitlab.io/AMR. # +# ==================================================================== # + +#' Transform to antibiotic ID +#' +#' Use this function to determine the antibiotic code of one or more antibiotics. The data set \code{\link{antibiotics}} will be searched for abbreviations, official names and synonyms (brand names). +#' @param x character vector to determine to antibiotic ID +#' @rdname as.ab +#' @keywords atc +#' @inheritSection WHOCC WHOCC +#' @export +#' @importFrom dplyr %>% filter slice pull +#' @details Use the \code{\link{ab_property}} functions to get properties based on the returned ATC code, see Examples. +#' +#' In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups. +#' Source: \url{https://www.whocc.no/atc/structure_and_principles/} +#' @section Source: +#' World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/} +#' +#' WHONET 2019 software: \url{http://www.whonet.org/software.html} +#' +#' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm} +#' @return Character (vector) with class \code{"act"}. Unknown values will return \code{NA}. +#' @seealso \code{\link{antibiotics}} for the dataframe that is being used to determine ATCs. +#' @inheritSection AMR Read more on our website! +#' @examples +#' # These examples all return "ERY", the ID of Erythromycin: +#' as.ab("J01FA01") +#' as.ab("J 01 FA 01") +#' as.ab("Erythromycin") +#' as.ab("eryt") +#' as.ab(" eryt 123") +#' as.ab("ERYT") +#' as.ab("ERY") +#' as.ab("erytromicine") # spelled wrong +#' as.ab("Erythrocin") # trade name +#' as.ab("Romycin") # trade name +#' +#' # Use ab_* functions to get a specific properties (see ?ab_property); +#' # they use as.ab() internally: +#' ab_name("J01FA01") # "Erythromycin" +#' ab_name("eryt") # "Erythromycin" +as.ab <- function(x) { + if (is.ab(x)) { + return(x) + } + x_bak <- x + # remove suffices + x_bak_clean <- gsub("_(mic|rsi)$", "", x) + # remove disk concentrations, like LVX_NM -> LVX + x_bak_clean <- gsub("_[A-Z]{2}[0-9_]{0,3}$", "", x_bak_clean) + # clean rest of it + x_bak_clean <- gsub("[^a-zA-Z0-9/-]", "", x_bak_clean) + # keep only a-z when it's not an ATC code or only numbers + x_bak_clean[!x_bak_clean %like% "^([A-Z][0-9]{2}[A-Z]{2}[0-9]{2}|[0-9]+)$"] <- gsub("[^a-zA-Z]+", + "", + x_bak_clean[!x_bak_clean %like% "^([A-Z][0-9]{2}[A-Z]{2}[0-9]{2}|[0-9]+)$"]) + x <- unique(x_bak_clean) + x_new <- rep(NA_character_, length(x)) + x_unknown <- character(0) + + for (i in 1:length(x)) { + if (is.na(x[i]) | is.null(x[i])) { + next + } + if (identical(x[i], "")) { + x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) + next + } + + # exact AB code + found <- AMR::antibiotics[which(AMR::antibiotics$ab == toupper(x[i])),]$ab + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # exact ATC code + found <- AMR::antibiotics[which(AMR::antibiotics$atc == toupper(x[i])),]$ab + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # exact CID code + found <- AMR::antibiotics[which(AMR::antibiotics$cid == x[i]),]$ab + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # exact name + found <- AMR::antibiotics[which(toupper(AMR::antibiotics$name) == toupper(x[i])),]$ab + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # exact synonym + synonym_found <- unlist(lapply(AMR::antibiotics$synonyms, + function(s) if (toupper(x[i]) %in% toupper(s)) { + TRUE + } else { + FALSE + })) + found <- AMR::antibiotics$ab[synonym_found == TRUE] + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # exact abbreviation + abbr_found <- unlist(lapply(AMR::antibiotics$abbreviations, + function(a) if (toupper(x[i]) %in% toupper(a)) { + TRUE + } else { + FALSE + })) + found <- AMR::antibiotics$ab[abbr_found == TRUE] + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # first >=4 characters of name + if (nchar(x[i]) >= 4) { + found <- AMR::antibiotics[which(toupper(AMR::antibiotics$name) %like% paste0("^", x[i])),]$ab + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + } + + # allow characters that resemble others, but only continue when having more than 3 characters + if (nchar(x[i]) <= 3) { + x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) + next + } + x_spelling <- x[i] + x_spelling <- gsub("[iy]+", "[iy]+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("[sz]+", "[sz]+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("(c|k|q|qu)+", "(c|k|q|qu)+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("(ph|f|v)+", "(ph|f|v)+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("(th|t)+", "(th|t)+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("a+", "a+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("e+", "e+", x_spelling, ignore.case = TRUE) + x_spelling <- gsub("o+", "o+", x_spelling, ignore.case = TRUE) + # allow any ending of -in/-ine and -im/-ime + x_spelling <- gsub("(\\[iy\\]\\+(n|m)|\\[iy\\]\\+(n|m)e\\+)$", "[iy]+(n|m)e*", x_spelling, ignore.case = TRUE) + # allow any ending of -ol/-ole + x_spelling <- gsub("(o\\+l|o\\+le\\+)$", "o+le*", x_spelling, ignore.case = TRUE) + # try if name starts with it + found <- AMR::antibiotics[which(AMR::antibiotics$name %like% paste0("^", x_spelling)),]$ab + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + # and try if any synonym starts with it + synonym_found <- unlist(lapply(AMR::antibiotics$synonyms, + function(s) if (any(s %like% paste0("^", x_spelling))) { + TRUE + } else { + FALSE + })) + found <- AMR::antibiotics$ab[synonym_found == TRUE] + if (length(found) > 0) { + x_new[i] <- found[1L] + next + } + + # not found + x_unknown <- c(x_unknown, x_bak[x[i] == x_bak_clean][1]) + } + + if (length(x_unknown) > 0) { + warning("These values could not be coerced to a valid antibiotic ID: ", + paste('"', sort(unique(x_unknown)), '"', sep = "", collapse = ', '), + ".", + call. = FALSE) + } + + x_result <- data.frame(x = x_bak_clean, stringsAsFactors = FALSE) %>% + left_join(data.frame(x = x, x_new = x_new, stringsAsFactors = FALSE), by = "x") %>% + pull(x_new) + + structure(.Data = x_result, + class = "ab") +} + +#' @rdname as.atc +#' @export +is.ab <- function(x) { + identical(class(x), "ab") +} + +#' @exportMethod print.ab +#' @export +#' @noRd +print.ab <- function(x, ...) { + cat("Class 'ab'\n") + print.default(as.character(x), quote = FALSE) +} + +#' @exportMethod as.data.frame.ab +#' @export +#' @noRd +as.data.frame.ab <- function (x, ...) { + # same as as.data.frame.character but with removed stringsAsFactors + nm <- paste(deparse(substitute(x), width.cutoff = 500L), + collapse = " ") + if (!"nm" %in% names(list(...))) { + as.data.frame.vector(x, ..., nm = nm) + } else { + as.data.frame.vector(x, ...) + } +} + +#' @exportMethod pull.ab +#' @export +#' @importFrom dplyr pull +#' @noRd +pull.ab <- function(.data, ...) { + pull(as.data.frame(.data), ...) +} diff --git a/R/ab_property.R b/R/ab_property.R new file mode 100644 index 000000000..0300e4c50 --- /dev/null +++ b/R/ab_property.R @@ -0,0 +1,185 @@ +# ==================================================================== # +# TITLE # +# Antimicrobial Resistance (AMR) Analysis # +# # +# SOURCE # +# https://gitlab.com/msberends/AMR # +# # +# LICENCE # +# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # +# # +# This R package is free software; you can freely use and distribute # +# it for both personal and commercial purposes under the terms of the # +# GNU General Public License version 2.0 (GNU GPL-2), as published by # +# the Free Software Foundation. # +# # +# This R package was created for academic research and was publicly # +# released in the hope that it will be useful, but it comes WITHOUT # +# ANY WARRANTY OR LIABILITY. # +# Visit our website for more info: https://msberends.gitlab.io/AMR. # +# ==================================================================== # + +#' Property of an antibiotic +#' +#' Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set. All input values will be evaluated internally with \code{\link{as.ab}}. +#' @param x any (vector of) text that can be coerced to a valid microorganism code with \code{\link{as.ab}} +#' @param tolower logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b". +#' @param property one of the column names of one of the \code{\link{antibiotics}} data set +#' @param language language of the returned text, defaults to system language (see \code{\link{get_locale}}) and can also be set with \code{\link{getOption}("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation. +#' @param administration way of administration, either \code{"oral"} or \code{"iv"} +#' @param units a logical to indicate whether the units instead of the DDDs itself must be returned, see Examples +#' @param ... other parameters passed on to \code{\link{as.ab}} +#' @details All output will be \link{translate}d where possible. +#' @inheritSection as.ab Source +#' @rdname ab_property +#' @name ab_property +#' @return \itemize{ +#' \item{An \code{integer} in case of \code{ab_cid}} +#' \item{A named \code{list} in case of multiple \code{ab_synonyms}} +#' \item{A \code{double} in case of \code{ab_ddd}} +#' \item{A \code{character} in all other cases} +#' } +#' @export +#' @seealso \code{\link{antibiotics}} +#' @inheritSection AMR Read more on our website! +#' @examples +#' # all properties: +#' ab_name("AMX") # "Amoxicillin" +#' ab_atc("AMX") # J01CA04 (ATC code from the WHO) +#' ab_cid("AMX") # 33613 (Compound ID from PubChem) +#' +#' ab_synonyms("AMX") # a list with brand names of amoxicillin +#' ab_tradenames("AMX") # same +#' +#' ab_group("AMX") # "Beta-lactams/penicillins" +#' ab_atc_group1("AMX") # "Beta-lactam antibacterials, penicillins" +#' ab_atc_group2("AMX") # "Penicillins with extended spectrum" +#' +#' ab_name(x = c("AMC", "PLB")) # "Amoxicillin/clavulanic acid" "Polymyxin B" +#' ab_name(x = c("AMC", "PLB"), +#' tolower = TRUE) # "amoxicillin/clavulanic acid" "polymyxin B" +#' +#' ab_ddd("AMX", "oral") # 1 +#' ab_ddd("AMX", "oral", units = TRUE) # "g" +#' ab_ddd("AMX", "iv") # 1 +#' ab_ddd("AMX", "iv", units = TRUE) # "g" +#' +#' # all ab_* functions use as.ab() internally: +#' ab_name("Fluclox") # "Flucloxacillin" +#' ab_name("fluklox") # "Flucloxacillin" +#' ab_name("floxapen") # "Flucloxacillin" +#' ab_name(21319) # "Flucloxacillin" (using CID) +#' ab_name("J01CF05") # "Flucloxacillin" (using ATC) +ab_name <- function(x, language = get_locale(), tolower = FALSE, ...) { + x <- ab_validate(x = x, property = "name", ...) + res <- t(x, language = language) + if (tolower == TRUE) { + # use perl to only transform the first character + # as we want "polymyxin B", not "polymyxin b" + res <- gsub("^([A-Z])", "\\L\\1", res, perl = TRUE) + } + res +} + +#' @rdname ab_property +#' @export +ab_atc <- function(x, ...) { + ab_validate(x = x, property = "atc", ...) +} + +#' @rdname ab_property +#' @export +ab_cid <- function(x, ...) { + ab_validate(x = x, property = "cid", ...) +} + +#' @rdname ab_property +#' @export +ab_synonyms <- function(x, ...) { + syns <- ab_validate(x = x, property = "synonyms", ...) + names(syns) <- x + if (length(syns) == 1) { + unname(unlist(syns)) + } else { + syns + } +} + +#' @rdname ab_property +#' @export +ab_tradenames <- function(x, ...) { + ab_synonyms(x, ...) +} + +#' @rdname ab_property +#' @export +ab_group <- function(x, ...) { + ab_validate(x = x, property = "group", ...) +} + +#' @rdname ab_property +#' @export +ab_atc_group1 <- function(x, ...) { + ab_validate(x = x, property = "atc_group1", ...) +} + +#' @rdname ab_property +#' @export +ab_atc_group2 <- function(x, ...) { + ab_validate(x = x, property = "atc_group2", ...) +} + +#' @rdname ab_property +#' @export +ab_ddd <- function(x, administration = "oral", units = FALSE, ...) { + if (!administration %in% c("oral", "iv")) { + stop("`administration` must be 'oral' or 'iv'", call. = FALSE) + } + ddd_prop <- administration + if (units == TRUE) { + ddd_prop <- paste0(ddd_prop, "_units") + } else { + ddd_prop <- paste0(ddd_prop, "_ddd") + } + ab_validate(x = x, property = ddd_prop, ...) +} + +#' @rdname ab_property +#' @export +ab_property <- function(x, property = 'name', language = get_locale(), ...) { + if (length(property) != 1L) { + stop("'property' must be of length 1.") + } + if (!property %in% colnames(AMR::antibiotics)) { + stop("invalid property: '", property, "' - use a column name of the `antibiotics` data set") + } + + t(ab_validate(x = x, property = property, ...), language = language) +} + +ab_validate <- function(x, property, ...) { + if (!"AMR" %in% base::.packages()) { + library("AMR") + # check onLoad() in R/zzz.R: data tables are created there. + } + + # try to catch an error when inputting an invalid parameter + # so the 'call.' can be set to FALSE + tryCatch(x[1L] %in% AMR::antibiotics[1, property], + error = function(e) stop(e$message, call. = FALSE)) + + if (!all(x %in% AMR::antibiotics[, property])) { + x <- data.frame(ab = as.ab(x), stringsAsFactors = FALSE) %>% + left_join(antibiotics %>% select(c("ab", property)), by = "ab") %>% + pull(property) + } + if (property %in% c("ab", "atc")) { + return(structure(x, class = property)) + } else if (property == "cid") { + return(as.integer(x)) + } else if (property %like% "ddd") { + return(as.double(x)) + } else { + return(x) + } +} diff --git a/R/abname.R b/R/abname.R deleted file mode 100755 index 87ae33d04..000000000 --- a/R/abname.R +++ /dev/null @@ -1,162 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Analysis # -# # -# SOURCE # -# https://gitlab.com/msberends/AMR # -# # -# LICENCE # -# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# # -# This R package was created for academic research and was publicly # -# released in the hope that it will be useful, but it comes WITHOUT # -# ANY WARRANTY OR LIABILITY. # -# Visit our website for more info: https://msberends.gitlab.io/AMR. # -# ==================================================================== # - -#' Name of an antibiotic -#' -#' Convert antibiotic codes to a (trivial) antibiotic name or ATC code, or vice versa. This uses the data from \code{\link{antibiotics}}. -#' @param abcode a code or name, like \code{"AMOX"}, \code{"AMCL"} or \code{"J01CA04"} -#' @param from,to type to transform from and to. See \code{\link{antibiotics}} for its column names. WIth \code{from = "guess"} the from will be guessed from \code{"atc"}, \code{"certe"} and \code{"umcg"}. When using \code{to = "atc"}, the ATC code will be searched using \code{\link{as.atc}}. -#' @param textbetween text to put between multiple returned texts -#' @param tolower return output as lower case with function \code{\link{tolower}}. -#' @details \strong{The \code{\link{ab_property}} functions are faster and more concise}, but do not support concatenated strings, like \code{abname("AMCL+GENT"}. -#' @keywords ab antibiotics -#' @source \code{\link{antibiotics}} -#' @inheritSection WHOCC WHOCC -#' @export -#' @importFrom dplyr %>% pull -#' @inheritSection AMR Read more on our website! -#' @examples -#' abname("AMCL") -#' # "Amoxicillin and beta-lactamase inhibitor" -#' -#' # It is quite flexible at default (having `from = "guess"`) -#' abname(c("amox", "J01CA04", "Trimox", "dispermox", "Amoxil")) -#' # "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" -#' -#' # Multiple antibiotics can be combined with "+". -#' # The second antibiotic will be set to lower case when `tolower` was not set: -#' abname("AMCL+GENT", textbetween = "/") -#' # "amoxicillin and enzyme inhibitor/gentamicin" -#' -#' abname(c("AMCL", "GENT")) -#' # "Amoxicillin and beta-lactamase inhibitor" "Gentamicin" -#' -#' abname("AMCL", to = "trivial_nl") -#' # "Amoxicilline/clavulaanzuur" -#' -#' abname("AMCL", to = "atc") -#' # "J01CR02" -#' -#' # specific codes for University Medical Center Groningen (UMCG): -#' abname("J01CR02", from = "atc", to = "umcg") -#' # "AMCL" -#' -#' # specific codes for Certe: -#' abname("J01CR02", from = "atc", to = "certe") -#' # "amcl" -abname <- function(abcode, - from = c("guess", "atc", "certe", "umcg"), - to = 'official', - textbetween = ' + ', - tolower = FALSE) { - - if (length(to) != 1L) { - stop('`to` must be of length 1', call. = FALSE) - } - - if (to == "atc") { - return(as.character(as.atc(abcode))) - } - - abx <- AMR::antibiotics - - from <- from[1] - colnames(abx) <- colnames(abx) %>% tolower() - from <- from %>% tolower() - to <- to %>% tolower() - - if (!(from %in% colnames(abx) | from == "guess") | - !to %in% colnames(abx)) { - stop(paste0('Invalid `from` or `to`. Choose one of ', - colnames(abx) %>% paste(collapse = ", "), '.'), call. = FALSE) - } - - abcode <- as.character(abcode) - abcode.bak <- abcode - - for (i in 1:length(abcode)) { - if (abcode[i] %like% "[+]") { - # support for multiple ab's with + - parts <- trimws(strsplit(abcode[i], split = "+", fixed = TRUE)[[1]]) - ab1 <- abname(parts[1], from = from, to = to) - ab2 <- abname(parts[2], from = from, to = to) - if (missing(tolower)) { - ab2 <- tolower(ab2) - } - abcode[i] <- paste0(ab1, textbetween, ab2) - next - } - if (from %in% c("atc", "guess")) { - if (abcode[i] %in% abx$atc) { - abcode[i] <- abx[which(abx$atc == abcode[i]),] %>% pull(to) %>% .[1] - next - } - } - if (from %in% c("certe", "guess")) { - if (abcode[i] %in% abx$certe) { - abcode[i] <- abx[which(abx$certe == abcode[i]),] %>% pull(to) %>% .[1] - next - } - } - if (from %in% c("umcg", "guess")) { - if (abcode[i] %in% abx$umcg) { - abcode[i] <- abx[which(abx$umcg == abcode[i]),] %>% pull(to) %>% .[1] - next - } - } - if (from %in% c("trade_name", "guess")) { - if (abcode[i] %in% abx$trade_name) { - abcode[i] <- abx[which(abx$trade_name == abcode[i]),] %>% pull(to) %>% .[1] - next - } - if (sum(abx$trade_name %like% abcode[i]) > 0) { - abcode[i] <- abx[which(abx$trade_name %like% abcode[i]),] %>% pull(to) %>% .[1] - next - } - } - - if (from != "guess") { - # when not found, try any `from` - abcode[i] <- abx[which(abx[,from] == abcode[i]),] %>% pull(to) %>% .[1] - } - - if (is.na(abcode[i]) | length(abcode[i] == 0)) { - # try as.atc - try(suppressWarnings( - abcode[i] <- as.atc(abcode[i]) - ), silent = TRUE) - if (is.na(abcode[i])) { - # still not found - abcode[i] <- abcode.bak[i] - warning('Code "', abcode.bak[i], '" not found in antibiotics list.', call. = FALSE) - } else { - # fill in the found ATC code - abcode[i] <- abname(abcode[i], from = "atc", to = to) - } - } - } - - if (tolower == TRUE) { - abcode <- abcode %>% tolower() - } - - abcode -} diff --git a/R/age.R b/R/age.R index 1b3ff420e..47e1e502a 100755 --- a/R/age.R +++ b/R/age.R @@ -112,7 +112,7 @@ age <- function(x, reference = Sys.Date()) { #' mo == as.mo("E. coli")) %>% #' group_by(age_group = age_groups(age)) %>% #' select(age_group, -#' cipr) %>% +#' CIP) %>% #' ggplot_rsi(x = "age_group") age_groups <- function(x, split_at = c(12, 25, 55, 75)) { if (is.character(split_at)) { diff --git a/R/atc.R b/R/atc.R index 626e399bd..4e97ec946 100755 --- a/R/atc.R +++ b/R/atc.R @@ -44,118 +44,8 @@ #' as.atc(" eryt 123") #' as.atc("ERYT") #' as.atc("ERY") -#' as.atc("Erythrocin") # Trade name -#' as.atc("Eryzole") # Trade name -#' as.atc("Pediamycin") # Trade name -#' -#' # Use ab_* functions to get a specific property based on an ATC code -#' Cipro <- as.atc("cipro") # returns `J01MA02` -#' atc_official(Cipro) # returns "Ciprofloxacin" -#' atc_umcg(Cipro) # returns "CIPR", the code used in the UMCG as.atc <- function(x) { - - x.new <- rep(NA_character_, length(x)) - x <- trimws(x, which = "both") - # keep only a-z when it's not an ATC code - x[!x %like% "[A-Z][0-9]{2}[A-Z]{2}[0-9]{2}"] <- gsub("[^a-zA-Z]+", "", x[!x %like% "[A-Z][0-9]{2}[A-Z]{2}[0-9]{2}"]) - - x.bak <- x - x <- unique(x) - failures <- character(0) - - for (i in 1:length(x)) { - if (is.na(x[i]) | is.null(x[i]) | identical(x[i], "")) { - x.new[i] <- x[i] - next - } - - fail <- TRUE - - # first try atc - found <- AMR::antibiotics[which(AMR::antibiotics$atc == x[i]),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # try ATC in ATC code form, even if it does not exist in the antibiotics data set YET - if (length(found) == 0 & x[i] %like% '[A-Z][0-9][0-9][A-Z][A-Z][0-9][0-9]') { - warning("ATC code ", x[i], " is not yet in the `antibiotics` data set.") - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- x[i] - } - - # try abbreviation of EARS-Net/WHONET - found <- AMR::antibiotics[which(tolower(AMR::antibiotics$ears_net) == tolower(x[i])),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # try abbreviation of certe and glims - found <- AMR::antibiotics[which(tolower(AMR::antibiotics$certe) == tolower(x[i])),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - found <- AMR::antibiotics[which(tolower(AMR::antibiotics$umcg) == tolower(x[i])),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # try exact official name - found <- AMR::antibiotics[which(tolower(AMR::antibiotics$official) == tolower(x[i])),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # try exact official Dutch - found <- AMR::antibiotics[which(tolower(AMR::antibiotics$official_nl) == tolower(x[i])),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # try trade name - found <- AMR::antibiotics[which(paste0("(", AMR::antibiotics$trade_name, ")") %like% x[i]),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # try abbreviation - found <- AMR::antibiotics[which(paste0("(", AMR::antibiotics$abbr, ")") %like% x[i]),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - - # nothing helped, try first chars of official name, but only if nchar > 4 (cipro, nitro, fosfo) - if (nchar(x[i]) > 4) { - found <- AMR::antibiotics[which(AMR::antibiotics$official %like% paste0("^", substr(x[i], 1, 5))),]$atc - if (length(found) > 0) { - fail <- FALSE - x.new[is.na(x.new) & x.bak == x[i]] <- found[1L] - } - } - - # not found - if (fail == TRUE) { - failures <- c(failures, x[i]) - } - } - - failures <- failures[!failures %in% c(NA, NULL, NaN)] - if (length(failures) > 0) { - warning("These values could not be coerced to a valid atc: ", - paste('"', unique(failures), '"', sep = "", collapse = ', '), - ".", - call. = FALSE) - } - class(x.new) <- "atc" - x.new + ab_atc(x) } #' @rdname as.atc diff --git a/R/atc_property.R b/R/atc_property.R deleted file mode 100755 index b3a55ded3..000000000 --- a/R/atc_property.R +++ /dev/null @@ -1,107 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Analysis # -# # -# SOURCE # -# https://gitlab.com/msberends/AMR # -# # -# LICENCE # -# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# # -# This R package was created for academic research and was publicly # -# released in the hope that it will be useful, but it comes WITHOUT # -# ANY WARRANTY OR LIABILITY. # -# Visit our website for more info: https://msberends.gitlab.io/AMR. # -# ==================================================================== # - -#' Property of an antibiotic -#' -#' Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}. -#' @param x a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}} -#' @param property one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"} -#' @param language language of the returned text, defaults to English (\code{"en"}) and can be set with \code{\link{getOption}("AMR_locale")}. Either one of \code{"en"} (English) or \code{"nl"} (Dutch). -#' @rdname atc_property -#' @return A vector of values. In case of \code{atc_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names. -#' @export -#' @importFrom dplyr %>% left_join pull -#' @seealso \code{\link{antibiotics}} -#' @inheritSection AMR Read more on our website! -#' @examples -#' as.atc("amcl") # J01CR02 -#' atc_name("amcl") # Amoxicillin and beta-lactamase inhibitor -#' atc_name("amcl", "nl") # Amoxicilline met enzymremmer -#' atc_trivial_nl("amcl") # Amoxicilline/clavulaanzuur -#' atc_certe("amcl") # amcl -#' atc_umcg("amcl") # AMCL -atc_property <- function(x, property = 'official') { - property <- property[1] - if (!property %in% colnames(AMR::antibiotics)) { - stop("invalid property: ", property, " - use a column name of the `antibiotics` data set") - } - if (!is.atc(x)) { - x <- as.atc(x) # this will give a warning if x cannot be coerced - } - suppressWarnings( - data.frame(atc = x, stringsAsFactors = FALSE) %>% - left_join(AMR::antibiotics, by = "atc") %>% - pull(property) - ) -} - -#' @rdname atc_property -#' @export -atc_official <- function(x, language = NULL) { - - if (is.null(language)) { - language <- getOption("AMR_locale", default = "en")[1L] - } else { - language <- tolower(language[1]) - } - if (language %in% c("en", "")) { - atc_property(x, "official") - } else if (language == "nl") { - atc_property(x, "official_nl") - } else { - stop("Unsupported language: '", language, "' - use one of: 'en', 'nl'", call. = FALSE) - } -} - -#' @rdname atc_property -#' @export -atc_name <- atc_official - -#' @rdname atc_property -#' @export -atc_trivial_nl <- function(x) { - atc_property(x, "trivial_nl") -} - -#' @rdname atc_property -#' @export -atc_certe <- function(x) { - atc_property(x, "certe") -} - -#' @rdname atc_property -#' @export -atc_umcg <- function(x) { - atc_property(x, "umcg") -} - -#' @rdname atc_property -#' @export -atc_tradenames <- function(x) { - res <- atc_property(x, "trade_name") - res <- strsplit(res, "|", fixed = TRUE) - if (length(x) == 1) { - res <- unlist(res) - } else { - names(res) <- x - } - res -} diff --git a/R/count.R b/R/count.R index 0d56ce1f5..37f2e8cbd 100755 --- a/R/count.R +++ b/R/count.R @@ -44,55 +44,55 @@ #' ?septic_patients #' #' # Count resistant isolates -#' count_R(septic_patients$amox) -#' count_IR(septic_patients$amox) +#' count_R(septic_patients$AMX) +#' count_IR(septic_patients$AMX) #' #' # Or susceptible isolates -#' count_S(septic_patients$amox) -#' count_SI(septic_patients$amox) +#' count_S(septic_patients$AMX) +#' count_SI(septic_patients$AMX) #' #' # Count all available isolates -#' count_all(septic_patients$amox) -#' n_rsi(septic_patients$amox) +#' count_all(septic_patients$AMX) +#' n_rsi(septic_patients$AMX) #' #' # Since n_rsi counts available isolates, you can #' # calculate back to count e.g. non-susceptible isolates. #' # This results in the same: -#' count_IR(septic_patients$amox) -#' portion_IR(septic_patients$amox) * n_rsi(septic_patients$amox) +#' count_IR(septic_patients$AMX) +#' portion_IR(septic_patients$AMX) * n_rsi(septic_patients$AMX) #' #' library(dplyr) #' septic_patients %>% #' group_by(hospital_id) %>% -#' summarise(R = count_R(cipr), -#' I = count_I(cipr), -#' S = count_S(cipr), -#' n1 = count_all(cipr), # the actual total; sum of all three -#' n2 = n_rsi(cipr), # same - analogous to n_distinct +#' summarise(R = count_R(CIP), +#' I = count_I(CIP), +#' S = count_S(CIP), +#' n1 = count_all(CIP), # the actual total; sum of all three +#' n2 = n_rsi(CIP), # same - analogous to n_distinct #' total = n()) # NOT the number of tested isolates! #' #' # Count co-resistance between amoxicillin/clav acid and gentamicin, #' # so we can see that combination therapy does a lot more than mono therapy. #' # Please mind that `portion_S` calculates percentages right away instead. -#' count_S(septic_patients$amcl) # S = 1342 (71.4%) -#' count_all(septic_patients$amcl) # n = 1879 +#' count_S(septic_patients$AMC) # S = 1342 (71.4%) +#' count_all(septic_patients$AMC) # n = 1879 #' -#' count_S(septic_patients$gent) # S = 1372 (74.0%) -#' count_all(septic_patients$gent) # n = 1855 +#' count_S(septic_patients$GEN) # S = 1372 (74.0%) +#' count_all(septic_patients$GEN) # n = 1855 #' #' with(septic_patients, -#' count_S(amcl, gent)) # S = 1660 (92.3%) +#' count_S(AMC, GEN)) # S = 1660 (92.3%) #' with(septic_patients, # n = 1798 -#' n_rsi(amcl, gent)) +#' n_rsi(AMC, GEN)) #' #' # Get portions S/I/R immediately of all rsi columns #' septic_patients %>% -#' select(amox, cipr) %>% +#' select(AMX, CIP) %>% #' count_df(translate = FALSE) #' #' # It also supports grouping variables #' septic_patients %>% -#' select(hospital_id, amox, cipr) %>% +#' select(hospital_id, AMX, CIP) %>% #' group_by(hospital_id) %>% #' count_df(translate = FALSE) #' @@ -172,7 +172,8 @@ n_rsi <- function(...) { #' @importFrom dplyr %>% select_if bind_rows summarise_if mutate group_vars select everything #' @export count_df <- function(data, - translate_ab = getOption("get_antibiotic_names", "official"), + translate_ab = "name", + language = get_locale(), combine_IR = FALSE) { if (!"data.frame" %in% class(data)) { @@ -183,10 +184,9 @@ count_df <- function(data, stop("No columns with class 'rsi' found. See ?as.rsi.") } - if (as.character(translate_ab) == "TRUE") { - translate_ab <- "official" + if (as.character(translate_ab) %in% c("TRUE", "official")) { + translate_ab <- "name" } - options(get_antibiotic_names = translate_ab) resS <- summarise_if(.tbl = data, .predicate = is.rsi, @@ -227,10 +227,7 @@ count_df <- function(data, } if (!translate_ab == FALSE) { - if (!tolower(translate_ab) %in% tolower(colnames(AMR::antibiotics))) { - stop("Parameter `translate_ab` does not occur in the `antibiotics` data set.", call. = FALSE) - } - res <- res %>% mutate(Antibiotic = abname(Antibiotic, from = "guess", to = translate_ab)) + res <- res %>% mutate(Antibiotic = ab_property(Antibiotic, property = translate_ab, language = language)) } res diff --git a/R/data.R b/R/data.R index 5ca6e1c92..f5f57566b 100755 --- a/R/data.R +++ b/R/data.R @@ -19,115 +19,36 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -#' Data set with ~500 antibiotics +#' Data set with ~450 antibiotics #' -#' A data set containing all antibiotics with a J0 code and some other antimicrobial agents, with their DDDs. Except for trade names and abbreviations, all properties were downloaded from the WHO, see Source. -#' @format A \code{\link{data.frame}} with 488 observations and 17 variables: +#' A data set containing all antibiotics. Use \code{\link{as.ab}} or one of the \code{\link{ab_property}} functions to retrieve values from this data set. Three identifiers are included in this data set: an antibiotic ID (\code{ab}, primarily used in this package) as defined by WHONET/EARS-Net, an ATC code (\code{atc}) as defined by the WHO, and a Compound ID (\code{cid}) as found in PubChem. Other properties in this data set are derived from one or more of these codes. +#' @format A \code{\link{data.frame}} with 455 observations and 13 variables: #' \describe{ -#' \item{\code{atc}}{ATC code (Anatomical Therapeutic Chemical), like \code{J01CR02}} -#' \item{\code{ears_net}}{EARS-Net code (European Antimicrobial Resistance Surveillance Network), like \code{AMC}} -#' \item{\code{certe}}{Certe code, like \code{amcl}} -#' \item{\code{umcg}}{UMCG code, like \code{AMCL}} -#' \item{\code{abbr}}{Abbreviation as used by many countries, used internally by \code{\link{as.atc}}} -#' \item{\code{official}}{Official name by the WHO, like \code{"Amoxicillin and beta-lactamase inhibitor"}} -#' \item{\code{official_nl}}{Official name in the Netherlands, like \code{"Amoxicilline met enzymremmer"}} -#' \item{\code{trivial_nl}}{Trivial name in Dutch, like \code{"Amoxicilline/clavulaanzuur"}} -#' \item{\code{trade_name}}{Trade name as used by many countries (a total of 294), used internally by \code{\link{as.atc}}} +#' \item{\code{ab}}{Antibiotic ID as used in this package (like \code{AMC}), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available} +#' \item{\code{atc}}{ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC, like \code{J01CR02}} +#' \item{\code{cid}}{Compound ID as found in PubChem} +#' \item{\code{name}}{Official name as used by WHONET/EARS-Net or the WHO} +#' \item{\code{group}}{A short and concise group name, based on WHONET and WHOCC definitions} +#' \item{\code{atc_group1}}{Official pharmacological subgroup (3rd level ATC code) as defined by the WHOCC, like \code{"Macrolides, lincosamides and streptogramins"}} +#' \item{\code{atc_group2}}{Official chemical subgroup (4th level ATC code) as defined by the WHOCC, like \code{"Macrolides"}} +#' \item{\code{abbr}}{List of abbreviations as used in many countries, also for antibiotic susceptibility testing (AST)} +#' \item{\code{synonyms}}{Synonyms (often trade names) of a drug, as found in PubChem based on their compound ID} #' \item{\code{oral_ddd}}{Defined Daily Dose (DDD), oral treatment} #' \item{\code{oral_units}}{Units of \code{ddd_units}} #' \item{\code{iv_ddd}}{Defined Daily Dose (DDD), parenteral treatment} #' \item{\code{iv_units}}{Units of \code{iv_ddd}} -#' \item{\code{atc_group1}}{ATC group, like \code{"Macrolides, lincosamides and streptogramins"}} -#' \item{\code{atc_group2}}{Subgroup of \code{atc_group1}, like \code{"Macrolides"}} -#' \item{\code{useful_gramnegative}}{\code{FALSE} if not useful according to EUCAST, \code{NA} otherwise (see Source)} -#' \item{\code{useful_grampositive}}{\code{FALSE} if not useful according to EUCAST, \code{NA} otherwise (see Source)} #' } -#' @source World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/} +#' @details Properties that are based on an ATC code are only available when an ATC is available. These properties are: \code{atc_group1}, \code{atc_group2}, \code{oral_ddd}, \code{oral_units}, \code{iv_ddd} and \code{iv_units} #' -#' Table antibiotic coding EARSS (from WHONET 5.3): \url{http://www.madsonline.dk/Tutorials/landskoder_antibiotika_WM.pdf} +#' Synonyms (i.e. trade names) are derived from the Compound ID (\code{cid}) and consequently only available where a CID is available. +#' @source World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): \url{https://www.whocc.no/atc_ddd_index/} #' -#' EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016: \url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf} +#' WHONET 2019 software: \url{http://www.whonet.org/software.html} #' #' European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm} #' @inheritSection WHOCC WHOCC #' @inheritSection AMR Read more on our website! #' @seealso \code{\link{microorganisms}} -# use this later to further fill AMR::antibiotics -# drug <- "Ciprofloxacin" -# url <- xml2::read_html(paste0("https://www.ncbi.nlm.nih.gov/pccompound?term=", drug)) %>% -# html_nodes(".rslt") %>% -# .[[1]] %>% -# html_nodes(".title a") %>% -# html_attr("href") %>% -# gsub("/compound/", "/rest/pug_view/data/compound/", ., fixed = TRUE) %>% -# paste0("/XML/?response_type=display") -# synonyms <- url %>% -# read_xml() %>% -# xml_contents() %>% .[[6]] %>% -# xml_contents() %>% .[[8]] %>% -# xml_contents() %>% .[[3]] %>% -# xml_contents() %>% .[[3]] %>% -# xml_contents() %>% -# paste() %>% -# .[. %like% "StringValueList"] %>% -# gsub("[]+StringValueList[>]", "", .) - -# last two columns created with: -# antibiotics %>% -# mutate(useful_gramnegative = -# if_else( -# atc_group1 %like% '(fusidic|glycopeptide|macrolide|lincosamide|daptomycin|linezolid)' | -# atc_group2 %like% '(fusidic|glycopeptide|macrolide|lincosamide|daptomycin|linezolid)' | -# official %like% '(fusidic|glycopeptide|macrolide|lincosamide|daptomycin|linezolid)', -# FALSE, -# NA -# ), -# useful_grampositive = -# if_else( -# atc_group1 %like% '(aztreonam|temocillin|polymyxin|colistin|nalidixic)' | -# atc_group2 %like% '(aztreonam|temocillin|polymyxin|colistin|nalidixic)' | -# official %like% '(aztreonam|temocillin|polymyxin|colistin|nalidixic)', -# FALSE, -# NA -# ) -# ) -# -# ADD NEW TRADE NAMES FROM OTHER DATAFRAME -# antibiotics_add_to_property <- function(ab_df, atc, property, value) { -# if (length(atc) > 1L) { -# stop("only one atc at a time") -# } -# if (!property %in% c("abbr", "trade_name")) { -# stop("only possible for abbr and trade_name") -# } -# -# value <- gsub(ab_df[which(ab_df$atc == atc),] %>% pull("official"), "", value, fixed = TRUE) -# value <- gsub("||", "|", value, fixed = TRUE) -# value <- gsub("[äáàâ]", "a", value) -# value <- gsub("[ëéèê]", "e", value) -# value <- gsub("[ïíìî]", "i", value) -# value <- gsub("[öóòô]", "o", value) -# value <- gsub("[üúùû]", "u", value) -# if (!atc %in% ab_df$atc) { -# message("SKIPPING - UNKNOWN ATC: ", atc) -# } -# if (is.na(value)) { -# message("SKIPPING - VALUE MISSES: ", atc) -# } -# if (atc %in% ab_df$atc & !is.na(value)) { -# current <- ab_df[which(ab_df$atc == atc),] %>% pull(property) -# if (!is.na(current)) { -# value <- paste(current, value, sep = "|") -# } -# value <- strsplit(value, "|", fixed = TRUE) %>% unlist() %>% unique() %>% paste(collapse = "|") -# value <- gsub("||", "|", value, fixed = TRUE) -# # print(value) -# ab_df[which(ab_df$atc == atc), property] <- value -# message("Added ", value, " to ", ab_official(atc), " (", atc, ", ", ab_certe(atc), ")") -# } -# ab_df -# } -# "antibiotics" #' Data set with ~65,000 microorganisms @@ -262,6 +183,24 @@ catalogue_of_life <- list( #' @inheritSection AMR Read more on our website! "WHONET" +#' Data set for RSI interpretation +#' +#' Data set to interpret MIC and disk diffusion to RSI values. Included guidelines are CLSI (2011-2019) and EUCAST (2011-2019). Use \code{\link{as.rsi}} to transform MICs or disks measurements to RSI values. +#' @format A \code{\link{data.frame}} with 11,559 observations and 9 variables: +#' \describe{ +#' \item{\code{guideline}}{Name of the guideline} +#' \item{\code{mo}}{Microbial ID, see \code{\link{as.mo}}} +#' \item{\code{ab}}{Antibiotic ID, see \code{\link{as.ab}}} +#' \item{\code{ref_tbl}}{Info about where the guideline rule can be found} +#' \item{\code{S_mic}}{Lowest MIC value that leads to "S"} +#' \item{\code{R_mic}}{Highest MIC value that leads to "R"} +#' \item{\code{dose_disk}}{Dose of the used disk diffusion method} +#' \item{\code{S_disk}}{Lowest number of millimeters that leads to "S"} +#' \item{\code{R_disk}}{Highest number of millimeters that leads to "R"} +#' } +#' @inheritSection AMR Read more on our website! +"rsi_translation" + # transforms data set to data.frame with only ASCII values, to comply with CRAN policies dataset_UTF8_to_ASCII <- function(df) { trans <- function(vect) { @@ -270,14 +209,21 @@ dataset_UTF8_to_ASCII <- function(df) { df <- as.data.frame(df, stringsAsFactors = FALSE) for (i in 1:NCOL(df)) { col <- df[, i] - if (is.factor(col)) { - levels(col) <- trans(levels(col)) - } else if (is.character(col)) { - col <- trans(col) + if (is.list(col)) { + for (j in 1:length(col)) { + col[[j]] <- trans(col[[j]]) + } + df[, i] <- list(col) } else { - col + if (is.factor(col)) { + levels(col) <- trans(levels(col)) + } else if (is.character(col)) { + col <- trans(col) + } else { + col + } + df[, i] <- col } - df[, i] <- col } df } diff --git a/R/deprecated.R b/R/deprecated.R index a05acce73..44d6b6e40 100755 --- a/R/deprecated.R +++ b/R/deprecated.R @@ -49,71 +49,49 @@ ratio <- function(x, ratio) { #' @rdname AMR-deprecated #' @export -ab_property <- function(...) { - .Deprecated(new = "atc_property", package = "AMR") - atc_property(...) +abname <- function(...) { + .Deprecated("ab_name", package = "AMR") + ab_name(...) } #' @rdname AMR-deprecated #' @export -ab_atc <- function(...) { - .Deprecated(new = "as.atc", package = "AMR") - as.atc(...) +atc_property <- function(...) { + .Deprecated("ab_property", package = "AMR") + ab_property(...) +} + +#' @rdname AMR-deprecated +#' @export +atc_official <- function(...) { + .Deprecated("ab_name", package = "AMR") + ab_name(...) } #' @rdname AMR-deprecated #' @export ab_official <- function(...) { - .Deprecated(new = "atc_official", package = "AMR") - atc_official(...) + .Deprecated("ab_name", package = "AMR") + ab_name(...) } #' @rdname AMR-deprecated #' @export -ab_name <- function(...) { - .Deprecated(new = "atc_name", package = "AMR") - atc_name(...) +atc_name <- function(...) { + .Deprecated("ab_name", package = "AMR") + ab_name(...) } #' @rdname AMR-deprecated #' @export -ab_trivial_nl <- function(...) { - .Deprecated(new = "atc_trivial_nl", package = "AMR") - atc_trivial_nl(...) +atc_trivial_nl <- function(...) { + .Deprecated("ab_name", package = "AMR") + ab_name(..., language = "nl") } #' @rdname AMR-deprecated #' @export -ab_certe <- function(...) { - .Deprecated(new = "atc_certe", package = "AMR") - atc_certe(...) +atc_tradenames <- function(...) { + .Deprecated("ab_tradenames", package = "AMR") + ab_tradenames(...) } - -#' @rdname AMR-deprecated -#' @export -ab_umcg <- function(...) { - .Deprecated(new = "atc_umcg", package = "AMR") - atc_umcg(...) -} - -#' @rdname AMR-deprecated -#' @export -ab_tradenames <- function(...) { - .Deprecated(new = "atc_tradenames", package = "AMR") - atc_tradenames(...) -} - -#' @rdname AMR-deprecated -#' @export -atc_ddd <- function(...) { - .Deprecated(new = "atc_online_ddd", package = "AMR") - atc_online_ddd(...) -} - -#' @rdname AMR-deprecated -#' @export -atc_groups <- function(...) { - .Deprecated(new = "atc_online_groups", package = "AMR") - atc_online_groups(...) -} - diff --git a/R/disk.R b/R/disk.R new file mode 100644 index 000000000..efe84d8ae --- /dev/null +++ b/R/disk.R @@ -0,0 +1,92 @@ +# ==================================================================== # +# TITLE # +# Antimicrobial Resistance (AMR) Analysis # +# # +# SOURCE # +# https://gitlab.com/msberends/AMR # +# # +# LICENCE # +# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # +# # +# This R package is free software; you can freely use and distribute # +# it for both personal and commercial purposes under the terms of the # +# GNU General Public License version 2.0 (GNU GPL-2), as published by # +# the Free Software Foundation. # +# # +# This R package was created for academic research and was publicly # +# released in the hope that it will be useful, but it comes WITHOUT # +# ANY WARRANTY OR LIABILITY. # +# Visit our website for more info: https://msberends.gitlab.io/AMR. # +# ==================================================================== # + +#' Class 'disk' +#' +#' This transforms a vector to a new class \code{disk}, which is a growth zone size (around an antibiotic disk) in millimeters between 6 and 99. +#' @rdname as.disk +#' @param x vector +#' @param na.rm a logical indicating whether missing values should be removed +#' @details Interpret disk values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI. +#' @return Ordered integer factor with new class \code{disk} +#' @keywords disk +#' @export +#' @seealso \code{\link{as.rsi}} +#' @inheritSection AMR Read more on our website! +#' @examples +#' # interpret disk values +#' as.rsi(x = 12, +#' mo = as.mo("S. pneumoniae"), +#' ab = "AMX", +#' guideline = "EUCAST") +#' as.rsi(x = 12, +#' mo = as.mo("S. pneumoniae"), +#' ab = "AMX", +#' guideline = "CLSI") +as.disk <- function(x, na.rm = FALSE) { + if (is.disk(x)) { + x + } else { + x <- x %>% unlist() + if (na.rm == TRUE) { + x <- x[!is.na(x)] + } + x.bak <- x + + na_before <- length(x[is.na(x)]) + + # force it to be integer + x <- suppressWarnings(as.integer(x)) + + # disks can never be less than 9 mm (size of a disk) or more than 50 mm + x[x < 6 | x > 99] <- NA_integer_ + na_after <- length(x[is.na(x)]) + + if (na_before != na_after) { + list_missing <- x.bak[is.na(x) & !is.na(x.bak)] %>% + unique() %>% + sort() + list_missing <- paste0('"', list_missing , '"', collapse = ", ") + warning(na_after - na_before, ' results truncated (', + round(((na_after - na_before) / length(x)) * 100), + '%) that were invalid disk zones: ', + list_missing, call. = FALSE) + } + + class(x) <- c('disk', 'integer') + x + } +} + +#' @rdname as.disk +#' @export +#' @importFrom dplyr %>% +is.disk <- function(x) { + class(x) %>% identical(c('disk', 'integer')) +} + +#' @exportMethod print.disk +#' @export +#' @noRd +print.disk <- function(x, ...) { + cat("Class 'disk'\n") + print(as.integer(x), quote = FALSE) +} diff --git a/R/eucast_rules.R b/R/eucast_rules.R index b7012b5af..d43c2442a 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -27,94 +27,95 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' EUCAST rules #' #' Apply susceptibility rules as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}. This includes (1) expert rules, (2) intrinsic resistance and (3) inferred resistance as defined in their breakpoint tables. -#' @param x data with antibiotic columns, like e.g. \code{amox} and \code{amcl} +#' @param x data with antibiotic columns, like e.g. \code{AMX} and \code{AMC} #' @param info print progress #' @param rules a character vector that specifies which rules should be applied - one or more of \code{c("breakpoints", "expert", "other", "all")} #' @param verbose a logical to indicate whether extensive info should be returned as a \code{data.frame} with info about which rows and columns are effected. It runs all EUCAST rules, but will not be applied to an output - only an informative \code{data.frame} with changes will be returned as output. -#' @param amcl,amik,amox,ampi,azit,azlo,aztr,cefa,cfep,cfot,cfox,cfra,cfta,cftr,cfur,chlo,cipr,clar,clin,clox,coli,czol,dapt,doxy,erta,eryt,fosf,fusi,gent,imip,kana,levo,linc,line,mero,mezl,mino,moxi,nali,neom,neti,nitr,norf,novo,oflo,oxac,peni,pipe,pita,poly,pris,qida,rifa,roxi,siso,teic,tetr,tica,tige,tobr,trim,trsu,vanc column name of an antibiotic, see Antibiotics -#' @param ... parameters that are passed on to \code{eucast_rules} +#' @param ... column name of an antibiotic, see section Antibiotics #' @inheritParams first_isolate #' @details -#' \strong{NOTE:} This function does not translate MIC values to RSI values. It only applies (1) inferred susceptibility and resistance based on results of other antibiotics and (2) intrinsic resistance based on taxonomic properties of a microorganism. +#' \strong{Note:} This function does not translate MIC values to RSI values. Use \code{\link{as.rsi}} for that. \cr +#' \strong{Note:} When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. #' -#' The file used for applying all EUCAST rules can be retrieved with \code{\link{eucast_rules_file}()}. It returns an easily readable data set containing all rules. The original TSV file (tab separated file) that is being read by this function can be found when running this command: \cr +#' The file used for applying all EUCAST rules can be retrieved with \code{\link{eucast_rules_file}()}. It returns an easily readable data set containing all rules. The original TSV file (tab separated file) that is being read by \code{eucast_rules()} can be found by running this command: \cr #' \code{AMR::EUCAST_RULES_FILE_LOCATION} (without brackets). #' -#' In the source code it is located under \href{https://gitlab.com/msberends/AMR/blob/master/inst/eucast/eucast_rules.tsv}{\code{./inst/eucast/eucast_rules.tsv}}. +#' In the source code the file containing all rules is located \href{https://gitlab.com/msberends/AMR/blob/master/inst/eucast/eucast_rules.tsv}{here}. #' -#' \strong{Note:} When ampicillin (J01CA01) is not available but amoxicillin (J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. #' @section Antibiotics: -#' To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning. +#' To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive), or use \code{NULL} to skip a column (e.g. \code{TIC = NULL} to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning. #' -#' Abbrevations of the column containing antibiotics in the form: \strong{abbreviation}: generic name (\emph{ATC code}) +#' Available abbrevations of the column containing antibiotics in the form '\strong{antimicrobial ID}: name (\emph{ATC code})': #' -#' \strong{amcl}: amoxicillin+clavulanic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR02}{J01CR02}), -#' \strong{amik}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), -#' \strong{amox}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), -#' \strong{ampi}: ampicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA01}{J01CA01}), -#' \strong{azit}: azithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA10}{J01FA10}), -#' \strong{azlo}: azlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA09}{J01CA09}), -#' \strong{aztr}: aztreonam (\href{https://www.whocc.no/atc_ddd_index/?code=J01DF01}{J01DF01}), -#' \strong{cefa}: cefaloridine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB02}{J01DB02}), -#' \strong{cfep}: cefepime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DE01}{J01DE01}), -#' \strong{cfot}: cefotaxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD01}{J01DD01}), -#' \strong{cfox}: cefoxitin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC01}{J01DC01}), -#' \strong{cfra}: cefradine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB09}{J01DB09}), -#' \strong{cfta}: ceftazidime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD02}{J01DD02}), -#' \strong{cftr}: ceftriaxone (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD04}{J01DD04}), -#' \strong{cfur}: cefuroxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC02}{J01DC02}), -#' \strong{chlo}: chloramphenicol (\href{https://www.whocc.no/atc_ddd_index/?code=J01BA01}{J01BA01}), -#' \strong{cipr}: ciprofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA02}{J01MA02}), -#' \strong{clar}: clarithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA09}{J01FA09}), -#' \strong{clin}: clindamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF01}{J01FF01}), -#' \strong{clox}: flucloxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CF05}{J01CF05}), -#' \strong{coli}: colistin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB01}{J01XB01}), -#' \strong{czol}: cefazolin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB04}{J01DB04}), -#' \strong{dapt}: daptomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX09}{J01XX09}), -#' \strong{doxy}: doxycycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA02}{J01AA02}), -#' \strong{erta}: ertapenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH03}{J01DH03}), -#' \strong{eryt}: erythromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA01}{J01FA01}), -#' \strong{fosf}: fosfomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX01}{J01XX01}), -#' \strong{fusi}: fusidic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XC01}{J01XC01}), -#' \strong{gent}: gentamicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB03}{J01GB03}), -#' \strong{imip}: imipenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH51}{J01DH51}), -#' \strong{kana}: kanamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB04}{J01GB04}), -#' \strong{levo}: levofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA12}{J01MA12}), -#' \strong{linc}: lincomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF02}{J01FF02}), -#' \strong{line}: linezolid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX08}{J01XX08}), -#' \strong{mero}: meropenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH02}{J01DH02}), -#' \strong{mezl}: mezlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA10}{J01CA10}), -#' \strong{mino}: minocycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA08}{J01AA08}), -#' \strong{moxi}: moxifloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01MA14}), -#' \strong{nali}: nalidixic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01MB02}{J01MB02}), -#' \strong{neom}: neomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB05}{J01GB05}), -#' \strong{neti}: netilmicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB07}{J01GB07}), -#' \strong{nitr}: nitrofurantoin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XE01}{J01XE01}), -#' \strong{norf}: norfloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA06}{J01MA06}), -#' \strong{novo}: novobiocin (an ATCvet code: \href{https://www.whocc.no/atc_ddd_index/?code=QJ01XX95}{QJ01XX95}), -#' \strong{oflo}: ofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01MA01}), -#' \strong{peni}: (benzyl)penicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CE01}{J01CE01}), -#' \strong{pipe}: piperacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA12}{J01CA12}), -#' \strong{pita}: piperacillin+tazobactam (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR05}{J01CR05}), -#' \strong{poly}: polymyxin B (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB02}{J01XB02}), -#' \strong{pris}: pristinamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG01}{J01FG01}), -#' \strong{qida}: quinupristin/dalfopristin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG02}{J01FG02}), -#' \strong{rifa}: rifampicin (\href{https://www.whocc.no/atc_ddd_index/?code=J04AB02}{J04AB02}), -#' \strong{roxi}: roxithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA06}{J01FA06}), -#' \strong{siso}: sisomicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB08}{J01GB08}), -#' \strong{teic}: teicoplanin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA02}{J01XA02}), -#' \strong{tetr}: tetracycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA07}{J01AA07}), -#' \strong{tica}: ticarcillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA13}{J01CA13}), -#' \strong{tige}: tigecycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA12}{J01AA12}), -#' \strong{tobr}: tobramycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB01}{J01GB01}), -#' \strong{trim}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), -#' \strong{trsu}: sulfamethoxazole and trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), -#' \strong{vanc}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). +#' \strong{AMC}: amoxicillin/clavulanic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR02}{J01CR02}), +#' \strong{AMK}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), +#' \strong{AMX}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), +#' \strong{AMP}: ampicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA01}{J01CA01}), +#' \strong{AZM}: azithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA10}{J01FA10}), +#' \strong{AZL}: azlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA09}{J01CA09}), +#' \strong{ATM}: aztreonam (\href{https://www.whocc.no/atc_ddd_index/?code=J01DF01}{J01DF01}), +#' \strong{RID}: cefaloridine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB02}{J01DB02}), +#' \strong{FEP}: cefepime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DE01}{J01DE01}), +#' \strong{CTX}: cefotaxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD01}{J01DD01}), +#' \strong{FOX}: cefoxitin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC01}{J01DC01}), +#' \strong{CED}: cefradine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB09}{J01DB09}), +#' \strong{CAZ}: ceftazidime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD02}{J01DD02}), +#' \strong{CRO}: ceftriaxone (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD04}{J01DD04}), +#' \strong{CXM}: cefuroxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC02}{J01DC02}), +#' \strong{CHL}: chloramphenicol (\href{https://www.whocc.no/atc_ddd_index/?code=J01BA01}{J01BA01}), +#' \strong{CIP}: ciprofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA02}{J01MA02}), +#' \strong{CLR}: clarithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA09}{J01FA09}), +#' \strong{CLI}: clindamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF01}{J01FF01}), +#' \strong{FLC}: flucloxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CF05}{J01CF05}), +#' \strong{COL}: colistin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB01}{J01XB01}), +#' \strong{CZO}: cefazolin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB04}{J01DB04}), +#' \strong{DAP}: daptomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX09}{J01XX09}), +#' \strong{DOX}: doxycycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA02}{J01AA02}), +#' \strong{ETP}: ertapenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH03}{J01DH03}), +#' \strong{ERY}: erythromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA01}{J01FA01}), +#' \strong{FOS}: fosfomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX01}{J01XX01}), +#' \strong{FUS}: fusidic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XC01}{J01XC01}), +#' \strong{GEN}: gentamicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB03}{J01GB03}), +#' \strong{IPM}: imipenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH51}{J01DH51}), +#' \strong{KAN}: kanamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB04}{J01GB04}), +#' \strong{LVX}: levofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA12}{J01MA12}), +#' \strong{LIN}: lincomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF02}{J01FF02}), +#' \strong{LNZ}: linezolid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX08}{J01XX08}), +#' \strong{MEM}: meropenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH02}{J01DH02}), +#' \strong{MEZ}: mezlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA10}{J01CA10}), +#' \strong{MNO}: minocycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA08}{J01AA08}), +#' \strong{MFX}: moxifloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01MA14}), +#' \strong{MTR}: metronidazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01XD01}), +#' \strong{NAL}: nalidixic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01MB02}{J01MB02}), +#' \strong{NEO}: neomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB05}{J01GB05}), +#' \strong{NET}: netilmicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB07}{J01GB07}), +#' \strong{NIT}: nitrofurantoin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XE01}{J01XE01}), +#' \strong{NOR}: norfloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA06}{J01MA06}), +#' \strong{NOV}: novobiocin (an ATCvet code: \href{https://www.whocc.no/atc_ddd_index/?code=QJ01XX95}{QJ01XX95}), +#' \strong{OFX}: ofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01MA01}), +#' \strong{OXA}: oxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01CF04}), +#' \strong{PEN}: penicillin G (\href{https://www.whocc.no/atc_ddd_index/?code=J01CE01}{J01CE01}), +#' \strong{PIP}: piperacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA12}{J01CA12}), +#' \strong{TZP}: piperacillin/tazobactam (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR05}{J01CR05}), +#' \strong{PLB}: polymyxin B (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB02}{J01XB02}), +#' \strong{PRI}: pristinamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG01}{J01FG01}), +#' \strong{QDA}: quinupristin/dalfopristin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG02}{J01FG02}), +#' \strong{RIF}: rifampicin (\href{https://www.whocc.no/atc_ddd_index/?code=J04AB02}{J04AB02}), +#' \strong{RXT}: roxithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA06}{J01FA06}), +#' \strong{SIS}: sisomicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB08}{J01GB08}), +#' \strong{TEC}: teicoplanin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA02}{J01XA02}), +#' \strong{TCY}: tetracycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA07}{J01AA07}), +#' \strong{TIC}: ticarcillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA13}{J01CA13}), +#' \strong{TGC}: tigecycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA12}{J01AA12}), +#' \strong{TOB}: tobramycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB01}{J01GB01}), +#' \strong{TMP}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), +#' \strong{SXT}: trimethoprim/sulfamethoxazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), +#' \strong{VAN}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). #' @keywords interpretive eucast reading resistance #' @rdname eucast_rules #' @export #' @importFrom dplyr %>% select pull mutate_at vars group_by summarise n -#' @importFrom crayon bold bgGreen bgYellow bgRed black green blue italic strip_style +#' @importFrom crayon bold bgGreen bgYellow bgRed black green blue italic strip_style white #' @return The input of \code{tbl_}, possibly with edited values of antibiotics. Or, if \code{verbose = TRUE}, a \code{data.frame} with all original and new values of the affected bug-drug combinations. #' @source #' \itemize{ @@ -133,7 +134,7 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' } #' } #' -#' For editing the reference file (which is available with \code{\link{eucast_rules_file}}), these values can all be used for target antibiotics: aminoglycosides, tetracyclines, polymyxins, macrolides, glycopeptides, streptogramins, cephalosporins, cephalosporins_without_cfta, carbapenems, aminopenicillins, ureidopenicillins, fluoroquinolones, all_betalactams, and all separate four letter codes like amcl. They can be separated by comma: \code{"amcl, fluoroquinolones"}. The mo_property can be any column name from the \code{\link{microorganisms}} data set, or \code{genus_species} or \code{gramstain}. This file contains references to the 'Burkholderia cepacia complex'. The species in this group can be found in: LiPuma JJ, 2015 (PMID 16217180). +#' For editing the reference file (which is available with \code{\link{eucast_rules_file}}), these values can all be used for target antibiotics: aminoglycosides, tetracyclines, polymyxins, macrolides, glycopeptides, streptogramins, cephalosporins, cephalosporins_without_cfta, carbapenems, aminopenicillins, ureidopenicillins, fluoroquinolones, all_betalactams, and all separate four letter codes like AMC. They can be separated by comma: \code{"AMC, fluoroquinolones"}. The mo_property can be any column name from the \code{\link{microorganisms}} data set, or \code{genus_species} or \code{gramstain}. This file contains references to the 'Burkholderia cepacia complex'. The species in this group can be found in: LiPuma JJ, 2015 (PMID 16217180). #' @inheritSection AMR Read more on our website! #' @examples #' a <- eucast_rules(septic_patients) @@ -143,17 +144,17 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' "Escherichia coli", #' "Klebsiella pneumoniae", #' "Pseudomonas aeruginosa"), -#' vanc = "-", # Vancomycin -#' amox = "-", # Amoxicillin -#' coli = "-", # Colistin -#' cfta = "-", # Ceftazidime -#' cfur = "-", # Cefuroxime -#' peni = "S", # Benzylpenicillin -#' cfox = "S", # Cefoxitin +#' VAN = "-", # Vancomycin +#' AMX = "-", # Amoxicillin +#' COL = "-", # Colistin +#' CAZ = "-", # Ceftazidime +#' CXM = "-", # Cefuroxime +#' PEN = "S", # Penicillin G +#' FOX = "S", # Cefoxitin #' stringsAsFactors = FALSE) #' #' a -#' # mo vanc amox coli cfta cfur peni cfox +#' # mo VAN AMX COL CAZ CXM PEN FOX #' # 1 Staphylococcus aureus - - - - - S S #' # 2 Enterococcus faecalis - - - - - S S #' # 3 Escherichia coli - - - - - S S @@ -165,7 +166,7 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' b <- eucast_rules(a) #' #' b -#' # mo vanc amox coli cfta cfur peni cfox +#' # mo VAN AMX COL CAZ CXM PEN FOX #' # 1 Staphylococcus aureus - S R R S S S #' # 2 Enterococcus faecalis - - R R R S R #' # 3 Escherichia coli R - - - - R S @@ -181,81 +182,12 @@ eucast_rules <- function(x, info = TRUE, rules = c("breakpoints", "expert", "other", "all"), verbose = FALSE, - amcl = guess_ab_col(), - amik = guess_ab_col(), - amox = guess_ab_col(), - ampi = guess_ab_col(), - azit = guess_ab_col(), - azlo = guess_ab_col(), - aztr = guess_ab_col(), - cefa = guess_ab_col(), - cfep = guess_ab_col(), - cfot = guess_ab_col(), - cfox = guess_ab_col(), - cfra = guess_ab_col(), - cfta = guess_ab_col(), - cftr = guess_ab_col(), - cfur = guess_ab_col(), - chlo = guess_ab_col(), - cipr = guess_ab_col(), - clar = guess_ab_col(), - clin = guess_ab_col(), - clox = guess_ab_col(), - coli = guess_ab_col(), - czol = guess_ab_col(), - dapt = guess_ab_col(), - doxy = guess_ab_col(), - erta = guess_ab_col(), - eryt = guess_ab_col(), - fosf = guess_ab_col(), - fusi = guess_ab_col(), - gent = guess_ab_col(), - imip = guess_ab_col(), - kana = guess_ab_col(), - levo = guess_ab_col(), - linc = guess_ab_col(), - line = guess_ab_col(), - mero = guess_ab_col(), - mezl = guess_ab_col(), - mino = guess_ab_col(), - moxi = guess_ab_col(), - nali = guess_ab_col(), - neom = guess_ab_col(), - neti = guess_ab_col(), - nitr = guess_ab_col(), - norf = guess_ab_col(), - novo = guess_ab_col(), - oflo = guess_ab_col(), - oxac = guess_ab_col(), - peni = guess_ab_col(), - pipe = guess_ab_col(), - pita = guess_ab_col(), - poly = guess_ab_col(), - pris = guess_ab_col(), - qida = guess_ab_col(), - rifa = guess_ab_col(), - roxi = guess_ab_col(), - siso = guess_ab_col(), - teic = guess_ab_col(), - tetr = guess_ab_col(), - tica = guess_ab_col(), - tige = guess_ab_col(), - tobr = guess_ab_col(), - trim = guess_ab_col(), - trsu = guess_ab_col(), - vanc = guess_ab_col(), ...) { - - # support old `tbl` parameter - if ("tbl" %in% names(list(...))) { - x <- list(...)$tbl - } - tbl_ <- x if (!is.data.frame(tbl_)) { - stop("`tbl_` must be a data frame.", call. = FALSE) + stop("`x` must be a data frame.", call. = FALSE) } # try to find columns based on type @@ -277,7 +209,7 @@ eucast_rules <- function(x, warned <- FALSE - txt_error <- function() { cat("", bgRed(black(" ERROR ")), "\n") } + txt_error <- function() { cat("", bgRed(white(" ERROR ")), "\n") } txt_warning <- function() { if (warned == FALSE) { cat("", bgYellow(black(" WARNING ")), "\n") }; warned <<- TRUE } txt_ok <- function(no_of_changes) { if (warned == FALSE) { @@ -294,145 +226,137 @@ eucast_rules <- function(x, } } - # check columns - if (identical(amcl, as.name("guess_ab_col"))) { amcl <- guess_ab_col(tbl_, "amcl", verbose = verbose) } - if (identical(amik, as.name("guess_ab_col"))) { amik <- guess_ab_col(tbl_, "amik", verbose = verbose) } - if (identical(amox, as.name("guess_ab_col"))) { amox <- guess_ab_col(tbl_, "amox", verbose = verbose) } - if (identical(ampi, as.name("guess_ab_col"))) { ampi <- guess_ab_col(tbl_, "ampi", verbose = verbose) } - if (identical(azit, as.name("guess_ab_col"))) { azit <- guess_ab_col(tbl_, "azit", verbose = verbose) } - if (identical(azlo, as.name("guess_ab_col"))) { azlo <- guess_ab_col(tbl_, "azlo", verbose = verbose) } - if (identical(aztr, as.name("guess_ab_col"))) { aztr <- guess_ab_col(tbl_, "aztr", verbose = verbose) } - if (identical(cefa, as.name("guess_ab_col"))) { cefa <- guess_ab_col(tbl_, "cefa", verbose = verbose) } - if (identical(cfep, as.name("guess_ab_col"))) { cfep <- guess_ab_col(tbl_, "cfep", verbose = verbose) } - if (identical(cfot, as.name("guess_ab_col"))) { cfot <- guess_ab_col(tbl_, "cfot", verbose = verbose) } - if (identical(cfox, as.name("guess_ab_col"))) { cfox <- guess_ab_col(tbl_, "cfox", verbose = verbose) } - if (identical(cfra, as.name("guess_ab_col"))) { cfra <- guess_ab_col(tbl_, "cfra", verbose = verbose) } - if (identical(cfta, as.name("guess_ab_col"))) { cfta <- guess_ab_col(tbl_, "cfta", verbose = verbose) } - if (identical(cftr, as.name("guess_ab_col"))) { cftr <- guess_ab_col(tbl_, "cftr", verbose = verbose) } - if (identical(cfur, as.name("guess_ab_col"))) { cfur <- guess_ab_col(tbl_, "cfur", verbose = verbose) } - if (identical(chlo, as.name("guess_ab_col"))) { chlo <- guess_ab_col(tbl_, "chlo", verbose = verbose) } - if (identical(cipr, as.name("guess_ab_col"))) { cipr <- guess_ab_col(tbl_, "cipr", verbose = verbose) } - if (identical(clar, as.name("guess_ab_col"))) { clar <- guess_ab_col(tbl_, "clar", verbose = verbose) } - if (identical(clin, as.name("guess_ab_col"))) { clin <- guess_ab_col(tbl_, "clin", verbose = verbose) } - if (identical(clox, as.name("guess_ab_col"))) { clox <- guess_ab_col(tbl_, "clox", verbose = verbose) } - if (identical(coli, as.name("guess_ab_col"))) { coli <- guess_ab_col(tbl_, "coli", verbose = verbose) } - if (identical(czol, as.name("guess_ab_col"))) { czol <- guess_ab_col(tbl_, "czol", verbose = verbose) } - if (identical(dapt, as.name("guess_ab_col"))) { dapt <- guess_ab_col(tbl_, "dapt", verbose = verbose) } - if (identical(doxy, as.name("guess_ab_col"))) { doxy <- guess_ab_col(tbl_, "doxy", verbose = verbose) } - if (identical(erta, as.name("guess_ab_col"))) { erta <- guess_ab_col(tbl_, "erta", verbose = verbose) } - if (identical(eryt, as.name("guess_ab_col"))) { eryt <- guess_ab_col(tbl_, "eryt", verbose = verbose) } - if (identical(fosf, as.name("guess_ab_col"))) { fosf <- guess_ab_col(tbl_, "fosf", verbose = verbose) } - if (identical(fusi, as.name("guess_ab_col"))) { fusi <- guess_ab_col(tbl_, "fusi", verbose = verbose) } - if (identical(gent, as.name("guess_ab_col"))) { gent <- guess_ab_col(tbl_, "gent", verbose = verbose) } - if (identical(imip, as.name("guess_ab_col"))) { imip <- guess_ab_col(tbl_, "imip", verbose = verbose) } - if (identical(kana, as.name("guess_ab_col"))) { kana <- guess_ab_col(tbl_, "kana", verbose = verbose) } - if (identical(levo, as.name("guess_ab_col"))) { levo <- guess_ab_col(tbl_, "levo", verbose = verbose) } - if (identical(linc, as.name("guess_ab_col"))) { linc <- guess_ab_col(tbl_, "linc", verbose = verbose) } - if (identical(line, as.name("guess_ab_col"))) { line <- guess_ab_col(tbl_, "line", verbose = verbose) } - if (identical(mero, as.name("guess_ab_col"))) { mero <- guess_ab_col(tbl_, "mero", verbose = verbose) } - if (identical(mezl, as.name("guess_ab_col"))) { mezl <- guess_ab_col(tbl_, "mezl", verbose = verbose) } - if (identical(mino, as.name("guess_ab_col"))) { mino <- guess_ab_col(tbl_, "mino", verbose = verbose) } - if (identical(moxi, as.name("guess_ab_col"))) { moxi <- guess_ab_col(tbl_, "moxi", verbose = verbose) } - if (identical(nali, as.name("guess_ab_col"))) { nali <- guess_ab_col(tbl_, "nali", verbose = verbose) } - if (identical(neom, as.name("guess_ab_col"))) { neom <- guess_ab_col(tbl_, "neom", verbose = verbose) } - if (identical(neti, as.name("guess_ab_col"))) { neti <- guess_ab_col(tbl_, "neti", verbose = verbose) } - if (identical(nitr, as.name("guess_ab_col"))) { nitr <- guess_ab_col(tbl_, "nitr", verbose = verbose) } - if (identical(norf, as.name("guess_ab_col"))) { norf <- guess_ab_col(tbl_, "norf", verbose = verbose) } - if (identical(novo, as.name("guess_ab_col"))) { novo <- guess_ab_col(tbl_, "novo", verbose = verbose) } - if (identical(oflo, as.name("guess_ab_col"))) { oflo <- guess_ab_col(tbl_, "oflo", verbose = verbose) } - if (identical(oxac, as.name("guess_ab_col"))) { oxac <- guess_ab_col(tbl_, "oxac", verbose = verbose) } - if (identical(peni, as.name("guess_ab_col"))) { peni <- guess_ab_col(tbl_, "peni", verbose = verbose) } - if (identical(pipe, as.name("guess_ab_col"))) { pipe <- guess_ab_col(tbl_, "pipe", verbose = verbose) } - if (identical(pita, as.name("guess_ab_col"))) { pita <- guess_ab_col(tbl_, "pita", verbose = verbose) } - if (identical(poly, as.name("guess_ab_col"))) { poly <- guess_ab_col(tbl_, "poly", verbose = verbose) } - if (identical(pris, as.name("guess_ab_col"))) { pris <- guess_ab_col(tbl_, "pris", verbose = verbose) } - if (identical(qida, as.name("guess_ab_col"))) { qida <- guess_ab_col(tbl_, "qida", verbose = verbose) } - if (identical(rifa, as.name("guess_ab_col"))) { rifa <- guess_ab_col(tbl_, "rifa", verbose = verbose) } - if (identical(roxi, as.name("guess_ab_col"))) { roxi <- guess_ab_col(tbl_, "roxi", verbose = verbose) } - if (identical(siso, as.name("guess_ab_col"))) { siso <- guess_ab_col(tbl_, "siso", verbose = verbose) } - if (identical(teic, as.name("guess_ab_col"))) { teic <- guess_ab_col(tbl_, "teic", verbose = verbose) } - if (identical(tetr, as.name("guess_ab_col"))) { tetr <- guess_ab_col(tbl_, "tetr", verbose = verbose) } - if (identical(tica, as.name("guess_ab_col"))) { tica <- guess_ab_col(tbl_, "tica", verbose = verbose) } - if (identical(tige, as.name("guess_ab_col"))) { tige <- guess_ab_col(tbl_, "tige", verbose = verbose) } - if (identical(tobr, as.name("guess_ab_col"))) { tobr <- guess_ab_col(tbl_, "tobr", verbose = verbose) } - if (identical(trim, as.name("guess_ab_col"))) { trim <- guess_ab_col(tbl_, "trim", verbose = verbose) } - if (identical(trsu, as.name("guess_ab_col"))) { trsu <- guess_ab_col(tbl_, "trsu", verbose = verbose) } - if (identical(vanc, as.name("guess_ab_col"))) { vanc <- guess_ab_col(tbl_, "vanc", verbose = verbose) } - col.list <- c(amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfra, cfep, cfot, - cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, - czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, - levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, - novo, norf, oflo, oxac, peni, pipe, pita, poly, pris, qida, rifa, - roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc) - if (length(col.list) < 63) { - warning('Some columns do not exist -- THIS MAY STRONGLY INFLUENCE THE OUTCOME.', - immediate. = TRUE, - call. = FALSE) - } - col.list <- check_available_columns(tbl = tbl_, col.list = col.list, info = info) - amcl <- col.list[amcl] - amik <- col.list[amik] - amox <- col.list[amox] - ampi <- col.list[ampi] - azit <- col.list[azit] - azlo <- col.list[azlo] - aztr <- col.list[aztr] - cefa <- col.list[cefa] - cfep <- col.list[cfep] - cfot <- col.list[cfot] - cfox <- col.list[cfox] - cfra <- col.list[cfra] - cfta <- col.list[cfta] - cftr <- col.list[cftr] - cfur <- col.list[cfur] - chlo <- col.list[chlo] - cipr <- col.list[cipr] - clar <- col.list[clar] - clin <- col.list[clin] - clox <- col.list[clox] - coli <- col.list[coli] - czol <- col.list[czol] - dapt <- col.list[dapt] - doxy <- col.list[doxy] - erta <- col.list[erta] - eryt <- col.list[eryt] - fosf <- col.list[fosf] - fusi <- col.list[fusi] - gent <- col.list[gent] - imip <- col.list[imip] - kana <- col.list[kana] - levo <- col.list[levo] - linc <- col.list[linc] - line <- col.list[line] - mero <- col.list[mero] - mezl <- col.list[mezl] - mino <- col.list[mino] - moxi <- col.list[moxi] - nali <- col.list[nali] - neom <- col.list[neom] - neti <- col.list[neti] - nitr <- col.list[nitr] - norf <- col.list[norf] - novo <- col.list[novo] - oflo <- col.list[oflo] - oxac <- col.list[oxac] - peni <- col.list[peni] - pipe <- col.list[pipe] - pita <- col.list[pita] - poly <- col.list[poly] - pris <- col.list[pris] - qida <- col.list[qida] - rifa <- col.list[rifa] - roxi <- col.list[roxi] - siso <- col.list[siso] - teic <- col.list[teic] - tetr <- col.list[tetr] - tica <- col.list[tica] - tige <- col.list[tige] - tobr <- col.list[tobr] - trim <- col.list[trim] - trsu <- col.list[trsu] - vanc <- col.list[vanc] + cols_ab <- get_column_abx(tbl = x, + soft_dependencies = c("AMC", + "AMK", + "AMX", + "AMP", + "AZM", + "AZL", + "ATM", + "RID", + "FEP", + "CTX", + "FOX", + "CED", + "CAZ", + "CRO", + "CXM", + "CHL", + "CIP", + "CLR", + "CLI", + "FLC", + "COL", + "CZO", + "DAP", + "DOX", + "ETP", + "ERY", + "FOS", + "FUS", + "GEN", + "IPM", + "KAN", + "LVX", + "LIN", + "LNZ", + "MEM", + "MEZ", + "MNO", + "MFX", + "NAL", + "NEO", + "NET", + "NIT", + "NOR", + "NOV", + "OFX", + "OXA", + "PEN", + "PIP", + "TZP", + "PLB", + "PRI", + "QDA", + "RIF", + "RXT", + "SIS", + "TEC", + "TCY", + "TIC", + "TGC", + "TOB", + "TMP", + "SXT", + "VAN"), + hard_dependencies = NULL, + verbose = verbose, + ...) + + AMC <- cols_ab['AMC'] + AMK <- cols_ab['AMK'] + AMP <- cols_ab['AMP'] + AMX <- cols_ab['AMX'] + ATM <- cols_ab['ATM'] + AZL <- cols_ab['AZL'] + AZM <- cols_ab['AZM'] + CAZ <- cols_ab['CAZ'] + CED <- cols_ab['CED'] + CHL <- cols_ab['CHL'] + CIP <- cols_ab['CIP'] + CLI <- cols_ab['CLI'] + CLR <- cols_ab['CLR'] + COL <- cols_ab['COL'] + CRO <- cols_ab['CRO'] + CTX <- cols_ab['CTX'] + CXM <- cols_ab['CXM'] + CZO <- cols_ab['CZO'] + DAP <- cols_ab['DAP'] + DOX <- cols_ab['DOX'] + ERY <- cols_ab['ERY'] + ETP <- cols_ab['ETP'] + FEP <- cols_ab['FEP'] + FLC <- cols_ab['FLC'] + FOS <- cols_ab['FOS'] + FOX <- cols_ab['FOX'] + FUS <- cols_ab['FUS'] + GEN <- cols_ab['GEN'] + IPM <- cols_ab['IPM'] + KAN <- cols_ab['KAN'] + LIN <- cols_ab['LIN'] + LNZ <- cols_ab['LNZ'] + LVX <- cols_ab['LVX'] + MEM <- cols_ab['MEM'] + MEZ <- cols_ab['MEZ'] + MFX <- cols_ab['MFX'] + MNO <- cols_ab['MNO'] + NAL <- cols_ab['NAL'] + NEO <- cols_ab['NEO'] + NET <- cols_ab['NET'] + NIT <- cols_ab['NIT'] + NOR <- cols_ab['NOR'] + NOV <- cols_ab['NOV'] + OFX <- cols_ab['OFX'] + OXA <- cols_ab['OXA'] + PEN <- cols_ab['PEN'] + PIP <- cols_ab['PIP'] + PLB <- cols_ab['PLB'] + PRI <- cols_ab['PRI'] + QDA <- cols_ab['QDA'] + RID <- cols_ab['RID'] + RIF <- cols_ab['RIF'] + RXT <- cols_ab['RXT'] + SIS <- cols_ab['SIS'] + SXT <- cols_ab['SXT'] + TCY <- cols_ab['TCY'] + TEC <- cols_ab['TEC'] + TGC <- cols_ab['TGC'] + TIC <- cols_ab['TIC'] + TMP <- cols_ab['TMP'] + TOB <- cols_ab['TOB'] + TZP <- cols_ab['TZP'] + VAN <- cols_ab['VAN'] ab_missing <- function(ab) { all(ab %in% c(NULL, NA)) @@ -521,41 +445,41 @@ eucast_rules <- function(x, } # since ampicillin ^= amoxicillin, get the first from the latter (not in original EUCAST table) - if (!ab_missing(ampi) & !ab_missing(amox)) { + if (!ab_missing(AMP) & !ab_missing(AMX)) { if (verbose == TRUE) { cat("\n VERBOSE: transforming", - length(which(tbl_[, amox] == "S" & !tbl_[, ampi] %in% c("S", "I", "R"))), + length(which(tbl_[, AMX] == "S" & !tbl_[, AMP] %in% c("S", "I", "R"))), "empty ampicillin fields to 'S' based on amoxicillin. ") cat("\n VERBOSE: transforming", - length(which(tbl_[, amox] == "I" & !tbl_[, ampi] %in% c("S", "I", "R"))), + length(which(tbl_[, AMX] == "I" & !tbl_[, AMP] %in% c("S", "I", "R"))), "empty ampicillin fields to 'I' based on amoxicillin. ") cat("\n VERBOSE: transforming", - length(which(tbl_[, amox] == "R" & !tbl_[, ampi] %in% c("S", "I", "R"))), + length(which(tbl_[, AMX] == "R" & !tbl_[, AMP] %in% c("S", "I", "R"))), "empty ampicillin fields to 'R' based on amoxicillin. \n") } - tbl_[which(tbl_[, amox] == "S" & !tbl_[, ampi] %in% c("S", "I", "R")), ampi] <- "S" - tbl_[which(tbl_[, amox] == "I" & !tbl_[, ampi] %in% c("S", "I", "R")), ampi] <- "I" - tbl_[which(tbl_[, amox] == "R" & !tbl_[, ampi] %in% c("S", "I", "R")), ampi] <- "R" - } else if (ab_missing(ampi) & !ab_missing(amox)) { + tbl_[which(tbl_[, AMX] == "S" & !tbl_[, AMP] %in% c("S", "I", "R")), AMP] <- "S" + tbl_[which(tbl_[, AMX] == "I" & !tbl_[, AMP] %in% c("S", "I", "R")), AMP] <- "I" + tbl_[which(tbl_[, AMX] == "R" & !tbl_[, AMP] %in% c("S", "I", "R")), AMP] <- "R" + } else if (ab_missing(AMP) & !ab_missing(AMX)) { # ampicillin column is missing, but amoxicillin is available - message(blue(paste0("NOTE: Using column `", bold(amox), "` as input for ampicillin (J01CA01) since many EUCAST rules depend on it."))) - ampi <- amox + message(blue(paste0("NOTE: Using column `", bold(AMX), "` as input for ampicillin (J01CA01) since many EUCAST rules depend on it."))) + AMP <- AMX } # antibiotic classes - aminoglycosides <- c(tobr, gent, kana, neom, neti, siso) - tetracyclines <- c(doxy, mino, tetr) # since EUCAST v3.1 tige(cycline) is set apart - polymyxins <- c(poly, coli) - macrolides <- c(eryt, azit, roxi, clar) # since EUCAST v3.1 clinda is set apart - glycopeptides <- c(vanc, teic) - streptogramins <- c(qida, pris) # should officially also be quinupristin/dalfopristin - cephalosporins <- c(cfep, cfot, cfox, cfra, cfta, cftr, cfur, czol) - cephalosporins_without_cfta <- cephalosporins[cephalosporins != ifelse(is.null(cfta), "", cfta)] - carbapenems <- c(erta, imip, mero) - aminopenicillins <- c(ampi, amox) - ureidopenicillins <- c(pipe, pita, azlo, mezl) - fluoroquinolones <- c(oflo, cipr, norf, levo, moxi) - all_betalactams <- c(aminopenicillins, ureidopenicillins, cephalosporins, carbapenems, amcl, oxac, clox, peni) + aminoglycosides <- c(TOB, GEN, KAN, NEO, NET, SIS) + tetracyclines <- c(DOX, MNO, TCY) # since EUCAST v3.1 tigecycline (TGC) is set apart + polymyxins <- c(PLB, COL) + macrolides <- c(ERY, AZM, RXT, CLR) # since EUCAST v3.1 clinda is set apart + glycopeptides <- c(VAN, TEC) + streptogramins <- c(QDA, PRI) # should officially also be quinupristin/dalfopristin + aminopenicillins <- c(AMP, AMX) + cephalosporins <- c(FEP, CTX, FOX, CED, CAZ, CRO, CXM, CZO) + cephalosporins_without_CAZ <- cephalosporins[cephalosporins != ifelse(is.null(CAZ), "", CAZ)] + carbapenems <- c(ETP, IPM, MEM) + ureidopenicillins <- c(PIP, TZP, AZL, MEZ) + all_betalactams <- c(aminopenicillins, cephalosporins, carbapenems, ureidopenicillins, AMC, OXA, FLC, PEN) + fluoroquinolones <- c(OFX, CIP, NOR, LVX, MFX) # Help function to get available antibiotic column names ------------------ get_antibiotic_columns <- function(x, df) { @@ -578,7 +502,7 @@ eucast_rules <- function(x, rule_group_current <- eucast_rules_df[i, "reference.rule_group"] rule_group_next <- eucast_rules_df[min(nrow(eucast_rules_df), i + 1), "reference.rule_group"] if (is.na(eucast_rules_df[i, 4])) { - rule_text <- paste(eucast_rules_df[i, 6], "=", eucast_rules_df[i, 7]) + rule_text <- paste("always:", eucast_rules_df[i, 6], "=", eucast_rules_df[i, 7]) } else { rule_text <- paste("if", eucast_rules_df[i, 4], "=", eucast_rules_df[i, 5], "then", eucast_rules_df[i, 6], "=", eucast_rules_df[i, 7]) diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R index 9b7c4631d..50dc44382 100644 --- a/R/filter_ab_class.R +++ b/R/filter_ab_class.R @@ -39,9 +39,9 @@ #' # filter on isolates that have any result for any aminoglycoside #' septic_patients %>% filter_aminoglycosides() #' -#' # this is essentially the same as: +#' # this is essentially the same as (but without determination of column names): #' septic_patients %>% -#' filter_at(.vars = vars(c("gent", "tobr", "amik", "kana")), +#' filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")), #' .vars_predicate = any_vars(. %in% c("S", "I", "R"))) #' #' @@ -264,7 +264,8 @@ filter_tetracyclines <- function(tbl, ab_class_vars <- function(ab_class) { ab_vars <- AMR::antibiotics %>% filter_at(vars(c("atc_group1", "atc_group2")), any_vars(. %like% ab_class)) %>% - select(atc:trade_name) %>% + select(ab:name, abbreviations, synonyms) %>% + unlist() %>% as.matrix() %>% as.character() %>% paste(collapse = "|") %>% @@ -289,7 +290,7 @@ ab_class_atcgroups <- function(ab_class) { "tetracycline"), paste0(ab_class, "s"), AMR::antibiotics %>% - filter(atc %in% ab_class_vars(ab_class)) %>% + filter(ab %in% ab_class_vars(ab_class)) %>% pull("atc_group2") %>% unique() %>% tolower() %>% diff --git a/R/first_isolate.R b/R/first_isolate.R index 5c2f1e7b1..224b6a8dc 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -98,14 +98,14 @@ #' # Now let's see if first isolates matter: #' A <- septic_patients %>% #' group_by(hospital_id) %>% -#' summarise(count = n_rsi(gent), # gentamicin availability -#' resistance = portion_IR(gent)) # gentamicin resistance +#' summarise(count = n_rsi(GEN), # gentamicin availability +#' resistance = portion_IR(GEN)) # gentamicin resistance #' #' B <- septic_patients %>% -#' filter_first_weighted_isolate() %>% # the 1st isolate filter +#' filter_first_weighted_isolate() %>% # the 1st isolate filter #' group_by(hospital_id) %>% -#' summarise(count = n_rsi(gent), # gentamicin availability -#' resistance = portion_IR(gent)) # gentamicin resistance +#' summarise(count = n_rsi(GEN), # gentamicin availability +#' resistance = portion_IR(GEN)) # gentamicin resistance #' #' # Have a look at A and B. #' # B is more reliable because every isolate is only counted once. diff --git a/R/freq.R b/R/freq.R index 431227f84..305bb3f10 100755 --- a/R/freq.R +++ b/R/freq.R @@ -181,8 +181,8 @@ #' #' #' # check differences between frequency tables -#' diff(freq(septic_patients$trim), -#' freq(septic_patients$trsu)) +#' diff(freq(septic_patients$TMP), +#' freq(septic_patients$SXT)) frequency_tbl <- function(x, ..., sort.count = TRUE, @@ -419,8 +419,8 @@ frequency_tbl <- function(x, } if (any(class(x) == "rsi")) { - header_list$count_S <- max(0, sum(x == "S", na.rm = TRUE), na.rm = TRUE) - header_list$count_IR <- max(0, sum(x %in% c("I", "R"), na.rm = TRUE), na.rm = TRUE) + header_list$count_SI <- max(0, sum(x %in% c("S", "I"), na.rm = TRUE), na.rm = TRUE) + header_list$count_R <- max(0, sum(x == "R", na.rm = TRUE), na.rm = TRUE) } formatdates <- "%e %B %Y" # = d mmmm yyyy @@ -565,14 +565,15 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ", # FORMATTING # rsi if (has_length == TRUE & any(x_class == "rsi")) { - ab <- tryCatch(atc_name(attributes(x)$opt$vars), error = function(e) NA) + ab <- tryCatch(as.ab(attributes(x)$opt$vars), error = function(e) NA) if (!is.na(ab)) { - header$drug <- ab[1L] + header$drug <- paste0(ab_name(ab[1L]), " (", ab[1L], ", ", ab_atc(ab[1L]), ")") + header$group <- ab_group(ab[1L]) } - header$`%IR` <- percent(header$count_IR / (header$count_S + header$count_IR), + header$`%SI` <- percent(header$count_SI / (header$count_SI + header$count_R), force_zero = TRUE, round = digits, decimal.mark = decimal.mark) } - header <- header[!names(header) %in% c("count_S", "count_IR")] + header <- header[!names(header) %in% c("count_SI", "count_R")] # dates if (!is.null(header$date_format)) { if (header$date_format == "%H:%M:%S") { diff --git a/R/get_locale.R b/R/get_locale.R index fc6584adb..991ddb9b7 100755 --- a/R/get_locale.R +++ b/R/get_locale.R @@ -19,20 +19,53 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -#' Get language for AMR +#' Translate strings from AMR package #' -#' Determines the system language to be used for language-dependent output of AMR functions, like \code{\link{mo_gramstain}} and \code{\link{mo_type}}. -#' @details The system language can be overwritten with \code{\link{getOption}("AMR_locale")}. -#' @section Supported languages: -#' Supported languages are \code{"en"} (English), \code{"de"} (German), \code{"nl"} (Dutch), \code{"es"} (Spanish), \code{"it"} (Italian), \code{"fr"} (French), and \code{"pt"} (Portuguese). +#' For language-dependent output of AMR functions, like \code{\link{mo_fullname}} and \code{\link{mo_type}}. +#' @details Strings will be translated to foreign languages if they are defined in a local translation file. This file comes with this package and can be found when running: +#' +#' \code{system.file("translations.tsv", package = "AMR")} +#' +#' This file will be read by all functions where a translated output can be desired, like all \code{\link{mo_property}} functions (\code{\link{mo_fullname}}, \code{\link{mo_type}}, etc.). Please suggest your own translations \href{https://gitlab.com/msberends/AMR/issues/new?issue[title]=Translation suggestion}{by creating a new issue on our repository}. +#' +#' The system language will be used at default, if supported, using \code{\link{get_locale}}. The system language can be overwritten with \code{\link{getOption}("AMR_locale")}. #' @inheritSection AMR Read more on our website! +#' @rdname translate +#' @name translate #' @export +#' @examples +#' # The 'language' parameter of below functions +#' # will be set automatically to your system language +#' # with get_locale() +#' +#' # English +#' mo_fullname("CoNS", language = "en") +#' #> "Coagulase-negative Staphylococcus (CoNS)" +#' +#' # German +#' mo_fullname("CoNS", language = "de") +#' #> "Koagulase-negative Staphylococcus (KNS)" +#' +#' # Dutch +#' mo_fullname("CoNS", language = "nl") +#' #> "Coagulase-negatieve Staphylococcus (CNS)" +#' +#' # Spanish +#' mo_fullname("CoNS", language = "es") +#' #> "Staphylococcus coagulasa negativo (SCN)" +#' +#' # Italian +#' mo_fullname("CoNS", language = "it") +#' #> "Staphylococcus negativo coagulasi (CoNS)" +#' +#' # Portuguese +#' mo_fullname("CoNS", language = "pt") +#' #> "Staphylococcus coagulase negativo (CoNS)" get_locale <- function() { - if (!is.null(getOption("AMR_locale"))) { - if (getOption("AMR_locale") %in% c("en", "de", "nl", "es", "it", "fr", "pt")) { - return(getOption("AMR_locale")) - } + if (getOption("AMR_locale", "en") != "en") { + return(getOption("AMR_locale")) } + lang <- Sys.getlocale("LC_COLLATE") # grepl with case = FALSE is faster than like if (grepl("^(English|en_|EN_)", lang, ignore.case = FALSE)) { diff --git a/R/ggplot_rsi.R b/R/ggplot_rsi.R index 988c99b21..dad04951d 100755 --- a/R/ggplot_rsi.R +++ b/R/ggplot_rsi.R @@ -29,14 +29,15 @@ #' @param breaks numeric vector of positions #' @param limits numeric vector of length two providing limits of the scale, use \code{NA} to refer to the existing minimum or maximum #' @param facet variable to split plots by, either \code{"Interpretation"} (default) or \code{"Antibiotic"} or a grouping variable -#' @param translate_ab a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations into, using \code{\link{abname}}. Default behaviour is to translate to official names according to the WHO. Use \code{translate_ab = FALSE} to disable translation. +#' @param translate_ab a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations into, using \code{\link{ab_name}}. Default behaviour is to translate to official names according to the WHO. Use \code{translate_ab = FALSE} to disable translation. +#' @param language the language used for translation of antibiotic names #' @param fun function to transform \code{data}, either \code{\link{count_df}} (default) or \code{\link{portion_df}} #' @param nrow (when using \code{facet}) number of rows #' @param datalabels show datalabels using \code{labels_rsi_count}, will at default only be shown when \code{fun = count_df} #' @param datalabels.size size of the datalabels #' @param datalabels.colour colour of the datalabels #' @param ... other parameters passed on to \code{geom_rsi} -#' @details At default, the names of antibiotics will be shown on the plots using \code{\link{abname}}. This can be set with the option \code{get_antibiotic_names} (a logical value), so change it e.g. to \code{FALSE} with \code{options(get_antibiotic_names = FALSE)}. +#' @details At default, the names of antibiotics will be shown on the plots using \code{\link{ab_name}}. This can be set with the option \code{get_antibiotic_names} (a logical value), so change it e.g. to \code{FALSE} with \code{options(get_antibiotic_names = FALSE)}. #' #' \strong{The functions}\cr #' \code{geom_rsi} will take any variable from the data that has an \code{rsi} class (created with \code{\link{as.rsi}}) using \code{fun} (\code{\link{count_df}} at default, can also be \code{\link{portion_df}}) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis. @@ -61,11 +62,11 @@ #' library(ggplot2) #' #' # get antimicrobial results for drugs against a UTI: -#' ggplot(septic_patients %>% select(amox, nitr, fosf, trim, cipr)) + +#' ggplot(septic_patients %>% select(AMX, NIT, FOS, TMP, CIP)) + #' geom_rsi() #' #' # prettify the plot using some additional functions: -#' df <- septic_patients[, c("amox", "nitr", "fosf", "trim", "cipr")] +#' df <- septic_patients[, c("AMX", "NIT", "FOS", "TMP", "CIP")] #' ggplot(df) + #' geom_rsi() + #' scale_y_percent() + @@ -75,17 +76,17 @@ #' #' # or better yet, simplify this using the wrapper function - a single command: #' septic_patients %>% -#' select(amox, nitr, fosf, trim, cipr) %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% #' ggplot_rsi() #' #' # get only portions and no counts: #' septic_patients %>% -#' select(amox, nitr, fosf, trim, cipr) %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% #' ggplot_rsi(fun = portion_df) #' #' # add other ggplot2 parameters as you like: #' septic_patients %>% -#' select(amox, nitr, fosf, trim, cipr) %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% #' ggplot_rsi(width = 0.5, #' colour = "black", #' size = 1, @@ -100,19 +101,19 @@ #' # `age_group` is also a function of this package: #' group_by(age_group = age_groups(age)) %>% #' select(age_group, -#' cipr) %>% +#' CIP) %>% #' ggplot_rsi(x = "age_group") #' \donttest{ #' #' # for colourblind mode, use divergent colours from the viridis package: #' septic_patients %>% -#' select(amox, nitr, fosf, trim, cipr) %>% +#' select(AMX, NIT, FOS, TMP, CIP) %>% #' ggplot_rsi() + scale_fill_viridis_d() #' #' #' # it also supports groups (don't forget to use the group var on `x` or `facet`): #' septic_patients %>% -#' select(hospital_id, amox, nitr, fosf, trim, cipr) %>% +#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>% #' group_by(hospital_id) %>% #' ggplot_rsi(x = hospital_id, #' facet = Antibiotic, @@ -136,7 +137,7 @@ #' # get short MO names (like "E. coli") #' mutate(mo = mo_shortname(mo, Becker = TRUE)) %>% #' # select this short name and some antiseptic drugs -#' select(mo, cfur, gent, cipr) %>% +#' select(mo, CXM, GEN, CIP) %>% #' # group by MO #' group_by(mo) %>% #' # plot the thing, putting MOs on the facet @@ -156,7 +157,8 @@ ggplot_rsi <- function(data, facet = NULL, breaks = seq(0, 1, 0.1), limits = NULL, - translate_ab = "official", + translate_ab = "name", + language = get_locale(), fun = count_df, nrow = NULL, datalabels = TRUE, @@ -229,7 +231,8 @@ ggplot_rsi <- function(data, geom_rsi <- function(position = NULL, x = c("Antibiotic", "Interpretation"), fill = "Interpretation", - translate_ab = "official", + translate_ab = "name", + language = get_locale(), fun = count_df, ...) { @@ -267,8 +270,6 @@ geom_rsi <- function(position = NULL, x <- "Interpretation" } - options(get_antibiotic_names = translate_ab) - ggplot2::layer(geom = "bar", stat = "identity", position = position, mapping = ggplot2::aes_string(x = x, y = y, fill = fill), data = fun, params = list(...)) diff --git a/R/globals.R b/R/globals.R index df54682c8..2bf59970f 100755 --- a/R/globals.R +++ b/R/globals.R @@ -21,13 +21,14 @@ globalVariables(c(".", "..property", + "ab", + "abbreviations", "antibiotic", "Antibiotic", "antibiotics", "atc", "authors", "Becker", - "certe", "CNS_CPS", "cnt", "col_id", @@ -56,8 +57,10 @@ globalVariables(c(".", "kingdom", "labs", "Lancefield", + "lang", "Last name", "lbl", + "lookup", "median", "mic", "microorganisms", @@ -70,6 +73,7 @@ globalVariables(c(".", "mo", "mo.old", "more_than_episode_ago", + "MPM", "n", "name", "new", @@ -92,6 +96,7 @@ globalVariables(c(".", "ref", "reference.rule", "reference.rule_group", + "rsi", "rule_group", "rule_name", "S", @@ -103,12 +108,13 @@ globalVariables(c(".", "species", "species_id", "subspecies", + "synonyms", "trade_name", + "trans", "transmute", "tsn", "tsn_new", "txt", - "umcg", "value", "Value", "x", diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R index 92feeb1fa..80eccb97f 100755 --- a/R/guess_ab_col.R +++ b/R/guess_ab_col.R @@ -35,7 +35,7 @@ #' #' guess_ab_col(df, "amoxicillin") #' # [1] "amox" -#' guess_ab_col(df, "J01AA07") # ATC code of Tetracycline +#' guess_ab_col(df, "J01AA07") # ATC code of tetracycline #' # [1] "tetr" #' #' guess_ab_col(df, "J01AA07", verbose = TRUE) @@ -49,7 +49,7 @@ #' # [1] "AMP_ND10" #' guess_ab_col(df, "J01CR02") #' # [1] "AMC_ED20" -#' guess_ab_col(df, as.atc("augmentin")) +#' guess_ab_col(df, as.ab("augmentin")) #' # [1] "AMC_ED20" guess_ab_col <- function(tbl = NULL, col = NULL, verbose = FALSE) { if (is.null(tbl) & is.null(col)) { @@ -60,77 +60,21 @@ guess_ab_col <- function(tbl = NULL, col = NULL, verbose = FALSE) { warning("argument 'col' has length > 1 and only the first element will be used") col <- col[1] } + col <- as.character(col) if (!is.data.frame(tbl)) { stop("`tbl` must be a data.frame") } - tbl_names <- colnames(tbl) - tbl_names_stripped <- colnames(tbl) %>% - strsplit("_") %>% - lapply(function(x) {x[1]}) %>% - unlist() - - if (col %in% tbl_names) { - if (verbose == TRUE) { - message(blue(paste0("NOTE: Using column `", bold(col), "` as input for `", col, "`."))) - } - return(col) - } - ab_result <- antibiotics %>% - select(atc:trade_name) %>% - filter_all(any_vars(tolower(.) == tolower(col))) %>% - filter_all(any_vars(. %in% tbl_names)) - - if (nrow(ab_result) == 0 & nchar(col) >= 5) { - # use like when col >= 5 characters - ab_result <- antibiotics %>% - select(atc:trade_name) %>% - filter_all(any_vars(tolower(.) %like% tolower(col))) %>% - filter_all(any_vars(. %in% tbl_names)) - } - - # WHONET - if (nrow(ab_result) == 0) { - # use like for any case - ab_result <- antibiotics %>% - select(atc:trade_name) %>% - filter_all(any_vars(tolower(.) == tolower(col))) %>% - filter_all(any_vars(. %in% tbl_names_stripped)) - } - - found_based_on_official_name <- FALSE - if (nrow(ab_result) == 0) { - # check if first part of official name resembles the columns that's been looking for - name <- suppressWarnings(atc_name(col)) - if (!is.null(name)) { - ab_result <- - antibiotics %>% - filter(official == name) %>% - pull(official) - ab_result <- tbl_names[tbl_names %like% paste0("^", substr(ab_result, 1, 5))] - found_based_on_official_name <- TRUE - } - } - - if (NROW(ab_result) > 1 & found_based_on_official_name == FALSE) { - # looking more and more for reliable hit - ab_result_1 <- ab_result %>% filter(tolower(atc) == tolower(col)) - if (nrow(ab_result_1) == 0) { - ab_result_1 <- ab_result %>% filter(tolower(certe) == tolower(col)) - } - if (nrow(ab_result_1) == 0) { - ab_result_1 <- ab_result %>% filter(tolower(umcg) == tolower(col)) - } - if (nrow(ab_result_1) == 0) { - ab_result_1 <- ab_result %>% filter(tolower(official) == tolower(col)) - } - if (nrow(ab_result_1) == 0) { - ab_result_1 <- ab_result %>% filter(tolower(official) == tolower(col)) - } - if (nrow(ab_result_1) == 0) { - ab_result_1 <- ab_result[1, ] - } - ab_result <- ab_result_1 + if (col %in% colnames(tbl)) { + ab_result <- col + } else { + # sort colnames on length - longest first + cols <- colnames(tbl[, tbl %>% colnames() %>% nchar() %>% order() %>% rev()]) + df_trans <- data.frame(cols = cols, + abs = suppressWarnings(as.ab(cols)), + stringsAsFactors = FALSE) + ab_result <- df_trans[which(df_trans$abs == as.ab(col)), "cols"] + ab_result <- ab_result[!is.na(ab_result)][1L] } if (length(ab_result) == 0) { @@ -139,19 +83,9 @@ guess_ab_col <- function(tbl = NULL, col = NULL, verbose = FALSE) { } return(NULL) } else { - result <- tbl_names[tbl_names %in% ab_result] - if (length(result) == 0) { - result <- tbl_names[tbl_names_stripped %in% ab_result] - } - if (length(result) == 0 | length(result) > 1) { - if (verbose == TRUE) { - message('No column found as input for `', col, '`.') - } - return(NULL) - } if (verbose == TRUE) { - message(blue(paste0("NOTE: Using column `", bold(result), "` as input for `", col, "`."))) + message(blue(paste0("NOTE: Using column `", bold(ab_result), "` as input for `", col, "`."))) } - return(result) + return(ab_result) } } diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 67527eeb4..6ffd98043 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -78,24 +78,24 @@ #' # FALSE, because I is not ignored and so the 4th value differs key_antibiotics <- function(tbl, col_mo = NULL, - universal_1 = guess_ab_col(tbl, "amox"), - universal_2 = guess_ab_col(tbl, "amcl"), - universal_3 = guess_ab_col(tbl, "cfur"), - universal_4 = guess_ab_col(tbl, "pita"), - universal_5 = guess_ab_col(tbl, "cipr"), - universal_6 = guess_ab_col(tbl, "trsu"), - GramPos_1 = guess_ab_col(tbl, "vanc"), - GramPos_2 = guess_ab_col(tbl, "teic"), - GramPos_3 = guess_ab_col(tbl, "tetr"), - GramPos_4 = guess_ab_col(tbl, "eryt"), - GramPos_5 = guess_ab_col(tbl, "oxac"), - GramPos_6 = guess_ab_col(tbl, "rifa"), - GramNeg_1 = guess_ab_col(tbl, "gent"), - GramNeg_2 = guess_ab_col(tbl, "tobr"), - GramNeg_3 = guess_ab_col(tbl, "coli"), - GramNeg_4 = guess_ab_col(tbl, "cfot"), - GramNeg_5 = guess_ab_col(tbl, "cfta"), - GramNeg_6 = guess_ab_col(tbl, "mero"), + universal_1 = guess_ab_col(tbl, "AMX"), + universal_2 = guess_ab_col(tbl, "AMC"), + universal_3 = guess_ab_col(tbl, "CXM"), + universal_4 = guess_ab_col(tbl, "TZP"), + universal_5 = guess_ab_col(tbl, "CIP"), + universal_6 = guess_ab_col(tbl, "SXT"), + GramPos_1 = guess_ab_col(tbl, "VAN"), + GramPos_2 = guess_ab_col(tbl, "TEC"), + GramPos_3 = guess_ab_col(tbl, "TCY"), + GramPos_4 = guess_ab_col(tbl, "ERY"), + GramPos_5 = guess_ab_col(tbl, "OXA"), + GramPos_6 = guess_ab_col(tbl, "RIF"), + GramNeg_1 = guess_ab_col(tbl, "GEN"), + GramNeg_2 = guess_ab_col(tbl, "TOB"), + GramNeg_3 = guess_ab_col(tbl, "COL"), + GramNeg_4 = guess_ab_col(tbl, "CTX"), + GramNeg_5 = guess_ab_col(tbl, "CAZ"), + GramNeg_6 = guess_ab_col(tbl, "MEM"), warnings = TRUE, ...) { @@ -112,6 +112,35 @@ key_antibiotics <- function(tbl, col.list <- c(universal_1, universal_2, universal_3, universal_4, universal_5, universal_6, GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6, GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6) + check_available_columns <- function(tbl, col.list, info = TRUE) { + # check columns + col.list <- col.list[!is.na(col.list) & !is.null(col.list)] + names(col.list) <- col.list + col.list.bak <- col.list + # are they available as upper case or lower case then? + for (i in 1:length(col.list)) { + if (is.null(col.list[i]) | isTRUE(is.na(col.list[i]))) { + col.list[i] <- NA + } else if (toupper(col.list[i]) %in% colnames(tbl)) { + col.list[i] <- toupper(col.list[i]) + } else if (tolower(col.list[i]) %in% colnames(tbl)) { + col.list[i] <- tolower(col.list[i]) + } else if (!col.list[i] %in% colnames(tbl)) { + col.list[i] <- NA + } + } + if (!all(col.list %in% colnames(tbl))) { + if (info == TRUE) { + warning('Some columns do not exist and will be ignored: ', + col.list.bak[!(col.list %in% colnames(tbl))] %>% toString(), + '.\nTHIS MAY STRONGLY INFLUENCE THE OUTCOME.', + immediate. = TRUE, + call. = FALSE) + } + } + col.list + } + col.list <- check_available_columns(tbl = tbl, col.list = col.list, info = warnings) universal_1 <- col.list[universal_1] universal_2 <- col.list[universal_2] @@ -139,11 +168,19 @@ key_antibiotics <- function(tbl, GramPos_1, GramPos_2, GramPos_3, GramPos_4, GramPos_5, GramPos_6) gram_positive <- gram_positive[!is.null(gram_positive)] + gram_positive <- gram_positive[!is.na(gram_positive)] + if (length(gram_positive) < 12) { + warning("only using ", length(gram_positive), " different antibiotics as key antibiotics for Gram positives. See ?key_antibiotics.", call. = FALSE) + } gram_negative = c(universal, GramNeg_1, GramNeg_2, GramNeg_3, GramNeg_4, GramNeg_5, GramNeg_6) gram_negative <- gram_negative[!is.null(gram_negative)] + gram_negative <- gram_negative[!is.na(gram_negative)] + if (length(gram_negative) < 12) { + warning("only using ", length(gram_negative), " different antibiotics as key antibiotics for Gram negatives. See ?key_antibiotics.", call. = FALSE) + } # join to microorganisms data set tbl <- tbl %>% diff --git a/R/mdro.R b/R/mdro.R index 4ee55c631..d244422bd 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -22,13 +22,11 @@ #' Determine multidrug-resistant organisms (MDRO) #' #' Determine which isolates are multidrug-resistant organisms (MDRO) according to country-specific guidelines. -#' @param tbl table with antibiotic columns, like e.g. \code{amox} and \code{amcl} +#' @param x table with antibiotic columns, like e.g. \code{AMX} and \code{AMC} #' @param country country code to determine guidelines. EUCAST rules will be used when left empty, see Details. Should be or a code from the \href{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements}{list of ISO 3166-1 alpha-2 country codes}. Case-insensitive. Currently supported are \code{de} (Germany) and \code{nl} (the Netherlands). #' @param info print progress #' @inheritParams eucast_rules -#' @param metr column name of an antibiotic, see Antibiotics #' @param verbose print additional info: missing antibiotic columns per parameter -#' @param ... parameters that are passed on to methods #' @inheritSection eucast_rules Antibiotics #' @details When \code{country} will be left blank, guidelines will be taken from EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\href{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{link}). #' @return Ordered factor with levels \code{Negative < Positive, unconfirmed < Positive}. @@ -43,86 +41,28 @@ #' septic_patients %>% #' mutate(EUCAST = mdro(.), #' BRMO = brmo(.)) -mdro <- function(tbl, +mdro <- function(x, country = NULL, col_mo = NULL, info = TRUE, - amcl = guess_ab_col(), - amik = guess_ab_col(), - amox = guess_ab_col(), - ampi = guess_ab_col(), - azit = guess_ab_col(), - aztr = guess_ab_col(), - cefa = guess_ab_col(), - cfra = guess_ab_col(), - cfep = guess_ab_col(), - cfot = guess_ab_col(), - cfox = guess_ab_col(), - cfta = guess_ab_col(), - cftr = guess_ab_col(), - cfur = guess_ab_col(), - chlo = guess_ab_col(), - cipr = guess_ab_col(), - clar = guess_ab_col(), - clin = guess_ab_col(), - clox = guess_ab_col(), - coli = guess_ab_col(), - czol = guess_ab_col(), - dapt = guess_ab_col(), - doxy = guess_ab_col(), - erta = guess_ab_col(), - eryt = guess_ab_col(), - fosf = guess_ab_col(), - fusi = guess_ab_col(), - gent = guess_ab_col(), - imip = guess_ab_col(), - kana = guess_ab_col(), - levo = guess_ab_col(), - linc = guess_ab_col(), - line = guess_ab_col(), - mero = guess_ab_col(), - metr = guess_ab_col(), - mino = guess_ab_col(), - moxi = guess_ab_col(), - nali = guess_ab_col(), - neom = guess_ab_col(), - neti = guess_ab_col(), - nitr = guess_ab_col(), - novo = guess_ab_col(), - norf = guess_ab_col(), - oflo = guess_ab_col(), - peni = guess_ab_col(), - pipe = guess_ab_col(), - pita = guess_ab_col(), - poly = guess_ab_col(), - qida = guess_ab_col(), - rifa = guess_ab_col(), - roxi = guess_ab_col(), - siso = guess_ab_col(), - teic = guess_ab_col(), - tetr = guess_ab_col(), - tica = guess_ab_col(), - tige = guess_ab_col(), - tobr = guess_ab_col(), - trim = guess_ab_col(), - trsu = guess_ab_col(), - vanc = guess_ab_col(), - verbose = FALSE) { + verbose = FALSE, + ...) { - if (!is.data.frame(tbl)) { - stop("`tbl` must be a data frame.", call. = FALSE) + tbl_ <- x + + if (!is.data.frame(tbl_)) { + stop("`x` must be a data frame.", call. = FALSE) } # try to find columns based on type # -- mo if (is.null(col_mo)) { - col_mo <- search_type_in_df(tbl = tbl, type = "mo") + col_mo <- search_type_in_df(tbl = tbl_, type = "mo") } if (is.null(col_mo)) { stop("`col_mo` must be set.", call. = FALSE) } - # strip whitespaces if (length(country) > 1) { stop('`country` must be a length one character string.', call. = FALSE) } @@ -169,169 +109,105 @@ mdro <- function(tbl, "\n", sep = "") } - # check columns - if (identical(amcl, as.name("guess_ab_col"))) { amcl <- guess_ab_col(tbl, "amcl", verbose = verbose) } - if (identical(amik, as.name("guess_ab_col"))) { amik <- guess_ab_col(tbl, "amik", verbose = verbose) } - if (identical(amox, as.name("guess_ab_col"))) { amox <- guess_ab_col(tbl, "amox", verbose = verbose) } - if (identical(ampi, as.name("guess_ab_col"))) { ampi <- guess_ab_col(tbl, "ampi", verbose = verbose) } - if (identical(azit, as.name("guess_ab_col"))) { azit <- guess_ab_col(tbl, "azit", verbose = verbose) } - if (identical(aztr, as.name("guess_ab_col"))) { aztr <- guess_ab_col(tbl, "aztr", verbose = verbose) } - if (identical(cefa, as.name("guess_ab_col"))) { cefa <- guess_ab_col(tbl, "cefa", verbose = verbose) } - if (identical(cfra, as.name("guess_ab_col"))) { cfra <- guess_ab_col(tbl, "cfra", verbose = verbose) } - if (identical(cfep, as.name("guess_ab_col"))) { cfep <- guess_ab_col(tbl, "cfep", verbose = verbose) } - if (identical(cfot, as.name("guess_ab_col"))) { cfot <- guess_ab_col(tbl, "cfot", verbose = verbose) } - if (identical(cfox, as.name("guess_ab_col"))) { cfox <- guess_ab_col(tbl, "cfox", verbose = verbose) } - if (identical(cfta, as.name("guess_ab_col"))) { cfta <- guess_ab_col(tbl, "cfta", verbose = verbose) } - if (identical(cftr, as.name("guess_ab_col"))) { cftr <- guess_ab_col(tbl, "cftr", verbose = verbose) } - if (identical(cfur, as.name("guess_ab_col"))) { cfur <- guess_ab_col(tbl, "cfur", verbose = verbose) } - if (identical(chlo, as.name("guess_ab_col"))) { chlo <- guess_ab_col(tbl, "chlo", verbose = verbose) } - if (identical(cipr, as.name("guess_ab_col"))) { cipr <- guess_ab_col(tbl, "cipr", verbose = verbose) } - if (identical(clar, as.name("guess_ab_col"))) { clar <- guess_ab_col(tbl, "clar", verbose = verbose) } - if (identical(clin, as.name("guess_ab_col"))) { clin <- guess_ab_col(tbl, "clin", verbose = verbose) } - if (identical(clox, as.name("guess_ab_col"))) { clox <- guess_ab_col(tbl, "clox", verbose = verbose) } - if (identical(coli, as.name("guess_ab_col"))) { coli <- guess_ab_col(tbl, "coli", verbose = verbose) } - if (identical(czol, as.name("guess_ab_col"))) { czol <- guess_ab_col(tbl, "czol", verbose = verbose) } - if (identical(dapt, as.name("guess_ab_col"))) { dapt <- guess_ab_col(tbl, "dapt", verbose = verbose) } - if (identical(doxy, as.name("guess_ab_col"))) { doxy <- guess_ab_col(tbl, "doxy", verbose = verbose) } - if (identical(erta, as.name("guess_ab_col"))) { erta <- guess_ab_col(tbl, "erta", verbose = verbose) } - if (identical(eryt, as.name("guess_ab_col"))) { eryt <- guess_ab_col(tbl, "eryt", verbose = verbose) } - if (identical(fosf, as.name("guess_ab_col"))) { fosf <- guess_ab_col(tbl, "fosf", verbose = verbose) } - if (identical(fusi, as.name("guess_ab_col"))) { fusi <- guess_ab_col(tbl, "fusi", verbose = verbose) } - if (identical(gent, as.name("guess_ab_col"))) { gent <- guess_ab_col(tbl, "gent", verbose = verbose) } - if (identical(imip, as.name("guess_ab_col"))) { imip <- guess_ab_col(tbl, "imip", verbose = verbose) } - if (identical(kana, as.name("guess_ab_col"))) { kana <- guess_ab_col(tbl, "kana", verbose = verbose) } - if (identical(levo, as.name("guess_ab_col"))) { levo <- guess_ab_col(tbl, "levo", verbose = verbose) } - if (identical(linc, as.name("guess_ab_col"))) { linc <- guess_ab_col(tbl, "linc", verbose = verbose) } - if (identical(line, as.name("guess_ab_col"))) { line <- guess_ab_col(tbl, "line", verbose = verbose) } - if (identical(mero, as.name("guess_ab_col"))) { mero <- guess_ab_col(tbl, "mero", verbose = verbose) } - if (identical(metr, as.name("guess_ab_col"))) { metr <- guess_ab_col(tbl, "metr", verbose = verbose) } - if (identical(mino, as.name("guess_ab_col"))) { mino <- guess_ab_col(tbl, "mino", verbose = verbose) } - if (identical(moxi, as.name("guess_ab_col"))) { moxi <- guess_ab_col(tbl, "moxi", verbose = verbose) } - if (identical(nali, as.name("guess_ab_col"))) { nali <- guess_ab_col(tbl, "nali", verbose = verbose) } - if (identical(neom, as.name("guess_ab_col"))) { neom <- guess_ab_col(tbl, "neom", verbose = verbose) } - if (identical(neti, as.name("guess_ab_col"))) { neti <- guess_ab_col(tbl, "neti", verbose = verbose) } - if (identical(nitr, as.name("guess_ab_col"))) { nitr <- guess_ab_col(tbl, "nitr", verbose = verbose) } - if (identical(novo, as.name("guess_ab_col"))) { novo <- guess_ab_col(tbl, "novo", verbose = verbose) } - if (identical(norf, as.name("guess_ab_col"))) { norf <- guess_ab_col(tbl, "norf", verbose = verbose) } - if (identical(oflo, as.name("guess_ab_col"))) { oflo <- guess_ab_col(tbl, "oflo", verbose = verbose) } - if (identical(peni, as.name("guess_ab_col"))) { peni <- guess_ab_col(tbl, "peni", verbose = verbose) } - if (identical(pipe, as.name("guess_ab_col"))) { pipe <- guess_ab_col(tbl, "pipe", verbose = verbose) } - if (identical(pita, as.name("guess_ab_col"))) { pita <- guess_ab_col(tbl, "pita", verbose = verbose) } - if (identical(poly, as.name("guess_ab_col"))) { poly <- guess_ab_col(tbl, "poly", verbose = verbose) } - if (identical(qida, as.name("guess_ab_col"))) { qida <- guess_ab_col(tbl, "qida", verbose = verbose) } - if (identical(rifa, as.name("guess_ab_col"))) { rifa <- guess_ab_col(tbl, "rifa", verbose = verbose) } - if (identical(roxi, as.name("guess_ab_col"))) { roxi <- guess_ab_col(tbl, "roxi", verbose = verbose) } - if (identical(siso, as.name("guess_ab_col"))) { siso <- guess_ab_col(tbl, "siso", verbose = verbose) } - if (identical(teic, as.name("guess_ab_col"))) { teic <- guess_ab_col(tbl, "teic", verbose = verbose) } - if (identical(tetr, as.name("guess_ab_col"))) { tetr <- guess_ab_col(tbl, "tetr", verbose = verbose) } - if (identical(tica, as.name("guess_ab_col"))) { tica <- guess_ab_col(tbl, "tica", verbose = verbose) } - if (identical(tige, as.name("guess_ab_col"))) { tige <- guess_ab_col(tbl, "tige", verbose = verbose) } - if (identical(tobr, as.name("guess_ab_col"))) { tobr <- guess_ab_col(tbl, "tobr", verbose = verbose) } - if (identical(trim, as.name("guess_ab_col"))) { trim <- guess_ab_col(tbl, "trim", verbose = verbose) } - if (identical(trsu, as.name("guess_ab_col"))) { trsu <- guess_ab_col(tbl, "trsu", verbose = verbose) } - if (identical(vanc, as.name("guess_ab_col"))) { vanc <- guess_ab_col(tbl, "vanc", verbose = verbose) } - col.list <- c(amcl, amik, amox, ampi, azit, aztr, cefa, cfra, cfep, cfot, - cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, - czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, - levo, linc, line, mero, metr, mino, moxi, nali, neom, neti, - nitr, novo, norf, oflo, peni, pipe, pita, poly, qida, rifa, - roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc) - if (length(col.list) < 60) { - warning('Some columns do not exist -- THIS MAY STRONGLY INFLUENCE THE OUTCOME.', - immediate. = TRUE, - call. = FALSE) - } - col.list <- check_available_columns(tbl = tbl, col.list = col.list, info = info) - amcl <- col.list[amcl] - amik <- col.list[amik] - amox <- col.list[amox] - ampi <- col.list[ampi] - azit <- col.list[azit] - aztr <- col.list[aztr] - cefa <- col.list[cefa] - cfra <- col.list[cfra] - cfep <- col.list[cfep] - cfot <- col.list[cfot] - cfox <- col.list[cfox] - cfta <- col.list[cfta] - cftr <- col.list[cftr] - cfur <- col.list[cfur] - chlo <- col.list[chlo] - cipr <- col.list[cipr] - clar <- col.list[clar] - clin <- col.list[clin] - clox <- col.list[clox] - coli <- col.list[coli] - czol <- col.list[czol] - dapt <- col.list[dapt] - doxy <- col.list[doxy] - erta <- col.list[erta] - eryt <- col.list[eryt] - fosf <- col.list[fosf] - fusi <- col.list[fusi] - gent <- col.list[gent] - imip <- col.list[imip] - kana <- col.list[kana] - levo <- col.list[levo] - linc <- col.list[linc] - line <- col.list[line] - mero <- col.list[mero] - metr <- col.list[metr] - mino <- col.list[mino] - moxi <- col.list[moxi] - nali <- col.list[nali] - neom <- col.list[neom] - neti <- col.list[neti] - nitr <- col.list[nitr] - novo <- col.list[novo] - norf <- col.list[norf] - oflo <- col.list[oflo] - peni <- col.list[peni] - pipe <- col.list[pipe] - pita <- col.list[pita] - poly <- col.list[poly] - qida <- col.list[qida] - rifa <- col.list[rifa] - roxi <- col.list[roxi] - siso <- col.list[siso] - teic <- col.list[teic] - tetr <- col.list[tetr] - tica <- col.list[tica] - tige <- col.list[tige] - tobr <- col.list[tobr] - trim <- col.list[trim] - trsu <- col.list[trsu] - vanc <- col.list[vanc] + + cols_ab <- get_column_abx(tbl = x, + ...) + + AMC <- cols_ab['AMC'] + AMK <- cols_ab['AMK'] + AMP <- cols_ab['AMP'] + AMX <- cols_ab['AMX'] + ATM <- cols_ab['ATM'] + AZL <- cols_ab['AZL'] + AZM <- cols_ab['AZM'] + CAZ <- cols_ab['CAZ'] + CED <- cols_ab['CED'] + CHL <- cols_ab['CHL'] + CIP <- cols_ab['CIP'] + CLI <- cols_ab['CLI'] + CLR <- cols_ab['CLR'] + COL <- cols_ab['COL'] + CRO <- cols_ab['CRO'] + CTX <- cols_ab['CTX'] + CXM <- cols_ab['CXM'] + CZO <- cols_ab['CZO'] + DAP <- cols_ab['DAP'] + DOX <- cols_ab['DOX'] + ERY <- cols_ab['ERY'] + ETP <- cols_ab['ETP'] + FEP <- cols_ab['FEP'] + FLC <- cols_ab['FLC'] + FOS <- cols_ab['FOS'] + FOX <- cols_ab['FOX'] + FUS <- cols_ab['FUS'] + GEN <- cols_ab['GEN'] + IPM <- cols_ab['IPM'] + KAN <- cols_ab['KAN'] + LIN <- cols_ab['LIN'] + LNZ <- cols_ab['LNZ'] + LVX <- cols_ab['LVX'] + MEM <- cols_ab['MEM'] + MEZ <- cols_ab['MEZ'] + MTR <- cols_ab['MTR'] + MFX <- cols_ab['MFX'] + MNO <- cols_ab['MNO'] + NAL <- cols_ab['NAL'] + NEO <- cols_ab['NEO'] + NET <- cols_ab['NET'] + NIT <- cols_ab['NIT'] + NOR <- cols_ab['NOR'] + NOV <- cols_ab['NOV'] + OFX <- cols_ab['OFX'] + PEN <- cols_ab['PEN'] + PIP <- cols_ab['PIP'] + PLB <- cols_ab['PLB'] + PRI <- cols_ab['PRI'] + QDA <- cols_ab['QDA'] + RID <- cols_ab['RID'] + RIF <- cols_ab['RIF'] + RXT <- cols_ab['RXT'] + SIS <- cols_ab['SIS'] + SXT <- cols_ab['SXT'] + TCY <- cols_ab['TCY'] + TEC <- cols_ab['TEC'] + TGC <- cols_ab['TGC'] + TIC <- cols_ab['TIC'] + TMP <- cols_ab['TMP'] + TOB <- cols_ab['TOB'] + TZP <- cols_ab['TZP'] + VAN <- cols_ab['VAN'] + ab_missing <- function(ab) { isTRUE(ab %in% c(NULL, NA)) | length(ab) == 0 } # antibiotic classes - aminoglycosides <- c(tobr, gent) # can also be kana but that one is often intrinsic R - cephalosporins <- c(cfep, cfot, cfox, cfra, cfta, cftr, cfur, czol) - cephalosporins_3rd <- c(cfot, cftr, cfta) - carbapenems <- c(erta, imip, mero) - fluoroquinolones <- c(oflo, cipr, levo, moxi) + aminoglycosides <- c(TOB, GEN) + cephalosporins <- c(FEP, CTX, FOX, CED, CAZ, CRO, CXM, CZO) + cephalosporins_3rd <- c(CTX, CRO, CAZ) + carbapenems <- c(ETP, IPM, MEM) + fluoroquinolones <- c(OFX, CIP, LVX, MFX) # helper function for editing the table trans_tbl <- function(to, rows, cols, any_all) { cols <- cols[!ab_missing(cols)] + cols <- cols[!is.na(cols)] if (length(rows) > 0 & length(cols) > 0) { if (any_all == "any") { - col_filter <- which(tbl[, cols] == 'R') + col_filter <- which(tbl_[, cols] == 'R') } else if (any_all == "all") { - col_filter <- tbl %>% + col_filter <- tbl_ %>% mutate(index = 1:nrow(.)) %>% filter_at(vars(cols), all_vars(. == "R")) %>% pull((index)) } rows <- rows[rows %in% col_filter] - tbl[rows, 'MDRO'] <<- to + tbl_[rows, 'MDRO'] <<- to } } - tbl <- tbl %>% + tbl_ <- tbl_ %>% mutate_at(vars(col_mo), as.mo) %>% # join to microorganisms data set left_join_microorganisms(by = col_mo) %>% @@ -342,64 +218,64 @@ mdro <- function(tbl, # EUCAST ------------------------------------------------------------------ # Table 5 trans_tbl(3, - which(tbl$family == 'Enterobacteriaceae' - | tbl$fullname %like% '^Pseudomonas aeruginosa' - | tbl$genus == 'Acinetobacter'), - coli, + which(tbl_$family == 'Enterobacteriaceae' + | tbl_$fullname %like% '^Pseudomonas aeruginosa' + | tbl_$genus == 'Acinetobacter'), + COL, "all") trans_tbl(3, - which(tbl$fullname %like% '^Salmonella Typhi'), + which(tbl_$fullname %like% '^Salmonella Typhi'), c(carbapenems, fluoroquinolones), "any") trans_tbl(3, - which(tbl$fullname %like% '^Haemophilus influenzae'), + which(tbl_$fullname %like% '^Haemophilus influenzae'), c(cephalosporins_3rd, carbapenems, fluoroquinolones), "any") trans_tbl(3, - which(tbl$fullname %like% '^Moraxella catarrhalis'), + which(tbl_$fullname %like% '^Moraxella catarrhalis'), c(cephalosporins_3rd, fluoroquinolones), "any") trans_tbl(3, - which(tbl$fullname %like% '^Neisseria meningitidis'), + which(tbl_$fullname %like% '^Neisseria meningitidis'), c(cephalosporins_3rd, fluoroquinolones), "any") trans_tbl(3, - which(tbl$fullname %like% '^Neisseria gonorrhoeae'), - azit, + which(tbl_$fullname %like% '^Neisseria gonorrhoeae'), + AZM, "any") # Table 6 trans_tbl(3, - which(tbl$fullname %like% '^Staphylococcus (aureus|epidermidis|coagulase negatief|hominis|haemolyticus|intermedius|pseudointermedius)'), - c(vanc, teic, dapt, line, qida, tige), + which(tbl_$fullname %like% '^Staphylococcus (aureus|epidermidis|coagulase negatief|hominis|haemolyticus|intermedius|pseudointermedius)'), + c(VAN, TEC, DAP, LNZ, QDA, TGC), "any") trans_tbl(3, - which(tbl$genus == 'Corynebacterium'), - c(vanc, teic, dapt, line, qida, tige), + which(tbl_$genus == 'Corynebacterium'), + c(VAN, TEC, DAP, LNZ, QDA, TGC), "any") trans_tbl(3, - which(tbl$fullname %like% '^Streptococcus pneumoniae'), - c(carbapenems, vanc, teic, dapt, line, qida, tige, rifa), + which(tbl_$fullname %like% '^Streptococcus pneumoniae'), + c(carbapenems, VAN, TEC, DAP, LNZ, QDA, TGC, RIF), "any") trans_tbl(3, # Sr. groups A/B/C/G - which(tbl$fullname %like% '^Streptococcus (pyogenes|agalactiae|equisimilis|equi|zooepidemicus|dysgalactiae|anginosus)'), - c(peni, cephalosporins, vanc, teic, dapt, line, qida, tige), + which(tbl_$fullname %like% '^Streptococcus (pyogenes|agalactiae|equisimilis|equi|zooepidemicus|dysgalactiae|anginosus)'), + c(PEN, cephalosporins, VAN, TEC, DAP, LNZ, QDA, TGC), "any") trans_tbl(3, - which(tbl$genus == 'Enterococcus'), - c(dapt, line, tige, teic), + which(tbl_$genus == 'Enterococcus'), + c(DAP, LNZ, TGC, TEC), "any") trans_tbl(3, - which(tbl$fullname %like% '^Enterococcus faecalis'), - c(ampi, amox), + which(tbl_$fullname %like% '^Enterococcus faecalis'), + c(AMP, AMX), "any") # Table 7 trans_tbl(3, - which(tbl$genus == 'Bacteroides'), - metr, + which(tbl_$genus == 'Bacteroides'), + MTR, "any") trans_tbl(3, - which(tbl$fullname %like% '^Clostridium difficile'), - c(metr, vanc), + which(tbl_$fullname %like% '^Clostridium difficile'), + c( MTR, VAN), "any") } @@ -416,68 +292,68 @@ mdro <- function(tbl, # Table 1 trans_tbl(3, - which(tbl$family == 'Enterobacteriaceae'), + which(tbl_$family == 'Enterobacteriaceae'), c(aminoglycosides, fluoroquinolones), "all") trans_tbl(2, - which(tbl$family == 'Enterobacteriaceae'), + which(tbl_$family == 'Enterobacteriaceae'), c(carbapenems), "any") # Table 2 trans_tbl(2, - which(tbl$genus == 'Acinetobacter'), + which(tbl_$genus == 'Acinetobacter'), c(carbapenems), "any") trans_tbl(3, - which(tbl$genus == 'Acinetobacter'), + which(tbl_$genus == 'Acinetobacter'), c(aminoglycosides, fluoroquinolones), "all") trans_tbl(3, - which(tbl$fullname %like% '^Stenotrophomonas maltophilia'), - trsu, + which(tbl_$fullname %like% '^Stenotrophomonas maltophilia'), + SXT, "all") - if (!ab_missing(mero) & !ab_missing(imip) - & !ab_missing(gent) & !ab_missing(tobr) - & !ab_missing(cipr) - & !ab_missing(cfta) - & !ab_missing(pita) ) { - tbl <- tbl %>% mutate( + if (!ab_missing(MEM) & !ab_missing(IPM) + & !ab_missing(GEN) & !ab_missing(TOB) + & !ab_missing(CIP) + & !ab_missing(CAZ) + & !ab_missing(TZP) ) { + tbl_ <- tbl_ %>% mutate( psae = 0, - psae = ifelse(mero == "R" | imip == "R", psae + 1, psae), - psae = ifelse(gent == "R" & tobr == "R", psae + 1, psae), - psae = ifelse(cipr == "R", psae + 1, psae), - psae = ifelse(cfta == "R", psae + 1, psae), - psae = ifelse(pita == "R", psae + 1, psae), + psae = ifelse(MEM == "R" | IPM == "R", psae + 1, psae), + psae = ifelse(GEN == "R" & TOB == "R", psae + 1, psae), + psae = ifelse(CIP == "R", psae + 1, psae), + psae = ifelse(CAZ == "R", psae + 1, psae), + psae = ifelse(TZP == "R", psae + 1, psae), psae = ifelse(is.na(psae), 0, psae) ) } else { - tbl$psae <- 0 + tbl_$psae <- 0 } - tbl[which( - tbl$fullname %like% 'Pseudomonas aeruginosa' - & tbl$psae >= 3 + tbl_[which( + tbl_$fullname %like% 'Pseudomonas aeruginosa' + & tbl_$psae >= 3 ), 'MDRO'] <- 3 # Table 3 trans_tbl(3, - which(tbl$fullname %like% 'Streptococcus pneumoniae'), - peni, + which(tbl_$fullname %like% 'Streptococcus pneumoniae'), + PEN, "all") trans_tbl(3, - which(tbl$fullname %like% 'Streptococcus pneumoniae'), - vanc, + which(tbl_$fullname %like% 'Streptococcus pneumoniae'), + VAN, "all") trans_tbl(3, - which(tbl$fullname %like% 'Enterococcus faecium'), - c(peni, vanc), + which(tbl_$fullname %like% 'Enterococcus faecium'), + c(PEN, VAN), "all") } - factor(x = tbl$MDRO, + factor(x = tbl_$MDRO, levels = 1:3, labels = c('Negative', 'Positive, unconfirmed', 'Positive'), ordered = TRUE) @@ -491,12 +367,61 @@ brmo <- function(..., country = "nl") { #' @rdname mdro #' @export -mrgn <- function(tbl, country = "de", ...) { - mdro(tbl = tbl, country = "de", ...) +mrgn <- function(x, country = "de", ...) { + mdro(x = x, country = "de", ...) } #' @rdname mdro #' @export -eucast_exceptional_phenotypes <- function(tbl, country = "EUCAST", ...) { - mdro(tbl = tbl, country = "EUCAST", ...) +eucast_exceptional_phenotypes <- function(x, country = "EUCAST", ...) { + mdro(x = x, country = "EUCAST", ...) } + +is_ESBL <- function(x, col_mo = NULL, ...) { + col_mo <- get_column_mo(tbl = x, col_mo = col_mo) + cols_ab <- get_column_abx(tbl = x, + soft_dependencies = c("AMX", "AMP"), + hard_dependencies = c("CAZ"), + ...) + + if (!any(c("AMX", "AMP") %in% names(cols_ab))) { + # both ampicillin and amoxicillin are missing + generate_warning_abs_missing(c("AMX", "AMP"), any = TRUE) + return(rep(NA, nrow(x))) + } + + ESBLs <- rep(NA, nrow(x)) + + # first make all eligible cases FALSE + ESBLs[which(mo_family(x[, col_mo]) == "Enterobacteriaceae" + & x[, get_ab_col(cols_ab, "AMX")] %in% c("R", "I", "S") + & x[, get_ab_col(cols_ab, "AMX")] %in% c("R", "I", "S") + & x[, get_ab_col(cols_ab, "AMX")] %in% c("R", "I", "S") + )] <- FALSE + # now make the positives cases TRUE + ESBLs[which(!is.na(ESBLs) + & x[, get_ab_col(cols_ab, "AMX")] == "R" + & x[, get_ab_col(cols_ab, "CAZ")] == "R")] <- TRUE + ESBLs + +} + +is_3MRGN <- function(x, ...) { + +} + +is_4MRGN <- function(x, ...) { + +} + +get_column_mo <- function(tbl, col_mo = NULL) { + # throws a blue note about which column will be used if guessed + if (is.null(col_mo)) { + col_mo <- search_type_in_df(tbl = tbl, type = "mo") + } + if (is.null(col_mo)) { + stop("`col_mo` must be set.", call. = FALSE) + } + col_mo +} + diff --git a/R/mic.R b/R/mic.R index 502eaebf2..ea71c3dae 100755 --- a/R/mic.R +++ b/R/mic.R @@ -25,6 +25,7 @@ #' @rdname as.mic #' @param x vector #' @param na.rm a logical indicating whether missing values should be removed +#' @details Interpret MIC values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI. #' @return Ordered factor with new class \code{mic} #' @keywords mic #' @export @@ -38,6 +39,16 @@ #' # this can also coerce combined MIC/RSI values: #' as.mic("<=0.002; S") # will return <=0.002 #' +#' # interpret MIC values +#' as.rsi(x = as.mic(2), +#' mo = as.mo("S. pneumoniae"), +#' ab = "AMX", +#' guideline = "EUCAST") +#' as.rsi(x = as.mic(4), +#' mo = as.mo("S. pneumoniae"), +#' ab = "AMX", +#' guideline = "EUCAST") +#' #' plot(mic_data) #' barplot(mic_data) #' freq(mic_data) @@ -71,11 +82,12 @@ as.mic <- function(x, na.rm = FALSE) { # force to be character x <- as.character(x) - # previously unempty values now empty - should return a warning later on + ## previously unempty values now empty - should return a warning later on x[x.bak != "" & x == ""] <- "invalid" - # these are alllowed MIC values and will become factor levels - lvls <- c("<0.002", "<=0.002", "0.002", ">=0.002", ">0.002", + # these are allowed MIC values and will become factor levels + lvls <- c("<0.001", "<=0.001", "0.001", ">=0.001", ">0.001", + "<0.002", "<=0.002", "0.002", ">=0.002", ">0.002", "<0.003", "<=0.003", "0.003", ">=0.003", ">0.003", "<0.004", "<=0.004", "0.004", ">=0.004", ">0.004", "<0.006", "<=0.006", "0.006", ">=0.006", ">0.006", @@ -134,11 +146,15 @@ as.mic <- function(x, na.rm = FALSE) { "<80", "<=80", "80", ">=80", ">80", "<96", "<=96", "96", ">=96", ">96", "<128", "<=128", "128", ">=128", ">128", + "129", "<160", "<=160", "160", ">=160", ">160", "<256", "<=256", "256", ">=256", ">256", + "257", "<320", "<=320", "320", ">=320", ">320", "<512", "<=512", "512", ">=512", ">512", - "<1024", "<=1024", "1024", ">=1024", ">1024") + "513", + "<1024", "<=1024", "1024", ">=1024", ">1024", + "1025") na_before <- x[is.na(x) | x == ''] %>% length() x[!x %in% lvls] <- NA diff --git a/R/misc.R b/R/misc.R index 43ee9dc9f..a20d2e820 100755 --- a/R/misc.R +++ b/R/misc.R @@ -30,7 +30,8 @@ addin_insert_like <- function() { } # No export, no Rd -# works exactly like round(), but rounds `round(44.55, 1)` as 44.6 instead of 44.5 and adds decimal zeroes until `digits` is reached +# works exactly like round(), but rounds `round(44.55, 1)` as 44.6 instead of 44.5 +# and adds decimal zeroes until `digits` is reached when force_zero = TRUE round2 <- function(x, digits = 0, force_zero = TRUE) { # https://stackoverflow.com/a/12688836/4575331 val <- (trunc((abs(x) * 10 ^ digits) + 0.5) / 10 ^ digits) * sign(x) @@ -41,62 +42,6 @@ round2 <- function(x, digits = 0, force_zero = TRUE) { val } -# No export, no Rd -percent <- function(x, round = 1, force_zero = FALSE, decimal.mark = getOption("OutDec"), ...) { - - decimal.mark.options <- getOption("OutDec") - options(OutDec = ".") - - val <- round2(x, round + 2, force_zero = FALSE) # round up 0.5 - val <- round(x = val * 100, digits = round) # remove floating point error - - if (force_zero == TRUE) { - if (any(val == as.integer(val) & !is.na(val))) { - # add zeroes to all integers - val[val == as.integer(as.character(val))] <- paste0(val[val == as.integer(val)], ".", strrep(0, round)) - } - # add extra zeroes if needed - val_decimals <- nchar(gsub(".*[.](.*)", "\\1", as.character(val))) - val[val_decimals < round] <- paste0(val[val_decimals < round], strrep(0, max(0, round - val_decimals))) - } - pct <- base::paste0(val, "%") - pct[pct %in% c("NA%", "NaN%")] <- NA_character_ - if (decimal.mark != ".") { - pct <- gsub(".", decimal.mark, pct, fixed = TRUE) - } - options(OutDec = decimal.mark.options) - pct -} - -check_available_columns <- function(tbl, col.list, info = TRUE) { - # check columns - col.list <- col.list[!is.na(col.list) & !is.null(col.list)] - names(col.list) <- col.list - col.list.bak <- col.list - # are they available as upper case or lower case then? - for (i in 1:length(col.list)) { - if (is.null(col.list[i]) | isTRUE(is.na(col.list[i]))) { - col.list[i] <- NA - } else if (toupper(col.list[i]) %in% colnames(tbl)) { - col.list[i] <- toupper(col.list[i]) - } else if (tolower(col.list[i]) %in% colnames(tbl)) { - col.list[i] <- tolower(col.list[i]) - } else if (!col.list[i] %in% colnames(tbl)) { - col.list[i] <- NA - } - } - if (!all(col.list %in% colnames(tbl))) { - if (info == TRUE) { - warning('Some columns do not exist and will be ignored: ', - col.list.bak[!(col.list %in% colnames(tbl))] %>% toString(), - '.\nTHIS MAY STRONGLY INFLUENCE THE OUTCOME.', - immediate. = TRUE, - call. = FALSE) - } - } - col.list -} - # Coefficient of variation (CV) cv <- function(x, na.rm = TRUE) { stats::sd(x, na.rm = na.rm) / base::abs(base::mean(x, na.rm = na.rm)) @@ -126,6 +71,20 @@ size_humanreadable <- function(bytes, decimals = 1) { out } +percent_scales <- scales::percent +# No export, no Rd +# based on scales::percent +percent <- function(x, round = 1, force_zero = FALSE, decimal.mark = getOption("OutDec"), ...) { + x <- percent_scales(x = as.double(x), + accuracy = 1 / 10 ^ round, + decimal.mark = decimal.mark, + ...) + if (force_zero == FALSE) { + x <- gsub("([.]%|%%)", "%", paste0(gsub("0+%$", "", x), "%")) + } + x +} + #' @importFrom crayon blue bold red #' @importFrom dplyr %>% pull search_type_in_df <- function(tbl, type) { @@ -195,8 +154,257 @@ search_type_in_df <- function(tbl, type) { found } +get_ab_col <- function(columns, ab) { + columns[names(columns) == ab] +} + +get_column_abx <- function(tbl, + soft_dependencies = NULL, + hard_dependencies = NULL, + verbose = FALSE, + AMC = guess_ab_col(), + AMK = guess_ab_col(), + AMX = guess_ab_col(), + AMP = guess_ab_col(), + AZM = guess_ab_col(), + AZL = guess_ab_col(), + ATM = guess_ab_col(), + RID = guess_ab_col(), + FEP = guess_ab_col(), + CTX = guess_ab_col(), + FOX = guess_ab_col(), + CED = guess_ab_col(), + CAZ = guess_ab_col(), + CRO = guess_ab_col(), + CXM = guess_ab_col(), + CHL = guess_ab_col(), + CIP = guess_ab_col(), + CLR = guess_ab_col(), + CLI = guess_ab_col(), + FLC = guess_ab_col(), + COL = guess_ab_col(), + CZO = guess_ab_col(), + DAP = guess_ab_col(), + DOX = guess_ab_col(), + ETP = guess_ab_col(), + ERY = guess_ab_col(), + FOS = guess_ab_col(), + FUS = guess_ab_col(), + GEN = guess_ab_col(), + IPM = guess_ab_col(), + KAN = guess_ab_col(), + LVX = guess_ab_col(), + LIN = guess_ab_col(), + LNZ = guess_ab_col(), + MEM = guess_ab_col(), + MTR = guess_ab_col(), + MEZ = guess_ab_col(), + MNO = guess_ab_col(), + MFX = guess_ab_col(), + NAL = guess_ab_col(), + NEO = guess_ab_col(), + NET = guess_ab_col(), + NIT = guess_ab_col(), + NOR = guess_ab_col(), + NOV = guess_ab_col(), + OFX = guess_ab_col(), + OXA = guess_ab_col(), + PEN = guess_ab_col(), + PIP = guess_ab_col(), + TZP = guess_ab_col(), + PLB = guess_ab_col(), + PRI = guess_ab_col(), + QDA = guess_ab_col(), + RIF = guess_ab_col(), + RXT = guess_ab_col(), + SIS = guess_ab_col(), + TEC = guess_ab_col(), + TCY = guess_ab_col(), + TIC = guess_ab_col(), + TGC = guess_ab_col(), + TOB = guess_ab_col(), + TMP = guess_ab_col(), + SXT = guess_ab_col(), + VAN = guess_ab_col()) { + # check columns + if (identical(AMC, as.name("guess_ab_col"))) AMC <- guess_ab_col(tbl, "AMC", verbose = verbose) + if (identical(AMK, as.name("guess_ab_col"))) AMK <- guess_ab_col(tbl, "AMK", verbose = verbose) + if (identical(AMX, as.name("guess_ab_col"))) AMX <- guess_ab_col(tbl, "AMX", verbose = verbose) + if (identical(AMP, as.name("guess_ab_col"))) AMP <- guess_ab_col(tbl, "AMP", verbose = verbose) + if (identical(AZM, as.name("guess_ab_col"))) AZM <- guess_ab_col(tbl, "AZM", verbose = verbose) + if (identical(AZL, as.name("guess_ab_col"))) AZL <- guess_ab_col(tbl, "AZL", verbose = verbose) + if (identical(ATM, as.name("guess_ab_col"))) ATM <- guess_ab_col(tbl, "ATM", verbose = verbose) + if (identical(RID, as.name("guess_ab_col"))) RID <- guess_ab_col(tbl, "RID", verbose = verbose) + if (identical(FEP, as.name("guess_ab_col"))) FEP <- guess_ab_col(tbl, "FEP", verbose = verbose) + if (identical(CTX, as.name("guess_ab_col"))) CTX <- guess_ab_col(tbl, "CTX", verbose = verbose) + if (identical(FOX, as.name("guess_ab_col"))) FOX <- guess_ab_col(tbl, "FOX", verbose = verbose) + if (identical(CED, as.name("guess_ab_col"))) CED <- guess_ab_col(tbl, "CED", verbose = verbose) + if (identical(CAZ, as.name("guess_ab_col"))) CAZ <- guess_ab_col(tbl, "CAZ", verbose = verbose) + if (identical(CRO, as.name("guess_ab_col"))) CRO <- guess_ab_col(tbl, "CRO", verbose = verbose) + if (identical(CXM, as.name("guess_ab_col"))) CXM <- guess_ab_col(tbl, "CXM", verbose = verbose) + if (identical(CHL, as.name("guess_ab_col"))) CHL <- guess_ab_col(tbl, "CHL", verbose = verbose) + if (identical(CIP, as.name("guess_ab_col"))) CIP <- guess_ab_col(tbl, "CIP", verbose = verbose) + if (identical(CLR, as.name("guess_ab_col"))) CLR <- guess_ab_col(tbl, "CLR", verbose = verbose) + if (identical(CLI, as.name("guess_ab_col"))) CLI <- guess_ab_col(tbl, "CLI", verbose = verbose) + if (identical(FLC, as.name("guess_ab_col"))) FLC <- guess_ab_col(tbl, "FLC", verbose = verbose) + if (identical(COL, as.name("guess_ab_col"))) COL <- guess_ab_col(tbl, "COL", verbose = verbose) + if (identical(CZO, as.name("guess_ab_col"))) CZO <- guess_ab_col(tbl, "CZO", verbose = verbose) + if (identical(DAP, as.name("guess_ab_col"))) DAP <- guess_ab_col(tbl, "DAP", verbose = verbose) + if (identical(DOX, as.name("guess_ab_col"))) DOX <- guess_ab_col(tbl, "DOX", verbose = verbose) + if (identical(ETP, as.name("guess_ab_col"))) ETP <- guess_ab_col(tbl, "ETP", verbose = verbose) + if (identical(ERY, as.name("guess_ab_col"))) ERY <- guess_ab_col(tbl, "ERY", verbose = verbose) + if (identical(FOS, as.name("guess_ab_col"))) FOS <- guess_ab_col(tbl, "FOS", verbose = verbose) + if (identical(FUS, as.name("guess_ab_col"))) FUS <- guess_ab_col(tbl, "FUS", verbose = verbose) + if (identical(GEN, as.name("guess_ab_col"))) GEN <- guess_ab_col(tbl, "GEN", verbose = verbose) + if (identical(IPM, as.name("guess_ab_col"))) IPM <- guess_ab_col(tbl, "IPM", verbose = verbose) + if (identical(KAN, as.name("guess_ab_col"))) KAN <- guess_ab_col(tbl, "KAN", verbose = verbose) + if (identical(LVX, as.name("guess_ab_col"))) LVX <- guess_ab_col(tbl, "LVX", verbose = verbose) + if (identical(LIN, as.name("guess_ab_col"))) LIN <- guess_ab_col(tbl, "LIN", verbose = verbose) + if (identical(LNZ, as.name("guess_ab_col"))) LNZ <- guess_ab_col(tbl, "LNZ", verbose = verbose) + if (identical(MEM, as.name("guess_ab_col"))) MEM <- guess_ab_col(tbl, "MEM", verbose = verbose) + if (identical(MTR, as.name("guess_ab_col"))) MTR <- guess_ab_col(tbl, "MTR", verbose = verbose) + if (identical(MEZ, as.name("guess_ab_col"))) MEZ <- guess_ab_col(tbl, "MEZ", verbose = verbose) + if (identical(MNO, as.name("guess_ab_col"))) MNO <- guess_ab_col(tbl, "MNO", verbose = verbose) + if (identical(MFX, as.name("guess_ab_col"))) MFX <- guess_ab_col(tbl, "MFX", verbose = verbose) + if (identical(NAL, as.name("guess_ab_col"))) NAL <- guess_ab_col(tbl, "NAL", verbose = verbose) + if (identical(NEO, as.name("guess_ab_col"))) NEO <- guess_ab_col(tbl, "NEO", verbose = verbose) + if (identical(NET, as.name("guess_ab_col"))) NET <- guess_ab_col(tbl, "NET", verbose = verbose) + if (identical(NIT, as.name("guess_ab_col"))) NIT <- guess_ab_col(tbl, "NIT", verbose = verbose) + if (identical(NOR, as.name("guess_ab_col"))) NOR <- guess_ab_col(tbl, "NOR", verbose = verbose) + if (identical(NOV, as.name("guess_ab_col"))) NOV <- guess_ab_col(tbl, "NOV", verbose = verbose) + if (identical(OFX, as.name("guess_ab_col"))) OFX <- guess_ab_col(tbl, "OFX", verbose = verbose) + if (identical(OXA, as.name("guess_ab_col"))) OXA <- guess_ab_col(tbl, "OXA", verbose = verbose) + if (identical(PEN, as.name("guess_ab_col"))) PEN <- guess_ab_col(tbl, "PEN", verbose = verbose) + if (identical(PIP, as.name("guess_ab_col"))) PIP <- guess_ab_col(tbl, "PIP", verbose = verbose) + if (identical(TZP, as.name("guess_ab_col"))) TZP <- guess_ab_col(tbl, "TZP", verbose = verbose) + if (identical(PLB, as.name("guess_ab_col"))) PLB <- guess_ab_col(tbl, "PLB", verbose = verbose) + if (identical(PRI, as.name("guess_ab_col"))) PRI <- guess_ab_col(tbl, "PRI", verbose = verbose) + if (identical(QDA, as.name("guess_ab_col"))) QDA <- guess_ab_col(tbl, "QDA", verbose = verbose) + if (identical(RIF, as.name("guess_ab_col"))) RIF <- guess_ab_col(tbl, "RIF", verbose = verbose) + if (identical(RXT, as.name("guess_ab_col"))) RXT <- guess_ab_col(tbl, "RXT", verbose = verbose) + if (identical(SIS, as.name("guess_ab_col"))) SIS <- guess_ab_col(tbl, "SIS", verbose = verbose) + if (identical(TEC, as.name("guess_ab_col"))) TEC <- guess_ab_col(tbl, "TEC", verbose = verbose) + if (identical(TCY, as.name("guess_ab_col"))) TCY <- guess_ab_col(tbl, "TCY", verbose = verbose) + if (identical(TIC, as.name("guess_ab_col"))) TIC <- guess_ab_col(tbl, "TIC", verbose = verbose) + if (identical(TGC, as.name("guess_ab_col"))) TGC <- guess_ab_col(tbl, "TGC", verbose = verbose) + if (identical(TOB, as.name("guess_ab_col"))) TOB <- guess_ab_col(tbl, "TOB", verbose = verbose) + if (identical(TMP, as.name("guess_ab_col"))) TMP <- guess_ab_col(tbl, "TMP", verbose = verbose) + if (identical(SXT, as.name("guess_ab_col"))) SXT <- guess_ab_col(tbl, "SXT", verbose = verbose) + if (identical(VAN, as.name("guess_ab_col"))) VAN <- guess_ab_col(tbl, "VAN", verbose = verbose) + columns_available <- c(AMC = AMC, AMK = AMK, AMX = AMX, AMP = AMP, AZM = AZM, + AZL = AZL, ATM = ATM, RID = RID, FEP = FEP, CTX = CTX, + FOX = FOX, CED = CED, CAZ = CAZ, CRO = CRO, CXM = CXM, + CHL = CHL, CIP = CIP, CLR = CLR, CLI = CLI, FLC = FLC, + COL = COL, CZO = CZO, DAP = DAP, DOX = DOX, ETP = ETP, + ERY = ERY, FOS = FOS, FUS = FUS, GEN = GEN, IPM = IPM, + KAN = KAN, LVX = LVX, LIN = LIN, LNZ = LNZ, MEM = MEM, + MTR = MTR, MEZ = MEZ, MNO = MNO, MFX = MFX, NAL = NAL, + NEO = NEO, NET = NET, NIT = NIT, NOR = NOR, NOV = NOV, + OFX = OFX, OXA = OXA, PEN = PEN, PIP = PIP, TZP = TZP, + PLB = PLB, PRI = PRI, QDA = QDA, RIF = RIF, RXT = RXT, + SIS = SIS, TEC = TEC, TCY = TCY, TIC = TIC, TGC = TGC, + TOB = TOB, TMP = TMP, SXT = SXT, VAN = VAN) + + if (!is.null(hard_dependencies)) { + if (!all(hard_dependencies %in% names(columns_available))) { + # missing a hard dependency will return NA and consequently the data will not be analysed + missing <- hard_dependencies[!hard_dependencies %in% names(columns_available)] + generate_warning_abs_missing(missing, any = FALSE) + return(NA) + } + } + if (!is.null(soft_dependencies)) { + if (!all(soft_dependencies %in% names(columns_available))) { + # missing a soft dependency may lower the reliability + missing <- soft_dependencies[!soft_dependencies %in% names(columns_available)] + missing <- paste0("`", missing, "` (", ab_name(missing, tolower = TRUE), ")") + warning('Reliability might be improved if these antimicrobial results would be available too: ', paste(missing, collapse = ", "), + immediate. = TRUE, + call. = FALSE) + } + } + #deps <- c(soft_dependencies, hard_dependencies) + #if (length(deps) > 0) { + # columns_available[names(columns_available) %in% deps] + #} else { + columns_available + #} +} + +generate_warning_abs_missing <- function(missing, any = FALSE) { + missing <- paste0("`", missing, "` (", ab_name(missing, tolower = TRUE), ")") + if (any == TRUE) { + any_txt <- c(" any of", "is") + } else { + any_txt <- c("", "are") + } + warning(paste0("Introducing NAs since", any_txt[1], " these antimicrobials ", any_txt[2], " required: ", + paste(missing, collapse = ", ")), + immediate. = TRUE, + call. = FALSE) +} + + stopifnot_installed_package <- function(package) { if (!package %in% base::rownames(utils::installed.packages())) { stop("this function requires the ", package, " package.", call. = FALSE) } } + +# translate strings based on inst/translations.tsv +#' @importFrom dplyr %>% filter +t <- function(from, language = get_locale()) { + # if (getOption("AMR_locale", "en") != language) { + # language <- getOption("AMR_locale", "en") + # } + + if (is.null(language)) { + return(from) + } + if (language %in% c("en", "")) { + return(from) + } + + df_trans <- utils::read.table(file = system.file("translations.tsv", package = "AMR"), + sep = "\t", + stringsAsFactors = FALSE, + header = TRUE, + blank.lines.skip = TRUE, + fill = TRUE, + strip.white = TRUE, + encoding = "UTF-8", + fileEncoding = "UTF-8", + na.strings = c(NA, "", NULL)) + + if (!language %in% df_trans$lang) { + stop("Unsupported language: '", language, "' - use one of: ", + paste0("'", sort(unique(df_trans$lang)), "'", collapse = ", "), + call. = FALSE) + } + + df_trans <- df_trans %>% filter(lang == language) + + # default case sensitive if value if 'ignore.case' is missing: + df_trans$ignore.case[is.na(df_trans$ignore.case)] <- FALSE + # default not using regular expressions (fixed = TRUE) if 'fixed' is missing: + df_trans$fixed[is.na(df_trans$fixed)] <- TRUE + + # check if text to look for is in one of the patterns + pattern_total <- tryCatch(paste0("(", paste(df_trans$pattern, collapse = "|"), ")"), + error = "") + if (NROW(df_trans) == 0 | !any(from %like% pattern_total)) { + return(from) + } + + for (i in 1:nrow(df_trans)) { + from <- gsub(x = from, + pattern = df_trans$pattern[i], + replacement = df_trans$replacement[i], + fixed = df_trans$fixed[i], + ignore.case = df_trans$ignore.case[i]) + } + + # force UTF-8 for diacritics + base::enc2utf8(from) + +} diff --git a/R/mo.R b/R/mo.R index 6c78c5b3e..41af877a9 100755 --- a/R/mo.R +++ b/R/mo.R @@ -126,7 +126,7 @@ #' @section Source: #' [1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870–926. \url{https://dx.doi.org/10.1128/CMR.00109-13} #' -#' [2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).}. 2019. Clin Microbiol Infect. 2019 Mar 11. \url{https://doi.org/10.1016/j.cmi.2019.02.028} +#' [2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the \emph{S. aureus} complex, \emph{S. argenteus} and \emph{S. schweitzeri}: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).} 2019. Clin Microbiol Infect. \url{https://doi.org/10.1016/j.cmi.2019.02.028} #' #' [3] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571} #' @@ -195,6 +195,8 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, # check onLoad() in R/zzz.R: data tables are created there. } + x[x == ""] <- NA_character_ + uncertainty_level <- translate_allow_uncertain(allow_uncertain) mo_hist <- get_mo_history(x, uncertainty_level, force = isTRUE(list(...)$force_mo_history)) @@ -261,7 +263,8 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, y <- mo_validate(x = x, property = "mo", Becker = Becker, Lancefield = Lancefield, allow_uncertain = uncertainty_level, reference_df = reference_df, - force_mo_history = isTRUE(list(...)$force_mo_history)) + force_mo_history = isTRUE(list(...)$force_mo_history), + ...) } @@ -296,6 +299,8 @@ exec_as.mo <- function(x, # check onLoad() in R/zzz.R: data tables are created there. } + x[x == ""] <- NA_character_ + if (initial_search == TRUE) { options(mo_failures = NULL) options(mo_uncertainties = NULL) @@ -548,7 +553,9 @@ exec_as.mo <- function(x, next } - if (nchar(gsub("[^a-zA-Z]", "", x_trimmed[i])) < 3) { + # check for very small input, but ignore the O antigens of E. coli + if (nchar(gsub("[^a-zA-Z]", "", x_trimmed[i])) < 3 + & !x_backup_without_spp[i] %like% "O?(26|103|104|104|111|121|145|157)") { # check if search term was like "A. species", then return first genus found with ^A if (x_backup[i] %like% "[a-z]+ species" | x_backup[i] %like% "[a-z] spp[.]?") { # get mo code of first hit @@ -609,7 +616,8 @@ exec_as.mo <- function(x, } next } - if (toupper(x_backup_without_spp[i]) %in% c("EHEC", "EPEC", "EIEC", "STEC", "ATEC")) { + if (toupper(x_backup_without_spp[i]) %in% c("EHEC", "EPEC", "EIEC", "STEC", "ATEC") + | x_backup_without_spp[i] %like% "O?(26|103|104|104|111|121|145|157)") { x[i] <- microorganismsDT[mo == 'B_ESCHR_COL', ..property][[1]][1L] if (initial_search == TRUE) { set_mo_history(x_backup[i], get_mo_code(x[i], property), 0, force = force_mo_history) diff --git a/R/mo_history.R b/R/mo_history.R index c0c50de76..18ac330e8 100644 --- a/R/mo_history.R +++ b/R/mo_history.R @@ -22,7 +22,7 @@ # print successful as.mo coercions to AMR environment #' @importFrom dplyr %>% distinct filter set_mo_history <- function(x, mo, uncertainty_level, force = FALSE) { - # disable function + # disable function for now return(base::invisible()) # if (base::interactive() | force == TRUE) { @@ -58,7 +58,7 @@ set_mo_history <- function(x, mo, uncertainty_level, force = FALSE) { } get_mo_history <- function(x, uncertainty_level, force = FALSE) { - # disable function + # disable function for now return(NA) # history <- read_mo_history(uncertainty_level = uncertainty_level, force = force) @@ -73,7 +73,7 @@ get_mo_history <- function(x, uncertainty_level, force = FALSE) { #' @importFrom dplyr %>% filter distinct read_mo_history <- function(uncertainty_level = 2, force = FALSE, unfiltered = FALSE) { - # disable function + # disable function for now return(NULL) # if ((!base::interactive() & force == FALSE)) { diff --git a/R/mo_property.R b/R/mo_property.R index 3ee619b20..29af76be3 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -36,8 +36,9 @@ #' #' The Gram stain - \code{mo_gramstain()} - will be determined on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002) who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram positive - all other bacteria are considered Gram negative. Species outside the kingdom of Bacteria will return a value \code{NA}. #' +#' All output will be \link{translate}d where possible. +#' #' The function \code{mo_url()} will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species. -#' @inheritSection get_locale Supported languages #' @inheritSection catalogue_of_life Catalogue of Life #' @inheritSection as.mo Source #' @rdname mo_property @@ -70,7 +71,7 @@ #' mo_gramstain("E. coli") # "Gram negative" #' mo_type("E. coli") # "Bacteria" (equal to kingdom) #' mo_rank("E. coli") # "species" -#' mo_url("E. coli") # get the direct url to the Catalogue of Life +#' mo_url("E. coli") # get the direct url to the online database entry #' #' ## scientific reference #' mo_ref("E. coli") # "Castellani et al., 1919" @@ -128,11 +129,11 @@ #' language = "nl") # "Streptococcus groep A" #' #' -#' # get a list with the complete taxonomy (kingdom to subspecies) +#' # get a list with the complete taxonomy (from kingdom to subspecies) #' mo_taxonomy("E. coli") mo_fullname <- function(x, language = get_locale(), ...) { x <- mo_validate(x = x, property = "fullname", ...) - mo_translate(x, language = language) + t(x, language = language) } #' @rdname mo_property @@ -199,49 +200,49 @@ mo_shortname <- function(x, language = get_locale(), ...) { } } - mo_translate(result, language = language) + t(result, language = language) } #' @rdname mo_property #' @export mo_subspecies <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "subspecies", ...), language = language) + t(mo_validate(x = x, property = "subspecies", ...), language = language) } #' @rdname mo_property #' @export mo_species <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "species", ...), language = language) + t(mo_validate(x = x, property = "species", ...), language = language) } #' @rdname mo_property #' @export mo_genus <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "genus", ...), language = language) + t(mo_validate(x = x, property = "genus", ...), language = language) } #' @rdname mo_property #' @export mo_family <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "family", ...), language = language) + t(mo_validate(x = x, property = "family", ...), language = language) } #' @rdname mo_property #' @export mo_order <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "order", ...), language = language) + t(mo_validate(x = x, property = "order", ...), language = language) } #' @rdname mo_property #' @export mo_class <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "class", ...), language = language) + t(mo_validate(x = x, property = "class", ...), language = language) } #' @rdname mo_property #' @export mo_phylum <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "phylum", ...), language = language) + t(mo_validate(x = x, property = "phylum", ...), language = language) } #' @rdname mo_property @@ -250,10 +251,10 @@ mo_kingdom <- function(x, language = get_locale(), ...) { if (all(x %in% AMR::microorganisms$kingdom)) { return(x) } - x <- as.mo(x, language = "en", ...) + x <- as.mo(x, ...) kngdm <- mo_validate(x = x, property = "kingdom", ...) if (language != "en") { - kngdm[x == "UNKNOWN"] <- mo_translate(kngdm[x == "UNKNOWN"], language = language) + kngdm[x == "UNKNOWN"] <- t(kngdm[x == "UNKNOWN"], language = language) } kngdm } @@ -261,13 +262,13 @@ mo_kingdom <- function(x, language = get_locale(), ...) { #' @rdname mo_property #' @export mo_type <- function(x, language = get_locale(), ...) { - mo_translate(mo_validate(x = x, property = "kingdom", ...), language = language) + t(mo_validate(x = x, property = "kingdom", ...), language = language) } #' @rdname mo_property #' @export mo_gramstain <- function(x, language = get_locale(), ...) { - x.mo <- as.mo(x, language = "en", ...) + x.mo <- as.mo(x, ...) x.phylum <- mo_phylum(x.mo, language = "en") x[x.phylum %in% c("Actinobacteria", "Chloroflexi", @@ -278,7 +279,7 @@ mo_gramstain <- function(x, language = get_locale(), ...) { x[x.mo == "B_GRAMP"] <- "Gram positive" x[x.mo == "B_GRAMN"] <- "Gram negative" - mo_translate(x, language = language) + t(x, language = language) } #' @rdname mo_property @@ -363,214 +364,7 @@ mo_property <- function(x, property = 'fullname', language = get_locale(), ...) stop("invalid property: '", property, "' - use a column name of the `microorganisms` data set") } - mo_translate(mo_validate(x = x, property = property, ...), language = language) -} - -#' @importFrom dplyr %>% case_when -mo_translate <- function(x, language) { - if (is.null(language)) { - return(x) - } - if (language %in% c("en", "")) { - return(x) - } - - supported <- c("en", "de", "nl", "es", "pt", "it", "fr") - if (!language %in% supported) { - stop("Unsupported language: '", language, "' - use one of: ", paste0("'", sort(supported), "'", collapse = ", "), call. = FALSE) - } - - x_tobetranslated <- grepl(x = x, - pattern = "(Coagulase-negative Staphylococcus|Coagulase-positive Staphylococcus|Beta-haemolytic Streptococcus|unknown Gram negatives|unknown Gram positives|unknown name|unknown kingdom|unknown phylum|unknown class|unknown order|unknown family|unknown genus|unknown species|unknown subspecies|unknown rank|CoNS|CoPS|Gram negative|Gram positive|Bacteria|Fungi|Protozoa|biogroup|biotype|vegetative|group|Group)") - - if (sum(x_tobetranslated, na.rm = TRUE) == 0) { - return(x) - } - - # only translate the ones that need translation - x[x_tobetranslated] <- case_when( - # German - language == "de" ~ x[x_tobetranslated] %>% - gsub("Coagulase-negative Staphylococcus","Koagulase-negative Staphylococcus", ., fixed = TRUE) %>% - gsub("Coagulase-positive Staphylococcus","Koagulase-positive Staphylococcus", ., fixed = TRUE) %>% - gsub("Beta-haemolytic Streptococcus", "Beta-h\u00e4molytischer Streptococcus", ., fixed = TRUE) %>% - gsub("unknown Gram negatives", "unbekannte Gramnegativen", ., fixed = TRUE) %>% - gsub("unknown Gram positives", "unbekannte Grampositiven", ., fixed = TRUE) %>% - gsub("unknown name", "unbekannte Name", ., fixed = TRUE) %>% - gsub("unknown kingdom", "unbekanntes Reich", ., fixed = TRUE) %>% - gsub("unknown phylum", "unbekannter Stamm", ., fixed = TRUE) %>% - gsub("unknown class", "unbekannte Klasse", ., fixed = TRUE) %>% - gsub("unknown order", "unbekannte Ordnung", ., fixed = TRUE) %>% - gsub("unknown family", "unbekannte Familie", ., fixed = TRUE) %>% - gsub("unknown genus", "unbekannte Gattung", ., fixed = TRUE) %>% - gsub("unknown species", "unbekannte Art", ., fixed = TRUE) %>% - gsub("unknown subspecies", "unbekannte Unterart", ., fixed = TRUE) %>% - gsub("unknown rank", "unbekannter Rang", ., fixed = TRUE) %>% - gsub("(CoNS)", "(KNS)", ., fixed = TRUE) %>% - gsub("(CoPS)", "(KPS)", ., fixed = TRUE) %>% - gsub("Gram negative", "Gramnegativ", ., fixed = TRUE) %>% - gsub("Gram positive", "Grampositiv", ., fixed = TRUE) %>% - gsub("Bacteria", "Bakterien", ., fixed = TRUE) %>% - gsub("Fungi", "Hefen/Pilze", ., fixed = TRUE) %>% - gsub("Protozoa", "Protozoen", ., fixed = TRUE) %>% - gsub("biogroup", "Biogruppe", ., fixed = TRUE) %>% - gsub("biotype", "Biotyp", ., fixed = TRUE) %>% - gsub("vegetative", "vegetativ", ., fixed = TRUE) %>% - gsub("([([ ]*?)group", "\\1Gruppe", .) %>% - gsub("([([ ]*?)Group", "\\1Gruppe", .) %>% - iconv(to = "UTF-8"), - - # Dutch - language == "nl" ~ x[x_tobetranslated] %>% - gsub("Coagulase-negative Staphylococcus","Coagulase-negatieve Staphylococcus", ., fixed = TRUE) %>% - gsub("Coagulase-positive Staphylococcus","Coagulase-positieve Staphylococcus", ., fixed = TRUE) %>% - gsub("Beta-haemolytic Streptococcus", "Beta-hemolytische Streptococcus", ., fixed = TRUE) %>% - gsub("unknown Gram negatives", "onbekende Gram-negatieven", ., fixed = TRUE) %>% - gsub("unknown Gram positives", "onbekende Gram-positieven", ., fixed = TRUE) %>% - gsub("unknown name", "onbekende naam", ., fixed = TRUE) %>% - gsub("unknown kingdom", "onbekend koninkrijk", ., fixed = TRUE) %>% - gsub("unknown phylum", "onbekende fylum", ., fixed = TRUE) %>% - gsub("unknown class", "onbekende klasse", ., fixed = TRUE) %>% - gsub("unknown order", "onbekende orde", ., fixed = TRUE) %>% - gsub("unknown family", "onbekende familie", ., fixed = TRUE) %>% - gsub("unknown genus", "onbekend geslacht", ., fixed = TRUE) %>% - gsub("unknown species", "onbekende soort", ., fixed = TRUE) %>% - gsub("unknown subspecies", "onbekende ondersoort", ., fixed = TRUE) %>% - gsub("unknown rank", "onbekende rang", ., fixed = TRUE) %>% - gsub("(CoNS)", "(CNS)", ., fixed = TRUE) %>% - gsub("(CoPS)", "(CPS)", ., fixed = TRUE) %>% - gsub("Gram negative", "Gram-negatief", ., fixed = TRUE) %>% - gsub("Gram positive", "Gram-positief", ., fixed = TRUE) %>% - gsub("Bacteria", "Bacteri\u00ebn", ., fixed = TRUE) %>% - gsub("Fungi", "Schimmels/gisten", ., fixed = TRUE) %>% - gsub("Protozoa", "protozo\u00ebn", ., fixed = TRUE) %>% - gsub("biogroup", "biogroep", ., fixed = TRUE) %>% - # gsub("biotype", "biotype", ., fixed = TRUE) %>% - gsub("vegetative", "vegetatief", ., fixed = TRUE) %>% - gsub("([([ ]*?)group", "\\1groep", .) %>% - gsub("([([ ]*?)Group", "\\1Groep", .) %>% - iconv(to = "UTF-8"), - - # Spanish - language == "es" ~ x[x_tobetranslated] %>% - # not 'negativa' - # https://www.sciencedirect.com/science/article/pii/S0123939215000739 - gsub("Coagulase-negative Staphylococcus","Staphylococcus coagulasa negativo", ., fixed = TRUE) %>% - gsub("Coagulase-positive Staphylococcus","Staphylococcus coagulasa positivo", ., fixed = TRUE) %>% - gsub("Beta-haemolytic Streptococcus", "Streptococcus Beta-hemol\u00edtico", ., fixed = TRUE) %>% - gsub("unknown Gram negatives", "Gram negativos desconocidos", ., fixed = TRUE) %>% - gsub("unknown Gram positives", "Gram positivos desconocidos", ., fixed = TRUE) %>% - gsub("unknown name", "nombre desconocido", ., fixed = TRUE) %>% - gsub("unknown kingdom", "reino desconocido", ., fixed = TRUE) %>% - gsub("unknown phylum", "filo desconocido", ., fixed = TRUE) %>% - gsub("unknown class", "clase desconocida", ., fixed = TRUE) %>% - gsub("unknown order", "orden desconocido", ., fixed = TRUE) %>% - gsub("unknown family", "familia desconocida", ., fixed = TRUE) %>% - gsub("unknown genus", "g\u00e9nero desconocido", ., fixed = TRUE) %>% - gsub("unknown species", "especie desconocida", ., fixed = TRUE) %>% - gsub("unknown subspecies", "subespecie desconocida", ., fixed = TRUE) %>% - gsub("unknown rank", "rango desconocido", ., fixed = TRUE) %>% - gsub("(CoNS)", "(SCN)", ., fixed = TRUE) %>% - gsub("(CoPS)", "(SCP)", ., fixed = TRUE) %>% - gsub("Gram negative", "Gram negativo", ., fixed = TRUE) %>% - gsub("Gram positive", "Gram positivo", ., fixed = TRUE) %>% - gsub("Bacteria", "Bacterias", ., fixed = TRUE) %>% - gsub("Fungi", "Hongos", ., fixed = TRUE) %>% - gsub("Protozoa", "Protozoarios", ., fixed = TRUE) %>% - gsub("biogroup", "biogrupo", ., fixed = TRUE) %>% - gsub("biotype", "biotipo", ., fixed = TRUE) %>% - gsub("vegetative", "vegetativo", ., fixed = TRUE) %>% - gsub("([([ ]*?)group", "\\1grupo", .) %>% - gsub("([([ ]*?)Group", "\\1Grupo", .) %>% - iconv(to = "UTF-8"), - - # Italian - language == "it" ~ x[x_tobetranslated] %>% - gsub("Coagulase-negative Staphylococcus","Staphylococcus negativo coagulasi", ., fixed = TRUE) %>% - gsub("Coagulase-positive Staphylococcus","Staphylococcus positivo coagulasi", ., fixed = TRUE) %>% - gsub("Beta-haemolytic Streptococcus", "Streptococcus Beta-emolitico", ., fixed = TRUE) %>% - gsub("unknown Gram negatives", "Gram negativi sconosciuti", ., fixed = TRUE) %>% - gsub("unknown Gram positives", "Gram positivi sconosciuti", ., fixed = TRUE) %>% - gsub("unknown name", "nome sconosciuto", ., fixed = TRUE) %>% - gsub("unknown kingdom", "regno sconosciuto", ., fixed = TRUE) %>% - gsub("unknown phylum", "phylum sconosciuto", ., fixed = TRUE) %>% - gsub("unknown class", "classe sconosciuta", ., fixed = TRUE) %>% - gsub("unknown order", "ordine sconosciuto", ., fixed = TRUE) %>% - gsub("unknown family", "famiglia sconosciuta", ., fixed = TRUE) %>% - gsub("unknown genus", "genere sconosciuto", ., fixed = TRUE) %>% - gsub("unknown species", "specie sconosciute", ., fixed = TRUE) %>% - gsub("unknown subspecies", "sottospecie sconosciute", ., fixed = TRUE) %>% - gsub("unknown rank", "grado sconosciuto", ., fixed = TRUE) %>% - gsub("Gram negative", "Gram negativo", ., fixed = TRUE) %>% - gsub("Gram positive", "Gram positivo", ., fixed = TRUE) %>% - gsub("Bacteria", "Batteri", ., fixed = TRUE) %>% - gsub("Fungi", "Fungo", ., fixed = TRUE) %>% - gsub("Protozoa", "Protozoi", ., fixed = TRUE) %>% - gsub("biogroup", "biogruppo", ., fixed = TRUE) %>% - gsub("biotype", "biotipo", ., fixed = TRUE) %>% - gsub("vegetative", "vegetativo", ., fixed = TRUE) %>% - gsub("([([ ]*?)group", "\\1gruppo", .) %>% - gsub("([([ ]*?)Group", "\\1Gruppo", .), - - # French - language == "fr" ~ x[x_tobetranslated] %>% - gsub("Coagulase-negative Staphylococcus","Staphylococcus \u00e0 coagulase n\u00e9gative", ., fixed = TRUE) %>% - gsub("Coagulase-positive Staphylococcus","Staphylococcus \u00e0 coagulase positif", ., fixed = TRUE) %>% - gsub("Beta-haemolytic Streptococcus", "Streptococcus B\u00eata-h\u00e9molytique", ., fixed = TRUE) %>% - gsub("unknown Gram negatives", "Gram n\u00e9gatifs inconnus", ., fixed = TRUE) %>% - gsub("unknown Gram positives", "Gram positifs inconnus", ., fixed = TRUE) %>% - gsub("unknown name", "nom inconnu", ., fixed = TRUE) %>% - gsub("unknown kingdom", "r\u00e8gme inconnu", ., fixed = TRUE) %>% - gsub("unknown phylum", "embranchement inconnu", ., fixed = TRUE) %>% - gsub("unknown class", "classe inconnue", ., fixed = TRUE) %>% - gsub("unknown order", "ordre inconnu", ., fixed = TRUE) %>% - gsub("unknown family", "famille inconnue", ., fixed = TRUE) %>% - gsub("unknown genus", "genre inconnu", ., fixed = TRUE) %>% - gsub("unknown species", "esp\u00e8ce inconnue", ., fixed = TRUE) %>% - gsub("unknown subspecies", "sous-esp\u00e8ce inconnue", ., fixed = TRUE) %>% - gsub("unknown rank", "rang inconnu", ., fixed = TRUE) %>% - gsub("Gram negative", "Gram n\u00e9gatif", ., fixed = TRUE) %>% - gsub("Gram positive", "Gram positif", ., fixed = TRUE) %>% - gsub("Bacteria", "Bact\u00e9ries", ., fixed = TRUE) %>% - gsub("Fungi", "Champignons", ., fixed = TRUE) %>% - gsub("Protozoa", "Protozoaires", ., fixed = TRUE) %>% - gsub("biogroup", "biogroupe", ., fixed = TRUE) %>% - # gsub("biotype", "biotype", ., fixed = TRUE) %>% - gsub("vegetative", "v\u00e9g\u00e9tatif", ., fixed = TRUE) %>% - gsub("([([ ]*?)group", "\\1groupe", .) %>% - gsub("([([ ]*?)Group", "\\1Groupe", .) %>% - iconv(to = "UTF-8"), - - # Portuguese - language == "pt" ~ x[x_tobetranslated] %>% - gsub("Coagulase-negative Staphylococcus","Staphylococcus coagulase negativo", ., fixed = TRUE) %>% - gsub("Coagulase-positive Staphylococcus","Staphylococcus coagulase positivo", ., fixed = TRUE) %>% - gsub("Beta-haemolytic Streptococcus", "Streptococcus Beta-hemol\u00edtico", ., fixed = TRUE) %>% - gsub("unknown Gram negatives", "Gram negativos desconhecidos", ., fixed = TRUE) %>% - gsub("unknown Gram positives", "Gram positivos desconhecidos", ., fixed = TRUE) %>% - gsub("unknown name", "nome desconhecido", ., fixed = TRUE) %>% - gsub("unknown kingdom", "reino desconhecido", ., fixed = TRUE) %>% - gsub("unknown phylum", "filo desconhecido", ., fixed = TRUE) %>% - gsub("unknown class", "classe desconhecida", ., fixed = TRUE) %>% - gsub("unknown order", "ordem desconhecido", ., fixed = TRUE) %>% - gsub("unknown family", "fam\u00edlia desconhecida", ., fixed = TRUE) %>% - gsub("unknown genus", "g\u00eanero desconhecido", ., fixed = TRUE) %>% - gsub("unknown species", "esp\u00e9cies desconhecida", ., fixed = TRUE) %>% - gsub("unknown subspecies", "subesp\u00e9cies desconhecida", ., fixed = TRUE) %>% - gsub("unknown rank", "classifica\u00e7\u00e3o desconhecido", ., fixed = TRUE) %>% - gsub("Gram negative", "Gram negativo", ., fixed = TRUE) %>% - gsub("Gram positive", "Gram positivo", ., fixed = TRUE) %>% - gsub("Bacteria", "Bact\u00e9rias", ., fixed = TRUE) %>% - gsub("Fungi", "Fungos", ., fixed = TRUE) %>% - gsub("Protozoa", "Protozo\u00e1rios", ., fixed = TRUE) %>% - gsub("biogroup", "biogrupo", ., fixed = TRUE) %>% - gsub("biotype", "bi\u00f3tipo", ., fixed = TRUE) %>% - gsub("vegetative", "vegetativo", ., fixed = TRUE) %>% - gsub("([([ ]*?)group", "\\1grupo", .) %>% - gsub("([([ ]*?)Group", "\\1Grupo", .) %>% - iconv(to = "UTF-8")) - - x + t(mo_validate(x = x, property = property, ...), language = language) } mo_validate <- function(x, property, ...) { @@ -591,7 +385,7 @@ mo_validate <- function(x, property, ...) { } # try to catch an error when inputting an invalid parameter - # so the call can be set to FALSE + # so the 'call.' can be set to FALSE tryCatch(x[1L] %in% AMR::microorganisms[1, property], error = function(e) stop(e$message, call. = FALSE)) diff --git a/R/portion.R b/R/portion.R index 31a73cafc..b55bafcd5 100755 --- a/R/portion.R +++ b/R/portion.R @@ -29,15 +29,14 @@ #' @param as_percent a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character). A value of \code{0.123456} will then be returned as \code{"12.3\%"}. #' @param also_single_tested a logical to indicate whether (in combination therapies) also observations should be included where not all antibiotics were tested, but at least one of the tested antibiotics contains a target interpretation (e.g. S in case of \code{portion_S} and R in case of \code{portion_R}). \strong{This would lead to selection bias in almost all cases.} #' @param data a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}}) -#' @param translate_ab a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{abname}}. This can be set with \code{\link{getOption}("get_antibiotic_names")}. +#' @param translate_ab a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{ab_property}} +#' @inheritParams ab_property #' @param combine_IR a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible) #' @details \strong{Remember that you should filter your table to let it contain only first isolates!} Use \code{\link{first_isolate}} to determine them in your data set. #' #' These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. \emph{Low counts can infuence the outcome - these \code{portion} functions may camouflage this, since they only return the portion albeit being dependent on the \code{minimum} parameter.} #' #' \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}. -#' -#' The old \code{\link{rsi}} function is still available for backwards compatibility but is deprecated. #' \if{html}{ # (created with https://www.latex4technics.com/) #' \cr\cr @@ -69,64 +68,64 @@ #' ?septic_patients #' #' # Calculate resistance -#' portion_R(septic_patients$amox) -#' portion_IR(septic_patients$amox) +#' portion_R(septic_patients$AMX) +#' portion_IR(septic_patients$AMX) #' #' # Or susceptibility -#' portion_S(septic_patients$amox) -#' portion_SI(septic_patients$amox) +#' portion_S(septic_patients$AMX) +#' portion_SI(septic_patients$AMX) #' #' # Do the above with pipes: #' library(dplyr) -#' septic_patients %>% portion_R(amox) -#' septic_patients %>% portion_IR(amox) -#' septic_patients %>% portion_S(amox) -#' septic_patients %>% portion_SI(amox) +#' septic_patients %>% portion_R(AMX) +#' septic_patients %>% portion_IR(AMX) +#' septic_patients %>% portion_S(AMX) +#' septic_patients %>% portion_SI(AMX) #' #' septic_patients %>% #' group_by(hospital_id) %>% -#' summarise(p = portion_S(cipr), -#' n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr +#' summarise(p = portion_S(CIP), +#' n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr #' #' septic_patients %>% #' group_by(hospital_id) %>% -#' summarise(R = portion_R(cipr, as_percent = TRUE), -#' I = portion_I(cipr, as_percent = TRUE), -#' S = portion_S(cipr, as_percent = TRUE), -#' n1 = count_all(cipr), # the actual total; sum of all three -#' n2 = n_rsi(cipr), # same - analogous to n_distinct +#' summarise(R = portion_R(CIP, as_percent = TRUE), +#' I = portion_I(CIP, as_percent = TRUE), +#' S = portion_S(CIP, as_percent = TRUE), +#' n1 = count_all(CIP), # the actual total; sum of all three +#' n2 = n_rsi(CIP), # same - analogous to n_distinct #' total = n()) # NOT the number of tested isolates! #' #' # Calculate co-resistance between amoxicillin/clav acid and gentamicin, #' # so we can see that combination therapy does a lot more than mono therapy: -#' septic_patients %>% portion_S(amcl) # S = 71.4% -#' septic_patients %>% count_all(amcl) # n = 1879 +#' septic_patients %>% portion_S(AMC) # S = 71.4% +#' septic_patients %>% count_all(AMC) # n = 1879 #' -#' septic_patients %>% portion_S(gent) # S = 74.0% -#' septic_patients %>% count_all(gent) # n = 1855 +#' septic_patients %>% portion_S(GEN) # S = 74.0% +#' septic_patients %>% count_all(GEN) # n = 1855 #' -#' septic_patients %>% portion_S(amcl, gent) # S = 92.3% -#' septic_patients %>% count_all(amcl, gent) # n = 1798 +#' septic_patients %>% portion_S(AMC, GEN) # S = 92.3% +#' septic_patients %>% count_all(AMC, GEN) # n = 1798 #' #' #' septic_patients %>% #' group_by(hospital_id) %>% -#' summarise(cipro_p = portion_S(cipr, as_percent = TRUE), -#' cipro_n = count_all(cipr), -#' genta_p = portion_S(gent, as_percent = TRUE), -#' genta_n = count_all(gent), -#' combination_p = portion_S(cipr, gent, as_percent = TRUE), -#' combination_n = count_all(cipr, gent)) +#' summarise(cipro_p = portion_S(CIP, as_percent = TRUE), +#' cipro_n = count_all(CIP), +#' genta_p = portion_S(GEN, as_percent = TRUE), +#' genta_n = count_all(GEN), +#' combination_p = portion_S(CIP, GEN, as_percent = TRUE), +#' combination_n = count_all(CIP, GEN)) #' #' # Get portions S/I/R immediately of all rsi columns #' septic_patients %>% -#' select(amox, cipr) %>% +#' select(AMX, CIP) %>% #' portion_df(translate = FALSE) #' #' # It also supports grouping variables #' septic_patients %>% -#' select(hospital_id, amox, cipr) %>% +#' select(hospital_id, AMX, CIP) %>% #' group_by(hospital_id) %>% #' portion_df(translate = FALSE) #' @@ -137,8 +136,8 @@ #' my_table %>% #' filter(first_isolate == TRUE, #' genus == "Helicobacter") %>% -#' summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole -#' n = count_all(amox, metr)) +#' summarise(p = portion_S(AMX, MTR), # amoxicillin with metronidazole +#' n = count_all(AMX, MTR)) #' } portion_R <- function(..., minimum = 30, @@ -217,7 +216,8 @@ portion_S <- function(..., #' @importFrom dplyr %>% select_if bind_rows summarise_if mutate group_vars select everything #' @export portion_df <- function(data, - translate_ab = getOption("get_antibiotic_names", "official"), + translate_ab = "name", + language = get_locale(), minimum = 30, as_percent = FALSE, combine_IR = FALSE) { @@ -230,10 +230,9 @@ portion_df <- function(data, stop("No columns with class 'rsi' found. See ?as.rsi.") } - if (as.character(translate_ab) == "TRUE") { - translate_ab <- "official" + if (as.character(translate_ab) %in% c("TRUE", "official")) { + translate_ab <- "name" } - options(get_antibiotic_names = translate_ab) resS <- summarise_if(.tbl = data, .predicate = is.rsi, @@ -282,55 +281,8 @@ portion_df <- function(data, } if (!translate_ab == FALSE) { - if (!tolower(translate_ab) %in% tolower(colnames(AMR::antibiotics))) { - stop("Parameter `translate_ab` does not occur in the `antibiotics` data set.", call. = FALSE) - } - res <- res %>% mutate(Antibiotic = abname(Antibiotic, from = "guess", to = translate_ab)) + res <- res %>% mutate(Antibiotic = ab_property(Antibiotic, property = translate_ab, language = language)) } res } - - -#' Calculate resistance of isolates -#' -#' This function is deprecated. Use the \code{\link{portion}} functions instead. -#' @inheritParams portion -#' @param ab1,ab2 vector (or column) with antibiotic interpretations. It will be transformed internally with \code{\link{as.rsi}} if needed. -#' @param interpretation antimicrobial interpretation to check for -#' @param ... deprecated parameters to support usage on older versions -#' @importFrom dplyr tibble case_when -#' @export -rsi <- function(ab1, - ab2 = NULL, - interpretation = "IR", - minimum = 30, - as_percent = FALSE, - ...) { - - .Deprecated(new = paste0("portion_", interpretation)) - - if (all(is.null(ab2))) { - df <- tibble(ab1 = ab1) - } else { - df <- tibble(ab1 = ab1, - ab2 = ab2) - } - - if (!interpretation %in% c("S", "SI", "IS", "I", "RI", "IR", "R")) { - stop("invalid interpretation") - } - - result <- case_when( - interpretation == "S" ~ portion_S(df, minimum = minimum, as_percent = FALSE), - interpretation %in% c("SI", "IS") ~ portion_SI(df, minimum = minimum, as_percent = FALSE), - interpretation == "I" ~ portion_I(df, minimum = minimum, as_percent = FALSE), - interpretation %in% c("RI", "IR") ~ portion_IR(df, minimum = minimum, as_percent = FALSE), - interpretation == "R" ~ portion_R(df, minimum = minimum, as_percent = FALSE)) - - if (as_percent == TRUE) { - percent(result, force_zero = TRUE) - } else { - result - } -} diff --git a/R/resistance_predict.R b/R/resistance_predict.R index 122499396..b8b159b08 100755 --- a/R/resistance_predict.R +++ b/R/resistance_predict.R @@ -60,7 +60,7 @@ #' @importFrom dplyr %>% pull mutate mutate_at n group_by_at summarise filter filter_at all_vars n_distinct arrange case_when n_groups transmute #' @inheritSection AMR Read more on our website! #' @examples -#' x <- resistance_predict(septic_patients, col_ab = "amox", year_min = 2010) +#' x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010) #' plot(x) #' ggplot_rsi_predict(x) #' @@ -69,7 +69,7 @@ #' x <- septic_patients %>% #' filter_first_isolate() %>% #' filter(mo_genus(mo) == "Staphylococcus") %>% -#' resistance_predict("peni") +#' resistance_predict("PEN") #' plot(x) #' #' @@ -83,7 +83,7 @@ #' #' data <- septic_patients %>% #' filter(mo == as.mo("E. coli")) %>% -#' resistance_predict(col_ab = "amox", +#' resistance_predict(col_ab = "AMX", #' col_date = "date", #' info = FALSE, #' minimum = 15) diff --git a/R/rsi.R b/R/rsi.R index 455c52500..705e256c7 100755 --- a/R/rsi.R +++ b/R/rsi.R @@ -21,14 +21,20 @@ #' Class 'rsi' #' -#' This transforms a vector to a new class \code{rsi}, which is an ordered factor with levels \code{S < I < R}. Invalid antimicrobial interpretations will be translated as \code{NA} with a warning. +#' Interpret MIC values according to EUCAST or CLSI, or clean up existing RSI values. This transforms the input to a new class \code{rsi}, which is an ordered factor with levels \code{S < I < R}. Invalid antimicrobial interpretations will be translated as \code{NA} with a warning. #' @rdname as.rsi -#' @param x vector +#' @param x vector of values (for class \code{mic}: an MIC value in mg/L, for class \code{disk}: a disk diffusion radius in millimeters) +#' @param mo a microorganism code, generated with \code{\link{as.mo}} +#' @param ab an antibiotic code, generated with \code{\link{as.ab}} +#' @inheritParams first_isolate +#' @param guideline defaults to the latest included EUCAST guideline, run \code{unique(AMR::rsi_translation$guideline)} for all options #' @param threshold maximum fraction of \code{x} that is allowed to fail transformation, see Examples -#' @details -#' \strong{NOTE:} This function does not translate MIC values to RSI values. If more than 50\% of the input resembles MIC values, it will warn about this.\cr You can use \code{\link{eucast_rules}} to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism. +#' @param ... parameters passed on to methods +#' @details Run \code{unique(AMR::rsi_translation$guideline)} for a list of all supported guidelines. #' -#' The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains only valid antimicrobial interpretations (S and/or I and/or R), and \code{FALSE} otherwise. +#' After using \code{as.rsi}, you can use \code{\link{eucast_rules}} to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism. +#' +#' The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains at most 5\% invalid antimicrobial interpretations (not S and/or I and/or R), and \code{FALSE} otherwise. The threshold of 5\% can be set with the \code{threshold} parameter. #' @return Ordered factor with new class \code{rsi} #' @keywords rsi #' @export @@ -43,6 +49,16 @@ #' # this can also coerce combined MIC/RSI values: #' as.rsi("<= 0.002; S") # will return S #' +#' # interpret MIC values +#' as.rsi(x = as.mic(2), +#' mo = as.mo("S. pneumoniae"), +#' ab = "AMX", +#' guideline = "EUCAST") +#' as.rsi(x = as.mic(4), +#' mo = as.mo("S. pneumoniae"), +#' ab = "AMX", +#' guideline = "EUCAST") +#' #' plot(rsi_data) # for percentages #' barplot(rsi_data) # for frequencies #' freq(rsi_data) # frequency table with informative header @@ -50,7 +66,7 @@ #' # using dplyr's mutate #' library(dplyr) #' septic_patients %>% -#' mutate_at(vars(peni:rifa), as.rsi) +#' mutate_at(vars(PEN:RIF), as.rsi) #' #' #' # fastest way to transform all columns with already valid AB results to class `rsi`: @@ -60,16 +76,21 @@ #' #' # default threshold of `is.rsi.eligible` is 5%. #' is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid -#' is.rsi.eligible(WHONET$`First name`, threshold = 0.9) # succeeds -as.rsi <- function(x) { +#' is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds +as.rsi <- function(x, ...) { + UseMethod("as.rsi") +} + +#' @export +as.rsi.default <- function(x, ...) { if (is.rsi(x)) { x } else if (identical(levels(x), c("S", "I", "R"))) { structure(x, class = c('rsi', 'ordered', 'factor')) } else { - if (input_resembles_mic(x) > 0.5) { - warning("`as.rsi` is intended to clean antimicrobial interpretations - not to interpret MIC values.", call. = FALSE) - } + # if (input_resembles_mic(x) > 0.5) { + # warning("`as.rsi` is intended to clean antimicrobial interpretations - not to interpret MIC values.", call. = FALSE) + # } x <- x %>% unlist() x.bak <- x @@ -106,9 +127,8 @@ as.rsi <- function(x) { list_missing, call. = FALSE) } - x <- factor(x, levels = c("S", "I", "R"), ordered = TRUE) - class(x) <- c('rsi', 'ordered', 'factor') - x + structure(.Data = factor(x, levels = c("S", "I", "R"), ordered = TRUE), + class = c('rsi', 'ordered', 'factor')) } } @@ -125,6 +145,160 @@ input_resembles_mic <- function(x) { } } +#' @rdname as.rsi +#' @importFrom dplyr case_when +#' @export +as.rsi.mic <- function(x, mo, ab, guideline = "EUCAST", ...) { + exec_as.rsi(method = "mic", + x = x, + mo = mo, + ab = ab, + guideline = guideline) +} + +#' @rdname as.rsi +#' @export +as.rsi.disk <- function(x, mo, ab, guideline = "EUCAST", ...) { + exec_as.rsi(method = "disk", + x = x, + mo = mo, + ab = ab, + guideline = guideline) +} + +exec_as.rsi <- function(method, x, mo, ab, guideline) { + if (method == "mic") { + x <- as.mic(x) # when as.rsi.mic is called directly + } else if (method == "disk") { + x <- as.disk(x) # when as.rsi.disk is called directly + } + + mo <- as.mo(mo) + ab <- as.ab(ab) + + mo_genus <- as.mo(mo_genus(mo)) + mo_family <- as.mo(mo_family(mo)) + mo_order <- as.mo(mo_order(mo)) + mo_becker <- as.mo(mo, Becker = TRUE) + mo_lancefield <- as.mo(mo, Lancefield = TRUE) + + guideline <- toupper(guideline) + if (guideline %in% c("CLSI", "EUCAST")) { + guideline <- AMR::rsi_translation %>% + filter(guideline %like% guideline) %>% + pull(guideline) %>% + sort() %>% + rev() %>% + .[1] + } + + if (!guideline %in% AMR::rsi_translation$guideline) { + stop(paste0("invalid guideline: '", guideline, + "'.\nValid guidelines are: ", paste0("'", rev(sort(unique(AMR::rsi_translation$guideline))), "'", collapse = ", ")), + call. = FALSE) + } + + new_rsi <- rep(NA_character_, length(x)) + trans <- AMR::rsi_translation %>% + filter(guideline == guideline) %>% + mutate(lookup = paste(mo, ab)) + + lookup_mo <- paste(mo, ab) + lookup_genus <- paste(mo_genus, ab) + lookup_family <- paste(mo_family, ab) + lookup_order <- paste(mo_order, ab) + lookup_becker <- paste(mo_becker, ab) + lookup_lancefield <- paste(mo_lancefield, ab) + + for (i in 1:length(x)) { + get_record <- trans %>% + filter(lookup %in% c(lookup_mo[i], + lookup_genus[i], + lookup_family[i], + lookup_order[i], + lookup_becker[i], + lookup_lancefield[i])) %>% + # be as specific as possible (i.e. prefer species over genus): + arrange(desc(nchar(mo))) %>% + .[1L,] + + if (NROW(get_record) > 0) { + if (method == "mic") { + new_rsi[i] <- case_when(is.na(get_record$S_mic) | is.na(get_record$R_mic) ~ NA_character_, + x[i] <= get_record$S_mic ~ "S", + x[i] >= get_record$R_mic ~ "R", + TRUE ~ "I") + } else if (method == "disk") { + new_rsi[i] <- case_when(is.na(get_record$S_disk) | is.na(get_record$R_disk) ~ NA_character_, + x[i] <= get_record$S_disk ~ "S", + x[i] >= get_record$R_disk ~ "R", + TRUE ~ "I") + } + + } + } + structure(.Data = factor(new_rsi, levels = c("S", "I", "R"), ordered = TRUE), + class = c('rsi', 'ordered', 'factor')) +} + +#' @rdname as.rsi +#' @importFrom crayon red blue +#' @export +as.rsi.data.frame <- function(x, col_mo = NULL, guideline = "EUCAST", ...) { + tbl_ <- x + + ab_cols <- colnames(tbl_)[sapply(tbl_, function(x) is.mic(x) | is.disk(x))] + if (length(ab_cols) == 0) { + stop("No columns with MIC values or disk zones found in this data set. Use as.mic or as.disk to transform antibiotic columns.", call. = FALSE) + } + + # try to find columns based on type + # -- mo + if (is.null(col_mo)) { + col_mo <- search_type_in_df(tbl = tbl_, type = "mo") + } + if (is.null(col_mo)) { + stop("`col_mo` must be set.", call. = FALSE) + } + + # transform all MICs + ab_cols <- colnames(tbl_)[sapply(tbl_, is.mic)] + if (length(ab_cols) > 0) { + for (i in 1:length(ab_cols)) { + if (is.na(suppressWarnings(as.ab(ab_cols[i])))) { + 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]), "` (", ab_name(ab_cols[i], tolower = TRUE), ")...")), appendLF = FALSE) + tbl_[, ab_cols[i]] <- exec_as.rsi(method = "mic", + x = tbl_ %>% pull(ab_cols[i]), + mo = tbl_ %>% pull(col_mo), + ab = as.ab(ab_cols[i]), + guideline = guideline) + message(blue(" OK.")) + } + } + # transform all disks + ab_cols <- colnames(tbl_)[sapply(tbl_, is.disk)] + if (length(ab_cols) > 0) { + for (i in 1:length(ab_cols)) { + if (is.na(suppressWarnings(as.ab(ab_cols[i])))) { + 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]), "` (", ab_name(ab_cols[i], tolower = TRUE), ")...")), appendLF = FALSE) + tbl_[, ab_cols[i]] <- exec_as.rsi(method = "disk", + x = tbl_ %>% pull(ab_cols[i]), + mo = tbl_ %>% pull(col_mo), + ab = as.ab(ab_cols[i]), + guideline = guideline) + message(blue(" OK.")) + } + } + + tbl_ +} + #' @rdname as.rsi #' @export is.rsi <- function(x) { @@ -211,6 +385,15 @@ plot.rsi <- function(x, ...) { filter(!is.na(x)) %>% mutate(s = round((n / sum(n)) * 100, 1)) ) + if (!"S" %in% data$x) { + data <- rbind(data, data.frame(x = "S", n = 0, s = 0)) + } + if (!"I" %in% data$x) { + data <- rbind(data, data.frame(x = "I", n = 0, s = 0)) + } + if (!"R" %in% data$x) { + data <- rbind(data, data.frame(x = "R", n = 0, s = 0)) + } data$x <- factor(data$x, levels = c('S', 'I', 'R'), ordered = TRUE) @@ -239,7 +422,7 @@ plot.rsi <- function(x, ...) { #' @exportMethod barplot.rsi #' @export -#' @importFrom dplyr %>% group_by summarise filter mutate if_else n_distinct +#' @importFrom dplyr %>% group_by summarise #' @importFrom graphics barplot axis #' @noRd barplot.rsi <- function(height, ...) { diff --git a/R/rsi_calc.R b/R/rsi_calc.R index a579a1ad4..f887c1727 100755 --- a/R/rsi_calc.R +++ b/R/rsi_calc.R @@ -73,6 +73,11 @@ rsi_calc <- function(..., } } + if (is.null(x)) { + warning("argument is NULL (check if columns exist): returning NA", call. = FALSE) + return(NA) + } + print_warning <- FALSE type_trans <- as.integer(as.rsi(type)) diff --git a/R/zzz.R b/R/zzz.R index e9995bbbb..b458d7a86 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -84,6 +84,7 @@ make <- function() { "Treponema", "Trichophyton", "Ureaplasma") + | rank %in% c("kingdom", "phylum", "class", "order", "family") ~ 2, TRUE ~ 3 )) diff --git a/_pkgdown.yml b/_pkgdown.yml index e2b69889f..ebe89a1b4 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -53,8 +53,8 @@ navbar: href: 'reference/mo_property.html' - text: 'Get properties of an antibiotic' icon: 'fa-capsules' - # href: 'articles/atc_property.html' - href: 'reference/atc_property.html' + # href: 'articles/ab_property.html' + href: 'reference/ab_property.html' - text: 'Create frequency tables' icon: 'fa-sort-amount-down' href: 'articles/freq.html' @@ -100,6 +100,7 @@ reference: - starts_with("as.") - '`mo_source`' - '`eucast_rules`' + - '`rsi_translation`' - '`guess_ab_col`' - '`read.4D`' - title: 'Adding variables to your data' @@ -113,13 +114,12 @@ reference: - '`mdro`' - '`key_antibiotics`' - '`mo_property`' - - '`atc_property`' - - '`atc_online_property`' - - '`abname`' + - '`ab_property`' - '`age`' - '`age_groups`' - '`p.symbol`' - '`join`' + - '`atc_online_property`' - title: 'Analysing your data' desc: > Functions for conducting AMR analysis, like counting isolates, calculating @@ -134,7 +134,6 @@ reference: - '`ggplot_rsi`' - '`kurtosis`' - '`resistance_predict`' - - '`rsi`' - '`skewness`' - title: 'Included data sets' desc: > diff --git a/data/antibiotics.rda b/data/antibiotics.rda index 0c9a1c9e5..43b0f66b3 100755 Binary files a/data/antibiotics.rda and b/data/antibiotics.rda differ diff --git a/data/microorganisms.codes.rda b/data/microorganisms.codes.rda index 9e30f40f0..9b5fd9f45 100644 Binary files a/data/microorganisms.codes.rda and b/data/microorganisms.codes.rda differ diff --git a/data/microorganisms.old.rda b/data/microorganisms.old.rda index bfa33f475..87cd2321f 100644 Binary files a/data/microorganisms.old.rda and b/data/microorganisms.old.rda differ diff --git a/data/microorganisms.rda b/data/microorganisms.rda index 1269a0b3c..d3e8ee0cd 100755 Binary files a/data/microorganisms.rda and b/data/microorganisms.rda differ diff --git a/data/rsi_translation.rda b/data/rsi_translation.rda new file mode 100644 index 000000000..8bea9e35b Binary files /dev/null and b/data/rsi_translation.rda differ diff --git a/data/septic_patients.rda b/data/septic_patients.rda index 095af455d..953a95a00 100755 Binary files a/data/septic_patients.rda and b/data/septic_patients.rda differ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index ae2c6d42d..e547c6e3f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@
@@ -143,7 +143,7 @@AMR.Rmd
Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 05 April 2019.
+Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 10 May 2019.
Using the left_join()
function from the dplyr
package, we can ‘map’ the gender to the patient ID using the patients_table
object we created earlier:
So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values M
and F
. From a researcher perspective: there are slightly more men. Nothing we didn’t already know.
The data is already quite clean, but we still need to transform some variables. The bacteria
column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The mutate()
function of the dplyr
package makes this really easy:
We also want to transform the antibiotics, because in real life data we don’t know if they are really clean. The as.rsi()
function ensures reliability and reproducibility in these kind of variables. The mutate_at()
will run the as.rsi()
function on defined variables:
Finally, we will apply EUCAST rules on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the eucast_rules()
function can also apply additional rules, like forcing
Because the amoxicillin (column amox
) and amoxicillin/clavulanic acid (column amcl
) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The eucast_rules()
fixes this:
Because the amoxicillin (column AMX
) and amoxicillin/clavulanic acid (column AMC
) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The eucast_rules()
fixes this:
data <- eucast_rules(data, col_mo = "bacteria")
#>
#> Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
@@ -442,14 +442,14 @@
#> Pasteurella multocida (no new changes)
#> Staphylococcus (no new changes)
#> Streptococcus groups A, B, C, G (no new changes)
-#> Streptococcus pneumoniae (1476 new changes)
+#> Streptococcus pneumoniae (1422 new changes)
#> Viridans group streptococci (no new changes)
#>
#> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-#> Table 01: Intrinsic resistance in Enterobacteriaceae (1290 new changes)
+#> Table 01: Intrinsic resistance in Enterobacteriaceae (1271 new changes)
#> Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no new changes)
#> Table 03: Intrinsic resistance in other Gram-negative bacteria (no new changes)
-#> Table 04: Intrinsic resistance in Gram-positive bacteria (2758 new changes)
+#> Table 04: Intrinsic resistance in Gram-positive bacteria (2747 new changes)
#> Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no new changes)
#> Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no new changes)
#> Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no new changes)
@@ -457,24 +457,24 @@
#> Table 13: Interpretive rules for quinolones (no new changes)
#>
#> Other rules
-#> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2311 new changes)
-#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (107 new changes)
+#> Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2255 new changes)
+#> Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (112 new changes)
#> Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no new changes)
#> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no new changes)
#> Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no new changes)
#> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no new changes)
#>
#> --------------------------------------------------------------------------
-#> EUCAST rules affected 6,584 out of 20,000 rows, making a total of 7,942 edits
+#> EUCAST rules affected 6,518 out of 20,000 rows, making a total of 7,807 edits
#> => added 0 test results
#>
-#> => changed 7,942 test results
-#> - 125 test results changed from S to I
-#> - 4,719 test results changed from S to R
-#> - 1,093 test results changed from I to S
-#> - 299 test results changed from I to R
-#> - 1,682 test results changed from R to S
-#> - 24 test results changed from R to I
+#> => changed 7,807 test results
+#> - 104 test results changed from S to I
+#> - 4,681 test results changed from S to R
+#> - 1,080 test results changed from I to S
+#> - 336 test results changed from I to R
+#> - 1,588 test results changed from R to S
+#> - 18 test results changed from R to I
#> --------------------------------------------------------------------------
#>
#> Use verbose = TRUE to get a data.frame with all specified edits instead.
So only 28.4% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.2% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
For future use, the above two syntaxes can be shortened with the filter_first_isolate()
function:
Only 2 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics()
function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.
Only 1 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics()
function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.
If a column exists with a name like ‘key(…)ab’ the first_isolate()
function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:
data <- data %>%
mutate(keyab = key_antibiotics(.)) %>%
@@ -650,49 +650,49 @@
#> NOTE: Using column `patient_id` as input for `col_patient_id`.
#> NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
#> [Criterion] Inclusion based on key antibiotics, ignoring I.
-#> => Found 15,059 first weighted isolates (75.3% of total)
isolate | date | patient_id | bacteria | -amox | -amcl | -cipr | -gent | +AMX | +AMC | +CIP | +GEN | first | first_weighted | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-01-24 | -N5 | +2010-01-22 | +M1 | B_ESCHR_COL | S | S | -S | +R | S | TRUE | TRUE | ||
2 | -2010-07-22 | -N5 | +2010-03-11 | +M1 | B_ESCHR_COL | S | S | -S | +R | S | FALSE | FALSE | ||
3 | -2010-07-29 | -N5 | +2010-03-17 | +M1 | B_ESCHR_COL | R | S | @@ -703,70 +703,70 @@|||||||
4 | -2010-09-17 | -N5 | +2010-04-28 | +M1 | B_ESCHR_COL | R | -I | S | +R | S | FALSE | -FALSE | +TRUE | |
5 | -2011-02-27 | -N5 | +2010-05-26 | +M1 | B_ESCHR_COL | +R | S | S | S | -S | -TRUE | +FALSE | TRUE | |
6 | -2011-04-25 | -N5 | +2010-06-03 | +M1 | B_ESCHR_COL | -S | -S | +R | +R | S | S | FALSE | -FALSE | +TRUE |
7 | -2011-04-30 | -N5 | +2010-07-03 | +M1 | B_ESCHR_COL | S | S | S | S | FALSE | -FALSE | +TRUE | ||
8 | -2011-05-27 | -N5 | +2010-07-07 | +M1 | B_ESCHR_COL | -S | -S | +R | +R | S | S | FALSE | -FALSE | +TRUE |
9 | -2011-06-24 | -N5 | +2010-07-30 | +M1 | B_ESCHR_COL | -R | +S | S | S | S | @@ -775,23 +775,23 @@||||
10 | -2011-10-29 | -N5 | +2010-10-12 | +M1 | B_ESCHR_COL | R | S | -R | +S | S | FALSE | TRUE |
Instead of 2, now 5 isolates are flagged. In total, 75.3% of all isolates are marked ‘first weighted’ - 46.9% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
+Instead of 1, now 9 isolates are flagged. In total, 75.6% of all isolates are marked ‘first weighted’ - 47.4% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
As with filter_first_isolate()
, there’s a shortcut for this new algorithm too:
So we end up with 15,059 isolates for analysis.
+So we end up with 15,129 isolates for analysis.
We can remove unneeded columns:
@@ -799,14 +799,15 @@date | patient_id | hospital | bacteria | -amox | -amcl | -cipr | -gent | +AMX | +AMC | +CIP | +GEN | gender | gramstain | genus | @@ -815,24 +816,26 @@||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2015-03-05 | -Z5 | -Hospital B | +1 | +2017-12-11 | +C4 | +Hospital A | B_ESCHR_COL | +R | +I | +R | S | -S | -S | -S | -F | +M | Gram negative | Escherichia | coli | TRUE |
2017-08-05 | -K5 | -Hospital B | +3 | +2014-03-15 | +J1 | +Hospital C | B_STRPT_PNE | S | S | @@ -845,43 +848,62 @@TRUE | ||||||||||
2012-08-31 | -V4 | +4 | +2010-09-09 | +T6 | +Hospital C | +B_STPHY_AUR | +S | +S | +R | +R | +F | +Gram positive | +Staphylococcus | +aureus | +TRUE | +|||||
6 | +2010-01-15 | +M8 | Hospital A | +B_STRPT_PNE | +I | +I | +R | +R | +M | +Gram positive | +Streptococcus | +pneumoniae | +TRUE | +|||||||
7 | +2015-04-19 | +E5 | +Hospital C | B_KLBSL_PNE | R | S | -R | S | -F | +S | +M | Gram negative | Klebsiella | pneumoniae | TRUE | |||||
2013-07-07 | -G5 | -Hospital A | -B_ESCHR_COL | -R | -S | -R | -S | -M | -Gram negative | -Escherichia | -coli | -TRUE | -||||||||
2015-09-03 | -O2 | +8 | +2016-03-04 | +R4 | Hospital A | B_ESCHR_COL | S | S | -S | +R | S | F | Gram negative | @@ -889,21 +911,6 @@coli | TRUE | |||||
2014-03-20 | -K9 | -Hospital D | -B_ESCHR_COL | -S | -S | -R | -S | -M | -Gram negative | -Escherichia | -coli | -TRUE | -
Time for the analysis!
@@ -912,7 +919,7 @@You might want to start by getting an idea of how the data is distributed. It’s an important start, because it also decides how you will continue your analysis.
+You might want to start by getting an idea of how the data is distributed. It’s an important start, because it also decides how you will continue your analysis. Although this package contains a convenient function to make frequency tables, exploratory data analysis (EDA) is not the primary scope of this package. Use a package like DataExplorer
for that, or read the free online book Exploratory Data Analysis with R by Roger D. Peng.
Or can be used like the dplyr
way, which is easier readable:
Frequency table of genus
and species
from a data.frame
(15,059 x 13)
Frequency table of genus
and species
from a data.frame
(15,129 x 13)
Columns: 2
-Length: 15,059 (of which NA: 0 = 0.00%)
+Length: 15,129 (of which NA: 0 = 0.00%)
Unique: 4
Shortest: 16
Longest: 24
The functions portion_S()
, portion_SI()
, portion_I()
, portion_IR()
and portion_R()
can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:
Or can be used in conjuction with group_by()
and summarise()
, both from the dplyr
package:
hospital | @@ -990,27 +997,27 @@ Longest: 24||
---|---|---|
Hospital A | -0.5037963 | +0.4884229 |
Hospital B | -0.5007457 | +0.4994329 |
Hospital C | -0.5111524 | +0.4838561 |
Hospital D | -0.4851550 | +0.4959586 |
Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the n_rsi()
can be used, which works exactly like n_distinct()
from the dplyr
package. It counts all isolates available for every group (i.e. values S, I or R):
data_1st %>%
group_by(hospital) %>%
- summarise(amoxicillin = portion_IR(amox),
- available = n_rsi(amox))
hospital | @@ -1020,32 +1027,32 @@ Longest: 24||||
---|---|---|---|---|
Hospital A | -0.5037963 | -4478 | +0.4884229 | +4578 |
Hospital B | -0.5007457 | -5364 | +0.4994329 | +5290 |
Hospital C | -0.5111524 | -2152 | +0.4838561 | +2168 |
Hospital D | -0.4851550 | -3065 | +0.4959586 | +3093 |
These functions can also be used to get the portion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:
data_1st %>%
group_by(genus) %>%
- summarise(amoxiclav = portion_S(amcl),
- gentamicin = portion_S(gent),
- amoxiclav_genta = portion_S(amcl, gent))
genus | @@ -1056,36 +1063,36 @@ Longest: 24||||||
---|---|---|---|---|---|---|
Escherichia | -0.8796370 | -0.8973846 | -0.9902589 | +0.8857369 | +0.8953688 | +0.9886529 |
Klebsiella | -0.7172942 | -0.9081047 | -0.9821315 | +0.7345758 | +0.8901028 | +0.9678663 |
Staphylococcus | -0.8829295 | -0.9221345 | -0.9918323 | +0.8775510 | +0.9235374 | +0.9874830 |
Streptococcus | -0.5767742 | +0.5804226 | 0.0000000 | -0.5767742 | +0.5804226 |
To make a transition to the next part, let’s see how this difference could be plotted:
data_1st %>%
group_by(genus) %>%
- summarise("1. Amoxi/clav" = portion_S(amcl),
- "2. Gentamicin" = portion_S(gent),
- "3. Amoxi/clav + gent" = portion_S(amcl, gent)) %>%
+ summarise("1. Amoxi/clav" = portion_S(AMC),
+ "2. Gentamicin" = portion_S(GEN),
+ "3. Amoxi/clav + GEN" = portion_S(AMC, GEN)) %>%
tidyr::gather("Antibiotic", "S", -genus) %>%
ggplot(aes(x = genus,
y = S,
@@ -1113,7 +1120,7 @@ Longest: 24

-Omit the translate_ab = FALSE
to have the antibiotic codes (amox, amcl, cipr, gent) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin).
+Omit the translate_ab = FALSE
to have the antibiotic codes (AMX, AMC, CIP, GEN) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin).
If we group on e.g. the genus
column and add some additional functions from our package, we can create this:
# group the data on `genus`
ggplot(data_1st %>% group_by(genus)) +
@@ -1150,7 +1157,7 @@ Longest: 24
Independence test
The next example uses the included septic_patients
, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This data.frame
can be used to practice AMR analysis.
-We will compare the resistance to fosfomycin (column fosf
) in hospital A and D. The input for the final fisher.test()
will be this:
+We will compare the resistance to fosfomycin (column FOS
) in hospital A and D. The input for the final fisher.test()
will be this:
To split ages, the input can be:
A numeric vector. A vector of e.g. c(10, 20)
will split on 0-9, 10-19 and 20+. A value of only 50
will split on 0-49 and 50+.
- The default is to split on young children (0-11), youth (12-24), young adults (26-54), middle-aged adults (55-74) and elderly (75+).
+ The default is to split on young children (0-11), youth (12-24), young adults (25-54), middle-aged adults (55-74) and elderly (75+).
A character:
"children"
, equivalent of: c(0, 1, 2, 4, 6, 13, 18)
. This will split on 0, 1, 2-3, 4-5, 6-12, 13-17 and 18+.
"elderly"
or "seniors"
, equivalent of: c(65, 75, 85)
. This will split on 0-64, 65-74, 75-84, 85+.
@@ -314,7 +314,7 @@
mo == as.mo("E. coli")) %>%
group_by(age_group = age_groups(age)) %>%
select(age_group,
- cipr) %>%
+ CIP) %>%
ggplot_rsi(x = "age_group")
# }
diff --git a/docs/reference/antibiotics.html b/docs/reference/antibiotics.html
index 1479e67ce..9d0a2b380 100644
--- a/docs/reference/antibiotics.html
+++ b/docs/reference/antibiotics.html
@@ -6,7 +6,7 @@
-Data set with ~500 antibiotics — antibiotics • AMR (for R)
+Data set with ~450 antibiotics — antibiotics • AMR (for R)
@@ -45,9 +45,9 @@
-
+
-
+
@@ -80,7 +80,7 @@
antibiotics.Rd
A data set containing all antibiotics with a J0 code and some other antimicrobial agents, with their DDDs. Except for trade names and abbreviations, all properties were downloaded from the WHO, see Source.
+A data set containing all antibiotics. Use as.ab
or one of the ab_property
functions to retrieve values from this data set. Three identifiers are included in this data set: an antibiotic ID (ab
, primarily used in this package) as defined by WHONET/EARS-Net, an ATC code (atc
) as defined by the WHO, and a Compound ID (cid
) as found in PubChem. Other properties in this data set are derived from one or more of these codes.
A data.frame
with 488 observations and 17 variables:
atc
ATC code (Anatomical Therapeutic Chemical), like J01CR02
ears_net
EARS-Net code (European Antimicrobial Resistance Surveillance Network), like AMC
certe
Certe code, like amcl
umcg
UMCG code, like AMCL
abbr
Abbreviation as used by many countries, used internally by as.atc
official
Official name by the WHO, like "Amoxicillin and beta-lactamase inhibitor"
official_nl
Official name in the Netherlands, like "Amoxicilline met enzymremmer"
trivial_nl
Trivial name in Dutch, like "Amoxicilline/clavulaanzuur"
trade_name
Trade name as used by many countries (a total of 294), used internally by as.atc
A data.frame
with 455 observations and 13 variables:
ab
Antibiotic ID as used in this package (like AMC
), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
atc
ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC, like J01CR02
cid
Compound ID as found in PubChem
name
Official name as used by WHONET/EARS-Net or the WHO
group
A short and concise group name, based on WHONET and WHOCC definitions
atc_group1
Official pharmacological subgroup (3rd level ATC code) as defined by the WHOCC, like "Macrolides, lincosamides and streptogramins"
atc_group2
Official chemical subgroup (4th level ATC code) as defined by the WHOCC, like "Macrolides"
abbr
List of abbreviations as used in many countries, also for antibiotic susceptibility testing (AST)
synonyms
Synonyms (often trade names) of a drug, as found in PubChem based on their compound ID
oral_ddd
Defined Daily Dose (DDD), oral treatment
oral_units
Units of ddd_units
iv_ddd
Defined Daily Dose (DDD), parenteral treatment
iv_units
Units of iv_ddd
atc_group1
ATC group, like "Macrolides, lincosamides and streptogramins"
atc_group2
Subgroup of atc_group1
, like "Macrolides"
useful_gramnegative
FALSE
if not useful according to EUCAST, NA
otherwise (see Source)
useful_grampositive
FALSE
if not useful according to EUCAST, NA
otherwise (see Source)
World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: https://www.whocc.no/atc_ddd_index/
-Table antibiotic coding EARSS (from WHONET 5.3): http://www.madsonline.dk/Tutorials/landskoder_antibiotika_WM.pdf
-EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016: http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf
+World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): https://www.whocc.no/atc_ddd_index/
+WHONET 2019 software: http://www.whonet.org/software.html
European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: http://ec.europa.eu/health/documents/community-register/html/atc.htm
+Properties that are based on an ATC code are only available when an ATC is available. These properties are: atc_group1
, atc_group2
, oral_ddd
, oral_units
, iv_ddd
and iv_units
Synonyms (i.e. trade names) are derived from the Compound ID (cid
) and consequently only available where a CID is available.
as.ab.Rd
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)+ +
x | +character vector to determine to antibiotic ID |
+
---|
Character (vector) with class "act"
. Unknown values will return NA
.
Use the ab_property
functions to get properties based on the returned ATC code, see Examples.
In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups. + Source: https://www.whocc.no/atc/structure_and_principles/
+ +World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: https://www.whocc.no/atc_ddd_index/
+WHONET 2019 software: http://www.whonet.org/software.html
+European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: http://ec.europa.eu/health/documents/community-register/html/atc.htm
+ +
+This package contains all ~500 antimicrobial drugs and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, https://www.whocc.no) and the Pharmaceuticals Community Register of the European Commission (http://ec.europa.eu/health/documents/community-register/html/atc.htm).
These have become the gold standard for international drug utilisation monitoring and research.
+The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest.
+ +On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
+ +antibiotics
for the dataframe that is being used to determine ATCs.
# NOT RUN { +# These examples all return "ERY", the ID of Erythromycin: +as.ab("J01FA01") +as.ab("J 01 FA 01") +as.ab("Erythromycin") +as.ab("eryt") +as.ab(" eryt 123") +as.ab("ERYT") +as.ab("ERY") +as.ab("erytromicine") # spelled wrong +as.ab("Erythrocin") # trade name +as.ab("Romycin") # trade name + +# Use ab_* functions to get a specific properties (see ?ab_property); +# they use as.ab() internally: +ab_name("J01FA01") # "Erythromycin" +ab_name("eryt") # "Erythromycin" +# }+
as.atc(x) +@@ -145,7 +145,7 @@is.ab(x) + +as.atc(x) is.atc(x)@@ -260,7 +262,7 @@Details
-Use the
+ab_property
functions to get properties based on the returned ATC code, see Examples.Use the
ab_property
functions to get properties based on the returned ATC code, see Examples.In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups. Source: https://www.whocc.no/atc/structure_and_principles/
@@ -291,14 +293,6 @@ This package contains all ~500 antimicrobial drugs and their An as.atc(" eryt 123") as.atc("ERYT") as.atc("ERY") -as.atc("Erythrocin") # Trade name -as.atc("Eryzole") # Trade name -as.atc("Pediamycin") # Trade name - -# Use ab_* functions to get a specific property based on an ATC code -Cipro <- as.atc("cipro") # returns `J01MA02` -atc_official(Cipro) # returns "Ciprofloxacin" -atc_umcg(Cipro) # returns "CIPR", the code used in the UMCG # }
Ordered factor with new class mic
Interpret MIC values as RSI values with as.rsi
. It supports guidelines from EUCAST and CLSI.
[1] Becker K et al. Coagulase-Negative Staphylococci. 2014. Clin Microbiol Rev. 27(4): 870–926. https://dx.doi.org/10.1128/CMR.00109-13
-[2] Becker K et al. Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).. 2019. Clin Microbiol Infect. 2019 Mar 11. https://doi.org/10.1016/j.cmi.2019.02.028
+[2] Becker K et al. Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS). 2019. Clin Microbiol Infect. https://doi.org/10.1016/j.cmi.2019.02.028
[3] Lancefield RC A serological differentiation of human and other groups of hemolytic streptococci. 1933. J Exp Med. 57(4): 571–95. https://dx.doi.org/10.1084/jem.57.4.571
[4] Catalogue of Life: Annual Checklist (public online taxonomic database), www.catalogueoflife.org (check included annual version with catalogue_of_life_version()
).
This transforms a vector to a new class rsi
, which is an ordered factor with levels S < I < R
. Invalid antimicrobial interpretations will be translated as NA
with a warning.
Interpret MIC values according to EUCAST or CLSI, or clean up existing RSI values. This transforms the input to a new class rsi
, which is an ordered factor with levels S < I < R
. Invalid antimicrobial interpretations will be translated as NA
with a warning.
as.rsi(x) +as.rsi(x, ...) + +# S3 method for mic +as.rsi(x, mo, ab, guideline = "EUCAST", ...) + +# S3 method for disk +as.rsi(x, mo, ab, guideline = "EUCAST", ...) + +# S3 method for data.frame +as.rsi(x, col_mo = NULL, guideline = "EUCAST", + ...) is.rsi(x) @@ -252,7 +262,27 @@+ x -+ vector
+ vector of values (for class
mic
: an MIC value in mg/L, for classdisk
: a disk diffusion radius in millimeters)+ +... ++ parameters passed on to methods
+ +mo ++ a microorganism code, generated with
as.mo
+ +ab ++ an antibiotic code, generated with
as.ab
+ +guideline ++ defaults to the latest included EUCAST guideline, run
unique(AMR::rsi_translation$guideline)
for all options+ col_mo +column name of the unique IDs of the microorganisms (see
mo
), defaults to the first column of classmo
. Values will be coerced usingas.mo
.threshold @@ -266,8 +296,9 @@Details
-NOTE: This function does not translate MIC values to RSI values. If more than 50% of the input resembles MIC values, it will warn about this.
-
You can useeucast_rules
to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.The function
+is.rsi.eligible
returnsTRUE
when a columns contains only valid antimicrobial interpretations (S and/or I and/or R), andFALSE
otherwise.Run
+unique(AMR::rsi_translation$guideline)
for a list of all supported guidelines.After using
+as.rsi
, you can useeucast_rules
to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.The function
is.rsi.eligible
returnsTRUE
when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), andFALSE
otherwise. The threshold of 5% can be set with thethreshold
parameter.Read more on our website!
@@ -288,6 +319,16 @@ # this can also coerce combined MIC/RSI values: as.rsi("<= 0.002; S") # will return S +# interpret MIC values +as.rsi(x = as.mic(2), + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") +as.rsi(x = as.mic(4), + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") + plot(rsi_data) # for percentages barplot(rsi_data) # for frequencies freq(rsi_data) # frequency table with informative header @@ -295,7 +336,7 @@ # using dplyr's mutate library(dplyr) septic_patients %>% - mutate_at(vars(peni:rifa), as.rsi) + mutate_at(vars(PEN:RIF), as.rsi) # fastest way to transform all columns with already valid AB results to class `rsi`: @@ -305,7 +346,7 @@ # default threshold of `is.rsi.eligible` is 5%. is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid -is.rsi.eligible(WHONET$`First name`, threshold = 0.9) # succeeds +is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds # } @@ -145,7 +145,7 @@- + Get properties of an antibiotic diff --git a/docs/reference/catalogue_of_life_version.html b/docs/reference/catalogue_of_life_version.html index 0ecc05a40..747ca0dd0 100644 --- a/docs/reference/catalogue_of_life_version.html +++ b/docs/reference/catalogue_of_life_version.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@ - + Get properties of an antibiotic diff --git a/docs/reference/count.html b/docs/reference/count.html index 8b318deea..ae7775143 100644 --- a/docs/reference/count.html +++ b/docs/reference/count.html @@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ @@ -146,7 +146,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ - + Get properties of an antibiotic @@ -257,8 +257,8 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ n_rsi(...) -count_df(data, translate_ab = getOption("get_antibiotic_names", - "official"), combine_IR = FALSE) +count_df(data, translate_ab = "name", language = get_locale(), + combine_IR = FALSE) Arguments
@@ -277,7 +277,11 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
@@ -321,7 +286,7 @@+ translate_ab -+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingabname
. This can be set withgetOption("get_antibiotic_names")
.+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingab_property
+ language +language of the returned text, defaults to system language (see
get_locale
) and can also be set withgetOption("AMR_locale")
. Uselanguage = NULL
orlanguage = ""
to prevent translation.combine_IR @@ -315,55 +319,55 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_ ?septic_patients # Count resistant isolates -count_R(septic_patients$amox) -count_IR(septic_patients$amox) +count_R(septic_patients$AMX) +count_IR(septic_patients$AMX) # Or susceptible isolates -count_S(septic_patients$amox) -count_SI(septic_patients$amox) +count_S(septic_patients$AMX) +count_SI(septic_patients$AMX) # Count all available isolates -count_all(septic_patients$amox) -n_rsi(septic_patients$amox) +count_all(septic_patients$AMX) +n_rsi(septic_patients$AMX) # Since n_rsi counts available isolates, you can # calculate back to count e.g. non-susceptible isolates. # This results in the same: -count_IR(septic_patients$amox) -portion_IR(septic_patients$amox) * n_rsi(septic_patients$amox) +count_IR(septic_patients$AMX) +portion_IR(septic_patients$AMX) * n_rsi(septic_patients$AMX) library(dplyr) septic_patients %>% group_by(hospital_id) %>% - summarise(R = count_R(cipr), - I = count_I(cipr), - S = count_S(cipr), - n1 = count_all(cipr), # the actual total; sum of all three - n2 = n_rsi(cipr), # same - analogous to n_distinct + summarise(R = count_R(CIP), + I = count_I(CIP), + S = count_S(CIP), + n1 = count_all(CIP), # the actual total; sum of all three + n2 = n_rsi(CIP), # same - analogous to n_distinct total = n()) # NOT the number of tested isolates! # Count co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy. # Please mind that `portion_S` calculates percentages right away instead. -count_S(septic_patients$amcl) # S = 1342 (71.4%) -count_all(septic_patients$amcl) # n = 1879 +count_S(septic_patients$AMC) # S = 1342 (71.4%) +count_all(septic_patients$AMC) # n = 1879 -count_S(septic_patients$gent) # S = 1372 (74.0%) -count_all(septic_patients$gent) # n = 1855 +count_S(septic_patients$GEN) # S = 1372 (74.0%) +count_all(septic_patients$GEN) # n = 1855 with(septic_patients, - count_S(amcl, gent)) # S = 1660 (92.3%) + count_S(AMC, GEN)) # S = 1660 (92.3%) with(septic_patients, # n = 1798 - n_rsi(amcl, gent)) + n_rsi(AMC, GEN)) # Get portions S/I/R immediately of all rsi columns septic_patients %>% - select(amox, cipr) %>% + select(AMX, CIP) %>% count_df(translate = FALSE) # It also supports grouping variables septic_patients %>% - select(hospital_id, amox, cipr) %>% + select(hospital_id, AMX, CIP) %>% group_by(hospital_id) %>% count_df(translate = FALSE) diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index 512f3b8d5..007c9f6ff 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@- + Get properties of an antibiotic @@ -242,38 +242,7 @@ eucast_rules(x, col_mo = NULL, info = TRUE, rules = c("breakpoints", - "expert", "other", "all"), verbose = FALSE, amcl = guess_ab_col(), - amik = guess_ab_col(), amox = guess_ab_col(), - ampi = guess_ab_col(), azit = guess_ab_col(), - azlo = guess_ab_col(), aztr = guess_ab_col(), - cefa = guess_ab_col(), cfep = guess_ab_col(), - cfot = guess_ab_col(), cfox = guess_ab_col(), - cfra = guess_ab_col(), cfta = guess_ab_col(), - cftr = guess_ab_col(), cfur = guess_ab_col(), - chlo = guess_ab_col(), cipr = guess_ab_col(), - clar = guess_ab_col(), clin = guess_ab_col(), - clox = guess_ab_col(), coli = guess_ab_col(), - czol = guess_ab_col(), dapt = guess_ab_col(), - doxy = guess_ab_col(), erta = guess_ab_col(), - eryt = guess_ab_col(), fosf = guess_ab_col(), - fusi = guess_ab_col(), gent = guess_ab_col(), - imip = guess_ab_col(), kana = guess_ab_col(), - levo = guess_ab_col(), linc = guess_ab_col(), - line = guess_ab_col(), mero = guess_ab_col(), - mezl = guess_ab_col(), mino = guess_ab_col(), - moxi = guess_ab_col(), nali = guess_ab_col(), - neom = guess_ab_col(), neti = guess_ab_col(), - nitr = guess_ab_col(), norf = guess_ab_col(), - novo = guess_ab_col(), oflo = guess_ab_col(), - oxac = guess_ab_col(), peni = guess_ab_col(), - pipe = guess_ab_col(), pita = guess_ab_col(), - poly = guess_ab_col(), pris = guess_ab_col(), - qida = guess_ab_col(), rifa = guess_ab_col(), - roxi = guess_ab_col(), siso = guess_ab_col(), - teic = guess_ab_col(), tetr = guess_ab_col(), - tica = guess_ab_col(), tige = guess_ab_col(), - tobr = guess_ab_col(), trim = guess_ab_col(), - trsu = guess_ab_col(), vanc = guess_ab_col(), ...) + "expert", "other", "all"), verbose = FALSE, ...) eucast_rules_file()@@ -282,7 +251,7 @@x -+ data with antibiotic columns, like e.g.
amox
andamcl
data with antibiotic columns, like e.g.
AMX
andAMC
- col_mo @@ -300,13 +269,9 @@verbose a logical to indicate whether extensive info should be returned as a
data.frame
with info about which rows and columns are effected. It runs all EUCAST rules, but will not be applied to an output - only an informativedata.frame
with changes will be returned as output.- amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, oxac, peni, pipe, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc -- column name of an antibiotic, see Antibiotics
... -+ parameters that are passed on to
eucast_rules
column name of an antibiotic, see section Antibiotics
- EUCAST Breakpoint tables for interpretation of MICs and zone diameters. Version 9.0, 2019.
http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Breakpoint_tables/v_9.0_Breakpoint_Tables.xlsxFor editing the reference file (which is available with
+eucast_rules_file
), these values can all be used for target antibiotics: aminoglycosides, tetracyclines, polymyxins, macrolides, glycopeptides, streptogramins, cephalosporins, cephalosporins_without_cfta, carbapenems, aminopenicillins, ureidopenicillins, fluoroquinolones, all_betalactams, and all separate four letter codes like amcl. They can be separated by comma:"amcl, fluoroquinolones"
. The mo_property can be any column name from themicroorganisms
data set, orgenus_species
orgramstain
. This file contains references to the 'Burkholderia cepacia complex'. The species in this group can be found in: LiPuma JJ, 2015 (PMID 16217180).For editing the reference file (which is available with
eucast_rules_file
), these values can all be used for target antibiotics: aminoglycosides, tetracyclines, polymyxins, macrolides, glycopeptides, streptogramins, cephalosporins, cephalosporins_without_cfta, carbapenems, aminopenicillins, ureidopenicillins, fluoroquinolones, all_betalactams, and all separate four letter codes like AMC. They can be separated by comma:"AMC, fluoroquinolones"
. The mo_property can be any column name from themicroorganisms
data set, orgenus_species
orgramstain
. This file contains references to the 'Burkholderia cepacia complex'. The species in this group can be found in: LiPuma JJ, 2015 (PMID 16217180).Value
@@ -329,79 +294,81 @@Details
-NOTE: This function does not translate MIC values to RSI values. It only applies (1) inferred susceptibility and resistance based on results of other antibiotics and (2) intrinsic resistance based on taxonomic properties of a microorganism.
-The file used for applying all EUCAST rules can be retrieved with
eucast_rules_file()
. It returns an easily readable data set containing all rules. The original TSV file (tab separated file) that is being read by this function can be found when running this command:
+Note: This function does not translate MIC values to RSI values. Use
+as.rsi
for that.
+Note: When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.The file used for applying all EUCAST rules can be retrieved with
-eucast_rules_file()
. It returns an easily readable data set containing all rules. The original TSV file (tab separated file) that is being read byeucast_rules()
can be found by running this command:
AMR::EUCAST_RULES_FILE_LOCATION
(without brackets).In the source code it is located under
-./inst/eucast/eucast_rules.tsv
.Note: When ampicillin (J01CA01) is not available but amoxicillin (J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.
+In the source code the file containing all rules is located here.
Antibiotics
-To define antibiotics column names, leave as it is to determine it automatically with
-guess_ab_col
or input a text (case-insensitive) or useNULL
to skip a column (e.g.tica = NULL
). Non-existing columns will anyway be skipped with a warning.Abbrevations of the column containing antibiotics in the form: abbreviation: generic name (ATC code)
-amcl: amoxicillin+clavulanic acid (J01CR02), - amik: amikacin (J01GB06), - amox: amoxicillin (J01CA04), - ampi: ampicillin (J01CA01), - azit: azithromycin (J01FA10), - azlo: azlocillin (J01CA09), - aztr: aztreonam (J01DF01), - cefa: cefaloridine (J01DB02), - cfep: cefepime (J01DE01), - cfot: cefotaxime (J01DD01), - cfox: cefoxitin (J01DC01), - cfra: cefradine (J01DB09), - cfta: ceftazidime (J01DD02), - cftr: ceftriaxone (J01DD04), - cfur: cefuroxime (J01DC02), - chlo: chloramphenicol (J01BA01), - cipr: ciprofloxacin (J01MA02), - clar: clarithromycin (J01FA09), - clin: clindamycin (J01FF01), - clox: flucloxacillin (J01CF05), - coli: colistin (J01XB01), - czol: cefazolin (J01DB04), - dapt: daptomycin (J01XX09), - doxy: doxycycline (J01AA02), - erta: ertapenem (J01DH03), - eryt: erythromycin (J01FA01), - fosf: fosfomycin (J01XX01), - fusi: fusidic acid (J01XC01), - gent: gentamicin (J01GB03), - imip: imipenem (J01DH51), - kana: kanamycin (J01GB04), - levo: levofloxacin (J01MA12), - linc: lincomycin (J01FF02), - line: linezolid (J01XX08), - mero: meropenem (J01DH02), - mezl: mezlocillin (J01CA10), - mino: minocycline (J01AA08), - moxi: moxifloxacin (J01MA14), - nali: nalidixic acid (J01MB02), - neom: neomycin (J01GB05), - neti: netilmicin (J01GB07), - nitr: nitrofurantoin (J01XE01), - norf: norfloxacin (J01MA06), - novo: novobiocin (an ATCvet code: QJ01XX95), - oflo: ofloxacin (J01MA01), - peni: (benzyl)penicillin (J01CE01), - pipe: piperacillin (J01CA12), - pita: piperacillin+tazobactam (J01CR05), - poly: polymyxin B (J01XB02), - pris: pristinamycin (J01FG01), - qida: quinupristin/dalfopristin (J01FG02), - rifa: rifampicin (J04AB02), - roxi: roxithromycin (J01FA06), - siso: sisomicin (J01GB08), - teic: teicoplanin (J01XA02), - tetr: tetracycline (J01AA07), - tica: ticarcillin (J01CA13), - tige: tigecycline (J01AA12), - tobr: tobramycin (J01GB01), - trim: trimethoprim (J01EA01), - trsu: sulfamethoxazole and trimethoprim (J01EE01), - vanc: vancomycin (J01XA01).
+To define antibiotics column names, leave as it is to determine it automatically with
+guess_ab_col
or input a text (case-insensitive), or useNULL
to skip a column (e.g.TIC = NULL
to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning.Available abbrevations of the column containing antibiotics in the form 'antimicrobial ID: name (ATC code)':
+AMC: amoxicillin/clavulanic acid (J01CR02), + AMK: amikacin (J01GB06), + AMX: amoxicillin (J01CA04), + AMP: ampicillin (J01CA01), + AZM: azithromycin (J01FA10), + AZL: azlocillin (J01CA09), + ATM: aztreonam (J01DF01), + RID: cefaloridine (J01DB02), + FEP: cefepime (J01DE01), + CTX: cefotaxime (J01DD01), + FOX: cefoxitin (J01DC01), + CED: cefradine (J01DB09), + CAZ: ceftazidime (J01DD02), + CRO: ceftriaxone (J01DD04), + CXM: cefuroxime (J01DC02), + CHL: chloramphenicol (J01BA01), + CIP: ciprofloxacin (J01MA02), + CLR: clarithromycin (J01FA09), + CLI: clindamycin (J01FF01), + FLC: flucloxacillin (J01CF05), + COL: colistin (J01XB01), + CZO: cefazolin (J01DB04), + DAP: daptomycin (J01XX09), + DOX: doxycycline (J01AA02), + ETP: ertapenem (J01DH03), + ERY: erythromycin (J01FA01), + FOS: fosfomycin (J01XX01), + FUS: fusidic acid (J01XC01), + GEN: gentamicin (J01GB03), + IPM: imipenem (J01DH51), + KAN: kanamycin (J01GB04), + LVX: levofloxacin (J01MA12), + LIN: lincomycin (J01FF02), + LNZ: linezolid (J01XX08), + MEM: meropenem (J01DH02), + MEZ: mezlocillin (J01CA10), + MNO: minocycline (J01AA08), + MFX: moxifloxacin (J01MA14), + MTR: metronidazole (J01XD01), + NAL: nalidixic acid (J01MB02), + NEO: neomycin (J01GB05), + NET: netilmicin (J01GB07), + NIT: nitrofurantoin (J01XE01), + NOR: norfloxacin (J01MA06), + NOV: novobiocin (an ATCvet code: QJ01XX95), + OFX: ofloxacin (J01MA01), + OXA: oxacillin (J01CF04), + PEN: penicillin G (J01CE01), + PIP: piperacillin (J01CA12), + TZP: piperacillin/tazobactam (J01CR05), + PLB: polymyxin B (J01XB02), + PRI: pristinamycin (J01FG01), + QDA: quinupristin/dalfopristin (J01FG02), + RIF: rifampicin (J04AB02), + RXT: roxithromycin (J01FA06), + SIS: sisomicin (J01GB08), + TEC: teicoplanin (J01XA02), + TCY: tetracycline (J01AA07), + TIC: ticarcillin (J01CA13), + TGC: tigecycline (J01AA12), + TOB: tobramycin (J01GB01), + TMP: trimethoprim (J01EA01), + SXT: trimethoprim/sulfamethoxazole (J01EE01), + VAN: vancomycin (J01XA01).
Read more on our website!
@@ -418,17 +385,17 @@ "Escherichia coli", "Klebsiella pneumoniae", "Pseudomonas aeruginosa"), - vanc = "-", # Vancomycin - amox = "-", # Amoxicillin - coli = "-", # Colistin - cfta = "-", # Ceftazidime - cfur = "-", # Cefuroxime - peni = "S", # Benzylpenicillin - cfox = "S", # Cefoxitin + VAN = "-", # Vancomycin + AMX = "-", # Amoxicillin + COL = "-", # Colistin + CAZ = "-", # Ceftazidime + CXM = "-", # Cefuroxime + PEN = "S", # Penicillin G + FOX = "S", # Cefoxitin stringsAsFactors = FALSE) a -# mo vanc amox coli cfta cfur peni cfox +# mo VAN AMX COL CAZ CXM PEN FOX # 1 Staphylococcus aureus - - - - - S S # 2 Enterococcus faecalis - - - - - S S # 3 Escherichia coli - - - - - S S @@ -440,7 +407,7 @@ b <- eucast_rules(a) b -# mo vanc amox coli cfta cfur peni cfox +# mo VAN AMX COL CAZ CXM PEN FOX # 1 Staphylococcus aureus - S R R S S S # 2 Enterococcus faecalis - - R R R S R # 3 Escherichia coli R - - - - R S diff --git a/docs/reference/filter_ab_class.html b/docs/reference/filter_ab_class.html index 47ed92822..3bfcc5aba 100644 --- a/docs/reference/filter_ab_class.html +++ b/docs/reference/filter_ab_class.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@- + Get properties of an antibiotic @@ -302,9 +302,9 @@ # filter on isolates that have any result for any aminoglycoside septic_patients %>% filter_aminoglycosides() -# this is essentially the same as: +# this is essentially the same as (but without determination of column names): septic_patients %>% - filter_at(.vars = vars(c("gent", "tobr", "amik", "kana")), + filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")), .vars_predicate = any_vars(. %in% c("S", "I", "R"))) diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 9874bce80..18cf28329 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@ - + Get properties of an antibiotic @@ -397,14 +397,14 @@ To conduct an analysis of antimicrobial resistance, you should only include the # Now let's see if first isolates matter: A <- septic_patients %>% group_by(hospital_id) %>% - summarise(count = n_rsi(gent), # gentamicin availability - resistance = portion_IR(gent)) # gentamicin resistance + summarise(count = n_rsi(GEN), # gentamicin availability + resistance = portion_IR(GEN)) # gentamicin resistance B <- septic_patients %>% - filter_first_weighted_isolate() %>% # the 1st isolate filter + filter_first_weighted_isolate() %>% # the 1st isolate filter group_by(hospital_id) %>% - summarise(count = n_rsi(gent), # gentamicin availability - resistance = portion_IR(gent)) # gentamicin resistance + summarise(count = n_rsi(GEN), # gentamicin availability + resistance = portion_IR(GEN)) # gentamicin resistance # Have a look at A and B. # B is more reliable because every isolate is only counted once. diff --git a/docs/reference/freq.html b/docs/reference/freq.html index e456932a6..25a733559 100644 --- a/docs/reference/freq.html +++ b/docs/reference/freq.html @@ -81,7 +81,7 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co @@ -146,7 +146,7 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co - + Get properties of an antibiotic @@ -487,8 +487,8 @@ top_freq can be used to get the top/bottom n items of a frequency table, with co # check differences between frequency tables -diff(freq(septic_patients$trim), - freq(septic_patients$trsu)) +diff(freq(septic_patients$TMP), + freq(septic_patients$SXT)) # } @@ -145,7 +145,7 @@ - + Get properties of an antibiotic @@ -243,13 +243,13 @@ ggplot_rsi(data, position = NULL, x = "Antibiotic", fill = "Interpretation", facet = NULL, breaks = seq(0, 1, 0.1), - limits = NULL, translate_ab = "official", fun = count_df, - nrow = NULL, datalabels = TRUE, datalabels.size = 3, - datalabels.colour = "grey15", ...) + limits = NULL, translate_ab = "name", language = get_locale(), + fun = count_df, nrow = NULL, datalabels = TRUE, + datalabels.size = 3, datalabels.colour = "grey15", ...) geom_rsi(position = NULL, x = c("Antibiotic", "Interpretation"), - fill = "Interpretation", translate_ab = "official", fun = count_df, - ...) + fill = "Interpretation", translate_ab = "name", + language = get_locale(), fun = count_df, ...) facet_rsi(facet = c("Interpretation", "Antibiotic"), nrow = NULL) @@ -295,7 +295,11 @@+ translate_ab -+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations into, usingabname
. Default behaviour is to translate to official names according to the WHO. Usetranslate_ab = FALSE
to disable translation.+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations into, usingab_name
. Default behaviour is to translate to official names according to the WHO. Usetranslate_ab = FALSE
to disable translation.+ language +the language used for translation of antibiotic names
fun @@ -325,7 +329,7 @@Details
-At default, the names of antibiotics will be shown on the plots using
+abname
. This can be set with the optionget_antibiotic_names
(a logical value), so change it e.g. toFALSE
withoptions(get_antibiotic_names = FALSE)
.At default, the names of antibiotics will be shown on the plots using
ab_name
. This can be set with the optionget_antibiotic_names
(a logical value), so change it e.g. toFALSE
withoptions(get_antibiotic_names = FALSE)
.The functions
geom_rsi
will take any variable from the data that has anrsi
class (created withas.rsi
) usingfun
(count_df
at default, can also beportion_df
) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.@@ -347,11 +351,11 @@ library(ggplot2) # get antimicrobial results for drugs against a UTI: -ggplot(septic_patients %>% select(amox, nitr, fosf, trim, cipr)) + +ggplot(septic_patients %>% select(AMX, NIT, FOS, TMP, CIP)) + geom_rsi() # prettify the plot using some additional functions: -df <- septic_patients[, c("amox", "nitr", "fosf", "trim", "cipr")] +df <- septic_patients[, c("AMX", "NIT", "FOS", "TMP", "CIP")] ggplot(df) + geom_rsi() + scale_y_percent() + @@ -361,17 +365,17 @@ # or better yet, simplify this using the wrapper function - a single command: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(AMX, NIT, FOS, TMP, CIP) %>% ggplot_rsi() # get only portions and no counts: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(AMX, NIT, FOS, TMP, CIP) %>% ggplot_rsi(fun = portion_df) # add other ggplot2 parameters as you like: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(AMX, NIT, FOS, TMP, CIP) %>% ggplot_rsi(width = 0.5, colour = "black", size = 1, @@ -386,18 +390,18 @@ # `age_group` is also a function of this package: group_by(age_group = age_groups(age)) %>% select(age_group, - cipr) %>% + CIP) %>% ggplot_rsi(x = "age_group") # }# NOT RUN { # for colourblind mode, use divergent colours from the viridis package: septic_patients %>% - select(amox, nitr, fosf, trim, cipr) %>% + select(AMX, NIT, FOS, TMP, CIP) %>% ggplot_rsi() + scale_fill_viridis_d() # it also supports groups (don't forget to use the group var on `x` or `facet`): septic_patients %>% - select(hospital_id, amox, nitr, fosf, trim, cipr) %>% + select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>% group_by(hospital_id) %>% ggplot_rsi(x = hospital_id, facet = Antibiotic, @@ -421,7 +425,7 @@ # get short MO names (like "E. coli") mutate(mo = mo_shortname(mo, Becker = TRUE)) %>% # select this short name and some antiseptic drugs - select(mo, cfur, gent, cipr) %>% + select(mo, CXM, GEN, CIP) %>% # group by MO group_by(mo) %>% # plot the thing, putting MOs on the facet diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index 700425ec1..296680ca7 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@
facet_rsi
creates 2d plots (at default based on S/I/R) usingfacet_wrap
.- + Get properties of an antibiotic @@ -273,7 +273,7 @@ guess_ab_col(df, "amoxicillin") # [1] "amox" -guess_ab_col(df, "J01AA07") # ATC code of Tetracycline +guess_ab_col(df, "J01AA07") # ATC code of tetracycline # [1] "tetr" guess_ab_col(df, "J01AA07", verbose = TRUE) @@ -287,7 +287,7 @@ # [1] "AMP_ND10" guess_ab_col(df, "J01CR02") # [1] "AMC_ED20" -guess_ab_col(df, as.atc("augmentin")) +guess_ab_col(df, as.ab("augmentin")) # [1] "AMC_ED20" # } diff --git a/docs/reference/index.html b/docs/reference/index.html index c3d3df8c9..0e7d4aebe 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -78,7 +78,7 @@ @@ -143,7 +143,7 @@ - + Get properties of an antibiotic @@ -281,11 +281,23 @@ - + + ++ Transform to antibiotic ID
+ + + Transform to ATC code
+ + + ++ Class 'disk'
+ @@ -316,6 +328,12 @@ EUCAST rules
+ + + ++ Data set for RSI interpretation
+ @@ -361,23 +379,11 @@ - +
atc_property()
atc_official()
atc_name()
atc_trivial_nl()
atc_certe()
atc_umcg()
atc_tradenames()
ab_name()
ab_atc()
ab_cid()
ab_synonyms()
ab_tradenames()
ab_group()
ab_atc_group1()
ab_atc_group2()
ab_ddd()
ab_property()
Property of an antibiotic
- - - -- Get ATC properties from WHOCC website
- - - - -- Name of an antibiotic
- @@ -400,6 +406,12 @@
inner_join_microorganisms()
left_join_microorganisms()
right_join_microorganisms()
full_join_microorganisms()
semi_join_microorganisms()
anti_join_microorganisms()
+ Join a table with
microorganisms
+ + + + +Get ATC properties from WHOCC website
@@ -464,12 +476,6 @@ Predict antimicrobial resistance
- - - -- Calculate resistance of isolates
- @@ -487,7 +493,7 @@ - + Data set with ~500 antibiotics
Data set with ~450 antibiotics
@@ -529,9 +535,9 @@ - + -+ Get language for AMR
Translate strings from AMR package
@@ -549,7 +555,7 @@ diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index a052f97c2..43d7aa867 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@ - +
ratio()
ab_property()
ab_atc()
ab_official()
ab_name()
ab_trivial_nl()
ab_certe()
ab_umcg()
ab_tradenames()
atc_ddd()
atc_groups()
ratio()
abname()
atc_property()
atc_official()
ab_official()
atc_name()
atc_trivial_nl()
atc_tradenames()
Deprecated functions
- + Get properties of an antibiotic @@ -242,19 +242,19 @@ key_antibiotics(tbl, col_mo = NULL, universal_1 = guess_ab_col(tbl, - "amox"), universal_2 = guess_ab_col(tbl, "amcl"), - universal_3 = guess_ab_col(tbl, "cfur"), - universal_4 = guess_ab_col(tbl, "pita"), - universal_5 = guess_ab_col(tbl, "cipr"), - universal_6 = guess_ab_col(tbl, "trsu"), - GramPos_1 = guess_ab_col(tbl, "vanc"), GramPos_2 = guess_ab_col(tbl, - "teic"), GramPos_3 = guess_ab_col(tbl, "tetr"), - GramPos_4 = guess_ab_col(tbl, "eryt"), GramPos_5 = guess_ab_col(tbl, - "oxac"), GramPos_6 = guess_ab_col(tbl, "rifa"), - GramNeg_1 = guess_ab_col(tbl, "gent"), GramNeg_2 = guess_ab_col(tbl, - "tobr"), GramNeg_3 = guess_ab_col(tbl, "coli"), - GramNeg_4 = guess_ab_col(tbl, "cfot"), GramNeg_5 = guess_ab_col(tbl, - "cfta"), GramNeg_6 = guess_ab_col(tbl, "mero"), warnings = TRUE, ...) + "AMX"), universal_2 = guess_ab_col(tbl, "AMC"), + universal_3 = guess_ab_col(tbl, "CXM"), + universal_4 = guess_ab_col(tbl, "TZP"), + universal_5 = guess_ab_col(tbl, "CIP"), + universal_6 = guess_ab_col(tbl, "SXT"), GramPos_1 = guess_ab_col(tbl, + "VAN"), GramPos_2 = guess_ab_col(tbl, "TEC"), + GramPos_3 = guess_ab_col(tbl, "TCY"), GramPos_4 = guess_ab_col(tbl, + "ERY"), GramPos_5 = guess_ab_col(tbl, "OXA"), + GramPos_6 = guess_ab_col(tbl, "RIF"), GramNeg_1 = guess_ab_col(tbl, + "GEN"), GramNeg_2 = guess_ab_col(tbl, "TOB"), + GramNeg_3 = guess_ab_col(tbl, "COL"), GramNeg_4 = guess_ab_col(tbl, + "CTX"), GramNeg_5 = guess_ab_col(tbl, "CAZ"), + GramNeg_6 = guess_ab_col(tbl, "MEM"), warnings = TRUE, ...) key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"), ignore_I = TRUE, points_threshold = 2, info = FALSE)diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index a9871569f..5bd628e8f 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@- + Get properties of an antibiotic @@ -241,50 +241,21 @@ - mdro(tbl, country = NULL, col_mo = NULL, info = TRUE, - amcl = guess_ab_col(), amik = guess_ab_col(), - amox = guess_ab_col(), ampi = guess_ab_col(), - azit = guess_ab_col(), aztr = guess_ab_col(), - cefa = guess_ab_col(), cfra = guess_ab_col(), - cfep = guess_ab_col(), cfot = guess_ab_col(), - cfox = guess_ab_col(), cfta = guess_ab_col(), - cftr = guess_ab_col(), cfur = guess_ab_col(), - chlo = guess_ab_col(), cipr = guess_ab_col(), - clar = guess_ab_col(), clin = guess_ab_col(), - clox = guess_ab_col(), coli = guess_ab_col(), - czol = guess_ab_col(), dapt = guess_ab_col(), - doxy = guess_ab_col(), erta = guess_ab_col(), - eryt = guess_ab_col(), fosf = guess_ab_col(), - fusi = guess_ab_col(), gent = guess_ab_col(), - imip = guess_ab_col(), kana = guess_ab_col(), - levo = guess_ab_col(), linc = guess_ab_col(), - line = guess_ab_col(), mero = guess_ab_col(), - metr = guess_ab_col(), mino = guess_ab_col(), - moxi = guess_ab_col(), nali = guess_ab_col(), - neom = guess_ab_col(), neti = guess_ab_col(), - nitr = guess_ab_col(), novo = guess_ab_col(), - norf = guess_ab_col(), oflo = guess_ab_col(), - peni = guess_ab_col(), pipe = guess_ab_col(), - pita = guess_ab_col(), poly = guess_ab_col(), - qida = guess_ab_col(), rifa = guess_ab_col(), - roxi = guess_ab_col(), siso = guess_ab_col(), - teic = guess_ab_col(), tetr = guess_ab_col(), - tica = guess_ab_col(), tige = guess_ab_col(), - tobr = guess_ab_col(), trim = guess_ab_col(), - trsu = guess_ab_col(), vanc = guess_ab_col(), verbose = FALSE) +mdro(x, country = NULL, col_mo = NULL, info = TRUE, + verbose = FALSE, ...) brmo(..., country = "nl") -mrgn(tbl, country = "de", ...) +mrgn(x, country = "de", ...) -eucast_exceptional_phenotypes(tbl, country = "EUCAST", ...)+eucast_exceptional_phenotypes(x, country = "EUCAST", ...)Arguments
@@ -559,70 +290,72 @@
- tbl -+ table with antibiotic columns, like e.g.
amox
andamcl
x +table with antibiotic columns, like e.g.
AMX
andAMC
- country @@ -298,253 +269,13 @@info print progress
- -amcl -- column name of an antibiotic, see Antibiotics
- -amik -- column name of an antibiotic, see Antibiotics
- -amox -- column name of an antibiotic, see Antibiotics
- -ampi -- column name of an antibiotic, see Antibiotics
- -azit -- column name of an antibiotic, see Antibiotics
- -aztr -- column name of an antibiotic, see Antibiotics
- -cefa -- column name of an antibiotic, see Antibiotics
- -cfra -- column name of an antibiotic, see Antibiotics
- -cfep -- column name of an antibiotic, see Antibiotics
- -cfot -- column name of an antibiotic, see Antibiotics
- -cfox -- column name of an antibiotic, see Antibiotics
- -cfta -- column name of an antibiotic, see Antibiotics
- -cftr -- column name of an antibiotic, see Antibiotics
- -cfur -- column name of an antibiotic, see Antibiotics
- -chlo -- column name of an antibiotic, see Antibiotics
- -cipr -- column name of an antibiotic, see Antibiotics
- -clar -- column name of an antibiotic, see Antibiotics
- -clin -- column name of an antibiotic, see Antibiotics
- -clox -- column name of an antibiotic, see Antibiotics
- -coli -- column name of an antibiotic, see Antibiotics
- -czol -- column name of an antibiotic, see Antibiotics
- -dapt -- column name of an antibiotic, see Antibiotics
- -doxy -- column name of an antibiotic, see Antibiotics
- -erta -- column name of an antibiotic, see Antibiotics
- -eryt -- column name of an antibiotic, see Antibiotics
- -fosf -- column name of an antibiotic, see Antibiotics
- -fusi -- column name of an antibiotic, see Antibiotics
- -gent -- column name of an antibiotic, see Antibiotics
- -imip -- column name of an antibiotic, see Antibiotics
- -kana -- column name of an antibiotic, see Antibiotics
- -levo -- column name of an antibiotic, see Antibiotics
- -linc -- column name of an antibiotic, see Antibiotics
- -line -- column name of an antibiotic, see Antibiotics
- -mero -- column name of an antibiotic, see Antibiotics
- -metr -- column name of an antibiotic, see Antibiotics
- -mino -- column name of an antibiotic, see Antibiotics
- -moxi -- column name of an antibiotic, see Antibiotics
- -nali -- column name of an antibiotic, see Antibiotics
- -neom -- column name of an antibiotic, see Antibiotics
- -neti -- column name of an antibiotic, see Antibiotics
- -nitr -- column name of an antibiotic, see Antibiotics
- -novo -- column name of an antibiotic, see Antibiotics
- -norf -- column name of an antibiotic, see Antibiotics
- -oflo -- column name of an antibiotic, see Antibiotics
- -peni -- column name of an antibiotic, see Antibiotics
- -pipe -- column name of an antibiotic, see Antibiotics
- -pita -- column name of an antibiotic, see Antibiotics
- -poly -- column name of an antibiotic, see Antibiotics
- -qida -- column name of an antibiotic, see Antibiotics
- -rifa -- column name of an antibiotic, see Antibiotics
- -roxi -- column name of an antibiotic, see Antibiotics
- -siso -- column name of an antibiotic, see Antibiotics
- -teic -- column name of an antibiotic, see Antibiotics
- -tetr -- column name of an antibiotic, see Antibiotics
- -tica -- column name of an antibiotic, see Antibiotics
- -tige -- column name of an antibiotic, see Antibiotics
- -tobr -- column name of an antibiotic, see Antibiotics
- -trim -- column name of an antibiotic, see Antibiotics
- -trsu -- column name of an antibiotic, see Antibiotics
- vanc -- column name of an antibiotic, see Antibiotics
verbose print additional info: missing antibiotic columns per parameter
... -+ parameters that are passed on to methods
column name of an antibiotic, see section Antibiotics
Antibiotics
-To define antibiotics column names, leave as it is to determine it automatically with
-guess_ab_col
or input a text (case-insensitive) or useNULL
to skip a column (e.g.tica = NULL
). Non-existing columns will anyway be skipped with a warning.Abbrevations of the column containing antibiotics in the form: abbreviation: generic name (ATC code)
-amcl: amoxicillin+clavulanic acid (J01CR02), - amik: amikacin (J01GB06), - amox: amoxicillin (J01CA04), - ampi: ampicillin (J01CA01), - azit: azithromycin (J01FA10), - azlo: azlocillin (J01CA09), - aztr: aztreonam (J01DF01), - cefa: cefaloridine (J01DB02), - cfep: cefepime (J01DE01), - cfot: cefotaxime (J01DD01), - cfox: cefoxitin (J01DC01), - cfra: cefradine (J01DB09), - cfta: ceftazidime (J01DD02), - cftr: ceftriaxone (J01DD04), - cfur: cefuroxime (J01DC02), - chlo: chloramphenicol (J01BA01), - cipr: ciprofloxacin (J01MA02), - clar: clarithromycin (J01FA09), - clin: clindamycin (J01FF01), - clox: flucloxacillin (J01CF05), - coli: colistin (J01XB01), - czol: cefazolin (J01DB04), - dapt: daptomycin (J01XX09), - doxy: doxycycline (J01AA02), - erta: ertapenem (J01DH03), - eryt: erythromycin (J01FA01), - fosf: fosfomycin (J01XX01), - fusi: fusidic acid (J01XC01), - gent: gentamicin (J01GB03), - imip: imipenem (J01DH51), - kana: kanamycin (J01GB04), - levo: levofloxacin (J01MA12), - linc: lincomycin (J01FF02), - line: linezolid (J01XX08), - mero: meropenem (J01DH02), - mezl: mezlocillin (J01CA10), - mino: minocycline (J01AA08), - moxi: moxifloxacin (J01MA14), - nali: nalidixic acid (J01MB02), - neom: neomycin (J01GB05), - neti: netilmicin (J01GB07), - nitr: nitrofurantoin (J01XE01), - norf: norfloxacin (J01MA06), - novo: novobiocin (an ATCvet code: QJ01XX95), - oflo: ofloxacin (J01MA01), - peni: (benzyl)penicillin (J01CE01), - pipe: piperacillin (J01CA12), - pita: piperacillin+tazobactam (J01CR05), - poly: polymyxin B (J01XB02), - pris: pristinamycin (J01FG01), - qida: quinupristin/dalfopristin (J01FG02), - rifa: rifampicin (J04AB02), - roxi: roxithromycin (J01FA06), - siso: sisomicin (J01GB08), - teic: teicoplanin (J01XA02), - tetr: tetracycline (J01AA07), - tica: ticarcillin (J01CA13), - tige: tigecycline (J01AA12), - tobr: tobramycin (J01GB01), - trim: trimethoprim (J01EA01), - trsu: sulfamethoxazole and trimethoprim (J01EE01), - vanc: vancomycin (J01XA01).
+To define antibiotics column names, leave as it is to determine it automatically with
+guess_ab_col
or input a text (case-insensitive), or useNULL
to skip a column (e.g.TIC = NULL
to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning.Available abbrevations of the column containing antibiotics in the form 'antimicrobial ID: name (ATC code)':
+AMC: amoxicillin/clavulanic acid (J01CR02), + AMK: amikacin (J01GB06), + AMX: amoxicillin (J01CA04), + AMP: ampicillin (J01CA01), + AZM: azithromycin (J01FA10), + AZL: azlocillin (J01CA09), + ATM: aztreonam (J01DF01), + RID: cefaloridine (J01DB02), + FEP: cefepime (J01DE01), + CTX: cefotaxime (J01DD01), + FOX: cefoxitin (J01DC01), + CED: cefradine (J01DB09), + CAZ: ceftazidime (J01DD02), + CRO: ceftriaxone (J01DD04), + CXM: cefuroxime (J01DC02), + CHL: chloramphenicol (J01BA01), + CIP: ciprofloxacin (J01MA02), + CLR: clarithromycin (J01FA09), + CLI: clindamycin (J01FF01), + FLC: flucloxacillin (J01CF05), + COL: colistin (J01XB01), + CZO: cefazolin (J01DB04), + DAP: daptomycin (J01XX09), + DOX: doxycycline (J01AA02), + ETP: ertapenem (J01DH03), + ERY: erythromycin (J01FA01), + FOS: fosfomycin (J01XX01), + FUS: fusidic acid (J01XC01), + GEN: gentamicin (J01GB03), + IPM: imipenem (J01DH51), + KAN: kanamycin (J01GB04), + LVX: levofloxacin (J01MA12), + LIN: lincomycin (J01FF02), + LNZ: linezolid (J01XX08), + MEM: meropenem (J01DH02), + MEZ: mezlocillin (J01CA10), + MNO: minocycline (J01AA08), + MFX: moxifloxacin (J01MA14), + MTR: metronidazole (J01XD01), + NAL: nalidixic acid (J01MB02), + NEO: neomycin (J01GB05), + NET: netilmicin (J01GB07), + NIT: nitrofurantoin (J01XE01), + NOR: norfloxacin (J01MA06), + NOV: novobiocin (an ATCvet code: QJ01XX95), + OFX: ofloxacin (J01MA01), + OXA: oxacillin (J01CF04), + PEN: penicillin G (J01CE01), + PIP: piperacillin (J01CA12), + TZP: piperacillin/tazobactam (J01CR05), + PLB: polymyxin B (J01XB02), + PRI: pristinamycin (J01FG01), + QDA: quinupristin/dalfopristin (J01FG02), + RIF: rifampicin (J04AB02), + RXT: roxithromycin (J01FA06), + SIS: sisomicin (J01GB08), + TEC: teicoplanin (J01XA02), + TCY: tetracycline (J01AA07), + TIC: ticarcillin (J01CA13), + TGC: tigecycline (J01AA12), + TOB: tobramycin (J01GB01), + TMP: trimethoprim (J01EA01), + SXT: trimethoprim/sulfamethoxazole (J01EE01), + VAN: vancomycin (J01XA01).
Read more on our website!
diff --git a/docs/reference/microorganisms.codes.html b/docs/reference/microorganisms.codes.html index b0df9b2bf..afe4035e1 100644 --- a/docs/reference/microorganisms.codes.html +++ b/docs/reference/microorganisms.codes.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@- + Get properties of an antibiotic diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index 99b3e534a..04cc088fa 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@ - + Get properties of an antibiotic diff --git a/docs/reference/microorganisms.old.html b/docs/reference/microorganisms.old.html index 0549ab5cf..8e2e09778 100644 --- a/docs/reference/microorganisms.old.html +++ b/docs/reference/microorganisms.old.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@ - + Get properties of an antibiotic diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index e3c0a846a..4c9f333a8 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -80,7 +80,7 @@ @@ -145,7 +145,7 @@ - + Get properties of an antibiotic @@ -241,29 +241,29 @@ - mo_fullname(x, language = get_locale(), ...) +mo_fullname(x, language = get_locale(), ...) -mo_shortname(x, language = get_locale(), ...) +mo_shortname(x, language = get_locale(), ...) -mo_subspecies(x, language = get_locale(), ...) +mo_subspecies(x, language = get_locale(), ...) -mo_species(x, language = get_locale(), ...) +mo_species(x, language = get_locale(), ...) -mo_genus(x, language = get_locale(), ...) +mo_genus(x, language = get_locale(), ...) -mo_family(x, language = get_locale(), ...) +mo_family(x, language = get_locale(), ...) -mo_order(x, language = get_locale(), ...) +mo_order(x, language = get_locale(), ...) -mo_class(x, language = get_locale(), ...) +mo_class(x, language = get_locale(), ...) -mo_phylum(x, language = get_locale(), ...) +mo_phylum(x, language = get_locale(), ...) -mo_kingdom(x, language = get_locale(), ...) +mo_kingdom(x, language = get_locale(), ...) -mo_type(x, language = get_locale(), ...) +mo_type(x, language = get_locale(), ...) -mo_gramstain(x, language = get_locale(), ...) +mo_gramstain(x, language = get_locale(), ...) mo_ref(x, ...) @@ -273,11 +273,11 @@ mo_rank(x, ...) -mo_taxonomy(x, language = get_locale(), ...) +mo_taxonomy(x, language = get_locale(), ...) mo_url(x, open = FALSE, ...) -mo_property(x, property = "fullname", language = get_locale(), ...)+mo_property(x, property = "fullname", language = get_locale(), ...)Arguments
@@ -288,7 +288,7 @@
language -+ language of the returned text, defaults to system language (see
get_locale
) and can also be set withgetOption("AMR_locale")
. Uselanguage = NULL
orlanguage = ""
to prevent translation.language of the returned text, defaults to system language (see
get_locale
) and can also be set withgetOption("AMR_locale")
. Uselanguage = NULL
orlanguage = ""
to prevent translation.... @@ -323,13 +323,9 @@
mo_ref("Chlamydophila psittaci")
will return"Everett et al., 1999"
(without a warning)The Gram stain -
+mo_gramstain()
- will be determined on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002) who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram positive - all other bacteria are considered Gram negative. Species outside the kingdom of Bacteria will return a valueNA
.All output will be translated where possible.
The function
-mo_url()
will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.Supported languages
- - -Supported languages are
-"en"
(English),"de"
(German),"nl"
(Dutch),"es"
(Spanish),"it"
(Italian),"fr"
(French), and"pt"
(Portuguese).Catalogue of Life
@@ -341,7 +337,7 @@ This package contains the complete taxonomic tree of almost all microorganisms ([1] Becker K et al. Coagulase-Negative Staphylococci. 2014. Clin Microbiol Rev. 27(4): 870–926. https://dx.doi.org/10.1128/CMR.00109-13
-[2] Becker K et al. Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).. 2019. Clin Microbiol Infect. 2019 Mar 11. https://doi.org/10.1016/j.cmi.2019.02.028
+[2] Becker K et al. Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS). 2019. Clin Microbiol Infect. https://doi.org/10.1016/j.cmi.2019.02.028
[3] Lancefield RC A serological differentiation of human and other groups of hemolytic streptococci. 1933. J Exp Med. 57(4): 571–95. https://dx.doi.org/10.1084/jem.57.4.571
[4] Catalogue of Life: Annual Checklist (public online taxonomic database), www.catalogueoflife.org (check included annual version with
@@ -375,7 +371,7 @@ This package contains the complete taxonomic tree of almost all microorganisms ( mo_gramstain("E. coli") # "Gram negative" mo_type("E. coli") # "Bacteria" (equal to kingdom) mo_rank("E. coli") # "species" -mo_url("E. coli") # get the direct url to the Catalogue of Life +mo_url("E. coli") # get the direct url to the online database entry ## scientific reference mo_ref("E. coli") # "Castellani et al., 1919" @@ -433,7 +429,7 @@ This package contains the complete taxonomic tree of almost all microorganisms ( language = "nl") # "Streptococcus groep A" -# get a list with the complete taxonomy (kingdom to subspecies) +# get a list with the complete taxonomy (from kingdom to subspecies) mo_taxonomy("E. coli") # } @@ -446,8 +442,6 @@ This package contains the complete taxonomic tree of almost all microorganisms (catalogue_of_life_version()
).Details -Supported languages -Catalogue of Life Source diff --git a/docs/reference/portion.html b/docs/reference/portion.html index 43621143a..a488db6a6 100644 --- a/docs/reference/portion.html +++ b/docs/reference/portion.html @@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port @@ -146,7 +146,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port- + Get properties of an antibiotic @@ -258,8 +258,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port portion_S(..., minimum = 30, as_percent = FALSE, also_single_tested = FALSE) -portion_df(data, translate_ab = getOption("get_antibiotic_names", - "official"), minimum = 30, as_percent = FALSE, combine_IR = FALSE) +portion_df(data, translate_ab = "name", language = get_locale(), + minimum = 30, as_percent = FALSE, combine_IR = FALSE) Arguments
@@ -286,7 +286,11 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
+ translate_ab -+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingabname
. This can be set withgetOption("get_antibiotic_names")
.+ a column name of the
antibiotics
data set to translate the antibiotic abbreviations to, usingab_property
+ language +language of the returned text, defaults to system language (see
get_locale
) and can also be set withgetOption("AMR_locale")
. Uselanguage = NULL
orlanguage = ""
to prevent translation.combine_IR @@ -307,8 +311,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and portRemember that you should filter your table to let it contain only first isolates! Use
first_isolate
to determine them in your data set.These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the
-count
functions to count isolates. Low counts can infuence the outcome - theseportion
functions may camouflage this, since they only return the portion albeit being dependent on theminimum
parameter.-
portion_df
takes any variable fromdata
that has an"rsi"
class (created withas.rsi
) and calculates the portions R, I and S. The resulting tidy data (see Source)data.frame
will have three rows (S/I/R) and a column for each variable with class"rsi"
.The old
rsi
function is still available for backwards compatibility but is deprecated. +
portion_df
takes any variable fromdata
that has an"rsi"
class (created withas.rsi
) and calculates the portions R, I and S. The resulting tidy data (see Source)data.frame
will have three rows (S/I/R) and a column for each variable with class"rsi"
.
To calculate the probability (p) of susceptibility of one antibiotic, we use this formula:@@ -338,63 +341,63 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port ?septic_patients # Calculate resistance -portion_R(septic_patients$amox) -portion_IR(septic_patients$amox) +portion_R(septic_patients$AMX) +portion_IR(septic_patients$AMX) # Or susceptibility -portion_S(septic_patients$amox) -portion_SI(septic_patients$amox) +portion_S(septic_patients$AMX) +portion_SI(septic_patients$AMX) # Do the above with pipes: library(dplyr) -septic_patients %>% portion_R(amox) -septic_patients %>% portion_IR(amox) -septic_patients %>% portion_S(amox) -septic_patients %>% portion_SI(amox) +septic_patients %>% portion_R(AMX) +septic_patients %>% portion_IR(AMX) +septic_patients %>% portion_S(AMX) +septic_patients %>% portion_SI(AMX) septic_patients %>% group_by(hospital_id) %>% - summarise(p = portion_S(cipr), - n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr + summarise(p = portion_S(CIP), + n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr septic_patients %>% group_by(hospital_id) %>% - summarise(R = portion_R(cipr, as_percent = TRUE), - I = portion_I(cipr, as_percent = TRUE), - S = portion_S(cipr, as_percent = TRUE), - n1 = count_all(cipr), # the actual total; sum of all three - n2 = n_rsi(cipr), # same - analogous to n_distinct + summarise(R = portion_R(CIP, as_percent = TRUE), + I = portion_I(CIP, as_percent = TRUE), + S = portion_S(CIP, as_percent = TRUE), + n1 = count_all(CIP), # the actual total; sum of all three + n2 = n_rsi(CIP), # same - analogous to n_distinct total = n()) # NOT the number of tested isolates! # Calculate co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy: -septic_patients %>% portion_S(amcl) # S = 71.4% -septic_patients %>% count_all(amcl) # n = 1879 +septic_patients %>% portion_S(AMC) # S = 71.4% +septic_patients %>% count_all(AMC) # n = 1879 -septic_patients %>% portion_S(gent) # S = 74.0% -septic_patients %>% count_all(gent) # n = 1855 +septic_patients %>% portion_S(GEN) # S = 74.0% +septic_patients %>% count_all(GEN) # n = 1855 -septic_patients %>% portion_S(amcl, gent) # S = 92.3% -septic_patients %>% count_all(amcl, gent) # n = 1798 +septic_patients %>% portion_S(AMC, GEN) # S = 92.3% +septic_patients %>% count_all(AMC, GEN) # n = 1798 septic_patients %>% group_by(hospital_id) %>% - summarise(cipro_p = portion_S(cipr, as_percent = TRUE), - cipro_n = count_all(cipr), - genta_p = portion_S(gent, as_percent = TRUE), - genta_n = count_all(gent), - combination_p = portion_S(cipr, gent, as_percent = TRUE), - combination_n = count_all(cipr, gent)) + summarise(cipro_p = portion_S(CIP, as_percent = TRUE), + cipro_n = count_all(CIP), + genta_p = portion_S(GEN, as_percent = TRUE), + genta_n = count_all(GEN), + combination_p = portion_S(CIP, GEN, as_percent = TRUE), + combination_n = count_all(CIP, GEN)) # Get portions S/I/R immediately of all rsi columns septic_patients %>% - select(amox, cipr) %>% + select(AMX, CIP) %>% portion_df(translate = FALSE) # It also supports grouping variables septic_patients %>% - select(hospital_id, amox, cipr) %>% + select(hospital_id, AMX, CIP) %>% group_by(hospital_id) %>% portion_df(translate = FALSE) @@ -404,8 +407,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port my_table %>% filter(first_isolate == TRUE, genus == "Helicobacter") %>% - summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole - n = count_all(amox, metr)) + summarise(p = portion_S(AMX, MTR), # amoxicillin with metronidazole + n = count_all(AMX, MTR)) # } @@ -145,7 +145,7 @@- + Get properties of an antibiotic @@ -357,7 +357,7 @@ Examples
# NOT RUN { -x <- resistance_predict(septic_patients, col_ab = "amox", year_min = 2010) +x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010) plot(x) ggplot_rsi_predict(x) @@ -366,7 +366,7 @@ x <- septic_patients %>% filter_first_isolate() %>% filter(mo_genus(mo) == "Staphylococcus") %>% - resistance_predict("peni") + resistance_predict("PEN") plot(x) @@ -380,7 +380,7 @@ data <- septic_patients %>% filter(mo == as.mo("E. coli")) %>% - resistance_predict(col_ab = "amox", + resistance_predict(col_ab = "AMX", col_date = "date", info = FALSE, minimum = 15) diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html new file mode 100644 index 000000000..fe532c2bb --- /dev/null +++ b/docs/reference/rsi_translation.html @@ -0,0 +1,311 @@ + + + + + + + + +Data set for RSI interpretation — rsi_translation • AMR (for R) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + + diff --git a/docs/reference/translate.html b/docs/reference/translate.html new file mode 100644 index 000000000..9e4cf1b31 --- /dev/null +++ b/docs/reference/translate.html @@ -0,0 +1,336 @@ + + + + + + + + ++ + + + + +++ + +++ +++ +Data set for RSI interpretation
+ ++rsi_translation.Rd
+ ++ +Data set to interpret MIC and disk diffusion to RSI values. Included guidelines are CLSI (2011-2019) and EUCAST (2011-2019). Use
+ +as.rsi
to transform MICs or disks measurements to RSI values.rsi_translation
+ +Format
+ +A
data.frame
with 11,559 observations and 9 variables:+
+ +guideline
- +
Name of the guideline
mo
- +
Microbial ID, see
as.mo
ab
- +
Antibiotic ID, see
as.ab
ref_tbl
- +
Info about where the guideline rule can be found
S_mic
- +
Lowest MIC value that leads to "S"
R_mic
- +
Highest MIC value that leads to "R"
dose_disk
- +
Dose of the used disk diffusion method
S_disk
- +
Lowest number of millimeters that leads to "S"
R_disk
- +
Highest number of millimeters that leads to "R"
Read more on our website!
+ + +On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
+ + +Translate strings from AMR package — translate • AMR (for R) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +++ + + + + + + + + diff --git a/docs/sitemap.xml b/docs/sitemap.xml index d641d6185..45016876d 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -16,7 +16,7 @@+ + + + + +++ + +++ +++ +Translate strings from AMR package
+ ++translate.Rd
+ ++ +For language-dependent output of AMR functions, like
+ +mo_fullname
andmo_type
.get_locale()
+ +Details
+ +Strings will be translated to foreign languages if they are defined in a local translation file. This file comes with this package and can be found when running:
++
system.file("translations.tsv", package = "AMR")
This file will be read by all functions where a translated output can be desired, like all
+mo_property
functions (mo_fullname
,mo_type
, etc.). Please suggest your own translations by creating a new issue on our repository.The system language will be used at default, if supported, using
+ +get_locale
. The system language can be overwritten withgetOption("AMR_locale")
.Read more on our website!
+ + +On our website https://msberends.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.
+ + +Examples
+# NOT RUN { +# The 'language' parameter of below functions +# will be set automatically to your system language +# with get_locale() + +# English +mo_fullname("CoNS", language = "en") +#> "Coagulase-negative Staphylococcus (CoNS)" + +# German +mo_fullname("CoNS", language = "de") +#> "Koagulase-negative Staphylococcus (KNS)" + +# Dutch +mo_fullname("CoNS", language = "nl") +#> "Coagulase-negatieve Staphylococcus (CNS)" + +# Spanish +mo_fullname("CoNS", language = "es") +#> "Staphylococcus coagulasa negativo (SCN)" + +# Italian +mo_fullname("CoNS", language = "it") +#> "Staphylococcus negativo coagulasi (CoNS)" + +# Portuguese +mo_fullname("CoNS", language = "pt") +#> "Staphylococcus coagulase negativo (CoNS)" +# }+https://msberends.gitlab.io/AMR/reference/WHONET.html - https://msberends.gitlab.io/AMR/reference/abname.html +https://msberends.gitlab.io/AMR/reference/ab_property.html https://msberends.gitlab.io/AMR/reference/age.html @@ -27,9 +27,15 @@+ https://msberends.gitlab.io/AMR/reference/antibiotics.html + https://msberends.gitlab.io/AMR/reference/as.ab.html ++ https://msberends.gitlab.io/AMR/reference/as.atc.html + https://msberends.gitlab.io/AMR/reference/as.disk.html +@@ -42,9 +48,6 @@ https://msberends.gitlab.io/AMR/reference/as.mic.html - https://msberends.gitlab.io/AMR/reference/atc_online.html - https://msberends.gitlab.io/AMR/reference/atc_property.html -@@ -72,9 +75,6 @@ https://msberends.gitlab.io/AMR/reference/availability.html - https://msberends.gitlab.io/AMR/reference/g.test.html - https://msberends.gitlab.io/AMR/reference/get_locale.html -@@ -124,7 +124,7 @@ https://msberends.gitlab.io/AMR/reference/ggplot_rsi.html https://msberends.gitlab.io/AMR/reference/resistance_predict.html - https://msberends.gitlab.io/AMR/reference/rsi.html +https://msberends.gitlab.io/AMR/reference/rsi_translation.html https://msberends.gitlab.io/AMR/reference/septic_patients.html @@ -132,6 +132,9 @@+ https://msberends.gitlab.io/AMR/reference/skewness.html + https://msberends.gitlab.io/AMR/reference/translate.html +@@ -148,7 +151,7 @@ https://msberends.gitlab.io/AMR/articles/AMR.html https://msberends.gitlab.io/AMR/articles/WHONET.html - https://msberends.gitlab.io/AMR/articles/atc_property.html +https://msberends.gitlab.io/AMR/articles/ab_property.html https://msberends.gitlab.io/AMR/articles/benchmarks.html diff --git a/index.md b/index.md index 7677cd2a6..7ad967e69 100644 --- a/index.md +++ b/index.md @@ -6,7 +6,7 @@ `AMR` is a free and open-source [R package](https://www.r-project.org) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. It supports any data format, including WHONET/EARS-Net data. -After installing this package, R knows [**~65,000 microorganisms**](./reference/microorganisms.html) and [**~500 antibiotics**](./reference/antibiotics.html) by name and code, and knows all about valid RSI and MIC values. +After installing this package, R knows [**~65,000 microorganisms**](./reference/microorganisms.html) and [**~450 antibiotics**](./reference/antibiotics.html) by name and code, and knows all about valid RSI and MIC values. **Used to SPSS?** Read our [tutorial on how to import data from SPSS, SAS or Stata](./articles/SPSS.html) and learn in which ways R outclasses any of these statistical packages. @@ -114,7 +114,7 @@ Read more about the data from the Catalogue of Life [in our manual](./reference/-This package contains **all ~500 antimicrobial drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, https://www.whocc.no) and the [Pharmaceuticals Community Register of the European Commission](http://ec.europa.eu/health/documents/community-register/html/atc.htm). +This package contains **all ~450 antimicrobial drugs** and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD, oral and IV) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, https://www.whocc.no) and the [Pharmaceuticals Community Register of the European Commission](http://ec.europa.eu/health/documents/community-register/html/atc.htm). Read more about the data from WHOCC [in our manual](./reference/WHOCC.html). @@ -132,10 +132,10 @@ The `AMR` package basically does four important things: 1. It **cleanses existing data** by providing new *classes* for microoganisms, antibiotics and antimicrobial results (both S/I/R and MIC). By installing this package, you teach R everything about microbiology that is needed for analysis. These functions all use intelligent rules to guess results that you would expect: - * Use `as.mo()` to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNE" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)). + * Use `as.mo()` to get a microbial ID. The IDs are human readable for the trained eye - the ID of *Klebsiella pneumoniae* is "B_KLBSL_PNE" (B stands for Bacteria) and the ID of *S. aureus* is "B_STPHY_AUR". The function takes almost any text as input that looks like the name or code of a microorganism like "E. coli", "esco" or "esccol" and tries to find expected results using intelligent rules combined with the included Catalogue of Life data set. It only takes milliseconds to find results, please see our [benchmarks](./articles/benchmarks.html). Moreover, it can group *Staphylococci* into coagulase negative and positive (CoNS and CoPS, see [source](./reference/as.mo.html#source)) and can categorise *Streptococci* into Lancefield groups (like beta-haemolytic *Streptococcus* Group B, [source](./reference/as.mo.html#source)). * Use `as.rsi()` to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like "<=0.002; S" (combined MIC/RSI) will result in "S". * Use `as.mic()` to cleanse your MIC values. It produces a so-called factor (called *ordinal* in SPSS) with valid MIC values as levels. A value like "<=0.002; S" (combined MIC/RSI) will result in "<=0.002". - * Use `as.atc()` to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values "Furabid", "Furadantin", "nitro" all return the ATC code of Nitrofurantoine. + * Use `as.ab()` to get a antibiotic ID, which are abbreviations used by EARS-Net whenever available. Use `as.atc()` to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values "Furabid", "Furadantin", "nitro" all return the ID of Nitrofurantoine. 2. It **enhances existing data** and **adds new data** from data sets included in this package. @@ -144,7 +144,7 @@ The `AMR` package basically does four important things: * You can also identify first *weighted* isolates of every patient, an adjusted version of the CLSI guideline. This takes into account key antibiotics of every strain and compares them. * Use `mdro()` (abbreviation of Multi Drug Resistant Organisms) to check your isolates for exceptional resistance with country-specific guidelines or EUCAST rules. Currently, national guidelines for Germany and the Netherlands are supported. * The [data set `microorganisms`](./reference/microorganisms.html) contains the complete taxonomic tree of ~65,000 microorganisms. Furthermore, some colloquial names and all Gram stains are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like `mo_genus()`, `mo_family()`, `mo_gramstain()` or even `mo_phylum()`. As they use `as.mo()` internally, they also use the same intelligent rules for determination. For example, `mo_genus("MRSA")` and `mo_genus("S. aureus")` will both return `"Staphylococcus"`. They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data. - * The [data set `antibiotics`](./reference/antibiotics.html) contains almost 500 antimicrobial drugs with their ATC code, EARS-Net code, common LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains hundreds of trade names. Use functions like `atc_name()` and `atc_tradenames()` to look up values. The `atc_*` functions use `as.atc()` internally so they support the same intelligent rules to guess the most probable result. For example, `atc_name("Fluclox")`, `atc_name("Floxapen")` and `atc_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. + * The [data set `antibiotics`](./reference/antibiotics.html) contains ~450 antimicrobial drugs with their EARS-Net code, ATC code, PubChem compound ID, official name, common LIS codes and DDDs of both oral and parenteral administration. It also contains all (thousands of) trade names found in PubChem. Use functions like `ab_name()`, `ab_group()` and `ab_tradenames()` to look up values. The `ab_*` functions use `as.ab()` internally so they support the same intelligent rules to guess the most probable result. For example, `ab_name("Fluclox")`, `ab_name("Floxapen")` and `ab_name("J01CF05")` will all return `"Flucloxacillin"`. These functions can again be used to add new variables to your data. 3. It **analyses the data** with convenient functions that use well-known methods. diff --git a/inst/eucast/eucast_rules.tsv b/inst/eucast/eucast_rules.tsv index f68ea5812..2537e5986 100644 --- a/inst/eucast/eucast_rules.tsv +++ b/inst/eucast/eucast_rules.tsv @@ -1,182 +1,182 @@ if_mo_property like_is_one_of this_value and_these_antibiotics have_these_values then_change_these_antibiotics to_value reference.rule reference.rule_group -order is Enterobacteriales ampi S amox S Enterobacteriales (Order) Breakpoints -order is Enterobacteriales ampi I amox I Enterobacteriales (Order) Breakpoints -order is Enterobacteriales ampi R amox R Enterobacteriales (Order) Breakpoints -genus is Staphylococcus peni, cfox S ampi, amox, pipe, tica S Staphylococcus Breakpoints -genus is Staphylococcus peni, cfox R, S oxac, clox S Staphylococcus Breakpoints -genus is Staphylococcus cfox R all_betalactams R Staphylococcus Breakpoints -genus_species is Staphylococcus saprophyticus ampi S amox, amcl, pipe, pita S Staphylococcus Breakpoints -genus is Staphylococcus cfox S carbapenems, cephalosporins_without_cfta S Staphylococcus Breakpoints -genus is Staphylococcus cfox I carbapenems, cephalosporins_without_cfta I Staphylococcus Breakpoints -genus is Staphylococcus cfox R carbapenems, cephalosporins_without_cfta R Staphylococcus Breakpoints -genus is Staphylococcus norf S cipr, levo, moxi, oflo S Staphylococcus Breakpoints -genus is Staphylococcus eryt S azit, clar, roxi S Staphylococcus Breakpoints -genus is Staphylococcus eryt I azit, clar, roxi I Staphylococcus Breakpoints -genus is Staphylococcus eryt R azit, clar, roxi R Staphylococcus Breakpoints -genus is Staphylococcus tetr S doxy, mino S Staphylococcus Breakpoints -genus_species is Enterococcus faecium ampi R all_betalactams R Enterococcus Breakpoints -genus is Enterococcus ampi S amox, amcl, pipe, pita S Enterococcus Breakpoints -genus is Enterococcus ampi I amox, amcl, pipe, pita I Enterococcus Breakpoints -genus is Enterococcus ampi R amox, amcl, pipe, pita R Enterococcus Breakpoints -genus is Enterococcus norf S cipr, levo S Enterococcus Breakpoints -genus is Enterococcus norf I cipr, levo I Enterococcus Breakpoints -genus is Enterococcus norf R cipr, levo R Enterococcus Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ peni S aminopenicillins, ureidopenicillins, cephalosporins, carbapenems, clox, amcl S Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ peni I aminopenicillins, ureidopenicillins, cephalosporins, carbapenems, clox, amcl I Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ peni R aminopenicillins, ureidopenicillins, cephalosporins, carbapenems, clox, amcl R Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ norf S levo, moxi S Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ eryt S azit, clar, roxi S Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ eryt I azit, clar, roxi I Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ eryt R azit, clar, roxi R Streptococcus groups A, B, C, G Breakpoints -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ tetr S doxy, mino S Streptococcus groups A, B, C, G Breakpoints -genus_species is Streptococcus pneumoniae peni S ampi, amox, amcl, pipe, pita S Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae ampi S amox, amcl, pipe, pita S Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae ampi I amox, amcl, pipe, pita I Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae ampi R amox, amcl, pipe, pita R Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae norf S levo, moxi S Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae eryt S azit, clar, roxi S Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae eryt I azit, clar, roxi I Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae eryt R azit, clar, roxi R Streptococcus pneumoniae Breakpoints -genus_species is Streptococcus pneumoniae tetr S doxy, mino S Streptococcus pneumoniae Breakpoints -genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ peni S ampi, amox, amcl, pipe, pita S Viridans group streptococci Breakpoints -genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ ampi S amox, amcl, pipe, pita S Viridans group streptococci Breakpoints -genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ ampi I amox, amcl, pipe, pita I Viridans group streptococci Breakpoints -genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ ampi R amox, amcl, pipe, pita R Viridans group streptococci Breakpoints -genus_species is Haemophilus influenzae ampi S amox, pipe S Haemophilus influenzae Breakpoints -genus_species is ^Haemophilus influenzae ampi I amox, pipe I Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae ampi R amox, pipe R Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae peni S ampi, amox, amcl, pipe, pita S Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae amcl S pita S Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae amcl I pita I Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae amcl R pita R Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae nali S cipr, levo, moxi, oflo S Haemophilus influenzae Breakpoints -genus_species is Haemophilus influenzae tetr S doxy, mino S Haemophilus influenzae Breakpoints -genus_species is Moraxella catarrhalis amcl S pita S Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis amcl I pita I Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis amcl R pita R Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis nali S cipr, levo, moxi, oflo S Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis eryt S azit, clar, roxi S Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis eryt I azit, clar, roxi I Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis eryt R azit, clar, roxi R Moraxella catarrhalis Breakpoints -genus_species is Moraxella catarrhalis tetr S doxy, mino S Moraxella catarrhalis Breakpoints -genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus , Propionibacterium peni S ampi, amox, pipe, pita, tica S Anaerobic Gram positives Breakpoints -genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus , Propionibacterium peni I ampi, amox, pipe, pita, tica I Anaerobic Gram positives Breakpoints -genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus , Propionibacterium peni R ampi, amox, pipe, pita, tica R Anaerobic Gram positives Breakpoints -genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella peni S ampi, amox, pipe, pita, tica S Anaerobic Gram negatives Breakpoints -genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella peni I ampi, amox, pipe, pita, tica I Anaerobic Gram negatives Breakpoints -genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella peni R ampi, amox, pipe, pita, tica R Anaerobic Gram negatives Breakpoints -genus_species is Pasteurella multocida peni S ampi, amox S Pasteurella multocida Breakpoints -genus_species is Pasteurella multocida peni I ampi, amox I Pasteurella multocida Breakpoints -genus_species is Pasteurella multocida peni R ampi, amox R Pasteurella multocida Breakpoints -genus_species is Campylobacter coli eryt S azit, clar S Campylobacter coli Breakpoints -genus_species is Campylobacter coli eryt I azit, clar I Campylobacter coli Breakpoints -genus_species is Campylobacter coli eryt R azit, clar R Campylobacter coli Breakpoints -genus_species is Campylobacter coli tetr S doxy S Campylobacter coli Breakpoints -genus_species is Campylobacter coli tetr I doxy I Campylobacter coli Breakpoints -genus_species is Campylobacter coli tetr R doxy R Campylobacter coli Breakpoints -genus_species is Campylobacter jejuni eryt S azit, clar S Campylobacter jejuni Breakpoints -genus_species is Campylobacter jejuni eryt I azit, clar I Campylobacter jejuni Breakpoints -genus_species is Campylobacter jejuni eryt R azit, clar R Campylobacter jejuni Breakpoints -genus_species is Campylobacter jejuni tetr S doxy S Campylobacter jejuni Breakpoints -genus_species is Campylobacter jejuni tetr I doxy I Campylobacter jejuni Breakpoints -genus_species is Campylobacter jejuni tetr R doxy R Campylobacter jejuni Breakpoints -genus_species is Aerococcus sanguinicola norf S fluoroquinolones S Aerococcus sanguinicola Breakpoints -genus_species is Aerococcus sanguinicola norf I fluoroquinolones I Aerococcus sanguinicola Breakpoints -genus_species is Aerococcus sanguinicola norf R fluoroquinolones R Aerococcus sanguinicola Breakpoints -genus_species is Aerococcus sanguinicola cipr S levo S Aerococcus sanguinicola Breakpoints -genus_species is Aerococcus sanguinicola cipr I levo I Aerococcus sanguinicola Breakpoints -genus_species is Aerococcus sanguinicola cipr R levo R Aerococcus urinae Breakpoints -genus_species is Aerococcus urinae norf S fluoroquinolones S Aerococcus urinae Breakpoints -genus_species is Aerococcus urinae norf I fluoroquinolones I Aerococcus urinae Breakpoints -genus_species is Aerococcus urinae norf R fluoroquinolones R Aerococcus urinae Breakpoints -genus_species is Aerococcus urinae cipr S levo S Aerococcus urinae Breakpoints -genus_species is Aerococcus urinae cipr I levo I Aerococcus urinae Breakpoints -genus_species is Aerococcus urinae cipr R levo R Aerococcus urinae Breakpoints -genus_species is Kingella kingae peni S ampi, amox S Kingella kingae Breakpoints -genus_species is Kingella kingae peni I ampi, amox I Kingella kingae Breakpoints -genus_species is Kingella kingae peni R ampi, amox R Kingella kingae Breakpoints -genus_species is Kingella kingae eryt S azit, clar S Kingella kingae Breakpoints -genus_species is Kingella kingae eryt I azit, clar I Kingella kingae Breakpoints -genus_species is Kingella kingae eryt R azit, clar R Kingella kingae Breakpoints -genus_species is Kingella kingae tetr S doxy S Kingella kingae Breakpoints -family is Enterobacteriaceae peni, glycopeptides, fusi, macrolides, linc, streptogramins, rifa, dapt, line R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, tica R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, amcl, czol, cfox R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Enterobacter cloacae aminopenicillins, amcl, czol, cfox R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Enterobacter aerogenes aminopenicillins, amcl, czol, cfox R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Escherichia hermanni aminopenicillins, tica R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Hafnia alvei aminopenicillins, amcl, czol, cfox R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus is Klebsiella aminopenicillins, tica R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Morganella morganii aminopenicillins, amcl, czol, tetracyclines, polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Proteus mirabilis tetracyclines, tige, polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Proteus penneri aminopenicillins, czol, cfur, tetracyclines, tige, polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Proteus vulgaris aminopenicillins, czol, cfur, tetracyclines, tige, polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Providencia rettgeri aminopenicillins, amcl, czol, cfur, tetracyclines, tige, polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Providencia stuartii aminopenicillins, amcl, czol, cfur, tetracyclines, tige, polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus is Raoultella aminopenicillins, tica R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Serratia marcescens aminopenicillins, amcl, czol, cfox, cfur, tetracyclines[tetracyclines != na.rm(mino)], polymyxins, nitr R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Yersinia enterocolitica aminopenicillins, amcl, tica, czol, cfox R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus_species is Yersinia pseudotuberculosis poly, coli R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules -genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordatella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas peni, cfox, cfur, glycopeptides, fusi, macrolides, linc, streptogramins, rifa, dapt, line R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Acinetobacter baumannii aminopenicillins, amcl, czol, cfot, cftr, aztr, erta, trim, fosf, doxy, tetr R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Acinetobacter pittii aminopenicillins, amcl, czol, cfot, cftr, aztr, erta, trim, fosf, doxy, tetr R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Acinetobacter nosocomialis aminopenicillins, amcl, czol, cfot, cftr, aztr, erta, trim, fosf, doxy, tetr R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Acinetobacter calcoaceticus aminopenicillins, amcl, czol, cfot, cftr, aztr, erta, trim, fosf, doxy, tetr R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Achromobacter xylosoxidans aminopenicillins, czol, cfot, cftr, erta R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -fullname like ^Burkholderia (cepacia|multivorans|cenocepacia|stabilis|vietnamiensis|dolosa|ambifaria|anthina|pyrrocinia|ubonensis) aminopenicillins, amcl, tica, pipe, pita, czol, cfot, cftr, aztr, erta, cipr, chlo, aminoglycosides, trim, fosf, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Elizabethkingia meningoseptica aminopenicillins, amcl, tica, czol, cfot, cftr, cfta, cfep, aztr, erta, imip, mero, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Ochrobactrum anthropi aminopenicillins, amcl, tica, pipe, pita, czol, cfot, cftr, cfta, cfep, aztr, erta R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Pseudomonas aeruginosa aminopenicillins, amcl, czol, cfot, cftr, erta, chlo, kana, neom, trim, trsu, tetracyclines, tige R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus_species is Stenotrophomonas maltophilia aminopenicillins, amcl, tica, pipe, pita, czol, cfot, cftr, cfta, aztr, erta, imip, mero, aminoglycosides, trim, fosf, tetr R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules -genus one_of Haemophilus, Moraxella, Neisseria, Campylobacter glycopeptides, linc, dapt, line R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -genus_species is Haemophilus influenzae fusi, streptogramins R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -genus_species is Moraxella catarrhalis trim R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -genus is Neisseria trim R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -genus_species is Campylobacter fetus fusi, streptogramins, trim, nali R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -genus_species is Campylobacter jejuni fusi, streptogramins, trim R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -genus_species is Campylobacter coli fusi, streptogramins, trim R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules -gramstain is Gram positive aztr, polymyxins, nali R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus saprophyticus fusi, cfta, fosf, novo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus cohnii cfta, novo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus xylosus cfta, novo R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus capitis cfta, fosf R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus aureus cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus epidermidis cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus coagulase-negative cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus hominis cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus haemolyticus cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus intermedius cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Staphylococcus pseudintermedius cfta R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus is Streptococcus fusi, cfta, aminoglycosides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Enterococcus faecalis fusi, cfta, cephalosporins_without_cfta, aminoglycosides, macrolides, clin, qida, trim, trsu R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Enterococcus gallinarum fusi, cfta, cephalosporins_without_cfta, aminoglycosides, macrolides, clin, qida, vanc, trim, trsu R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Enterococcus casseliflavus fusi, cfta, cephalosporins_without_cfta, aminoglycosides, macrolides, clin, qida, vanc, trim, trsu R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Enterococcus faecium fusi, cfta, cephalosporins_without_cfta, aminoglycosides, macrolides, trim, trsu R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus is Corynebacterium fosf R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +order is Enterobacteriales AMP S AMX S Enterobacteriales (Order) Breakpoints +order is Enterobacteriales AMP I AMX I Enterobacteriales (Order) Breakpoints +order is Enterobacteriales AMP R AMX R Enterobacteriales (Order) Breakpoints +genus is Staphylococcus PEN, FOX S AMP, AMX, PIP, TIC S Staphylococcus Breakpoints +genus is Staphylococcus PEN, FOX R, S OXA, FLC S Staphylococcus Breakpoints +genus is Staphylococcus FOX R all_betalactams R Staphylococcus Breakpoints +genus_species is Staphylococcus saprophyticus AMP S AMX, AMC, PIP, TZP S Staphylococcus Breakpoints +genus is Staphylococcus FOX S carbapenems, cephalosporins_without_CAZ S Staphylococcus Breakpoints +genus is Staphylococcus FOX I carbapenems, cephalosporins_without_CAZ I Staphylococcus Breakpoints +genus is Staphylococcus FOX R carbapenems, cephalosporins_without_CAZ R Staphylococcus Breakpoints +genus is Staphylococcus NOR S CIP, LVX, MFX, OFX S Staphylococcus Breakpoints +genus is Staphylococcus ERY S AZM, CLR, RXT S Staphylococcus Breakpoints +genus is Staphylococcus ERY I AZM, CLR, RXT I Staphylococcus Breakpoints +genus is Staphylococcus ERY R AZM, CLR, RXT R Staphylococcus Breakpoints +genus is Staphylococcus TCY S DOX, MNO S Staphylococcus Breakpoints +genus_species is Enterococcus faecium AMP R all_betalactams R Enterococcus Breakpoints +genus is Enterococcus AMP S AMX, AMC, PIP, TZP S Enterococcus Breakpoints +genus is Enterococcus AMP I AMX, AMC, PIP, TZP I Enterococcus Breakpoints +genus is Enterococcus AMP R AMX, AMC, PIP, TZP R Enterococcus Breakpoints +genus is Enterococcus NOR S CIP, LVX S Enterococcus Breakpoints +genus is Enterococcus NOR I CIP, LVX I Enterococcus Breakpoints +genus is Enterococcus NOR R CIP, LVX R Enterococcus Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ PEN S aminopenicillins, ureidopenicillins, cephalosporins_without_CAZ, carbapenems, FLC, AMC S Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ PEN I aminopenicillins, ureidopenicillins, cephalosporins_without_CAZ, carbapenems, FLC, AMC I Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ PEN R aminopenicillins, ureidopenicillins, cephalosporins_without_CAZ, carbapenems, FLC, AMC R Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ NOR S LVX, MFX S Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ ERY S AZM, CLR, RXT S Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ ERY I AZM, CLR, RXT I Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ ERY R AZM, CLR, RXT R Streptococcus groups A, B, C, G Breakpoints +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G)$ TCY S DOX, MNO S Streptococcus groups A, B, C, G Breakpoints +genus_species is Streptococcus pneumoniae PEN S AMP, AMX, AMC, PIP, TZP S Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae AMP S AMX, AMC, PIP, TZP S Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae AMP I AMX, AMC, PIP, TZP I Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae AMP R AMX, AMC, PIP, TZP R Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae NOR S LVX, MFX S Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae ERY S AZM, CLR, RXT S Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae ERY I AZM, CLR, RXT I Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae ERY R AZM, CLR, RXT R Streptococcus pneumoniae Breakpoints +genus_species is Streptococcus pneumoniae TCY S DOX, MNO S Streptococcus pneumoniae Breakpoints +genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ PEN S AMP, AMX, AMC, PIP, TZP S Viridans group streptococci Breakpoints +genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ AMP S AMX, AMC, PIP, TZP S Viridans group streptococci Breakpoints +genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ AMP I AMX, AMC, PIP, TZP I Viridans group streptococci Breakpoints +genus_species like ^Streptococcus (australis|bovis|constellatus|cristatus|gallolyticus|gordonii|infantarius|infantis|mitis|mutans|oligofermentans|oralis|peroris|pseudopneumoniae|salivarius|sinensis|sobrinus|thermophilus|vestibularis|anginosus|equinus|intermedius|parasanguinis|sanguinis)$ AMP R AMX, AMC, PIP, TZP R Viridans group streptococci Breakpoints +genus_species is Haemophilus influenzae AMP S AMX, PIP S Haemophilus influenzae Breakpoints +genus_species is ^Haemophilus influenzae AMP I AMX, PIP I Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae AMP R AMX, PIP R Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae PEN S AMP, AMX, AMC, PIP, TZP S Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae AMC S TZP S Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae AMC I TZP I Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae AMC R TZP R Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae NAL S CIP, LVX, MFX, OFX S Haemophilus influenzae Breakpoints +genus_species is Haemophilus influenzae TCY S DOX, MNO S Haemophilus influenzae Breakpoints +genus_species is Moraxella catarrhalis AMC S TZP S Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis AMC I TZP I Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis AMC R TZP R Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis NAL S CIP, LVX, MFX, OFX S Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis ERY S AZM, CLR, RXT S Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis ERY I AZM, CLR, RXT I Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis ERY R AZM, CLR, RXT R Moraxella catarrhalis Breakpoints +genus_species is Moraxella catarrhalis TCY S DOX, MNO S Moraxella catarrhalis Breakpoints +genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus, Propionibacterium PEN S AMP, AMX, PIP, TZP, TIC S Anaerobic Gram positives Breakpoints +genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus, Propionibacterium PEN I AMP, AMX, PIP, TZP, TIC I Anaerobic Gram positives Breakpoints +genus one_of Actinomyces, Bifidobacterium, Clostridium, Cutibacterium, Eggerthella, Eubacterium, Lactobacillus, Propionibacterium PEN R AMP, AMX, PIP, TZP, TIC R Anaerobic Gram positives Breakpoints +genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella PEN S AMP, AMX, PIP, TZP, TIC S Anaerobic Gram negatives Breakpoints +genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella PEN I AMP, AMX, PIP, TZP, TIC I Anaerobic Gram negatives Breakpoints +genus one_of Bacteroides, Bilophila , Fusobacterium, Mobiluncus, Porphyromonas, Prevotella PEN R AMP, AMX, PIP, TZP, TIC R Anaerobic Gram negatives Breakpoints +genus_species is Pasteurella multocida PEN S AMP, AMX S Pasteurella multocida Breakpoints +genus_species is Pasteurella multocida PEN I AMP, AMX I Pasteurella multocida Breakpoints +genus_species is Pasteurella multocida PEN R AMP, AMX R Pasteurella multocida Breakpoints +genus_species is Campylobacter coli ERY S AZM, CLR S Campylobacter coli Breakpoints +genus_species is Campylobacter coli ERY I AZM, CLR I Campylobacter coli Breakpoints +genus_species is Campylobacter coli ERY R AZM, CLR R Campylobacter coli Breakpoints +genus_species is Campylobacter coli TCY S DOX S Campylobacter coli Breakpoints +genus_species is Campylobacter coli TCY I DOX I Campylobacter coli Breakpoints +genus_species is Campylobacter coli TCY R DOX R Campylobacter coli Breakpoints +genus_species is Campylobacter jejuni ERY S AZM, CLR S Campylobacter jejuni Breakpoints +genus_species is Campylobacter jejuni ERY I AZM, CLR I Campylobacter jejuni Breakpoints +genus_species is Campylobacter jejuni ERY R AZM, CLR R Campylobacter jejuni Breakpoints +genus_species is Campylobacter jejuni TCY S DOX S Campylobacter jejuni Breakpoints +genus_species is Campylobacter jejuni TCY I DOX I Campylobacter jejuni Breakpoints +genus_species is Campylobacter jejuni TCY R DOX R Campylobacter jejuni Breakpoints +genus_species is Aerococcus sanguinicola NOR S fluoroquinolones S Aerococcus sanguinicola Breakpoints +genus_species is Aerococcus sanguinicola NOR I fluoroquinolones I Aerococcus sanguinicola Breakpoints +genus_species is Aerococcus sanguinicola NOR R fluoroquinolones R Aerococcus sanguinicola Breakpoints +genus_species is Aerococcus sanguinicola CIP S LVX S Aerococcus sanguinicola Breakpoints +genus_species is Aerococcus sanguinicola CIP I LVX I Aerococcus sanguinicola Breakpoints +genus_species is Aerococcus sanguinicola CIP R LVX R Aerococcus urinae Breakpoints +genus_species is Aerococcus urinae NOR S fluoroquinolones S Aerococcus urinae Breakpoints +genus_species is Aerococcus urinae NOR I fluoroquinolones I Aerococcus urinae Breakpoints +genus_species is Aerococcus urinae NOR R fluoroquinolones R Aerococcus urinae Breakpoints +genus_species is Aerococcus urinae CIP S LVX S Aerococcus urinae Breakpoints +genus_species is Aerococcus urinae CIP I LVX I Aerococcus urinae Breakpoints +genus_species is Aerococcus urinae CIP R LVX R Aerococcus urinae Breakpoints +genus_species is Kingella kingae PEN S AMP, AMX S Kingella kingae Breakpoints +genus_species is Kingella kingae PEN I AMP, AMX I Kingella kingae Breakpoints +genus_species is Kingella kingae PEN R AMP, AMX R Kingella kingae Breakpoints +genus_species is Kingella kingae ERY S AZM, CLR S Kingella kingae Breakpoints +genus_species is Kingella kingae ERY I AZM, CLR I Kingella kingae Breakpoints +genus_species is Kingella kingae ERY R AZM, CLR R Kingella kingae Breakpoints +genus_species is Kingella kingae TCY S DOX S Kingella kingae Breakpoints +family is Enterobacteriaceae PEN, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +fullname like ^Citrobacter (koseri|amalonaticus|sedlakii|farmeri|rodentium) aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +fullname like ^Citrobacter (freundii|braakii|murliniae|werkmanii|youngae) aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Enterobacter cloacae aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Enterobacter aerogenes aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Escherichia hermanni aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Hafnia alvei aminopenicillins, AMC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus is Klebsiella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Morganella morganii aminopenicillins, AMC, CZO, tetracyclines, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Proteus mirabilis tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Proteus penneri aminopenicillins, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Proteus vulgaris aminopenicillins, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Providencia rettgeri aminopenicillins, AMC, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Providencia stuartii aminopenicillins, AMC, CZO, CXM, tetracyclines, TGC, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus is Raoultella aminopenicillins, TIC R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Serratia marcescens aminopenicillins, AMC, CZO, FOX, CXM, DOX, TCY, polymyxins, NIT R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Yersinia enterocolitica aminopenicillins, AMC, TIC, CZO, FOX R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus_species is Yersinia pseudotuberculosis poly, COL R Table 01: Intrinsic resistance in Enterobacteriaceae Expert Rules +genus one_of Achromobacter, Acinetobacter, Alcaligenes, Bordatella, Burkholderia, Elizabethkingia, Flavobacterium, Ochrobactrum, Pseudomonas, Stenotrophomonas PEN, FOX, CXM, glycopeptides, FUS, macrolides, LIN, streptogramins, RIF, DAP, LNZ R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Acinetobacter baumannii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Acinetobacter pittii aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Acinetobacter nosocomialis aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Acinetobacter calcoaceticus aminopenicillins, AMC, CZO, CTX, CRO, ATM, ETP, TMP, FOS, DOX, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Achromobacter xylosoxidans aminopenicillins, CZO, CTX, CRO, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +fullname like ^Burkholderia (cepacia|multivorans|cenocepacia|stabilis|vietnamiensis|dolosa|ambifaria|anthina|pyrrocinia|ubonensis) aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, ATM, ETP, CIP, CHL, aminoglycosides, TMP, FOS, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Elizabethkingia meningoseptica aminopenicillins, AMC, TIC, CZO, CTX, CRO, CAZ, FEP, ATM, ETP, IPM, MEM, polymyxins R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Ochrobactrum anthropi aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, CAZ, FEP, ATM, ETP R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Pseudomonas aeruginosa aminopenicillins, AMC, CZO, CTX, CRO, ETP, CHL, KAN, NEO, TMP, SXT, tetracyclines, TGC R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus_species is Stenotrophomonas maltophilia aminopenicillins, AMC, TIC, PIP, TZP, CZO, CTX, CRO, CAZ, ATM, ETP, IPM, MEM, aminoglycosides, TMP, FOS, TCY R Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria Expert Rules +genus one_of Haemophilus, Moraxella, Neisseria, Campylobacter glycopeptides, LIN, DAP, LNZ R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +genus_species is Haemophilus influenzae FUS, streptogramins R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +genus_species is Moraxella catarrhalis TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +genus is Neisseria TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +genus_species is Campylobacter fetus FUS, streptogramins, TMP, NAL R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +genus_species is Campylobacter jejuni FUS, streptogramins, TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +genus_species is Campylobacter coli FUS, streptogramins, TMP R Table 03: Intrinsic resistance in other Gram-negative bacteria Expert Rules +gramstain is Gram positive ATM, polymyxins, NAL R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus saprophyticus FUS, CAZ, FOS, NOV R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus cohnii CAZ, NOV R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus xylosus CAZ, NOV R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus capitis CAZ, FOS R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus aureus CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus epidermidis CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus coagulase-negative CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus hominis CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus haemolyticus CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus intermedius CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Staphylococcus pseudintermedius CAZ R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus is Streptococcus FUS, CAZ, aminoglycosides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Enterococcus faecalis FUS, CAZ, cephalosporins_without_CAZ, aminoglycosides, macrolides, CLI, QDA, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Enterococcus gallinarum FUS, CAZ, cephalosporins_without_CAZ, aminoglycosides, macrolides, CLI, QDA, VAN, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Enterococcus casseliflavus FUS, CAZ, cephalosporins_without_CAZ, aminoglycosides, macrolides, CLI, QDA, VAN, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Enterococcus faecium FUS, CAZ, cephalosporins_without_CAZ, aminoglycosides, macrolides, TMP, SXT R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus is Corynebacterium FOS R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules genus_species is Listeria monocytogenes cephalosporins R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules genus is Leuconostoc, Pediococcus glycopeptides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules genus is Lactobacillus glycopeptides R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Clostridium ramosum vanc R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species is Clostridium innocuum vanc R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules -genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G) peni S aminopenicillins, cephalosporins, carbapenems S Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules -genus is Enterococcus ampi R ureidopenicillins, carbapenems R Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules -genus is Enterococcus amox R ureidopenicillins, carbapenems R Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules -family is Enterobacteriaceae tica, pipe R, S pipe R Table 09: Interpretive rules for B-lactam agents and Gram-negative rods Expert Rules -genus is .* eryt S azit, clar S Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules -genus is .* eryt I azit, clar I Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules -genus is .* eryt R azit, clar R Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules -genus is Staphylococcus tobr R kana, amik R Table 12: Interpretive rules for aminoglycosides Expert Rules -genus is Staphylococcus gent R aminoglycosides R Table 12: Interpretive rules for aminoglycosides Expert Rules -family is Enterobacteriaceae gent, tobr I, S gent R Table 12: Interpretive rules for aminoglycosides Expert Rules -family is Enterobacteriaceae gent, tobr R, I tobr R Table 12: Interpretive rules for aminoglycosides Expert Rules -genus is Staphylococcus moxi R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules -genus_species is Streptococcus pneumoniae moxi R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules -family is Enterobacteriaceae cipr R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules -genus_species is Neisseria gonorrhoeae cipr R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules -genus is .* amcl R ampi, amox R Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R Other rules -genus is .* pita R pipe R Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R Other rules -genus is .* trsu R trim R Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R Other rules -genus is .* ampi S amcl S Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S Other rules -genus is .* amox S amcl S Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S Other rules -genus is .* pipe S pita S Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S Other rules -genus is .* trim S trsu S Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S Other rules +genus_species is Clostridium ramosum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species is Clostridium innocuum VAN R Table 04: Intrinsic resistance in Gram-positive bacteria Expert Rules +genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G) PEN S aminopenicillins, cephalosporins_without_CAZ, carbapenems S Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules +genus is Enterococcus AMP R ureidopenicillins, carbapenems R Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules +genus is Enterococcus AMX R ureidopenicillins, carbapenems R Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules +family is Enterobacteriaceae TIC, PIP R, S PIP R Table 09: Interpretive rules for B-lactam agents and Gram-negative rods Expert Rules +genus is .* ERY S AZM, CLR S Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules +genus is .* ERY I AZM, CLR I Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules +genus is .* ERY R AZM, CLR R Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules +genus is Staphylococcus TOB R KAN, amik R Table 12: Interpretive rules for aminoglycosides Expert Rules +genus is Staphylococcus GEN R aminoglycosides R Table 12: Interpretive rules for aminoglycosides Expert Rules +family is Enterobacteriaceae GEN, TOB I, S GEN R Table 12: Interpretive rules for aminoglycosides Expert Rules +family is Enterobacteriaceae GEN, TOB R, I TOB R Table 12: Interpretive rules for aminoglycosides Expert Rules +genus is Staphylococcus MFX R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules +genus_species is Streptococcus pneumoniae MFX R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules +family is Enterobacteriaceae CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules +genus_species is Neisseria gonorrhoeae CIP R fluoroquinolones R Table 13: Interpretive rules for quinolones Expert Rules +genus is .* AMC R AMP, AMX R Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R Other rules +genus is .* TZP R PIP R Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R Other rules +genus is .* SXT R TMP R Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R Other rules +genus is .* AMP S AMC S Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S Other rules +genus is .* AMX S AMC S Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S Other rules +genus is .* PIP S TZP S Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S Other rules +genus is .* TMP S SXT S Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S Other rules diff --git a/inst/rstudio/addins.dcf b/inst/rstudio/addins.dcf index a87253d28..d43c060a3 100644 --- a/inst/rstudio/addins.dcf +++ b/inst/rstudio/addins.dcf @@ -1,24 +1,3 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Analysis # -# # -# SOURCE # -# https://gitlab.com/msberends/AMR # -# # -# LICENCE # -# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# # -# This R package was created for academic research and was publicly # -# released in the hope that it will be useful, but it comes WITHOUT # -# ANY WARRANTY OR LIABILITY. # -# Visit our website for more info: https://msberends.gitlab.io/AMR. # -# ==================================================================== # - Name: Insert %in% Binding: addin_insert_in Interactive: false diff --git a/inst/translations.tsv b/inst/translations.tsv new file mode 100644 index 000000000..58870c3b0 --- /dev/null +++ b/inst/translations.tsv @@ -0,0 +1,456 @@ +lang pattern replacement fixed ignore.case +de Coagulase-negative Staphylococcus Koagulase-negative Staphylococcus FALSE FALSE +de Coagulase-positive Staphylococcus Koagulase-positive Staphylococcus FALSE FALSE +de Beta-haemolytic Streptococcus Beta-hämolytischer Streptococcus FALSE FALSE +de unknown Gram negatives unbekannte Gramnegativen FALSE FALSE +de unknown Gram positives unbekannte Grampositiven FALSE FALSE +de unknown name unbekannte Name FALSE FALSE +de unknown kingdom unbekanntes Reich FALSE FALSE +de unknown phylum unbekannter Stamm FALSE FALSE +de unknown class unbekannte Klasse FALSE FALSE +de unknown order unbekannte Ordnung FALSE FALSE +de unknown family unbekannte Familie FALSE FALSE +de unknown genus unbekannte Gattung FALSE FALSE +de unknown species unbekannte Art FALSE FALSE +de unknown subspecies unbekannte Unterart FALSE FALSE +de unknown rank unbekannter Rang FALSE FALSE +de (CoNS) (KNS) TRUE FALSE +de (CoPS) (KPS) TRUE FALSE +de Gram negative Gramnegativ FALSE FALSE +de Gram positive Grampositiv FALSE FALSE +de Bacteria Bakterien FALSE FALSE +de Fungi Hefen/Pilze FALSE FALSE +de Protozoa Protozoen FALSE FALSE +de biogroup Biogruppe FALSE FALSE +de biotype Biotyp FALSE FALSE +de vegetative vegetativ FALSE FALSE +de ([([ ]*?)group \\1Gruppe FALSE FALSE +de ([([ ]*?)Group \\1Gruppe FALSE FALSE +nl Coagulase-negative Staphylococcus Coagulase-negatieve Staphylococcus FALSE FALSE +nl Coagulase-positive Staphylococcus Coagulase-positieve Staphylococcus FALSE FALSE +nl Beta-haemolytic Streptococcus Beta-hemolytische Streptococcus FALSE FALSE +nl unknown Gram negatives onbekende Gram-negatieven FALSE FALSE +nl unknown Gram positives onbekende Gram-positieven FALSE FALSE +nl unknown name onbekende naam FALSE FALSE +nl unknown kingdom onbekend koninkrijk FALSE FALSE +nl unknown phylum onbekend fylum FALSE FALSE +nl unknown class onbekende klasse FALSE FALSE +nl unknown order onbekende orde FALSE FALSE +nl unknown family onbekende familie FALSE FALSE +nl unknown genus onbekend geslacht FALSE FALSE +nl unknown species onbekende soort FALSE FALSE +nl unknown subspecies onbekende ondersoort FALSE FALSE +nl unknown rank onbekende rang FALSE FALSE +nl (CoNS) (CNS) TRUE FALSE +nl (CoPS) (CPS) TRUE FALSE +nl Gram negative Gram-negatief FALSE FALSE +nl Gram positive Gram-positief FALSE FALSE +nl Bacteria Bacteriën FALSE FALSE +nl Fungi Schimmels/gisten FALSE FALSE +nl Protozoa protozoën FALSE FALSE +nl biogroup biogroep FALSE FALSE +nl vegetative vegetatief FALSE FALSE +nl ([([ ]*?)group \\1groep FALSE FALSE +nl ([([ ]*?)Group \\1Groep FALSE FALSE +es Coagulase-negative Staphylococcus Staphylococcus coagulasa negativo FALSE FALSE +es Coagulase-positive Staphylococcus Staphylococcus coagulasa positivo FALSE FALSE +es Beta-haemolytic Streptococcus Streptococcus Beta-hemolítico FALSE FALSE +es unknown Gram negatives Gram negativos desconocidos FALSE FALSE +es unknown Gram positives Gram positivos desconocidos FALSE FALSE +es unknown name nombre desconocido FALSE FALSE +es unknown kingdom reino desconocido FALSE FALSE +es unknown phylum filo desconocido FALSE FALSE +es unknown class clase desconocida FALSE FALSE +es unknown order orden desconocido FALSE FALSE +es unknown family familia desconocida FALSE FALSE +es unknown genus género desconocido FALSE FALSE +es unknown species especie desconocida FALSE FALSE +es unknown subspecies subespecie desconocida FALSE FALSE +es unknown rank rango desconocido FALSE FALSE +es (CoNS) (SCN) TRUE FALSE +es (CoPS) (SCP) TRUE FALSE +es Gram negative Gram negativo FALSE FALSE +es Gram positive Gram positivo FALSE FALSE +es Bacteria Bacterias FALSE FALSE +es Fungi Hongos FALSE FALSE +es Protozoa Protozoarios FALSE FALSE +es biogroup biogrupo FALSE FALSE +es biotype biotipo FALSE FALSE +es vegetative vegetativo FALSE FALSE +es ([([ ]*?)group \\1grupo FALSE FALSE +es ([([ ]*?)Group \\1Grupo FALSE FALSE +it Coagulase-negative Staphylococcus Staphylococcus negativo coagulasi FALSE FALSE +it Coagulase-positive Staphylococcus Staphylococcus positivo coagulasi FALSE FALSE +it Beta-haemolytic Streptococcus Streptococcus Beta-emolitico FALSE FALSE +it unknown Gram negatives Gram negativi sconosciuti FALSE FALSE +it unknown Gram positives Gram positivi sconosciuti FALSE FALSE +it unknown name nome sconosciuto FALSE FALSE +it unknown kingdom regno sconosciuto FALSE FALSE +it unknown phylum phylum sconosciuto FALSE FALSE +it unknown class classe sconosciuta FALSE FALSE +it unknown order ordine sconosciuto FALSE FALSE +it unknown family famiglia sconosciuta FALSE FALSE +it unknown genus genere sconosciuto FALSE FALSE +it unknown species specie sconosciute FALSE FALSE +it unknown subspecies sottospecie sconosciute FALSE FALSE +it unknown rank grado sconosciuto FALSE FALSE +it Gram negative Gram negativo FALSE FALSE +it Gram positive Gram positivo FALSE FALSE +it Bacteria Batteri FALSE FALSE +it Fungi Fungo FALSE FALSE +it Protozoa Protozoi FALSE FALSE +it biogroup biogruppo FALSE FALSE +it biotype biotipo FALSE FALSE +it vegetative vegetativo FALSE FALSE +it ([([ ]*?)group \\1gruppo FALSE FALSE +it ([([ ]*?)Group \\1Gruppo FALSE FALSE +fr Coagulase-negative Staphylococcus Staphylococcus à coagulase négative FALSE FALSE +fr Coagulase-positive Staphylococcus Staphylococcus à coagulase positif FALSE FALSE +fr Beta-haemolytic Streptococcus Streptococcus Bêta-hémolytique FALSE FALSE +fr unknown Gram negatives Gram négatifs inconnus FALSE FALSE +fr unknown Gram positives Gram positifs inconnus FALSE FALSE +fr unknown name nom inconnu FALSE FALSE +fr unknown kingdom règme inconnu FALSE FALSE +fr unknown phylum embranchement inconnu FALSE FALSE +fr unknown class classe inconnue FALSE FALSE +fr unknown order ordre inconnu FALSE FALSE +fr unknown family famille inconnue FALSE FALSE +fr unknown genus genre inconnu FALSE FALSE +fr unknown species espèce inconnue FALSE FALSE +fr unknown subspecies sous-espèce inconnue FALSE FALSE +fr unknown rank rang inconnu FALSE FALSE +fr Gram negative Gram négatif FALSE FALSE +fr Gram positive Gram positif FALSE FALSE +fr Bacteria Bactéries FALSE FALSE +fr Fungi Champignons FALSE FALSE +fr Protozoa Protozoaires FALSE FALSE +fr biogroup biogroupe FALSE FALSE +fr vegetative végétatif FALSE FALSE +fr ([([ ]*?)group \\1groupe FALSE FALSE +fr ([([ ]*?)Group \\1Groupe FALSE FALSE +pt Coagulase-negative Staphylococcus Staphylococcus coagulase negativo FALSE FALSE +pt Coagulase-positive Staphylococcus Staphylococcus coagulase positivo FALSE FALSE +pt Beta-haemolytic Streptococcus Streptococcus Beta-hemolítico FALSE FALSE +pt unknown Gram negatives Gram negativos desconhecidos FALSE FALSE +pt unknown Gram positives Gram positivos desconhecidos FALSE FALSE +pt unknown name nome desconhecido FALSE FALSE +pt unknown kingdom reino desconhecido FALSE FALSE +pt unknown phylum filo desconhecido FALSE FALSE +pt unknown class classe desconhecida FALSE FALSE +pt unknown order ordem desconhecido FALSE FALSE +pt unknown family família desconhecida FALSE FALSE +pt unknown genus gênero desconhecido FALSE FALSE +pt unknown species espécies desconhecida FALSE FALSE +pt unknown subspecies subespécies desconhecida FALSE FALSE +pt unknown rank classificação desconhecido FALSE FALSE +pt Gram negative Gram negativo FALSE FALSE +pt Gram positive Gram positivo FALSE FALSE +pt Bacteria Bactérias FALSE FALSE +pt Fungi Fungos FALSE FALSE +pt Protozoa Protozoários FALSE FALSE +pt biogroup biogrupo FALSE FALSE +pt biotype biótipo FALSE FALSE +pt vegetative vegetativo FALSE FALSE +pt ([([ ]*?)group \\1grupo FALSE FALSE +pt ([([ ]*?)Group \\1Grupo FALSE FALSE + +nl 4-aminosalicylic acid aminosalicylzuur +nl adefovir dipivoxil adefovir +nl aldesulfone sodium aldesulfon +nl amikacin amikacine +nl amoxicillin amoxicilline +nl amoxicillin and beta-lactamase inhibitor amoxicilline met enzymremmer +nl amphotericin B amfotericine B +nl ampicillin ampicilline +nl ampicillin and beta-lactamase inhibitor ampicilline met enzymremmer +nl ampicillin, combinations ampicilline, combinatiepreparaten +nl anidulafungin anidulafungine +nl anthrax antigen anthrax-antigeen +nl anti-d (rh) immunoglobulin rhesus(d)immunoglobuline +nl azidocillin azidocilline +nl azithromycin azitromycine +nl azlocillin azlocilline +nl bacampicillin bacampicilline +nl bacitracin bacitracine +nl benzathine benzylpenicillin benzylpenicillinebenzathine +nl benzathine phenoxymethylpenicillin fenoxymethylpenicillinebenzathine +nl benzylpenicillin benzylpenicilline +nl botulinum antitoxin serum tegen botulisme +nl brucella antigen brucella-antigeen +nl calcium aminosalicylate aminosalicylzuur +nl capreomycin capreomycine +nl carbenicillin carbenicilline +nl carindacillin carindacilline +nl caspofungin caspofungine +nl cefacetrile cefacetril +nl cefalexin cefalexine +nl cefalotin cefalotine +nl cefamandole cefamandol +nl cefapirin cefapirine +nl cefazedone cefazedon +nl cefazolin cefazoline +nl cefepime cefepim +nl cefixime cefixim +nl cefmenoxime cefmenoxim +nl cefmetazole cefmetazol +nl cefodizime cefodizim +nl cefonicid cefonicide +nl cefoperazone cefoperazon +nl cefoperazone and beta-lactamase inhibitor cefoperazon combinatiepreparaten +nl cefotaxime cefotaxim +nl cefoxitin cefoxitine +nl cefpirome cefpirom +nl cefpodoxime cefpodoxim +nl cefsulodin cefsulodine +nl ceftazidime ceftazidim +nl ceftezole ceftezol +nl ceftizoxime ceftizoxim +nl ceftriaxone ceftriaxon +nl ceftriaxone, combinations ceftriaxon, combinatiepreparaten +nl cefuroxime cefuroxim +nl cefuroxime and metronidazole cefuroxim met andere antibacteriele middelen +nl chloramphenicol chlooramfenicol +nl chlortetracycline chloortetracycline +nl cholera, combinations with typhoid vaccine, inactivated, whole cell choleravaccin met tyfusvaccin, geinactiveerd, hele cel +nl cholera, inactivated, whole cell cholera, geinactiveerd, hele cel +nl cholera, live attenuated cholera, levend verzwakt +nl cinoxacin cinoxacine +nl ciprofloxacin ciprofloxacine +nl clarithromycin claritromycine +nl clavulanic acid clavulaanzuur +nl clindamycin clindamycine +nl clometocillin clometocilline +nl clotrimazole clotrimazol +nl cloxacillin cloxacilline +nl colistin colistine +nl combinations combinatiepreparaten +nl combinations combinatiepreparaten +nl combinations combinatiepreparaten +nl combinations combinatiepreparaten +nl combinations combinatiepreparaten +nl combinations combinatiepreparaten +nl combinations combinatiepreparaten +nl combinations of penicillins combinatiepreparaten +nl combinations of tetracyclines tetracycline combinatiepreparaten +nl cytomegalovirus immunoglobulin cytomegalie-immunoglobuline +nl dapsone dapson +nl daptomycin daptomycine +nl dibekacin dibekacine +nl dicloxacillin dicloxacilline +nl diphtheria antitoxin serum tegen difterie +nl diphtheria immunoglobulin difterie-immunoglobuline +nl diphtheria toxoid difterietoxoide +nl diphtheria-hemophilus influenzae b-pertussis-poliomyelitis-tetanus difterie-haemophilus-kinkhoest-poliomyelitis-tetanus +nl diphtheria-hemophilus influenzae b-pertussis-poliomyelitis-tetanus-hepatitis B difterie-haemophilus-kinkhoest-polio-tetanus-hepatitis B +nl diphtheria-hemophilus influenzae b-pertussis-tetanus-hepatitis B difterie-haemophilus-kinkhoest-tetanus-hepatitis B +nl diphtheria-hepatitis b-pertussis-tetanus difterie-hepatitis b-kinkhoest-tetanus +nl diphtheria-hepatitis b-tetanus difterie-hepatitis b-tetanus +nl diphtheria-pertussis-poliomyelitis-tetanus difterie-kinkhoest-poliomyelitis-tetanus +nl diphtheria-pertussis-poliomyelitis-tetanus-hepatitis B difterie-kinkhoest-poliomyelitis-tetanus-hepatitis B +nl diphtheria-poliomyelitis-tetanus difterie-poliomyelitis-tetanus +nl diphtheria-rubella-tetanus difterie-rubella-tetanus +nl dirithromycin diritromycine +nl econazole econazol +nl encephalitis, japanese, inactivated, whole virus japanse-encefalitis, geinactiveerd, intact virus +nl encephalitis, tick borne immunoglobulin teken-encephalitis-immunoglobuline +nl encephalitis, tick borne, inactivated, whole virus tekenencefalitis, geinactiveerd, intact virus +nl enoxacin enoxacine +nl epicillin epicilline +nl erythromycin erytromycine +nl ethambutol and isoniazid ethambutol met isoniazide +nl fleroxacin fleroxacine +nl flucloxacillin flucloxacilline +nl fluconazole fluconazol +nl flucytosine fluorocytosine +nl flurithromycin fluritromycine +nl fosfomycin fosfomycine +nl fusidic acid fusidinezuur +nl gas-gangrene sera serum tegen gasgangreen +nl gatifloxacin gatifloxacine +nl gemifloxacin gemifloxacine +nl gentamicin gentamicine +nl grepafloxacin grepafloxacine +nl hachimycin hachimycine +nl hemophilus influenzae B and hepatitis B haemophilus influenzae b-hepatitis B +nl hemophilus influenzae B and poliomyelitis haemophilus influenzae b-poliomyelitis +nl hemophilus influenzae B, combinations with pertussis and toxoids haemophilus influenzae B met kinkhoest en toxoiden +nl hemophilus influenzae B, combinations with toxoids haemophilus influenzae B met toxoiden +nl hemophilus influenzae B, purified antigen conjugated haemophilus influenzae B, gezuiverd geconjugeerd antigeen +nl hepatitis A immunoglobulin hepatitis a-immunoglobuline +nl hepatitis A, inactivated, whole virus hepatitis A, geinactiveerd, intact virus +nl hepatitis B immunoglobulin hepatitis b-immunoglobuline +nl hepatitis B, purified antigen hepatitis B, gezuiverd antigeen +nl hetacillin hetacilline +nl imipenem and cilastatin imipenem met enzymremmer +nl immunoglobulins, normal human, for extravascular adm, immunoglobuline, normaal, extravasculair +nl immunoglobulins, normal human, for intravascular adm, immunoglobuline, normaal, intravasculair +nl influenza, inactivated, split virus or surface antigen influenza, gezuiverd antigeen +nl influenza, inactivated, whole virus influenza, geinactiveerd, intact virus +nl inosine pranobex inosiplex +nl isepamicin isepamicine +nl isoconazole isoconazol +nl isoniazid isoniazide +nl isoniazid, combinations isoniazide, combinatiepreparaten +nl itraconazole itraconazol +nl josamycin josamycine +nl kanamycin kanamycine +nl ketoconazole ketoconazol +nl levofloxacin levofloxacine +nl lincomycin lincomycine +nl lomefloxacin lomefloxacine +nl lysozyme lysozym +nl mandelic acid amandelzuur +nl measles immunoglobulin mazelenimmunoglobuline +nl measles, combinations with mumps and rubella, live attenuated mazelen met bof en rubella, levend verzwakt +nl measles, combinations with mumps, live attenuated mazelen met bof, levend verzwakt +nl measles, combinations with mumps, rubella and varicella, live attenuated mazelen met bof, rubella en varicella, levend verzwakt +nl measles, combinations with rubella, live attenuated mazelen met rubella, levend verzwakt +nl measles, live attenuated mazelen, levend verzwakt +nl meningococcus A, purified polysaccharides antigen meningokok A, gezuiverd polysaccharidenantigeen +nl meningococcus A,c, bivalent purified polysaccharides antigen meningokok, 2 typen, gezuiverd polysaccharidenantigeen +nl meningococcus A,c,y,w-135, tetravalent purified polysaccharides antigen meningokok, 4 typen, gezuiverd polysaccharidenantigeen +nl meningococcus B, outer membrane vesicle vaccine meningokok B, buitenmembraanvaccin +nl meningococcus C, purified polysaccharides antigen conjugated meningokok C, gezuiverd saccharidenantigeen geconjugeerd +nl metampicillin metampicilline +nl meticillin meticilline +nl metisazone metisazon +nl metronidazole metronidazol +nl mezlocillin mezlocilline +nl micafungin micafungine +nl miconazole miconazol +nl midecamycin midecamycine +nl miocamycin miocamycine +nl moxifloxacin moxifloxacine +nl mumps immunoglobulin bofimmunoglobuline +nl mumps, live attenuated bof, levend verzwakt +nl mupirocin mupirocine +nl nalidixic acid nalidixinezuur +nl neomycin neomycine +nl netilmicin netilmicine +nl nitrofurantoin nitrofurantoine +nl norfloxacin norfloxacine +nl novobiocin novobiocine +nl nystatin nystatine +nl ofloxacin ofloxacine +nl oleandomycin oleandomycine +nl ornidazole ornidazol +nl other meningococcal monovalent purified polysaccharides antigen meningokok, 1 type, gezuiverd polysaccaridenantigeen +nl other meningococcal polyvalent purified polysaccharides antigen meningokok, meer typen, gezuiverd polysaccharidenantigeen +nl oxacillin oxacilline +nl oxolinic acid oxolinezuur +nl oxytetracycline, combinations oxytetracycline, combinatiepreparaten +nl pazufloxacin pazufloxacine +nl pefloxacin pefloxacine +nl penamecillin penamecilline +nl penicillins, combinations with other antibacterials penicillines met andere antibacteriele middelen +nl pertussis immunoglobulin kinkhoestimmunoglobuline +nl pertussis, inactivated, whole cell pertussis, geinactiveerd, hele cel +nl pertussis, inactivated, whole cell, combinations with toxoids pertussis, geinactiveerd hele cel, met toxoiden +nl pertussis, purified antigen pertussis, gezuiverd antigeen +nl pertussis, purified antigen, combinations with toxoids pertussis, gezuiverd antigeen, met toxoiden +nl pheneticillin feneticilline +nl phenoxymethylpenicillin fenoxymethylpenicilline +nl pipemidic acid pipemidinezuur +nl piperacillin piperacilline +nl piperacillin and beta-lactamase inhibitor piperacilline met enzymremmer +nl piromidic acid piromidinezuur +nl pivampicillin pivampicilline +nl plague, inactivated, whole cell yersinia pestis, geinactiveerd, hele cel +nl pneumococcus, purified polysaccharides antigen pneumokok, gezuiverd polysaccharidenantigeen +nl pneumococcus, purified polysaccharides antigen conjugated pneumokok, gezuiverd geconjugeerd polysaccharidenantigeen +nl poliomyelitis oral, monovalent, live attenuated poliomyelitis, oraal, 1 type, levend verzwakt +nl poliomyelitis oral, trivalent, live attenuated poliomyelitis, oraal, 3 typen, levend verzwakt +nl poliomyelitis, trivalent, inactivated, whole virus poliomyelitis, 3 typen, geinactiveerd, intact virus +nl polymyxin B polymyxine B +nl posaconazole posaconazol +nl pristinamycin pristinamycine +nl procaine benzylpenicillin benzylpenicillineprocaine +nl propicillin propicilline +nl prulifloxacin prulifloxacine +nl quinupristin/dalfopristin quinupristine/dalfopristine +nl rabies immunoglobulin rabiesimmunoglobuline +nl rabies serum serum tegen rabies +nl rabies, inactivated, whole virus rabies, geinactiveerd, intact virus +nl ribostamycin ribostamycine +nl rifabutin rifabutine +nl rifampicin rifampicine +nl rifampicin and isoniazid rifampicine met isoniazide +nl rifampicin, pyrazinamide and isoniazid rifampicine met pyrazinamide en isoniazide +nl rifampicin, pyrazinamide, ethambutol and isoniazid rifampicine met pyrazinamide, ethambutol en isoniazide +nl rifamycin rifamycine +nl rifaximin rifaximine +nl rokitamycin rokitamycine +nl rosoxacin rosoxacine +nl rota virus, live attenuated rotavirus, levend verzwakt +nl roxithromycin roxitromycine +nl rubella immunoglobulin rubella-immunoglobuline +nl rubella, combinations with mumps, live attenuated rubella met bof, levend verzwakt +nl rubella, live attenuated rubella, levend verzwakt +nl rufloxacin rufloxacine +nl sisomicin sisomicine +nl snake venom antiserum serum tegen slangebeet +nl sodium aminosalicylate aminosalicylzuur,4- (na-zout) +nl sparfloxacin sparfloxacine +nl spectinomycin spectinomycine +nl spiramycin spiramycine +nl spiramycin and metronidazole spiramycine met andere antibacteriele middelen +nl staphylococcus immunoglobulin stafylokokkenimmunoglobuline +nl streptoduocin streptoduocine +nl streptomycin streptomycine +nl streptomycin and isoniazid streptomycine met isoniazide +nl sulbenicillin sulbenicilline +nl sulfadiazine and tetroxoprim sulfadiazine met tetroxoprim +nl sulfadiazine and trimethoprim sulfadiazine met trimethoprim +nl sulfadimidine and trimethoprim sulfadimidine met trimethoprim +nl sulfafurazole sulfafurazol +nl sulfaisodimidine sulfisomidine +nl sulfalene sulfaleen +nl sulfamazone sulfamazon +nl sulfamerazine and trimethoprim sulfamerazine met trimethoprim +nl sulfamethizole sulfamethizol +nl sulfamethoxazole sulfamethoxazol +nl sulfamethoxazole and trimethoprim sulfamethoxazol met trimethoprim +nl sulfametoxydiazine sulfamethoxydiazine +nl sulfametrole and trimethoprim sulfametrol met trimethoprim +nl sulfamoxole sulfamoxol +nl sulfamoxole and trimethoprim sulfamoxol met trimethoprim +nl sulfaperin sulfaperine +nl sulfaphenazole sulfafenazol +nl sulfathiazole sulfathiazol +nl sulfathiourea sulfathioureum +nl sulfonamides, combinations with other antibacterials (excl, trimethoprim) sulfonamiden met andere antibacteriele middelen (exc trim) +nl sultamicillin sultamicilline +nl talampicillin talampicilline +nl teicoplanin teicoplanine +nl telithromycin telitromycine +nl temafloxacin temafloxacine +nl temocillin temocilline +nl tenofovir disoproxil tenofovir +nl terizidone terizidon +nl tetanus antitoxin serum tegen tetanus +nl tetanus immunoglobulin tetanusimmunoglobuline +nl tetanus toxoid tetanustoxoide +nl tetanus toxoid, combinations with diphtheria toxoid tetanustoxoide met difterietoxoide +nl tetanus toxoid, combinations with tetanus immunoglobulin tetanustoxoide met tetanusimmunoglobuline +nl thiamphenicol thiamfenicol +nl thiamphenicol, combinations thiamfenicol combinatiepreparaten +nl thioacetazone and isoniazid thioacetazon met isoniazide +nl ticarcillin ticarcilline +nl ticarcillin and beta-lactamase inhibitor ticarcilline met enzymremmer +nl tinidazole tinidazol +nl tobramycin tobramycine +nl troleandomycin troleandomycine +nl trovafloxacin trovafloxacine +nl tuberculosis, live attenuated bacillus calmette guerin, levend verzwakt +nl typhoid, combinations with paratyphi types buiktyfus met paratyfus-typen +nl typhoid, inactivated, whole cell buiktyfus, geinactiveerd, hele cel +nl typhoid, oral, live attenuated buiktyfus, oraal, levend verzwakt +nl typhoid, purified polysaccharide antigen buiktyfus, gezuiverd polysaccharidenantigeen +nl typhoid-hepatitis A buiktyfus-hepatitis A +nl typhus exanthematicus, inactivated, whole cell vlektyfus, geinactiveerd, hele cel +nl vaccinia immunoglobulin vaccinia-immunoglobuline +nl vancomycin vancomycine +nl varicella, live attenuated varicella, levend verzwakt +nl varicella/zoster immunoglobulin varicella-zoster-immunoglobuline +nl voriconazole voriconazol +nl yellow fever, live attenuated gele koorts, levend verzwakt diff --git a/man/AMR-deprecated.Rd b/man/AMR-deprecated.Rd index 743f9547e..9579966df 100644 --- a/man/AMR-deprecated.Rd +++ b/man/AMR-deprecated.Rd @@ -3,39 +3,30 @@ \name{AMR-deprecated} \alias{AMR-deprecated} \alias{ratio} -\alias{ab_property} -\alias{ab_atc} +\alias{abname} +\alias{atc_property} +\alias{atc_official} \alias{ab_official} -\alias{ab_name} -\alias{ab_trivial_nl} -\alias{ab_certe} -\alias{ab_umcg} -\alias{ab_tradenames} -\alias{atc_ddd} -\alias{atc_groups} +\alias{atc_name} +\alias{atc_trivial_nl} +\alias{atc_tradenames} \title{Deprecated functions} \usage{ ratio(x, ratio) -ab_property(...) +abname(...) -ab_atc(...) +atc_property(...) + +atc_official(...) ab_official(...) -ab_name(...) +atc_name(...) -ab_trivial_nl(...) +atc_trivial_nl(...) -ab_certe(...) - -ab_umcg(...) - -ab_tradenames(...) - -atc_ddd(...) - -atc_groups(...) +atc_tradenames(...) } \description{ These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one). diff --git a/man/ab_property.Rd b/man/ab_property.Rd new file mode 100644 index 000000000..8abb59dc5 --- /dev/null +++ b/man/ab_property.Rd @@ -0,0 +1,110 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ab_property.R +\name{ab_property} +\alias{ab_property} +\alias{ab_name} +\alias{ab_atc} +\alias{ab_cid} +\alias{ab_synonyms} +\alias{ab_tradenames} +\alias{ab_group} +\alias{ab_atc_group1} +\alias{ab_atc_group2} +\alias{ab_ddd} +\title{Property of an antibiotic} +\usage{ +ab_name(x, language = get_locale(), tolower = FALSE, ...) + +ab_atc(x, ...) + +ab_cid(x, ...) + +ab_synonyms(x, ...) + +ab_tradenames(x, ...) + +ab_group(x, ...) + +ab_atc_group1(x, ...) + +ab_atc_group2(x, ...) + +ab_ddd(x, administration = "oral", units = FALSE, ...) + +ab_property(x, property = "name", language = get_locale(), ...) +} +\arguments{ +\item{x}{any (vector of) text that can be coerced to a valid microorganism code with \code{\link{as.ab}}} + +\item{language}{language of the returned text, defaults to system language (see \code{\link{get_locale}}) and can also be set with \code{\link{getOption}("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation.} + +\item{tolower}{logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b".} + +\item{...}{other parameters passed on to \code{\link{as.ab}}} + +\item{administration}{way of administration, either \code{"oral"} or \code{"iv"}} + +\item{units}{a logical to indicate whether the units instead of the DDDs itself must be returned, see Examples} + +\item{property}{one of the column names of one of the \code{\link{antibiotics}} data set} +} +\value{ +\itemize{ + \item{An \code{integer} in case of \code{ab_cid}} + \item{A named \code{list} in case of multiple \code{ab_synonyms}} + \item{A \code{double} in case of \code{ab_ddd}} + \item{A \code{character} in all other cases} +} +} +\description{ +Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set. All input values will be evaluated internally with \code{\link{as.ab}}. +} +\details{ +All output will be \link{translate}d where possible. +} +\section{Source}{ + +World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/} + +WHONET 2019 software: \url{http://www.whonet.org/software.html} + +European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm} +} + +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\examples{ +# all properties: +ab_name("AMX") # "Amoxicillin" +ab_atc("AMX") # J01CA04 (ATC code from the WHO) +ab_cid("AMX") # 33613 (Compound ID from PubChem) + +ab_synonyms("AMX") # a list with brand names of amoxicillin +ab_tradenames("AMX") # same + +ab_group("AMX") # "Beta-lactams/penicillins" +ab_atc_group1("AMX") # "Beta-lactam antibacterials, penicillins" +ab_atc_group2("AMX") # "Penicillins with extended spectrum" + +ab_name(x = c("AMC", "PLB")) # "Amoxicillin/clavulanic acid" "Polymyxin B" +ab_name(x = c("AMC", "PLB"), + tolower = TRUE) # "amoxicillin/clavulanic acid" "polymyxin B" + +ab_ddd("AMX", "oral") # 1 +ab_ddd("AMX", "oral", units = TRUE) # "g" +ab_ddd("AMX", "iv") # 1 +ab_ddd("AMX", "iv", units = TRUE) # "g" + +# all ab_* functions use as.ab() internally: +ab_name("Fluclox") # "Flucloxacillin" +ab_name("fluklox") # "Flucloxacillin" +ab_name("floxapen") # "Flucloxacillin" +ab_name(21319) # "Flucloxacillin" (using CID) +ab_name("J01CF05") # "Flucloxacillin" (using ATC) +} +\seealso{ +\code{\link{antibiotics}} +} diff --git a/man/abname.Rd b/man/abname.Rd deleted file mode 100644 index 5de0e51ba..000000000 --- a/man/abname.Rd +++ /dev/null @@ -1,74 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/abname.R -\name{abname} -\alias{abname} -\title{Name of an antibiotic} -\source{ -\code{\link{antibiotics}} -} -\usage{ -abname(abcode, from = c("guess", "atc", "certe", "umcg"), - to = "official", textbetween = " + ", tolower = FALSE) -} -\arguments{ -\item{abcode}{a code or name, like \code{"AMOX"}, \code{"AMCL"} or \code{"J01CA04"}} - -\item{from, to}{type to transform from and to. See \code{\link{antibiotics}} for its column names. WIth \code{from = "guess"} the from will be guessed from \code{"atc"}, \code{"certe"} and \code{"umcg"}. When using \code{to = "atc"}, the ATC code will be searched using \code{\link{as.atc}}.} - -\item{textbetween}{text to put between multiple returned texts} - -\item{tolower}{return output as lower case with function \code{\link{tolower}}.} -} -\description{ -Convert antibiotic codes to a (trivial) antibiotic name or ATC code, or vice versa. This uses the data from \code{\link{antibiotics}}. -} -\details{ -\strong{The \code{\link{ab_property}} functions are faster and more concise}, but do not support concatenated strings, like \code{abname("AMCL+GENT"}. -} -\section{WHOCC}{ - -\if{html}{\figure{logo_who.png}{options: height=60px style=margin-bottom:5px} \cr} -This package contains \strong{all ~500 antimicrobial drugs} and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, \url{https://www.whocc.no}) and the Pharmaceuticals Community Register of the European Commission (\url{http://ec.europa.eu/health/documents/community-register/html/atc.htm}). - -These have become the gold standard for international drug utilisation monitoring and research. - -The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest. -} - -\section{Read more on our website!}{ - -On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. -} - -\examples{ -abname("AMCL") -# "Amoxicillin and beta-lactamase inhibitor" - -# It is quite flexible at default (having `from = "guess"`) -abname(c("amox", "J01CA04", "Trimox", "dispermox", "Amoxil")) -# "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" "Amoxicillin" - -# Multiple antibiotics can be combined with "+". -# The second antibiotic will be set to lower case when `tolower` was not set: -abname("AMCL+GENT", textbetween = "/") -# "amoxicillin and enzyme inhibitor/gentamicin" - -abname(c("AMCL", "GENT")) -# "Amoxicillin and beta-lactamase inhibitor" "Gentamicin" - -abname("AMCL", to = "trivial_nl") -# "Amoxicilline/clavulaanzuur" - -abname("AMCL", to = "atc") -# "J01CR02" - -# specific codes for University Medical Center Groningen (UMCG): -abname("J01CR02", from = "atc", to = "umcg") -# "AMCL" - -# specific codes for Certe: -abname("J01CR02", from = "atc", to = "certe") -# "amcl" -} -\keyword{ab} -\keyword{antibiotics} diff --git a/man/age_groups.Rd b/man/age_groups.Rd index e6f0050c0..d4ef33220 100644 --- a/man/age_groups.Rd +++ b/man/age_groups.Rd @@ -9,7 +9,7 @@ age_groups(x, split_at = c(12, 25, 55, 75)) \arguments{ \item{x}{age, e.g. calculated with \code{\link{age}}} -\item{split_at}{values to split \code{x} at, defaults to age groups 0-11, 12-24, 26-54, 55-74 and 75+. See Details.} +\item{split_at}{values to split \code{x} at, defaults to age groups 0-11, 12-24, 25-54, 55-74 and 75+. See Details.} } \value{ Ordered \code{\link{factor}} @@ -21,7 +21,7 @@ Split ages into age groups defined by the \code{split} parameter. This allows fo To split ages, the input can be: \itemize{ \item{A numeric vector. A vector of e.g. \code{c(10, 20)} will split on 0-9, 10-19 and 20+. A value of only \code{50} will split on 0-49 and 50+. - The default is to split on young children (0-11), youth (12-24), young adults (26-54), middle-aged adults (55-74) and elderly (75+).} + The default is to split on young children (0-11), youth (12-24), young adults (25-54), middle-aged adults (55-74) and elderly (75+).} \item{A character:} \itemize{ \item{\code{"children"}, equivalent of: \code{c(0, 1, 2, 4, 6, 13, 18)}. This will split on 0, 1, 2-3, 4-5, 6-12, 13-17 and 18+.} @@ -66,7 +66,7 @@ septic_patients \%>\% mo == as.mo("E. coli")) \%>\% group_by(age_group = age_groups(age)) \%>\% select(age_group, - cipr) \%>\% + CIP) \%>\% ggplot_rsi(x = "age_group") } \seealso{ diff --git a/man/antibiotics.Rd b/man/antibiotics.Rd index ca42d689e..9f1b6cd25 100644 --- a/man/antibiotics.Rd +++ b/man/antibiotics.Rd @@ -3,33 +3,27 @@ \docType{data} \name{antibiotics} \alias{antibiotics} -\title{Data set with ~500 antibiotics} -\format{A \code{\link{data.frame}} with 488 observations and 17 variables: +\title{Data set with ~450 antibiotics} +\format{A \code{\link{data.frame}} with 455 observations and 13 variables: \describe{ - \item{\code{atc}}{ATC code (Anatomical Therapeutic Chemical), like \code{J01CR02}} - \item{\code{ears_net}}{EARS-Net code (European Antimicrobial Resistance Surveillance Network), like \code{AMC}} - \item{\code{certe}}{Certe code, like \code{amcl}} - \item{\code{umcg}}{UMCG code, like \code{AMCL}} - \item{\code{abbr}}{Abbreviation as used by many countries, used internally by \code{\link{as.atc}}} - \item{\code{official}}{Official name by the WHO, like \code{"Amoxicillin and beta-lactamase inhibitor"}} - \item{\code{official_nl}}{Official name in the Netherlands, like \code{"Amoxicilline met enzymremmer"}} - \item{\code{trivial_nl}}{Trivial name in Dutch, like \code{"Amoxicilline/clavulaanzuur"}} - \item{\code{trade_name}}{Trade name as used by many countries (a total of 294), used internally by \code{\link{as.atc}}} + \item{\code{ab}}{Antibiotic ID as used in this package (like \code{AMC}), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available} + \item{\code{atc}}{ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC, like \code{J01CR02}} + \item{\code{cid}}{Compound ID as found in PubChem} + \item{\code{name}}{Official name as used by WHONET/EARS-Net or the WHO} + \item{\code{group}}{A short and concise group name, based on WHONET and WHOCC definitions} + \item{\code{atc_group1}}{Official pharmacological subgroup (3rd level ATC code) as defined by the WHOCC, like \code{"Macrolides, lincosamides and streptogramins"}} + \item{\code{atc_group2}}{Official chemical subgroup (4th level ATC code) as defined by the WHOCC, like \code{"Macrolides"}} + \item{\code{abbr}}{List of abbreviations as used in many countries, also for antibiotic susceptibility testing (AST)} + \item{\code{synonyms}}{Synonyms (often trade names) of a drug, as found in PubChem based on their compound ID} \item{\code{oral_ddd}}{Defined Daily Dose (DDD), oral treatment} \item{\code{oral_units}}{Units of \code{ddd_units}} \item{\code{iv_ddd}}{Defined Daily Dose (DDD), parenteral treatment} \item{\code{iv_units}}{Units of \code{iv_ddd}} - \item{\code{atc_group1}}{ATC group, like \code{"Macrolides, lincosamides and streptogramins"}} - \item{\code{atc_group2}}{Subgroup of \code{atc_group1}, like \code{"Macrolides"}} - \item{\code{useful_gramnegative}}{\code{FALSE} if not useful according to EUCAST, \code{NA} otherwise (see Source)} - \item{\code{useful_grampositive}}{\code{FALSE} if not useful according to EUCAST, \code{NA} otherwise (see Source)} }} \source{ -World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/} +World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): \url{https://www.whocc.no/atc_ddd_index/} -Table antibiotic coding EARSS (from WHONET 5.3): \url{http://www.madsonline.dk/Tutorials/landskoder_antibiotika_WM.pdf} - -EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes Tables. Version 3.1, 2016: \url{http://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf} +WHONET 2019 software: \url{http://www.whonet.org/software.html} European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm} } @@ -37,7 +31,12 @@ European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{htt antibiotics } \description{ -A data set containing all antibiotics with a J0 code and some other antimicrobial agents, with their DDDs. Except for trade names and abbreviations, all properties were downloaded from the WHO, see Source. +A data set containing all antibiotics. Use \code{\link{as.ab}} or one of the \code{\link{ab_property}} functions to retrieve values from this data set. Three identifiers are included in this data set: an antibiotic ID (\code{ab}, primarily used in this package) as defined by WHONET/EARS-Net, an ATC code (\code{atc}) as defined by the WHO, and a Compound ID (\code{cid}) as found in PubChem. Other properties in this data set are derived from one or more of these codes. +} +\details{ +Properties that are based on an ATC code are only available when an ATC is available. These properties are: \code{atc_group1}, \code{atc_group2}, \code{oral_ddd}, \code{oral_units}, \code{iv_ddd} and \code{iv_units} + +Synonyms (i.e. trade names) are derived from the Compound ID (\code{cid}) and consequently only available where a CID is available. } \section{WHOCC}{ diff --git a/man/as.ab.Rd b/man/as.ab.Rd new file mode 100644 index 000000000..d8776bf12 --- /dev/null +++ b/man/as.ab.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ab.R +\name{as.ab} +\alias{as.ab} +\title{Transform to antibiotic ID} +\usage{ +as.ab(x) +} +\arguments{ +\item{x}{character vector to determine to antibiotic ID} +} +\value{ +Character (vector) with class \code{"act"}. Unknown values will return \code{NA}. +} +\description{ +Use this function to determine the antibiotic code of one or more antibiotics. The data set \code{\link{antibiotics}} will be searched for abbreviations, official names and synonyms (brand names). +} +\details{ +Use the \code{\link{ab_property}} functions to get properties based on the returned ATC code, see Examples. + +In the ATC classification system, the active substances are classified in a hierarchy with five different levels. The system has fourteen main anatomical/pharmacological groups or 1st levels. Each ATC main group is divided into 2nd levels which could be either pharmacological or therapeutic groups. The 3rd and 4th levels are chemical, pharmacological or therapeutic subgroups and the 5th level is the chemical substance. The 2nd, 3rd and 4th levels are often used to identify pharmacological subgroups when that is considered more appropriate than therapeutic or chemical subgroups. + Source: \url{https://www.whocc.no/atc/structure_and_principles/} +} +\section{Source}{ + +World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology: \url{https://www.whocc.no/atc_ddd_index/} + +WHONET 2019 software: \url{http://www.whonet.org/software.html} + +European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{http://ec.europa.eu/health/documents/community-register/html/atc.htm} +} + +\section{WHOCC}{ + +\if{html}{\figure{logo_who.png}{options: height=60px style=margin-bottom:5px} \cr} +This package contains \strong{all ~500 antimicrobial drugs} and their Anatomical Therapeutic Chemical (ATC) codes, ATC groups and Defined Daily Dose (DDD) from the World Health Organization Collaborating Centre for Drug Statistics Methodology (WHOCC, \url{https://www.whocc.no}) and the Pharmaceuticals Community Register of the European Commission (\url{http://ec.europa.eu/health/documents/community-register/html/atc.htm}). + +These have become the gold standard for international drug utilisation monitoring and research. + +The WHOCC is located in Oslo at the Norwegian Institute of Public Health and funded by the Norwegian government. The European Commission is the executive of the European Union and promotes its general interest. +} + +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\examples{ +# These examples all return "ERY", the ID of Erythromycin: +as.ab("J01FA01") +as.ab("J 01 FA 01") +as.ab("Erythromycin") +as.ab("eryt") +as.ab(" eryt 123") +as.ab("ERYT") +as.ab("ERY") +as.ab("erytromicine") # spelled wrong +as.ab("Erythrocin") # trade name +as.ab("Romycin") # trade name + +# Use ab_* functions to get a specific properties (see ?ab_property); +# they use as.ab() internally: +ab_name("J01FA01") # "Erythromycin" +ab_name("eryt") # "Erythromycin" +} +\seealso{ +\code{\link{antibiotics}} for the dataframe that is being used to determine ATCs. +} +\keyword{atc} diff --git a/man/as.atc.Rd b/man/as.atc.Rd index 4c260377b..888b3bf12 100644 --- a/man/as.atc.Rd +++ b/man/as.atc.Rd @@ -1,11 +1,14 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/atc.R -\name{as.atc} +% Please edit documentation in R/ab.R, R/atc.R +\name{is.ab} +\alias{is.ab} \alias{as.atc} \alias{atc} \alias{is.atc} \title{Transform to ATC code} \usage{ +is.ab(x) + as.atc(x) is.atc(x) @@ -48,14 +51,6 @@ as.atc("eryt") as.atc(" eryt 123") as.atc("ERYT") as.atc("ERY") -as.atc("Erythrocin") # Trade name -as.atc("Eryzole") # Trade name -as.atc("Pediamycin") # Trade name - -# Use ab_* functions to get a specific property based on an ATC code -Cipro <- as.atc("cipro") # returns `J01MA02` -atc_official(Cipro) # returns "Ciprofloxacin" -atc_umcg(Cipro) # returns "CIPR", the code used in the UMCG } \seealso{ \code{\link{antibiotics}} for the dataframe that is being used to determine ATCs. diff --git a/man/as.disk.Rd b/man/as.disk.Rd new file mode 100644 index 000000000..ee597ad1d --- /dev/null +++ b/man/as.disk.Rd @@ -0,0 +1,45 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/disk.R +\name{as.disk} +\alias{as.disk} +\alias{is.disk} +\title{Class 'disk'} +\usage{ +as.disk(x, na.rm = FALSE) + +is.disk(x) +} +\arguments{ +\item{x}{vector} + +\item{na.rm}{a logical indicating whether missing values should be removed} +} +\value{ +Ordered integer factor with new class \code{disk} +} +\description{ +This transforms a vector to a new class \code{disk}, which is a growth zone size (around an antibiotic disk) in millimeters between 6 and 99. +} +\details{ +Interpret disk values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI. +} +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\examples{ +# interpret disk values +as.rsi(x = 12, + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") +as.rsi(x = 12, + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "CLSI") +} +\seealso{ +\code{\link{as.rsi}} +} +\keyword{disk} diff --git a/man/as.mic.Rd b/man/as.mic.Rd index d1f361e4d..90f4686c7 100755 --- a/man/as.mic.Rd +++ b/man/as.mic.Rd @@ -20,6 +20,9 @@ Ordered factor with new class \code{mic} \description{ This transforms a vector to a new class \code{mic}, which is an ordered factor with valid MIC values as levels. Invalid MIC values will be translated as \code{NA} with a warning. } +\details{ +Interpret MIC values as RSI values with \code{\link{as.rsi}}. It supports guidelines from EUCAST and CLSI. +} \section{Read more on our website!}{ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. @@ -32,6 +35,16 @@ is.mic(mic_data) # this can also coerce combined MIC/RSI values: as.mic("<=0.002; S") # will return <=0.002 +# interpret MIC values +as.rsi(x = as.mic(2), + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") +as.rsi(x = as.mic(4), + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") + plot(mic_data) barplot(mic_data) freq(mic_data) diff --git a/man/as.mo.Rd b/man/as.mo.Rd index a3824e1ac..24c822c16 100644 --- a/man/as.mo.Rd +++ b/man/as.mo.Rd @@ -127,7 +127,7 @@ Group 2 probably contains all other microbial pathogens ever found in humans. [1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870–926. \url{https://dx.doi.org/10.1128/CMR.00109-13} -[2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).}. 2019. Clin Microbiol Infect. 2019 Mar 11. \url{https://doi.org/10.1016/j.cmi.2019.02.028} +[2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the \emph{S. aureus} complex, \emph{S. argenteus} and \emph{S. schweitzeri}: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).} 2019. Clin Microbiol Infect. \url{https://doi.org/10.1016/j.cmi.2019.02.028} [3] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571} diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd index a9d5e8ecc..b03eb6272 100755 --- a/man/as.rsi.Rd +++ b/man/as.rsi.Rd @@ -2,18 +2,38 @@ % Please edit documentation in R/rsi.R \name{as.rsi} \alias{as.rsi} +\alias{as.rsi.mic} +\alias{as.rsi.disk} +\alias{as.rsi.data.frame} \alias{is.rsi} \alias{is.rsi.eligible} \title{Class 'rsi'} \usage{ -as.rsi(x) +as.rsi(x, ...) + +\method{as.rsi}{mic}(x, mo, ab, guideline = "EUCAST", ...) + +\method{as.rsi}{disk}(x, mo, ab, guideline = "EUCAST", ...) + +\method{as.rsi}{data.frame}(x, col_mo = NULL, guideline = "EUCAST", + ...) is.rsi(x) is.rsi.eligible(x, threshold = 0.05) } \arguments{ -\item{x}{vector} +\item{x}{vector of values (for class \code{mic}: an MIC value in mg/L, for class \code{disk}: a disk diffusion radius in millimeters)} + +\item{...}{parameters passed on to methods} + +\item{mo}{a microorganism code, generated with \code{\link{as.mo}}} + +\item{ab}{an antibiotic code, generated with \code{\link{as.ab}}} + +\item{guideline}{defaults to the latest included EUCAST guideline, run \code{unique(AMR::rsi_translation$guideline)} for all options} + +\item{col_mo}{column name of the unique IDs of the microorganisms (see \code{\link{mo}}), defaults to the first column of class \code{mo}. Values will be coerced using \code{\link{as.mo}}.} \item{threshold}{maximum fraction of \code{x} that is allowed to fail transformation, see Examples} } @@ -21,12 +41,14 @@ is.rsi.eligible(x, threshold = 0.05) Ordered factor with new class \code{rsi} } \description{ -This transforms a vector to a new class \code{rsi}, which is an ordered factor with levels \code{S < I < R}. Invalid antimicrobial interpretations will be translated as \code{NA} with a warning. +Interpret MIC values according to EUCAST or CLSI, or clean up existing RSI values. This transforms the input to a new class \code{rsi}, which is an ordered factor with levels \code{S < I < R}. Invalid antimicrobial interpretations will be translated as \code{NA} with a warning. } \details{ -\strong{NOTE:} This function does not translate MIC values to RSI values. If more than 50\% of the input resembles MIC values, it will warn about this.\cr You can use \code{\link{eucast_rules}} to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism. +Run \code{unique(AMR::rsi_translation$guideline)} for a list of all supported guidelines. -The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains only valid antimicrobial interpretations (S and/or I and/or R), and \code{FALSE} otherwise. +After using \code{as.rsi}, you can use \code{\link{eucast_rules}} to (1) apply inferred susceptibility and resistance based on results of other antibiotics and (2) apply intrinsic resistance based on taxonomic properties of a microorganism. + +The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains at most 5\% invalid antimicrobial interpretations (not S and/or I and/or R), and \code{FALSE} otherwise. The threshold of 5\% can be set with the \code{threshold} parameter. } \section{Read more on our website!}{ @@ -41,6 +63,16 @@ is.rsi(rsi_data) # this can also coerce combined MIC/RSI values: as.rsi("<= 0.002; S") # will return S +# interpret MIC values +as.rsi(x = as.mic(2), + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") +as.rsi(x = as.mic(4), + mo = as.mo("S. pneumoniae"), + ab = "AMX", + guideline = "EUCAST") + plot(rsi_data) # for percentages barplot(rsi_data) # for frequencies freq(rsi_data) # frequency table with informative header @@ -48,7 +80,7 @@ freq(rsi_data) # frequency table with informative header # using dplyr's mutate library(dplyr) septic_patients \%>\% - mutate_at(vars(peni:rifa), as.rsi) + mutate_at(vars(PEN:RIF), as.rsi) # fastest way to transform all columns with already valid AB results to class `rsi`: @@ -58,7 +90,7 @@ septic_patients \%>\% # default threshold of `is.rsi.eligible` is 5\%. is.rsi.eligible(WHONET$`First name`) # fails, >80\% is invalid -is.rsi.eligible(WHONET$`First name`, threshold = 0.9) # succeeds +is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds } \seealso{ \code{\link{as.mic}} diff --git a/man/atc_property.Rd b/man/atc_property.Rd deleted file mode 100755 index 4f30e135e..000000000 --- a/man/atc_property.Rd +++ /dev/null @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/atc_property.R -\name{atc_property} -\alias{atc_property} -\alias{atc_official} -\alias{atc_name} -\alias{atc_trivial_nl} -\alias{atc_certe} -\alias{atc_umcg} -\alias{atc_tradenames} -\title{Property of an antibiotic} -\usage{ -atc_property(x, property = "official") - -atc_official(x, language = NULL) - -atc_name(x, language = NULL) - -atc_trivial_nl(x) - -atc_certe(x) - -atc_umcg(x) - -atc_tradenames(x) -} -\arguments{ -\item{x}{a (vector of a) valid \code{\link{atc}} code or any text that can be coerced to a valid atc with \code{\link{as.atc}}} - -\item{property}{one of the column names of one of the \code{\link{antibiotics}} data set, like \code{"atc"} and \code{"official"}} - -\item{language}{language of the returned text, defaults to English (\code{"en"}) and can be set with \code{\link{getOption}("AMR_locale")}. Either one of \code{"en"} (English) or \code{"nl"} (Dutch).} -} -\value{ -A vector of values. In case of \code{atc_tradenames}, if \code{x} is of length one, a vector will be returned. Otherwise a \code{\link{list}}, with \code{x} as names. -} -\description{ -Use these functions to return a specific property of an antibiotic from the \code{\link{antibiotics}} data set, based on their ATC code. Get such a code with \code{\link{as.atc}}. -} -\section{Read more on our website!}{ - -On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. -} - -\examples{ -as.atc("amcl") # J01CR02 -atc_name("amcl") # Amoxicillin and beta-lactamase inhibitor -atc_name("amcl", "nl") # Amoxicilline met enzymremmer -atc_trivial_nl("amcl") # Amoxicilline/clavulaanzuur -atc_certe("amcl") # amcl -atc_umcg("amcl") # AMCL -} -\seealso{ -\code{\link{antibiotics}} -} diff --git a/man/count.Rd b/man/count.Rd index d0bd3b1d7..e32053ad8 100644 --- a/man/count.Rd +++ b/man/count.Rd @@ -29,8 +29,8 @@ count_all(...) n_rsi(...) -count_df(data, translate_ab = getOption("get_antibiotic_names", - "official"), combine_IR = FALSE) +count_df(data, translate_ab = "name", language = get_locale(), + combine_IR = FALSE) } \arguments{ \item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed.} @@ -39,7 +39,9 @@ count_df(data, translate_ab = getOption("get_antibiotic_names", \item{data}{a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}})} -\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{abname}}. This can be set with \code{\link{getOption}("get_antibiotic_names")}.} +\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{ab_property}}} + +\item{language}{language of the returned text, defaults to system language (see \code{\link{get_locale}}) and can also be set with \code{\link{getOption}("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation.} \item{combine_IR}{a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)} } @@ -68,55 +70,55 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https:// ?septic_patients # Count resistant isolates -count_R(septic_patients$amox) -count_IR(septic_patients$amox) +count_R(septic_patients$AMX) +count_IR(septic_patients$AMX) # Or susceptible isolates -count_S(septic_patients$amox) -count_SI(septic_patients$amox) +count_S(septic_patients$AMX) +count_SI(septic_patients$AMX) # Count all available isolates -count_all(septic_patients$amox) -n_rsi(septic_patients$amox) +count_all(septic_patients$AMX) +n_rsi(septic_patients$AMX) # Since n_rsi counts available isolates, you can # calculate back to count e.g. non-susceptible isolates. # This results in the same: -count_IR(septic_patients$amox) -portion_IR(septic_patients$amox) * n_rsi(septic_patients$amox) +count_IR(septic_patients$AMX) +portion_IR(septic_patients$AMX) * n_rsi(septic_patients$AMX) library(dplyr) septic_patients \%>\% group_by(hospital_id) \%>\% - summarise(R = count_R(cipr), - I = count_I(cipr), - S = count_S(cipr), - n1 = count_all(cipr), # the actual total; sum of all three - n2 = n_rsi(cipr), # same - analogous to n_distinct + summarise(R = count_R(CIP), + I = count_I(CIP), + S = count_S(CIP), + n1 = count_all(CIP), # the actual total; sum of all three + n2 = n_rsi(CIP), # same - analogous to n_distinct total = n()) # NOT the number of tested isolates! # Count co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy. # Please mind that `portion_S` calculates percentages right away instead. -count_S(septic_patients$amcl) # S = 1342 (71.4\%) -count_all(septic_patients$amcl) # n = 1879 +count_S(septic_patients$AMC) # S = 1342 (71.4\%) +count_all(septic_patients$AMC) # n = 1879 -count_S(septic_patients$gent) # S = 1372 (74.0\%) -count_all(septic_patients$gent) # n = 1855 +count_S(septic_patients$GEN) # S = 1372 (74.0\%) +count_all(septic_patients$GEN) # n = 1855 with(septic_patients, - count_S(amcl, gent)) # S = 1660 (92.3\%) + count_S(AMC, GEN)) # S = 1660 (92.3\%) with(septic_patients, # n = 1798 - n_rsi(amcl, gent)) + n_rsi(AMC, GEN)) # Get portions S/I/R immediately of all rsi columns septic_patients \%>\% - select(amox, cipr) \%>\% + select(AMX, CIP) \%>\% count_df(translate = FALSE) # It also supports grouping variables septic_patients \%>\% - select(hospital_id, amox, cipr) \%>\% + select(hospital_id, AMX, CIP) \%>\% group_by(hospital_id) \%>\% count_df(translate = FALSE) diff --git a/man/eucast_rules.Rd b/man/eucast_rules.Rd index 314a25533..b22a637b2 100644 --- a/man/eucast_rules.Rd +++ b/man/eucast_rules.Rd @@ -21,47 +21,16 @@ } } - For editing the reference file (which is available with \code{\link{eucast_rules_file}}), these values can all be used for target antibiotics: aminoglycosides, tetracyclines, polymyxins, macrolides, glycopeptides, streptogramins, cephalosporins, cephalosporins_without_cfta, carbapenems, aminopenicillins, ureidopenicillins, fluoroquinolones, all_betalactams, and all separate four letter codes like amcl. They can be separated by comma: \code{"amcl, fluoroquinolones"}. The mo_property can be any column name from the \code{\link{microorganisms}} data set, or \code{genus_species} or \code{gramstain}. This file contains references to the 'Burkholderia cepacia complex'. The species in this group can be found in: LiPuma JJ, 2015 (PMID 16217180). + For editing the reference file (which is available with \code{\link{eucast_rules_file}}), these values can all be used for target antibiotics: aminoglycosides, tetracyclines, polymyxins, macrolides, glycopeptides, streptogramins, cephalosporins, cephalosporins_without_cfta, carbapenems, aminopenicillins, ureidopenicillins, fluoroquinolones, all_betalactams, and all separate four letter codes like AMC. They can be separated by comma: \code{"AMC, fluoroquinolones"}. The mo_property can be any column name from the \code{\link{microorganisms}} data set, or \code{genus_species} or \code{gramstain}. This file contains references to the 'Burkholderia cepacia complex'. The species in this group can be found in: LiPuma JJ, 2015 (PMID 16217180). } \usage{ eucast_rules(x, col_mo = NULL, info = TRUE, rules = c("breakpoints", - "expert", "other", "all"), verbose = FALSE, amcl = guess_ab_col(), - amik = guess_ab_col(), amox = guess_ab_col(), - ampi = guess_ab_col(), azit = guess_ab_col(), - azlo = guess_ab_col(), aztr = guess_ab_col(), - cefa = guess_ab_col(), cfep = guess_ab_col(), - cfot = guess_ab_col(), cfox = guess_ab_col(), - cfra = guess_ab_col(), cfta = guess_ab_col(), - cftr = guess_ab_col(), cfur = guess_ab_col(), - chlo = guess_ab_col(), cipr = guess_ab_col(), - clar = guess_ab_col(), clin = guess_ab_col(), - clox = guess_ab_col(), coli = guess_ab_col(), - czol = guess_ab_col(), dapt = guess_ab_col(), - doxy = guess_ab_col(), erta = guess_ab_col(), - eryt = guess_ab_col(), fosf = guess_ab_col(), - fusi = guess_ab_col(), gent = guess_ab_col(), - imip = guess_ab_col(), kana = guess_ab_col(), - levo = guess_ab_col(), linc = guess_ab_col(), - line = guess_ab_col(), mero = guess_ab_col(), - mezl = guess_ab_col(), mino = guess_ab_col(), - moxi = guess_ab_col(), nali = guess_ab_col(), - neom = guess_ab_col(), neti = guess_ab_col(), - nitr = guess_ab_col(), norf = guess_ab_col(), - novo = guess_ab_col(), oflo = guess_ab_col(), - oxac = guess_ab_col(), peni = guess_ab_col(), - pipe = guess_ab_col(), pita = guess_ab_col(), - poly = guess_ab_col(), pris = guess_ab_col(), - qida = guess_ab_col(), rifa = guess_ab_col(), - roxi = guess_ab_col(), siso = guess_ab_col(), - teic = guess_ab_col(), tetr = guess_ab_col(), - tica = guess_ab_col(), tige = guess_ab_col(), - tobr = guess_ab_col(), trim = guess_ab_col(), - trsu = guess_ab_col(), vanc = guess_ab_col(), ...) + "expert", "other", "all"), verbose = FALSE, ...) eucast_rules_file() } \arguments{ -\item{x}{data with antibiotic columns, like e.g. \code{amox} and \code{amcl}} +\item{x}{data with antibiotic columns, like e.g. \code{AMX} and \code{AMC}} \item{col_mo}{column name of the unique IDs of the microorganisms (see \code{\link{mo}}), defaults to the first column of class \code{mo}. Values will be coerced using \code{\link{as.mo}}.} @@ -71,9 +40,7 @@ eucast_rules_file() \item{verbose}{a logical to indicate whether extensive info should be returned as a \code{data.frame} with info about which rows and columns are effected. It runs all EUCAST rules, but will not be applied to an output - only an informative \code{data.frame} with changes will be returned as output.} -\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, oxac, peni, pipe, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column name of an antibiotic, see Antibiotics} - -\item{...}{parameters that are passed on to \code{eucast_rules}} +\item{...}{column name of an antibiotic, see section Antibiotics} } \value{ The input of \code{tbl_}, possibly with edited values of antibiotics. Or, if \code{verbose = TRUE}, a \code{data.frame} with all original and new values of the affected bug-drug combinations. @@ -82,83 +49,84 @@ The input of \code{tbl_}, possibly with edited values of antibiotics. Or, if \co Apply susceptibility rules as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}. This includes (1) expert rules, (2) intrinsic resistance and (3) inferred resistance as defined in their breakpoint tables. } \details{ -\strong{NOTE:} This function does not translate MIC values to RSI values. It only applies (1) inferred susceptibility and resistance based on results of other antibiotics and (2) intrinsic resistance based on taxonomic properties of a microorganism. +\strong{Note:} This function does not translate MIC values to RSI values. Use \code{\link{as.rsi}} for that. \cr +\strong{Note:} When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. -The file used for applying all EUCAST rules can be retrieved with \code{\link{eucast_rules_file}()}. It returns an easily readable data set containing all rules. The original TSV file (tab separated file) that is being read by this function can be found when running this command: \cr +The file used for applying all EUCAST rules can be retrieved with \code{\link{eucast_rules_file}()}. It returns an easily readable data set containing all rules. The original TSV file (tab separated file) that is being read by \code{eucast_rules()} can be found by running this command: \cr \code{AMR::EUCAST_RULES_FILE_LOCATION} (without brackets). -In the source code it is located under \href{https://gitlab.com/msberends/AMR/blob/master/inst/eucast/eucast_rules.tsv}{\code{./inst/eucast/eucast_rules.tsv}}. - -\strong{Note:} When ampicillin (J01CA01) is not available but amoxicillin (J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. +In the source code the file containing all rules is located \href{https://gitlab.com/msberends/AMR/blob/master/inst/eucast/eucast_rules.tsv}{here}. } \section{Antibiotics}{ -To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning. +To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive), or use \code{NULL} to skip a column (e.g. \code{TIC = NULL} to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning. -Abbrevations of the column containing antibiotics in the form: \strong{abbreviation}: generic name (\emph{ATC code}) +Available abbrevations of the column containing antibiotics in the form '\strong{antimicrobial ID}: name (\emph{ATC code})': - \strong{amcl}: amoxicillin+clavulanic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR02}{J01CR02}), - \strong{amik}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), - \strong{amox}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), - \strong{ampi}: ampicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA01}{J01CA01}), - \strong{azit}: azithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA10}{J01FA10}), - \strong{azlo}: azlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA09}{J01CA09}), - \strong{aztr}: aztreonam (\href{https://www.whocc.no/atc_ddd_index/?code=J01DF01}{J01DF01}), - \strong{cefa}: cefaloridine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB02}{J01DB02}), - \strong{cfep}: cefepime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DE01}{J01DE01}), - \strong{cfot}: cefotaxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD01}{J01DD01}), - \strong{cfox}: cefoxitin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC01}{J01DC01}), - \strong{cfra}: cefradine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB09}{J01DB09}), - \strong{cfta}: ceftazidime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD02}{J01DD02}), - \strong{cftr}: ceftriaxone (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD04}{J01DD04}), - \strong{cfur}: cefuroxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC02}{J01DC02}), - \strong{chlo}: chloramphenicol (\href{https://www.whocc.no/atc_ddd_index/?code=J01BA01}{J01BA01}), - \strong{cipr}: ciprofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA02}{J01MA02}), - \strong{clar}: clarithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA09}{J01FA09}), - \strong{clin}: clindamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF01}{J01FF01}), - \strong{clox}: flucloxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CF05}{J01CF05}), - \strong{coli}: colistin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB01}{J01XB01}), - \strong{czol}: cefazolin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB04}{J01DB04}), - \strong{dapt}: daptomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX09}{J01XX09}), - \strong{doxy}: doxycycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA02}{J01AA02}), - \strong{erta}: ertapenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH03}{J01DH03}), - \strong{eryt}: erythromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA01}{J01FA01}), - \strong{fosf}: fosfomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX01}{J01XX01}), - \strong{fusi}: fusidic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XC01}{J01XC01}), - \strong{gent}: gentamicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB03}{J01GB03}), - \strong{imip}: imipenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH51}{J01DH51}), - \strong{kana}: kanamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB04}{J01GB04}), - \strong{levo}: levofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA12}{J01MA12}), - \strong{linc}: lincomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF02}{J01FF02}), - \strong{line}: linezolid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX08}{J01XX08}), - \strong{mero}: meropenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH02}{J01DH02}), - \strong{mezl}: mezlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA10}{J01CA10}), - \strong{mino}: minocycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA08}{J01AA08}), - \strong{moxi}: moxifloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01MA14}), - \strong{nali}: nalidixic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01MB02}{J01MB02}), - \strong{neom}: neomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB05}{J01GB05}), - \strong{neti}: netilmicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB07}{J01GB07}), - \strong{nitr}: nitrofurantoin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XE01}{J01XE01}), - \strong{norf}: norfloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA06}{J01MA06}), - \strong{novo}: novobiocin (an ATCvet code: \href{https://www.whocc.no/atc_ddd_index/?code=QJ01XX95}{QJ01XX95}), - \strong{oflo}: ofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01MA01}), - \strong{peni}: (benzyl)penicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CE01}{J01CE01}), - \strong{pipe}: piperacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA12}{J01CA12}), - \strong{pita}: piperacillin+tazobactam (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR05}{J01CR05}), - \strong{poly}: polymyxin B (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB02}{J01XB02}), - \strong{pris}: pristinamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG01}{J01FG01}), - \strong{qida}: quinupristin/dalfopristin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG02}{J01FG02}), - \strong{rifa}: rifampicin (\href{https://www.whocc.no/atc_ddd_index/?code=J04AB02}{J04AB02}), - \strong{roxi}: roxithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA06}{J01FA06}), - \strong{siso}: sisomicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB08}{J01GB08}), - \strong{teic}: teicoplanin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA02}{J01XA02}), - \strong{tetr}: tetracycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA07}{J01AA07}), - \strong{tica}: ticarcillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA13}{J01CA13}), - \strong{tige}: tigecycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA12}{J01AA12}), - \strong{tobr}: tobramycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB01}{J01GB01}), - \strong{trim}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), - \strong{trsu}: sulfamethoxazole and trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), - \strong{vanc}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). + \strong{AMC}: amoxicillin/clavulanic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR02}{J01CR02}), + \strong{AMK}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), + \strong{AMX}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), + \strong{AMP}: ampicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA01}{J01CA01}), + \strong{AZM}: azithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA10}{J01FA10}), + \strong{AZL}: azlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA09}{J01CA09}), + \strong{ATM}: aztreonam (\href{https://www.whocc.no/atc_ddd_index/?code=J01DF01}{J01DF01}), + \strong{RID}: cefaloridine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB02}{J01DB02}), + \strong{FEP}: cefepime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DE01}{J01DE01}), + \strong{CTX}: cefotaxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD01}{J01DD01}), + \strong{FOX}: cefoxitin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC01}{J01DC01}), + \strong{CED}: cefradine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB09}{J01DB09}), + \strong{CAZ}: ceftazidime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD02}{J01DD02}), + \strong{CRO}: ceftriaxone (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD04}{J01DD04}), + \strong{CXM}: cefuroxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC02}{J01DC02}), + \strong{CHL}: chloramphenicol (\href{https://www.whocc.no/atc_ddd_index/?code=J01BA01}{J01BA01}), + \strong{CIP}: ciprofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA02}{J01MA02}), + \strong{CLR}: clarithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA09}{J01FA09}), + \strong{CLI}: clindamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF01}{J01FF01}), + \strong{FLC}: flucloxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CF05}{J01CF05}), + \strong{COL}: colistin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB01}{J01XB01}), + \strong{CZO}: cefazolin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB04}{J01DB04}), + \strong{DAP}: daptomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX09}{J01XX09}), + \strong{DOX}: doxycycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA02}{J01AA02}), + \strong{ETP}: ertapenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH03}{J01DH03}), + \strong{ERY}: erythromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA01}{J01FA01}), + \strong{FOS}: fosfomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX01}{J01XX01}), + \strong{FUS}: fusidic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XC01}{J01XC01}), + \strong{GEN}: gentamicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB03}{J01GB03}), + \strong{IPM}: imipenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH51}{J01DH51}), + \strong{KAN}: kanamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB04}{J01GB04}), + \strong{LVX}: levofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA12}{J01MA12}), + \strong{LIN}: lincomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF02}{J01FF02}), + \strong{LNZ}: linezolid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX08}{J01XX08}), + \strong{MEM}: meropenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH02}{J01DH02}), + \strong{MEZ}: mezlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA10}{J01CA10}), + \strong{MNO}: minocycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA08}{J01AA08}), + \strong{MFX}: moxifloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01MA14}), + \strong{MTR}: metronidazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01XD01}), + \strong{NAL}: nalidixic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01MB02}{J01MB02}), + \strong{NEO}: neomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB05}{J01GB05}), + \strong{NET}: netilmicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB07}{J01GB07}), + \strong{NIT}: nitrofurantoin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XE01}{J01XE01}), + \strong{NOR}: norfloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA06}{J01MA06}), + \strong{NOV}: novobiocin (an ATCvet code: \href{https://www.whocc.no/atc_ddd_index/?code=QJ01XX95}{QJ01XX95}), + \strong{OFX}: ofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01MA01}), + \strong{OXA}: oxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01CF04}), + \strong{PEN}: penicillin G (\href{https://www.whocc.no/atc_ddd_index/?code=J01CE01}{J01CE01}), + \strong{PIP}: piperacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA12}{J01CA12}), + \strong{TZP}: piperacillin/tazobactam (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR05}{J01CR05}), + \strong{PLB}: polymyxin B (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB02}{J01XB02}), + \strong{PRI}: pristinamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG01}{J01FG01}), + \strong{QDA}: quinupristin/dalfopristin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG02}{J01FG02}), + \strong{RIF}: rifampicin (\href{https://www.whocc.no/atc_ddd_index/?code=J04AB02}{J04AB02}), + \strong{RXT}: roxithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA06}{J01FA06}), + \strong{SIS}: sisomicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB08}{J01GB08}), + \strong{TEC}: teicoplanin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA02}{J01XA02}), + \strong{TCY}: tetracycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA07}{J01AA07}), + \strong{TIC}: ticarcillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA13}{J01CA13}), + \strong{TGC}: tigecycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA12}{J01AA12}), + \strong{TOB}: tobramycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB01}{J01GB01}), + \strong{TMP}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), + \strong{SXT}: trimethoprim/sulfamethoxazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), + \strong{VAN}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). } \section{Read more on our website!}{ @@ -174,17 +142,17 @@ a <- data.frame(mo = c("Staphylococcus aureus", "Escherichia coli", "Klebsiella pneumoniae", "Pseudomonas aeruginosa"), - vanc = "-", # Vancomycin - amox = "-", # Amoxicillin - coli = "-", # Colistin - cfta = "-", # Ceftazidime - cfur = "-", # Cefuroxime - peni = "S", # Benzylpenicillin - cfox = "S", # Cefoxitin + VAN = "-", # Vancomycin + AMX = "-", # Amoxicillin + COL = "-", # Colistin + CAZ = "-", # Ceftazidime + CXM = "-", # Cefuroxime + PEN = "S", # Penicillin G + FOX = "S", # Cefoxitin stringsAsFactors = FALSE) a -# mo vanc amox coli cfta cfur peni cfox +# mo VAN AMX COL CAZ CXM PEN FOX # 1 Staphylococcus aureus - - - - - S S # 2 Enterococcus faecalis - - - - - S S # 3 Escherichia coli - - - - - S S @@ -196,7 +164,7 @@ a b <- eucast_rules(a) b -# mo vanc amox coli cfta cfur peni cfox +# mo VAN AMX COL CAZ CXM PEN FOX # 1 Staphylococcus aureus - S R R S S S # 2 Enterococcus faecalis - - R R R S R # 3 Escherichia coli R - - - - R S diff --git a/man/filter_ab_class.Rd b/man/filter_ab_class.Rd index 19df430cb..31859f4b4 100644 --- a/man/filter_ab_class.Rd +++ b/man/filter_ab_class.Rd @@ -62,9 +62,9 @@ library(dplyr) # filter on isolates that have any result for any aminoglycoside septic_patients \%>\% filter_aminoglycosides() -# this is essentially the same as: +# this is essentially the same as (but without determination of column names): septic_patients \%>\% - filter_at(.vars = vars(c("gent", "tobr", "amik", "kana")), + filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")), .vars_predicate = any_vars(. \%in\% c("S", "I", "R"))) diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index b8cc97dff..4de198cf1 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -124,14 +124,14 @@ septic_patients \%>\% # Now let's see if first isolates matter: A <- septic_patients \%>\% group_by(hospital_id) \%>\% - summarise(count = n_rsi(gent), # gentamicin availability - resistance = portion_IR(gent)) # gentamicin resistance + summarise(count = n_rsi(GEN), # gentamicin availability + resistance = portion_IR(GEN)) # gentamicin resistance B <- septic_patients \%>\% - filter_first_weighted_isolate() \%>\% # the 1st isolate filter + filter_first_weighted_isolate() \%>\% # the 1st isolate filter group_by(hospital_id) \%>\% - summarise(count = n_rsi(gent), # gentamicin availability - resistance = portion_IR(gent)) # gentamicin resistance + summarise(count = n_rsi(GEN), # gentamicin availability + resistance = portion_IR(GEN)) # gentamicin resistance # Have a look at A and B. # B is more reliable because every isolate is only counted once. diff --git a/man/freq.Rd b/man/freq.Rd index fca5000c5..2e0c4be2c 100755 --- a/man/freq.Rd +++ b/man/freq.Rd @@ -215,8 +215,8 @@ septic_patients \%>\% # check differences between frequency tables -diff(freq(septic_patients$trim), - freq(septic_patients$trsu)) +diff(freq(septic_patients$TMP), + freq(septic_patients$SXT)) } \keyword{freq} \keyword{frequency} diff --git a/man/get_locale.Rd b/man/get_locale.Rd deleted file mode 100644 index 3f943deee..000000000 --- a/man/get_locale.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/get_locale.R -\name{get_locale} -\alias{get_locale} -\title{Get language for AMR} -\usage{ -get_locale() -} -\description{ -Determines the system language to be used for language-dependent output of AMR functions, like \code{\link{mo_gramstain}} and \code{\link{mo_type}}. -} -\details{ -The system language can be overwritten with \code{\link{getOption}("AMR_locale")}. -} -\section{Supported languages}{ - -Supported languages are \code{"en"} (English), \code{"de"} (German), \code{"nl"} (Dutch), \code{"es"} (Spanish), \code{"it"} (Italian), \code{"fr"} (French), and \code{"pt"} (Portuguese). -} - -\section{Read more on our website!}{ - -On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. -} - diff --git a/man/ggplot_rsi.Rd b/man/ggplot_rsi.Rd index 709b2bc44..bc384174f 100644 --- a/man/ggplot_rsi.Rd +++ b/man/ggplot_rsi.Rd @@ -12,13 +12,13 @@ \usage{ ggplot_rsi(data, position = NULL, x = "Antibiotic", fill = "Interpretation", facet = NULL, breaks = seq(0, 1, 0.1), - limits = NULL, translate_ab = "official", fun = count_df, - nrow = NULL, datalabels = TRUE, datalabels.size = 3, - datalabels.colour = "grey15", ...) + limits = NULL, translate_ab = "name", language = get_locale(), + fun = count_df, nrow = NULL, datalabels = TRUE, + datalabels.size = 3, datalabels.colour = "grey15", ...) geom_rsi(position = NULL, x = c("Antibiotic", "Interpretation"), - fill = "Interpretation", translate_ab = "official", fun = count_df, - ...) + fill = "Interpretation", translate_ab = "name", + language = get_locale(), fun = count_df, ...) facet_rsi(facet = c("Interpretation", "Antibiotic"), nrow = NULL) @@ -46,7 +46,9 @@ labels_rsi_count(position = NULL, x = "Antibiotic", \item{limits}{numeric vector of length two providing limits of the scale, use \code{NA} to refer to the existing minimum or maximum} -\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations into, using \code{\link{abname}}. Default behaviour is to translate to official names according to the WHO. Use \code{translate_ab = FALSE} to disable translation.} +\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations into, using \code{\link{ab_name}}. Default behaviour is to translate to official names according to the WHO. Use \code{translate_ab = FALSE} to disable translation.} + +\item{language}{the language used for translation of antibiotic names} \item{fun}{function to transform \code{data}, either \code{\link{count_df}} (default) or \code{\link{portion_df}}} @@ -64,7 +66,7 @@ labels_rsi_count(position = NULL, x = "Antibiotic", Use these functions to create bar plots for antimicrobial resistance analysis. All functions rely on internal \code{\link[ggplot2]{ggplot}} functions. } \details{ -At default, the names of antibiotics will be shown on the plots using \code{\link{abname}}. This can be set with the option \code{get_antibiotic_names} (a logical value), so change it e.g. to \code{FALSE} with \code{options(get_antibiotic_names = FALSE)}. +At default, the names of antibiotics will be shown on the plots using \code{\link{ab_name}}. This can be set with the option \code{get_antibiotic_names} (a logical value), so change it e.g. to \code{FALSE} with \code{options(get_antibiotic_names = FALSE)}. \strong{The functions}\cr \code{geom_rsi} will take any variable from the data that has an \code{rsi} class (created with \code{\link{as.rsi}}) using \code{fun} (\code{\link{count_df}} at default, can also be \code{\link{portion_df}}) and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis. @@ -91,11 +93,11 @@ library(dplyr) library(ggplot2) # get antimicrobial results for drugs against a UTI: -ggplot(septic_patients \%>\% select(amox, nitr, fosf, trim, cipr)) + +ggplot(septic_patients \%>\% select(AMX, NIT, FOS, TMP, CIP)) + geom_rsi() # prettify the plot using some additional functions: -df <- septic_patients[, c("amox", "nitr", "fosf", "trim", "cipr")] +df <- septic_patients[, c("AMX", "NIT", "FOS", "TMP", "CIP")] ggplot(df) + geom_rsi() + scale_y_percent() + @@ -105,17 +107,17 @@ ggplot(df) + # or better yet, simplify this using the wrapper function - a single command: septic_patients \%>\% - select(amox, nitr, fosf, trim, cipr) \%>\% + select(AMX, NIT, FOS, TMP, CIP) \%>\% ggplot_rsi() # get only portions and no counts: septic_patients \%>\% - select(amox, nitr, fosf, trim, cipr) \%>\% + select(AMX, NIT, FOS, TMP, CIP) \%>\% ggplot_rsi(fun = portion_df) # add other ggplot2 parameters as you like: septic_patients \%>\% - select(amox, nitr, fosf, trim, cipr) \%>\% + select(AMX, NIT, FOS, TMP, CIP) \%>\% ggplot_rsi(width = 0.5, colour = "black", size = 1, @@ -130,19 +132,19 @@ septic_patients \%>\% # `age_group` is also a function of this package: group_by(age_group = age_groups(age)) \%>\% select(age_group, - cipr) \%>\% + CIP) \%>\% ggplot_rsi(x = "age_group") \donttest{ # for colourblind mode, use divergent colours from the viridis package: septic_patients \%>\% - select(amox, nitr, fosf, trim, cipr) \%>\% + select(AMX, NIT, FOS, TMP, CIP) \%>\% ggplot_rsi() + scale_fill_viridis_d() # it also supports groups (don't forget to use the group var on `x` or `facet`): septic_patients \%>\% - select(hospital_id, amox, nitr, fosf, trim, cipr) \%>\% + select(hospital_id, AMX, NIT, FOS, TMP, CIP) \%>\% group_by(hospital_id) \%>\% ggplot_rsi(x = hospital_id, facet = Antibiotic, @@ -166,7 +168,7 @@ septic_patients \%>\% # get short MO names (like "E. coli") mutate(mo = mo_shortname(mo, Becker = TRUE)) \%>\% # select this short name and some antiseptic drugs - select(mo, cfur, gent, cipr) \%>\% + select(mo, CXM, GEN, CIP) \%>\% # group by MO group_by(mo) \%>\% # plot the thing, putting MOs on the facet diff --git a/man/guess_ab_col.Rd b/man/guess_ab_col.Rd index 831c67d34..8770a4dc2 100644 --- a/man/guess_ab_col.Rd +++ b/man/guess_ab_col.Rd @@ -27,7 +27,7 @@ df <- data.frame(amox = "S", guess_ab_col(df, "amoxicillin") # [1] "amox" -guess_ab_col(df, "J01AA07") # ATC code of Tetracycline +guess_ab_col(df, "J01AA07") # ATC code of tetracycline # [1] "tetr" guess_ab_col(df, "J01AA07", verbose = TRUE) @@ -41,6 +41,6 @@ guess_ab_col(df, "ampicillin") # [1] "AMP_ND10" guess_ab_col(df, "J01CR02") # [1] "AMC_ED20" -guess_ab_col(df, as.atc("augmentin")) +guess_ab_col(df, as.ab("augmentin")) # [1] "AMC_ED20" } diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd index b632b9677..e6f71f213 100755 --- a/man/key_antibiotics.Rd +++ b/man/key_antibiotics.Rd @@ -6,19 +6,19 @@ \title{Key antibiotics for first \emph{weighted} isolates} \usage{ key_antibiotics(tbl, col_mo = NULL, universal_1 = guess_ab_col(tbl, - "amox"), universal_2 = guess_ab_col(tbl, "amcl"), - universal_3 = guess_ab_col(tbl, "cfur"), - universal_4 = guess_ab_col(tbl, "pita"), - universal_5 = guess_ab_col(tbl, "cipr"), - universal_6 = guess_ab_col(tbl, "trsu"), - GramPos_1 = guess_ab_col(tbl, "vanc"), GramPos_2 = guess_ab_col(tbl, - "teic"), GramPos_3 = guess_ab_col(tbl, "tetr"), - GramPos_4 = guess_ab_col(tbl, "eryt"), GramPos_5 = guess_ab_col(tbl, - "oxac"), GramPos_6 = guess_ab_col(tbl, "rifa"), - GramNeg_1 = guess_ab_col(tbl, "gent"), GramNeg_2 = guess_ab_col(tbl, - "tobr"), GramNeg_3 = guess_ab_col(tbl, "coli"), - GramNeg_4 = guess_ab_col(tbl, "cfot"), GramNeg_5 = guess_ab_col(tbl, - "cfta"), GramNeg_6 = guess_ab_col(tbl, "mero"), warnings = TRUE, ...) + "AMX"), universal_2 = guess_ab_col(tbl, "AMC"), + universal_3 = guess_ab_col(tbl, "CXM"), + universal_4 = guess_ab_col(tbl, "TZP"), + universal_5 = guess_ab_col(tbl, "CIP"), + universal_6 = guess_ab_col(tbl, "SXT"), GramPos_1 = guess_ab_col(tbl, + "VAN"), GramPos_2 = guess_ab_col(tbl, "TEC"), + GramPos_3 = guess_ab_col(tbl, "TCY"), GramPos_4 = guess_ab_col(tbl, + "ERY"), GramPos_5 = guess_ab_col(tbl, "OXA"), + GramPos_6 = guess_ab_col(tbl, "RIF"), GramNeg_1 = guess_ab_col(tbl, + "GEN"), GramNeg_2 = guess_ab_col(tbl, "TOB"), + GramNeg_3 = guess_ab_col(tbl, "COL"), GramNeg_4 = guess_ab_col(tbl, + "CTX"), GramNeg_5 = guess_ab_col(tbl, "CAZ"), + GramNeg_6 = guess_ab_col(tbl, "MEM"), warnings = TRUE, ...) key_antibiotics_equal(x, y, type = c("keyantibiotics", "points"), ignore_I = TRUE, points_threshold = 2, info = FALSE) diff --git a/man/mdro.Rd b/man/mdro.Rd index e31e14218..b5028ad88 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -7,46 +7,17 @@ \alias{eucast_exceptional_phenotypes} \title{Determine multidrug-resistant organisms (MDRO)} \usage{ -mdro(tbl, country = NULL, col_mo = NULL, info = TRUE, - amcl = guess_ab_col(), amik = guess_ab_col(), - amox = guess_ab_col(), ampi = guess_ab_col(), - azit = guess_ab_col(), aztr = guess_ab_col(), - cefa = guess_ab_col(), cfra = guess_ab_col(), - cfep = guess_ab_col(), cfot = guess_ab_col(), - cfox = guess_ab_col(), cfta = guess_ab_col(), - cftr = guess_ab_col(), cfur = guess_ab_col(), - chlo = guess_ab_col(), cipr = guess_ab_col(), - clar = guess_ab_col(), clin = guess_ab_col(), - clox = guess_ab_col(), coli = guess_ab_col(), - czol = guess_ab_col(), dapt = guess_ab_col(), - doxy = guess_ab_col(), erta = guess_ab_col(), - eryt = guess_ab_col(), fosf = guess_ab_col(), - fusi = guess_ab_col(), gent = guess_ab_col(), - imip = guess_ab_col(), kana = guess_ab_col(), - levo = guess_ab_col(), linc = guess_ab_col(), - line = guess_ab_col(), mero = guess_ab_col(), - metr = guess_ab_col(), mino = guess_ab_col(), - moxi = guess_ab_col(), nali = guess_ab_col(), - neom = guess_ab_col(), neti = guess_ab_col(), - nitr = guess_ab_col(), novo = guess_ab_col(), - norf = guess_ab_col(), oflo = guess_ab_col(), - peni = guess_ab_col(), pipe = guess_ab_col(), - pita = guess_ab_col(), poly = guess_ab_col(), - qida = guess_ab_col(), rifa = guess_ab_col(), - roxi = guess_ab_col(), siso = guess_ab_col(), - teic = guess_ab_col(), tetr = guess_ab_col(), - tica = guess_ab_col(), tige = guess_ab_col(), - tobr = guess_ab_col(), trim = guess_ab_col(), - trsu = guess_ab_col(), vanc = guess_ab_col(), verbose = FALSE) +mdro(x, country = NULL, col_mo = NULL, info = TRUE, + verbose = FALSE, ...) brmo(..., country = "nl") -mrgn(tbl, country = "de", ...) +mrgn(x, country = "de", ...) -eucast_exceptional_phenotypes(tbl, country = "EUCAST", ...) +eucast_exceptional_phenotypes(x, country = "EUCAST", ...) } \arguments{ -\item{tbl}{table with antibiotic columns, like e.g. \code{amox} and \code{amcl}} +\item{x}{table with antibiotic columns, like e.g. \code{AMX} and \code{AMC}} \item{country}{country code to determine guidelines. EUCAST rules will be used when left empty, see Details. Should be or a code from the \href{https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements}{list of ISO 3166-1 alpha-2 country codes}. Case-insensitive. Currently supported are \code{de} (Germany) and \code{nl} (the Netherlands).} @@ -54,129 +25,9 @@ eucast_exceptional_phenotypes(tbl, country = "EUCAST", ...) \item{info}{print progress} -\item{amcl}{column name of an antibiotic, see Antibiotics} - -\item{amik}{column name of an antibiotic, see Antibiotics} - -\item{amox}{column name of an antibiotic, see Antibiotics} - -\item{ampi}{column name of an antibiotic, see Antibiotics} - -\item{azit}{column name of an antibiotic, see Antibiotics} - -\item{aztr}{column name of an antibiotic, see Antibiotics} - -\item{cefa}{column name of an antibiotic, see Antibiotics} - -\item{cfra}{column name of an antibiotic, see Antibiotics} - -\item{cfep}{column name of an antibiotic, see Antibiotics} - -\item{cfot}{column name of an antibiotic, see Antibiotics} - -\item{cfox}{column name of an antibiotic, see Antibiotics} - -\item{cfta}{column name of an antibiotic, see Antibiotics} - -\item{cftr}{column name of an antibiotic, see Antibiotics} - -\item{cfur}{column name of an antibiotic, see Antibiotics} - -\item{chlo}{column name of an antibiotic, see Antibiotics} - -\item{cipr}{column name of an antibiotic, see Antibiotics} - -\item{clar}{column name of an antibiotic, see Antibiotics} - -\item{clin}{column name of an antibiotic, see Antibiotics} - -\item{clox}{column name of an antibiotic, see Antibiotics} - -\item{coli}{column name of an antibiotic, see Antibiotics} - -\item{czol}{column name of an antibiotic, see Antibiotics} - -\item{dapt}{column name of an antibiotic, see Antibiotics} - -\item{doxy}{column name of an antibiotic, see Antibiotics} - -\item{erta}{column name of an antibiotic, see Antibiotics} - -\item{eryt}{column name of an antibiotic, see Antibiotics} - -\item{fosf}{column name of an antibiotic, see Antibiotics} - -\item{fusi}{column name of an antibiotic, see Antibiotics} - -\item{gent}{column name of an antibiotic, see Antibiotics} - -\item{imip}{column name of an antibiotic, see Antibiotics} - -\item{kana}{column name of an antibiotic, see Antibiotics} - -\item{levo}{column name of an antibiotic, see Antibiotics} - -\item{linc}{column name of an antibiotic, see Antibiotics} - -\item{line}{column name of an antibiotic, see Antibiotics} - -\item{mero}{column name of an antibiotic, see Antibiotics} - -\item{metr}{column name of an antibiotic, see Antibiotics} - -\item{mino}{column name of an antibiotic, see Antibiotics} - -\item{moxi}{column name of an antibiotic, see Antibiotics} - -\item{nali}{column name of an antibiotic, see Antibiotics} - -\item{neom}{column name of an antibiotic, see Antibiotics} - -\item{neti}{column name of an antibiotic, see Antibiotics} - -\item{nitr}{column name of an antibiotic, see Antibiotics} - -\item{novo}{column name of an antibiotic, see Antibiotics} - -\item{norf}{column name of an antibiotic, see Antibiotics} - -\item{oflo}{column name of an antibiotic, see Antibiotics} - -\item{peni}{column name of an antibiotic, see Antibiotics} - -\item{pipe}{column name of an antibiotic, see Antibiotics} - -\item{pita}{column name of an antibiotic, see Antibiotics} - -\item{poly}{column name of an antibiotic, see Antibiotics} - -\item{qida}{column name of an antibiotic, see Antibiotics} - -\item{rifa}{column name of an antibiotic, see Antibiotics} - -\item{roxi}{column name of an antibiotic, see Antibiotics} - -\item{siso}{column name of an antibiotic, see Antibiotics} - -\item{teic}{column name of an antibiotic, see Antibiotics} - -\item{tetr}{column name of an antibiotic, see Antibiotics} - -\item{tica}{column name of an antibiotic, see Antibiotics} - -\item{tige}{column name of an antibiotic, see Antibiotics} - -\item{tobr}{column name of an antibiotic, see Antibiotics} - -\item{trim}{column name of an antibiotic, see Antibiotics} - -\item{trsu}{column name of an antibiotic, see Antibiotics} - -\item{vanc}{column name of an antibiotic, see Antibiotics} - \item{verbose}{print additional info: missing antibiotic columns per parameter} -\item{...}{parameters that are passed on to methods} +\item{...}{column name of an antibiotic, see section Antibiotics} } \value{ Ordered factor with levels \code{Negative < Positive, unconfirmed < Positive}. @@ -189,72 +40,74 @@ When \code{country} will be left blank, guidelines will be taken from EUCAST Exp } \section{Antibiotics}{ -To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive) or use \code{NULL} to skip a column (e.g. \code{tica = NULL}). Non-existing columns will anyway be skipped with a warning. +To define antibiotics column names, leave as it is to determine it automatically with \code{\link{guess_ab_col}} or input a text (case-insensitive), or use \code{NULL} to skip a column (e.g. \code{TIC = NULL} to skip ticarcillin). Manually defined but non-existing columns will be skipped with a warning. -Abbrevations of the column containing antibiotics in the form: \strong{abbreviation}: generic name (\emph{ATC code}) +Available abbrevations of the column containing antibiotics in the form '\strong{antimicrobial ID}: name (\emph{ATC code})': - \strong{amcl}: amoxicillin+clavulanic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR02}{J01CR02}), - \strong{amik}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), - \strong{amox}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), - \strong{ampi}: ampicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA01}{J01CA01}), - \strong{azit}: azithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA10}{J01FA10}), - \strong{azlo}: azlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA09}{J01CA09}), - \strong{aztr}: aztreonam (\href{https://www.whocc.no/atc_ddd_index/?code=J01DF01}{J01DF01}), - \strong{cefa}: cefaloridine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB02}{J01DB02}), - \strong{cfep}: cefepime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DE01}{J01DE01}), - \strong{cfot}: cefotaxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD01}{J01DD01}), - \strong{cfox}: cefoxitin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC01}{J01DC01}), - \strong{cfra}: cefradine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB09}{J01DB09}), - \strong{cfta}: ceftazidime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD02}{J01DD02}), - \strong{cftr}: ceftriaxone (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD04}{J01DD04}), - \strong{cfur}: cefuroxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC02}{J01DC02}), - \strong{chlo}: chloramphenicol (\href{https://www.whocc.no/atc_ddd_index/?code=J01BA01}{J01BA01}), - \strong{cipr}: ciprofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA02}{J01MA02}), - \strong{clar}: clarithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA09}{J01FA09}), - \strong{clin}: clindamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF01}{J01FF01}), - \strong{clox}: flucloxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CF05}{J01CF05}), - \strong{coli}: colistin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB01}{J01XB01}), - \strong{czol}: cefazolin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB04}{J01DB04}), - \strong{dapt}: daptomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX09}{J01XX09}), - \strong{doxy}: doxycycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA02}{J01AA02}), - \strong{erta}: ertapenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH03}{J01DH03}), - \strong{eryt}: erythromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA01}{J01FA01}), - \strong{fosf}: fosfomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX01}{J01XX01}), - \strong{fusi}: fusidic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XC01}{J01XC01}), - \strong{gent}: gentamicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB03}{J01GB03}), - \strong{imip}: imipenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH51}{J01DH51}), - \strong{kana}: kanamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB04}{J01GB04}), - \strong{levo}: levofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA12}{J01MA12}), - \strong{linc}: lincomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF02}{J01FF02}), - \strong{line}: linezolid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX08}{J01XX08}), - \strong{mero}: meropenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH02}{J01DH02}), - \strong{mezl}: mezlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA10}{J01CA10}), - \strong{mino}: minocycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA08}{J01AA08}), - \strong{moxi}: moxifloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01MA14}), - \strong{nali}: nalidixic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01MB02}{J01MB02}), - \strong{neom}: neomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB05}{J01GB05}), - \strong{neti}: netilmicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB07}{J01GB07}), - \strong{nitr}: nitrofurantoin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XE01}{J01XE01}), - \strong{norf}: norfloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA06}{J01MA06}), - \strong{novo}: novobiocin (an ATCvet code: \href{https://www.whocc.no/atc_ddd_index/?code=QJ01XX95}{QJ01XX95}), - \strong{oflo}: ofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01MA01}), - \strong{peni}: (benzyl)penicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CE01}{J01CE01}), - \strong{pipe}: piperacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA12}{J01CA12}), - \strong{pita}: piperacillin+tazobactam (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR05}{J01CR05}), - \strong{poly}: polymyxin B (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB02}{J01XB02}), - \strong{pris}: pristinamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG01}{J01FG01}), - \strong{qida}: quinupristin/dalfopristin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG02}{J01FG02}), - \strong{rifa}: rifampicin (\href{https://www.whocc.no/atc_ddd_index/?code=J04AB02}{J04AB02}), - \strong{roxi}: roxithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA06}{J01FA06}), - \strong{siso}: sisomicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB08}{J01GB08}), - \strong{teic}: teicoplanin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA02}{J01XA02}), - \strong{tetr}: tetracycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA07}{J01AA07}), - \strong{tica}: ticarcillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA13}{J01CA13}), - \strong{tige}: tigecycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA12}{J01AA12}), - \strong{tobr}: tobramycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB01}{J01GB01}), - \strong{trim}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), - \strong{trsu}: sulfamethoxazole and trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), - \strong{vanc}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). + \strong{AMC}: amoxicillin/clavulanic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR02}{J01CR02}), + \strong{AMK}: amikacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB06}{J01GB06}), + \strong{AMX}: amoxicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA04}{J01CA04}), + \strong{AMP}: ampicillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA01}{J01CA01}), + \strong{AZM}: azithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA10}{J01FA10}), + \strong{AZL}: azlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA09}{J01CA09}), + \strong{ATM}: aztreonam (\href{https://www.whocc.no/atc_ddd_index/?code=J01DF01}{J01DF01}), + \strong{RID}: cefaloridine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB02}{J01DB02}), + \strong{FEP}: cefepime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DE01}{J01DE01}), + \strong{CTX}: cefotaxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD01}{J01DD01}), + \strong{FOX}: cefoxitin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC01}{J01DC01}), + \strong{CED}: cefradine (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB09}{J01DB09}), + \strong{CAZ}: ceftazidime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD02}{J01DD02}), + \strong{CRO}: ceftriaxone (\href{https://www.whocc.no/atc_ddd_index/?code=J01DD04}{J01DD04}), + \strong{CXM}: cefuroxime (\href{https://www.whocc.no/atc_ddd_index/?code=J01DC02}{J01DC02}), + \strong{CHL}: chloramphenicol (\href{https://www.whocc.no/atc_ddd_index/?code=J01BA01}{J01BA01}), + \strong{CIP}: ciprofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA02}{J01MA02}), + \strong{CLR}: clarithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA09}{J01FA09}), + \strong{CLI}: clindamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF01}{J01FF01}), + \strong{FLC}: flucloxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CF05}{J01CF05}), + \strong{COL}: colistin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB01}{J01XB01}), + \strong{CZO}: cefazolin (\href{https://www.whocc.no/atc_ddd_index/?code=J01DB04}{J01DB04}), + \strong{DAP}: daptomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX09}{J01XX09}), + \strong{DOX}: doxycycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA02}{J01AA02}), + \strong{ETP}: ertapenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH03}{J01DH03}), + \strong{ERY}: erythromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA01}{J01FA01}), + \strong{FOS}: fosfomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX01}{J01XX01}), + \strong{FUS}: fusidic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XC01}{J01XC01}), + \strong{GEN}: gentamicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB03}{J01GB03}), + \strong{IPM}: imipenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH51}{J01DH51}), + \strong{KAN}: kanamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB04}{J01GB04}), + \strong{LVX}: levofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA12}{J01MA12}), + \strong{LIN}: lincomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FF02}{J01FF02}), + \strong{LNZ}: linezolid (\href{https://www.whocc.no/atc_ddd_index/?code=J01XX08}{J01XX08}), + \strong{MEM}: meropenem (\href{https://www.whocc.no/atc_ddd_index/?code=J01DH02}{J01DH02}), + \strong{MEZ}: mezlocillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA10}{J01CA10}), + \strong{MNO}: minocycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA08}{J01AA08}), + \strong{MFX}: moxifloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01MA14}), + \strong{MTR}: metronidazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA14}{J01XD01}), + \strong{NAL}: nalidixic acid (\href{https://www.whocc.no/atc_ddd_index/?code=J01MB02}{J01MB02}), + \strong{NEO}: neomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB05}{J01GB05}), + \strong{NET}: netilmicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB07}{J01GB07}), + \strong{NIT}: nitrofurantoin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XE01}{J01XE01}), + \strong{NOR}: norfloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA06}{J01MA06}), + \strong{NOV}: novobiocin (an ATCvet code: \href{https://www.whocc.no/atc_ddd_index/?code=QJ01XX95}{QJ01XX95}), + \strong{OFX}: ofloxacin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01MA01}), + \strong{OXA}: oxacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01MA01}{J01CF04}), + \strong{PEN}: penicillin G (\href{https://www.whocc.no/atc_ddd_index/?code=J01CE01}{J01CE01}), + \strong{PIP}: piperacillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA12}{J01CA12}), + \strong{TZP}: piperacillin/tazobactam (\href{https://www.whocc.no/atc_ddd_index/?code=J01CR05}{J01CR05}), + \strong{PLB}: polymyxin B (\href{https://www.whocc.no/atc_ddd_index/?code=J01XB02}{J01XB02}), + \strong{PRI}: pristinamycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG01}{J01FG01}), + \strong{QDA}: quinupristin/dalfopristin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FG02}{J01FG02}), + \strong{RIF}: rifampicin (\href{https://www.whocc.no/atc_ddd_index/?code=J04AB02}{J04AB02}), + \strong{RXT}: roxithromycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01FA06}{J01FA06}), + \strong{SIS}: sisomicin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB08}{J01GB08}), + \strong{TEC}: teicoplanin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA02}{J01XA02}), + \strong{TCY}: tetracycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA07}{J01AA07}), + \strong{TIC}: ticarcillin (\href{https://www.whocc.no/atc_ddd_index/?code=J01CA13}{J01CA13}), + \strong{TGC}: tigecycline (\href{https://www.whocc.no/atc_ddd_index/?code=J01AA12}{J01AA12}), + \strong{TOB}: tobramycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01GB01}{J01GB01}), + \strong{TMP}: trimethoprim (\href{https://www.whocc.no/atc_ddd_index/?code=J01EA01}{J01EA01}), + \strong{SXT}: trimethoprim/sulfamethoxazole (\href{https://www.whocc.no/atc_ddd_index/?code=J01EE01}{J01EE01}), + \strong{VAN}: vancomycin (\href{https://www.whocc.no/atc_ddd_index/?code=J01XA01}{J01XA01}). } \section{Read more on our website!}{ diff --git a/man/mo_property.Rd b/man/mo_property.Rd index e917ea5e7..6fccb9cd9 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -92,13 +92,10 @@ All functions will return the most recently known taxonomic property according t The Gram stain - \code{mo_gramstain()} - will be determined on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002) who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram positive - all other bacteria are considered Gram negative. Species outside the kingdom of Bacteria will return a value \code{NA}. +All output will be \link{translate}d where possible. + The function \code{mo_url()} will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species. } -\section{Supported languages}{ - -Supported languages are \code{"en"} (English), \code{"de"} (German), \code{"nl"} (Dutch), \code{"es"} (Spanish), \code{"it"} (Italian), \code{"fr"} (French), and \code{"pt"} (Portuguese). -} - \section{Catalogue of Life}{ \if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} @@ -111,7 +108,7 @@ This package contains the complete taxonomic tree of almost all microorganisms ( [1] Becker K \emph{et al.} \strong{Coagulase-Negative Staphylococci}. 2014. Clin Microbiol Rev. 27(4): 870–926. \url{https://dx.doi.org/10.1128/CMR.00109-13} -[2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the S. aureus complex, S. argenteus and S. schweitzeri: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).}. 2019. Clin Microbiol Infect. 2019 Mar 11. \url{https://doi.org/10.1016/j.cmi.2019.02.028} +[2] Becker K \emph{et al.} \strong{Implications of identifying the recently defined members of the \emph{S. aureus} complex, \emph{S. argenteus} and \emph{S. schweitzeri}: A position paper of members of the ESCMID Study Group for staphylococci and Staphylococcal Diseases (ESGS).} 2019. Clin Microbiol Infect. \url{https://doi.org/10.1016/j.cmi.2019.02.028} [3] Lancefield RC \strong{A serological differentiation of human and other groups of hemolytic streptococci}. 1933. J Exp Med. 57(4): 571–95. \url{https://dx.doi.org/10.1084/jem.57.4.571} @@ -142,7 +139,7 @@ mo_shortname("E. coli") # "E. coli" mo_gramstain("E. coli") # "Gram negative" mo_type("E. coli") # "Bacteria" (equal to kingdom) mo_rank("E. coli") # "species" -mo_url("E. coli") # get the direct url to the Catalogue of Life +mo_url("E. coli") # get the direct url to the online database entry ## scientific reference mo_ref("E. coli") # "Castellani et al., 1919" @@ -200,7 +197,7 @@ mo_fullname("S. pyogenes", language = "nl") # "Streptococcus groep A" -# get a list with the complete taxonomy (kingdom to subspecies) +# get a list with the complete taxonomy (from kingdom to subspecies) mo_taxonomy("E. coli") } \seealso{ diff --git a/man/portion.Rd b/man/portion.Rd index 705acf03d..fa81cdaca 100644 --- a/man/portion.Rd +++ b/man/portion.Rd @@ -30,8 +30,8 @@ portion_SI(..., minimum = 30, as_percent = FALSE, portion_S(..., minimum = 30, as_percent = FALSE, also_single_tested = FALSE) -portion_df(data, translate_ab = getOption("get_antibiotic_names", - "official"), minimum = 30, as_percent = FALSE, combine_IR = FALSE) +portion_df(data, translate_ab = "name", language = get_locale(), + minimum = 30, as_percent = FALSE, combine_IR = FALSE) } \arguments{ \item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.} @@ -44,7 +44,9 @@ portion_df(data, translate_ab = getOption("get_antibiotic_names", \item{data}{a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}})} -\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{abname}}. This can be set with \code{\link{getOption}("get_antibiotic_names")}.} +\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations to, using \code{\link{ab_property}}} + +\item{language}{language of the returned text, defaults to system language (see \code{\link{get_locale}}) and can also be set with \code{\link{getOption}("AMR_locale")}. Use \code{language = NULL} or \code{language = ""} to prevent translation.} \item{combine_IR}{a logical to indicate whether all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)} } @@ -62,8 +64,6 @@ These functions can be used to calculate the (co-)resistance of microbial isolat These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. \emph{Low counts can infuence the outcome - these \code{portion} functions may camouflage this, since they only return the portion albeit being dependent on the \code{minimum} parameter.} \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}. - -The old \code{\link{rsi}} function is still available for backwards compatibility but is deprecated. \if{html}{ \cr\cr To calculate the probability (\emph{p}) of susceptibility of one antibiotic, we use this formula: @@ -89,63 +89,63 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https:// ?septic_patients # Calculate resistance -portion_R(septic_patients$amox) -portion_IR(septic_patients$amox) +portion_R(septic_patients$AMX) +portion_IR(septic_patients$AMX) # Or susceptibility -portion_S(septic_patients$amox) -portion_SI(septic_patients$amox) +portion_S(septic_patients$AMX) +portion_SI(septic_patients$AMX) # Do the above with pipes: library(dplyr) -septic_patients \%>\% portion_R(amox) -septic_patients \%>\% portion_IR(amox) -septic_patients \%>\% portion_S(amox) -septic_patients \%>\% portion_SI(amox) +septic_patients \%>\% portion_R(AMX) +septic_patients \%>\% portion_IR(AMX) +septic_patients \%>\% portion_S(AMX) +septic_patients \%>\% portion_SI(AMX) septic_patients \%>\% group_by(hospital_id) \%>\% - summarise(p = portion_S(cipr), - n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr + summarise(p = portion_S(CIP), + n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr septic_patients \%>\% group_by(hospital_id) \%>\% - summarise(R = portion_R(cipr, as_percent = TRUE), - I = portion_I(cipr, as_percent = TRUE), - S = portion_S(cipr, as_percent = TRUE), - n1 = count_all(cipr), # the actual total; sum of all three - n2 = n_rsi(cipr), # same - analogous to n_distinct + summarise(R = portion_R(CIP, as_percent = TRUE), + I = portion_I(CIP, as_percent = TRUE), + S = portion_S(CIP, as_percent = TRUE), + n1 = count_all(CIP), # the actual total; sum of all three + n2 = n_rsi(CIP), # same - analogous to n_distinct total = n()) # NOT the number of tested isolates! # Calculate co-resistance between amoxicillin/clav acid and gentamicin, # so we can see that combination therapy does a lot more than mono therapy: -septic_patients \%>\% portion_S(amcl) # S = 71.4\% -septic_patients \%>\% count_all(amcl) # n = 1879 +septic_patients \%>\% portion_S(AMC) # S = 71.4\% +septic_patients \%>\% count_all(AMC) # n = 1879 -septic_patients \%>\% portion_S(gent) # S = 74.0\% -septic_patients \%>\% count_all(gent) # n = 1855 +septic_patients \%>\% portion_S(GEN) # S = 74.0\% +septic_patients \%>\% count_all(GEN) # n = 1855 -septic_patients \%>\% portion_S(amcl, gent) # S = 92.3\% -septic_patients \%>\% count_all(amcl, gent) # n = 1798 +septic_patients \%>\% portion_S(AMC, GEN) # S = 92.3\% +septic_patients \%>\% count_all(AMC, GEN) # n = 1798 septic_patients \%>\% group_by(hospital_id) \%>\% - summarise(cipro_p = portion_S(cipr, as_percent = TRUE), - cipro_n = count_all(cipr), - genta_p = portion_S(gent, as_percent = TRUE), - genta_n = count_all(gent), - combination_p = portion_S(cipr, gent, as_percent = TRUE), - combination_n = count_all(cipr, gent)) + summarise(cipro_p = portion_S(CIP, as_percent = TRUE), + cipro_n = count_all(CIP), + genta_p = portion_S(GEN, as_percent = TRUE), + genta_n = count_all(GEN), + combination_p = portion_S(CIP, GEN, as_percent = TRUE), + combination_n = count_all(CIP, GEN)) # Get portions S/I/R immediately of all rsi columns septic_patients \%>\% - select(amox, cipr) \%>\% + select(AMX, CIP) \%>\% portion_df(translate = FALSE) # It also supports grouping variables septic_patients \%>\% - select(hospital_id, amox, cipr) \%>\% + select(hospital_id, AMX, CIP) \%>\% group_by(hospital_id) \%>\% portion_df(translate = FALSE) @@ -156,8 +156,8 @@ septic_patients \%>\% my_table \%>\% filter(first_isolate == TRUE, genus == "Helicobacter") \%>\% - summarise(p = portion_S(amox, metr), # amoxicillin with metronidazole - n = count_all(amox, metr)) + summarise(p = portion_S(AMX, MTR), # amoxicillin with metronidazole + n = count_all(AMX, MTR)) } } \seealso{ diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index dae9b797c..cc98afd7b 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -86,7 +86,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https:// } \examples{ -x <- resistance_predict(septic_patients, col_ab = "amox", year_min = 2010) +x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010) plot(x) ggplot_rsi_predict(x) @@ -95,7 +95,7 @@ library(dplyr) x <- septic_patients \%>\% filter_first_isolate() \%>\% filter(mo_genus(mo) == "Staphylococcus") \%>\% - resistance_predict("peni") + resistance_predict("PEN") plot(x) @@ -109,7 +109,7 @@ if (!require(ggplot2)) { data <- septic_patients \%>\% filter(mo == as.mo("E. coli")) \%>\% - resistance_predict(col_ab = "amox", + resistance_predict(col_ab = "AMX", col_date = "date", info = FALSE, minimum = 15) diff --git a/man/rsi.Rd b/man/rsi.Rd deleted file mode 100644 index 9a96902b5..000000000 --- a/man/rsi.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/portion.R -\name{rsi} -\alias{rsi} -\title{Calculate resistance of isolates} -\usage{ -rsi(ab1, ab2 = NULL, interpretation = "IR", minimum = 30, - as_percent = FALSE, ...) -} -\arguments{ -\item{ab1, ab2}{vector (or column) with antibiotic interpretations. It will be transformed internally with \code{\link{as.rsi}} if needed.} - -\item{interpretation}{antimicrobial interpretation to check for} - -\item{minimum}{the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.} - -\item{as_percent}{a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character). A value of \code{0.123456} will then be returned as \code{"12.3\%"}.} - -\item{...}{deprecated parameters to support usage on older versions} -} -\description{ -This function is deprecated. Use the \code{\link{portion}} functions instead. -} diff --git a/man/rsi_translation.Rd b/man/rsi_translation.Rd new file mode 100644 index 000000000..e89c881e9 --- /dev/null +++ b/man/rsi_translation.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{rsi_translation} +\alias{rsi_translation} +\title{Data set for RSI interpretation} +\format{A \code{\link{data.frame}} with 11,559 observations and 9 variables: +\describe{ + \item{\code{guideline}}{Name of the guideline} + \item{\code{mo}}{Microbial ID, see \code{\link{as.mo}}} + \item{\code{ab}}{Antibiotic ID, see \code{\link{as.ab}}} + \item{\code{ref_tbl}}{Info about where the guideline rule can be found} + \item{\code{S_mic}}{Lowest MIC value that leads to "S"} + \item{\code{R_mic}}{Highest MIC value that leads to "R"} + \item{\code{dose_disk}}{Dose of the used disk diffusion method} + \item{\code{S_disk}}{Lowest number of millimeters that leads to "S"} + \item{\code{R_disk}}{Highest number of millimeters that leads to "R"} +}} +\usage{ +rsi_translation +} +\description{ +Data set to interpret MIC and disk diffusion to RSI values. Included guidelines are CLSI (2011-2019) and EUCAST (2011-2019). Use \code{\link{as.rsi}} to transform MICs or disks measurements to RSI values. +} +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\keyword{datasets} diff --git a/man/translate.Rd b/man/translate.Rd new file mode 100644 index 000000000..90a874823 --- /dev/null +++ b/man/translate.Rd @@ -0,0 +1,55 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_locale.R +\name{translate} +\alias{translate} +\alias{get_locale} +\title{Translate strings from AMR package} +\usage{ +get_locale() +} +\description{ +For language-dependent output of AMR functions, like \code{\link{mo_fullname}} and \code{\link{mo_type}}. +} +\details{ +Strings will be translated to foreign languages if they are defined in a local translation file. This file comes with this package and can be found when running: + +\code{system.file("translations.tsv", package = "AMR")} + +This file will be read by all functions where a translated output can be desired, like all \code{\link{mo_property}} functions (\code{\link{mo_fullname}}, \code{\link{mo_type}}, etc.). Please suggest your own translations \href{https://gitlab.com/msberends/AMR/issues/new?issue[title]=Translation suggestion}{by creating a new issue on our repository}. + +The system language will be used at default, if supported, using \code{\link{get_locale}}. The system language can be overwritten with \code{\link{getOption}("AMR_locale")}. +} +\section{Read more on our website!}{ + +On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a comprehensive tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}. +} + +\examples{ +# The 'language' parameter of below functions +# will be set automatically to your system language +# with get_locale() + +# English +mo_fullname("CoNS", language = "en") +#> "Coagulase-negative Staphylococcus (CoNS)" + +# German +mo_fullname("CoNS", language = "de") +#> "Koagulase-negative Staphylococcus (KNS)" + +# Dutch +mo_fullname("CoNS", language = "nl") +#> "Coagulase-negatieve Staphylococcus (CNS)" + +# Spanish +mo_fullname("CoNS", language = "es") +#> "Staphylococcus coagulasa negativo (SCN)" + +# Italian +mo_fullname("CoNS", language = "it") +#> "Staphylococcus negativo coagulasi (CoNS)" + +# Portuguese +mo_fullname("CoNS", language = "pt") +#> "Staphylococcus coagulase negativo (CoNS)" +} diff --git a/pkgdown/extra.js b/pkgdown/extra.js index 876bc3fb5..35858b3a1 100644 --- a/pkgdown/extra.js +++ b/pkgdown/extra.js @@ -24,6 +24,10 @@ // Add updated Font Awesome 5.6.3 library $('head').append(''); +// Email template for new GitLab issues +//https://stackoverflow.com/a/33190494/4575331 +//incoming+msberends-amr-9011429-5miwzuo1xo70wbz9r6fwv4dmg-issue@incoming.gitlab.com + // Edit footer $( document ).ready(function() { diff --git a/reproduction_of_antibiotics.R b/reproduction_of_antibiotics.R index b1a657145..f7f0e2cb5 100644 --- a/reproduction_of_antibiotics.R +++ b/reproduction_of_antibiotics.R @@ -1,7 +1,145 @@ -# WORK IN PROGRESS -------------------------------------------------------- +library(dplyr) -# vector with official names, return vector with CIDs +# got EARS-Net codes (= ECDC/WHO codes) from here: + +# Installed WHONET 2019 software on Windows (http://www.whonet.org/software.html), +# opened C:\WHONET\Codes\WHONETCodes.mdb in MS Access +# and exported table 'DRGLST' to MS Excel +library(readxl) +DRGLST <- read_excel("DRGLST.xlsx") +abx <- DRGLST %>% + select(ab = WHON5_CODE, + name = ANTIBIOTIC) %>% + # remove the ones without WHONET code + filter(!is.na(ab)) %>% + distinct(name, .keep_all = TRUE) %>% + # add the ones without WHONET code + bind_rows( + DRGLST %>% + select(ab = WHON5_CODE, + name = ANTIBIOTIC) %>% + filter(is.na(ab)) %>% + distinct(name, .keep_all = TRUE) + # add new ab code later + ) %>% + arrange(name) + +# add old ATC codes +ab_old <- AMR::antibiotics %>% + mutate(official = gsub("( and |, )", "/", official), + abbr = tolower(paste(ifelse(is.na(abbr), "", abbr), + ifelse(is.na(certe), "", certe), + ifelse(is.na(umcg), "", umcg), + sep = "|"))) +for (i in 1:nrow(ab_old)) { + abbr <- ab_old[i, "abbr"] + abbr <- strsplit(abbr, "|", fixed = TRUE) %>% unlist() %>% unique() + abbr <- abbr[abbr != ""] + #print(abbr) + if (length(abbr) == 0) { + ab_old[i, "abbr"] <- NA_character_ + } else { + ab_old[i, "abbr"] <- paste(abbr, collapse = "|") + } +} + +# create reference data set: to be able to map ab to atc +abx_atc1 <- abx %>% + mutate(name_lower = tolower(name)) %>% + left_join(ab_old %>% + select(ears_net, atc), by = c(ab = "ears_net")) %>% + rename(atc1 = atc) %>% + left_join(ab_old %>% + mutate(official = gsub(", combinations", "", official, fixed = TRUE)) %>% + transmute(official = tolower(official), atc), by = c(name_lower = "official")) %>% + rename(atc2 = atc) %>% + left_join(ab_old %>% + mutate(official = gsub(", combinations", "", official, fixed = TRUE)) %>% + mutate(official = gsub("f", "ph", official)) %>% + transmute(official = tolower(official), atc), by = c(name_lower = "official")) %>% + rename(atc3 = atc) %>% + left_join(ab_old %>% + mutate(official = gsub(", combinations", "", official, fixed = TRUE)) %>% + mutate(official = gsub("t", "th", official)) %>% + transmute(official = tolower(official), atc), by = c(name_lower = "official")) %>% + rename(atc4 = atc) %>% + left_join(ab_old %>% + mutate(official = gsub(", combinations", "", official, fixed = TRUE)) %>% + mutate(official = gsub("f", "ph", official)) %>% + mutate(official = gsub("t", "th", official)) %>% + transmute(official = tolower(official), atc), by = c(name_lower = "official")) %>% + rename(atc5 = atc) %>% + left_join(ab_old %>% + mutate(official = gsub(", combinations", "", official, fixed = TRUE)) %>% + mutate(official = gsub("f", "ph", official)) %>% + mutate(official = gsub("t", "th", official)) %>% + mutate(official = gsub("ine$", "in", official)) %>% + transmute(official = tolower(official), atc), by = c(name_lower = "official")) %>% + rename(atc6 = atc) %>% + mutate(atc = case_when(!is.na(atc1) ~ atc1, + !is.na(atc2) ~ atc2, + !is.na(atc3) ~ atc3, + !is.na(atc4) ~ atc4, + !is.na(atc4) ~ atc5, + TRUE ~ atc6)) %>% + distinct(ab, name, .keep_all = TRUE) %>% + select(ab, atc, name) + +abx_atc2 <- ab_old %>% + filter(!atc %in% abx_atc1$atc, + is.na(ears_net), + !is.na(atc_group1), + !atc_group1 %like% ("virus|vaccin|viral|immun"), + !official %like% "(combinations| with )") %>% + mutate(ab = NA_character_) %>% + as.data.frame(stringsAsFactors = FALSE) %>% + select(ab, atc, name = official) + +abx2 <- bind_rows(abx_atc1, abx_atc2) + +rm(abx_atc1) +rm(abx_atc2) + +abx2$ab[is.na(abx2$ab)] <- toupper(abbreviate(gsub("[/0-9-]", + " ", + abx2$name[is.na(abx2$ab)]), + minlength = 3, + method = "left.kept", + strict = TRUE)) + +n_distinct(abx2$ab) + +abx2 <- abx2 %>% arrange(ab) +seqnr <- 0 +# add follow up nrs +for (i in 2:nrow(abx2)) { + if (abx2[i, "ab"] == abx2[i - 1, "ab"]) { + seqnr <- seqnr + 1 + abx2[i, "seqnr"] <- seqnr + } else { + seqnr <- 0 + } +} +for (i in 2:nrow(abx2)) { + if (!is.na(abx2[i, "seqnr"])) { + abx2[i, "ab"] <- paste0(abx2[i, "ab"], abx2[i, "seqnr"]) + } +} +abx2 <- abx2 %>% select(-seqnr) %>% arrange(name) + +# everything unique?? +nrow(abx2) == n_distinct(abx2$ab) + +# get ATC properties +abx2 <- abx2 %>% + left_join(ab_old %>% + select(atc, abbr, atc_group1, atc_group2, + oral_ddd, oral_units, iv_ddd, iv_units)) + +abx2$abbr <- lapply(as.list(abx2$abbr), function(x) unlist(strsplit(x, "|", fixed = TRUE))) + +# vector with official names, returns vector with CIDs get_CID <- function(ab) { CID <- rep(NA_integer_, length(ab)) p <- progress_estimated(n = length(ab), min_time = 0) @@ -10,49 +148,150 @@ get_CID <- function(ab) { CID[i] <- tryCatch( data.table::fread(paste0("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/", - ab[i], + URLencode(ab[i], reserved = TRUE), "/cids/TXT?name_type=complete"), showProgress = FALSE)[[1]][1], error = function(e) NA_integer_) - Sys.sleep(0.2) + if (is.na(CID[i])) { + # try with removing the text in brackets + CID[i] <- tryCatch( + data.table::fread(paste0("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/", + URLencode(trimws(gsub("[(].*[)]", "", ab[i])), reserved = TRUE), + "/cids/TXT?name_type=complete"), + showProgress = FALSE)[[1]][1], + error = function(e) NA_integer_) + } + if (is.na(CID[i])) { + # try match on word and take the lowest CID value (sorted) + ab[i] <- gsub("[^a-z0-9]+", " ", ab[i], ignore.case = TRUE) + CID[i] <- tryCatch( + data.table::fread(paste0("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/", + URLencode(ab[i], reserved = TRUE), + "/cids/TXT?name_type=word"), + showProgress = FALSE)[[1]][1], + error = function(e) NA_integer_) + } + Sys.sleep(0.1) } CID } -# returns vector with synonyms (brand names) for a single CID +# get CIDs (2-3 min) +CIDs <- get_CID(abx2$name) +# These could not be found: +abx2[is.na(CIDs),] %>% View() + +# returns list with synonyms (brand names), with CIDs as names get_synonyms <- function(CID, clean = TRUE) { + synonyms <- rep(NA_character_, length(CID)) p <- progress_estimated(n = length(CID), min_time = 0) - p$tick()$print() - synonyms_txt <- tryCatch( - data.table::fread(paste0("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastidentity/cid/", - CID, - "/synonyms/TXT"), - sep = "\n", - showProgress = FALSE)[[1]], - error = function(e) NA_character_) + for (i in 1:length(CID)) { + p$tick()$print() - if (clean == TRUE) { - # remove txt between brackets - synonyms_txt <- trimws(gsub("[(].*[)]", "", gsub("[[].*[]]", "", synonyms_txt))) - # only length 6 to 20 and no txt with reading marks or numbers - synonyms_txt <- synonyms_txt[nchar(synonyms_txt) %in% c(6:20) - & !synonyms_txt %like% "[-&{},_0-9]"] - synonyms_txt <- unlist(strsplit(synonyms_txt, ";", fixed = TRUE)) + synonyms_txt <- "" + + if (is.na(CID[i])) { + next + } + + synonyms_txt <- tryCatch( + data.table::fread(paste0("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/fastidentity/cid/", + CID[i], + "/synonyms/TXT"), + sep = "\n", + showProgress = FALSE)[[1]], + error = function(e) NA_character_) + + Sys.sleep(0.1) + + if (clean == TRUE) { + # remove text between brackets + synonyms_txt <- trimws(gsub("[(].*[)]", "", + gsub("[[].*[]]", "", + gsub("[(].*[]]", "", + gsub("[[].*[)]", "", synonyms_txt))))) + synonyms_txt <- gsub("Co-", "Co", synonyms_txt, fixed = TRUE) + # only length 6 to 20 and no txt with reading marks or numbers and must start with capital letter (= brand) + synonyms_txt <- synonyms_txt[nchar(synonyms_txt) %in% c(6:20) + & !grepl("[-&{},_0-9/]", synonyms_txt) + & grepl("^[A-Z]", synonyms_txt, ignore.case = FALSE)] + synonyms_txt <- unlist(strsplit(synonyms_txt, ";", fixed = TRUE)) + } + synonyms_txt <- unique(trimws(synonyms_txt[tolower(synonyms_txt) %in% unique(tolower(synonyms_txt))])) + synonyms[i] <- list(sort(synonyms_txt)) } - synonyms_txt <- synonyms_txt[tolower(synonyms_txt) %in% unique(tolower(synonyms_txt))] - sort(synonyms_txt) + names(synonyms) <- CID + synonyms } -CIDs <- get_CID(antibiotics$official) -synonyms <- character(length(CIDs)) -p <- progress_estimated(n = length(synonyms), min_time = 0) -for (i in 365:length(synonyms)) { - #p$tick()$print() - if (!is.na(CIDs[i])) { - synonyms[i] <- paste(get_synonyms(CIDs[i]), collapse = "|") - } -} +# get brand names (2-3 min) +synonyms <- get_synonyms(CIDs) +synonyms <- lapply(synonyms, + function(x) { + if (length(x) == 0 | all(is.na(x))) { + "" + } else { + x + }}) -antibiotics$cid <- CIDs -antibiotics$trade_name <- synonyms +# add them to data set +antibiotics <- abx2 %>% + left_join(DRGLST %>% + select(ab = WHON5_CODE, CLASS, SUBCLASS) %>% + distinct(ab, .keep_all = TRUE), by = "ab") %>% + transmute(ab, + atc, + cid = CIDs, + # no capital after a slash: Ampicillin/Sulbactam -> Ampicillin/sulbactam + name = gsub("edta", "EDTA", gsub("/([A-Z])", "/\\L\\1", name, perl = TRUE), ignore.case = TRUE), + group = case_when( + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "am(ph|f)enicol" ~ "Amphenicols", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "aminoglycoside" ~ "Aminoglycosides", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "carbapenem" | name %like% "(imipenem|meropenem)" ~ "Carbapenems", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "First-generation cephalosporin" ~ "Cephalosporins (1st gen.)", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "Second-generation cephalosporin" ~ "Cephalosporins (2nd gen.)", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "Third-generation cephalosporin" ~ "Cephalosporins (3rd gen.)", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "Fourth-generation cephalosporin" ~ "Cephalosporins (4th gen.)", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "(tuberculosis|mycobacter)" ~ "Antimycobacterials", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "cephalosporin" ~ "Cephalosporins", + name %like% "^Ce" & is.na(atc_group1) & paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "beta-?lactam" ~ "Cephalosporins", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "(beta-?lactam|penicillin)" ~ "Beta-lactams/penicillins", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "quinolone" ~ "Quinolones", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "glycopeptide" ~ "Glycopeptides", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "macrolide" ~ "Macrolides/lincosamides", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "tetracycline" ~ "Tetracyclines", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "trimethoprim" ~ "Trimethoprims", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "polymyxin" ~ "Polymyxins", + paste(atc_group1, atc_group2, CLASS, SUBCLASS) %like% "(fungal|mycot)" ~ "Antifungals/antimycotics", + TRUE ~ "Other antibacterials" + ), + atc_group1, atc_group2, + abbreviations = unname(abbr), + synonyms = unname(synonyms), + oral_ddd, oral_units, + iv_ddd, iv_units) %>% + as.data.frame(stringsAsFactors = FALSE) + +# some exceptions +antibiotics[which(antibiotics$ab == "DOX"), "abbreviations"][[1]] <- list(c("dox", "doxy")) +antibiotics[which(antibiotics$ab == "FLC"), "abbreviations"][[1]] <- list(c("clox")) +antibiotics[which(antibiotics$ab == "CEC"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CEC"), "abbreviations"][[1]], "CFC")) # cefaclor old WHONET4 code +# 'Polymixin B' (POL) and 'Polymyxin B' (PLB) both exist, so: +antibiotics[which(antibiotics$ab == "PLB"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "PLB"), "abbreviations"][[1]], "POL", "Polymixin", "Polymixin B")) +antibiotics <- filter(antibiotics, ab != "POL") +# 'Latamoxef' (LTM) and 'Moxalactam (Latamoxef)' (MOX) both exist, so: +antibiotics[which(antibiotics$ab == "LTM"), "abbreviations"][[1]] <- list(c("MOX", "moxa")) +antibiotics <- filter(antibiotics, ab != "MOX") +# ESBL E-test codes: +antibiotics[which(antibiotics$ab == "CCV"), "abbreviations"][[1]] <- list(c("xtzl")) +antibiotics[which(antibiotics$ab == "CAZ"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CAZ"), "abbreviations"][[1]], "xtz")) +antibiotics[which(antibiotics$ab == "CPC"), "abbreviations"][[1]] <- list(c("xpml")) +antibiotics[which(antibiotics$ab == "FEP"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "FEP"), "abbreviations"][[1]], "xpm")) +antibiotics[which(antibiotics$ab == "CTC"), "abbreviations"][[1]] <- list(c("xctl")) +antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]] <- list(c(antibiotics[which(antibiotics$ab == "CTX"), "abbreviations"][[1]], "xct")) + +class(antibiotics$ab) <- "ab" +class(antibiotics$atc) <- "atc" + +usethis::use_data(antibiotics, overwrite = TRUE) diff --git a/reproduction_of_microorganisms.R b/reproduction_of_microorganisms.R index 6b139e23e..ba2e899c4 100644 --- a/reproduction_of_microorganisms.R +++ b/reproduction_of_microorganisms.R @@ -96,8 +96,6 @@ MOs <- data_total %>% ( # we only want all MICROorganisms and no viruses !kingdom %in% c("Animalia", "Plantae", "Viruses") - # and no entries above genus level - all species already have a taxonomic tree - & !rank %in% c("kingdom", "phylum", "superfamily", "class", "order", "family") # and not all fungi: Aspergillus, Candida, Trichphyton and Pneumocystis are the most important, # so only keep these orders from the fungi: & !(kingdom == "Fungi" @@ -194,7 +192,12 @@ MOs.old <- MOs %>% MOs <- MOs %>% filter(is.na(col_id_new) | source == "DSMZ") %>% transmute(col_id, - fullname = trimws(paste(genus, species, subspecies)), + fullname = trimws(case_when(rank == "family" ~ family, + rank == "order" ~ order, + rank == "class" ~ class, + rank == "phylum" ~ phylum, + rank == "kingdom" ~ kingdom, + TRUE ~ paste(genus, species, subspecies))), kingdom, phylum, class, @@ -220,6 +223,34 @@ MOs <- MOs %>% # These will become valid and unique microbial IDs for the AMR package. MOs <- MOs %>% group_by(kingdom) %>% + mutate(abbr_other = case_when( + rank == "family" ~ paste0("[FAM]_", + abbreviate(family, + minlength = 8, + use.classes = TRUE, + method = "both.sides", + strict = FALSE)), + rank == "order" ~ paste0("[ORD]_", + abbreviate(order, + minlength = 8, + use.classes = TRUE, + method = "both.sides", + strict = FALSE)), + rank == "class" ~ paste0("[CLS]_", + abbreviate(class, + minlength = 8, + use.classes = TRUE, + method = "both.sides", + strict = FALSE)), + rank == "phylum" ~ paste0("[PHL]_", + abbreviate(phylum, + minlength = 8, + use.classes = TRUE, + method = "both.sides", + strict = FALSE)), + rank == "kingdom" ~ paste0("[KNG]_", kingdom), + TRUE ~ NA_character_ + )) %>% # abbreviations may be same for genera between kingdoms, # because each abbreviation starts with the the first character(s) of the kingdom mutate(abbr_genus = abbreviate(genus, @@ -247,9 +278,12 @@ MOs <- MOs %>% toupper(paste(ifelse(kingdom %in% c("Animalia", "Plantae"), substr(kingdom, 1, 2), substr(kingdom, 1, 1)), - abbr_genus, - abbr_species, - abbr_subspecies, + ifelse(is.na(abbr_other), + paste(abbr_genus, + abbr_species, + abbr_subspecies, + sep = "_"), + abbr_other), sep = "_")))) %>% mutate(mo = ifelse(duplicated(.$mo), # these one or two must be unique too @@ -259,7 +293,7 @@ MOs <- MOs %>% trimws(paste(genus, species, subspecies)), fullname)) %>% # put `mo` in front, followed by the rest - select(mo, everything(), -abbr_genus, -abbr_species, -abbr_subspecies) + select(mo, everything(), -abbr_other, -abbr_genus, -abbr_species, -abbr_subspecies) # add non-taxonomic entries @@ -419,7 +453,7 @@ sum(duplicated(MOs$mo)) colnames(MOs) # save it -MOs <- as.data.frame(MOs %>% arrange(mo), stringsAsFactors = FALSE) +MOs <- as.data.frame(MOs %>% arrange(fullname), stringsAsFactors = FALSE) MOs.old <- as.data.frame(MOs.old, stringsAsFactors = FALSE) class(MOs$mo) <- "mo" diff --git a/reproduction_of_rsi_translation.R b/reproduction_of_rsi_translation.R new file mode 100644 index 000000000..3382d29ff --- /dev/null +++ b/reproduction_of_rsi_translation.R @@ -0,0 +1,52 @@ +library(dplyr) +library(readxl) + +# Installed WHONET 2019 software on Windows (http://www.whonet.org/software.html), +# opened C:\WHONET\Codes\WHONETCodes.mdb in MS Access +# and exported table 'DRGLST1' to MS Excel +DRGLST1 <- read_excel("DRGLST1.xlsx") +rsi_translation <- DRGLST1 %>% + # only keep CLSI and EUCAST guidelines: + filter(GUIDELINES %like% "^(CLSI|EUCST)") %>% + # set a nice layout: + transmute(guideline = gsub("([0-9]+)$", " 20\\1", gsub("EUCST", "EUCAST", GUIDELINES)), + method = TESTMETHOD, + mo = as.mo(ORG_CODE), + ab = as.ab(WHON5_CODE), + ref_tbl = REF_TABLE, + dose_disk = POTENCY, + S_disk = as.disk(DISK_S), + R_disk = as.disk(DISK_R), + S_mic = as.mic(MIC_S), + R_mic = as.mic(MIC_R)) %>% + filter(!is.na(mo) & !is.na(ab)) %>% + arrange(desc(guideline), mo, ab) + +# create 2 tables: MIC and disk +tbl_mic <- rsi_translation %>% + filter(method == "MIC") %>% + select(-ends_with("_disk")) %>% + mutate(joinstring = paste(guideline, mo, ab)) +tbl_disk <- rsi_translation %>% + filter(method == "DISK") %>% + select(-S_mic, -R_mic) %>% + mutate(joinstring = paste(guideline, mo, ab)) %>% + select(joinstring, ends_with("_disk")) + +# merge them so every record is a unique combination of method, mo and ab +rsi_translation <- tbl_mic %>% + left_join(tbl_disk, + by = "joinstring") %>% + select(-joinstring, -method) %>% + as.data.frame(stringsAsFactors = FALSE) %>% + # force classes again + mutate(mo = as.mo(mo), + ab = as.ab(ab), + S_mic = as.mic(S_mic), + R_mic = as.mic(R_mic), + S_disk = as.disk(S_disk), + R_disk = as.disk(R_disk)) + +# save to package +usethis::use_data(rsi_translation, overwrite = TRUE) +rm(rsi_translation) diff --git a/tests/testthat/test-atc.R b/tests/testthat/test-ab.R similarity index 64% rename from tests/testthat/test-atc.R rename to tests/testthat/test-ab.R index 5877ccf77..08c37dfff 100755 --- a/tests/testthat/test-atc.R +++ b/tests/testthat/test-ab.R @@ -19,27 +19,28 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -context("atc.R") +context("ab.R") -test_that("as.atc works", { - expect_equal(suppressWarnings(as.character(as.atc(c("J01FA01", - "Erythromycin", - "eryt", - "ERYT", - "ERY", - "Erythrocin", - "Eryzole", - "Pediamycin")))), - rep("J01FA01", 8)) +test_that("as.ab works", { + expect_equal(as.character(as.ab(c("J01FA01", + "J 01 FA 01", + "Erythromycin", + "eryt", + " eryt 123", + "ERYT", + "ERY", + "erytromicine", + "Erythrocin", + "Romycin"))), + rep("ERY", 10)) - expect_identical(class(as.atc("amox")), "atc") - expect_identical(class(pull(antibiotics, atc)), "atc") - expect_identical(atc_trivial_nl("Cefmenoxim"), "Cefmenoxim") + expect_identical(class(as.ab("amox")), "ab") + expect_identical(class(pull(antibiotics, ab)), "ab") - expect_warning(as.atc("Z00ZZ00")) # not yet available in data set - expect_warning(as.atc("UNKNOWN")) + expect_warning(as.ab("Z00ZZ00")) # not yet available in data set + expect_warning(as.ab("UNKNOWN")) - expect_output(print(as.atc("amox"))) + expect_output(print(as.ab("amox"))) # first 5 chars of official name expect_equal(as.character(as.atc(c("nitro", "cipro"))), diff --git a/tests/testthat/test-atc_property.R b/tests/testthat/test-ab_property.R similarity index 50% rename from tests/testthat/test-atc_property.R rename to tests/testthat/test-ab_property.R index bc3cae891..fb42cd105 100644 --- a/tests/testthat/test-atc_property.R +++ b/tests/testthat/test-ab_property.R @@ -19,19 +19,37 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -context("atc_property.R") +context("ab_property.R") -test_that("atc_property works", { - expect_equal(atc_certe("amox"), "amox") - expect_equal(atc_name("amox", language = "en"), "Amoxicillin") - expect_equal(atc_name("amox", language = "nl"), "Amoxicilline") - expect_equal(atc_official("amox", language = "en"), "Amoxicillin") - expect_equal(atc_trivial_nl("amox"), "Amoxicilline") - expect_equal(atc_umcg("amox"), "AMOX") - expect_equal(class(atc_tradenames("amox")), "character") - expect_equal(class(atc_tradenames(c("amox", "amox"))), "list") +test_that("ab_property works", { - expect_error(atc_property("amox", "invalid property")) - expect_error(atc_name("amox", language = "INVALID")) - expect_output(print(atc_name("amox", language = NULL))) + expect_identical(ab_name("AMX"), "Amoxicillin") + expect_identical(as.character(ab_atc("AMX")), "J01CA04") + expect_identical(ab_cid("AMX"), as.integer(33613)) + + expect_equal(class(ab_tradenames("AMX")), "character") + expect_equal(class(ab_tradenames(c("AMX", "AMX"))), "list") + + expect_identical(ab_group("AMX"), "Beta-lactams/penicillins") + expect_identical(ab_atc_group1("AMX"), "Beta-lactam antibacterials, penicillins") + expect_identical(ab_atc_group2("AMX"), "Penicillins with extended spectrum") + + expect_identical(ab_name("Fluclox"), "Flucloxacillin") + expect_identical(ab_name("fluklox"), "Flucloxacillin") + expect_identical(ab_name("floxapen"), "Flucloxacillin") + expect_identical(ab_name(21319) , "Flucloxacillin") + expect_identical(ab_name("J01CF05"), "Flucloxacillin") + + expect_identical(ab_ddd("AMX", "oral"), 1) + expect_identical(ab_ddd("AMX", "oral", units = TRUE) , "g") + expect_identical(ab_ddd("AMX", "iv"), 1) + expect_identical(ab_ddd("AMX", "iv", units = TRUE) , "g") + + expect_identical(ab_name(x = c("AMC", "PLB")), c("Amoxicillin/clavulanic acid", "Polymyxin B")) + expect_identical(ab_name(x = c("AMC", "PLB"), tolower = TRUE), + c("amoxicillin/clavulanic acid", "polymyxin B")) + + expect_error(ab_property("amox", "invalid property")) + expect_error(ab_name("amox", language = "INVALID")) + expect_output(print(ab_name("amox", language = NULL))) }) diff --git a/tests/testthat/test-abname.R b/tests/testthat/test-abname.R deleted file mode 100644 index a54d192f3..000000000 --- a/tests/testthat/test-abname.R +++ /dev/null @@ -1,43 +0,0 @@ -# ==================================================================== # -# TITLE # -# Antimicrobial Resistance (AMR) Analysis # -# # -# SOURCE # -# https://gitlab.com/msberends/AMR # -# # -# LICENCE # -# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) # -# # -# This R package is free software; you can freely use and distribute # -# it for both personal and commercial purposes under the terms of the # -# GNU General Public License version 2.0 (GNU GPL-2), as published by # -# the Free Software Foundation. # -# # -# This R package was created for academic research and was publicly # -# released in the hope that it will be useful, but it comes WITHOUT # -# ANY WARRANTY OR LIABILITY. # -# Visit our website for more info: https://msberends.gitlab.io/AMR. # -# ==================================================================== # - -context("abname.R") - -test_that("abname works", { - expect_equal(abname("AMOX"), "Amoxicillin") - expect_equal(abname(c("AMOX", "GENT")), c("Amoxicillin", "Gentamicin")) - expect_equal(abname(c("AMOX+GENT")), "Amoxicillin + gentamicin") - expect_equal(abname("AMOX", from = 'umcg'), "Amoxicillin") - expect_equal(abname("amox", from = 'certe', tolower = TRUE), "amoxicillin") - expect_equal(abname("J01CA04", from = 'atc'), "Amoxicillin") - expect_equal(abname(c("amox", "J01CA04", "Trimox", "dispermox", "Amoxil")), - rep("Amoxicillin", 5)) - expect_equal(abname("AMOX", to = 'atc'), "J01CA04") - - expect_error(abname("AMOX", to = c(1:3))) - expect_error(abname("AMOX", to = "test")) - expect_warning(abname("NOTEXISTING - ")) - expect_warning(abname("AMOX or GENT")) - - # this one is being found with as.atc internally - expect_equal(abname("flu_clox123"), "Flucloxacillin") -}) diff --git a/tests/testthat/test-count.R b/tests/testthat/test-count.R index ad9507cc7..f8106302b 100644 --- a/tests/testthat/test-count.R +++ b/tests/testthat/test-count.R @@ -22,52 +22,52 @@ context("count.R") test_that("counts work", { - # amox resistance in `septic_patients` - expect_equal(count_R(septic_patients$amox), 683) - expect_equal(count_I(septic_patients$amox), 3) - expect_equal(count_S(septic_patients$amox), 543) - expect_equal(count_R(septic_patients$amox) + count_I(septic_patients$amox), - count_IR(septic_patients$amox)) - expect_equal(count_S(septic_patients$amox) + count_I(septic_patients$amox), - count_SI(septic_patients$amox)) + # AMX resistance in `septic_patients` + expect_equal(count_R(septic_patients$AMX), 683) + expect_equal(count_I(septic_patients$AMX), 3) + expect_equal(count_S(septic_patients$AMX), 543) + expect_equal(count_R(septic_patients$AMX) + count_I(septic_patients$AMX), + count_IR(septic_patients$AMX)) + expect_equal(count_S(septic_patients$AMX) + count_I(septic_patients$AMX), + count_SI(septic_patients$AMX)) library(dplyr) - expect_equal(septic_patients %>% count_S(amcl), 1342) - expect_equal(septic_patients %>% count_S(amcl, gent), 1660) - expect_equal(septic_patients %>% count_all(amcl, gent), 1798) - expect_identical(septic_patients %>% count_all(amcl, gent), - septic_patients %>% count_S(amcl, gent) + - septic_patients %>% count_IR(amcl, gent)) + expect_equal(septic_patients %>% count_S(AMC), 1342) + expect_equal(septic_patients %>% count_S(AMC, GEN), 1660) + expect_equal(septic_patients %>% count_all(AMC, GEN), 1798) + expect_identical(septic_patients %>% count_all(AMC, GEN), + septic_patients %>% count_S(AMC, GEN) + + septic_patients %>% count_IR(AMC, GEN)) # count of cases expect_equal(septic_patients %>% group_by(hospital_id) %>% - summarise(cipro = count_S(cipr), - genta = count_S(gent), - combination = count_S(cipr, gent)) %>% + summarise(cipro = count_S(CIP), + genta = count_S(GEN), + combination = count_S(CIP, GEN)) %>% pull(combination), c(192, 446, 184, 474)) # count_df expect_equal( - septic_patients %>% select(amox) %>% count_df() %>% pull(Value), - c(septic_patients$amox %>% count_S(), - septic_patients$amox %>% count_I(), - septic_patients$amox %>% count_R()) + septic_patients %>% select(AMX) %>% count_df() %>% pull(Value), + c(septic_patients$AMX %>% count_S(), + septic_patients$AMX %>% count_I(), + septic_patients$AMX %>% count_R()) ) expect_equal( - septic_patients %>% select(amox) %>% count_df(combine_IR = TRUE) %>% pull(Value), - c(septic_patients$amox %>% count_S(), - septic_patients$amox %>% count_IR()) + septic_patients %>% select(AMX) %>% count_df(combine_IR = TRUE) %>% pull(Value), + c(septic_patients$AMX %>% count_S(), + septic_patients$AMX %>% count_IR()) ) # warning for speed loss - expect_warning(count_R(as.character(septic_patients$amcl))) - expect_warning(count_I(as.character(septic_patients$amcl))) - expect_warning(count_S(as.character(septic_patients$amcl, - septic_patients$gent))) - expect_warning(count_S(septic_patients$amcl, - as.character(septic_patients$gent))) + expect_warning(count_R(as.character(septic_patients$AMC))) + expect_warning(count_I(as.character(septic_patients$AMC))) + expect_warning(count_S(as.character(septic_patients$AMC, + septic_patients$GEN))) + expect_warning(count_S(septic_patients$AMC, + as.character(septic_patients$GEN))) # check for errors expect_error(count_IR("test", minimum = "test")) diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R index a74aa11d9..c9bd5ee1f 100644 --- a/tests/testthat/test-data.R +++ b/tests/testthat/test-data.R @@ -23,7 +23,7 @@ context("data.R") test_that("data sets are valid", { # IDs should always be unique - expect_identical(nrow(antibiotics), length(unique(antibiotics$atc))) + expect_identical(nrow(antibiotics), length(unique(antibiotics$ab))) expect_identical(nrow(microorganisms), length(unique(microorganisms$mo))) # there should be no diacritics (i.e. non ASCII) characters in the datasets diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R index 387205d70..c14a9fc4e 100644 --- a/tests/testthat/test-deprecated.R +++ b/tests/testthat/test-deprecated.R @@ -30,15 +30,11 @@ test_that("deprecated functions work", { expect_identical(suppressWarnings(ratio(c(772, 1611, 737), ratio = "1:2:1")), c(780, 1560, 780)) expect_identical(suppressWarnings(ratio(c(1752, 1895), ratio = c(1, 1))), c(1823.5, 1823.5)) - expect_warning(ab_property("amox")) - expect_warning(ab_atc("amox")) + expect_warning(atc_property("amox")) + expect_warning(atc_official("amox")) expect_warning(ab_official("amox")) - expect_warning(ab_name("amox")) - expect_warning(ab_trivial_nl("amox")) - expect_warning(ab_certe("amox")) - expect_warning(ab_umcg("amox")) - expect_warning(ab_tradenames("amox")) - expect_warning(atc_ddd("amox")) - expect_warning(atc_groups("amox")) + expect_warning(atc_name("amox")) + expect_warning(atc_trivial_nl("amox")) + expect_warning(atc_tradenames("amox")) }) diff --git a/tests/testthat/test-eucast_rules.R b/tests/testthat/test-eucast_rules.R index 1a85f5014..286bcd810 100755 --- a/tests/testthat/test-eucast_rules.R +++ b/tests/testthat/test-eucast_rules.R @@ -52,11 +52,11 @@ test_that("EUCAST rules work", { a <- data.frame(mo = c("Staphylococcus aureus", "Streptococcus group A"), - coli = "-", # Colistin + COL = "-", # Colistin stringsAsFactors = FALSE) b <- data.frame(mo = c("Staphylococcus aureus", "Streptococcus group A"), - coli = "R", # Colistin + COL = "R", # Colistin stringsAsFactors = FALSE) expect_equal(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b) @@ -64,30 +64,30 @@ test_that("EUCAST rules work", { library(dplyr) expect_equal(suppressWarnings( septic_patients %>% - mutate(tica = as.rsi("R"), - pipe = as.rsi("S")) %>% + mutate(TIC = as.rsi("R"), + PIP = as.rsi("S")) %>% eucast_rules(col_mo = "mo") %>% left_join_microorganisms() %>% filter(family == "Enterobacteriaceae") %>% - pull(pipe) %>% + pull(PIP) %>% unique() %>% as.character()), "R") - # azit and clar must be equal to eryt + # Azithromicin and Clarythromycin must be equal to Erythromycin a <- suppressWarnings( septic_patients %>% transmute(mo, - eryt, - azit = as.rsi("R"), - clar = as.rsi("R")) %>% + ERY, + AZM = as.rsi("R"), + CLR = as.rsi("R")) %>% eucast_rules(col_mo = "mo") %>% - pull(clar)) + pull(CLR)) b <- suppressWarnings( septic_patients %>% - select(mo, eryt) %>% + select(mo, ERY) %>% eucast_rules(col_mo = "mo") %>% - pull(eryt)) + pull(ERY)) expect_identical(a[!is.na(b)], b[!is.na(b)]) @@ -97,15 +97,15 @@ test_that("EUCAST rules work", { suppressWarnings( as.list(eucast_rules( data.frame(mo = as.mo("Kingella kingae"), - peni = "S", - amox = "-", + PEN = "S", + AMX = "-", stringsAsFactors = FALSE) - , info = FALSE))$amox + , info = FALSE))$AMX ), "S") # also test norf - expect_output(suppressWarnings(eucast_rules(septic_patients %>% mutate(norf = "S", nali = "S")))) + expect_output(suppressWarnings(eucast_rules(septic_patients %>% mutate(NOR = "S", NAL = "S")))) # check verbose output expect_output(suppressWarnings(eucast_rules(septic_patients, verbose = TRUE))) diff --git a/tests/testthat/test-freq.R b/tests/testthat/test-freq.R index 3bbdbe8e6..e757e7310 100755 --- a/tests/testthat/test-freq.R +++ b/tests/testthat/test-freq.R @@ -51,7 +51,7 @@ test_that("frequency table works", { # mo expect_output(print(freq(septic_patients$mo))) # rsi - expect_output(print(freq(septic_patients$amox))) + expect_output(print(freq(septic_patients$AMX))) # integer expect_output(print(freq(septic_patients$age))) # date @@ -61,7 +61,7 @@ test_that("frequency table works", { # table expect_output(print(freq(table(septic_patients$gender, septic_patients$age)))) # rsi - expect_output(print(freq(septic_patients$amcl))) + expect_output(print(freq(septic_patients$AMC))) # hms expect_output(suppressWarnings(print(freq(hms::as.hms(sample(c(0:86399), 50)))))) # matrix @@ -89,8 +89,8 @@ test_that("frequency table works", { # grouping variable expect_output(print(septic_patients %>% group_by(gender) %>% freq(hospital_id))) - expect_output(print(septic_patients %>% group_by(gender) %>% freq(amox, quote = TRUE))) - expect_output(print(septic_patients %>% group_by(gender) %>% freq(amox, markdown = TRUE))) + expect_output(print(septic_patients %>% group_by(gender) %>% freq(AMX, quote = TRUE))) + expect_output(print(septic_patients %>% group_by(gender) %>% freq(AMX, markdown = TRUE))) # quasiquotation expect_output(print(septic_patients %>% freq(mo_genus(mo)))) @@ -152,7 +152,7 @@ test_that("frequency table works", { expect_error(septic_patients %>% freq(nonexisting)) expect_error(septic_patients %>% select(1:10) %>% freq()) - expect_error(septic_patients %>% freq(peni, oxac, clox, amox, amcl, + expect_error(septic_patients %>% freq(peni, oxac, clox, AMX, AMC, ampi, pita, czol, cfep, cfur)) # (un)select columns @@ -163,15 +163,15 @@ test_that("frequency table works", { # run diff expect_output(print( - diff(freq(septic_patients$amcl), - freq(septic_patients$amox)) + diff(freq(septic_patients$AMC), + freq(septic_patients$AMX)) )) expect_output(print( diff(freq(septic_patients$age), freq(septic_patients$age)) # "No differences found." )) expect_error(print( - diff(freq(septic_patients$amcl), + diff(freq(septic_patients$AMX), "Just a string") # not a freq tbl )) diff --git a/tests/testthat/test-ggplot_rsi.R b/tests/testthat/test-ggplot_rsi.R index b55b5741a..27465fc90 100644 --- a/tests/testthat/test-ggplot_rsi.R +++ b/tests/testthat/test-ggplot_rsi.R @@ -30,36 +30,36 @@ test_that("ggplot_rsi works", { # data should be equal expect_equal( - (septic_patients %>% select(amcl, cipr) %>% ggplot_rsi())$data %>% + (septic_patients %>% select(AMC, CIP) %>% ggplot_rsi())$data %>% summarise_all(portion_IR) %>% as.double(), - septic_patients %>% select(amcl, cipr) %>% + septic_patients %>% select(AMC, CIP) %>% summarise_all(portion_IR) %>% as.double() ) expect_equal( - (septic_patients %>% select(amcl, cipr) %>% ggplot_rsi(x = "Interpretation", facet = "Antibiotic"))$data %>% + (septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "Interpretation", facet = "Antibiotic"))$data %>% summarise_all(portion_IR) %>% as.double(), - septic_patients %>% select(amcl, cipr) %>% + septic_patients %>% select(AMC, CIP) %>% summarise_all(portion_IR) %>% as.double() ) expect_equal( - (septic_patients %>% select(amcl, cipr) %>% ggplot_rsi(x = "Antibiotic", facet = "Interpretation"))$data %>% + (septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "Antibiotic", facet = "Interpretation"))$data %>% summarise_all(portion_IR) %>% as.double(), - septic_patients %>% select(amcl, cipr) %>% + septic_patients %>% select(AMC, CIP) %>% summarise_all(portion_IR) %>% as.double() ) expect_equal( - (septic_patients %>% select(amcl, cipr) %>% ggplot_rsi(x = "Antibiotic", + (septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "Antibiotic", facet = "Interpretation", fun = count_df))$data %>% summarise_all(count_IR) %>% as.double(), - septic_patients %>% select(amcl, cipr) %>% + septic_patients %>% select(AMC, CIP) %>% summarise_all(count_IR) %>% as.double() ) - expect_equal(colnames(getlbls(septic_patients %>% select(amcl, cipr))), + expect_equal(colnames(getlbls(septic_patients %>% select(AMC, CIP))), c("Interpretation", "Antibiotic", "Value", "lbl")) expect_error(ggplot_rsi(septic_patients, fun = "invalid")) diff --git a/tests/testthat/test-guess_ab_col.R b/tests/testthat/test-guess_ab_col.R index 7ead1fa0e..c74ff0706 100644 --- a/tests/testthat/test-guess_ab_col.R +++ b/tests/testthat/test-guess_ab_col.R @@ -24,15 +24,15 @@ context("guess_ab_col.R") test_that("guess_ab_col works", { expect_equal(guess_ab_col(septic_patients, "amox"), - "amox") + "AMX") expect_equal(guess_ab_col(septic_patients, "amoxicillin"), - "amox") + "AMX") expect_equal(guess_ab_col(septic_patients, "J01AA07"), - "tetr") + "TCY") expect_equal(guess_ab_col(septic_patients, "tetracycline"), - "tetr") + "TCY") expect_equal(guess_ab_col(septic_patients, "TETR"), - "tetr") + "TCY") df <- data.frame(AMP_ND10 = "R", AMC_ED20 = "S") diff --git a/tests/testthat/test-portion.R b/tests/testthat/test-portion.R index 95907770e..02b700a5d 100755 --- a/tests/testthat/test-portion.R +++ b/tests/testthat/test-portion.R @@ -22,40 +22,33 @@ context("portion.R") test_that("portions works", { - # amox resistance in `septic_patients` - expect_equal(portion_R(septic_patients$amox), 0.5557364, tolerance = 0.0001) - expect_equal(portion_I(septic_patients$amox), 0.002441009, tolerance = 0.0001) - expect_equal(1 - portion_R(septic_patients$amox) - portion_I(septic_patients$amox), - portion_S(septic_patients$amox)) - expect_equal(portion_R(septic_patients$amox) + portion_I(septic_patients$amox), - portion_IR(septic_patients$amox)) - expect_equal(portion_S(septic_patients$amox) + portion_I(septic_patients$amox), - portion_SI(septic_patients$amox)) + # AMX resistance in `septic_patients` + expect_equal(portion_R(septic_patients$AMX), 0.5557364, tolerance = 0.0001) + expect_equal(portion_I(septic_patients$AMX), 0.002441009, tolerance = 0.0001) + expect_equal(1 - portion_R(septic_patients$AMX) - portion_I(septic_patients$AMX), + portion_S(septic_patients$AMX)) + expect_equal(portion_R(septic_patients$AMX) + portion_I(septic_patients$AMX), + portion_IR(septic_patients$AMX)) + expect_equal(portion_S(septic_patients$AMX) + portion_I(septic_patients$AMX), + portion_SI(septic_patients$AMX)) - expect_equal(septic_patients %>% portion_S(amcl), + expect_equal(septic_patients %>% portion_S(AMC), 0.7142097, tolerance = 0.0001) - expect_equal(septic_patients %>% portion_S(amcl, gent), + expect_equal(septic_patients %>% portion_S(AMC, GEN), 0.9232481, tolerance = 0.0001) - expect_equal(septic_patients %>% portion_S(amcl, gent, also_single_tested = TRUE), + expect_equal(septic_patients %>% portion_S(AMC, GEN, also_single_tested = TRUE), 0.926045, tolerance = 0.0001) - # amcl+genta susceptibility around 92.3% - expect_equal(suppressWarnings(rsi(septic_patients$amcl, - septic_patients$gent, - interpretation = "S")), - 0.9232481, - tolerance = 0.000001) - # percentages expect_equal(septic_patients %>% group_by(hospital_id) %>% - summarise(R = portion_R(cipr, as_percent = TRUE), - I = portion_I(cipr, as_percent = TRUE), - S = portion_S(cipr, as_percent = TRUE), - n = n_rsi(cipr), + summarise(R = portion_R(CIP, as_percent = TRUE), + I = portion_I(CIP, as_percent = TRUE), + S = portion_S(CIP, as_percent = TRUE), + n = n_rsi(CIP), total = n()) %>% pull(n) %>% sum(), @@ -64,23 +57,23 @@ test_that("portions works", { # count of cases expect_equal(septic_patients %>% group_by(hospital_id) %>% - summarise(cipro_p = portion_S(cipr, as_percent = TRUE), - cipro_n = n_rsi(cipr), - genta_p = portion_S(gent, as_percent = TRUE), - genta_n = n_rsi(gent), - combination_p = portion_S(cipr, gent, as_percent = TRUE), - combination_n = n_rsi(cipr, gent)) %>% + summarise(CIPo_p = portion_S(CIP, as_percent = TRUE), + CIPo_n = n_rsi(CIP), + GENa_p = portion_S(GEN, as_percent = TRUE), + GENa_n = n_rsi(GEN), + combination_p = portion_S(CIP, GEN, as_percent = TRUE), + combination_n = n_rsi(CIP, GEN)) %>% pull(combination_n), c(202, 488, 201, 499)) - expect_warning(portion_R(as.character(septic_patients$amcl))) - expect_warning(portion_S(as.character(septic_patients$amcl))) - expect_warning(portion_S(as.character(septic_patients$amcl, - septic_patients$gent))) - expect_warning(n_rsi(as.character(septic_patients$amcl, - septic_patients$gent))) - expect_equal(suppressWarnings(n_rsi(as.character(septic_patients$amcl, - septic_patients$gent))), + expect_warning(portion_R(as.character(septic_patients$AMC))) + expect_warning(portion_S(as.character(septic_patients$AMC))) + expect_warning(portion_S(as.character(septic_patients$AMC, + septic_patients$GEN))) + expect_warning(n_rsi(as.character(septic_patients$AMC, + septic_patients$GEN))) + expect_equal(suppressWarnings(n_rsi(as.character(septic_patients$AMC, + septic_patients$GEN))), 1879) # check for errors @@ -93,59 +86,29 @@ test_that("portions works", { expect_error(portion_S("test", also_single_tested = "test")) # check too low amount of isolates - expect_identical(suppressWarnings(portion_R(septic_patients$amox, minimum = nrow(septic_patients) + 1)), + expect_identical(suppressWarnings(portion_R(septic_patients$AMX, minimum = nrow(septic_patients) + 1)), NA) - expect_identical(suppressWarnings(portion_I(septic_patients$amox, minimum = nrow(septic_patients) + 1)), + expect_identical(suppressWarnings(portion_I(septic_patients$AMX, minimum = nrow(septic_patients) + 1)), NA) - expect_identical(suppressWarnings(portion_S(septic_patients$amox, minimum = nrow(septic_patients) + 1)), + expect_identical(suppressWarnings(portion_S(septic_patients$AMX, minimum = nrow(septic_patients) + 1)), NA) # warning for speed loss - expect_warning(portion_R(as.character(septic_patients$gent))) - expect_warning(portion_I(as.character(septic_patients$gent))) - expect_warning(portion_S(septic_patients$amcl, as.character(septic_patients$gent))) - -}) - -test_that("old rsi works", { - # amox resistance in `septic_patients` should be around 58.53% - expect_equal(suppressWarnings(rsi(septic_patients$amox)), 0.5581774, tolerance = 0.0001) - expect_equal(suppressWarnings(rsi(septic_patients$amox, interpretation = "S")), 1 - 0.5581774, tolerance = 0.0001) - - # pita+genta susceptibility around 95.3% - expect_equal(suppressWarnings(rsi(septic_patients$pita, - septic_patients$gent, - interpretation = "S", - info = TRUE)), - 0.9526814, - tolerance = 0.0001) - - # count of cases - expect_equal(septic_patients %>% - group_by(hospital_id) %>% - summarise(cipro_S = suppressWarnings(rsi(cipr, interpretation = "S", - as_percent = TRUE, warning = FALSE)), - cipro_n = n_rsi(cipr), - genta_S = suppressWarnings(rsi(gent, interpretation = "S", - as_percent = TRUE, warning = FALSE)), - genta_n = n_rsi(gent), - combination_S = suppressWarnings(rsi(cipr, gent, interpretation = "S", - as_percent = TRUE, warning = FALSE)), - combination_n = n_rsi(cipr, gent)) %>% - pull(combination_n), - c(202, 488, 201, 499)) + expect_warning(portion_R(as.character(septic_patients$GEN))) + expect_warning(portion_I(as.character(septic_patients$GEN))) + expect_warning(portion_S(septic_patients$AMC, as.character(septic_patients$GEN))) # portion_df expect_equal( - septic_patients %>% select(amox) %>% portion_df() %>% pull(Value), - c(septic_patients$amox %>% portion_S(), - septic_patients$amox %>% portion_I(), - septic_patients$amox %>% portion_R()) + septic_patients %>% select(AMX) %>% portion_df() %>% pull(Value), + c(septic_patients$AMX %>% portion_S(), + septic_patients$AMX %>% portion_I(), + septic_patients$AMX %>% portion_R()) ) expect_equal( - septic_patients %>% select(amox) %>% portion_df(combine_IR = TRUE) %>% pull(Value), - c(septic_patients$amox %>% portion_S(), - septic_patients$amox %>% portion_IR()) + septic_patients %>% select(AMX) %>% portion_df(combine_IR = TRUE) %>% pull(Value), + c(septic_patients$AMX %>% portion_S(), + septic_patients$AMX %>% portion_IR()) ) diff --git a/tests/testthat/test-resistance_predict.R b/tests/testthat/test-resistance_predict.R index cb511b1a4..b48ded4e3 100644 --- a/tests/testthat/test-resistance_predict.R +++ b/tests/testthat/test-resistance_predict.R @@ -22,17 +22,17 @@ context("portion.R") test_that("prediction of rsi works", { - amox_R <- septic_patients %>% + AMX_R <- septic_patients %>% filter(mo == "B_ESCHR_COL") %>% - rsi_predict(col_ab = "amox", + rsi_predict(col_ab = "AMX", col_date = "date", minimum = 10, info = TRUE) %>% pull("value") - # amox resistance will increase according to data set `septic_patients` - expect_true(amox_R[3] < amox_R[20]) + # AMX resistance will increase according to data set `septic_patients` + expect_true(AMX_R[3] < AMX_R[20]) - x <- resistance_predict(septic_patients, col_ab = "amox", year_min = 2010) + x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010) plot(x) ggplot_rsi_predict(x) expect_error(ggplot_rsi_predict(septic_patients)) @@ -41,23 +41,23 @@ test_that("prediction of rsi works", { expect_output(rsi_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), model = "binomial", - col_ab = "amox", + col_ab = "AMX", col_date = "date", info = TRUE)) expect_output(rsi_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), model = "loglin", - col_ab = "amox", + col_ab = "AMX", col_date = "date", info = TRUE)) expect_output(rsi_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), model = "lin", - col_ab = "amox", + col_ab = "AMX", col_date = "date", info = TRUE)) expect_error(rsi_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), model = "INVALID MODEL", - col_ab = "amox", + col_ab = "AMX", col_date = "date", info = TRUE)) expect_error(rsi_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), @@ -65,12 +65,12 @@ test_that("prediction of rsi works", { col_date = "date", info = TRUE)) expect_error(rsi_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), - col_ab = "amox", + col_ab = "AMX", col_date = "NOT EXISTING COLUMN", info = TRUE)) - # almost all E. coli are mero S in the Netherlands :) + # almost all E. coli are MEM S in the Netherlands :) expect_error(resistance_predict(tbl = filter(septic_patients, mo == "B_ESCHR_COL"), - col_ab = "mero", + col_ab = "MEM", col_date = "date", info = TRUE)) diff --git a/tests/testthat/test-rsi.R b/tests/testthat/test-rsi.R index 422ea462a..1b827836a 100644 --- a/tests/testthat/test-rsi.R +++ b/tests/testthat/test-rsi.R @@ -47,7 +47,7 @@ test_that("rsi works", { library(dplyr) # 40 rsi columns expect_equal(septic_patients %>% - mutate_at(vars(peni:rifa), as.character) %>% + mutate_at(vars(PEN:RIF), as.character) %>% lapply(is.rsi.eligible) %>% as.logical() %>% sum(), diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index dab834d42..12b80a264 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -35,8 +35,8 @@ You can skip to [Cleaning the data](#cleaning-the-data) if you already have your knitr::kable(dplyr::tibble(date = Sys.Date(), patient_id = c("abcd", "abcd", "efgh"), mo = "Escherichia coli", - amox = c("S", "S", "R"), - cipr = c("S", "R", "S")), + AMX = c("S", "S", "R"), + CIP = c("S", "R", "S")), align = "c") ``` @@ -113,13 +113,13 @@ data <- data.frame(date = sample(dates, size = sample_size, replace = TRUE), prob = c(0.30, 0.35, 0.15, 0.20)), bacteria = sample(bacteria, size = sample_size, replace = TRUE, prob = c(0.50, 0.25, 0.15, 0.10)), - amox = sample(ab_interpretations, size = sample_size, replace = TRUE, + AMX = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.60, 0.05, 0.35)), - amcl = sample(ab_interpretations, size = sample_size, replace = TRUE, + AMC = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.75, 0.10, 0.15)), - cipr = sample(ab_interpretations, size = sample_size, replace = TRUE, + CIP = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.80, 0.00, 0.20)), - gent = sample(ab_interpretations, size = sample_size, replace = TRUE, + GEN = sample(ab_interpretations, size = sample_size, replace = TRUE, prob = c(0.92, 0.00, 0.08)) ) ``` @@ -166,12 +166,12 @@ We also want to transform the antibiotics, because in real life data we don't kn ```{r transform abx} data <- data %>% - mutate_at(vars(amox:gent), as.rsi) + mutate_at(vars(AMX:GEN), as.rsi) ``` Finally, we will apply [EUCAST rules](http://www.eucast.org/expert_rules_and_intrinsic_resistance/) on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the `eucast_rules()` function can also apply additional rules, like forcingWHO Collaborating Centre for Drug Statistics Methodology
ampicillin = R whenamoxicillin/clavulanic acid = R. -Because the amoxicillin (column `amox`) and amoxicillin/clavulanic acid (column `amcl`) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The `eucast_rules()` fixes this: +Because the amoxicillin (column `AMX`) and amoxicillin/clavulanic acid (column `AMC`) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The `eucast_rules()` fixes this: ```{r eucast, warning = FALSE, message = FALSE} data <- eucast_rules(data, col_mo = "bacteria") @@ -226,7 +226,7 @@ weighted_df <- data %>% # only most prevalent patient filter(patient_id == top_freq(freq(., patient_id), 1)[1]) %>% arrange(date) %>% - select(date, patient_id, bacteria, amox:gent, first) %>% + select(date, patient_id, bacteria, AMX:GEN, first) %>% # maximum of 10 rows .[1:min(10, nrow(.)),] %>% mutate(isolate = row_number()) %>% @@ -240,7 +240,7 @@ Only `r sum(weighted_df$first)` isolates are marked as 'first' according to CLSI If a column exists with a name like 'key(...)ab' the `first_isolate()` function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output: -```{r 1st weighted} +```{r 1st weighted, warning = FALSE} data <- data %>% mutate(keyab = key_antibiotics(.)) %>% mutate(first_weighted = first_isolate(.)) @@ -252,7 +252,7 @@ weighted_df2 <- data %>% # only most prevalent patient filter(patient_id == top_freq(freq(., patient_id), 1)[1]) %>% arrange(date) %>% - select(date, patient_id, bacteria, amox:gent, first, first_weighted) %>% + select(date, patient_id, bacteria, AMX:GEN, first, first_weighted) %>% # maximum of 10 rows .[1:min(10, nrow(.)),] %>% mutate(isolate = row_number()) %>% @@ -292,7 +292,7 @@ knitr::kable(head(data_1st), align = "c") Time for the analysis! # Analysing the data -You might want to start by getting an idea of how the data is distributed. It's an important start, because it also decides how you will continue your analysis. +You might want to start by getting an idea of how the data is distributed. It's an important start, because it also decides how you will continue your analysis. Although this package contains a convenient function to make frequency tables, exploratory data analysis (EDA) is not the primary scope of this package. Use a package like [`DataExplorer`](https://cran.r-project.org/package=DataExplorer) for that, or read the free online book [Exploratory Data Analysis with R](https://bookdown.org/rdpeng/exdata/) by Roger D. Peng. ## Dispersion of species To just get an idea how the species are distributed, create a frequency table with our `freq()` function. We created the `genus` and `species` column earlier based on the microbial ID. With `paste()`, we can concatenate them together. @@ -318,7 +318,7 @@ data_1st %>% The functions `portion_S()`, `portion_SI()`, `portion_I()`, `portion_IR()` and `portion_R()` can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own: ```{r} -data_1st %>% portion_IR(amox) +data_1st %>% portion_IR(AMX) ``` Or can be used in conjuction with `group_by()` and `summarise()`, both from the `dplyr` package: @@ -326,12 +326,12 @@ Or can be used in conjuction with `group_by()` and `summarise()`, both from the ```{r, eval = FALSE} data_1st %>% group_by(hospital) %>% - summarise(amoxicillin = portion_IR(amox)) + summarise(amoxicillin = portion_IR(AMX)) ``` ```{r, echo = FALSE} data_1st %>% group_by(hospital) %>% - summarise(amoxicillin = portion_IR(amox)) %>% + summarise(amoxicillin = portion_IR(AMX)) %>% knitr::kable(align = "c", big.mark = ",") ``` @@ -340,14 +340,14 @@ Of course it would be very convenient to know the number of isolates responsible ```{r, eval = FALSE} data_1st %>% group_by(hospital) %>% - summarise(amoxicillin = portion_IR(amox), - available = n_rsi(amox)) + summarise(amoxicillin = portion_IR(AMX), + available = n_rsi(AMX)) ``` ```{r, echo = FALSE} data_1st %>% group_by(hospital) %>% - summarise(amoxicillin = portion_IR(amox), - available = n_rsi(amox)) %>% + summarise(amoxicillin = portion_IR(AMX), + available = n_rsi(AMX)) %>% knitr::kable(align = "c", big.mark = ",") ``` @@ -356,16 +356,16 @@ These functions can also be used to get the portion of multiple antibiotics, to ```{r, eval = FALSE} data_1st %>% group_by(genus) %>% - summarise(amoxiclav = portion_S(amcl), - gentamicin = portion_S(gent), - amoxiclav_genta = portion_S(amcl, gent)) + summarise(amoxiclav = portion_S(AMC), + gentamicin = portion_S(GEN), + amoxiclav_genta = portion_S(AMC, GEN)) ``` ```{r, echo = FALSE} data_1st %>% group_by(genus) %>% - summarise(amoxiclav = portion_S(amcl), - gentamicin = portion_S(gent), - amoxiclav_genta = portion_S(amcl, gent)) %>% + summarise(amoxiclav = portion_S(AMC), + gentamicin = portion_S(GEN), + amoxiclav_genta = portion_S(AMC, GEN)) %>% knitr::kable(align = "c", big.mark = ",") ``` @@ -374,9 +374,9 @@ To make a transition to the next part, let's see how this difference could be pl ```{r plot 1} data_1st %>% group_by(genus) %>% - summarise("1. Amoxi/clav" = portion_S(amcl), - "2. Gentamicin" = portion_S(gent), - "3. Amoxi/clav + gent" = portion_S(amcl, gent)) %>% + summarise("1. Amoxi/clav" = portion_S(AMC), + "2. Gentamicin" = portion_S(GEN), + "3. Amoxi/clav + GEN" = portion_S(AMC, GEN)) %>% tidyr::gather("Antibiotic", "S", -genus) %>% ggplot(aes(x = genus, y = S, @@ -409,7 +409,7 @@ ggplot(data_1st) + geom_rsi(translate_ab = FALSE) ``` -Omit the `translate_ab = FALSE` to have the antibiotic codes (amox, amcl, cipr, gent) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin). +Omit the `translate_ab = FALSE` to have the antibiotic codes (AMX, AMC, CIP, GEN) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin). If we group on e.g. the `genus` column and add some additional functions from our package, we can create this: @@ -452,12 +452,12 @@ data_1st %>% The next example uses the included `septic_patients`, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This `data.frame` can be used to practice AMR analysis. -We will compare the resistance to fosfomycin (column `fosf`) in hospital A and D. The input for the final `fisher.test()` will be this: +We will compare the resistance to fosfomycin (column `FOS`) in hospital A and D. The input for the final `fisher.test()` will be this: ```{r, echo = FALSE, results = 'asis'} septic_patients %>% filter(hospital_id %in% c("A", "D")) %>% - select(hospital_id, fosf) %>% + select(hospital_id, FOS) %>% group_by(hospital_id) %>% count_df(combine_IR = TRUE) %>% tidyr::spread(hospital_id, Value) %>% @@ -472,7 +472,7 @@ We can transform the data and apply the test in only a couple of lines: ```{r} septic_patients %>% filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D - select(hospital_id, fosf) %>% # select the hospitals and fosfomycin + select(hospital_id, FOS) %>% # select the hospitals and fosfomycin group_by(hospital_id) %>% # group on the hospitals count_df(combine_IR = TRUE) %>% # count all isolates per group (hospital_id) tidyr::spread(hospital_id, Value) %>% # transform output so A and D are columns diff --git a/vignettes/SPSS.Rmd b/vignettes/SPSS.Rmd index e15765c87..ee8dc864e 100755 --- a/vignettes/SPSS.Rmd +++ b/vignettes/SPSS.Rmd @@ -64,7 +64,7 @@ As said, SPSS is easier to learn than R. But SPSS, SAS and Stata come with major If you are working at a midsized or small company, you can save it tens of thousands of dollars by using R instead of e.g. SPSS - gaining even more functions and flexibility. And all R enthousiasts can do as much PR as they want (like I do here), because nobody is officially associated with or affiliated by R. It is really free. -If you sometimes write syntaxes in SPSS to run a complete analysis or to 'automate' some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. +If you sometimes write syntaxes in SPSS to run a complete analysis or to 'automate' some of your work, you should perhaps do this in R. You will notice that writing syntaxes in R is a lot more nifty and clever than in SPSS. Still, as working with any statistical package, you will have to have knowledge about what you are doing (statistically) and what you are willing to accomplish. To demonstrate the first point: @@ -83,10 +83,10 @@ klebsiella_test <- data.frame(mo = "klebsiella", klebsiella_test eucast_rules(klebsiella_test, info = FALSE) -# hundreds of trade names can be translated to an ATC or name: -atc_name("floxapen") -as.atc("floxapen") -atc_tradenames("floxapen") +# hundreds of trade names can be translated to a name, trade name or an ATC code: +ab_name("floxapen") +ab_tradenames("floxapen") +ab_atc("floxapen") ``` ## Import data from SPSS/SAS/Stata diff --git a/vignettes/atc_property.Rmd b/vignettes/ab_property.Rmd similarity index 100% rename from vignettes/atc_property.Rmd rename to vignettes/ab_property.Rmd diff --git a/vignettes/benchmarks.Rmd b/vignettes/benchmarks.Rmd index 46ebf8b0e..a62dc7ea6 100755 --- a/vignettes/benchmarks.Rmd +++ b/vignettes/benchmarks.Rmd @@ -81,7 +81,7 @@ boxplot(microbenchmark(as.mo("Thermus islandicus"), as.mo("E. coli"), times = 10), horizontal = TRUE, las = 1, unit = "s", log = FALSE, - xlab = "", ylab = "Time in seconds", ylim = c(0, 0.5), + xlab = "", ylab = "Time in seconds", main = "Benchmarks per prevalence") ``` diff --git a/vignettes/resistance_predict.Rmd b/vignettes/resistance_predict.Rmd index 463d1ae61..72ff87738 100755 --- a/vignettes/resistance_predict.Rmd +++ b/vignettes/resistance_predict.Rmd @@ -41,16 +41,16 @@ Our package contains a function `resistance_predict()`, which takes the same inp It is basically as easy as: ```{r, eval = FALSE} -# resistance prediction of piperacillin/tazobactam (pita): -resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "pita") +# resistance prediction of piperacillin/tazobactam (TZP): +resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "TZP") # or: septic_patients %>% - resistance_predict(col_ab = "pita") + resistance_predict(col_ab = "TZP") -# to bind it to object 'predict_pita' for example: -predict_pita <- septic_patients %>% - resistance_predict(col_ab = "pita") +# to bind it to object 'predict_TZP' for example: +predict_TZP <- septic_patients %>% + resistance_predict(col_ab = "TZP") ``` The function will look for a date column itself if `col_date` is not set. @@ -58,20 +58,20 @@ The function will look for a date column itself if `col_date` is not set. When running any of these commands, a summary of the regression model will be printed unless using `resistance_predict(..., info = FALSE)`. ```{r, echo = FALSE} -predict_pita <- septic_patients %>% - resistance_predict(col_ab = "pita") +predict_TZP <- septic_patients %>% + resistance_predict(col_ab = "TZP") ``` This text is only a printed summary - the actual result (output) of the function is a `data.frame` containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation: ```{r} -predict_pita +predict_TZP ``` The function `plot` is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions: ```{r, fig.height = 5.5} -plot(predict_pita) +plot(predict_TZP) ``` This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model. @@ -79,10 +79,10 @@ This is the fastest way to plot the result. It automatically adds the right axes We also support the `ggplot2` package with our custom function `ggplot_rsi_predict()` to create more appealing plots: ```{r} -ggplot_rsi_predict(predict_pita) +ggplot_rsi_predict(predict_TZP) # choose for error bars instead of a ribbon -ggplot_rsi_predict(predict_pita, ribbon = FALSE) +ggplot_rsi_predict(predict_TZP, ribbon = FALSE) ``` ### Choosing the right model @@ -92,7 +92,7 @@ Resistance is not easily predicted; if we look at vancomycin resistance in Gram ```{r} septic_patients %>% filter(mo_gramstain(mo) == "Gram positive") %>% - resistance_predict(col_ab = "vanc", year_min = 2010, info = FALSE) %>% + resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE) %>% ggplot_rsi_predict() ``` @@ -113,7 +113,7 @@ For the vancomycin resistance in Gram positive bacteria, a linear model might be ```{r} septic_patients %>% filter(mo_gramstain(mo) == "Gram positive") %>% - resistance_predict(col_ab = "vanc", year_min = 2010, info = FALSE, model = "linear") %>% + resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "linear") %>% ggplot_rsi_predict() ``` @@ -121,7 +121,7 @@ This seems more likely, doesn't it? The model itself is also available from the object, as an `attribute`: ```{r} -model <- attributes(predict_pita)$model +model <- attributes(predict_TZP)$model summary(model)$family