mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 18:06:12 +01:00
CI tests
This commit is contained in:
parent
0444c4ed9d
commit
38a4421450
@ -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(
|
||||
|
6
NEWS.md
6
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`.
|
||||
|
10
R/ab.R
10
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
|
||||
|
64
R/count.R
64
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))
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
76
R/portion.R
76
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))
|
||||
}
|
||||
|
42
R/rsi.R
42
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_)
|
||||
}
|
||||
|
||||
}
|
||||
|
85
R/rsi_calc.R
85
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
|
||||
}
|
||||
|
@ -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.
|
||||
#'
|
||||
|
@ -204,6 +204,7 @@
|
||||
<ul>
|
||||
<li>Reference for microorganisms, since it contains all microbial (sub)species from the <a href="http://www.catalogueoflife.org">Catalogue of Life</a>
|
||||
</li>
|
||||
<li>Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines</li>
|
||||
<li>Calculating antimicrobial resistance</li>
|
||||
<li>Calculating empirical susceptibility of both mono therapy and combination therapy</li>
|
||||
<li>Predicting future antimicrobial resistance using regression models</li>
|
||||
@ -211,7 +212,7 @@
|
||||
<li>Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)</li>
|
||||
<li>Plotting antimicrobial resistance</li>
|
||||
<li>Determining first isolates to be used for AMR analysis</li>
|
||||
<li>Applying EUCAST expert rules (not the translation from MIC to RSI values)</li>
|
||||
<li>Applying EUCAST expert rules</li>
|
||||
<li>Determining multi-drug resistant organisms (MDRO)</li>
|
||||
<li>Descriptive statistics: frequency tables, kurtosis and skewness</li>
|
||||
</ul>
|
||||
@ -314,7 +315,7 @@
|
||||
<p>It <strong>cleanses existing data</strong> by providing new <em>classes</em> 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:</p>
|
||||
<ul>
|
||||
<li>Use <code><a href="reference/as.mo.html">as.mo()</a></code> to get a microbial ID. The IDs are human readable for the trained eye - the ID of <em>Klebsiella pneumoniae</em> is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of <em>S. aureus</em> 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 <a href="./articles/benchmarks.html">benchmarks</a>. Moreover, it can group <em>Staphylococci</em> into coagulase negative and positive (CoNS and CoPS, see <a href="./reference/as.mo.html#source">source</a>) and can categorise <em>Streptococci</em> into Lancefield groups (like beta-haemolytic <em>Streptococcus</em> Group B, <a href="./reference/as.mo.html#source">source</a>).</li>
|
||||
<li>Use <code><a href="reference/as.rsi.html">as.rsi()</a></code> 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”.</li>
|
||||
<li>Use <code><a href="reference/as.rsi.html">as.rsi()</a></code> 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”.</li>
|
||||
<li>Use <code><a href="reference/as.mic.html">as.mic()</a></code> to cleanse your MIC values. It produces a so-called factor (called <em>ordinal</em> in SPSS) with valid MIC values as levels. A value like “<=0.002; S” (combined MIC/RSI) will result in “<=0.002”.</li>
|
||||
<li>Use <code><a href="reference/as.ab.html">as.ab()</a></code> to get a antibiotic ID, which are abbreviations used by EARS-Net whenever available. Use <code><a href="reference/as.atc.html">as.atc()</a></code> 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.</li>
|
||||
</ul>
|
||||
|
@ -250,7 +250,13 @@
|
||||
<ul>
|
||||
<li>Completely reworked the <code>antibiotics</code> data set:
|
||||
<ul>
|
||||
<li>All entries now have 3 different identifiers: a human readable EARS-Net code (<code>ab</code>, used by ECDC and WHONET), an ATC code (<code>atc</code>, used by WHO), and a CID code (<code>cid</code>, Compound ID, used by PubChem)</li>
|
||||
<li>All entries now have 3 different identifiers:
|
||||
<ul>
|
||||
<li>Column <code>ab</code> contains a human readable EARS-Net code, used by ECDC and WHO/WHONET - this is the primary identifier used in this package</li>
|
||||
<li>Column <code>atc</code> contains the ATC code, used by WHO/WHOCC</li>
|
||||
<li>Column <code>cid</code> contains the CID code (Compound ID), used by PubChem</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Based on the Compound ID, more than a thousand official brand names have been added from many different countries</li>
|
||||
<li>All references to antibiotics in our package now use EARS-Net codes, like <code>AMX</code> for amoxicillin</li>
|
||||
<li>Functions <code>atc_certe</code>, <code>ab_umcg</code> and <code>atc_trivial_nl</code> have been removed</li>
|
||||
@ -264,6 +270,7 @@ Please create an issue in one of our repositories if you want additions in this
|
||||
<li>Improved intelligence of looking up antibiotic tables in data set using <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code>
|
||||
</li>
|
||||
<li>Added ~5,000 more old taxonomic names to the <code>microorganisms.old</code> data set, which leads to better results finding when using the <code><a href="../reference/as.mo.html">as.mo()</a></code> function</li>
|
||||
<li>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 <code><a href="../reference/portion.html">portion_df()</a></code> and <code><a href="../reference/count.html">count_df()</a></code> this means that their new parameter <code>combine_SI</code> is TRUE at default.</li>
|
||||
<li>Removed deprecated functions <code>guess_mo()</code>, <code>guess_atc()</code>, <code>EUCAST_rules()</code>, <code>interpretive_reading()</code>, <code>rsi()</code>
|
||||
</li>
|
||||
<li>Frequency tables of microbial IDs speed improvement</li>
|
||||
|
@ -246,7 +246,7 @@
|
||||
|
||||
|
||||
<p><img src='figures/logo_who.png' height=60px style=margin-bottom:5px /> <br />
|
||||
This package contains <strong>all ~500 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
This package contains <strong>all ~450 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
<p>These have become the gold standard for international drug utilisation monitoring and research.</p>
|
||||
<p>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.</p>
|
||||
|
||||
|
@ -276,7 +276,7 @@
|
||||
|
||||
|
||||
<p><img src='figures/logo_who.png' height=60px style=margin-bottom:5px /> <br />
|
||||
This package contains <strong>all ~500 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
This package contains <strong>all ~450 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
<p>These have become the gold standard for international drug utilisation monitoring and research.</p>
|
||||
<p>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.</p>
|
||||
|
||||
|
@ -254,11 +254,12 @@
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>Character (vector) with class <code>"act"</code>. Unknown values will return <code>NA</code>.</p>
|
||||
<p>Character (vector) with class <code>"ab"</code>. Unknown values will return <code>NA</code>.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||
|
||||
<p>Use the <code><a href='ab_property.html'>ab_property</a></code> functions to get properties based on the returned ATC code, see Examples.</p>
|
||||
<p>All entries in the <code>{link{antibiotics}</code> data set have three different identifiers: a human readable EARS-Net code (column <code>ab</code>, used by ECDC and WHONET), an ATC code (column <code>atc</code>, used by WHO), and a CID code (column <code>cid</code>, Compound ID, used by PubChem). The data set contains more than 5,000 official brand names from many different countries, as found in PubChem.</p>
|
||||
<p>Use the <code><a href='ab_property.html'>ab_property</a></code> functions to get properties based on the returned ATC code, see Examples.</p>
|
||||
<p>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: <a href='https://www.whocc.no/atc/structure_and_principles/'>https://www.whocc.no/atc/structure_and_principles/</a></p>
|
||||
|
||||
@ -273,7 +274,7 @@
|
||||
|
||||
|
||||
<p><img src='figures/logo_who.png' height=60px style=margin-bottom:5px /> <br />
|
||||
This package contains <strong>all ~500 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
This package contains <strong>all ~450 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
<p>These have become the gold standard for international drug utilisation monitoring and research.</p>
|
||||
<p>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.</p>
|
||||
|
||||
|
@ -270,7 +270,7 @@
|
||||
|
||||
|
||||
<p><img src='figures/logo_who.png' height=60px style=margin-bottom:5px /> <br />
|
||||
This package contains <strong>all ~500 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
This package contains <strong>all ~450 antimicrobial drugs</strong> 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, <a href='https://www.whocc.no'>https://www.whocc.no</a>) and the Pharmaceuticals Community Register of the European Commission (<a href='http://ec.europa.eu/health/documents/community-register/html/atc.htm'>http://ec.europa.eu/health/documents/community-register/html/atc.htm</a>).</p>
|
||||
<p>These have become the gold standard for international drug utilisation monitoring and research.</p>
|
||||
<p>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.</p>
|
||||
|
||||
|
@ -300,6 +300,19 @@
|
||||
<p>After using <code>as.rsi</code>, you can use <code><a href='eucast_rules.html'>eucast_rules</a></code> 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.</p>
|
||||
<p>The function <code>is.rsi.eligible</code> returns <code>TRUE</code> when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and <code>FALSE</code> otherwise. The threshold of 5% can be set with the <code>threshold</code> parameter.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="interpretation-of-s-i-and-r"><a class="anchor" href="#interpretation-of-s-i-and-r"></a>Interpretation of S, I and R</h2>
|
||||
|
||||
|
||||
<p>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".</p>
|
||||
<ul>
|
||||
<li><p><strong>S</strong>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.</p></li>
|
||||
<li><p><strong>I</strong>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.</p></li>
|
||||
<li><p><strong>R</strong>Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p></li>
|
||||
</ul>
|
||||
<p>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.</p>
|
||||
<p>Source: <a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>.</p>
|
||||
<p><strong>This AMR package honours this new insight.</strong></p>
|
||||
|
||||
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
|
||||
|
||||
|
||||
@ -358,6 +371,8 @@
|
||||
|
||||
<li><a href="#details">Details</a></li>
|
||||
|
||||
<li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li>
|
||||
|
||||
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
|
||||
|
||||
<li><a href="#see-also">See also</a></li>
|
||||
|
@ -258,7 +258,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
<span class='fu'>n_rsi</span>(<span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>count_df</span>(<span class='no'>data</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(),
|
||||
<span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
<span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
@ -284,8 +284,8 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
<td><p>language of the returned text, defaults to system language (see <code><a href='translate.html'>get_locale</a></code>) and can also be set with <code><a href='https://www.rdocumentation.org/packages/base/topics/options'>getOption</a>("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>combine_IR</th>
|
||||
<td><p>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)</p></td>
|
||||
<th>combine_SI</th>
|
||||
<td><p>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</code>, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now <code>TRUE</code>.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -303,6 +303,19 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
<p><code>n_rsi</code> is an alias of <code>count_all</code>. 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><a href='https://dplyr.tidyverse.org/reference/n_distinct.html'>n_distinct</a></code>. Their function is equal to <code>count_S(...) + count_IR(...)</code>.</p>
|
||||
<p><code>count_df</code> takes any variable from <code>data</code> that has an <code>"rsi"</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) and counts the amounts of R, I and S. The resulting <em>tidy data</em> (see Source) <code>data.frame</code> will have three rows (S/I/R) and a column for each variable with class <code>"rsi"</code>.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="interpretation-of-s-i-and-r"><a class="anchor" href="#interpretation-of-s-i-and-r"></a>Interpretation of S, I and R</h2>
|
||||
|
||||
|
||||
<p>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".</p>
|
||||
<ul>
|
||||
<li><p><strong>S</strong>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.</p></li>
|
||||
<li><p><strong>I</strong>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.</p></li>
|
||||
<li><p><strong>R</strong>Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p></li>
|
||||
</ul>
|
||||
<p>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.</p>
|
||||
<p>Source: <a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>.</p>
|
||||
<p><strong>This AMR package honours this new insight.</strong></p>
|
||||
|
||||
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
|
||||
|
||||
|
||||
@ -384,6 +397,8 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
|
||||
<li><a href="#details">Details</a></li>
|
||||
|
||||
<li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li>
|
||||
|
||||
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
|
||||
|
||||
<li><a href="#see-also">See also</a></li>
|
||||
|
@ -243,13 +243,15 @@
|
||||
|
||||
<pre class="usage"><span class='fu'>ggplot_rsi</span>(<span class='no'>data</span>, <span class='kw'>position</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"Antibiotic"</span>,
|
||||
<span class='kw'>fill</span> <span class='kw'>=</span> <span class='st'>"Interpretation"</span>, <span class='kw'>facet</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>breaks</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/seq'>seq</a></span>(<span class='fl'>0</span>, <span class='fl'>1</span>, <span class='fl'>0.1</span>),
|
||||
<span class='kw'>limits</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(),
|
||||
<span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>count_df</span>, <span class='kw'>nrow</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
|
||||
<span class='kw'>datalabels.size</span> <span class='kw'>=</span> <span class='fl'>3</span>, <span class='kw'>datalabels.colour</span> <span class='kw'>=</span> <span class='st'>"grey15"</span>, <span class='no'>...</span>)
|
||||
<span class='kw'>limits</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>, <span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
|
||||
<span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(), <span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>count_df</span>,
|
||||
<span class='kw'>nrow</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>datalabels.size</span> <span class='kw'>=</span> <span class='fl'>3</span>,
|
||||
<span class='kw'>datalabels.colour</span> <span class='kw'>=</span> <span class='st'>"grey15"</span>, <span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>geom_rsi</span>(<span class='kw'>position</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>x</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Antibiotic"</span>, <span class='st'>"Interpretation"</span>),
|
||||
<span class='kw'>fill</span> <span class='kw'>=</span> <span class='st'>"Interpretation"</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>,
|
||||
<span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(), <span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>count_df</span>, <span class='no'>...</span>)
|
||||
<span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(), <span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
|
||||
<span class='kw'>fun</span> <span class='kw'>=</span> <span class='no'>count_df</span>, <span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>facet_rsi</span>(<span class='kw'>facet</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Interpretation"</span>, <span class='st'>"Antibiotic"</span>), <span class='kw'>nrow</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)
|
||||
|
||||
@ -295,11 +297,15 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>translate_ab</th>
|
||||
<td><p>a column name of the <code><a href='antibiotics.html'>antibiotics</a></code> data set to translate the antibiotic abbreviations into, using <code><a href='ab_property.html'>ab_name</a></code>. Default behaviour is to translate to official names according to the WHO. Use <code>translate_ab = FALSE</code> to disable translation.</p></td>
|
||||
<td><p>a column name of the <code><a href='antibiotics.html'>antibiotics</a></code> data set to translate the antibiotic abbreviations to, using <code><a href='ab_property.html'>ab_property</a></code></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>combine_SI</th>
|
||||
<td><p>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</code>, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now <code>TRUE</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>language</th>
|
||||
<td><p>the language used for translation of antibiotic names</p></td>
|
||||
<td><p>language of the returned text, defaults to system language (see <code><a href='translate.html'>get_locale</a></code>) and can also be set with <code><a href='https://www.rdocumentation.org/packages/base/topics/options'>getOption</a>("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>fun</th>
|
||||
|
@ -241,18 +241,18 @@
|
||||
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>guess_ab_col</span>(<span class='kw'>tbl</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>col</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
<pre class="usage"><span class='fu'>guess_ab_col</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>search_string</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>tbl</th>
|
||||
<th>x</th>
|
||||
<td><p>a <code>data.frame</code></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>col</th>
|
||||
<td><p>a character to look for</p></td>
|
||||
<th>search_string</th>
|
||||
<td><p>a text to search <code>x</code> for</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>verbose</th>
|
||||
@ -260,6 +260,10 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>A column name of <code>x</code>, or <code>NULL</code> when no result is found.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
|
||||
|
||||
|
||||
@ -277,7 +281,7 @@
|
||||
<span class='co'># [1] "tetr"</span>
|
||||
|
||||
<span class='fu'>guess_ab_col</span>(<span class='no'>df</span>, <span class='st'>"J01AA07"</span>, <span class='kw'>verbose</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
|
||||
<span class='co'># using column `tetr` for col "J01AA07"</span>
|
||||
<span class='co'># Note: Using column `tetr` as input for "J01AA07".</span>
|
||||
<span class='co'># [1] "tetr"</span>
|
||||
|
||||
<span class='co'># WHONET codes</span>
|
||||
@ -296,6 +300,8 @@
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
|
||||
<li><a href="#value">Value</a></li>
|
||||
|
||||
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
|
||||
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
|
@ -259,7 +259,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
|
||||
<span class='kw'>also_single_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>portion_df</span>(<span class='no'>data</span>, <span class='kw'>translate_ab</span> <span class='kw'>=</span> <span class='st'>"name"</span>, <span class='kw'>language</span> <span class='kw'>=</span> <span class='fu'><a href='translate.html'>get_locale</a></span>(),
|
||||
<span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>30</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
<span class='kw'>minimum</span> <span class='kw'>=</span> <span class='fl'>30</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>combine_SI</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
|
||||
<span class='kw'>combine_IR</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre>
|
||||
|
||||
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
|
||||
<table class="ref-arguments">
|
||||
@ -293,8 +294,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
|
||||
<td><p>language of the returned text, defaults to system language (see <code><a href='translate.html'>get_locale</a></code>) and can also be set with <code><a href='https://www.rdocumentation.org/packages/base/topics/options'>getOption</a>("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>combine_IR</th>
|
||||
<td><p>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)</p></td>
|
||||
<th>combine_SI</th>
|
||||
<td><p>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</code>, but this now follows the redefinition by EUCAST about the interpretion of I (increased exposure) in 2019, see below. Default is now <code>TRUE</code>.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -325,6 +326,19 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
|
||||
<br />
|
||||
And so on.</p>
|
||||
|
||||
<h2 class="hasAnchor" id="interpretation-of-s-i-and-r"><a class="anchor" href="#interpretation-of-s-i-and-r"></a>Interpretation of S, I and R</h2>
|
||||
|
||||
|
||||
<p>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".</p>
|
||||
<ul>
|
||||
<li><p><strong>S</strong>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.</p></li>
|
||||
<li><p><strong>I</strong>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.</p></li>
|
||||
<li><p><strong>R</strong>Resistant: A microorganism is categorised as "Resistant" when there is a high likelihood of therapeutic failure even when there is increased exposure.</p></li>
|
||||
</ul>
|
||||
<p>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.</p>
|
||||
<p>Source: <a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>.</p>
|
||||
<p><strong>This AMR package honours this new insight.</strong></p>
|
||||
|
||||
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
|
||||
|
||||
|
||||
@ -422,6 +436,8 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
|
||||
|
||||
<li><a href="#details">Details</a></li>
|
||||
|
||||
<li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li>
|
||||
|
||||
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
|
||||
|
||||
<li><a href="#see-also">See also</a></li>
|
||||
|
5
index.md
5
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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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}.
|
||||
|
21
man/count.Rd
21
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}.
|
||||
|
@ -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}}}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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}.
|
||||
|
@ -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"))
|
||||
|
39
tests/testthat/test-atc.R
Executable file
39
tests/testthat/test-atc.R
Executable file
@ -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")))
|
||||
|
||||
|
||||
|
||||
})
|
@ -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)))
|
||||
|
@ -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())
|
||||
)
|
||||
|
||||
|
||||
})
|
||||
|
@ -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())
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user