From 38a4421450da23c9e953363b14a4652a30443bc9 Mon Sep 17 00:00:00 2001
From: "Matthijs S. Berends"
Date: Mon, 13 May 2019 10:10:16 +0200
Subject: [PATCH] CI tests
---
DESCRIPTION | 2 +-
NEWS.md | 6 ++-
R/ab.R | 10 ++--
R/count.R | 64 ++++--------------------
R/ggplot_rsi.R | 33 +++++++++++--
R/guess_ab_col.R | 35 ++++++-------
R/portion.R | 76 +++++-----------------------
R/rsi.R | 42 ++++++++++------
R/rsi_calc.R | 85 ++++++++++++++++++++++++++++++++
R/whocc.R | 2 +-
docs/index.html | 5 +-
docs/news/index.html | 9 +++-
docs/reference/WHOCC.html | 2 +-
docs/reference/antibiotics.html | 2 +-
docs/reference/as.ab.html | 7 +--
docs/reference/as.atc.html | 2 +-
docs/reference/as.rsi.html | 15 ++++++
docs/reference/count.html | 21 ++++++--
docs/reference/ggplot_rsi.html | 18 ++++---
docs/reference/guess_ab_col.html | 16 ++++--
docs/reference/portion.html | 22 +++++++--
index.md | 5 +-
man/WHOCC.Rd | 2 +-
man/antibiotics.Rd | 2 +-
man/as.ab.Rd | 6 ++-
man/as.atc.Rd | 2 +-
man/as.rsi.Rd | 17 +++++++
man/count.Rd | 21 +++++++-
man/ggplot_rsi.Rd | 16 +++---
man/guess_ab_col.Rd | 11 +++--
man/portion.Rd | 22 ++++++++-
tests/testthat/test-ab.R | 3 ++
tests/testthat/test-atc.R | 39 +++++++++++++++
tests/testthat/test-count.R | 9 +++-
tests/testthat/test-portion.R | 9 +++-
tests/testthat/test-rsi.R | 50 +++++++++++++++++++
36 files changed, 475 insertions(+), 213 deletions(-)
create mode 100755 tests/testthat/test-atc.R
diff --git a/DESCRIPTION b/DESCRIPTION
index f29d3eaf..ae7ddc00 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,6 +1,6 @@
Package: AMR
Version: 0.6.1.9003
-Date: 2019-05-11
+Date: 2019-05-13
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(
diff --git a/NEWS.md b/NEWS.md
index 356bce49..e794ec0c 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,7 +6,10 @@
#### Changed
* 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)
+ * All entries now have 3 different identifiers:
+ * Column `ab` contains a human readable EARS-Net code, used by ECDC and WHO/WHONET - this is the primary identifier used in this package
+ * Column `atc` contains the ATC code, used by WHO/WHOCC
+ * Column `cid` contains the CID code (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
@@ -18,6 +21,7 @@
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
+* This package now honours the new EUCAST insight (2019) that S and I are but classified as susceptible, where I is defined as 'increased exposure' and not 'intermediate' anymore. For functions like `portion_df()` and `count_df()` this means that their new parameter `combine_SI` is TRUE at default.
* 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`.
diff --git a/R/ab.R b/R/ab.R
index 62fd2074..09fdf302 100755
--- a/R/ab.R
+++ b/R/ab.R
@@ -28,7 +28,9 @@
#' @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.
+#' @details All entries in the \code{\{link{antibiotics}} data set have three different identifiers: a human readable EARS-Net code (column \code{ab}, used by ECDC and WHONET), an ATC code (column \code{atc}, used by WHO), and a CID code (column \code{cid}, Compound ID, used by PubChem). The data set contains more than 5,000 official brand names from many different countries, as found in PubChem.
+#'
+#' 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/}
@@ -38,7 +40,7 @@
#' 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}.
+#' @return Character (vector) with class \code{"ab"}. 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
@@ -64,9 +66,9 @@ as.ab <- function(x) {
}
x_bak <- x
# remove suffices
- x_bak_clean <- gsub("_(mic|rsi)$", "", x)
+ x_bak_clean <- gsub("_(mic|rsi|disk|disc)$", "", x)
# remove disk concentrations, like LVX_NM -> LVX
- x_bak_clean <- gsub("_[A-Z]{2}[0-9_]{0,3}$", "", x_bak_clean)
+ x_bak_clean <- gsub("_[A-Z]{2}[0-9_]{0,3}$", "", x_bak_clean, ignore.case = TRUE)
# 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
diff --git a/R/count.R b/R/count.R
index 37f2e8cb..492369bc 100755
--- a/R/count.R
+++ b/R/count.R
@@ -26,6 +26,7 @@
#' \code{count_R} and \code{count_IR} can be used to count resistant isolates, \code{count_S} and \code{count_SI} can be used to count susceptible isolates.\cr
#' @param ... one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed.
#' @inheritParams portion
+#' @inheritSection as.rsi Interpretation of S, I and R
#' @details These functions are meant to count isolates. Use the \code{\link{portion}_*} functions to calculate microbial resistance.
#'
#' \code{n_rsi} is an alias of \code{count_all}. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to \code{\link{n_distinct}}. Their function is equal to \code{count_S(...) + count_IR(...)}.
@@ -174,61 +175,14 @@ n_rsi <- function(...) {
count_df <- function(data,
translate_ab = "name",
language = get_locale(),
+ combine_SI = TRUE,
combine_IR = FALSE) {
- if (!"data.frame" %in% class(data)) {
- stop("`count_df` must be called on a data.frame")
- }
-
- if (data %>% select_if(is.rsi) %>% ncol() == 0) {
- stop("No columns with class 'rsi' found. See ?as.rsi.")
- }
-
- if (as.character(translate_ab) %in% c("TRUE", "official")) {
- translate_ab <- "name"
- }
-
- resS <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = count_S) %>%
- mutate(Interpretation = "S") %>%
- select(Interpretation, everything())
-
- if (combine_IR == FALSE) {
- resI <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = count_I) %>%
- mutate(Interpretation = "I") %>%
- select(Interpretation, everything())
-
- resR <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = count_R) %>%
- mutate(Interpretation = "R") %>%
- select(Interpretation, everything())
-
- data.groups <- group_vars(data)
-
- res <- bind_rows(resS, resI, resR) %>%
- mutate(Interpretation = factor(Interpretation, levels = c("R", "I", "S"), ordered = TRUE)) %>%
- tidyr::gather(Antibiotic, Value, -Interpretation, -data.groups)
- } else {
- resIR <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = count_IR) %>%
- mutate(Interpretation = "IR") %>%
- select(Interpretation, everything())
-
- data.groups <- group_vars(data)
-
- res <- bind_rows(resS, resIR) %>%
- mutate(Interpretation = factor(Interpretation, levels = c("IR", "S"), ordered = TRUE)) %>%
- tidyr::gather(Antibiotic, Value, -Interpretation, -data.groups)
- }
-
- if (!translate_ab == FALSE) {
- res <- res %>% mutate(Antibiotic = ab_property(Antibiotic, property = translate_ab, language = language))
- }
-
- res
+ rsi_calc_df(type = "count",
+ data = data,
+ translate_ab = translate_ab,
+ language = language,
+ combine_SI = combine_SI,
+ combine_IR = combine_IR,
+ combine_SI_missing = missing(combine_SI))
}
diff --git a/R/ggplot_rsi.R b/R/ggplot_rsi.R
index dad04951..126cb796 100755
--- a/R/ggplot_rsi.R
+++ b/R/ggplot_rsi.R
@@ -29,9 +29,8 @@
#' @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{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}}
+#' @inheritParams portion
#' @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
@@ -158,6 +157,8 @@ ggplot_rsi <- function(data,
breaks = seq(0, 1, 0.1),
limits = NULL,
translate_ab = "name",
+ combine_SI = TRUE,
+ combine_IR = FALSE,
language = get_locale(),
fun = count_df,
nrow = NULL,
@@ -196,7 +197,8 @@ ggplot_rsi <- function(data,
}
p <- ggplot2::ggplot(data = data) +
- geom_rsi(position = position, x = x, fill = fill, translate_ab = translate_ab, fun = fun, ...) +
+ geom_rsi(position = position, x = x, fill = fill, translate_ab = translate_ab,
+ fun = fun, combine_SI = combine_SI, combine_IR = combine_IR, ...) +
theme_rsi()
if (fill == "Interpretation") {
@@ -233,11 +235,17 @@ geom_rsi <- function(position = NULL,
fill = "Interpretation",
translate_ab = "name",
language = get_locale(),
+ combine_SI = TRUE,
+ combine_IR = FALSE,
fun = count_df,
...) {
stopifnot_installed_package("ggplot2")
+ if (is.data.frame(position)) {
+ stop("`position` is invalid. Did you accidentally use '%>%' instead of '+'?", call. = FALSE)
+ }
+
fun_name <- deparse(substitute(fun))
if (!fun_name %in% c("portion_df", "count_df", "fun")) {
stop("`fun` must be portion_df or count_df")
@@ -272,7 +280,13 @@ geom_rsi <- function(position = NULL,
ggplot2::layer(geom = "bar", stat = "identity", position = position,
mapping = ggplot2::aes_string(x = x, y = y, fill = fill),
- data = fun, params = list(...))
+ params = list(...), data = function(x) {
+ fun(data = x,
+ translate_ab = translate_ab,
+ language = language,
+ combine_SI = combine_SI,
+ combine_IR = combine_IR)
+ })
}
@@ -320,7 +334,16 @@ scale_y_percent <- function(breaks = seq(0, 1, 0.1), limits = NULL) {
scale_rsi_colours <- function() {
stopifnot_installed_package("ggplot2")
#ggplot2::scale_fill_brewer(palette = "RdYlGn")
- ggplot2::scale_fill_manual(values = c("#b22222", "#ae9c20", "#7cfc00"))
+ #ggplot2::scale_fill_manual(values = c("#b22222", "#ae9c20", "#7cfc00"))
+
+ # mixed using https://www.colorhexa.com/b22222
+ # and https://www.w3schools.com/colors/colors_mixer.asp
+ ggplot2::scale_fill_manual(values = c(S = "#22b222",
+ SI = "#22b222",
+ I = "#548022",
+ IR = "#b22222",
+ R = "#b22222"))
+
}
#' @rdname ggplot_rsi
diff --git a/R/guess_ab_col.R b/R/guess_ab_col.R
index 80eccb97..70e542d6 100755
--- a/R/guess_ab_col.R
+++ b/R/guess_ab_col.R
@@ -22,11 +22,12 @@
#' Guess antibiotic column
#'
#' This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. Also supports WHONET abbreviations. You can look for an antibiotic (trade) name or abbreviation and it will search the \code{data.frame} for any column containing a name or ATC code of that antibiotic.
-#' @param tbl a \code{data.frame}
-#' @param col a character to look for
+#' @param x a \code{data.frame}
+#' @param search_string a text to search \code{x} for
#' @param verbose a logical to indicate whether additional info should be printed
#' @importFrom dplyr %>% select filter_all any_vars
#' @importFrom crayon blue
+#' @return A column name of \code{x}, or \code{NULL} when no result is found.
#' @export
#' @inheritSection AMR Read more on our website!
#' @examples
@@ -39,7 +40,7 @@
#' # [1] "tetr"
#'
#' guess_ab_col(df, "J01AA07", verbose = TRUE)
-#' # using column `tetr` for col "J01AA07"
+#' # Note: Using column `tetr` as input for "J01AA07".
#' # [1] "tetr"
#'
#' # WHONET codes
@@ -51,40 +52,40 @@
#' # [1] "AMC_ED20"
#' 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)) {
+guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE) {
+ if (is.null(x) & is.null(search_string)) {
return(as.name("guess_ab_col"))
}
- if (length(col) > 1) {
- warning("argument 'col' has length > 1 and only the first element will be used")
- col <- col[1]
+ if (length(search_string) > 1) {
+ warning("argument 'search_string' has length > 1 and only the first element will be used")
+ search_string <- search_string[1]
}
- col <- as.character(col)
- if (!is.data.frame(tbl)) {
- stop("`tbl` must be a data.frame")
+ search_string <- as.character(search_string)
+ if (!is.data.frame(x)) {
+ stop("`x` must be a data.frame")
}
- if (col %in% colnames(tbl)) {
- ab_result <- col
+ if (search_string %in% colnames(x)) {
+ ab_result <- search_string
} else {
# sort colnames on length - longest first
- cols <- colnames(tbl[, tbl %>% colnames() %>% nchar() %>% order() %>% rev()])
+ cols <- colnames(x[, x %>% 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 <- df_trans[which(df_trans$abs == as.ab(search_string)), "cols"]
ab_result <- ab_result[!is.na(ab_result)][1L]
}
if (length(ab_result) == 0) {
if (verbose == TRUE) {
- message('No column found as input for `', col, '`.')
+ message('No column found as input for `', search_string, '`.')
}
return(NULL)
} else {
if (verbose == TRUE) {
- message(blue(paste0("NOTE: Using column `", bold(ab_result), "` as input for `", col, "`.")))
+ message(blue(paste0("NOTE: Using column `", bold(ab_result), "` as input for `", search_string, "`.")))
}
return(ab_result)
}
diff --git a/R/portion.R b/R/portion.R
index b55bafcd..0896b3bd 100755
--- a/R/portion.R
+++ b/R/portion.R
@@ -31,7 +31,8 @@
#' @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{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)
+#' @param combine_SI a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter \code{combine_IR}, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now \code{TRUE}.
+#' @inheritSection as.rsi Interpretation of S, I and R
#' @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.}
@@ -220,69 +221,16 @@ portion_df <- function(data,
language = get_locale(),
minimum = 30,
as_percent = FALSE,
+ combine_SI = TRUE,
combine_IR = FALSE) {
- if (!"data.frame" %in% class(data)) {
- stop("`portion_df` must be called on a data.frame")
- }
-
- if (data %>% select_if(is.rsi) %>% ncol() == 0) {
- stop("No columns with class 'rsi' found. See ?as.rsi.")
- }
-
- if (as.character(translate_ab) %in% c("TRUE", "official")) {
- translate_ab <- "name"
- }
-
- resS <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = portion_S,
- minimum = minimum,
- as_percent = as_percent) %>%
- mutate(Interpretation = "S") %>%
- select(Interpretation, everything())
-
- if (combine_IR == FALSE) {
- resI <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = portion_I,
- minimum = minimum,
- as_percent = as_percent) %>%
- mutate(Interpretation = "I") %>%
- select(Interpretation, everything())
-
- resR <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = portion_R,
- minimum = minimum,
- as_percent = as_percent) %>%
- mutate(Interpretation = "R") %>%
- select(Interpretation, everything())
-
- data.groups <- group_vars(data)
-
- res <- bind_rows(resS, resI, resR) %>%
- mutate(Interpretation = factor(Interpretation, levels = c("R", "I", "S"), ordered = TRUE)) %>%
- tidyr::gather(Antibiotic, Value, -Interpretation, -data.groups)
- } else {
- resIR <- summarise_if(.tbl = data,
- .predicate = is.rsi,
- .funs = portion_IR,
- minimum = minimum,
- as_percent = as_percent) %>%
- mutate(Interpretation = "IR") %>%
- select(Interpretation, everything())
-
- data.groups <- group_vars(data)
-
- res <- bind_rows(resS, resIR) %>%
- mutate(Interpretation = factor(Interpretation, levels = c("IR", "S"), ordered = TRUE)) %>%
- tidyr::gather(Antibiotic, Value, -Interpretation, -data.groups)
- }
-
- if (!translate_ab == FALSE) {
- res <- res %>% mutate(Antibiotic = ab_property(Antibiotic, property = translate_ab, language = language))
- }
-
- res
+ rsi_calc_df(type = "portion",
+ data = data,
+ translate_ab = translate_ab,
+ language = language,
+ minimum = minimum,
+ as_percent = as_percent,
+ combine_SI = combine_SI,
+ combine_IR = combine_IR,
+ combine_SI_missing = missing(combine_SI))
}
diff --git a/R/rsi.R b/R/rsi.R
index 705e256c..d62f21cf 100755
--- a/R/rsi.R
+++ b/R/rsi.R
@@ -35,6 +35,20 @@
#' 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 Interpretation of S, I and R:
+#' In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+#'
+#' \itemize{
+#' \item{\strong{S}}{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
+#' \item{\strong{I}}{Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.}
+#' \item{\strong{R}}{Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.}
+#' }
+#'
+#' Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+#'
+#' Source: \url{http://www.eucast.org/newsiandr/}.
+#'
+#' \strong{This AMR package honours this new insight.}
#' @return Ordered factor with new class \code{rsi}
#' @keywords rsi
#' @export
@@ -182,17 +196,17 @@ exec_as.rsi <- function(method, x, mo, ab, guideline) {
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) %>%
+ guideline_param <- toupper(guideline)
+ if (guideline_param %in% c("CLSI", "EUCAST")) {
+ guideline_param <- AMR::rsi_translation %>%
+ filter(guideline %like% guideline_param) %>%
pull(guideline) %>%
sort() %>%
rev() %>%
.[1]
}
- if (!guideline %in% AMR::rsi_translation$guideline) {
+ if (!guideline_param %in% AMR::rsi_translation$guideline) {
stop(paste0("invalid guideline: '", guideline,
"'.\nValid guidelines are: ", paste0("'", rev(sort(unique(AMR::rsi_translation$guideline))), "'", collapse = ", ")),
call. = FALSE)
@@ -200,7 +214,7 @@ exec_as.rsi <- function(method, x, mo, ab, guideline) {
new_rsi <- rep(NA_character_, length(x))
trans <- AMR::rsi_translation %>%
- filter(guideline == guideline) %>%
+ filter(guideline == guideline_param) %>%
mutate(lookup = paste(mo, ab))
lookup_mo <- paste(mo, ab)
@@ -224,15 +238,15 @@ exec_as.rsi <- function(method, x, mo, ab, guideline) {
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")
+ new_rsi[i] <- case_when(isTRUE(x[i] <= get_record$S_mic) ~ "S",
+ isTRUE(x[i] >= get_record$R_mic) ~ "R",
+ !is.na(get_record$S_mic) & !is.na(get_record$R_mic) ~ "I",
+ TRUE ~ NA_character_)
} 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")
+ new_rsi[i] <- case_when(isTRUE(x[i] >= get_record$S_disk) ~ "S",
+ isTRUE(x[i] <= get_record$R_disk) ~ "R",
+ !is.na(get_record$S_disk) & !is.na(get_record$R_disk) ~ "I",
+ TRUE ~ NA_character_)
}
}
diff --git a/R/rsi_calc.R b/R/rsi_calc.R
index f887c172..cfe764e1 100755
--- a/R/rsi_calc.R
+++ b/R/rsi_calc.R
@@ -150,3 +150,88 @@ rsi_calc <- function(...,
result
}
}
+
+rsi_calc_df <- function(type, # "portion" or "count"
+ data,
+ translate_ab = "name",
+ language = get_locale(),
+ minimum = 30,
+ as_percent = FALSE,
+ combine_SI = TRUE,
+ combine_IR = FALSE,
+ combine_SI_missing = FALSE) {
+
+ if (!"data.frame" %in% class(data)) {
+ stop(paste0("`", type, "_df` must be called on a data.frame"), call. = FALSE)
+ }
+
+ if (isTRUE(combine_IR) & isTRUE(combine_SI_missing)) {
+ combine_SI <- FALSE
+ }
+ if (isTRUE(combine_SI) & isTRUE(combine_IR)) {
+ stop("either `combine_SI` or `combine_IR` can be TRUE", call. = FALSE)
+ }
+
+ if (data %>% select_if(is.rsi) %>% ncol() == 0) {
+ stop("No columns with class 'rsi' found. See ?as.rsi.", call. = FALSE)
+ }
+
+ if (as.character(translate_ab) %in% c("TRUE", "official")) {
+ translate_ab <- "name"
+ }
+
+ get_summaryfunction <- function(int) {
+ # look for portion_S, count_S, etc:
+ int_fn <- get(paste0(type, "_", int), envir = asNamespace("AMR"))
+
+ if (type == "portion") {
+ summ <- summarise_if(.tbl = data,
+ .predicate = is.rsi,
+ .funs = int_fn,
+ minimum = minimum,
+ as_percent = as_percent)
+ } else if (type == "count") {
+ summ <- summarise_if(.tbl = data,
+ .predicate = is.rsi,
+ .funs = int_fn)
+ }
+ summ %>%
+ mutate(Interpretation = int) %>%
+ select(Interpretation, everything())
+ }
+
+ resS <- get_summaryfunction("S")
+ resI <- get_summaryfunction("I")
+ resR <- get_summaryfunction("R")
+ resSI <- get_summaryfunction("SI")
+ resIR <- get_summaryfunction("IR")
+ data.groups <- group_vars(data)
+
+ if (isFALSE(combine_SI) & isFALSE(combine_IR)) {
+ res <- bind_rows(resS, resI, resR) %>%
+ mutate(Interpretation = factor(Interpretation,
+ levels = c("S", "I", "R"),
+ ordered = TRUE))
+
+ } else if (isTRUE(combine_IR)) {
+ res <- bind_rows(resS, resIR) %>%
+ mutate(Interpretation = factor(Interpretation,
+ levels = c("S", "IR"),
+ ordered = TRUE))
+
+ } else if (isTRUE(combine_SI)) {
+ res <- bind_rows(resSI, resR) %>%
+ mutate(Interpretation = factor(Interpretation,
+ levels = c("SI", "R"),
+ ordered = TRUE))
+ }
+
+ res <- res %>%
+ tidyr::gather(Antibiotic, Value, -Interpretation, -data.groups)
+
+ if (!translate_ab == FALSE) {
+ res <- res %>% mutate(Antibiotic = ab_property(Antibiotic, property = translate_ab, language = language))
+ }
+
+ res
+}
diff --git a/R/whocc.R b/R/whocc.R
index c49552fb..6566a6ba 100755
--- a/R/whocc.R
+++ b/R/whocc.R
@@ -24,7 +24,7 @@
#' All antimicrobial drugs and their official names, ATC codes, ATC groups and defined daily dose (DDD) are included in this package, using the WHO Collaborating Centre for Drug Statistics Methodology.
#' @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}).
+#' This package contains \strong{all ~450 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.
#'
diff --git a/docs/index.html b/docs/index.html
index b0978a81..dbb82f62 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -204,6 +204,7 @@
- Reference for microorganisms, since it contains all microbial (sub)species from the Catalogue of Life
+- Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines
- Calculating antimicrobial resistance
- Calculating empirical susceptibility of both mono therapy and combination therapy
- Predicting future antimicrobial resistance using regression models
@@ -211,7 +212,7 @@
- Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)
- Plotting antimicrobial resistance
- Determining first isolates to be used for AMR analysis
-- Applying EUCAST expert rules (not the translation from MIC to RSI values)
+- Applying EUCAST expert rules
- Determining multi-drug resistant organisms (MDRO)
- Descriptive statistics: frequency tables, kurtosis and skewness
@@ -314,7 +315,7 @@
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 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. Moreover, it can group Staphylococci into coagulase negative and positive (CoNS and CoPS, see source) and can categorise Streptococci into Lancefield groups (like beta-haemolytic Streptococcus Group B, 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.rsi()
to get antibiotic interpretations based on raw MIC values (in mg/L) or disk diffusion values (in mm), or transform existing 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.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.
diff --git a/docs/news/index.html b/docs/news/index.html
index fa364bc1..accffc4c 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -250,7 +250,13 @@
- 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)
+- All entries now have 3 different identifiers:
+
+- Column
ab
contains a human readable EARS-Net code, used by ECDC and WHO/WHONET - this is the primary identifier used in this package
+- Column
atc
contains the ATC code, used by WHO/WHOCC
+- Column
cid
contains the CID code (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
@@ -264,6 +270,7 @@ Please create an issue in one of our repositories if you want additions in this
- 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
+- This package now honours the new EUCAST insight (2019) that S and I are but classified as susceptible, where I is defined as ‘increased exposure’ and not ‘intermediate’ anymore. For functions like
portion_df()
and count_df()
this means that their new parameter combine_SI
is TRUE at default.
- Removed deprecated functions
guess_mo()
, guess_atc()
, EUCAST_rules()
, interpretive_reading()
, rsi()
- Frequency tables of microbial IDs speed improvement
diff --git a/docs/reference/WHOCC.html b/docs/reference/WHOCC.html
index 7e8d22da..f00f1d26 100644
--- a/docs/reference/WHOCC.html
+++ b/docs/reference/WHOCC.html
@@ -246,7 +246,7 @@
-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) 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.
diff --git a/docs/reference/antibiotics.html b/docs/reference/antibiotics.html
index 9d0a2b38..3b2df153 100644
--- a/docs/reference/antibiotics.html
+++ b/docs/reference/antibiotics.html
@@ -276,7 +276,7 @@
-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) 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.
diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html
index 644165a6..be457dde 100644
--- a/docs/reference/as.ab.html
+++ b/docs/reference/as.ab.html
@@ -254,11 +254,12 @@
Value
- Character (vector) with class "act"
. Unknown values will return NA
.
+ Character (vector) with class "ab"
. Unknown values will return NA
.
Details
- Use the ab_property
functions to get properties based on the returned ATC code, see Examples.
+ All entries in the {link{antibiotics}
data set have three different identifiers: a human readable EARS-Net code (column ab
, used by ECDC and WHONET), an ATC code (column atc
, used by WHO), and a CID code (column cid
, Compound ID, used by PubChem). The data set contains more than 5,000 official brand names from many different countries, as found in PubChem.
+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/
@@ -273,7 +274,7 @@
-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) 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.
diff --git a/docs/reference/as.atc.html b/docs/reference/as.atc.html
index 84963401..88b6b92d 100644
--- a/docs/reference/as.atc.html
+++ b/docs/reference/as.atc.html
@@ -270,7 +270,7 @@
-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) 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.
diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html
index d78ff890..0a754a70 100644
--- a/docs/reference/as.rsi.html
+++ b/docs/reference/as.rsi.html
@@ -300,6 +300,19 @@
After using as.rsi
, you can use 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 is.rsi.eligible
returns TRUE
when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and FALSE
otherwise. The threshold of 5% can be set with the threshold
parameter.
+ Interpretation of S, I and R
+
+
+ In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+
+SSusceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.
+ISusceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
+RResistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.
+
+ Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+Source: http://www.eucast.org/newsiandr/.
+This AMR package honours this new insight.
+
Read more on our website!
@@ -358,6 +371,8 @@
Details
+ Interpretation of S, I and R
+
Read more on our website!
See also
diff --git a/docs/reference/count.html b/docs/reference/count.html
index ae777514..1f1b64ee 100644
--- a/docs/reference/count.html
+++ b/docs/reference/count.html
@@ -258,7 +258,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
n_rsi(...)
count_df(data, translate_ab = "name", language = get_locale(),
- combine_IR = FALSE)
+ combine_SI = TRUE, combine_IR = FALSE)
Arguments
@@ -284,8 +284,8 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
language of the returned text, defaults to system language (see get_locale ) and can also be set with getOption("AMR_locale") . Use language = NULL or language = "" to prevent translation. |
- 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) |
+ combine_SI |
+ a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter combine_IR , but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now TRUE . |
@@ -303,6 +303,19 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
n_rsi
is an alias of count_all
. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to n_distinct
. Their function is equal to count_S(...) + count_IR(...)
.
count_df
takes any variable from data
that has an "rsi"
class (created with as.rsi
) and counts the amounts of 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"
.
+ Interpretation of S, I and R
+
+
+ In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+
+SSusceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.
+ISusceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
+RResistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.
+
+ Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+Source: http://www.eucast.org/newsiandr/.
+This AMR package honours this new insight.
+
Read more on our website!
@@ -384,6 +397,8 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
Details
+ Interpretation of S, I and R
+
Read more on our website!
See also
diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html
index db3236cf..6a85bad8 100644
--- a/docs/reference/ggplot_rsi.html
+++ b/docs/reference/ggplot_rsi.html
@@ -243,13 +243,15 @@
ggplot_rsi(data, position = NULL, x = "Antibiotic",
fill = "Interpretation", facet = NULL, breaks = seq(0, 1, 0.1),
- limits = NULL, translate_ab = "name", language = get_locale(),
- fun = count_df, nrow = NULL, datalabels = TRUE,
- datalabels.size = 3, datalabels.colour = "grey15", ...)
+ limits = NULL, translate_ab = "name", combine_SI = TRUE,
+ combine_IR = FALSE, 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 = "name",
- language = get_locale(), fun = count_df, ...)
+ language = get_locale(), combine_SI = TRUE, combine_IR = FALSE,
+ fun = count_df, ...)
facet_rsi(facet = c("Interpretation", "Antibiotic"), nrow = NULL)
@@ -295,11 +297,15 @@
translate_ab |
- a column name of the antibiotics data set to translate the antibiotic abbreviations into, using ab_name . Default behaviour is to translate to official names according to the WHO. Use translate_ab = FALSE to disable translation. |
+ a column name of the antibiotics data set to translate the antibiotic abbreviations to, using ab_property |
+
+
+ combine_SI |
+ a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter combine_IR , but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now TRUE . |
language |
- the language used for translation of antibiotic names |
+ language of the returned text, defaults to system language (see get_locale ) and can also be set with getOption("AMR_locale") . Use language = NULL or language = "" to prevent translation. |
fun |
diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html
index 296680ca..5b41f545 100644
--- a/docs/reference/guess_ab_col.html
+++ b/docs/reference/guess_ab_col.html
@@ -241,18 +241,18 @@
- guess_ab_col(tbl = NULL, col = NULL, verbose = FALSE)
+ guess_ab_col(x = NULL, search_string = NULL, verbose = FALSE)
Arguments
- tbl |
+ x |
a data.frame |
- col |
- a character to look for |
+ search_string |
+ a text to search x for |
verbose |
@@ -260,6 +260,10 @@
+ Value
+
+ A column name of x
, or NULL
when no result is found.
+
Read more on our website!
@@ -277,7 +281,7 @@
# [1] "tetr"
guess_ab_col(df, "J01AA07", verbose = TRUE)
-# using column `tetr` for col "J01AA07"
+# Note: Using column `tetr` as input for "J01AA07".
# [1] "tetr"
# WHONET codes
@@ -296,6 +300,8 @@
- Arguments
+ - Value
+
- Read more on our website!
- Examples
diff --git a/docs/reference/portion.html b/docs/reference/portion.html
index a488db6a..8fbdaacf 100644
--- a/docs/reference/portion.html
+++ b/docs/reference/portion.html
@@ -259,7 +259,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
also_single_tested = FALSE)
portion_df(data, translate_ab = "name", language = get_locale(),
- minimum = 30, as_percent = FALSE, combine_IR = FALSE)
+ minimum = 30, as_percent = FALSE, combine_SI = TRUE,
+ combine_IR = FALSE)
Arguments
@@ -293,8 +294,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
language of the returned text, defaults to system language (see get_locale ) and can also be set with getOption("AMR_locale") . Use language = NULL or language = "" to prevent translation. |
- 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) |
+ combine_SI |
+ a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter combine_IR , but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now TRUE . |
@@ -325,6 +326,19 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
And so on.
+ Interpretation of S, I and R
+
+
+ In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+
+SSusceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.
+ISusceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.
+RResistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.
+
+ Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+Source: http://www.eucast.org/newsiandr/.
+This AMR package honours this new insight.
+
Read more on our website!
@@ -422,6 +436,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
- Details
+ - Interpretation of S, I and R
+
- Read more on our website!
- See also
diff --git a/index.md b/index.md
index 7ad967e6..44c362ad 100644
--- a/index.md
+++ b/index.md
@@ -16,6 +16,7 @@ This R package is actively maintained and is free software; you can freely use a
This package can be used for:
* Reference for microorganisms, since it contains all microbial (sub)species from the [Catalogue of Life](http://www.catalogueoflife.org)
+ * Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines
* Calculating antimicrobial resistance
* Calculating empirical susceptibility of both mono therapy and combination therapy
* Predicting future antimicrobial resistance using regression models
@@ -23,7 +24,7 @@ This package can be used for:
* Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)
* Plotting antimicrobial resistance
* Determining first isolates to be used for AMR analysis
- * Applying EUCAST expert rules (not the translation from MIC to RSI values)
+ * Applying EUCAST expert rules
* Determining multi-drug resistant organisms (MDRO)
* Descriptive statistics: frequency tables, kurtosis and skewness
@@ -133,7 +134,7 @@ 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 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.rsi()` to get antibiotic interpretations based on raw MIC values (in mg/L) or disk diffusion values (in mm), or transform existing 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.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.
diff --git a/man/WHOCC.Rd b/man/WHOCC.Rd
index b63b1c30..6ce87ab7 100644
--- a/man/WHOCC.Rd
+++ b/man/WHOCC.Rd
@@ -9,7 +9,7 @@ All antimicrobial drugs and their official names, ATC codes, ATC groups and defi
\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}).
+This package contains \strong{all ~450 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.
diff --git a/man/antibiotics.Rd b/man/antibiotics.Rd
index 9f1b6cd2..93776f10 100644
--- a/man/antibiotics.Rd
+++ b/man/antibiotics.Rd
@@ -41,7 +41,7 @@ Synonyms (i.e. trade names) are derived from the Compound ID (\code{cid}) and co
\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}).
+This package contains \strong{all ~450 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.
diff --git a/man/as.ab.Rd b/man/as.ab.Rd
index d8776bf1..bbc072bd 100644
--- a/man/as.ab.Rd
+++ b/man/as.ab.Rd
@@ -10,12 +10,14 @@ as.ab(x)
\item{x}{character vector to determine to antibiotic ID}
}
\value{
-Character (vector) with class \code{"act"}. Unknown values will return \code{NA}.
+Character (vector) with class \code{"ab"}. 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{
+All entries in the \code{\{link{antibiotics}} data set have three different identifiers: a human readable EARS-Net code (column \code{ab}, used by ECDC and WHONET), an ATC code (column \code{atc}, used by WHO), and a CID code (column \code{cid}, Compound ID, used by PubChem). The data set contains more than 5,000 official brand names from many different countries, as found in PubChem.
+
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.
@@ -33,7 +35,7 @@ European Commission Public Health PHARMACEUTICALS - COMMUNITY REGISTER: \url{htt
\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}).
+This package contains \strong{all ~450 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.
diff --git a/man/as.atc.Rd b/man/as.atc.Rd
index 888b3bf1..7c8b623b 100644
--- a/man/as.atc.Rd
+++ b/man/as.atc.Rd
@@ -31,7 +31,7 @@ In the ATC classification system, the active substances are classified in a hier
\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}).
+This package contains \strong{all ~450 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.
diff --git a/man/as.rsi.Rd b/man/as.rsi.Rd
index b03eb627..d931ee75 100755
--- a/man/as.rsi.Rd
+++ b/man/as.rsi.Rd
@@ -50,6 +50,23 @@ After using \code{as.rsi}, you can use \code{\link{eucast_rules}} to (1) apply i
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{Interpretation of S, I and R}{
+
+In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+
+\itemize{
+ \item{\strong{S}}{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
+ \item{\strong{I}}{Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.}
+ \item{\strong{R}}{Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.}
+}
+
+Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+
+Source: \url{http://www.eucast.org/newsiandr/}.
+
+\strong{This AMR package honours this new insight.}
+}
+
\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/count.Rd b/man/count.Rd
index e32053ad..e2accb73 100644
--- a/man/count.Rd
+++ b/man/count.Rd
@@ -30,7 +30,7 @@ count_all(...)
n_rsi(...)
count_df(data, translate_ab = "name", language = get_locale(),
- combine_IR = FALSE)
+ combine_SI = TRUE, 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.}
@@ -43,7 +43,7 @@ count_df(data, translate_ab = "name", language = get_locale(),
\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)}
+\item{combine_SI}{a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter \code{combine_IR}, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now \code{TRUE}.}
}
\value{
Integer
@@ -60,6 +60,23 @@ These functions are meant to count isolates. Use the \code{\link{portion}_*} fun
\code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the amounts of 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"}.
}
+\section{Interpretation of S, I and R}{
+
+In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+
+\itemize{
+ \item{\strong{S}}{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
+ \item{\strong{I}}{Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.}
+ \item{\strong{R}}{Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.}
+}
+
+Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+
+Source: \url{http://www.eucast.org/newsiandr/}.
+
+\strong{This AMR package honours this new insight.}
+}
+
\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 bc384174..edc51a51 100644
--- a/man/ggplot_rsi.Rd
+++ b/man/ggplot_rsi.Rd
@@ -12,13 +12,15 @@
\usage{
ggplot_rsi(data, position = NULL, x = "Antibiotic",
fill = "Interpretation", facet = NULL, breaks = seq(0, 1, 0.1),
- limits = NULL, translate_ab = "name", language = get_locale(),
- fun = count_df, nrow = NULL, datalabels = TRUE,
- datalabels.size = 3, datalabels.colour = "grey15", ...)
+ limits = NULL, translate_ab = "name", combine_SI = TRUE,
+ combine_IR = FALSE, 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 = "name",
- language = get_locale(), fun = count_df, ...)
+ language = get_locale(), combine_SI = TRUE, combine_IR = FALSE,
+ fun = count_df, ...)
facet_rsi(facet = c("Interpretation", "Antibiotic"), nrow = NULL)
@@ -46,9 +48,11 @@ 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{ab_name}}. 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 to, using \code{\link{ab_property}}}
-\item{language}{the language used for translation of antibiotic names}
+\item{combine_SI}{a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter \code{combine_IR}, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now \code{TRUE}.}
+
+\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{fun}{function to transform \code{data}, either \code{\link{count_df}} (default) or \code{\link{portion_df}}}
diff --git a/man/guess_ab_col.Rd b/man/guess_ab_col.Rd
index 8770a4dc..e5014af2 100644
--- a/man/guess_ab_col.Rd
+++ b/man/guess_ab_col.Rd
@@ -4,15 +4,18 @@
\alias{guess_ab_col}
\title{Guess antibiotic column}
\usage{
-guess_ab_col(tbl = NULL, col = NULL, verbose = FALSE)
+guess_ab_col(x = NULL, search_string = NULL, verbose = FALSE)
}
\arguments{
-\item{tbl}{a \code{data.frame}}
+\item{x}{a \code{data.frame}}
-\item{col}{a character to look for}
+\item{search_string}{a text to search \code{x} for}
\item{verbose}{a logical to indicate whether additional info should be printed}
}
+\value{
+A column name of \code{x}, or \code{NULL} when no result is found.
+}
\description{
This tries to find a column name in a data set based on information from the \code{\link{antibiotics}} data set. Also supports WHONET abbreviations. You can look for an antibiotic (trade) name or abbreviation and it will search the \code{data.frame} for any column containing a name or ATC code of that antibiotic.
}
@@ -31,7 +34,7 @@ guess_ab_col(df, "J01AA07") # ATC code of tetracycline
# [1] "tetr"
guess_ab_col(df, "J01AA07", verbose = TRUE)
-# using column `tetr` for col "J01AA07"
+# Note: Using column `tetr` as input for "J01AA07".
# [1] "tetr"
# WHONET codes
diff --git a/man/portion.Rd b/man/portion.Rd
index fa81cdac..574e6f36 100644
--- a/man/portion.Rd
+++ b/man/portion.Rd
@@ -31,7 +31,8 @@ portion_S(..., minimum = 30, as_percent = FALSE,
also_single_tested = FALSE)
portion_df(data, translate_ab = "name", language = get_locale(),
- minimum = 30, as_percent = FALSE, combine_IR = FALSE)
+ minimum = 30, as_percent = FALSE, combine_SI = TRUE,
+ 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.}
@@ -48,7 +49,7 @@ portion_df(data, translate_ab = "name", language = get_locale(),
\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)}
+\item{combine_SI}{a logical to indicate whether all values of I and S must be merged into one, so the output only consists of S+I vs. R (susceptible vs. resistant). This used to be the parameter \code{combine_IR}, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now \code{TRUE}.}
}
\value{
Double or, when \code{as_percent = TRUE}, a character.
@@ -79,6 +80,23 @@ These functions are not meant to count isolates, but to calculate the portion of
And so on.
}
}
+\section{Interpretation of S, I and R}{
+
+In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
+
+\itemize{
+ \item{\strong{S}}{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
+ \item{\strong{I}}{Susceptible, increased exposure: A microorganism is categorised as "Susceptible, Increased exposure" when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.}
+ \item{\strong{R}}{Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.}
+}
+
+Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
+
+Source: \url{http://www.eucast.org/newsiandr/}.
+
+\strong{This AMR package honours this new insight.}
+}
+
\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/tests/testthat/test-ab.R b/tests/testthat/test-ab.R
index 08c37dff..e44468bb 100755
--- a/tests/testthat/test-ab.R
+++ b/tests/testthat/test-ab.R
@@ -36,6 +36,9 @@ test_that("as.ab works", {
expect_identical(class(as.ab("amox")), "ab")
expect_identical(class(pull(antibiotics, ab)), "ab")
+ expect_true(is.ab(as.ab("amox")))
+ expect_output(print(as.ab("amox")))
+ expect_output(print(data.frame(a = as.ab("amox"))))
expect_warning(as.ab("Z00ZZ00")) # not yet available in data set
expect_warning(as.ab("UNKNOWN"))
diff --git a/tests/testthat/test-atc.R b/tests/testthat/test-atc.R
new file mode 100755
index 00000000..c8eee86a
--- /dev/null
+++ b/tests/testthat/test-atc.R
@@ -0,0 +1,39 @@
+# ==================================================================== #
+# 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("ab.R")
+
+test_that("as.atc works", {
+ expect_identical(class(as.atc("amox")), "atc")
+ expect_true(is.atc(as.atc("amox")))
+ expect_output(print(as.atc("amox")))
+ expect_output(print(data.frame(a = as.atc("amox"))))
+
+ expect_identical(class(pull(antibiotics, atc)), "atc")
+
+ expect_warning(as.atc("Z00ZZ00")) # not yet availatcle in data set
+ expect_warning(as.atc("UNKNOWN"))
+
+ expect_output(print(as.atc("amox")))
+
+
+
+})
diff --git a/tests/testthat/test-count.R b/tests/testthat/test-count.R
index f8106302..0d3b0840 100644
--- a/tests/testthat/test-count.R
+++ b/tests/testthat/test-count.R
@@ -51,8 +51,7 @@ test_that("counts work", {
# count_df
expect_equal(
septic_patients %>% select(AMX) %>% count_df() %>% pull(Value),
- c(septic_patients$AMX %>% count_S(),
- septic_patients$AMX %>% count_I(),
+ c(septic_patients$AMX %>% count_SI(),
septic_patients$AMX %>% count_R())
)
expect_equal(
@@ -60,6 +59,12 @@ test_that("counts work", {
c(septic_patients$AMX %>% count_S(),
septic_patients$AMX %>% count_IR())
)
+ expect_equal(
+ septic_patients %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(Value),
+ c(septic_patients$AMX %>% count_S(),
+ septic_patients$AMX %>% count_I(),
+ septic_patients$AMX %>% count_R())
+ )
# warning for speed loss
expect_warning(count_R(as.character(septic_patients$AMC)))
diff --git a/tests/testthat/test-portion.R b/tests/testthat/test-portion.R
index 02b700a5..2135bf5d 100755
--- a/tests/testthat/test-portion.R
+++ b/tests/testthat/test-portion.R
@@ -101,8 +101,7 @@ test_that("portions works", {
# portion_df
expect_equal(
septic_patients %>% select(AMX) %>% portion_df() %>% pull(Value),
- c(septic_patients$AMX %>% portion_S(),
- septic_patients$AMX %>% portion_I(),
+ c(septic_patients$AMX %>% portion_SI(),
septic_patients$AMX %>% portion_R())
)
expect_equal(
@@ -110,6 +109,12 @@ test_that("portions works", {
c(septic_patients$AMX %>% portion_S(),
septic_patients$AMX %>% portion_IR())
)
+ expect_equal(
+ septic_patients %>% select(AMX) %>% portion_df(combine_SI = FALSE) %>% pull(Value),
+ c(septic_patients$AMX %>% portion_S(),
+ septic_patients$AMX %>% portion_I(),
+ septic_patients$AMX %>% portion_R())
+ )
})
diff --git a/tests/testthat/test-rsi.R b/tests/testthat/test-rsi.R
index 1b827836..60e1be5c 100644
--- a/tests/testthat/test-rsi.R
+++ b/tests/testthat/test-rsi.R
@@ -54,3 +54,53 @@ test_that("rsi works", {
40)
})
+
+test_that("mic2rsi works", {
+ expect_equal(as.character(
+ as.rsi(x = as.mic(0.125),
+ mo = "B_STRPT_PNE",
+ ab = "AMX",
+ guideline = "EUCAST")),
+ "S")
+ expect_equal(as.character(
+ as.rsi(x = as.mic(4),
+ mo = "B_STRPT_PNE",
+ ab = "AMX",
+ guideline = "EUCAST")),
+ "R")
+
+ expect_true(septic_patients %>%
+ mutate(amox_mic = as.mic(2)) %>%
+ select(mo, amox_mic) %>%
+ as.rsi() %>%
+ pull(amox_mic) %>%
+ is.rsi())
+})
+
+test_that("disk2rsi works", {
+ expect_equal(as.character(
+ as.rsi(x = as.disk(22),
+ mo = "B_STRPT_PNE",
+ ab = "ERY",
+ guideline = "CLSI")),
+ "S")
+ expect_equal(as.character(
+ as.rsi(x = as.disk(18),
+ mo = "B_STRPT_PNE",
+ ab = "ERY",
+ guideline = "CLSI")),
+ "I")
+ expect_equal(as.character(
+ as.rsi(x = as.disk(10),
+ mo = "B_STRPT_PNE",
+ ab = "ERY",
+ guideline = "CLSI")),
+ "R")
+
+ expect_true(septic_patients %>%
+ mutate(amox_disk = as.disk(15)) %>%
+ select(mo, amox_disk) %>%
+ as.rsi(guideline = "CLSI") %>%
+ pull(amox_disk) %>%
+ is.rsi())
+})