(v1.2.0.9008) ab_class improvement

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-06-17 15:14:37 +02:00
parent c4d7412f36
commit ac12392da3
37 changed files with 619 additions and 362 deletions

View File

@ -1,5 +1,5 @@
Package: AMR
Version: 1.2.0.9007
Version: 1.2.0.9008
Date: 2020-06-17
Title: Antimicrobial Resistance Analysis
Authors@R: c(

View File

@ -64,6 +64,7 @@ export(ab_atc)
export(ab_atc_group1)
export(ab_atc_group2)
export(ab_cid)
export(ab_class)
export(ab_ddd)
export(ab_group)
export(ab_info)

10
NEWS.md
View File

@ -1,4 +1,4 @@
# AMR 1.2.0.9007
# AMR 1.2.0.9008
## <small>Last updated: 17-Jun-2020</small>
### New
@ -13,17 +13,23 @@
tibble(J01CA01 = "S") %>%
select(penicillins())
#> Selecting beta-lactams/penicillins: `J01CA01` (ampicillin)
# select an antibiotic class manually with `ab_class()`
example_isolates %>%
select(ab_class("mycobact"))
#> Selecting antimycobacterials: `RIF` (rifampicin)
```
### Changed
* Fixed a bug where `eucast_rules()` would not work on a tibble when the `tibble` or `dplyr` package was loaded
* All `*_join_microorganisms()` functions now return the original data class (e.g. tibbles and data.tables)
* All `*_join_microorganisms()` functions and `bug_drug_combinations()` now return the original data class (e.g. `tibble`s and `data.table`s)
* Fixed a bug where `as.ab()` would return an error on invalid input values
* Fixed a bug for using grouped versions of `rsi_df()`, `proportion_df()` and `count_df()`, and fixed a bug where not all different antimicrobial results were added as rows
* Added function `filter_penicillins()` to filter isolates on a specific result in any column with a name in the antimicrobial 'penicillins' class (more specific: ATC subgroup *Beta-lactam antibacterials, penicillins*)
* Added official antimicrobial names to all `filter_ab_class()` functions, such as `filter_aminoglycosides()`
* Added antibiotics code "FOX1" for cefoxitin screening (abbreviation "cfsc") to the `antibiotics` data set
* Improved auto-determination for columns of types `<mo>` and `<Date>`
* Fixed a bug in `bug_drug_combinations()` for when only one antibiotic was in the input data
# AMR 1.2.0

View File

@ -63,14 +63,12 @@ filter_join_worker <- function(x, y, by = NULL, type = c("anti", "semi")) {
# No export, no Rd
addin_insert_in <- function() {
stopifnot_installed_package("rstudioapi")
get("insertText", envir = asNamespace("rstudioapi"))(" %in% ")
import_fn("insertText", "rstudioapi")(" %in% ")
}
# No export, no Rd
addin_insert_like <- function() {
stopifnot_installed_package("rstudioapi")
get("insertText", envir = asNamespace("rstudioapi"))(" %like% ")
import_fn("insertText", "rstudioapi")(" %like% ")
}
check_dataset_integrity <- function() {
@ -186,12 +184,23 @@ stopifnot_installed_package <- function(package) {
# https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html
sapply(package, function(x)
tryCatch(get(".packageName", envir = asNamespace(x)),
error = function(e) stop("package '", x, "' required but not installed.",
"\nTry to install it with: install.packages(\"", x, "\")",
call. = FALSE)))
error = function(e) {
if (package == "rstudioapi") {
stop("This function only works in RStudio.", call. = FALSE)
} else {
stop("package '", x, "' required but not installed.",
"\nTry to install it with: install.packages(\"", x, "\")",
call. = FALSE)
}
}))
return(invisible())
}
import_fn <- function(name, pkg) {
stopifnot_installed_package(pkg)
get(name, envir = asNamespace(pkg))
}
stopifnot_msg <- function(expr, msg) {
if (!isTRUE(expr)) {
stop(msg, call. = FALSE)
@ -245,7 +254,7 @@ dataset_UTF8_to_ASCII <- function(df) {
df
}
has_colour <- function () {
has_colour <- function() {
# this is a base R version of crayon::has_color
enabled <- getOption("crayon.enabled")
if (!is.null(enabled)) {
@ -276,7 +285,7 @@ has_colour <- function () {
}
return(FALSE)
}
emacs_version <- function () {
emacs_version <- function() {
ver <- Sys.getenv("INSIDE_EMACS")
if (ver == "") {
return(NA_integer_)

View File

@ -22,6 +22,7 @@
#' Antibiotic class selectors
#'
#' Use these selection helpers inside any function that allows [Tidyverse selections](https://tidyselect.r-lib.org/reference/language.html), like `dplyr::select()` or `tidyr::pivot_longer()`. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
#' @inheritParams filter_ab_class
#' @details All columns will be searched for known antibiotic names, abbreviations, brand names and codes (ATC, EARS-Net, WHO, etc.). This means that a selector like e.g. [aminoglycosides()] will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
#'
#' These functions only work if the `tidyselect` package is installed, that comes with the `dplyr` package. An error will be thrown if `tidyselect` package is not installed, or if the functions are used outside a function that allows Tidyverse selections like `select()` or `pivot_longer()`.
@ -36,119 +37,138 @@
#' example_isolates %>%
#' select(carbapenems())
#'
#'
#' # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
#' example_isolates %>%
#' select(mo, aminoglycosides())
#'
#' # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
#' example_isolates %>%
#' select(mo, ab_class("mycobact"))
#'
#'
#' # get bug/drug combinations for only macrolides in Gram-positives:
#' example_isolates %>%
#' filter(mo_gramstain(mo) %like% "pos") %>%
#' select(mo, macrolides()) %>%
#' bug_drug_combinations() %>%
#' format()
#'
#'
#' data.frame(irrelevant = "value",
#' J01CA01 = "S") %>% # ATC code of ampicillin
#' select(penicillins()) # so the 'J01CA01' column is selected
#'
#'
#' }
ab_class <- function(ab_class) {
ab_selector(ab_class, function_name = "ab_class")
}
#' @rdname antibiotic_class_selectors
#' @export
aminoglycosides <- function() {
ab_selector("aminoglycoside")
ab_selector("aminoglycoside", function_name = "aminoglycosides")
}
#' @rdname antibiotic_class_selectors
#' @export
carbapenems <- function() {
ab_selector("carbapenem")
ab_selector("carbapenem", function_name = "carbapenems")
}
#' @rdname antibiotic_class_selectors
#' @export
cephalosporins <- function() {
ab_selector("cephalosporin")
ab_selector("cephalosporin", function_name = "cephalosporins")
}
#' @rdname antibiotic_class_selectors
#' @export
cephalosporins_1st <- function() {
ab_selector("cephalosporins.*1")
ab_selector("cephalosporins.*1", function_name = "cephalosporins_1st")
}
#' @rdname antibiotic_class_selectors
#' @export
cephalosporins_2nd <- function() {
ab_selector("cephalosporins.*2")
ab_selector("cephalosporins.*2", function_name = "cephalosporins_2nd")
}
#' @rdname antibiotic_class_selectors
#' @export
cephalosporins_3rd <- function() {
ab_selector("cephalosporins.*3")
ab_selector("cephalosporins.*3", function_name = "cephalosporins_3rd")
}
#' @rdname antibiotic_class_selectors
#' @export
cephalosporins_4th <- function() {
ab_selector("cephalosporins.*4")
ab_selector("cephalosporins.*4", function_name = "cephalosporins_4th")
}
#' @rdname antibiotic_class_selectors
#' @export
cephalosporins_5th <- function() {
ab_selector("cephalosporins.*5")
ab_selector("cephalosporins.*5", function_name = "cephalosporins_5th")
}
#' @rdname antibiotic_class_selectors
#' @export
fluoroquinolones <- function() {
ab_selector("fluoroquinolone")
ab_selector("fluoroquinolone", function_name = "fluoroquinolones")
}
#' @rdname antibiotic_class_selectors
#' @export
glycopeptides <- function() {
ab_selector("glycopeptide")
ab_selector("glycopeptide", function_name = "glycopeptides")
}
#' @rdname antibiotic_class_selectors
#' @export
macrolides <- function() {
ab_selector("macrolide")
ab_selector("macrolide", function_name = "macrolides")
}
#' @rdname antibiotic_class_selectors
#' @export
penicillins <- function() {
ab_selector("penicillin")
ab_selector("penicillin", function_name = "penicillins")
}
#' @rdname antibiotic_class_selectors
#' @export
tetracyclines <- function() {
ab_selector("tetracycline")
ab_selector("tetracycline", function_name = "tetracyclines")
}
ab_selector <- function(ab_class, vars = NULL) {
stopifnot_installed_package("tidyselect")
peek_vars_tidyselect <- get("peek_vars", envir = asNamespace("tidyselect"))
vars_vct <- peek_vars_tidyselect(fn = ab_class)
ab_selector <- function(ab_class, function_name) {
peek_vars_tidyselect <- import_fn("peek_vars", "tidyselect")
vars_vct <- peek_vars_tidyselect(fn = function_name)
vars_df <- data.frame(as.list(vars_vct))[0, , drop = FALSE]
colnames(vars_df) <- vars_vct
ab_in_data <- suppressMessages(get_column_abx(vars_df))
if (length(ab_in_data) == 0) {
message(font_blue("NOTE: no antimicrobial agents found."))
return(NULL)
}
ab_reference <- subset(antibiotics,
group %like% ab_class |
atc_group1 %like% ab_class |
atc_group2 %like% ab_class)
ab_group <- find_ab_group(ab_class)
if (ab_group == "") {
ab_group <- paste0("'", ab_class, "'")
examples <- ""
} else {
examples <- paste0(" (such as ", find_ab_names(ab_class, 2), ")")
}
# get the columns with a group names in the chosen ab class
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
if (length(agents) == 0) {
message(font_blue(paste0("NOTE: no antimicrobial agents of class ", ab_group,
" found (such as ", find_ab_names(ab_class, 2),
").")))
message(font_blue(paste0("NOTE: No antimicrobial agents of class ", ab_group,
" found", examples, ".")))
} else {
message(font_blue(paste0("Selecting ", ab_group, ": ",
paste(paste0("`", font_bold(agents, collapse = NULL),

View File

@ -76,15 +76,14 @@ atc_online_property <- function(atc_code,
administration = "O",
url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no") {
stopifnot_installed_package(c("curl", "rvest", "xml2"))
has_internet <- get("has_internet", envir = asNamespace("curl"))
html_attr <- get("html_attr", envir = asNamespace("rvest"))
html_children <- get("html_children", envir = asNamespace("rvest"))
html_node <- get("html_node", envir = asNamespace("rvest"))
html_nodes <- get("html_nodes", envir = asNamespace("rvest"))
html_table <- get("html_table", envir = asNamespace("rvest"))
html_text <- get("html_text", envir = asNamespace("rvest"))
read_html <- get("read_html", envir = asNamespace("xml2"))
has_internet <- import_fn("has_internet", "curl")
html_attr <- import_fn("html_attr", "rvest")
html_children <- import_fn("html_children", "rvest")
html_node <- import_fn("html_node", "rvest")
html_nodes <- import_fn("html_nodes", "rvest")
html_table <- import_fn("html_table", "rvest")
html_text <- import_fn("html_text", "rvest")
read_html <- import_fn("read_html", "xml2")
check_dataset_integrity()

View File

@ -62,6 +62,9 @@ bug_drug_combinations <- function(x,
if (!is.data.frame(x)) {
stop("`x` must be a data frame.", call. = FALSE)
}
if (!any(sapply(x, is.rsi), na.rm = TRUE)) {
stop("No columns with class <rsi> found. See ?as.rsi.", call. = FALSE)
}
# try to find columns based on type
# -- mo
@ -72,12 +75,13 @@ bug_drug_combinations <- function(x,
stop("`col_mo` must be set.", call. = FALSE)
}
x_class <- class(x)
x <- as.data.frame(x, stringsAsFactors = FALSE)
x[, col_mo] <- FUN(x[, col_mo, drop = TRUE])
x <- x[, c(col_mo, names(which(sapply(x, is.rsi))))]
x <- x[, c(col_mo, names(which(sapply(x, is.rsi)))), drop = FALSE]
unique_mo <- sort(unique(x[, col_mo, drop = TRUE]))
out <- data.frame(
mo = character(0),
ab = character(0),
@ -85,10 +89,10 @@ bug_drug_combinations <- function(x,
I = integer(0),
R = integer(0),
total = integer(0))
for (i in seq_len(length(unique_mo))) {
# filter on MO group and only select R/SI columns
x_mo_filter <- x[which(x[, col_mo, drop = TRUE] == unique_mo[i]), names(which(sapply(x, is.rsi)))]
x_mo_filter <- x[which(x[, col_mo, drop = TRUE] == unique_mo[i]), names(which(sapply(x, is.rsi))), drop = FALSE]
# turn and merge everything
pivot <- lapply(x_mo_filter, function(x) {
m <- as.matrix(table(x))
@ -103,8 +107,8 @@ bug_drug_combinations <- function(x,
total = merged$S + merged$I + merged$R)
out <- rbind(out, out_group)
}
structure(.Data = out, class = c("bug_drug_combinations", class(x)))
structure(.Data = out, class = c("bug_drug_combinations", x_class))
}
#' @method format bug_drug_combinations
@ -121,6 +125,7 @@ format.bug_drug_combinations <- function(x,
decimal.mark = getOption("OutDec"),
big.mark = ifelse(decimal.mark == ",", ".", ","),
...) {
x <- as.data.frame(x, stringsAsFactors = FALSE)
x <- subset(x, total >= minimum)
if (remove_intrinsic_resistant == TRUE) {
@ -221,6 +226,8 @@ format.bug_drug_combinations <- function(x,
#' @method print bug_drug_combinations
#' @export
print.bug_drug_combinations <- function(x, ...) {
print(as.data.frame(x, stringsAsFactors = FALSE))
message(font_blue("NOTE: Use 'format()' on this result to get a publicable/printable format."))
x_class <- class(x)
print(structure(x, class = x_class[x_class != "bug_drug_combinations"]),
...)
message(font_blue("NOTE: Use 'format()' on this result to get a publishable/printable format."))
}

View File

@ -206,7 +206,7 @@ eucast_rules <- function(x,
"\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- eucast_rules(data, verbose = TRUE)\n\nDo you want to continue?")
if ("rstudioapi" %in% rownames(utils::installed.packages())) {
showQuestion <- get("showQuestion", envir = asNamespace("rstudioapi"))
showQuestion <- import_fn("showQuestion", "rstudioapi")
q_continue <- showQuestion("Using verbose = TRUE with eucast_rules()", txt)
} else {
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)

View File

@ -26,10 +26,10 @@
#' Lifecycles of functions in the `AMR` package
#' @name lifecycle
#' @rdname lifecycle
#' @description Functions in this `AMR` package are categorised using [the lifecycle circle of the `tidyverse` as found on www.tidyverse.org/lifecycle](https://www.tidyverse.org/lifecycle).
#' @description Functions in this `AMR` package are categorised using [the lifecycle circle of the Tidyverse as found on www.tidyverse.org/lifecycle](https://www.Tidyverse.org/lifecycle).
#'
#' \if{html}{\figure{lifecycle_tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
#' This page contains a section for every lifecycle (with text borrowed from the aforementioned `tidyverse` website), so they can be used in the manual pages of the functions.
#' \if{html}{\figure{lifecycle_Tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
#' This page contains a section for every lifecycle (with text borrowed from the aforementioned Tidyverse website), so they can be used in the manual pages of the functions.
#' @section Experimental lifecycle:
#' \if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \cr}
#' The [lifecycle][AMR::lifecycle] of this function is **experimental**. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this `AMR` package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.

View File

@ -95,7 +95,7 @@ mdro <- function(x,
"\n\nThis may overwrite your existing data if you use e.g.:",
"\ndata <- mdro(data, verbose = TRUE)\n\nDo you want to continue?")
if ("rstudioapi" %in% rownames(utils::installed.packages())) {
showQuestion <- get("showQuestion", envir = asNamespace("rstudioapi"))
showQuestion <- import_fn("showQuestion", "rstudioapi")
q_continue <- showQuestion("Using verbose = TRUE with mdro()", txt)
} else {
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)

6
R/mo.R
View File

@ -152,7 +152,7 @@
#' \dontrun{
#' df$mo <- as.mo(df$microorganism_name)
#'
#' # the select function of tidyverse is also supported:
#' # the select function of the Tidyverse is also supported:
#' library(dplyr)
#' df$mo <- df %>%
#' select(microorganism_name) %>%
@ -1805,13 +1805,13 @@ parse_and_convert <- function(x) {
if (NCOL(x) > 2) {
stop("A maximum of two columns is allowed.", call. = FALSE)
} else if (NCOL(x) == 2) {
# support tidyverse selection like: df %>% select(colA, colB)
# support Tidyverse selection like: df %>% select(colA, colB)
# paste these columns together
x <- as.data.frame(x, stringsAsFactors = FALSE)
colnames(x) <- c("A", "B")
x <- paste(x$A, x$B)
} else {
# support tidyverse selection like: df %>% select(colA)
# support Tidyverse selection like: df %>% select(colA)
x <- as.data.frame(x, stringsAsFactors = FALSE)[[1]]
}
}

View File

@ -135,8 +135,7 @@ set_mo_source <- function(path) {
} else if (path %like% "[.]xlsx?$") {
# is Excel file (old or new)
stopifnot_installed_package("readxl")
read_excel <- get("read_excel", envir = asNamespace("readxl"))
read_excel <- import_fn("read_excel", "readxl")
df <- read_excel(path)
} else if (path %like% "[.]tsv$") {

View File

@ -40,7 +40,7 @@
#'
#' **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 [first_isolate()] to determine them in your data set.
#'
#' These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the `count()`][AMR::count()] functions to count isolates. The function [susceptibility()] is essentially equal to `count_susceptible() / count_all()`. *Low counts can influence the outcome - the `proportion` functions may camouflage this, since they only return the proportion (albeit being dependent on the `minimum` parameter).*
#' These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the [`count()`][AMR::count()] functions to count isolates. The function [susceptibility()] is essentially equal to `count_susceptible() / count_all()`. *Low counts can influence the outcome - the `proportion` functions may camouflage this, since they only return the proportion (albeit being dependent on the `minimum` parameter).*
#'
#' The function [proportion_df()] takes any variable from `data` that has an [`rsi`] class (created with [as.rsi()]) and calculates the proportions R, I and S. It also supports grouped variables. The function [rsi_df()] works exactly like [proportion_df()], but adds the number of isolates.
#' @section Combination therapy:

View File

@ -316,9 +316,9 @@ plot.resistance_predict <- function(x, main = paste("Resistance Prediction of",
}
# get plot() generic; this was moved from the 'graphics' pkg to the 'base' pkg in R 4.0.0
if (as.integer(R.Version()$major) >= 4) {
plot <- get("plot", envir = asNamespace("base"))
plot <- import_fn("plot", "base")
} else {
plot <- get("plot", envir = asNamespace("graphics"))
plot <- import_fn("plot", "graphics")
}
plot(x = x$year,
y = x$value,

View File

@ -594,9 +594,9 @@ plot.rsi <- function(x,
# get plot() generic; this was moved from the 'graphics' pkg to the 'base' pkg in R 4.0.0
if (as.integer(R.Version()$major) >= 4) {
plot <- get("plot", envir = asNamespace("base"))
plot <- import_fn("plot", "base")
} else {
plot <- get("plot", envir = asNamespace("graphics"))
plot <- import_fn("plot", "graphics")
}
plot(x = data$x,
y = data$s,

View File

@ -81,7 +81,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>

View File

@ -81,7 +81,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -81,7 +81,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>

View File

@ -81,7 +81,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>

View File

@ -43,7 +43,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>

View File

@ -81,7 +81,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>
@ -229,9 +229,9 @@
<small>Source: <a href='https://gitlab.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
</div>
<div id="amr-1209007" class="section level1">
<h1 class="page-header" data-toc-text="1.2.0.9007">
<a href="#amr-1209007" class="anchor"></a>AMR 1.2.0.9007<small> Unreleased </small>
<div id="amr-1209008" class="section level1">
<h1 class="page-header" data-toc-text="1.2.0.9008">
<a href="#amr-1209008" class="anchor"></a>AMR 1.2.0.9008<small> Unreleased </small>
</h1>
<div id="last-updated-17-jun-2020" class="section level2">
<h2 class="hasAnchor">
@ -251,7 +251,12 @@
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/reexports.html">tibble</a></span>(<span class="kw">J01CA01</span> <span class="kw">=</span> <span class="st">"S"</span>) <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="fu"><a href="../reference/antibiotic_class_selectors.html">penicillins</a></span>())
<span class="co">#&gt; Selecting beta-lactams/penicillins: `J01CA01` (ampicillin)</span></pre></div>
<span class="co">#&gt; Selecting beta-lactams/penicillins: `J01CA01` (ampicillin)</span>
<span class="co"># select an antibiotic class manually with `ab_class()`</span>
<span class="no">example_isolates</span> <span class="kw">%&gt;%</span>
<span class="fu"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="fu"><a href="../reference/antibiotic_class_selectors.html">ab_class</a></span>(<span class="st">"mycobact"</span>))
<span class="co">#&gt; Selecting antimycobacterials: `RIF` (rifampicin)</span></pre></div>
</li>
</ul>
</div>
@ -260,7 +265,7 @@
<a href="#changed" class="anchor"></a>Changed</h3>
<ul>
<li>Fixed a bug where <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code> would not work on a tibble when the <code>tibble</code> or <code>dplyr</code> package was loaded</li>
<li>All <code>*_join_microorganisms()</code> functions now return the original data class (e.g. tibbles and data.tables)</li>
<li>All <code>*_join_microorganisms()</code> functions and <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> now return the original data class (e.g. <code>tibble</code>s and <code>data.table</code>s)</li>
<li>Fixed a bug where <code><a href="../reference/as.ab.html">as.ab()</a></code> would return an error on invalid input values</li>
<li>Fixed a bug for using grouped versions of <code><a href="../reference/proportion.html">rsi_df()</a></code>, <code><a href="../reference/proportion.html">proportion_df()</a></code> and <code><a href="../reference/count.html">count_df()</a></code>, and fixed a bug where not all different antimicrobial results were added as rows</li>
<li>Added function <code><a href="../reference/filter_ab_class.html">filter_penicillins()</a></code> to filter isolates on a specific result in any column with a name in the antimicrobial penicillins class (more specific: ATC subgroup <em>Beta-lactam antibacterials, penicillins</em>)</li>
@ -269,6 +274,7 @@
<li>Added antibiotics code “FOX1” for cefoxitin screening (abbreviation “cfsc”) to the <code>antibiotics</code> data set</li>
<li>Improved auto-determination for columns of types <code>&lt;mo&gt;</code> and <code>&lt;Date&gt;</code>
</li>
<li>Fixed a bug in <code><a href="../reference/bug_drug_combinations.html">bug_drug_combinations()</a></code> for when only one antibiotic was in the input data</li>
</ul>
</div>
</div>

View File

@ -10,7 +10,7 @@ articles:
WHONET: WHONET.html
benchmarks: benchmarks.html
resistance_predict: resistance_predict.html
last_built: 2020-06-16T23:38Z
last_built: 2020-06-17T13:03Z
urls:
reference: https://msberends.gitlab.io/AMR/reference
article: https://msberends.gitlab.io/AMR/articles

View File

@ -82,7 +82,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>
@ -235,7 +235,9 @@
<p>Use these selection helpers inside any function that allows <a href='https://tidyselect.r-lib.org/reference/language.html'>Tidyverse selections</a>, like <code><a href='https://dplyr.tidyverse.org/reference/select.html'>dplyr::select()</a></code> or <code><a href='https://tidyr.tidyverse.org/reference/pivot_longer.html'>tidyr::pivot_longer()</a></code>. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.</p>
</div>
<pre class="usage"><span class='fu'>aminoglycosides</span>()
<pre class="usage"><span class='fu'>ab_class</span>(<span class='no'>ab_class</span>)
<span class='fu'>aminoglycosides</span>()
<span class='fu'>carbapenems</span>()
@ -261,6 +263,14 @@
<span class='fu'>tetracyclines</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>ab_class</th>
<td><p>an antimicrobial class, like <code>"carbapenems"</code>. The columns <code>group</code>, <code>atc_group1</code> and <code>atc_group2</code> of the <a href='antibiotics.html'>antibiotics</a> data set will be searched (case-insensitive) for this value.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
@ -277,11 +287,22 @@
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='fu'>carbapenems</span>())
<span class='co'># this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>mo</span>, <span class='fu'>aminoglycosides</span>())
<span class='co'># this will select columns 'mo' and all antimycobacterial drugs ('RIF'):</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>mo</span>, <span class='fu'>ab_class</span>(<span class='st'>"mycobact"</span>))
<span class='co'># get bug/drug combinations for only macrolides in Gram-positives:</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_gramstain</a></span>(<span class='no'>mo</span>) <span class='kw'>%like%</span> <span class='st'>"pos"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>mo</span>, <span class='fu'>macrolides</span>()) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='bug_drug_combinations.html'>bug_drug_combinations</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://rdrr.io/r/base/format.html'>format</a></span>()
<span class='fu'><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></span>(<span class='kw'>irrelevant</span> <span class='kw'>=</span> <span class='st'>"value"</span>,
<span class='kw'>J01CA01</span> <span class='kw'>=</span> <span class='st'>"S"</span>) <span class='kw'>%&gt;%</span> <span class='co'># ATC code of ampicillin</span>

View File

@ -82,7 +82,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">1.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>
@ -425,7 +425,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
<span class='kw'>if</span> (<span class='fl'>FALSE</span>) {
<span class='no'>df</span>$<span class='no'>mo</span> <span class='kw'>&lt;-</span> <span class='fu'>as.mo</span>(<span class='no'>df</span>$<span class='no'>microorganism_name</span>)
<span class='co'># the select function of tidyverse is also supported:</span>
<span class='co'># the select function of the Tidyverse is also supported:</span>
<span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>df</span>$<span class='no'>mo</span> <span class='kw'>&lt;-</span> <span class='no'>df</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>microorganism_name</span>) <span class='kw'>%&gt;%</span>

View File

@ -81,7 +81,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">1.2.0.9007</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>
@ -420,6 +420,12 @@
<td><p>Principal Component Analysis (for AMR)</p></td>
</tr><tr>
<td>
<p><code><a href="antibiotic_class_selectors.html">ab_class()</a></code> <code><a href="antibiotic_class_selectors.html">aminoglycosides()</a></code> <code><a href="antibiotic_class_selectors.html">carbapenems()</a></code> <code><a href="antibiotic_class_selectors.html">cephalosporins()</a></code> <code><a href="antibiotic_class_selectors.html">cephalosporins_1st()</a></code> <code><a href="antibiotic_class_selectors.html">cephalosporins_2nd()</a></code> <code><a href="antibiotic_class_selectors.html">cephalosporins_3rd()</a></code> <code><a href="antibiotic_class_selectors.html">cephalosporins_4th()</a></code> <code><a href="antibiotic_class_selectors.html">cephalosporins_5th()</a></code> <code><a href="antibiotic_class_selectors.html">fluoroquinolones()</a></code> <code><a href="antibiotic_class_selectors.html">glycopeptides()</a></code> <code><a href="antibiotic_class_selectors.html">macrolides()</a></code> <code><a href="antibiotic_class_selectors.html">penicillins()</a></code> <code><a href="antibiotic_class_selectors.html">tetracyclines()</a></code> </p>
</td>
<td><p>Antibiotic class selectors</p></td>
</tr><tr>
<td>
<p><code><a href="filter_ab_class.html">filter_ab_class()</a></code> <code><a href="filter_ab_class.html">filter_aminoglycosides()</a></code> <code><a href="filter_ab_class.html">filter_carbapenems()</a></code> <code><a href="filter_ab_class.html">filter_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_1st_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_2nd_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_3rd_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_4th_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_5th_cephalosporins()</a></code> <code><a href="filter_ab_class.html">filter_fluoroquinolones()</a></code> <code><a href="filter_ab_class.html">filter_glycopeptides()</a></code> <code><a href="filter_ab_class.html">filter_macrolides()</a></code> <code><a href="filter_ab_class.html">filter_penicillins()</a></code> <code><a href="filter_ab_class.html">filter_tetracyclines()</a></code> </p>
</td>

View File

@ -49,9 +49,9 @@
<script src="../extra.js"></script>
<meta property="og:title" content="Lifecycles of functions in the <code>AMR</code> package — lifecycle" />
<meta property="og:description" content="Functions in this AMR package are categorised using the lifecycle circle of the tidyverse as found on www.tidyverse.org/lifecycle.
<meta property="og:description" content="Functions in this AMR package are categorised using the lifecycle circle of the Tidyverse as found on www.tidyverse.org/lifecycle.
This page contains a section for every lifecycle (with text borrowed from the aforementioned tidyverse website), so they can be used in the manual pages of the functions." />
This page contains a section for every lifecycle (with text borrowed from the aforementioned Tidyverse website), so they can be used in the manual pages of the functions." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.svg" />
@ -84,7 +84,7 @@ This page contains a section for every lifecycle (with text borrowed from the af
</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">1.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>
@ -234,9 +234,9 @@ This page contains a section for every lifecycle (with text borrowed from the af
</div>
<div class="ref-description">
<p>Functions in this <code>AMR</code> package are categorised using <a href='https://www.tidyverse.org/lifecycle'>the lifecycle circle of the <code>tidyverse</code> as found on www.tidyverse.org/lifecycle</a>.</p>
<p><img src='figures/lifecycle_tidyverse.svg' height=200px style=margin-bottom:5px /> <br />
This page contains a section for every lifecycle (with text borrowed from the aforementioned <code>tidyverse</code> website), so they can be used in the manual pages of the functions.</p>
<p>Functions in this <code>AMR</code> package are categorised using <a href='https://www.Tidyverse.org/lifecycle'>the lifecycle circle of the Tidyverse as found on www.tidyverse.org/lifecycle</a>.</p>
<p><img src='figures/lifecycle_Tidyverse.svg' height=200px style=margin-bottom:5px /> <br />
This page contains a section for every lifecycle (with text borrowed from the aforementioned Tidyverse website), so they can be used in the manual pages of the functions.</p>
</div>

View File

@ -83,7 +83,7 @@ resistance() should be used to calculate resistance, susceptibility() should be
</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">1.2.0</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.2.0.9008</span>
</span>
</div>
@ -322,7 +322,7 @@ resistance() should be used to calculate resistance, susceptibility() should be
<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>][AMR::count()] functions to count isolates. The function <code>susceptibility()</code> is essentially equal to <code>count_susceptible() / count_all()</code>. <em>Low counts can influence 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>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 influence 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><a href='as.rsi.html'>rsi</a></code> class (created with <code><a href='as.rsi.html'>as.rsi()</a></code>) and calculates the proportions R, I and S. It also supports grouped variables. 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>
@ -410,7 +410,7 @@ A microorganism is categorised as <em>Susceptible, Increased exposure</em> when
<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='kw'>total</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/context.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>

View File

@ -2,6 +2,7 @@
% Please edit documentation in R/ab_class_selectors.R
\name{antibiotic_class_selectors}
\alias{antibiotic_class_selectors}
\alias{ab_class}
\alias{aminoglycosides}
\alias{carbapenems}
\alias{cephalosporins}
@ -17,6 +18,8 @@
\alias{tetracyclines}
\title{Antibiotic class selectors}
\usage{
ab_class(ab_class)
aminoglycosides()
carbapenems()
@ -43,6 +46,9 @@ penicillins()
tetracyclines()
}
\arguments{
\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.}
}
\description{
Use these selection helpers inside any function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selections}, like \code{dplyr::select()} or \code{tidyr::pivot_longer()}. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
}
@ -58,16 +64,27 @@ if (require("dplyr")) {
example_isolates \%>\%
select(carbapenems())
# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
example_isolates \%>\%
select(mo, aminoglycosides())
# this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
example_isolates \%>\%
select(mo, ab_class("mycobact"))
# get bug/drug combinations for only macrolides in Gram-positives:
example_isolates \%>\%
filter(mo_gramstain(mo) \%like\% "pos") \%>\%
select(mo, macrolides()) \%>\%
bug_drug_combinations() \%>\%
format()
data.frame(irrelevant = "value",
J01CA01 = "S") \%>\% # ATC code of ampicillin
select(penicillins()) # so the 'J01CA01' column is selected
}
}
\seealso{

View File

@ -192,7 +192,7 @@ mo_gramstain("E. coli") # returns "Gram negative"
\dontrun{
df$mo <- as.mo(df$microorganism_name)
# the select function of tidyverse is also supported:
# the select function of the Tidyverse is also supported:
library(dplyr)
df$mo <- df \%>\%
select(microorganism_name) \%>\%

View File

@ -4,10 +4,10 @@
\alias{lifecycle}
\title{Lifecycles of functions in the \code{AMR} package}
\description{
Functions in this \code{AMR} package are categorised using \href{https://www.tidyverse.org/lifecycle}{the lifecycle circle of the \code{tidyverse} as found on www.tidyverse.org/lifecycle}.
Functions in this \code{AMR} package are categorised using \href{https://www.Tidyverse.org/lifecycle}{the lifecycle circle of the Tidyverse as found on www.tidyverse.org/lifecycle}.
\if{html}{\figure{lifecycle_tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
This page contains a section for every lifecycle (with text borrowed from the aforementioned \code{tidyverse} website), so they can be used in the manual pages of the functions.
\if{html}{\figure{lifecycle_Tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
This page contains a section for every lifecycle (with text borrowed from the aforementioned Tidyverse website), so they can be used in the manual pages of the functions.
}
\section{Experimental lifecycle}{

View File

@ -83,7 +83,7 @@ The function \code{\link[=resistance]{resistance()}} is equal to the function \c
\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]{first_isolate()}} to determine them in your data set.
These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{count()}][AMR::count()] functions to count isolates. The function \code{\link[=susceptibility]{susceptibility()}} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can influence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (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]{count()}} functions to count isolates. The function \code{\link[=susceptibility]{susceptibility()}} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can influence 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{\link[=proportion_df]{proportion_df()}} takes any variable from \code{data} that has an \code{\link{rsi}} class (created with \code{\link[=as.rsi]{as.rsi()}}) and calculates the proportions R, I and S. It also supports grouped variables. The function \code{\link[=rsi_df]{rsi_df()}} works exactly like \code{\link[=proportion_df]{proportion_df()}}, but adds the number of isolates.
}

View File

@ -190,7 +190,7 @@ Finally, we will apply [EUCAST rules](http://www.eucast.org/expert_rules_and_int
Because the amoxicillin (column `AMX`) and amoxicillin/clavulanic acid (column `AMC`) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The `eucast_rules()` fixes this:
```{r eucast, warning = FALSE, message = FALSE}
data <- eucast_rules(data, col_mo = "bacteria")
data <- eucast_rules(data, col_mo = "bacteria", rules = "all")
```
# Adding new variables
@ -332,6 +332,41 @@ data_1st %>%
freq(genus, species, header = TRUE)
```
## Overview of different bug/drug combinations
If you want to get a quick glance of the number of isolates in different bug/drug combinations, you can use the `bug_drug_combinations()` function:
```{r bug_drg 1a, eval = FALSE}
data_1st %>%
bug_drug_combinations() %>%
head() # show first 6 rows
```
```{r bug_drg 1b, echo = FALSE, results = 'asis'}
knitr::kable(data_1st %>%
bug_drug_combinations() %>%
head(),
align = "c")
```
Using [Tidyverse selections](https://tidyselect.r-lib.org/reference/language.html), you can also select columns based on the antibiotic class they are in:
```{r bug_drg 2a, eval = FALSE}
data_1st %>%
select(bacteria, fluoroquinolones()) %>%
bug_drug_combinations()
```
```{r bug_drg 2b, echo = FALSE, results = 'asis'}
knitr::kable(data_1st %>%
select(bacteria, fluoroquinolones()) %>%
bug_drug_combinations(),
align = "c")
```
This will only give you the crude numbers in the data. To calculate antimicrobial resistance, we use the `resistance()` and `susceptibility()` functions.
## Resistance percentages
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.