(v0.8.0.9027) adding susceptibility() and resistance()
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 0.8.0.9026
|
||||
Version: 0.8.0.9027
|
||||
Date: 2019-11-10
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
|
12
NAMESPACE
@ -74,7 +74,6 @@ export(age)
|
||||
export(age_groups)
|
||||
export(anti_join_microorganisms)
|
||||
export(as.ab)
|
||||
export(as.atc)
|
||||
export(as.disk)
|
||||
export(as.mic)
|
||||
export(as.mo)
|
||||
@ -94,6 +93,8 @@ export(count_S)
|
||||
export(count_SI)
|
||||
export(count_all)
|
||||
export(count_df)
|
||||
export(count_resistant)
|
||||
export(count_susceptible)
|
||||
export(eucast_exceptional_phenotypes)
|
||||
export(eucast_rules)
|
||||
export(facet_rsi)
|
||||
@ -172,8 +173,14 @@ export(portion_IR)
|
||||
export(portion_R)
|
||||
export(portion_S)
|
||||
export(portion_SI)
|
||||
export(portion_df)
|
||||
export(proportion_I)
|
||||
export(proportion_IR)
|
||||
export(proportion_R)
|
||||
export(proportion_S)
|
||||
export(proportion_SI)
|
||||
export(proportion_df)
|
||||
export(read.4D)
|
||||
export(resistance)
|
||||
export(resistance_predict)
|
||||
export(right_join_microorganisms)
|
||||
export(rsi_df)
|
||||
@ -185,6 +192,7 @@ export(scale_y_percent)
|
||||
export(semi_join_microorganisms)
|
||||
export(set_mo_source)
|
||||
export(skewness)
|
||||
export(susceptibility)
|
||||
export(theme_rsi)
|
||||
exportMethods("[.ab")
|
||||
exportMethods("[.mo")
|
||||
|
7
NEWS.md
@ -1,17 +1,20 @@
|
||||
# AMR 0.8.0.9026
|
||||
# AMR 0.8.0.9027
|
||||
<small>Last updated: 10-Nov-2019</small>
|
||||
|
||||
### New
|
||||
* Functions `susceptibility()` and `resistance()` as aliases of `proportion_SI()` and `proportion_R()`, respectively. These functions were added to make it more clear that I should be considered susceptible and not resistant.
|
||||
* Support for a new MDRO guideline: Magiorakos AP, Srinivasan A *et al.* "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012).
|
||||
* This is now the new default guideline for the `mdro()` function
|
||||
* The new Verbose mode (`mdro(...., verbose = TRUE)`) returns an informative data set where the reason for MDRO determination is given for every isolate, and an list of the resistant antimicrobial agents
|
||||
|
||||
### Changes
|
||||
* Removed previously deprecated function `as.rsi()` - this function was replaced by `ab_atc()`
|
||||
* Renamed all `portion_*` functions to `proportion_*`. All `portion_*` functions are still available as deprecated functions, and will return a warning when used.
|
||||
* When running `as.rsi()` over a data set, it will now print the guideline that will be used if it is not specified by the user
|
||||
* Fix for `eucast_rules()`: *Stenotrophomonas maltophilia* not interpreted "R" to ceftazidime anymore (following EUCAST v3.1)
|
||||
* Adopted Adeolu *et al.* (2016), [PMID 27620848](https://www.ncbi.nlm.nih.gov/pubmed/27620848) for the `microorganisms` data set, which means that the new order Enterobacterales now consists of a part of the existing family *Enterobacteriaceae*, but that this family has been split into other families as well (like *Morganellaceae* and *Yersiniaceae*). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with `mdro()` will now use the Enterobacterales order for all guidelines before 2016.
|
||||
* Fix for interpreting MIC values with `as.rsi()` where the input is `NA`
|
||||
* Added "imi" as allowed abbreviation for Imipenem
|
||||
* Added "imi" and "imp" as allowed abbreviation for Imipenem (IPM)
|
||||
* Fix for automatically determining columns with antibiotic results in `mdro()` and `eucast_rules()`
|
||||
* Added ATC codes for ceftaroline, ceftobiprole and faropenem and fixed two typos in the `antibiotics` data set
|
||||
* More robust way of determining valid MIC values
|
||||
|
16
R/amr.R
@ -29,28 +29,20 @@
|
||||
#'
|
||||
#' This package can be used for:
|
||||
#' \itemize{
|
||||
#' \item{Reference for microorganisms, since it contains all microbial (sub)species from the Catalogue of Life}
|
||||
#' \item{Reference for the taxonomy of microorganisms, since the package contains all microbial (sub)species from the Catalogue of Life}
|
||||
#' \item{Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines}
|
||||
#' \item{Determining first isolates to be used for AMR analysis}
|
||||
#' \item{Calculating antimicrobial resistance}
|
||||
#' \item{Determining multi-drug resistance (MDR) / multi-drug resistant organisms (MDRO)}
|
||||
#' \item{Calculating empirical susceptibility of both mono therapy and combination therapy}
|
||||
#' \item{Calculating (empirical) susceptibility of both mono therapy and combination therapies}
|
||||
#' \item{Predicting future antimicrobial resistance using regression models}
|
||||
#' \item{Getting properties for any microorganism (like Gram stain, species, genus or family)}
|
||||
#' \item{Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)}
|
||||
#' \item{Getting properties for any antibiotic (like name, EARS-Net code, ATC code, PubChem code, defined daily dose or trade name)}
|
||||
#' \item{Plotting antimicrobial resistance}
|
||||
#' \item{Determining first isolates to be used for AMR analysis}
|
||||
#' \item{Applying EUCAST expert rules}
|
||||
#' \item{Descriptive statistics: frequency tables, kurtosis and skewness}
|
||||
#' }
|
||||
#' @section Authors:
|
||||
#' Matthijs S. Berends[1,2] Christian F. Luz[1], Erwin E.A. Hassing[2], Corinna Glasner[1], Alex W. Friedrich[1], Bhanu N.M. Sinha[1] \cr
|
||||
#'
|
||||
#' [1] Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands - \url{https://www.rug.nl} \url{https://www.umcg.nl} \cr
|
||||
#' [2] Certe Medical Diagnostics & Advice, Groningen, the Netherlands - \url{https://www.certe.nl}
|
||||
|
||||
#' @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 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}.
|
||||
|
||||
#' @section Contact us:
|
||||
#' For suggestions, comments or questions, please contact us at:
|
||||
#'
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
#' Check availability of columns
|
||||
#'
|
||||
#' Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. \code{\link{portion_R}}.
|
||||
#' Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. \code{\link{resistance}}.
|
||||
#' @param tbl a \code{data.frame} or \code{list}
|
||||
#' @param width number of characters to present the visual availability, defaults to filling the width of the console
|
||||
#' @details The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{portion_R}}.
|
||||
#' @details The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{resistance}}.
|
||||
#' @return \code{data.frame} with column names of \code{tbl} as row names
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @importFrom cleaner percentage
|
||||
@ -48,7 +48,7 @@ availability <- function(tbl, width = NULL) {
|
||||
1 - base::sum(base::is.na(x)) / base::length(x)
|
||||
})
|
||||
n <- base::sapply(tbl, function(x) base::length(x[!base::is.na(x)]))
|
||||
R <- base::sapply(tbl, function(x) base::ifelse(is.rsi(x), portion_R(x, minimum = 0), NA))
|
||||
R <- base::sapply(tbl, function(x) base::ifelse(is.rsi(x), resistance(x, minimum = 0), NA))
|
||||
R_print <- character(length(R))
|
||||
R_print[!is.na(R)] <- percentage(R[!is.na(R)])
|
||||
R_print[is.na(R)] <- ""
|
||||
|
79
R/count.R
@ -23,20 +23,19 @@
|
||||
#'
|
||||
#' @description These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
#'
|
||||
#' \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
|
||||
#' \code{count_resistant} should be used to count resistant isolates, \code{count_susceptible} should 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
|
||||
#' @inheritParams proportion
|
||||
#' @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.
|
||||
#' @details These functions are meant to count isolates. Use the \code{\link{resistance}}/\code{\link{susceptibility}} functions to calculate microbial resistance/susceptibility.
|
||||
#'
|
||||
#' The function \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(...)}.
|
||||
#' The function \code{count_resistant} is equal to the function \code{count_R}. The function \code{count_susceptible} is equal to the function \code{count_SI}.
|
||||
#'
|
||||
#' The function \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 S, I and R. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}.
|
||||
#' The function \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_susceptible(...) + count_resistant(...)}.
|
||||
#'
|
||||
#' The function \code{rsi_df} works exactly like \code{count_df}, but adds the percentage of S, I and R.
|
||||
#' @inheritSection portion Combination therapy
|
||||
#' @source Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
#' @seealso \code{\link{portion}_*} to calculate microbial resistance and susceptibility.
|
||||
#' The function \code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the number of S's, I's and R's. The function \code{rsi_df} works exactly like \code{count_df}, but adds the percentage of S, I and R.
|
||||
#' @inheritSection proportion Combination therapy
|
||||
#' @seealso \code{\link{proportion}_*} to calculate microbial resistance and susceptibility.
|
||||
#' @return Integer
|
||||
#' @rdname count
|
||||
#' @name count
|
||||
@ -46,23 +45,27 @@
|
||||
#' # example_isolates is a data set available in the AMR package.
|
||||
#' ?example_isolates
|
||||
#'
|
||||
#' # Count resistant isolates
|
||||
#' count_R(example_isolates$AMX)
|
||||
#' count_IR(example_isolates$AMX)
|
||||
#' count_resistant(example_isolates$AMX) # counts "R"
|
||||
#' count_susceptible(example_isolates$AMX) # counts "S" and "I"
|
||||
#' count_all(example_isolates$AMX) # counts "S", "I" and "R"
|
||||
#'
|
||||
#' # Or susceptible isolates
|
||||
#' # be more specific
|
||||
#' count_S(example_isolates$AMX)
|
||||
#' count_SI(example_isolates$AMX)
|
||||
#' count_I(example_isolates$AMX)
|
||||
#' count_IR(example_isolates$AMX)
|
||||
#' count_R(example_isolates$AMX)
|
||||
#'
|
||||
#' # Count all available isolates
|
||||
#' count_all(example_isolates$AMX)
|
||||
#' n_rsi(example_isolates$AMX)
|
||||
#'
|
||||
#' # Since n_rsi counts available isolates, you can
|
||||
#' # calculate back to count e.g. non-susceptible isolates.
|
||||
#' # This results in the same:
|
||||
#' count_SI(example_isolates$AMX)
|
||||
#' portion_SI(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
#' # n_rsi() is an alias of count_all().
|
||||
#' # Since it counts all available isolates, you can
|
||||
#' # calculate back to count e.g. susceptible isolates.
|
||||
#' # These results are the same:
|
||||
#' count_susceptible(example_isolates$AMX)
|
||||
#' susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
#'
|
||||
#' library(dplyr)
|
||||
#' example_isolates %>%
|
||||
@ -76,19 +79,17 @@
|
||||
#'
|
||||
#' # Count co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
#' # so we can see that combination therapy does a lot more than mono therapy.
|
||||
#' # Please mind that `portion_SI` calculates percentages right away instead.
|
||||
#' count_SI(example_isolates$AMC) # 1433
|
||||
#' count_all(example_isolates$AMC) # 1879
|
||||
#' # Please mind that `susceptibility()` calculates percentages right away instead.
|
||||
#' example_isolates %>% count_susceptible(AMC) # 1433
|
||||
#' example_isolates %>% count_all(AMC) # 1879
|
||||
#'
|
||||
#' count_SI(example_isolates$GEN) # 1399
|
||||
#' count_all(example_isolates$GEN) # 1855
|
||||
#' example_isolates %>% count_susceptible(GEN) # 1399
|
||||
#' example_isolates %>% count_all(GEN) # 1855
|
||||
#'
|
||||
#' with(example_isolates,
|
||||
#' count_SI(AMC, GEN)) # 1764
|
||||
#' with(example_isolates,
|
||||
#' n_rsi(AMC, GEN)) # 1936
|
||||
#'
|
||||
#' # Get portions S/I/R immediately of all rsi columns
|
||||
#' example_isolates %>% count_susceptible(AMC, GEN) # 1764
|
||||
#' example_isolates %>% count_all(AMC, GEN) # 1936
|
||||
|
||||
#' # Get number of S+I vs. R immediately of selected columns
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, CIP) %>%
|
||||
#' count_df(translate = FALSE)
|
||||
@ -99,6 +100,24 @@
|
||||
#' group_by(hospital_id) %>%
|
||||
#' count_df(translate = FALSE)
|
||||
#'
|
||||
count_resistant <- function(..., only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
#' @export
|
||||
count_susceptible <- function(..., only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I"),
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = TRUE)
|
||||
}
|
||||
|
||||
#' @rdname count
|
||||
#' @export
|
||||
count_R <- function(..., only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
@ -109,6 +128,7 @@ count_R <- function(..., only_all_tested = FALSE) {
|
||||
#' @rdname count
|
||||
#' @export
|
||||
count_IR <- function(..., only_all_tested = FALSE) {
|
||||
warning("Using 'count_IR' is discouraged; use 'count_resistant()' instead to not consider \"I\" being resistant.", call. = FALSE)
|
||||
rsi_calc(...,
|
||||
ab_result = c("I", "R"),
|
||||
only_all_tested = only_all_tested,
|
||||
@ -136,6 +156,7 @@ count_SI <- function(..., only_all_tested = FALSE) {
|
||||
#' @rdname count
|
||||
#' @export
|
||||
count_S <- function(..., only_all_tested = FALSE) {
|
||||
warning("Using 'count_S' is discouraged; use 'count_susceptible()' instead to also consider \"I\" being susceptible.", call. = FALSE)
|
||||
rsi_calc(...,
|
||||
ab_result = "S",
|
||||
only_all_tested = only_all_tested,
|
||||
|
@ -27,14 +27,42 @@
|
||||
#' @keywords internal
|
||||
#' @name AMR-deprecated
|
||||
#' @rdname AMR-deprecated
|
||||
as.atc <- function(x) {
|
||||
.Deprecated("ab_atc", package = "AMR")
|
||||
AMR::ab_atc(x)
|
||||
}
|
||||
|
||||
#' @rdname AMR-deprecated
|
||||
#' @export
|
||||
p.symbol <- function(...) {
|
||||
.Deprecated("p_symbol", package = "AMR")
|
||||
AMR::p_symbol(...)
|
||||
}
|
||||
|
||||
#' @rdname AMR-deprecated
|
||||
#' @export
|
||||
portion_R <- function(...) {
|
||||
.Deprecated("resistance", package = "AMR")
|
||||
proportion_R(...)
|
||||
}
|
||||
|
||||
#' @rdname AMR-deprecated
|
||||
#' @export
|
||||
portion_IR <- function(...) {
|
||||
.Deprecated("proportion_IR", package = "AMR")
|
||||
proportion_IR(...)
|
||||
}
|
||||
|
||||
#' @rdname AMR-deprecated
|
||||
#' @export
|
||||
portion_I <- function(...) {
|
||||
.Deprecated("proportion_I", package = "AMR")
|
||||
proportion_I(...)
|
||||
}
|
||||
|
||||
#' @rdname AMR-deprecated
|
||||
#' @export
|
||||
portion_SI <- function(...) {
|
||||
.Deprecated("susceptibility", package = "AMR")
|
||||
proportion_SI(...)
|
||||
}
|
||||
|
||||
#' @rdname AMR-deprecated
|
||||
#' @export
|
||||
portion_S <- function(...) {
|
||||
.Deprecated("proportion_S", package = "AMR")
|
||||
proportion_S(...)
|
||||
}
|
||||
|
4
R/freq.R
@ -63,9 +63,9 @@ freq.rsi <- function(x, ...) {
|
||||
freq.default(x = x, ...,
|
||||
.add_header = list(Drug = paste0(ab_name(ab), " (", ab, ", ", ab_atc(ab), ")"),
|
||||
group = ab_group(ab),
|
||||
`%SI` = AMR::portion_SI(x, minimum = 0, as_percent = TRUE)))
|
||||
`%SI` = AMR::susceptibility(x, minimum = 0, as_percent = TRUE)))
|
||||
} else {
|
||||
freq.default(x = x, ...,
|
||||
.add_header = list(`%SI` = AMR::portion_SI(x, minimum = 0, as_percent = TRUE)))
|
||||
.add_header = list(`%SI` = AMR::susceptibility(x, minimum = 0, as_percent = TRUE)))
|
||||
}
|
||||
}
|
||||
|
@ -23,13 +23,13 @@
|
||||
#'
|
||||
#' Use these functions to create bar plots for antimicrobial resistance analysis. All functions rely on internal \code{\link[ggplot2]{ggplot}2} functions.
|
||||
#' @param data a \code{data.frame} with column(s) of class \code{"rsi"} (see \code{\link{as.rsi}})
|
||||
#' @param position position adjustment of bars, either \code{"fill"} (default when \code{fun} is \code{\link{count_df}}), \code{"stack"} (default when \code{fun} is \code{\link{portion_df}}) or \code{"dodge"}
|
||||
#' @param position position adjustment of bars, either \code{"fill"}, \code{"stack"} or \code{"dodge"}
|
||||
#' @param x variable to show on x axis, either \code{"antibiotic"} (default) or \code{"interpretation"} or a grouping variable
|
||||
#' @param fill variable to categorise using the plots legend, either \code{"antibiotic"} (default) or \code{"interpretation"} or a grouping variable
|
||||
#' @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
|
||||
#' @inheritParams portion
|
||||
#' @inheritParams proportion
|
||||
#' @param nrow (when using \code{facet}) number of rows
|
||||
#' @param colours a named vector with colours for the bars. The names must be one or more of: S, SI, I, IR, R or be \code{FALSE} to use default \code{ggplot2} colours.
|
||||
#' @param datalabels show datalabels using \code{labels_rsi_count}
|
||||
@ -82,7 +82,7 @@
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi()
|
||||
#'
|
||||
#' # get only portions and no counts:
|
||||
#' # get only proportions and no counts:
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, NIT, FOS, TMP, CIP) %>%
|
||||
#' ggplot_rsi(datalabels = FALSE)
|
||||
@ -229,7 +229,7 @@ ggplot_rsi <- function(data,
|
||||
}
|
||||
|
||||
if (identical(position, "fill")) {
|
||||
# portions, so use y scale with percentage
|
||||
# proportions, so use y scale with percentage
|
||||
p <- p + scale_y_percent(breaks = breaks, limits = limits)
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,11 @@
|
||||
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
|
||||
# ==================================================================== #
|
||||
|
||||
#' Calculate resistance of isolates
|
||||
#' Calculate microbial resistance
|
||||
#'
|
||||
#' @description These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
#' @description These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
#'
|
||||
#' \code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr
|
||||
#' \code{resistance} should be used to calculate resistance, \code{susceptibility} should be used to calculate susceptibility.\cr
|
||||
#' @param ... 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.
|
||||
#' @param minimum the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.
|
||||
#' @param as_percent a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character). A value of \code{0.123456} will then be returned as \code{"12.3\%"}.
|
||||
@ -34,15 +34,16 @@
|
||||
#' @param combine_SI a logical to indicate whether all values of S and I 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 section 'Interpretation of S, I and R' below. Default is \code{TRUE}.
|
||||
#' @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. I+R (susceptible vs. non-susceptible). This is outdated, see parameter \code{combine_SI}.
|
||||
#' @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!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link{first_isolate}} to determine them in your data set.
|
||||
#' @details
|
||||
#' The function \code{resistance} is equal to the function \code{proportion_R}. The function \code{susceptibility} is equal to the function \code{proportion_SI}.
|
||||
#'
|
||||
#' 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. The function \code{portion_SI()} is essentially equal to \code{count_SI() / count_all()}. \emph{Low counts can infuence the outcome - the \code{portion} functions may camouflage this, since they only return the portion (albeit being dependent on the \code{minimum} parameter).}
|
||||
#' \strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link{first_isolate}} to determine them in your data set.
|
||||
#'
|
||||
#' The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
|
||||
#' These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. The function \code{susceptibility()} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can infuence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (albeit being dependent on the \code{minimum} parameter).}
|
||||
#'
|
||||
#' The function \code{rsi_df} works exactly like \code{portion_df}, but adds the number of isolates.
|
||||
#' The function \code{proportion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the proportions R, I and S. The function \code{rsi_df} works exactly like \code{proportion_df}, but adds the number of isolates.
|
||||
#' @section Combination therapy:
|
||||
#' When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
|
||||
#' When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{susceptibility} works to calculate the \%SI:
|
||||
#'
|
||||
#' \preformatted{
|
||||
#' --------------------------------------------------------------------
|
||||
@ -65,105 +66,96 @@
|
||||
#'
|
||||
#' Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
|
||||
#' \preformatted{
|
||||
#' count_S() + count_I() + count_R() == count_all()
|
||||
#' portion_S() + portion_I() + portion_R() == 1
|
||||
#' count_S() + count_I() + count_R() = count_all()
|
||||
#' proportion_S() + proportion_I() + proportion_R() = 1
|
||||
#' }
|
||||
#' and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
|
||||
#' \preformatted{
|
||||
#' count_S() + count_I() + count_R() >= count_all()
|
||||
#' portion_S() + portion_I() + portion_R() >= 1
|
||||
#' proportion_S() + proportion_I() + proportion_R() >= 1
|
||||
#' }
|
||||
#'
|
||||
#' Using \code{only_all_tested} has no impact when only using one antibiotic as input.
|
||||
#' @source \strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
|
||||
#'
|
||||
#' Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
#' @seealso \code{\link[AMR]{count}_*} to count resistant and susceptible isolates.
|
||||
#' @return Double or, when \code{as_percent = TRUE}, a character.
|
||||
#' @rdname portion
|
||||
#' @name portion
|
||||
#' @rdname proportion
|
||||
#' @aliases portion
|
||||
#' @name proportion
|
||||
#' @export
|
||||
#' @inheritSection AMR Read more on our website!
|
||||
#' @examples
|
||||
#' # example_isolates is a data set available in the AMR package.
|
||||
#' ?example_isolates
|
||||
#'
|
||||
#' # Calculate resistance
|
||||
#' portion_R(example_isolates$AMX)
|
||||
#' portion_IR(example_isolates$AMX)
|
||||
#' resistance(example_isolates$AMX) # determines %R
|
||||
#' susceptibility(example_isolates$AMX) # determines %S+I
|
||||
#'
|
||||
#' # Or susceptibility
|
||||
#' portion_S(example_isolates$AMX)
|
||||
#' portion_SI(example_isolates$AMX)
|
||||
#' # be more specific
|
||||
#' proportion_S(example_isolates$AMX)
|
||||
#' proportion_SI(example_isolates$AMX)
|
||||
#' proportion_I(example_isolates$AMX)
|
||||
#' proportion_IR(example_isolates$AMX)
|
||||
#' proportion_R(example_isolates$AMX)
|
||||
#'
|
||||
|
||||
#' # Do the above with pipes:
|
||||
#' library(dplyr)
|
||||
#' example_isolates %>% portion_R(AMX)
|
||||
#' example_isolates %>% portion_IR(AMX)
|
||||
#' example_isolates %>% portion_S(AMX)
|
||||
#' example_isolates %>% portion_SI(AMX)
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(r = resistance(CIP),
|
||||
#' n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr, see ?n_rsi
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(p = portion_SI(CIP),
|
||||
#' n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(R = portion_R(CIP, as_percent = TRUE),
|
||||
#' I = portion_I(CIP, as_percent = TRUE),
|
||||
#' S = portion_S(CIP, as_percent = TRUE),
|
||||
#' summarise(R = resistance(CIP, as_percent = TRUE),
|
||||
#' SI = susceptibility(CIP, as_percent = TRUE),
|
||||
#' n1 = count_all(CIP), # the actual total; sum of all three
|
||||
#' n2 = n_rsi(CIP), # same - analogous to n_distinct
|
||||
#' total = n()) # NOT the number of tested isolates!
|
||||
#'
|
||||
#' # Calculate co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
#' # so we can see that combination therapy does a lot more than mono therapy:
|
||||
#' example_isolates %>% portion_SI(AMC) # %SI = 76.3%
|
||||
#' example_isolates %>% susceptibility(AMC) # %SI = 76.3%
|
||||
#' example_isolates %>% count_all(AMC) # n = 1879
|
||||
#'
|
||||
#' example_isolates %>% portion_SI(GEN) # %SI = 75.4%
|
||||
#' example_isolates %>% susceptibility(GEN) # %SI = 75.4%
|
||||
#' example_isolates %>% count_all(GEN) # n = 1855
|
||||
#'
|
||||
#' example_isolates %>% portion_SI(AMC, GEN) # %SI = 94.1%
|
||||
#' example_isolates %>% susceptibility(AMC, GEN) # %SI = 94.1%
|
||||
#' example_isolates %>% count_all(AMC, GEN) # n = 1939
|
||||
#'
|
||||
#'
|
||||
#' # See Details on how `only_all_tested` works. Example:
|
||||
#' example_isolates %>%
|
||||
#' summarise(numerator = count_SI(AMC, GEN),
|
||||
#' summarise(numerator = count_susceptible(AMC, GEN),
|
||||
#' denominator = count_all(AMC, GEN),
|
||||
#' portion = portion_SI(AMC, GEN))
|
||||
#' # numerator denominator portion
|
||||
#' # 1764 1936 0.9408
|
||||
#' proportion = susceptibility(AMC, GEN))
|
||||
|
||||
#' example_isolates %>%
|
||||
#' summarise(numerator = count_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
#' summarise(numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
|
||||
#' denominator = count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
#' portion = portion_SI(AMC, GEN, only_all_tested = TRUE))
|
||||
#' # numerator denominator portion
|
||||
#' # 1687 1798 0.9383
|
||||
#' proportion = susceptibility(AMC, GEN, only_all_tested = TRUE))
|
||||
|
||||
#'
|
||||
#'
|
||||
#' example_isolates %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
|
||||
#' summarise(cipro_p = susceptibility(CIP, as_percent = TRUE),
|
||||
#' cipro_n = count_all(CIP),
|
||||
#' genta_p = portion_SI(GEN, as_percent = TRUE),
|
||||
#' genta_p = susceptibility(GEN, as_percent = TRUE),
|
||||
#' genta_n = count_all(GEN),
|
||||
#' combination_p = portion_SI(CIP, GEN, as_percent = TRUE),
|
||||
#' combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
|
||||
#' combination_n = count_all(CIP, GEN))
|
||||
#'
|
||||
#' # Get portions S/I/R immediately of all rsi columns
|
||||
#' # Get proportions S/I/R immediately of all rsi columns
|
||||
#' example_isolates %>%
|
||||
#' select(AMX, CIP) %>%
|
||||
#' portion_df(translate = FALSE)
|
||||
#' proportion_df(translate = FALSE)
|
||||
#'
|
||||
#' # It also supports grouping variables
|
||||
#' example_isolates %>%
|
||||
#' select(hospital_id, AMX, CIP) %>%
|
||||
#' group_by(hospital_id) %>%
|
||||
#' portion_df(translate = FALSE)
|
||||
#' proportion_df(translate = FALSE)
|
||||
#'
|
||||
#'
|
||||
#' \dontrun{
|
||||
@ -172,10 +164,10 @@
|
||||
#' my_table %>%
|
||||
#' filter(first_isolate == TRUE,
|
||||
#' genus == "Helicobacter") %>%
|
||||
#' summarise(p = portion_S(AMX, MTR), # amoxicillin with metronidazole
|
||||
#' summarise(p = susceptibility(AMX, MTR), # amoxicillin with metronidazole
|
||||
#' n = count_all(AMX, MTR))
|
||||
#' }
|
||||
portion_R <- function(...,
|
||||
resistance <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
@ -187,37 +179,9 @@ portion_R <- function(...,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname portion
|
||||
#' @rdname proportion
|
||||
#' @export
|
||||
portion_IR <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = c("I", "R"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname portion
|
||||
#' @export
|
||||
portion_I <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = "I",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname portion
|
||||
#' @export
|
||||
portion_SI <- function(...,
|
||||
susceptibility <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
@ -229,9 +193,65 @@ portion_SI <- function(...,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname portion
|
||||
#' @rdname proportion
|
||||
#' @export
|
||||
portion_S <- function(...,
|
||||
proportion_R <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = "R",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
#' @export
|
||||
proportion_IR <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = c("I", "R"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
#' @export
|
||||
proportion_I <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = "I",
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
#' @export
|
||||
proportion_SI <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
rsi_calc(...,
|
||||
ab_result = c("S", "I"),
|
||||
minimum = minimum,
|
||||
as_percent = as_percent,
|
||||
only_all_tested = only_all_tested,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname proportion
|
||||
#' @export
|
||||
proportion_S <- function(...,
|
||||
minimum = 30,
|
||||
as_percent = FALSE,
|
||||
only_all_tested = FALSE) {
|
||||
@ -243,10 +263,10 @@ portion_S <- function(...,
|
||||
only_count = FALSE)
|
||||
}
|
||||
|
||||
#' @rdname portion
|
||||
#' @rdname proportion
|
||||
#' @importFrom dplyr %>% select_if bind_rows summarise_if mutate group_vars select everything
|
||||
#' @export
|
||||
portion_df <- function(data,
|
||||
proportion_df <- function(data,
|
||||
translate_ab = "name",
|
||||
language = get_locale(),
|
||||
minimum = 30,
|
||||
@ -254,7 +274,7 @@ portion_df <- function(data,
|
||||
combine_SI = TRUE,
|
||||
combine_IR = FALSE) {
|
||||
|
||||
rsi_calc_df(type = "portion",
|
||||
rsi_calc_df(type = "proportion",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
2
R/rsi.R
@ -46,7 +46,7 @@
|
||||
#'
|
||||
#' 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.
|
||||
#'
|
||||
#' This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
#' This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
|
||||
#' @return Ordered factor with new class \code{rsi}
|
||||
#' @aliases RSI
|
||||
#' @export
|
||||
|
22
R/rsi_calc.R
@ -22,7 +22,7 @@
|
||||
#' @importFrom rlang enquos as_label
|
||||
dots2vars <- function(...) {
|
||||
# this function is to give more informative output about
|
||||
# variable names in count_* and portion_* functions
|
||||
# variable names in count_* and proportion_* functions
|
||||
paste(
|
||||
unlist(
|
||||
lapply(enquos(...),
|
||||
@ -62,30 +62,30 @@ rsi_calc <- function(...,
|
||||
dots_df <- ...elt(1) # it needs this evaluation
|
||||
dots <- base::eval(base::substitute(base::alist(...)))
|
||||
if ("also_single_tested" %in% names(dots)) {
|
||||
stop("`also_single_tested` was replaced by `only_all_tested`. Please read Details in the help page (`?portion`) as this may have a considerable impact on your analysis.", call. = FALSE)
|
||||
stop("`also_single_tested` was replaced by `only_all_tested`. Please read Details in the help page (`?proportion`) as this may have a considerable impact on your analysis.", call. = FALSE)
|
||||
}
|
||||
ndots <- length(dots)
|
||||
|
||||
if ("data.frame" %in% class(dots_df)) {
|
||||
# data.frame passed with other columns, like: example_isolates %>% portion_S(amcl, gent)
|
||||
# data.frame passed with other columns, like: example_isolates %>% proportion_S(amcl, gent)
|
||||
dots <- as.character(dots)
|
||||
dots <- dots[dots != "."]
|
||||
if (length(dots) == 0 | all(dots == "df")) {
|
||||
# for complete data.frames, like example_isolates %>% select(amcl, gent) %>% portion_S()
|
||||
# for complete data.frames, like example_isolates %>% select(amcl, gent) %>% proportion_S()
|
||||
# and the old rsi function, that has "df" as name of the first parameter
|
||||
x <- dots_df
|
||||
} else {
|
||||
x <- dots_df[, dots]
|
||||
}
|
||||
} else if (ndots == 1) {
|
||||
# only 1 variable passed (can also be data.frame), like: portion_S(example_isolates$amcl) and example_isolates$amcl %>% portion_S()
|
||||
# only 1 variable passed (can also be data.frame), like: proportion_S(example_isolates$amcl) and example_isolates$amcl %>% proportion_S()
|
||||
x <- dots_df
|
||||
} else {
|
||||
# multiple variables passed without pipe, like: portion_S(example_isolates$amcl, example_isolates$gent)
|
||||
# multiple variables passed without pipe, like: proportion_S(example_isolates$amcl, example_isolates$gent)
|
||||
x <- NULL
|
||||
try(x <- as.data.frame(dots), silent = TRUE)
|
||||
if (is.null(x)) {
|
||||
# support for: with(example_isolates, portion_S(amcl, gent))
|
||||
# support for: with(example_isolates, proportion_S(amcl, gent))
|
||||
x <- as.data.frame(rlang::list2(...))
|
||||
}
|
||||
}
|
||||
@ -169,7 +169,7 @@ rsi_calc <- function(...,
|
||||
|
||||
#' @importFrom dplyr %>% summarise_if mutate select everything bind_rows
|
||||
#' @importFrom tidyr gather
|
||||
rsi_calc_df <- function(type, # "portion" or "count"
|
||||
rsi_calc_df <- function(type, # "proportion" or "count"
|
||||
data,
|
||||
translate_ab = "name",
|
||||
language = get_locale(),
|
||||
@ -199,10 +199,11 @@ rsi_calc_df <- function(type, # "portion" or "count"
|
||||
}
|
||||
|
||||
get_summaryfunction <- function(int, type) {
|
||||
# look for portion_S, count_S, etc:
|
||||
# look for proportion_S, count_S, etc:
|
||||
int_fn <- get(paste0(type, "_", int), envir = asNamespace("AMR"))
|
||||
|
||||
if (type == "portion") {
|
||||
suppressWarnings(
|
||||
if (type == "proportion") {
|
||||
summ <- summarise_if(.tbl = data,
|
||||
.predicate = is.rsi,
|
||||
.funs = int_fn,
|
||||
@ -213,6 +214,7 @@ rsi_calc_df <- function(type, # "portion" or "count"
|
||||
.predicate = is.rsi,
|
||||
.funs = int_fn)
|
||||
}
|
||||
)
|
||||
summ %>%
|
||||
mutate(interpretation = int) %>%
|
||||
select(interpretation, everything())
|
||||
|
@ -19,7 +19,7 @@
|
||||
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
|
||||
# ==================================================================== #
|
||||
|
||||
#' @rdname portion
|
||||
#' @rdname proportion
|
||||
#' @rdname count
|
||||
#' @export
|
||||
rsi_df <- function(data,
|
||||
@ -30,7 +30,7 @@ rsi_df <- function(data,
|
||||
combine_SI = TRUE,
|
||||
combine_IR = FALSE) {
|
||||
|
||||
portions <- rsi_calc_df(type = "portion",
|
||||
proportions <- rsi_calc_df(type = "proportion",
|
||||
data = data,
|
||||
translate_ab = translate_ab,
|
||||
language = language,
|
||||
@ -50,7 +50,7 @@ rsi_df <- function(data,
|
||||
combine_IR = combine_IR,
|
||||
combine_SI_missing = missing(combine_SI))
|
||||
|
||||
data.frame(portions,
|
||||
data.frame(proportions,
|
||||
isolates = counts$value,
|
||||
stringsAsFactors = FALSE)
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="https://msberends.gitlab.io/AMR/index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -187,7 +187,7 @@
|
||||
<h1>How to conduct AMR analysis</h1>
|
||||
<h4 class="author">Matthijs S. Berends</h4>
|
||||
|
||||
<h4 class="date">09 November 2019</h4>
|
||||
<h4 class="date">10 November 2019</h4>
|
||||
|
||||
|
||||
<div class="hidden name"><code>AMR.Rmd</code></div>
|
||||
@ -196,7 +196,7 @@
|
||||
|
||||
|
||||
|
||||
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 09 November 2019.</p>
|
||||
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 10 November 2019.</p>
|
||||
<div id="introduction" class="section level1">
|
||||
<h1 class="hasAnchor">
|
||||
<a href="#introduction" class="anchor"></a>Introduction</h1>
|
||||
@ -212,21 +212,21 @@
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">2019-11-09</td>
|
||||
<td align="center">2019-11-10</td>
|
||||
<td align="center">abcd</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2019-11-09</td>
|
||||
<td align="center">2019-11-10</td>
|
||||
<td align="center">abcd</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2019-11-09</td>
|
||||
<td align="center">2019-11-10</td>
|
||||
<td align="center">efgh</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">R</td>
|
||||
@ -321,68 +321,68 @@
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">2011-07-25</td>
|
||||
<td align="center">L6</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">2016-01-11</td>
|
||||
<td align="center">N1</td>
|
||||
<td align="center">Hospital C</td>
|
||||
<td align="center">Staphylococcus aureus</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2015-11-29</td>
|
||||
<td align="center">J1</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Klebsiella pneumoniae</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2012-04-04</td>
|
||||
<td align="center">C3</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2017-10-06</td>
|
||||
<td align="center">W8</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2013-07-22</td>
|
||||
<td align="center">Q6</td>
|
||||
<td align="center">2010-12-17</td>
|
||||
<td align="center">D2</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2016-07-05</td>
|
||||
<td align="center">L5</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2011-06-05</td>
|
||||
<td align="center">W7</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">2016-12-23</td>
|
||||
<td align="center">C5</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">Klebsiella pneumoniae</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">2011-06-29</td>
|
||||
<td align="center">F3</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">M</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2011-07-01</td>
|
||||
<td align="center">N10</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">Escherichia coli</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
</tr>
|
||||
@ -406,8 +406,8 @@
|
||||
#
|
||||
# Item Count Percent Cum. Count Cum. Percent
|
||||
# --- ----- ------- -------- ----------- -------------
|
||||
# 1 M 10,398 51.99% 10,398 51.99%
|
||||
# 2 F 9,602 48.01% 20,000 100.00%</code></pre>
|
||||
# 1 M 10,264 51.32% 10,264 51.32%
|
||||
# 2 F 9,736 48.68% 20,000 100.00%</code></pre>
|
||||
<p>So, we can draw at least two conclusions immediately. From a data scientists perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researchers perspective: there are slightly more men. Nothing we didn’t already know.</p>
|
||||
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p>
|
||||
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb12-1" data-line-number="1">data <-<span class="st"> </span>data <span class="op">%>%</span></a>
|
||||
@ -437,14 +437,14 @@
|
||||
<a class="sourceLine" id="cb14-18" data-line-number="18"><span class="co"># Pasteurella multocida (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-19" data-line-number="19"><span class="co"># Staphylococcus (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-20" data-line-number="20"><span class="co"># Streptococcus groups A, B, C, G (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-21" data-line-number="21"><span class="co"># Streptococcus pneumoniae (1,452 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-21" data-line-number="21"><span class="co"># Streptococcus pneumoniae (1,477 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-22" data-line-number="22"><span class="co"># Viridans group streptococci (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-23" data-line-number="23"><span class="co"># </span></a>
|
||||
<a class="sourceLine" id="cb14-24" data-line-number="24"><span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
|
||||
<a class="sourceLine" id="cb14-25" data-line-number="25"><span class="co"># Table 01: Intrinsic resistance in Enterobacteriaceae (1,294 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-25" data-line-number="25"><span class="co"># Table 01: Intrinsic resistance in Enterobacteriaceae (1,306 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-26" data-line-number="26"><span class="co"># Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-27" data-line-number="27"><span class="co"># Table 03: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-28" data-line-number="28"><span class="co"># Table 04: Intrinsic resistance in Gram-positive bacteria (2,721 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-28" data-line-number="28"><span class="co"># Table 04: Intrinsic resistance in Gram-positive bacteria (2,791 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-29" data-line-number="29"><span class="co"># Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-30" data-line-number="30"><span class="co"># Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-31" data-line-number="31"><span class="co"># Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a>
|
||||
@ -452,24 +452,24 @@
|
||||
<a class="sourceLine" id="cb14-33" data-line-number="33"><span class="co"># Table 13: Interpretive rules for quinolones (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-34" data-line-number="34"><span class="co"># </span></a>
|
||||
<a class="sourceLine" id="cb14-35" data-line-number="35"><span class="co"># Other rules</span></a>
|
||||
<a class="sourceLine" id="cb14-36" data-line-number="36"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,287 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-37" data-line-number="37"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (107 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-36" data-line-number="36"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,203 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-37" data-line-number="37"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (104 values changed)</span></a>
|
||||
<a class="sourceLine" id="cb14-38" data-line-number="38"><span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-39" data-line-number="39"><span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-40" data-line-number="40"><span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-41" data-line-number="41"><span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
|
||||
<a class="sourceLine" id="cb14-42" data-line-number="42"><span class="co"># </span></a>
|
||||
<a class="sourceLine" id="cb14-43" data-line-number="43"><span class="co"># --------------------------------------------------------------------------</span></a>
|
||||
<a class="sourceLine" id="cb14-44" data-line-number="44"><span class="co"># EUCAST rules affected 6,525 out of 20,000 rows, making a total of 7,861 edits</span></a>
|
||||
<a class="sourceLine" id="cb14-44" data-line-number="44"><span class="co"># EUCAST rules affected 6,529 out of 20,000 rows, making a total of 7,881 edits</span></a>
|
||||
<a class="sourceLine" id="cb14-45" data-line-number="45"><span class="co"># => added 0 test results</span></a>
|
||||
<a class="sourceLine" id="cb14-46" data-line-number="46"><span class="co"># </span></a>
|
||||
<a class="sourceLine" id="cb14-47" data-line-number="47"><span class="co"># => changed 7,861 test results</span></a>
|
||||
<a class="sourceLine" id="cb14-48" data-line-number="48"><span class="co"># - 100 test results changed from S to I</span></a>
|
||||
<a class="sourceLine" id="cb14-49" data-line-number="49"><span class="co"># - 4,694 test results changed from S to R</span></a>
|
||||
<a class="sourceLine" id="cb14-50" data-line-number="50"><span class="co"># - 1,140 test results changed from I to S</span></a>
|
||||
<a class="sourceLine" id="cb14-51" data-line-number="51"><span class="co"># - 302 test results changed from I to R</span></a>
|
||||
<a class="sourceLine" id="cb14-52" data-line-number="52"><span class="co"># - 1,594 test results changed from R to S</span></a>
|
||||
<a class="sourceLine" id="cb14-53" data-line-number="53"><span class="co"># - 31 test results changed from R to I</span></a>
|
||||
<a class="sourceLine" id="cb14-47" data-line-number="47"><span class="co"># => changed 7,881 test results</span></a>
|
||||
<a class="sourceLine" id="cb14-48" data-line-number="48"><span class="co"># - 102 test results changed from S to I</span></a>
|
||||
<a class="sourceLine" id="cb14-49" data-line-number="49"><span class="co"># - 4,800 test results changed from S to R</span></a>
|
||||
<a class="sourceLine" id="cb14-50" data-line-number="50"><span class="co"># - 1,035 test results changed from I to S</span></a>
|
||||
<a class="sourceLine" id="cb14-51" data-line-number="51"><span class="co"># - 291 test results changed from I to R</span></a>
|
||||
<a class="sourceLine" id="cb14-52" data-line-number="52"><span class="co"># - 1,625 test results changed from R to S</span></a>
|
||||
<a class="sourceLine" id="cb14-53" data-line-number="53"><span class="co"># - 28 test results changed from R to I</span></a>
|
||||
<a class="sourceLine" id="cb14-54" data-line-number="54"><span class="co"># --------------------------------------------------------------------------</span></a>
|
||||
<a class="sourceLine" id="cb14-55" data-line-number="55"><span class="co"># </span></a>
|
||||
<a class="sourceLine" id="cb14-56" data-line-number="56"><span class="co"># Use eucast_rules(..., verbose = TRUE) (on your original data) to get a data.frame with all specified edits instead.</span></a></code></pre></div>
|
||||
@ -497,7 +497,7 @@
|
||||
<a class="sourceLine" id="cb16-3" data-line-number="3"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
|
||||
<a class="sourceLine" id="cb16-4" data-line-number="4"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
|
||||
<a class="sourceLine" id="cb16-5" data-line-number="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
|
||||
<a class="sourceLine" id="cb16-6" data-line-number="6"><span class="co"># => Found 5,670 first isolates (28.4% of total)</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb16-6" data-line-number="6"><span class="co"># => Found 5,674 first isolates (28.4% of total)</span></a></code></pre></div>
|
||||
<p>So only 28.4% is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
|
||||
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb17-1" data-line-number="1">data_1st <-<span class="st"> </span>data <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb17-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div>
|
||||
@ -508,7 +508,7 @@
|
||||
<div id="first-weighted-isolates" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#first-weighted-isolates" class="anchor"></a>First <em>weighted</em> isolates</h2>
|
||||
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient Y8, sorted on date:</p>
|
||||
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient S8, sorted on date:</p>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="center">isolate</th>
|
||||
@ -524,10 +524,10 @@
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">1</td>
|
||||
<td align="center">2010-04-05</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-01-27</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -535,10 +535,10 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2</td>
|
||||
<td align="center">2010-04-09</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-06-01</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -546,32 +546,32 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">3</td>
|
||||
<td align="center">2010-04-14</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-09-13</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">4</td>
|
||||
<td align="center">2010-05-23</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-09-27</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">5</td>
|
||||
<td align="center">2010-07-05</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-10-15</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -579,8 +579,8 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">6</td>
|
||||
<td align="center">2010-07-05</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-12-25</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
@ -590,32 +590,32 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">7</td>
|
||||
<td align="center">2010-07-10</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-02-06</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">8</td>
|
||||
<td align="center">2010-08-07</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-03-27</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">9</td>
|
||||
<td align="center">2010-09-24</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-05-14</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -623,18 +623,18 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">10</td>
|
||||
<td align="center">2011-02-13</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-09-12</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Only 1 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
|
||||
<p>Only 2 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
|
||||
<p>If a column exists with a name like ‘key(…)ab’ the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p>
|
||||
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb19-1" data-line-number="1">data <-<span class="st"> </span>data <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb19-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">keyab =</span> <span class="kw"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(.)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
@ -645,7 +645,7 @@
|
||||
<a class="sourceLine" id="cb19-7" data-line-number="7"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
|
||||
<a class="sourceLine" id="cb19-8" data-line-number="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
|
||||
<a class="sourceLine" id="cb19-9" data-line-number="9"><span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I</span></a>
|
||||
<a class="sourceLine" id="cb19-10" data-line-number="10"><span class="co"># => Found 15,079 first weighted isolates (75.4% of total)</span></a></code></pre></div>
|
||||
<a class="sourceLine" id="cb19-10" data-line-number="10"><span class="co"># => Found 15,253 first weighted isolates (76.3% of total)</span></a></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="center">isolate</th>
|
||||
@ -662,10 +662,10 @@
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">1</td>
|
||||
<td align="center">2010-04-05</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-01-27</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -674,10 +674,10 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">2</td>
|
||||
<td align="center">2010-04-09</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-06-01</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -686,34 +686,34 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">3</td>
|
||||
<td align="center">2010-04-14</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-09-13</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">4</td>
|
||||
<td align="center">2010-09-27</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">4</td>
|
||||
<td align="center">2010-05-23</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">5</td>
|
||||
<td align="center">2010-07-05</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-10-15</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -722,46 +722,46 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">6</td>
|
||||
<td align="center">2010-07-05</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2010-12-25</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">7</td>
|
||||
<td align="center">2010-07-10</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-02-06</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">TRUE</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">8</td>
|
||||
<td align="center">2010-08-07</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-03-27</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">9</td>
|
||||
<td align="center">2010-09-24</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-05-14</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
@ -770,23 +770,23 @@
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">10</td>
|
||||
<td align="center">2011-02-13</td>
|
||||
<td align="center">Y8</td>
|
||||
<td align="center">2011-09-12</td>
|
||||
<td align="center">S8</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">FALSE</td>
|
||||
<td align="center">TRUE</td>
|
||||
<td align="center">FALSE</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Instead of 1, now 7 isolates are flagged. In total, 75.4% of all isolates are marked ‘first weighted’ - 47.0% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
|
||||
<p>Instead of 2, now 6 isolates are flagged. In total, 76.3% of all isolates are marked ‘first weighted’ - 47.9% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
|
||||
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, there’s a shortcut for this new algorithm too:</p>
|
||||
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" data-line-number="1">data_1st <-<span class="st"> </span>data <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb20-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div>
|
||||
<p>So we end up with 15,079 isolates for analysis.</p>
|
||||
<p>So we end up with 15,253 isolates for analysis.</p>
|
||||
<p>We can remove unneeded columns:</p>
|
||||
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1">data_1st <-<span class="st"> </span>data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb21-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(first, keyab))</a></code></pre></div>
|
||||
@ -811,29 +811,29 @@
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td>1</td>
|
||||
<td align="center">2011-07-25</td>
|
||||
<td align="center">L6</td>
|
||||
<td>2</td>
|
||||
<td align="center">2010-12-17</td>
|
||||
<td align="center">D2</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">B_STPHY_AURS</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram-positive</td>
|
||||
<td align="center">Staphylococcus</td>
|
||||
<td align="center">aureus</td>
|
||||
<td align="center">Gram-negative</td>
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">coli</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>3</td>
|
||||
<td align="center">2012-04-04</td>
|
||||
<td align="center">C3</td>
|
||||
<td align="center">2016-07-05</td>
|
||||
<td align="center">L5</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
@ -844,31 +844,31 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>4</td>
|
||||
<td align="center">2017-10-06</td>
|
||||
<td align="center">W8</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">2016-12-23</td>
|
||||
<td align="center">C5</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">B_KLBSL_PNMN</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram-negative</td>
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">coli</td>
|
||||
<td align="center">Klebsiella</td>
|
||||
<td align="center">pneumoniae</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>5</td>
|
||||
<td align="center">2013-07-22</td>
|
||||
<td align="center">Q6</td>
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">2011-06-29</td>
|
||||
<td align="center">F3</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">I</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram-negative</td>
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">coli</td>
|
||||
@ -876,13 +876,13 @@
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td>6</td>
|
||||
<td align="center">2011-06-05</td>
|
||||
<td align="center">W7</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">2011-07-01</td>
|
||||
<td align="center">N10</td>
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">R</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">Gram-negative</td>
|
||||
@ -891,19 +891,19 @@
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td>9</td>
|
||||
<td align="center">2013-04-24</td>
|
||||
<td align="center">D1</td>
|
||||
<td>8</td>
|
||||
<td align="center">2010-01-02</td>
|
||||
<td align="center">X9</td>
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">B_STPHY_AURS</td>
|
||||
<td align="center">B_ESCHR_COLI</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">S</td>
|
||||
<td align="center">M</td>
|
||||
<td align="center">Gram-positive</td>
|
||||
<td align="center">Staphylococcus</td>
|
||||
<td align="center">aureus</td>
|
||||
<td align="center">F</td>
|
||||
<td align="center">Gram-negative</td>
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">coli</td>
|
||||
<td align="center">TRUE</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -925,7 +925,7 @@
|
||||
<div class="sourceCode" id="cb24"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb24-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/cleaner/man/freq.html">freq</a></span>(genus, species)</a></code></pre></div>
|
||||
<p><strong>Frequency table</strong></p>
|
||||
<p>Class: character<br>
|
||||
Length: 15,079 (of which NA: 0 = 0%)<br>
|
||||
Length: 15,253 (of which NA: 0 = 0%)<br>
|
||||
Unique: 4</p>
|
||||
<p>Shortest: 16<br>
|
||||
Longest: 24</p>
|
||||
@ -942,33 +942,33 @@ Longest: 24</p>
|
||||
<tr class="odd">
|
||||
<td align="left">1</td>
|
||||
<td align="left">Escherichia coli</td>
|
||||
<td align="right">7,442</td>
|
||||
<td align="right">49.35%</td>
|
||||
<td align="right">7,442</td>
|
||||
<td align="right">49.35%</td>
|
||||
<td align="right">7,529</td>
|
||||
<td align="right">49.36%</td>
|
||||
<td align="right">7,529</td>
|
||||
<td align="right">49.36%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">2</td>
|
||||
<td align="left">Staphylococcus aureus</td>
|
||||
<td align="right">3,732</td>
|
||||
<td align="right">24.75%</td>
|
||||
<td align="right">11,174</td>
|
||||
<td align="right">74.10%</td>
|
||||
<td align="right">3,765</td>
|
||||
<td align="right">24.68%</td>
|
||||
<td align="right">11,294</td>
|
||||
<td align="right">74.04%</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="left">3</td>
|
||||
<td align="left">Streptococcus pneumoniae</td>
|
||||
<td align="right">2,323</td>
|
||||
<td align="right">2,350</td>
|
||||
<td align="right">15.41%</td>
|
||||
<td align="right">13,497</td>
|
||||
<td align="right">89.51%</td>
|
||||
<td align="right">13,644</td>
|
||||
<td align="right">89.45%</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="left">4</td>
|
||||
<td align="left">Klebsiella pneumoniae</td>
|
||||
<td align="right">1,582</td>
|
||||
<td align="right">10.49%</td>
|
||||
<td align="right">15,079</td>
|
||||
<td align="right">1,609</td>
|
||||
<td align="right">10.55%</td>
|
||||
<td align="right">15,253</td>
|
||||
<td align="right">100.00%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -977,13 +977,14 @@ Longest: 24</p>
|
||||
<div id="resistance-percentages" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
|
||||
<p>The functions <code><a href="../reference/portion.html">portion_S()</a></code>, <code><a href="../reference/portion.html">portion_SI()</a></code>, <code><a href="../reference/portion.html">portion_I()</a></code>, <code><a href="../reference/portion.html">portion_IR()</a></code> and <code><a href="../reference/portion.html">portion_R()</a></code> can be used to determine the portion of a specific antimicrobial outcome. As per the EUCAST guideline of 2019, we calculate resistance as the portion of R (<code><a href="../reference/portion.html">portion_R()</a></code>) and susceptibility as the portion of S and I (<code><a href="../reference/portion.html">portion_SI()</a></code>). These functions can be used on their own:</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_R</a></span>(AMX)</a>
|
||||
<a class="sourceLine" id="cb25-2" data-line-number="2"><span class="co"># [1] 0.4668081</span></a></code></pre></div>
|
||||
<p>The functions <code><a href="../reference/proportion.html">resistance()</a></code> and <code><a href="../reference/proportion.html">susceptibility()</a></code> can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions <code><a href="../reference/proportion.html">proportion_S()</a></code>, <code><a href="../reference/proportion.html">proportion_SI()</a></code>, <code><a href="../reference/proportion.html">proportion_I()</a></code>, <code><a href="../reference/proportion.html">proportion_IR()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code> can be used to determine the proportion of a specific antimicrobial outcome.</p>
|
||||
<p>As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (<code><a href="../reference/proportion.html">proportion_R()</a></code>, equal to <code><a href="../reference/proportion.html">resistance()</a></code>) and susceptibility as the proportion of S and I (<code><a href="../reference/proportion.html">proportion_SI()</a></code>, equal to <code><a href="../reference/proportion.html">susceptibility()</a></code>). These functions can be used on their own:</p>
|
||||
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/proportion.html">resistance</a></span>(AMX)</a>
|
||||
<a class="sourceLine" id="cb25-2" data-line-number="2"><span class="co"># [1] 0.4715794</span></a></code></pre></div>
|
||||
<p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
|
||||
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb26-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb26-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="dt">amoxicillin =</span> <span class="kw"><a href="../reference/portion.html">portion_R</a></span>(AMX))</a></code></pre></div>
|
||||
<a class="sourceLine" id="cb26-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="dt">amoxicillin =</span> <span class="kw"><a href="../reference/proportion.html">resistance</a></span>(AMX))</a></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="center">hospital</th>
|
||||
@ -992,26 +993,26 @@ Longest: 24</p>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">0.4627198</td>
|
||||
<td align="center">0.4697103</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">0.4745283</td>
|
||||
<td align="center">0.4727821</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital C</td>
|
||||
<td align="center">0.4721269</td>
|
||||
<td align="center">0.4739112</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">0.4549763</td>
|
||||
<td align="center">0.4705116</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the <code><a href="../reference/count.html">n_rsi()</a></code> can be used, which works exactly like <code><a href="https://dplyr.tidyverse.org/reference/n_distinct.html">n_distinct()</a></code> from the <code>dplyr</code> package. It counts all isolates available for every group (i.e. values S, I or R):</p>
|
||||
<div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb27-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb27-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb27-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="dt">amoxicillin =</span> <span class="kw"><a href="../reference/portion.html">portion_R</a></span>(AMX),</a>
|
||||
<a class="sourceLine" id="cb27-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="dt">amoxicillin =</span> <span class="kw"><a href="../reference/proportion.html">resistance</a></span>(AMX),</a>
|
||||
<a class="sourceLine" id="cb27-4" data-line-number="4"> <span class="dt">available =</span> <span class="kw"><a href="../reference/count.html">n_rsi</a></span>(AMX))</a></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
@ -1022,32 +1023,32 @@ Longest: 24</p>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital A</td>
|
||||
<td align="center">0.4627198</td>
|
||||
<td align="center">4493</td>
|
||||
<td align="center">0.4697103</td>
|
||||
<td align="center">4556</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital B</td>
|
||||
<td align="center">0.4745283</td>
|
||||
<td align="center">5300</td>
|
||||
<td align="center">0.4727821</td>
|
||||
<td align="center">5309</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">Hospital C</td>
|
||||
<td align="center">0.4721269</td>
|
||||
<td align="center">2332</td>
|
||||
<td align="center">0.4739112</td>
|
||||
<td align="center">2319</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Hospital D</td>
|
||||
<td align="center">0.4549763</td>
|
||||
<td align="center">2954</td>
|
||||
<td align="center">0.4705116</td>
|
||||
<td align="center">3069</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>These functions can also be used to get the portion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:</p>
|
||||
<p>These functions can also be used to get the proportion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:</p>
|
||||
<div class="sourceCode" id="cb28"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb28-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb28-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(genus) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb28-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="dt">amoxiclav =</span> <span class="kw"><a href="../reference/portion.html">portion_SI</a></span>(AMC),</a>
|
||||
<a class="sourceLine" id="cb28-4" data-line-number="4"> <span class="dt">gentamicin =</span> <span class="kw"><a href="../reference/portion.html">portion_SI</a></span>(GEN),</a>
|
||||
<a class="sourceLine" id="cb28-5" data-line-number="5"> <span class="dt">amoxiclav_genta =</span> <span class="kw"><a href="../reference/portion.html">portion_SI</a></span>(AMC, GEN))</a></code></pre></div>
|
||||
<a class="sourceLine" id="cb28-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="dt">amoxiclav =</span> <span class="kw"><a href="../reference/proportion.html">susceptibility</a></span>(AMC),</a>
|
||||
<a class="sourceLine" id="cb28-4" data-line-number="4"> <span class="dt">gentamicin =</span> <span class="kw"><a href="../reference/proportion.html">susceptibility</a></span>(GEN),</a>
|
||||
<a class="sourceLine" id="cb28-5" data-line-number="5"> <span class="dt">amoxiclav_genta =</span> <span class="kw"><a href="../reference/proportion.html">susceptibility</a></span>(AMC, GEN))</a></code></pre></div>
|
||||
<table class="table">
|
||||
<thead><tr class="header">
|
||||
<th align="center">genus</th>
|
||||
@ -1058,36 +1059,36 @@ Longest: 24</p>
|
||||
<tbody>
|
||||
<tr class="odd">
|
||||
<td align="center">Escherichia</td>
|
||||
<td align="center">0.9250202</td>
|
||||
<td align="center">0.8972051</td>
|
||||
<td align="center">0.9965063</td>
|
||||
<td align="center">0.9246912</td>
|
||||
<td align="center">0.8918847</td>
|
||||
<td align="center">0.9929606</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Klebsiella</td>
|
||||
<td align="center">0.8160556</td>
|
||||
<td align="center">0.8982301</td>
|
||||
<td align="center">0.9841972</td>
|
||||
<td align="center">0.8309509</td>
|
||||
<td align="center">0.9030454</td>
|
||||
<td align="center">0.9869484</td>
|
||||
</tr>
|
||||
<tr class="odd">
|
||||
<td align="center">Staphylococcus</td>
|
||||
<td align="center">0.9217578</td>
|
||||
<td align="center">0.9161308</td>
|
||||
<td align="center">0.9930332</td>
|
||||
<td align="center">0.9301461</td>
|
||||
<td align="center">0.9189907</td>
|
||||
<td align="center">0.9933599</td>
|
||||
</tr>
|
||||
<tr class="even">
|
||||
<td align="center">Streptococcus</td>
|
||||
<td align="center">0.6147223</td>
|
||||
<td align="center">0.6251064</td>
|
||||
<td align="center">0.0000000</td>
|
||||
<td align="center">0.6147223</td>
|
||||
<td align="center">0.6251064</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>To make a transition to the next part, let’s see how this difference could be plotted:</p>
|
||||
<div class="sourceCode" id="cb29"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb29-1" data-line-number="1">data_1st <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb29-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(genus) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb29-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="st">"1. Amoxi/clav"</span> =<span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_SI</a></span>(AMC),</a>
|
||||
<a class="sourceLine" id="cb29-4" data-line-number="4"> <span class="st">"2. Gentamicin"</span> =<span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_SI</a></span>(GEN),</a>
|
||||
<a class="sourceLine" id="cb29-5" data-line-number="5"> <span class="st">"3. Amoxi/clav + genta"</span> =<span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_SI</a></span>(AMC, GEN)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb29-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise</a></span>(<span class="st">"1. Amoxi/clav"</span> =<span class="st"> </span><span class="kw"><a href="../reference/proportion.html">susceptibility</a></span>(AMC),</a>
|
||||
<a class="sourceLine" id="cb29-4" data-line-number="4"> <span class="st">"2. Gentamicin"</span> =<span class="st"> </span><span class="kw"><a href="../reference/proportion.html">susceptibility</a></span>(GEN),</a>
|
||||
<a class="sourceLine" id="cb29-5" data-line-number="5"> <span class="st">"3. Amoxi/clav + genta"</span> =<span class="st"> </span><span class="kw"><a href="../reference/proportion.html">susceptibility</a></span>(AMC, GEN)) <span class="op">%>%</span><span class="st"> </span></a>
|
||||
<a class="sourceLine" id="cb29-6" data-line-number="6"><span class="st"> </span>tidyr<span class="op">::</span><span class="kw"><a href="https://tidyr.tidyverse.org/reference/gather.html">gather</a></span>(<span class="st">"antibiotic"</span>, <span class="st">"S"</span>, <span class="op">-</span>genus) <span class="op">%>%</span></a>
|
||||
<a class="sourceLine" id="cb29-7" data-line-number="7"><span class="st"> </span><span class="kw"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span>(<span class="kw"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span>(<span class="dt">x =</span> genus,</a>
|
||||
<a class="sourceLine" id="cb29-8" data-line-number="8"> <span class="dt">y =</span> S,</a>
|
||||
@ -1111,7 +1112,7 @@ Longest: 24</p>
|
||||
<a class="sourceLine" id="cb30-10" data-line-number="10"><span class="co"># or as short as:</span></a>
|
||||
<a class="sourceLine" id="cb30-11" data-line-number="11"><span class="kw"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span>(a_data_set) <span class="op">+</span></a>
|
||||
<a class="sourceLine" id="cb30-12" data-line-number="12"><span class="st"> </span><span class="kw"><a href="https://ggplot2.tidyverse.org/reference/geom_bar.html">geom_bar</a></span>(<span class="kw"><a href="https://ggplot2.tidyverse.org/reference/aes.html">aes</a></span>(year))</a></code></pre></div>
|
||||
<p>The <code>AMR</code> package contains functions to extend this <code>ggplot2</code> package, for example <code><a href="../reference/ggplot_rsi.html">geom_rsi()</a></code>. It automatically transforms data with <code><a href="../reference/count.html">count_df()</a></code> or <code><a href="../reference/portion.html">portion_df()</a></code> and show results in stacked bars. Its simplest and shortest example:</p>
|
||||
<p>The <code>AMR</code> package contains functions to extend this <code>ggplot2</code> package, for example <code><a href="../reference/ggplot_rsi.html">geom_rsi()</a></code>. It automatically transforms data with <code><a href="../reference/count.html">count_df()</a></code> or <code><a href="../reference/proportion.html">proportion_df()</a></code> and show results in stacked bars. Its simplest and shortest example:</p>
|
||||
<div class="sourceCode" id="cb31"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb31-1" data-line-number="1"><span class="kw"><a href="https://ggplot2.tidyverse.org/reference/ggplot.html">ggplot</a></span>(data_1st) <span class="op">+</span></a>
|
||||
<a class="sourceLine" id="cb31-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/ggplot_rsi.html">geom_rsi</a></span>(<span class="dt">translate_ab =</span> <span class="ot">FALSE</span>)</a></code></pre></div>
|
||||
<p><img src="AMR_files/figure-html/plot%203-1.png" width="720"></p>
|
||||
|
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 102 KiB After Width: | Height: | Size: 102 KiB |
Before Width: | Height: | Size: 83 KiB After Width: | Height: | Size: 83 KiB |
@ -84,7 +84,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -45,7 +45,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -338,7 +338,7 @@ A methods paper about this package has been preprinted at bioRxiv. It was update
|
||||
<li>
|
||||
<p>It <strong>analyses the data</strong> with convenient functions that use well-known methods.</p>
|
||||
<ul>
|
||||
<li>Calculate the resistance (and even co-resistance) of microbial isolates with the <code><a href="reference/portion.html">portion_R()</a></code>, <code><a href="reference/portion.html">portion_IR()</a></code>, <code><a href="reference/portion.html">portion_I()</a></code>, <code><a href="reference/portion.html">portion_SI()</a></code> and <code><a href="reference/portion.html">portion_S()</a></code> functions. Similarly, the <em>number</em> of isolates can be determined with the <code><a href="reference/count.html">count_R()</a></code>, <code><a href="reference/count.html">count_IR()</a></code>, <code><a href="reference/count.html">count_I()</a></code>, <code><a href="reference/count.html">count_SI()</a></code> and <code><a href="reference/count.html">count_S()</a></code> functions. All these functions can be used with the <code>dplyr</code> package (e.g. in conjunction with <code>summarise()</code>)</li>
|
||||
<li>Calculate the microbial susceptibility or resistance (and even co-resistance) with the <code><a href="reference/proportion.html">susceptibility()</a></code> and <code><a href="reference/proportion.html">resistance()</a></code> functions, or be even more specific with the <code><a href="reference/proportion.html">proportion_R()</a></code>, <code><a href="reference/proportion.html">proportion_IR()</a></code>, <code><a href="reference/proportion.html">proportion_I()</a></code>, <code><a href="reference/proportion.html">proportion_SI()</a></code> and <code><a href="reference/proportion.html">proportion_S()</a></code> functions. Similarly, the <em>number</em> of isolates can be determined with the <code><a href="reference/count.html">count_resistant()</a></code>, <code><a href="reference/count.html">count_susceptible()</a></code> and <code><a href="reference/count.html">count_all()</a></code> functions. All these functions can be used with the <code>dplyr</code> package (e.g. in conjunction with <code>summarise()</code>)</li>
|
||||
<li>Plot AMR results with <code><a href="reference/ggplot_rsi.html">geom_rsi()</a></code>, a function made for the <code>ggplot2</code> package</li>
|
||||
<li>Predict antimicrobial resistance for the nextcoming years using logistic regression models with the <code><a href="reference/resistance_predict.html">resistance_predict()</a></code> function</li>
|
||||
</ul>
|
||||
|
@ -84,7 +84,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -231,15 +231,16 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div id="amr-0-8-0-9026" class="section level1">
|
||||
<div id="amr-0-8-0-9027" class="section level1">
|
||||
<h1 class="page-header">
|
||||
<a href="#amr-0-8-0-9026" class="anchor"></a>AMR 0.8.0.9026<small> Unreleased </small>
|
||||
<a href="#amr-0-8-0-9027" class="anchor"></a>AMR 0.8.0.9027<small> Unreleased </small>
|
||||
</h1>
|
||||
<p><small>Last updated: 10-Nov-2019</small></p>
|
||||
<div id="new" class="section level3">
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#new" class="anchor"></a>New</h3>
|
||||
<ul>
|
||||
<li>Functions <code><a href="../reference/proportion.html">susceptibility()</a></code> and <code><a href="../reference/proportion.html">resistance()</a></code> as aliases of <code><a href="../reference/proportion.html">proportion_SI()</a></code> and <code><a href="../reference/proportion.html">proportion_R()</a></code>, respectively. These functions were added to make it more clear that I should be considered susceptible and not resistant.</li>
|
||||
<li>Support for a new MDRO guideline: Magiorakos AP, Srinivasan A <em>et al.</em> “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012).
|
||||
<ul>
|
||||
<li>This is now the new default guideline for the <code><a href="../reference/mdro.html">mdro()</a></code> function</li>
|
||||
@ -252,12 +253,15 @@
|
||||
<h3 class="hasAnchor">
|
||||
<a href="#changes" class="anchor"></a>Changes</h3>
|
||||
<ul>
|
||||
<li>Removed previously deprecated function <code><a href="../reference/as.rsi.html">as.rsi()</a></code> - this function was replaced by <code><a href="../reference/ab_property.html">ab_atc()</a></code>
|
||||
</li>
|
||||
<li>Renamed all <code>portion_*</code> functions to <code>proportion_*</code>. All <code>portion_*</code> functions are still available as deprecated functions, and will return a warning when used.</li>
|
||||
<li>When running <code><a href="../reference/as.rsi.html">as.rsi()</a></code> over a data set, it will now print the guideline that will be used if it is not specified by the user</li>
|
||||
<li>Fix for <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>: <em>Stenotrophomonas maltophilia</em> not interpreted “R” to ceftazidime anymore (following EUCAST v3.1)</li>
|
||||
<li>Adopted Adeolu <em>et al.</em> (2016), <a href="https://www.ncbi.nlm.nih.gov/pubmed/27620848">PMID 27620848</a> for the <code>microorganisms</code> data set, which means that the new order Enterobacterales now consists of a part of the existing family <em>Enterobacteriaceae</em>, but that this family has been split into other families as well (like <em>Morganellaceae</em> and <em>Yersiniaceae</em>). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with <code><a href="../reference/mdro.html">mdro()</a></code> will now use the Enterobacterales order for all guidelines before 2016.</li>
|
||||
<li>Fix for interpreting MIC values with <code><a href="../reference/as.rsi.html">as.rsi()</a></code> where the input is <code>NA</code>
|
||||
</li>
|
||||
<li>Added “imi” as allowed abbreviation for Imipenem</li>
|
||||
<li>Added “imi” and “imp” as allowed abbreviation for Imipenem (IPM)</li>
|
||||
<li>Fix for automatically determining columns with antibiotic results in <code><a href="../reference/mdro.html">mdro()</a></code> and <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
|
||||
</li>
|
||||
<li>Added ATC codes for ceftaroline, ceftobiprole and faropenem and fixed two typos in the <code>antibiotics</code> data set</li>
|
||||
@ -392,7 +396,7 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
</ul>
|
||||
</li>
|
||||
<li>Improved the internal auto-guessing function for determining antimicrobials in your data set (<code>AMR:::get_column_abx()</code>)</li>
|
||||
<li>Removed class <code>atc</code> - using <code><a href="../reference/AMR-deprecated.html">as.atc()</a></code> is now deprecated in favour of <code><a href="../reference/ab_property.html">ab_atc()</a></code> and this will return a character, not the <code>atc</code> class anymore</li>
|
||||
<li>Removed class <code>atc</code> - using <code>as.atc()</code> is now deprecated in favour of <code><a href="../reference/ab_property.html">ab_atc()</a></code> and this will return a character, not the <code>atc</code> class anymore</li>
|
||||
<li>Removed deprecated functions <code>abname()</code>, <code>ab_official()</code>, <code>atc_name()</code>, <code>atc_official()</code>, <code>atc_property()</code>, <code>atc_tradenames()</code>, <code>atc_trivial_nl()</code>
|
||||
</li>
|
||||
<li>Fix and speed improvement for <code><a href="../reference/mo_property.html">mo_shortname()</a></code>
|
||||
@ -403,7 +407,7 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
<li>The <code>antibiotics</code> data set is now sorted by name and all cephalosporins now have their generation between brackets</li>
|
||||
<li>Speed improvement for <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> which is now 30 times faster for antibiotic abbreviations</li>
|
||||
<li>Improved <code><a href="../reference/filter_ab_class.html">filter_ab_class()</a></code> to be more reliable and to support 5th generation cephalosporins</li>
|
||||
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code><a href="../reference/portion.html">portion_R()</a></code> instead of <code><a href="../reference/portion.html">portion_IR()</a></code>, to comply with EUCAST insights</li>
|
||||
<li>Function <code><a href="../reference/availability.html">availability()</a></code> now uses <code><a href="../reference/AMR-deprecated.html">portion_R()</a></code> instead of <code><a href="../reference/AMR-deprecated.html">portion_IR()</a></code>, to comply with EUCAST insights</li>
|
||||
<li>Functions <code><a href="../reference/age.html">age()</a></code> and <code><a href="../reference/age_groups.html">age_groups()</a></code> now have a <code>na.rm</code> parameter to remove empty values</li>
|
||||
<li>Renamed function <code><a href="../reference/AMR-deprecated.html">p.symbol()</a></code> to <code><a href="../reference/p_symbol.html">p_symbol()</a></code> (the former is now deprecated and will be removed in a future version)</li>
|
||||
<li>Using negative values for <code>x</code> in <code><a href="../reference/age_groups.html">age_groups()</a></code> will now introduce <code>NA</code>s and not return an error anymore</li>
|
||||
@ -433,10 +437,10 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
<a href="#new-2" class="anchor"></a>New</h4>
|
||||
<ul>
|
||||
<li>
|
||||
<p>Function <code><a href="../reference/portion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><a href="../reference/count.html">count_df()</a></code> and <code><a href="../reference/portion.html">portion_df()</a></code> to immediately show resistance percentages and number of available isolates:</p>
|
||||
<p>Function <code><a href="../reference/proportion.html">rsi_df()</a></code> to transform a <code>data.frame</code> to a data set containing only the microbial interpretation (S, I, R), the antibiotic, the percentage of S/I/R and the number of available isolates. This is a convenient combination of the existing functions <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> to immediately show resistance percentages and number of available isolates:</p>
|
||||
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">septic_patients <span class="op">%>%</span></a>
|
||||
<a class="sourceLine" id="cb7-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(AMX, CIP) <span class="op">%>%</span></a>
|
||||
<a class="sourceLine" id="cb7-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/portion.html">rsi_df</a></span>()</a>
|
||||
<a class="sourceLine" id="cb7-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/proportion.html">rsi_df</a></span>()</a>
|
||||
<a class="sourceLine" id="cb7-4" data-line-number="4"><span class="co"># antibiotic interpretation value isolates</span></a>
|
||||
<a class="sourceLine" id="cb7-5" data-line-number="5"><span class="co"># 1 Amoxicillin SI 0.4442636 546</span></a>
|
||||
<a class="sourceLine" id="cb7-6" data-line-number="6"><span class="co"># 2 Amoxicillin R 0.5557364 683</span></a>
|
||||
@ -474,7 +478,7 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
|
||||
<h4 class="hasAnchor">
|
||||
<a href="#changed-1" class="anchor"></a>Changed</h4>
|
||||
<ul>
|
||||
<li>Column names of output <code><a href="../reference/count.html">count_df()</a></code> and <code><a href="../reference/portion.html">portion_df()</a></code> are now lowercase</li>
|
||||
<li>Column names of output <code><a href="../reference/count.html">count_df()</a></code> and <code>portion_df()</code> are now lowercase</li>
|
||||
<li>Fixed bug in translation of microorganism names</li>
|
||||
<li>Fixed bug in determining taxonomic kingdoms</li>
|
||||
<li>Algorithm improvements for <code><a href="../reference/as.ab.html">as.ab()</a></code> and <code><a href="../reference/as.mo.html">as.mo()</a></code> to understand even more severely misspelled input</li>
|
||||
@ -552,7 +556,7 @@ Please <a href="https://gitlab.com/msberends/AMR/issues/new?issue%5Btitle%5D=Tra
|
||||
<li>Improved intelligence of looking up antibiotic columns in a 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. Our plotting function <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> also reflects this change since it uses <code><a href="../reference/count.html">count_df()</a></code> internally.</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>portion_df()</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. Our plotting function <code><a href="../reference/ggplot_rsi.html">ggplot_rsi()</a></code> also reflects this change since it uses <code><a href="../reference/count.html">count_df()</a></code> internally.</li>
|
||||
<li>The <code><a href="../reference/age.html">age()</a></code> function gained a new parameter <code>exact</code> to determine ages with decimals</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>
|
||||
@ -681,7 +685,7 @@ This data is updated annually - check the included version with the new function
|
||||
<a class="sourceLine" id="cb12-5" data-line-number="5">ab_certe -><span class="st"> </span><span class="kw">atc_certe</span>()</a>
|
||||
<a class="sourceLine" id="cb12-6" data-line-number="6">ab_umcg -><span class="st"> </span><span class="kw">atc_umcg</span>()</a>
|
||||
<a class="sourceLine" id="cb12-7" data-line-number="7">ab_tradenames -><span class="st"> </span><span class="kw">atc_tradenames</span>()</a></code></pre></div>
|
||||
These functions use <code><a href="../reference/AMR-deprecated.html">as.atc()</a></code> internally. The old <code>atc_property</code> has been renamed <code><a href="../reference/atc_online.html">atc_online_property()</a></code>. This is done for two reasons: firstly, not all ATC codes are of antibiotics (ab) but can also be of antivirals or antifungals. Secondly, the input must have class <code>atc</code> or must be coerable to this class. Properties of these classes should start with the same class name, analogous to <code><a href="../reference/as.mo.html">as.mo()</a></code> and e.g. <code>mo_genus</code>.</li>
|
||||
These functions use <code>as.atc()</code> internally. The old <code>atc_property</code> has been renamed <code><a href="../reference/atc_online.html">atc_online_property()</a></code>. This is done for two reasons: firstly, not all ATC codes are of antibiotics (ab) but can also be of antivirals or antifungals. Secondly, the input must have class <code>atc</code> or must be coerable to this class. Properties of these classes should start with the same class name, analogous to <code><a href="../reference/as.mo.html">as.mo()</a></code> and e.g. <code>mo_genus</code>.</li>
|
||||
<li>New functions <code><a href="../reference/mo_source.html">set_mo_source()</a></code> and <code><a href="../reference/mo_source.html">get_mo_source()</a></code> to use your own predefined MO codes as input for <code><a href="../reference/as.mo.html">as.mo()</a></code> and consequently all <code>mo_*</code> functions</li>
|
||||
<li>Support for the upcoming <a href="https://dplyr.tidyverse.org"><code>dplyr</code></a> version 0.8.0</li>
|
||||
<li>New function <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> to find an antibiotic column in a table</li>
|
||||
@ -729,7 +733,7 @@ These functions use <code><a href="../reference/AMR-deprecated.html">as.atc()</a
|
||||
<li>Removed columns <code>atc_group1_nl</code> and <code>atc_group2_nl</code> from the <code>antibiotics</code> data set</li>
|
||||
<li>Functions <code>atc_ddd()</code> and <code>atc_groups()</code> have been renamed <code><a href="../reference/atc_online.html">atc_online_ddd()</a></code> and <code><a href="../reference/atc_online.html">atc_online_groups()</a></code>. The old functions are deprecated and will be removed in a future version.</li>
|
||||
<li>Function <code>guess_mo()</code> is now deprecated in favour of <code><a href="../reference/as.mo.html">as.mo()</a></code> and will be removed in future versions</li>
|
||||
<li>Function <code>guess_atc()</code> is now deprecated in favour of <code><a href="../reference/AMR-deprecated.html">as.atc()</a></code> and will be removed in future versions</li>
|
||||
<li>Function <code>guess_atc()</code> is now deprecated in favour of <code>as.atc()</code> and will be removed in future versions</li>
|
||||
<li>Improvements for <code><a href="../reference/as.mo.html">as.mo()</a></code>:
|
||||
<ul>
|
||||
<li>
|
||||
@ -900,7 +904,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
|
||||
</li>
|
||||
<li>Added parameter <code>combine_IR</code> (TRUE/FALSE) to functions <code>portion_df</code> and <code>count_df</code>, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)</li>
|
||||
<li>Fix for <code>portion_*(..., as_percent = TRUE)</code> when minimal number of isolates would not be met</li>
|
||||
<li>Added parameter <code>also_single_tested</code> for <code>portion_*</code> and <code>count_*</code> functions to also include cases where not all antibiotics were tested but at least one of the tested antibiotics includes the target antimicribial interpretation, see <code><a href="../reference/portion.html">?portion</a></code>
|
||||
<li>Added parameter <code>also_single_tested</code> for <code>portion_*</code> and <code>count_*</code> functions to also include cases where not all antibiotics were tested but at least one of the tested antibiotics includes the target antimicribial interpretation, see <code><a href="../reference/proportion.html">?portion</a></code>
|
||||
</li>
|
||||
<li>Using <code>portion_*</code> functions now throws a warning when total available isolate is below parameter <code>minimum</code>
|
||||
</li>
|
||||
@ -1078,9 +1082,9 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
|
||||
<a class="sourceLine" id="cb28-2" data-line-number="2"><span class="co"># which is the same as:</span></a>
|
||||
<a class="sourceLine" id="cb28-3" data-line-number="3">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/count.html">count_IR</a></span>(amox, cipr)</a>
|
||||
<a class="sourceLine" id="cb28-4" data-line-number="4"></a>
|
||||
<a class="sourceLine" id="cb28-5" data-line-number="5">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl)</a>
|
||||
<a class="sourceLine" id="cb28-6" data-line-number="6">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent)</a>
|
||||
<a class="sourceLine" id="cb28-7" data-line-number="7">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_S</a></span>(amcl, gent, pita)</a></code></pre></div>
|
||||
<a class="sourceLine" id="cb28-5" data-line-number="5">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/AMR-deprecated.html">portion_S</a></span>(amcl)</a>
|
||||
<a class="sourceLine" id="cb28-6" data-line-number="6">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/AMR-deprecated.html">portion_S</a></span>(amcl, gent)</a>
|
||||
<a class="sourceLine" id="cb28-7" data-line-number="7">septic_patients <span class="op">%>%</span><span class="st"> </span><span class="kw"><a href="../reference/AMR-deprecated.html">portion_S</a></span>(amcl, gent, pita)</a></code></pre></div>
|
||||
</li>
|
||||
<li>Edited <code>ggplot_rsi</code> and <code>geom_rsi</code> so they can cope with <code>count_df</code>. The new <code>fun</code> parameter has value <code>portion_df</code> at default, but can be set to <code>count_df</code>.</li>
|
||||
<li>Fix for <code>ggplot_rsi</code> when the <code>ggplot2</code> package was not loaded</li>
|
||||
@ -1333,7 +1337,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
|
||||
<div id="tocnav">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#amr-0-8-0-9026">0.8.0.9026</a></li>
|
||||
<li><a href="#amr-0-8-0-9027">0.8.0.9027</a></li>
|
||||
<li><a href="#amr-0-8-0">0.8.0</a></li>
|
||||
<li><a href="#amr-0-7-1">0.7.1</a></li>
|
||||
<li><a href="#amr-0-7-0">0.7.0</a></li>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -237,9 +237,17 @@
|
||||
<p>These functions are so-called '<a href='https://rdrr.io/r/base/Deprecated.html'>Deprecated</a>'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).</p>
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>as.atc</span>(<span class='no'>x</span>)
|
||||
<pre class="usage"><span class='fu'>p.symbol</span>(<span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>p.symbol</span>(<span class='no'>...</span>)</pre>
|
||||
<span class='fu'>portion_R</span>(<span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>portion_IR</span>(<span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>portion_I</span>(<span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>portion_SI</span>(<span class='no'>...</span>)
|
||||
|
||||
<span class='fu'>portion_S</span>(<span class='no'>...</span>)</pre>
|
||||
|
||||
|
||||
<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>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -244,27 +244,19 @@
|
||||
<p><code>AMR</code> is a free and open-source R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial properties by using evidence-based methods. It supports any table format, including WHONET/EARS-Net data.</p>
|
||||
<p>We created this package for both academic research and routine analysis at the Faculty of Medical Sciences of the University of Groningen and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is actively maintained and free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation.</p>
|
||||
<p>This package can be used for:</p><ul>
|
||||
<li><p>Reference for microorganisms, since it contains all microbial (sub)species from the Catalogue of Life</p></li>
|
||||
<li><p>Reference for the taxonomy of microorganisms, since the package contains all microbial (sub)species from the Catalogue of Life</p></li>
|
||||
<li><p>Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines</p></li>
|
||||
<li><p>Determining first isolates to be used for AMR analysis</p></li>
|
||||
<li><p>Calculating antimicrobial resistance</p></li>
|
||||
<li><p>Determining multi-drug resistance (MDR) / multi-drug resistant organisms (MDRO)</p></li>
|
||||
<li><p>Calculating empirical susceptibility of both mono therapy and combination therapy</p></li>
|
||||
<li><p>Calculating (empirical) susceptibility of both mono therapy and combination therapies</p></li>
|
||||
<li><p>Predicting future antimicrobial resistance using regression models</p></li>
|
||||
<li><p>Getting properties for any microorganism (like Gram stain, species, genus or family)</p></li>
|
||||
<li><p>Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)</p></li>
|
||||
<li><p>Getting properties for any antibiotic (like name, EARS-Net code, ATC code, PubChem code, defined daily dose or trade name)</p></li>
|
||||
<li><p>Plotting antimicrobial resistance</p></li>
|
||||
<li><p>Determining first isolates to be used for AMR analysis</p></li>
|
||||
<li><p>Applying EUCAST expert rules</p></li>
|
||||
<li><p>Descriptive statistics: frequency tables, kurtosis and skewness</p></li>
|
||||
</ul>
|
||||
|
||||
<h2 class="hasAnchor" id="authors"><a class="anchor" href="#authors"></a>Authors</h2>
|
||||
|
||||
|
||||
|
||||
<p>Matthijs S. Berends[1,2] Christian F. Luz[1], Erwin E.A. Hassing[2], Corinna Glasner[1], Alex W. Friedrich[1], Bhanu N.M. Sinha[1] <br /></p>
|
||||
<p>[1] Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands - <a href='https://www.rug.nl'>https://www.rug.nl</a> <a href='https://www.umcg.nl'>https://www.umcg.nl</a> <br />
|
||||
[2] Certe Medical Diagnostics & Advice, Groningen, the Netherlands - <a href='https://www.certe.nl'>https://www.certe.nl</a></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>
|
||||
|
||||
|
||||
@ -289,7 +281,6 @@ Post Office Box 30001 <br />
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#details">Details</a></li>
|
||||
<li><a href="#authors">Authors</a></li>
|
||||
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
|
||||
<li><a href="#contact-us">Contact us</a></li>
|
||||
</ul>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -306,7 +306,7 @@
|
||||
</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>This AMR package honours this new insight. Use <code><a href='portion.html'>portion_SI</a></code> to determine antimicrobial susceptibility and <code><a href='count.html'>count_SI</a></code> to count susceptible isolates.</p>
|
||||
<p>This AMR package honours this new insight. Use <code><a href='proportion.html'>susceptibility</a></code> (equal to <code><a href='proportion.html'>proportion_SI</a></code>) to determine antimicrobial susceptibility and <code><a href='count.html'>count_susceptible</a></code> (equal to <code><a href='count.html'>count_SI</a></code>) to count susceptible isolates.</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>
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -51,7 +51,7 @@
|
||||
<script src="../extra.js"></script>
|
||||
|
||||
<meta property="og:title" content="Check availability of columns — availability" />
|
||||
<meta property="og:description" content="Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. portion_R." />
|
||||
<meta property="og:description" content="Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. resistance." />
|
||||
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -234,7 +234,7 @@
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
<p>Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. <code><a href='portion.html'>portion_R</a></code>.</p>
|
||||
<p>Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. <code><a href='proportion.html'>resistance</a></code>.</p>
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>availability</span>(<span class='no'>tbl</span>, <span class='kw'>width</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)</pre>
|
||||
@ -257,7 +257,7 @@
|
||||
<p><code>data.frame</code> with column names of <code>tbl</code> as row names</p>
|
||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||
|
||||
<p>The function returns a <code>data.frame</code> with columns <code>"resistant"</code> and <code>"visual_resistance"</code>. The values in that columns are calculated with <code><a href='portion.html'>portion_R</a></code>.</p>
|
||||
<p>The function returns a <code>data.frame</code> with columns <code>"resistant"</code> and <code>"visual_resistance"</code>. The values in that columns are calculated with <code><a href='proportion.html'>resistance</a></code>.</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>
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
|
||||
<meta property="og:title" content="Count isolates — count" />
|
||||
<meta property="og:description" content="These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in dplyrs summarise and support grouped variables, see Examples.
|
||||
count_R and count_IR can be used to count resistant isolates, count_S and count_SI can be used to count susceptible isolates." />
|
||||
count_resistant should be used to count resistant isolates, count_susceptible should be used to count susceptible isolates." />
|
||||
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
@ -86,7 +86,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,10 +236,14 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
|
||||
<div class="ref-description">
|
||||
<p>These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in <code>dplyr</code>s <code><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></code> and support grouped variables, see <em>Examples</em>.</p>
|
||||
<p><code>count_R</code> and <code>count_IR</code> can be used to count resistant isolates, <code>count_S</code> and <code>count_SI</code> can be used to count susceptible isolates.<br /></p>
|
||||
<p><code>count_resistant</code> should be used to count resistant isolates, <code>count_susceptible</code> should be used to count susceptible isolates.<br /></p>
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>count_R</span>(<span class='no'>...</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
<pre class="usage"><span class='fu'>count_resistant</span>(<span class='no'>...</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>count_susceptible</span>(<span class='no'>...</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>count_R</span>(<span class='no'>...</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>count_IR</span>(<span class='no'>...</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
@ -289,18 +293,15 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
|
||||
|
||||
<p>Wickham H. <strong>Tidy Data.</strong> The Journal of Statistical Software, vol. 59, 2014. <a href='http://vita.had.co.nz/papers/tidy-data.html'>http://vita.had.co.nz/papers/tidy-data.html</a></p>
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>Integer</p>
|
||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||
|
||||
<p>These functions are meant to count isolates. Use the <code><a href='portion.html'>portion</a>_*</code> functions to calculate microbial resistance.</p>
|
||||
<p>The function <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>The function <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 S, I and R. 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>
|
||||
<p>The function <code>rsi_df</code> works exactly like <code>count_df</code>, but adds the percentage of S, I and R.</p>
|
||||
<p>These functions are meant to count isolates. Use the <code><a href='proportion.html'>resistance</a></code>/<code><a href='proportion.html'>susceptibility</a></code> functions to calculate microbial resistance/susceptibility.</p>
|
||||
<p>The function <code>count_resistant</code> is equal to the function <code>count_R</code>. The function <code>count_susceptible</code> is equal to the function <code>count_SI</code>.</p>
|
||||
<p>The function <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_susceptible(...) + count_resistant(...)</code>.</p>
|
||||
<p>The function <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 number of S's, I's and R's. The function <code>rsi_df</code> works exactly like <code>count_df</code>, but adds the percentage of S, I and R.</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>
|
||||
|
||||
|
||||
@ -313,12 +314,12 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
</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>This AMR package honours this new insight. Use <code><a href='portion.html'>portion_SI</a></code> to determine antimicrobial susceptibility and <code>count_SI</code> to count susceptible isolates.</p>
|
||||
<p>This AMR package honours this new insight. Use <code><a href='proportion.html'>susceptibility</a></code> (equal to <code><a href='proportion.html'>proportion_SI</a></code>) to determine antimicrobial susceptibility and <code>count_susceptible</code> (equal to <code>count_SI</code>) to count susceptible isolates.</p>
|
||||
<h2 class="hasAnchor" id="combination-therapy"><a class="anchor" href="#combination-therapy"></a>Combination therapy</h2>
|
||||
|
||||
|
||||
|
||||
<p>When using more than one variable for <code>...</code> (= combination therapy)), use <code>only_all_tested</code> to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how <code>portion_SI</code> works to calculate the %SI:</p>
|
||||
<p>When using more than one variable for <code>...</code> (= combination therapy)), use <code>only_all_tested</code> to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how <code>susceptibility</code> works to calculate the %SI:</p>
|
||||
<pre>
|
||||
--------------------------------------------------------------------
|
||||
only_all_tested = FALSE only_all_tested = TRUE
|
||||
@ -339,11 +340,11 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
</pre>
|
||||
|
||||
<p>Please note that, in combination therapies, for <code>only_all_tested = TRUE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
count_S() + count_I() + count_R() = count_all()
|
||||
proportion_S() + proportion_I() + proportion_R() = 1
|
||||
</pre><p>and that, in combination therapies, for <code>only_all_tested = FALSE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
proportion_S() + proportion_I() + proportion_R() >= 1
|
||||
</pre>
|
||||
|
||||
<p>Using <code>only_all_tested</code> has no impact when only using one antibiotic as input.</p>
|
||||
@ -354,29 +355,33 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
|
||||
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
|
||||
|
||||
<div class='dont-index'><p><code><a href='portion.html'>portion</a>_*</code> to calculate microbial resistance and susceptibility.</p></div>
|
||||
<div class='dont-index'><p><code><a href='proportion.html'>proportion</a>_*</code> to calculate microbial resistance and susceptibility.</p></div>
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><span class='co'># example_isolates is a data set available in the AMR package.</span>
|
||||
?<span class='no'>example_isolates</span>
|
||||
|
||||
<span class='co'># Count resistant isolates</span>
|
||||
<span class='fu'>count_R</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>count_IR</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>count_resistant</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) <span class='co'># counts "R"</span>
|
||||
<span class='fu'>count_susceptible</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) <span class='co'># counts "S" and "I"</span>
|
||||
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) <span class='co'># counts "S", "I" and "R"</span>
|
||||
|
||||
<span class='co'># Or susceptible isolates</span>
|
||||
<span class='co'># be more specific</span>
|
||||
<span class='fu'>count_S</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>count_I</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>count_IR</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>count_R</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
|
||||
<span class='co'># Count all available isolates</span>
|
||||
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>n_rsi</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
|
||||
<span class='co'># Since n_rsi counts available isolates, you can</span>
|
||||
<span class='co'># calculate back to count e.g. non-susceptible isolates.</span>
|
||||
<span class='co'># This results in the same:</span>
|
||||
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'><a href='portion.html'>portion_SI</a></span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) * <span class='fu'>n_rsi</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='co'># n_rsi() is an alias of count_all().</span>
|
||||
<span class='co'># Since it counts all available isolates, you can</span>
|
||||
<span class='co'># calculate back to count e.g. susceptible isolates.</span>
|
||||
<span class='co'># These results are the same:</span>
|
||||
<span class='fu'>count_susceptible</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'><a href='proportion.html'>susceptibility</a></span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) * <span class='fu'>n_rsi</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
@ -390,19 +395,16 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
|
||||
<span class='co'># Count co-resistance between amoxicillin/clav acid and gentamicin,</span>
|
||||
<span class='co'># so we can see that combination therapy does a lot more than mono therapy.</span>
|
||||
<span class='co'># Please mind that `portion_SI` calculates percentages right away instead.</span>
|
||||
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMC</span>) <span class='co'># 1433</span>
|
||||
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>AMC</span>) <span class='co'># 1879</span>
|
||||
<span class='co'># Please mind that `susceptibility()` calculates percentages right away instead.</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>count_susceptible</span>(<span class='no'>AMC</span>) <span class='co'># 1433</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>count_all</span>(<span class='no'>AMC</span>) <span class='co'># 1879</span>
|
||||
|
||||
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>GEN</span>) <span class='co'># 1399</span>
|
||||
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>GEN</span>) <span class='co'># 1855</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>count_susceptible</span>(<span class='no'>GEN</span>) <span class='co'># 1399</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>count_all</span>(<span class='no'>GEN</span>) <span class='co'># 1855</span>
|
||||
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/with.html'>with</a></span>(<span class='no'>example_isolates</span>,
|
||||
<span class='fu'>count_SI</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>)) <span class='co'># 1764</span>
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/with.html'>with</a></span>(<span class='no'>example_isolates</span>,
|
||||
<span class='fu'>n_rsi</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>)) <span class='co'># 1936</span>
|
||||
|
||||
<span class='co'># Get portions S/I/R immediately of all rsi columns</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>count_susceptible</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># 1764</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>count_all</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># 1936</span>
|
||||
<span class='co'># Get number of S+I vs. R immediately of selected columns</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
@ -417,7 +419,6 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
<li><a href="#source">Source</a></li>
|
||||
<li><a href="#value">Value</a></li>
|
||||
<li><a href="#details">Details</a></li>
|
||||
<li><a href="#interpretation-of-s-i-and-r">Interpretation of S, I and R</a></li>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -395,13 +395,13 @@ To conduct an analysis of antimicrobial resistance, you should only include the
|
||||
<span class='no'>A</span> <span class='kw'><-</span> <span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>count</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>GEN</span>), <span class='co'># gentamicin availability</span>
|
||||
<span class='kw'>resistance</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>GEN</span>)) <span class='co'># gentamicin resistance</span>
|
||||
<span class='kw'>resistance</span> <span class='kw'>=</span> <span class='fu'><a href='AMR-deprecated.html'>portion_IR</a></span>(<span class='no'>GEN</span>)) <span class='co'># gentamicin resistance</span>
|
||||
|
||||
<span class='no'>B</span> <span class='kw'><-</span> <span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'>filter_first_weighted_isolate</span>() <span class='kw'>%>%</span> <span class='co'># the 1st isolate filter</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>count</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>GEN</span>), <span class='co'># gentamicin availability</span>
|
||||
<span class='kw'>resistance</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>GEN</span>)) <span class='co'># gentamicin resistance</span>
|
||||
<span class='kw'>resistance</span> <span class='kw'>=</span> <span class='fu'><a href='AMR-deprecated.html'>portion_IR</a></span>(<span class='no'>GEN</span>)) <span class='co'># gentamicin resistance</span>
|
||||
|
||||
<span class='co'># Have a look at A and B.</span>
|
||||
<span class='co'># B is more reliable because every isolate is only counted once.</span>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -274,7 +274,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th>position</th>
|
||||
<td><p>position adjustment of bars, either <code>"fill"</code> (default when <code>fun</code> is <code><a href='count.html'>count_df</a></code>), <code>"stack"</code> (default when <code>fun</code> is <code><a href='portion.html'>portion_df</a></code>) or <code>"dodge"</code></p></td>
|
||||
<td><p>position adjustment of bars, either <code>"fill"</code>, <code>"stack"</code> or <code>"dodge"</code></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>x</th>
|
||||
@ -362,7 +362,7 @@
|
||||
|
||||
<p>At default, the names of antibiotics will be shown on the plots using <code><a href='ab_property.html'>ab_name</a></code>. This can be set with the <code>translate_ab</code> parameter. See <code><a href='count.html'>count_df</a></code>.</p>
|
||||
<p><strong>The functions</strong><br />
|
||||
<code>geom_rsi</code> will take any variable from the data that has an <code>rsi</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) using <code><a href='portion.html'>rsi_df</a></code> and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.</p>
|
||||
<code>geom_rsi</code> will take any variable from the data that has an <code>rsi</code> class (created with <code><a href='as.rsi.html'>as.rsi</a></code>) using <code><a href='proportion.html'>rsi_df</a></code> and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.</p>
|
||||
<p><code>facet_rsi</code> creates 2d plots (at default based on S/I/R) using <code><a href='https://ggplot2.tidyverse.org/reference/facet_wrap.html'>facet_wrap</a></code>.</p>
|
||||
<p><code>scale_y_percent</code> transforms the y axis to a 0 to 100% range using <code>scale_continuous</code>.</p>
|
||||
<p><code>scale_rsi_colours</code> sets colours to the bars: pastel blue for S, pastel turquoise for I and pastel red for R, using <code>scale_brewer</code>.</p>
|
||||
@ -397,7 +397,7 @@
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span>()
|
||||
|
||||
<span class='co'># get only portions and no counts:</span>
|
||||
<span class='co'># get only proportions and no counts:</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'>ggplot_rsi</span>(<span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -84,7 +84,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9026</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -428,15 +428,15 @@
|
||||
</tr><tr>
|
||||
|
||||
<td>
|
||||
<p><code><a href="count.html">count_R()</a></code> <code><a href="count.html">count_IR()</a></code> <code><a href="count.html">count_I()</a></code> <code><a href="count.html">count_SI()</a></code> <code><a href="count.html">count_S()</a></code> <code><a href="count.html">count_all()</a></code> <code><a href="count.html">n_rsi()</a></code> <code><a href="count.html">count_df()</a></code> </p>
|
||||
<p><code><a href="count.html">count_resistant()</a></code> <code><a href="count.html">count_susceptible()</a></code> <code><a href="count.html">count_R()</a></code> <code><a href="count.html">count_IR()</a></code> <code><a href="count.html">count_I()</a></code> <code><a href="count.html">count_SI()</a></code> <code><a href="count.html">count_S()</a></code> <code><a href="count.html">count_all()</a></code> <code><a href="count.html">n_rsi()</a></code> <code><a href="count.html">count_df()</a></code> </p>
|
||||
</td>
|
||||
<td><p>Count isolates</p></td>
|
||||
</tr><tr>
|
||||
|
||||
<td>
|
||||
<p><code><a href="portion.html">portion_R()</a></code> <code><a href="portion.html">portion_IR()</a></code> <code><a href="portion.html">portion_I()</a></code> <code><a href="portion.html">portion_SI()</a></code> <code><a href="portion.html">portion_S()</a></code> <code><a href="portion.html">portion_df()</a></code> <code><a href="portion.html">rsi_df()</a></code> </p>
|
||||
<p><code><a href="proportion.html">resistance()</a></code> <code><a href="proportion.html">susceptibility()</a></code> <code><a href="proportion.html">proportion_R()</a></code> <code><a href="proportion.html">proportion_IR()</a></code> <code><a href="proportion.html">proportion_I()</a></code> <code><a href="proportion.html">proportion_SI()</a></code> <code><a href="proportion.html">proportion_S()</a></code> <code><a href="proportion.html">proportion_df()</a></code> <code><a href="proportion.html">rsi_df()</a></code> </p>
|
||||
</td>
|
||||
<td><p>Calculate resistance of isolates</p></td>
|
||||
<td><p>Calculate microbial resistance</p></td>
|
||||
</tr><tr>
|
||||
|
||||
<td>
|
||||
@ -562,7 +562,7 @@
|
||||
<tr>
|
||||
|
||||
<td>
|
||||
<p><code><a href="AMR-deprecated.html">as.atc()</a></code> <code><a href="AMR-deprecated.html">p.symbol()</a></code> </p>
|
||||
<p><code><a href="AMR-deprecated.html">p.symbol()</a></code> <code><a href="AMR-deprecated.html">portion_R()</a></code> <code><a href="AMR-deprecated.html">portion_IR()</a></code> <code><a href="AMR-deprecated.html">portion_I()</a></code> <code><a href="AMR-deprecated.html">portion_SI()</a></code> <code><a href="AMR-deprecated.html">portion_S()</a></code> </p>
|
||||
</td>
|
||||
<td><p>Deprecated functions</p></td>
|
||||
</tr>
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9021</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -411,7 +411,7 @@
|
||||
</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>This AMR package honours this new insight. Use <code><a href='portion.html'>portion_SI</a></code> to determine antimicrobial susceptibility and <code><a href='count.html'>count_SI</a></code> to count susceptible isolates.</p>
|
||||
<p>This AMR package honours this new insight. Use <code><a href='proportion.html'>susceptibility</a></code> (equal to <code><a href='proportion.html'>proportion_SI</a></code>) to determine antimicrobial susceptibility and <code><a href='count.html'>count_susceptible</a></code> (equal to <code><a href='count.html'>count_SI</a></code>) to count susceptible isolates.</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>
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9008</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -86,7 +86,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
514
docs/reference/proportion.html
Normal file
@ -0,0 +1,514 @@
|
||||
<!-- Generated by pkgdown: do not edit by hand -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Calculate microbial resistance — proportion • AMR (for R)</title>
|
||||
|
||||
<!-- favicons -->
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
|
||||
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
|
||||
|
||||
<!-- jquery -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
|
||||
<!-- Bootstrap -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- Font Awesome icons -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous" />
|
||||
|
||||
<!-- clipboard.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- headroom.js -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
|
||||
|
||||
<!-- pkgdown -->
|
||||
<link href="../pkgdown.css" rel="stylesheet">
|
||||
<script src="../pkgdown.js"></script>
|
||||
|
||||
|
||||
<!-- docsearch -->
|
||||
<script src="../docsearch.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.css" integrity="sha256-QOSRU/ra9ActyXkIBbiIB144aDBdtvXBcNc3OTNuX/Q=" crossorigin="anonymous" />
|
||||
<link href="../docsearch.css" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity="sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin="anonymous"></script>
|
||||
|
||||
|
||||
<link href="../extra.css" rel="stylesheet">
|
||||
<script src="../extra.js"></script>
|
||||
|
||||
<meta property="og:title" content="Calculate microbial resistance — proportion" />
|
||||
<meta property="og:description" content="These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in dplyrs summarise and support grouped variables, see Examples.
|
||||
resistance should be used to calculate resistance, susceptibility should be used to calculate susceptibility." />
|
||||
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- mathjax -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
|
||||
|
||||
<!--[if lt IE 9]>
|
||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
|
||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container template-reference-topic">
|
||||
<header>
|
||||
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<a href="../index.html">
|
||||
<span class="fa fa-home"></span>
|
||||
|
||||
Home
|
||||
</a>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
|
||||
<span class="fa fa-question-circle"></span>
|
||||
|
||||
How to
|
||||
|
||||
<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" role="menu">
|
||||
<li>
|
||||
<a href="../articles/AMR.html">
|
||||
<span class="fa fa-directions"></span>
|
||||
|
||||
Conduct AMR analysis
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/resistance_predict.html">
|
||||
<span class="fa fa-dice"></span>
|
||||
|
||||
Predict antimicrobial resistance
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/MDR.html">
|
||||
<span class="fa fa-skull-crossbones"></span>
|
||||
|
||||
Determine multi-drug resistance (MDR)
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/WHONET.html">
|
||||
<span class="fa fa-globe-americas"></span>
|
||||
|
||||
Work with WHONET data
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/SPSS.html">
|
||||
<span class="fa fa-file-upload"></span>
|
||||
|
||||
Import data from SPSS/SAS/Stata
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/EUCAST.html">
|
||||
<span class="fa fa-exchange-alt"></span>
|
||||
|
||||
Apply EUCAST rules
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/mo_property.html">
|
||||
<span class="fa fa-bug"></span>
|
||||
|
||||
Get properties of a microorganism
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/ab_property.html">
|
||||
<span class="fa fa-capsules"></span>
|
||||
|
||||
Get properties of an antibiotic
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../articles/benchmarks.html">
|
||||
<span class="fa fa-shipping-fast"></span>
|
||||
|
||||
Other: benchmarks
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../reference/">
|
||||
<span class="fa fa-book-open"></span>
|
||||
|
||||
Manual
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../authors.html">
|
||||
<span class="fa fa-users"></span>
|
||||
|
||||
Authors
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../news/">
|
||||
<span class="far fa far fa-newspaper"></span>
|
||||
|
||||
Changelog
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://gitlab.com/msberends/AMR">
|
||||
<span class="fab fa fab fa-gitlab"></span>
|
||||
|
||||
Source Code
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../LICENSE-text.html">
|
||||
<span class="fa fa-book"></span>
|
||||
|
||||
Licence
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<form class="navbar-form navbar-right hidden-xs hidden-sm" role="search">
|
||||
<div class="form-group">
|
||||
<input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div><!--/.nav-collapse -->
|
||||
</div><!--/.container -->
|
||||
</div><!--/.navbar -->
|
||||
|
||||
|
||||
|
||||
</header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 contents">
|
||||
<div class="page-header">
|
||||
<h1>Calculate microbial resistance</h1>
|
||||
|
||||
<div class="hidden name"><code>proportion.Rd</code></div>
|
||||
</div>
|
||||
|
||||
<div class="ref-description">
|
||||
<p>These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in <code>dplyr</code>s <code><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></code> and support grouped variables, see <em>Examples</em>.</p>
|
||||
<p><code>resistance</code> should be used to calculate resistance, <code>susceptibility</code> should be used to calculate susceptibility.<br /></p>
|
||||
</div>
|
||||
|
||||
<pre class="usage"><span class='fu'>resistance</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>susceptibility</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>proportion_R</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>proportion_IR</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>proportion_I</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>proportion_SI</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>proportion_S</span>(<span class='no'>...</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'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='fu'>proportion_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_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='fu'>rsi_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_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">
|
||||
<colgroup><col class="name" /><col class="desc" /></colgroup>
|
||||
<tr>
|
||||
<th>...</th>
|
||||
<td><p>one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with <code><a href='as.rsi.html'>as.rsi</a></code> 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.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>minimum</th>
|
||||
<td><p>the minimum allowed number of available (tested) isolates. Any isolate count lower than <code>minimum</code> will return <code>NA</code> with a warning. The default number of <code>30</code> isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>as_percent</th>
|
||||
<td><p>a logical to indicate whether the output must be returned as a hundred fold with % sign (a character). A value of <code>0.123456</code> will then be returned as <code>"12.3%"</code>.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>only_all_tested</th>
|
||||
<td><p>(for combination therapies, i.e. using more than one variable for <code>...</code>) a logical to indicate that isolates must be tested for all antibiotics, see section <em>Combination therapy</em> below</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>data</th>
|
||||
<td><p>a <code>data.frame</code> containing columns with class <code>rsi</code> (see <code><a href='as.rsi.html'>as.rsi</a></code>)</p></td>
|
||||
</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 to, using <code><a href='ab_property.html'>ab_property</a></code></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>language</th>
|
||||
<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://rdrr.io/r/base/options.html'>getOption</a>("AMR_locale")</code>. Use <code>language = NULL</code> or <code>language = ""</code> to prevent translation.</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>combine_SI</th>
|
||||
<td><p>a logical to indicate whether all values of S and I 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 section 'Interpretation of S, I and R' below. Default is <code>TRUE</code>.</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. I+R (susceptible vs. non-susceptible). This is outdated, see parameter <code>combine_SI</code>.</p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
|
||||
|
||||
<p><strong>M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition</strong>, 2014, <em>Clinical and Laboratory Standards Institute (CLSI)</em>. <a href='https://clsi.org/standards/products/microbiology/documents/m39/'>https://clsi.org/standards/products/microbiology/documents/m39/</a>.</p>
|
||||
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
|
||||
|
||||
<p>Double or, when <code>as_percent = TRUE</code>, a character.</p>
|
||||
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
|
||||
|
||||
<p>The function <code>resistance</code> is equal to the function <code>proportion_R</code>. The function <code>susceptibility</code> is equal to the function <code>proportion_SI</code>.</p>
|
||||
<p><strong>Remember that you should filter your table to let it contain only first isolates!</strong> This is needed to exclude duplicates and to reduce selection bias. Use <code><a href='first_isolate.html'>first_isolate</a></code> to determine them in your data set.</p>
|
||||
<p>These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the <code><a href='count.html'>count</a></code> functions to count isolates. The function <code>susceptibility()</code> is essentially equal to <code>count_susceptible() / count_all()</code>. <em>Low counts can infuence the outcome - the <code>proportion</code> functions may camouflage this, since they only return the proportion (albeit being dependent on the <code>minimum</code> parameter).</em></p>
|
||||
<p>The function <code>proportion_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 calculates the proportions R, I and S. The function <code>rsi_df</code> works exactly like <code>proportion_df</code>, but adds the number of isolates.</p>
|
||||
<h2 class="hasAnchor" id="combination-therapy"><a class="anchor" href="#combination-therapy"></a>Combination therapy</h2>
|
||||
|
||||
|
||||
|
||||
<p>When using more than one variable for <code>...</code> (= combination therapy)), use <code>only_all_tested</code> to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how <code>susceptibility</code> works to calculate the %SI:</p>
|
||||
<pre>
|
||||
--------------------------------------------------------------------
|
||||
only_all_tested = FALSE only_all_tested = TRUE
|
||||
----------------------- -----------------------
|
||||
Drug A Drug B include as include as include as include as
|
||||
numerator denominator numerator denominator
|
||||
-------- -------- ---------- ----------- ---------- -----------
|
||||
S or I S or I X X X X
|
||||
R S or I X X X X
|
||||
<NA> S or I X X - -
|
||||
S or I R X X X X
|
||||
R R - X - X
|
||||
<NA> R - - - -
|
||||
S or I <NA> X X - -
|
||||
R <NA> - - - -
|
||||
<NA> <NA> - - - -
|
||||
--------------------------------------------------------------------
|
||||
</pre>
|
||||
|
||||
<p>Please note that, in combination therapies, for <code>only_all_tested = TRUE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() = count_all()
|
||||
proportion_S() + proportion_I() + proportion_R() = 1
|
||||
</pre><p>and that, in combination therapies, for <code>only_all_tested = FALSE</code> applies that:</p><pre>
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
proportion_S() + proportion_I() + proportion_R() >= 1
|
||||
</pre>
|
||||
|
||||
<p>Using <code>only_all_tested</code> has no impact when only using one antibiotic as input.</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, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories S, I and R as shown below (<a href='http://www.eucast.org/newsiandr/'>http://www.eucast.org/newsiandr/</a>). 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>This AMR package honours this new insight. Use <code>susceptibility</code> (equal to <code>proportion_SI</code>) to determine antimicrobial susceptibility and <code><a href='count.html'>count_susceptible</a></code> (equal to <code><a href='count.html'>count_SI</a></code>) to count susceptible isolates.</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>
|
||||
|
||||
|
||||
|
||||
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
|
||||
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
|
||||
|
||||
<div class='dont-index'><p><code><a href='count.html'>count</a>_*</code> to count resistant and susceptible isolates.</p></div>
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><span class='co'># example_isolates is a data set available in the AMR package.</span>
|
||||
?<span class='no'>example_isolates</span>
|
||||
|
||||
<span class='fu'>resistance</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) <span class='co'># determines %R</span>
|
||||
<span class='fu'>susceptibility</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) <span class='co'># determines %S+I</span>
|
||||
|
||||
<span class='co'># be more specific</span>
|
||||
<span class='fu'>proportion_S</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>proportion_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>proportion_I</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>proportion_IR</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
<span class='fu'>proportion_R</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
|
||||
|
||||
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>r</span> <span class='kw'>=</span> <span class='fu'>resistance</span>(<span class='no'>CIP</span>),
|
||||
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>CIP</span>)) <span class='co'># n_rsi works like n_distinct in dplyr, see ?n_rsi</span>
|
||||
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>R</span> <span class='kw'>=</span> <span class='fu'>resistance</span>(<span class='no'>CIP</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>SI</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>CIP</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>n1</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>CIP</span>), <span class='co'># the actual total; sum of all three</span>
|
||||
<span class='kw'>n2</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>CIP</span>), <span class='co'># same - analogous to n_distinct</span>
|
||||
<span class='kw'>total</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/n.html'>n</a></span>()) <span class='co'># NOT the number of tested isolates!</span>
|
||||
|
||||
<span class='co'># Calculate co-resistance between amoxicillin/clav acid and gentamicin,</span>
|
||||
<span class='co'># so we can see that combination therapy does a lot more than mono therapy:</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>susceptibility</span>(<span class='no'>AMC</span>) <span class='co'># %SI = 76.3%</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>) <span class='co'># n = 1879</span>
|
||||
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>susceptibility</span>(<span class='no'>GEN</span>) <span class='co'># %SI = 75.4%</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>GEN</span>) <span class='co'># n = 1855</span>
|
||||
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'>susceptibility</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># %SI = 94.1%</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># n = 1939</span>
|
||||
|
||||
|
||||
<span class='co'># See Details on how `only_all_tested` works. Example:</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>numerator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_susceptible</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>),
|
||||
<span class='kw'>denominator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>),
|
||||
<span class='kw'>proportion</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>))
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>numerator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_susceptible</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>denominator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>proportion</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>))
|
||||
|
||||
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>cipro_p</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>CIP</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>cipro_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>CIP</span>),
|
||||
<span class='kw'>genta_p</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>GEN</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>genta_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>GEN</span>),
|
||||
<span class='kw'>combination_p</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>CIP</span>, <span class='no'>GEN</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
|
||||
<span class='kw'>combination_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>CIP</span>, <span class='no'>GEN</span>))
|
||||
|
||||
<span class='co'># Get proportions S/I/R immediately of all rsi columns</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'>proportion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
<span class='co'># It also supports grouping variables</span>
|
||||
<span class='no'>example_isolates</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'>proportion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
|
||||
|
||||
|
||||
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
|
||||
|
||||
<span class='co'># calculate current empiric combination therapy of Helicobacter gastritis:</span>
|
||||
<span class='no'>my_table</span> <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,
|
||||
<span class='no'>genus</span> <span class='kw'>==</span> <span class='st'>"Helicobacter"</span>) <span class='kw'>%>%</span>
|
||||
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'>susceptibility</span>(<span class='no'>AMX</span>, <span class='no'>MTR</span>), <span class='co'># amoxicillin with metronidazole</span>
|
||||
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMX</span>, <span class='no'>MTR</span>))
|
||||
}</pre>
|
||||
</div>
|
||||
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
|
||||
<h2>Contents</h2>
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<li><a href="#arguments">Arguments</a></li>
|
||||
<li><a href="#source">Source</a></li>
|
||||
<li><a href="#value">Value</a></li>
|
||||
<li><a href="#details">Details</a></li>
|
||||
<li><a href="#combination-therapy">Combination therapy</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>
|
||||
<li><a href="#examples">Examples</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<footer>
|
||||
<div class="copyright">
|
||||
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
|
||||
</div>
|
||||
|
||||
<div class="pkgdown">
|
||||
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p>
|
||||
</div>
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.js" integrity="sha256-GKvGqXDznoRYHCwKXGnuchvKSwmx9SRMrZOTh2g4Sb0=" crossorigin="anonymous"></script>
|
||||
<script>
|
||||
docsearch({
|
||||
|
||||
|
||||
apiKey: 'f737050abfd4d726c63938e18f8c496e',
|
||||
indexName: 'amr',
|
||||
inputSelector: 'input#search-input.form-control',
|
||||
transformData: function(hits) {
|
||||
return hits.map(function (hit) {
|
||||
hit.url = updateHitURL(hit);
|
||||
return hit;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -339,7 +339,7 @@
|
||||
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
|
||||
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
|
||||
|
||||
<div class='dont-index'><p>The <code><a href='portion.html'>portion</a></code> function to calculate resistance, <br /> <code><a href='https://rdrr.io/r/stats/lm.html'>lm</a></code> <code><a href='https://rdrr.io/r/stats/glm.html'>glm</a></code></p></div>
|
||||
<div class='dont-index'><p>The <code><a href='proportion.html'>portion</a></code> function to calculate resistance, <br /> <code><a href='https://rdrr.io/r/stats/lm.html'>lm</a></code> <code><a href='https://rdrr.io/r/stats/glm.html'>glm</a></code></p></div>
|
||||
|
||||
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
|
||||
<pre class="examples"><span class='no'>x</span> <span class='kw'><-</span> <span class='fu'>resistance_predict</span>(<span class='no'>example_isolates</span>, <span class='kw'>col_ab</span> <span class='kw'>=</span> <span class='st'>"AMX"</span>, <span class='kw'>year_min</span> <span class='kw'>=</span> <span class='fl'>2010</span>, <span class='kw'>model</span> <span class='kw'>=</span> <span class='st'>"binomial"</span>)
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -86,7 +86,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -85,7 +85,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.8.0.9027</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -118,7 +118,7 @@
|
||||
<loc>https://msberends.gitlab.io/AMR/reference/p_symbol.html</loc>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://msberends.gitlab.io/AMR/reference/portion.html</loc>
|
||||
<loc>https://msberends.gitlab.io/AMR/reference/proportion.html</loc>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://msberends.gitlab.io/AMR/reference/read.4D.html</loc>
|
||||
|
2
index.md
@ -143,7 +143,7 @@ The `AMR` package basically does four important things:
|
||||
|
||||
3. It **analyses the data** with convenient functions that use well-known methods.
|
||||
|
||||
* Calculate the resistance (and even co-resistance) of microbial isolates with the `portion_R()`, `portion_IR()`, `portion_I()`, `portion_SI()` and `portion_S()` functions. Similarly, the *number* of isolates can be determined with the `count_R()`, `count_IR()`, `count_I()`, `count_SI()` and `count_S()` functions. All these functions can be used with the `dplyr` package (e.g. in conjunction with `summarise()`)
|
||||
* Calculate the microbial susceptibility or resistance (and even co-resistance) with the `susceptibility()` and `resistance()` functions, or be even more specific with the `proportion_R()`, `proportion_IR()`, `proportion_I()`, `proportion_SI()` and `proportion_S()` functions. Similarly, the *number* of isolates can be determined with the `count_resistant()`, `count_susceptible()` and `count_all()` functions. All these functions can be used with the `dplyr` package (e.g. in conjunction with `summarise()`)
|
||||
* Plot AMR results with `geom_rsi()`, a function made for the `ggplot2` package
|
||||
* Predict antimicrobial resistance for the nextcoming years using logistic regression models with the `resistance_predict()` function
|
||||
|
||||
|
@ -2,13 +2,25 @@
|
||||
% Please edit documentation in R/deprecated.R
|
||||
\name{AMR-deprecated}
|
||||
\alias{AMR-deprecated}
|
||||
\alias{as.atc}
|
||||
\alias{p.symbol}
|
||||
\alias{portion_R}
|
||||
\alias{portion_IR}
|
||||
\alias{portion_I}
|
||||
\alias{portion_SI}
|
||||
\alias{portion_S}
|
||||
\title{Deprecated functions}
|
||||
\usage{
|
||||
as.atc(x)
|
||||
|
||||
p.symbol(...)
|
||||
|
||||
portion_R(...)
|
||||
|
||||
portion_IR(...)
|
||||
|
||||
portion_I(...)
|
||||
|
||||
portion_SI(...)
|
||||
|
||||
portion_S(...)
|
||||
}
|
||||
\description{
|
||||
These functions are so-called '\link{Deprecated}'. They will be removed in a future release. Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
|
||||
|
17
man/AMR.Rd
@ -13,28 +13,19 @@ We created this package for both academic research and routine analysis at the F
|
||||
|
||||
This package can be used for:
|
||||
\itemize{
|
||||
\item{Reference for microorganisms, since it contains all microbial (sub)species from the Catalogue of Life}
|
||||
\item{Reference for the taxonomy of microorganisms, since the package contains all microbial (sub)species from the Catalogue of Life}
|
||||
\item{Interpreting raw MIC and disk diffusion values, based on the latest CLSI or EUCAST guidelines}
|
||||
\item{Determining first isolates to be used for AMR analysis}
|
||||
\item{Calculating antimicrobial resistance}
|
||||
\item{Determining multi-drug resistance (MDR) / multi-drug resistant organisms (MDRO)}
|
||||
\item{Calculating empirical susceptibility of both mono therapy and combination therapy}
|
||||
\item{Calculating (empirical) susceptibility of both mono therapy and combination therapies}
|
||||
\item{Predicting future antimicrobial resistance using regression models}
|
||||
\item{Getting properties for any microorganism (like Gram stain, species, genus or family)}
|
||||
\item{Getting properties for any antibiotic (like name, ATC code, defined daily dose or trade name)}
|
||||
\item{Getting properties for any antibiotic (like name, EARS-Net code, ATC code, PubChem code, defined daily dose or trade name)}
|
||||
\item{Plotting antimicrobial resistance}
|
||||
\item{Determining first isolates to be used for AMR analysis}
|
||||
\item{Applying EUCAST expert rules}
|
||||
\item{Descriptive statistics: frequency tables, kurtosis and skewness}
|
||||
}
|
||||
}
|
||||
\section{Authors}{
|
||||
|
||||
Matthijs S. Berends[1,2] Christian F. Luz[1], Erwin E.A. Hassing[2], Corinna Glasner[1], Alex W. Friedrich[1], Bhanu N.M. Sinha[1] \cr
|
||||
|
||||
[1] Department of Medical Microbiology, University of Groningen, University Medical Center Groningen, Groningen, the Netherlands - \url{https://www.rug.nl} \url{https://www.umcg.nl} \cr
|
||||
[2] Certe Medical Diagnostics & Advice, Groningen, the Netherlands - \url{https://www.certe.nl}
|
||||
}
|
||||
|
||||
\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 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}.
|
||||
|
@ -63,7 +63,7 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
|
||||
|
||||
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.
|
||||
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
|
@ -15,10 +15,10 @@ availability(tbl, width = NULL)
|
||||
\code{data.frame} with column names of \code{tbl} as row names
|
||||
}
|
||||
\description{
|
||||
Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. \code{\link{portion_R}}.
|
||||
Easy check for availability of columns in a data set. This makes it easy to get an idea of which antimicrobial combination can be used for calculation with e.g. \code{\link{resistance}}.
|
||||
}
|
||||
\details{
|
||||
The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{portion_R}}.
|
||||
The function returns a \code{data.frame} with columns \code{"resistant"} and \code{"visual_resistance"}. The values in that columns are calculated with \code{\link{resistance}}.
|
||||
}
|
||||
\section{Read more on our website!}{
|
||||
|
||||
|
72
man/count.Rd
@ -2,6 +2,8 @@
|
||||
% Please edit documentation in R/count.R
|
||||
\name{count}
|
||||
\alias{count}
|
||||
\alias{count_resistant}
|
||||
\alias{count_susceptible}
|
||||
\alias{count_R}
|
||||
\alias{count_IR}
|
||||
\alias{count_I}
|
||||
@ -11,10 +13,11 @@
|
||||
\alias{n_rsi}
|
||||
\alias{count_df}
|
||||
\title{Count isolates}
|
||||
\source{
|
||||
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
}
|
||||
\usage{
|
||||
count_resistant(..., only_all_tested = FALSE)
|
||||
|
||||
count_susceptible(..., only_all_tested = FALSE)
|
||||
|
||||
count_R(..., only_all_tested = FALSE)
|
||||
|
||||
count_IR(..., only_all_tested = FALSE)
|
||||
@ -53,16 +56,16 @@ Integer
|
||||
\description{
|
||||
These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
|
||||
\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
|
||||
\code{count_resistant} should be used to count resistant isolates, \code{count_susceptible} should be used to count susceptible isolates.\cr
|
||||
}
|
||||
\details{
|
||||
These functions are meant to count isolates. Use the \code{\link{portion}_*} functions to calculate microbial resistance.
|
||||
These functions are meant to count isolates. Use the \code{\link{resistance}}/\code{\link{susceptibility}} functions to calculate microbial resistance/susceptibility.
|
||||
|
||||
The function \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(...)}.
|
||||
The function \code{count_resistant} is equal to the function \code{count_R}. The function \code{count_susceptible} is equal to the function \code{count_SI}.
|
||||
|
||||
The function \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 S, I and R. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}.
|
||||
The function \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_susceptible(...) + count_resistant(...)}.
|
||||
|
||||
The function \code{rsi_df} works exactly like \code{count_df}, but adds the percentage of S, I and R.
|
||||
The function \code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the number of S's, I's and R's. The function \code{rsi_df} works exactly like \code{count_df}, but adds the percentage of S, I and R.
|
||||
}
|
||||
\section{Interpretation of S, I and R}{
|
||||
|
||||
@ -76,12 +79,12 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
|
||||
|
||||
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.
|
||||
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
|
||||
}
|
||||
|
||||
\section{Combination therapy}{
|
||||
|
||||
When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
|
||||
When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{susceptibility} works to calculate the \%SI:
|
||||
|
||||
\preformatted{
|
||||
--------------------------------------------------------------------
|
||||
@ -104,13 +107,13 @@ When using more than one variable for \code{...} (= combination therapy)), use \
|
||||
|
||||
Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
count_S() + count_I() + count_R() = count_all()
|
||||
proportion_S() + proportion_I() + proportion_R() = 1
|
||||
}
|
||||
and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
proportion_S() + proportion_I() + proportion_R() >= 1
|
||||
}
|
||||
|
||||
Using \code{only_all_tested} has no impact when only using one antibiotic as input.
|
||||
@ -125,23 +128,27 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
# example_isolates is a data set available in the AMR package.
|
||||
?example_isolates
|
||||
|
||||
# Count resistant isolates
|
||||
count_R(example_isolates$AMX)
|
||||
count_IR(example_isolates$AMX)
|
||||
count_resistant(example_isolates$AMX) # counts "R"
|
||||
count_susceptible(example_isolates$AMX) # counts "S" and "I"
|
||||
count_all(example_isolates$AMX) # counts "S", "I" and "R"
|
||||
|
||||
# Or susceptible isolates
|
||||
# be more specific
|
||||
count_S(example_isolates$AMX)
|
||||
count_SI(example_isolates$AMX)
|
||||
count_I(example_isolates$AMX)
|
||||
count_IR(example_isolates$AMX)
|
||||
count_R(example_isolates$AMX)
|
||||
|
||||
# Count all available isolates
|
||||
count_all(example_isolates$AMX)
|
||||
n_rsi(example_isolates$AMX)
|
||||
|
||||
# Since n_rsi counts available isolates, you can
|
||||
# calculate back to count e.g. non-susceptible isolates.
|
||||
# This results in the same:
|
||||
count_SI(example_isolates$AMX)
|
||||
portion_SI(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
# n_rsi() is an alias of count_all().
|
||||
# Since it counts all available isolates, you can
|
||||
# calculate back to count e.g. susceptible isolates.
|
||||
# These results are the same:
|
||||
count_susceptible(example_isolates$AMX)
|
||||
susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
|
||||
|
||||
library(dplyr)
|
||||
example_isolates \%>\%
|
||||
@ -155,19 +162,16 @@ example_isolates \%>\%
|
||||
|
||||
# Count co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
# so we can see that combination therapy does a lot more than mono therapy.
|
||||
# Please mind that `portion_SI` calculates percentages right away instead.
|
||||
count_SI(example_isolates$AMC) # 1433
|
||||
count_all(example_isolates$AMC) # 1879
|
||||
# Please mind that `susceptibility()` calculates percentages right away instead.
|
||||
example_isolates \%>\% count_susceptible(AMC) # 1433
|
||||
example_isolates \%>\% count_all(AMC) # 1879
|
||||
|
||||
count_SI(example_isolates$GEN) # 1399
|
||||
count_all(example_isolates$GEN) # 1855
|
||||
example_isolates \%>\% count_susceptible(GEN) # 1399
|
||||
example_isolates \%>\% count_all(GEN) # 1855
|
||||
|
||||
with(example_isolates,
|
||||
count_SI(AMC, GEN)) # 1764
|
||||
with(example_isolates,
|
||||
n_rsi(AMC, GEN)) # 1936
|
||||
|
||||
# Get portions S/I/R immediately of all rsi columns
|
||||
example_isolates \%>\% count_susceptible(AMC, GEN) # 1764
|
||||
example_isolates \%>\% count_all(AMC, GEN) # 1936
|
||||
# Get number of S+I vs. R immediately of selected columns
|
||||
example_isolates \%>\%
|
||||
select(AMX, CIP) \%>\%
|
||||
count_df(translate = FALSE)
|
||||
@ -180,5 +184,5 @@ example_isolates \%>\%
|
||||
|
||||
}
|
||||
\seealso{
|
||||
\code{\link{portion}_*} to calculate microbial resistance and susceptibility.
|
||||
\code{\link{proportion}_*} to calculate microbial resistance and susceptibility.
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ labels_rsi_count(position = NULL, x = "antibiotic",
|
||||
\arguments{
|
||||
\item{data}{a \code{data.frame} with column(s) of class \code{"rsi"} (see \code{\link{as.rsi}})}
|
||||
|
||||
\item{position}{position adjustment of bars, either \code{"fill"} (default when \code{fun} is \code{\link{count_df}}), \code{"stack"} (default when \code{fun} is \code{\link{portion_df}}) or \code{"dodge"}}
|
||||
\item{position}{position adjustment of bars, either \code{"fill"}, \code{"stack"} or \code{"dodge"}}
|
||||
|
||||
\item{x}{variable to show on x axis, either \code{"antibiotic"} (default) or \code{"interpretation"} or a grouping variable}
|
||||
|
||||
@ -131,7 +131,7 @@ example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi()
|
||||
|
||||
# get only portions and no counts:
|
||||
# get only proportions and no counts:
|
||||
example_isolates \%>\%
|
||||
select(AMX, NIT, FOS, TMP, CIP) \%>\%
|
||||
ggplot_rsi(datalabels = FALSE)
|
||||
|
@ -175,7 +175,7 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
|
||||
|
||||
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.
|
||||
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
|
@ -1,37 +1,44 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/portion.R, R/rsi_df.R
|
||||
\name{portion}
|
||||
% Please edit documentation in R/proportion.R, R/rsi_df.R
|
||||
\name{proportion}
|
||||
\alias{proportion}
|
||||
\alias{resistance}
|
||||
\alias{portion}
|
||||
\alias{portion_R}
|
||||
\alias{portion_IR}
|
||||
\alias{portion_I}
|
||||
\alias{portion_SI}
|
||||
\alias{portion_S}
|
||||
\alias{portion_df}
|
||||
\alias{susceptibility}
|
||||
\alias{proportion_R}
|
||||
\alias{proportion_IR}
|
||||
\alias{proportion_I}
|
||||
\alias{proportion_SI}
|
||||
\alias{proportion_S}
|
||||
\alias{proportion_df}
|
||||
\alias{rsi_df}
|
||||
\title{Calculate resistance of isolates}
|
||||
\title{Calculate microbial resistance}
|
||||
\source{
|
||||
\strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
|
||||
|
||||
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
}
|
||||
\usage{
|
||||
portion_R(..., minimum = 30, as_percent = FALSE,
|
||||
resistance(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_IR(..., minimum = 30, as_percent = FALSE,
|
||||
susceptibility(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_I(..., minimum = 30, as_percent = FALSE,
|
||||
proportion_R(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_SI(..., minimum = 30, as_percent = FALSE,
|
||||
proportion_IR(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_S(..., minimum = 30, as_percent = FALSE,
|
||||
proportion_I(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_df(data, translate_ab = "name", language = get_locale(),
|
||||
proportion_SI(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
proportion_S(..., minimum = 30, as_percent = FALSE,
|
||||
only_all_tested = FALSE)
|
||||
|
||||
proportion_df(data, translate_ab = "name", language = get_locale(),
|
||||
minimum = 30, as_percent = FALSE, combine_SI = TRUE,
|
||||
combine_IR = FALSE)
|
||||
|
||||
@ -62,22 +69,22 @@ rsi_df(data, translate_ab = "name", language = get_locale(),
|
||||
Double or, when \code{as_percent = TRUE}, a character.
|
||||
}
|
||||
\description{
|
||||
These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
These functions can be used to calculate the (co-)resistance or susceptibility of microbial isolates (i.e. percentage of S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
|
||||
\code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr
|
||||
\code{resistance} should be used to calculate resistance, \code{susceptibility} should be used to calculate susceptibility.\cr
|
||||
}
|
||||
\details{
|
||||
The function \code{resistance} is equal to the function \code{proportion_R}. The function \code{susceptibility} is equal to the function \code{proportion_SI}.
|
||||
|
||||
\strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. 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. The function \code{portion_SI()} is essentially equal to \code{count_SI() / count_all()}. \emph{Low counts can infuence the outcome - the \code{portion} functions may camouflage this, since they only return the portion (albeit being dependent on the \code{minimum} parameter).}
|
||||
These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. The function \code{susceptibility()} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can infuence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (albeit being dependent on the \code{minimum} parameter).}
|
||||
|
||||
The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
|
||||
|
||||
The function \code{rsi_df} works exactly like \code{portion_df}, but adds the number of isolates.
|
||||
The function \code{proportion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the proportions R, I and S. The function \code{rsi_df} works exactly like \code{proportion_df}, but adds the number of isolates.
|
||||
}
|
||||
\section{Combination therapy}{
|
||||
|
||||
When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
|
||||
When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{susceptibility} works to calculate the \%SI:
|
||||
|
||||
\preformatted{
|
||||
--------------------------------------------------------------------
|
||||
@ -100,13 +107,13 @@ When using more than one variable for \code{...} (= combination therapy)), use \
|
||||
|
||||
Please note that, in combination therapies, for \code{only_all_tested = TRUE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
count_S() + count_I() + count_R() = count_all()
|
||||
proportion_S() + proportion_I() + proportion_R() = 1
|
||||
}
|
||||
and that, in combination therapies, for \code{only_all_tested = FALSE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
proportion_S() + proportion_I() + proportion_R() >= 1
|
||||
}
|
||||
|
||||
Using \code{only_all_tested} has no impact when only using one antibiotic as input.
|
||||
@ -124,7 +131,7 @@ In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
|
||||
|
||||
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.
|
||||
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
This AMR package honours this new insight. Use \code{\link{susceptibility}} (equal to \code{\link{proportion_SI}}) to determine antimicrobial susceptibility and \code{\link{count_susceptible}} (equal to \code{\link{count_SI}}) to count susceptible isolates.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
@ -136,81 +143,72 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
|
||||
# example_isolates is a data set available in the AMR package.
|
||||
?example_isolates
|
||||
|
||||
# Calculate resistance
|
||||
portion_R(example_isolates$AMX)
|
||||
portion_IR(example_isolates$AMX)
|
||||
resistance(example_isolates$AMX) # determines \%R
|
||||
susceptibility(example_isolates$AMX) # determines \%S+I
|
||||
|
||||
# Or susceptibility
|
||||
portion_S(example_isolates$AMX)
|
||||
portion_SI(example_isolates$AMX)
|
||||
# be more specific
|
||||
proportion_S(example_isolates$AMX)
|
||||
proportion_SI(example_isolates$AMX)
|
||||
proportion_I(example_isolates$AMX)
|
||||
proportion_IR(example_isolates$AMX)
|
||||
proportion_R(example_isolates$AMX)
|
||||
|
||||
# Do the above with pipes:
|
||||
library(dplyr)
|
||||
example_isolates \%>\% portion_R(AMX)
|
||||
example_isolates \%>\% portion_IR(AMX)
|
||||
example_isolates \%>\% portion_S(AMX)
|
||||
example_isolates \%>\% portion_SI(AMX)
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(r = resistance(CIP),
|
||||
n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr, see ?n_rsi
|
||||
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(p = portion_SI(CIP),
|
||||
n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr
|
||||
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(R = portion_R(CIP, as_percent = TRUE),
|
||||
I = portion_I(CIP, as_percent = TRUE),
|
||||
S = portion_S(CIP, as_percent = TRUE),
|
||||
summarise(R = resistance(CIP, as_percent = TRUE),
|
||||
SI = susceptibility(CIP, as_percent = TRUE),
|
||||
n1 = count_all(CIP), # the actual total; sum of all three
|
||||
n2 = n_rsi(CIP), # same - analogous to n_distinct
|
||||
total = n()) # NOT the number of tested isolates!
|
||||
|
||||
# Calculate co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
# so we can see that combination therapy does a lot more than mono therapy:
|
||||
example_isolates \%>\% portion_SI(AMC) # \%SI = 76.3\%
|
||||
example_isolates \%>\% susceptibility(AMC) # \%SI = 76.3\%
|
||||
example_isolates \%>\% count_all(AMC) # n = 1879
|
||||
|
||||
example_isolates \%>\% portion_SI(GEN) # \%SI = 75.4\%
|
||||
example_isolates \%>\% susceptibility(GEN) # \%SI = 75.4\%
|
||||
example_isolates \%>\% count_all(GEN) # n = 1855
|
||||
|
||||
example_isolates \%>\% portion_SI(AMC, GEN) # \%SI = 94.1\%
|
||||
example_isolates \%>\% susceptibility(AMC, GEN) # \%SI = 94.1\%
|
||||
example_isolates \%>\% count_all(AMC, GEN) # n = 1939
|
||||
|
||||
|
||||
# See Details on how `only_all_tested` works. Example:
|
||||
example_isolates \%>\%
|
||||
summarise(numerator = count_SI(AMC, GEN),
|
||||
summarise(numerator = count_susceptible(AMC, GEN),
|
||||
denominator = count_all(AMC, GEN),
|
||||
portion = portion_SI(AMC, GEN))
|
||||
# numerator denominator portion
|
||||
# 1764 1936 0.9408
|
||||
proportion = susceptibility(AMC, GEN))
|
||||
example_isolates \%>\%
|
||||
summarise(numerator = count_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
summarise(numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
|
||||
denominator = count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
portion = portion_SI(AMC, GEN, only_all_tested = TRUE))
|
||||
# numerator denominator portion
|
||||
# 1687 1798 0.9383
|
||||
proportion = susceptibility(AMC, GEN, only_all_tested = TRUE))
|
||||
|
||||
|
||||
example_isolates \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
|
||||
summarise(cipro_p = susceptibility(CIP, as_percent = TRUE),
|
||||
cipro_n = count_all(CIP),
|
||||
genta_p = portion_SI(GEN, as_percent = TRUE),
|
||||
genta_p = susceptibility(GEN, as_percent = TRUE),
|
||||
genta_n = count_all(GEN),
|
||||
combination_p = portion_SI(CIP, GEN, as_percent = TRUE),
|
||||
combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
|
||||
combination_n = count_all(CIP, GEN))
|
||||
|
||||
# Get portions S/I/R immediately of all rsi columns
|
||||
# Get proportions S/I/R immediately of all rsi columns
|
||||
example_isolates \%>\%
|
||||
select(AMX, CIP) \%>\%
|
||||
portion_df(translate = FALSE)
|
||||
proportion_df(translate = FALSE)
|
||||
|
||||
# It also supports grouping variables
|
||||
example_isolates \%>\%
|
||||
select(hospital_id, AMX, CIP) \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
portion_df(translate = FALSE)
|
||||
proportion_df(translate = FALSE)
|
||||
|
||||
|
||||
\dontrun{
|
||||
@ -219,7 +217,7 @@ example_isolates \%>\%
|
||||
my_table \%>\%
|
||||
filter(first_isolate == TRUE,
|
||||
genus == "Helicobacter") \%>\%
|
||||
summarise(p = portion_S(AMX, MTR), # amoxicillin with metronidazole
|
||||
summarise(p = susceptibility(AMX, MTR), # amoxicillin with metronidazole
|
||||
n = count_all(AMX, MTR))
|
||||
}
|
||||
}
|
@ -174,7 +174,6 @@ Function Bootstrap {
|
||||
Progress "Downloading and installing travis_tool.sh"
|
||||
|
||||
cp "tests\appveyor\travis_tool.sh" "..\travis_tool.sh"
|
||||
# Invoke-WebRequest https://gitlab.com/msberends/AMR/raw/master/tests/appveyor/travis_tool.sh -OutFile "..\travis_tool.sh"
|
||||
echo '@bash.exe ../travis_tool.sh %*' | Out-File -Encoding ASCII .\travis_tool.sh.cmd
|
||||
cat .\travis_tool.sh.cmd
|
||||
bash -c "( echo; echo '^travis_tool\.sh\.cmd$' ) >> .Rbuildignore"
|
||||
|
@ -22,67 +22,67 @@
|
||||
context("count.R")
|
||||
|
||||
test_that("counts work", {
|
||||
|
||||
expect_equal(count_resistant(example_isolates$AMX), count_R(example_isolates$AMX))
|
||||
expect_equal(count_susceptible(example_isolates$AMX), count_SI(example_isolates$AMX))
|
||||
expect_equal(count_all(example_isolates$AMX), n_rsi(example_isolates$AMX))
|
||||
|
||||
# AMX resistance in `example_isolates`
|
||||
expect_equal(count_R(example_isolates$AMX), 683)
|
||||
expect_equal(count_I(example_isolates$AMX), 3)
|
||||
expect_equal(count_S(example_isolates$AMX), 543)
|
||||
expect_equal(suppressWarnings(count_S(example_isolates$AMX)), 543)
|
||||
expect_equal(count_R(example_isolates$AMX) + count_I(example_isolates$AMX),
|
||||
count_IR(example_isolates$AMX))
|
||||
expect_equal(count_S(example_isolates$AMX) + count_I(example_isolates$AMX),
|
||||
suppressWarnings(count_IR(example_isolates$AMX)))
|
||||
expect_equal(suppressWarnings(count_S(example_isolates$AMX)) + count_I(example_isolates$AMX),
|
||||
count_SI(example_isolates$AMX))
|
||||
|
||||
library(dplyr)
|
||||
expect_equal(example_isolates %>% count_S(AMC), 1342)
|
||||
expect_equal(example_isolates %>% count_S(AMC, GEN, only_all_tested = TRUE), 1660)
|
||||
expect_equal(example_isolates %>% count_S(AMC, GEN, only_all_tested = FALSE), 1728)
|
||||
expect_equal(example_isolates %>% count_susceptible(AMC), 1433)
|
||||
expect_equal(example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = TRUE), 1687)
|
||||
expect_equal(example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = FALSE), 1764)
|
||||
expect_equal(example_isolates %>% count_all(AMC, GEN, only_all_tested = TRUE), 1798)
|
||||
expect_equal(example_isolates %>% count_all(AMC, GEN, only_all_tested = FALSE), 1936)
|
||||
expect_identical(example_isolates %>% count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
example_isolates %>% count_S(AMC, GEN, only_all_tested = TRUE) +
|
||||
example_isolates %>% count_IR(AMC, GEN, only_all_tested = TRUE))
|
||||
example_isolates %>% count_susceptible(AMC, GEN, only_all_tested = TRUE) +
|
||||
example_isolates %>% count_resistant(AMC, GEN, only_all_tested = TRUE))
|
||||
|
||||
# count of cases
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(cipro = count_SI(CIP),
|
||||
genta = count_SI(GEN),
|
||||
combination = count_SI(CIP, GEN)) %>%
|
||||
summarise(cipro = count_susceptible(CIP),
|
||||
genta = count_susceptible(GEN),
|
||||
combination = count_susceptible(CIP, GEN)) %>%
|
||||
pull(combination),
|
||||
c(253, 465, 192, 558))
|
||||
|
||||
# count_df
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% count_df() %>% pull(value),
|
||||
c(example_isolates$AMX %>% count_SI(),
|
||||
example_isolates$AMX %>% count_R())
|
||||
c(example_isolates$AMX %>% count_susceptible(),
|
||||
example_isolates$AMX %>% count_resistant())
|
||||
)
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% count_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% count_S(),
|
||||
example_isolates$AMX %>% count_IR())
|
||||
c(suppressWarnings(example_isolates$AMX %>% count_S()),
|
||||
suppressWarnings(example_isolates$AMX %>% count_IR()))
|
||||
)
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% count_S(),
|
||||
c(suppressWarnings(example_isolates$AMX %>% count_S()),
|
||||
example_isolates$AMX %>% count_I(),
|
||||
example_isolates$AMX %>% count_R())
|
||||
)
|
||||
|
||||
# warning for speed loss
|
||||
expect_warning(count_R(as.character(example_isolates$AMC)))
|
||||
expect_warning(count_I(as.character(example_isolates$AMC)))
|
||||
expect_warning(count_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_warning(count_S(example_isolates$AMC,
|
||||
expect_warning(count_resistant(as.character(example_isolates$AMC)))
|
||||
expect_warning(count_resistant(example_isolates$AMC,
|
||||
as.character(example_isolates$GEN)))
|
||||
|
||||
# check for errors
|
||||
expect_error(count_IR("test", minimum = "test"))
|
||||
expect_error(count_IR("test", as_percent = "test"))
|
||||
expect_error(count_I("test", minimum = "test"))
|
||||
expect_error(count_I("test", as_percent = "test"))
|
||||
expect_error(count_S("test", minimum = "test"))
|
||||
expect_error(count_S("test", as_percent = "test"))
|
||||
expect_error(count_resistant("test", minimum = "test"))
|
||||
expect_error(count_resistant("test", as_percent = "test"))
|
||||
expect_error(count_susceptible("test", minimum = "test"))
|
||||
expect_error(count_susceptible("test", as_percent = "test"))
|
||||
|
||||
expect_error(count_df(c("A", "B", "C")))
|
||||
expect_error(count_df(example_isolates[, "date"]))
|
||||
|
@ -22,20 +22,12 @@
|
||||
context("deprecated.R")
|
||||
|
||||
test_that("deprecated functions work", {
|
||||
|
||||
# first 5 chars of official name
|
||||
expect_equal(suppressWarnings(as.character(as.atc(c("nitro", "cipro")))),
|
||||
c("J01XE01", "J01MA02"))
|
||||
|
||||
# EARS-Net
|
||||
expect_equal(suppressWarnings(as.character(as.atc("AMX"))),
|
||||
"J01CA04")
|
||||
|
||||
expect_equal(suppressWarnings(guess_ab_col(data.frame(AMP_ND10 = "R",
|
||||
AMC_ED20 = "S"),
|
||||
as.atc("augmentin"))),
|
||||
"AMC_ED20")
|
||||
|
||||
expect_identical(suppressWarnings(p.symbol(seq(0, 1, 0.001))),
|
||||
p_symbol(seq(0, 1, 0.001)))
|
||||
|
||||
expect_equal(suppressWarnings(portion_S(example_isolates$AMX)), proportion_S(example_isolates$AMX))
|
||||
expect_equal(suppressWarnings(portion_SI(example_isolates$AMX)), proportion_SI(example_isolates$AMX))
|
||||
expect_equal(suppressWarnings(portion_I(example_isolates$AMX)), proportion_I(example_isolates$AMX))
|
||||
expect_equal(suppressWarnings(portion_IR(example_isolates$AMX)), proportion_IR(example_isolates$AMX))
|
||||
expect_equal(suppressWarnings(portion_R(example_isolates$AMX)), proportion_R(example_isolates$AMX))
|
||||
})
|
||||
|
@ -30,26 +30,26 @@ test_that("ggplot_rsi works", {
|
||||
|
||||
# data should be equal
|
||||
expect_equal(
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi())$data %>% summarise_all(portion_IR) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(portion_IR) %>% as.double()
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi())$data %>% summarise_all(resistance) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(resistance) %>% as.double()
|
||||
)
|
||||
|
||||
print(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))
|
||||
print(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))
|
||||
|
||||
expect_equal(
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>% summarise_all(portion_IR) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(portion_IR) %>% as.double()
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>% summarise_all(resistance) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(resistance) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>% summarise_all(portion_IR) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(portion_IR) %>% as.double()
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>% summarise_all(resistance) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(resistance) %>% as.double()
|
||||
)
|
||||
|
||||
expect_equal(
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>% summarise_all(count_IR) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(count_IR) %>% as.double()
|
||||
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>% summarise_all(count_resistant) %>% as.double(),
|
||||
example_isolates %>% select(AMC, CIP) %>% summarise_all(count_resistant) %>% as.double()
|
||||
)
|
||||
|
||||
# support for scale_type ab and mo
|
||||
|
@ -1,121 +0,0 @@
|
||||
# ==================================================================== #
|
||||
# TITLE #
|
||||
# Antimicrobial Resistance (AMR) Analysis #
|
||||
# #
|
||||
# SOURCE #
|
||||
# https://gitlab.com/msberends/AMR #
|
||||
# #
|
||||
# LICENCE #
|
||||
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
|
||||
# #
|
||||
# This R package is free software; you can freely use and distribute #
|
||||
# it for both personal and commercial purposes under the terms of the #
|
||||
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
|
||||
# the Free Software Foundation. #
|
||||
# #
|
||||
# This R package was created for academic research and was publicly #
|
||||
# released in the hope that it will be useful, but it comes WITHOUT #
|
||||
# ANY WARRANTY OR LIABILITY. #
|
||||
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
|
||||
# ==================================================================== #
|
||||
|
||||
context("portion.R")
|
||||
|
||||
test_that("portions works", {
|
||||
# AMX resistance in `example_isolates`
|
||||
expect_equal(portion_R(example_isolates$AMX), 0.5557364, tolerance = 0.0001)
|
||||
expect_equal(portion_I(example_isolates$AMX), 0.002441009, tolerance = 0.0001)
|
||||
expect_equal(1 - portion_R(example_isolates$AMX) - portion_I(example_isolates$AMX),
|
||||
portion_S(example_isolates$AMX))
|
||||
expect_equal(portion_R(example_isolates$AMX) + portion_I(example_isolates$AMX),
|
||||
portion_IR(example_isolates$AMX))
|
||||
expect_equal(portion_S(example_isolates$AMX) + portion_I(example_isolates$AMX),
|
||||
portion_SI(example_isolates$AMX))
|
||||
|
||||
expect_equal(example_isolates %>% portion_SI(AMC),
|
||||
0.7626397,
|
||||
tolerance = 0.0001)
|
||||
expect_equal(example_isolates %>% portion_SI(AMC, GEN),
|
||||
0.9408,
|
||||
tolerance = 0.0001)
|
||||
expect_equal(example_isolates %>% portion_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
0.9382647,
|
||||
tolerance = 0.0001)
|
||||
|
||||
# percentages
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(R = portion_R(CIP, as_percent = TRUE),
|
||||
I = portion_I(CIP, as_percent = TRUE),
|
||||
S = portion_S(CIP, as_percent = TRUE),
|
||||
n = n_rsi(CIP),
|
||||
total = n()) %>%
|
||||
pull(n) %>%
|
||||
sum(),
|
||||
1409)
|
||||
|
||||
# count of cases
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
|
||||
cipro_n = n_rsi(CIP),
|
||||
genta_p = portion_SI(GEN, as_percent = TRUE),
|
||||
genta_n = n_rsi(GEN),
|
||||
combination_p = portion_SI(CIP, GEN, as_percent = TRUE),
|
||||
combination_n = n_rsi(CIP, GEN)) %>%
|
||||
pull(combination_n),
|
||||
c(305, 617, 241, 711))
|
||||
|
||||
expect_warning(portion_R(as.character(example_isolates$AMC)))
|
||||
expect_warning(portion_S(as.character(example_isolates$AMC)))
|
||||
expect_warning(portion_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_warning(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN))),
|
||||
1879)
|
||||
|
||||
# check for errors
|
||||
expect_error(portion_IR("test", minimum = "test"))
|
||||
expect_error(portion_IR("test", as_percent = "test"))
|
||||
expect_error(portion_I("test", minimum = "test"))
|
||||
expect_error(portion_I("test", as_percent = "test"))
|
||||
expect_error(portion_S("test", minimum = "test"))
|
||||
expect_error(portion_S("test", as_percent = "test"))
|
||||
expect_error(portion_S("test", also_single_tested = TRUE))
|
||||
|
||||
# check too low amount of isolates
|
||||
expect_identical(suppressWarnings(portion_R(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
expect_identical(suppressWarnings(portion_I(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
expect_identical(suppressWarnings(portion_S(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
|
||||
# warning for speed loss
|
||||
expect_warning(portion_R(as.character(example_isolates$GEN)))
|
||||
expect_warning(portion_I(as.character(example_isolates$GEN)))
|
||||
expect_warning(portion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
|
||||
|
||||
# portion_df
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% portion_df() %>% pull(value),
|
||||
c(example_isolates$AMX %>% portion_SI(),
|
||||
example_isolates$AMX %>% portion_R())
|
||||
)
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% portion_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% portion_S(),
|
||||
example_isolates$AMX %>% portion_IR())
|
||||
)
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% portion_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% portion_S(),
|
||||
example_isolates$AMX %>% portion_I(),
|
||||
example_isolates$AMX %>% portion_R())
|
||||
)
|
||||
|
||||
expect_error(portion_df(c("A", "B", "C")))
|
||||
expect_error(portion_df(example_isolates[, "date"]))
|
||||
})
|
124
tests/testthat/test-proportion.R
Executable file
@ -0,0 +1,124 @@
|
||||
# ==================================================================== #
|
||||
# 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("proportion.R")
|
||||
|
||||
test_that("proportions works", {
|
||||
expect_equal(proportion_R(example_isolates$AMX), resistance(example_isolates$AMX))
|
||||
expect_equal(proportion_SI(example_isolates$AMX), susceptibility(example_isolates$AMX))
|
||||
|
||||
# AMX resistance in `example_isolates`
|
||||
expect_equal(proportion_R(example_isolates$AMX), 0.5557364, tolerance = 0.0001)
|
||||
expect_equal(proportion_I(example_isolates$AMX), 0.002441009, tolerance = 0.0001)
|
||||
expect_equal(1 - proportion_R(example_isolates$AMX) - proportion_I(example_isolates$AMX),
|
||||
proportion_S(example_isolates$AMX))
|
||||
expect_equal(proportion_R(example_isolates$AMX) + proportion_I(example_isolates$AMX),
|
||||
proportion_IR(example_isolates$AMX))
|
||||
expect_equal(proportion_S(example_isolates$AMX) + proportion_I(example_isolates$AMX),
|
||||
proportion_SI(example_isolates$AMX))
|
||||
|
||||
expect_equal(example_isolates %>% proportion_SI(AMC),
|
||||
0.7626397,
|
||||
tolerance = 0.0001)
|
||||
expect_equal(example_isolates %>% proportion_SI(AMC, GEN),
|
||||
0.9408,
|
||||
tolerance = 0.0001)
|
||||
expect_equal(example_isolates %>% proportion_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
0.9382647,
|
||||
tolerance = 0.0001)
|
||||
|
||||
# percentages
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(R = proportion_R(CIP, as_percent = TRUE),
|
||||
I = proportion_I(CIP, as_percent = TRUE),
|
||||
S = proportion_S(CIP, as_percent = TRUE),
|
||||
n = n_rsi(CIP),
|
||||
total = n()) %>%
|
||||
pull(n) %>%
|
||||
sum(),
|
||||
1409)
|
||||
|
||||
# count of cases
|
||||
expect_equal(example_isolates %>%
|
||||
group_by(hospital_id) %>%
|
||||
summarise(cipro_p = proportion_SI(CIP, as_percent = TRUE),
|
||||
cipro_n = n_rsi(CIP),
|
||||
genta_p = proportion_SI(GEN, as_percent = TRUE),
|
||||
genta_n = n_rsi(GEN),
|
||||
combination_p = proportion_SI(CIP, GEN, as_percent = TRUE),
|
||||
combination_n = n_rsi(CIP, GEN)) %>%
|
||||
pull(combination_n),
|
||||
c(305, 617, 241, 711))
|
||||
|
||||
expect_warning(proportion_R(as.character(example_isolates$AMC)))
|
||||
expect_warning(proportion_S(as.character(example_isolates$AMC)))
|
||||
expect_warning(proportion_S(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_warning(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN)))
|
||||
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
|
||||
example_isolates$GEN))),
|
||||
1879)
|
||||
|
||||
# check for errors
|
||||
expect_error(proportion_IR("test", minimum = "test"))
|
||||
expect_error(proportion_IR("test", as_percent = "test"))
|
||||
expect_error(proportion_I("test", minimum = "test"))
|
||||
expect_error(proportion_I("test", as_percent = "test"))
|
||||
expect_error(proportion_S("test", minimum = "test"))
|
||||
expect_error(proportion_S("test", as_percent = "test"))
|
||||
expect_error(proportion_S("test", also_single_tested = TRUE))
|
||||
|
||||
# check too low amount of isolates
|
||||
expect_identical(suppressWarnings(proportion_R(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
expect_identical(suppressWarnings(proportion_I(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
expect_identical(suppressWarnings(proportion_S(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
|
||||
NA)
|
||||
|
||||
# warning for speed loss
|
||||
expect_warning(proportion_R(as.character(example_isolates$GEN)))
|
||||
expect_warning(proportion_I(as.character(example_isolates$GEN)))
|
||||
expect_warning(proportion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
|
||||
|
||||
# proportion_df
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% proportion_df() %>% pull(value),
|
||||
c(example_isolates$AMX %>% proportion_SI(),
|
||||
example_isolates$AMX %>% proportion_R())
|
||||
)
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% proportion_df(combine_IR = TRUE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% proportion_S(),
|
||||
example_isolates$AMX %>% proportion_IR())
|
||||
)
|
||||
expect_equal(
|
||||
example_isolates %>% select(AMX) %>% proportion_df(combine_SI = FALSE) %>% pull(value),
|
||||
c(example_isolates$AMX %>% proportion_S(),
|
||||
example_isolates$AMX %>% proportion_I(),
|
||||
example_isolates$AMX %>% proportion_R())
|
||||
)
|
||||
|
||||
expect_error(proportion_df(c("A", "B", "C")))
|
||||
expect_error(proportion_df(example_isolates[, "date"]))
|
||||
})
|
@ -321,10 +321,12 @@ data_1st %>%
|
||||
|
||||
## Resistance percentages
|
||||
|
||||
The functions `portion_S()`, `portion_SI()`, `portion_I()`, `portion_IR()` and `portion_R()` can be used to determine the portion of a specific antimicrobial outcome. As per the EUCAST guideline of 2019, we calculate resistance as the portion of R (`portion_R()`) and susceptibility as the portion of S and I (`portion_SI()`). These functions can be used on their own:
|
||||
The functions `resistance()` and `susceptibility()` can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions `proportion_S()`, `proportion_SI()`, `proportion_I()`, `proportion_IR()` and `proportion_R()` can be used to determine the proportion of a specific antimicrobial outcome.
|
||||
|
||||
As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (`proportion_R()`, equal to `resistance()`) and susceptibility as the proportion of S and I (`proportion_SI()`, equal to `susceptibility()`). These functions can be used on their own:
|
||||
|
||||
```{r}
|
||||
data_1st %>% portion_R(AMX)
|
||||
data_1st %>% resistance(AMX)
|
||||
```
|
||||
|
||||
Or can be used in conjuction with `group_by()` and `summarise()`, both from the `dplyr` package:
|
||||
@ -332,12 +334,12 @@ Or can be used in conjuction with `group_by()` and `summarise()`, both from the
|
||||
```{r, eval = FALSE}
|
||||
data_1st %>%
|
||||
group_by(hospital) %>%
|
||||
summarise(amoxicillin = portion_R(AMX))
|
||||
summarise(amoxicillin = resistance(AMX))
|
||||
```
|
||||
```{r, echo = FALSE}
|
||||
data_1st %>%
|
||||
group_by(hospital) %>%
|
||||
summarise(amoxicillin = portion_R(AMX)) %>%
|
||||
summarise(amoxicillin = resistance(AMX)) %>%
|
||||
knitr::kable(align = "c", big.mark = ",")
|
||||
```
|
||||
|
||||
@ -346,32 +348,32 @@ Of course it would be very convenient to know the number of isolates responsible
|
||||
```{r, eval = FALSE}
|
||||
data_1st %>%
|
||||
group_by(hospital) %>%
|
||||
summarise(amoxicillin = portion_R(AMX),
|
||||
summarise(amoxicillin = resistance(AMX),
|
||||
available = n_rsi(AMX))
|
||||
```
|
||||
```{r, echo = FALSE}
|
||||
data_1st %>%
|
||||
group_by(hospital) %>%
|
||||
summarise(amoxicillin = portion_R(AMX),
|
||||
summarise(amoxicillin = resistance(AMX),
|
||||
available = n_rsi(AMX)) %>%
|
||||
knitr::kable(align = "c", big.mark = ",")
|
||||
```
|
||||
|
||||
These functions can also be used to get the portion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:
|
||||
These functions can also be used to get the proportion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:
|
||||
|
||||
```{r, eval = FALSE}
|
||||
data_1st %>%
|
||||
group_by(genus) %>%
|
||||
summarise(amoxiclav = portion_SI(AMC),
|
||||
gentamicin = portion_SI(GEN),
|
||||
amoxiclav_genta = portion_SI(AMC, GEN))
|
||||
summarise(amoxiclav = susceptibility(AMC),
|
||||
gentamicin = susceptibility(GEN),
|
||||
amoxiclav_genta = susceptibility(AMC, GEN))
|
||||
```
|
||||
```{r, echo = FALSE}
|
||||
data_1st %>%
|
||||
group_by(genus) %>%
|
||||
summarise(amoxiclav = portion_SI(AMC),
|
||||
gentamicin = portion_SI(GEN),
|
||||
amoxiclav_genta = portion_SI(AMC, GEN)) %>%
|
||||
summarise(amoxiclav = susceptibility(AMC),
|
||||
gentamicin = susceptibility(GEN),
|
||||
amoxiclav_genta = susceptibility(AMC, GEN)) %>%
|
||||
knitr::kable(align = "c", big.mark = ",")
|
||||
```
|
||||
|
||||
@ -380,9 +382,9 @@ To make a transition to the next part, let's see how this difference could be pl
|
||||
```{r plot 1}
|
||||
data_1st %>%
|
||||
group_by(genus) %>%
|
||||
summarise("1. Amoxi/clav" = portion_SI(AMC),
|
||||
"2. Gentamicin" = portion_SI(GEN),
|
||||
"3. Amoxi/clav + genta" = portion_SI(AMC, GEN)) %>%
|
||||
summarise("1. Amoxi/clav" = susceptibility(AMC),
|
||||
"2. Gentamicin" = susceptibility(GEN),
|
||||
"3. Amoxi/clav + genta" = susceptibility(AMC, GEN)) %>%
|
||||
tidyr::gather("antibiotic", "S", -genus) %>%
|
||||
ggplot(aes(x = genus,
|
||||
y = S,
|
||||
@ -408,7 +410,7 @@ ggplot(a_data_set) +
|
||||
geom_bar(aes(year))
|
||||
```
|
||||
|
||||
The `AMR` package contains functions to extend this `ggplot2` package, for example `geom_rsi()`. It automatically transforms data with `count_df()` or `portion_df()` and show results in stacked bars. Its simplest and shortest example:
|
||||
The `AMR` package contains functions to extend this `ggplot2` package, for example `geom_rsi()`. It automatically transforms data with `count_df()` or `proportion_df()` and show results in stacked bars. Its simplest and shortest example:
|
||||
|
||||
```{r plot 3}
|
||||
ggplot(data_1st) +
|
||||
|