1
0
mirror of https://github.com/msberends/AMR.git synced 2025-02-22 18:30:07 +01:00

(v2.1.1.9151) update readme

This commit is contained in:
dr. M.S. (Matthijs) Berends 2025-02-15 20:53:12 +01:00
parent 9650545d6e
commit ef02f4a7f2
No known key found for this signature in database
15 changed files with 181 additions and 139 deletions

View File

@ -1,5 +1,5 @@
Package: AMR Package: AMR
Version: 2.1.1.9150 Version: 2.1.1.9151
Date: 2025-02-15 Date: 2025-02-15
Title: Antimicrobial Resistance Data Analysis Title: Antimicrobial Resistance Data Analysis
Description: Functions to simplify and standardise antimicrobial resistance (AMR) Description: Functions to simplify and standardise antimicrobial resistance (AMR)

View File

@ -1,4 +1,4 @@
# AMR 2.1.1.9150 # AMR 2.1.1.9151
*(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)*

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.2 Metadata-Version: 2.2
Name: AMR Name: AMR
Version: 2.1.1.9150 Version: 2.1.1.9151
Summary: A Python wrapper for the AMR R package Summary: A Python wrapper for the AMR R package
Home-page: https://github.com/msberends/AMR Home-page: https://github.com/msberends/AMR
Author: Matthijs Berends Author: Matthijs Berends

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@ from setuptools import setup, find_packages
setup( setup(
name='AMR', name='AMR',
version='2.1.1.9150', version='2.1.1.9151',
packages=find_packages(), packages=find_packages(),
install_requires=[ install_requires=[
'rpy2', 'rpy2',

View File

@ -55,8 +55,8 @@
#' @section Full list of supported (antimicrobial) classes: #' @section Full list of supported (antimicrobial) classes:
#' #'
#' `r paste0(" * ", na.omit(sapply(DEFINED_AB_GROUPS, function(ab) ifelse(tolower(gsub("^AB_", "", ab)) %in% ls(envir = asNamespace("AMR")), paste0("[", tolower(gsub("^AB_", "", ab)), "()] can select: \\cr ", vector_and(paste0(ab_name(eval(parse(text = ab), envir = asNamespace("AMR")), language = NULL, tolower = TRUE), " (", eval(parse(text = ab), envir = asNamespace("AMR")), ")"), quotes = FALSE, sort = TRUE)), character(0)), USE.NAMES = FALSE)), "\n", collapse = "")` #' `r paste0(" * ", na.omit(sapply(DEFINED_AB_GROUPS, function(ab) ifelse(tolower(gsub("^AB_", "", ab)) %in% ls(envir = asNamespace("AMR")), paste0("[", tolower(gsub("^AB_", "", ab)), "()] can select: \\cr ", vector_and(paste0(ab_name(eval(parse(text = ab), envir = asNamespace("AMR")), language = NULL, tolower = TRUE), " (", eval(parse(text = ab), envir = asNamespace("AMR")), ")"), quotes = FALSE, sort = TRUE)), character(0)), USE.NAMES = FALSE)), "\n", collapse = "")`
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @name antimicrobial_class_selectors #' @name antimicrobial_selectors
#' @return When used inside selecting or filtering, this returns a [character] vector of column names, with additional class `"amr_selector"`. When used individually, this returns an ['ab' vector][as.ab()] with all possible antimicrobials that the function would be able to select or filter. #' @return When used inside selecting or filtering, this returns a [character] vector of column names, with additional class `"amr_selector"`. When used individually, this returns an ['ab' vector][as.ab()] with all possible antimicrobials that the function would be able to select or filter.
#' @export #' @export
#' @inheritSection AMR Reference Data Publicly Available #' @inheritSection AMR Reference Data Publicly Available
@ -243,7 +243,7 @@ amr_class <- function(amr_class,
amr_select_exec(NULL, only_sir_columns = only_sir_columns, amr_class_args = amr_class, only_treatable = only_treatable, return_all = return_all) amr_select_exec(NULL, only_sir_columns = only_sir_columns, amr_class_args = amr_class, only_treatable = only_treatable, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @details The [amr_selector()] function can be used to internally filter the [antibiotics] data set on any results, see *Examples*. It allows for filtering on a (part of) a certain name, and/or a group name or even a minimum of DDDs for oral treatment. This function yields the highest flexibility, but is also the least user-friendly, since it requires a hard-coded filter to set. #' @details The [amr_selector()] function can be used to internally filter the [antibiotics] data set on any results, see *Examples*. It allows for filtering on a (part of) a certain name, and/or a group name or even a minimum of DDDs for oral treatment. This function yields the highest flexibility, but is also the least user-friendly, since it requires a hard-coded filter to set.
#' @export #' @export
amr_selector <- function(filter, amr_selector <- function(filter,
@ -280,7 +280,7 @@ amr_selector <- function(filter,
) )
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
aminoglycosides <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) { aminoglycosides <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -289,7 +289,7 @@ aminoglycosides <- function(only_sir_columns = FALSE, only_treatable = TRUE, ret
amr_select_exec("aminoglycosides", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all) amr_select_exec("aminoglycosides", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
aminopenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { aminopenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -297,7 +297,7 @@ aminopenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("aminopenicillins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("aminopenicillins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
antifungals <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { antifungals <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -305,7 +305,7 @@ antifungals <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("antifungals", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("antifungals", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
antimycobacterials <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { antimycobacterials <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -313,7 +313,7 @@ antimycobacterials <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("antimycobacterials", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("antimycobacterials", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
betalactams <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) { betalactams <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -322,7 +322,7 @@ betalactams <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_
amr_select_exec("betalactams", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all) amr_select_exec("betalactams", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
betalactams_with_inhibitor <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { betalactams_with_inhibitor <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -330,7 +330,7 @@ betalactams_with_inhibitor <- function(only_sir_columns = FALSE, return_all = TR
amr_select_exec("betalactams_with_inhibitor", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("betalactams_with_inhibitor", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
carbapenems <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) { carbapenems <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -339,7 +339,7 @@ carbapenems <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_
amr_select_exec("carbapenems", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all) amr_select_exec("carbapenems", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
cephalosporins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { cephalosporins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -347,7 +347,7 @@ cephalosporins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("cephalosporins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("cephalosporins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
cephalosporins_1st <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { cephalosporins_1st <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -355,7 +355,7 @@ cephalosporins_1st <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("cephalosporins_1st", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("cephalosporins_1st", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
cephalosporins_2nd <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { cephalosporins_2nd <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -363,7 +363,7 @@ cephalosporins_2nd <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("cephalosporins_2nd", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("cephalosporins_2nd", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
cephalosporins_3rd <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { cephalosporins_3rd <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -371,7 +371,7 @@ cephalosporins_3rd <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("cephalosporins_3rd", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("cephalosporins_3rd", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
cephalosporins_4th <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { cephalosporins_4th <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -379,7 +379,7 @@ cephalosporins_4th <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("cephalosporins_4th", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("cephalosporins_4th", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
cephalosporins_5th <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { cephalosporins_5th <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -387,7 +387,7 @@ cephalosporins_5th <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("cephalosporins_5th", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("cephalosporins_5th", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
fluoroquinolones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { fluoroquinolones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -395,7 +395,7 @@ fluoroquinolones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("fluoroquinolones", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("fluoroquinolones", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
glycopeptides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { glycopeptides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -403,7 +403,7 @@ glycopeptides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("glycopeptides", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("glycopeptides", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
isoxazolylpenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { isoxazolylpenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -411,7 +411,7 @@ isoxazolylpenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, .
amr_select_exec("isoxazolylpenicillins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("isoxazolylpenicillins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
lincosamides <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) { lincosamides <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -420,7 +420,7 @@ lincosamides <- function(only_sir_columns = FALSE, only_treatable = TRUE, return
amr_select_exec("lincosamides", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all) amr_select_exec("lincosamides", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
lipoglycopeptides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { lipoglycopeptides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -428,7 +428,7 @@ lipoglycopeptides <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("lipoglycopeptides", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("lipoglycopeptides", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
macrolides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { macrolides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -436,7 +436,7 @@ macrolides <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("macrolides", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("macrolides", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
monobactams <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { monobactams <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -444,7 +444,7 @@ monobactams <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("monobactams", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("monobactams", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
nitrofurans <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { nitrofurans <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -452,7 +452,7 @@ nitrofurans <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("nitrofurans", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("nitrofurans", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
oxazolidinones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { oxazolidinones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -460,7 +460,7 @@ oxazolidinones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("oxazolidinones", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("oxazolidinones", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
penicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { penicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -468,7 +468,7 @@ penicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("penicillins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("penicillins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
phenicols <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { phenicols <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -476,7 +476,7 @@ phenicols <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("phenicols", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("phenicols", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
polymyxins <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) { polymyxins <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -485,7 +485,7 @@ polymyxins <- function(only_sir_columns = FALSE, only_treatable = TRUE, return_a
amr_select_exec("polymyxins", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all) amr_select_exec("polymyxins", only_sir_columns = only_sir_columns, only_treatable = only_treatable, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
quinolones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { quinolones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -493,7 +493,7 @@ quinolones <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("quinolones", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("quinolones", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
rifamycins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { rifamycins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -501,7 +501,7 @@ rifamycins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("rifamycins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("rifamycins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
streptogramins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { streptogramins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -509,7 +509,7 @@ streptogramins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("streptogramins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("streptogramins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
tetracyclines <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { tetracyclines <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -517,7 +517,7 @@ tetracyclines <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("tetracyclines", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("tetracyclines", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
trimethoprims <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { trimethoprims <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -525,7 +525,7 @@ trimethoprims <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
amr_select_exec("trimethoprims", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("trimethoprims", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
ureidopenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { ureidopenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -533,7 +533,7 @@ ureidopenicillins <- function(only_sir_columns = FALSE, return_all = TRUE, ...)
amr_select_exec("ureidopenicillins", only_sir_columns = only_sir_columns, return_all = return_all) amr_select_exec("ureidopenicillins", only_sir_columns = only_sir_columns, return_all = return_all)
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @details The [administrable_per_os()] and [administrable_iv()] functions also rely on the [antibiotics] data set - antimicrobials will be matched where a DDD (defined daily dose) for resp. oral and IV treatment is available in the [antibiotics] data set. #' @details The [administrable_per_os()] and [administrable_iv()] functions also rely on the [antibiotics] data set - antimicrobials will be matched where a DDD (defined daily dose) for resp. oral and IV treatment is available in the [antibiotics] data set.
#' @export #' @export
administrable_per_os <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { administrable_per_os <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
@ -575,7 +575,7 @@ administrable_per_os <- function(only_sir_columns = FALSE, return_all = TRUE, ..
) )
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @export #' @export
administrable_iv <- function(only_sir_columns = FALSE, return_all = TRUE, ...) { administrable_iv <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1) meet_criteria(only_sir_columns, allow_class = "logical", has_length = 1)
@ -602,7 +602,7 @@ administrable_iv <- function(only_sir_columns = FALSE, return_all = TRUE, ...) {
) )
} }
#' @rdname antimicrobial_class_selectors #' @rdname antimicrobial_selectors
#' @inheritParams eucast_rules #' @inheritParams eucast_rules
#' @details The [not_intrinsic_resistant()] function can be used to only select antimicrobials that pose no intrinsic resistance for the microorganisms in the data set. For example, if a data set contains only microorganism codes or names of *E. coli* and *K. pneumoniae* and contains a column "vancomycin", this column will be removed (or rather, unselected) using this function. It currently applies `r format_eucast_version_nr(names(EUCAST_VERSION_EXPERT_RULES[1]))` to determine intrinsic resistance, using the [eucast_rules()] function internally. Because of this determination, this function is quite slow in terms of performance. #' @details The [not_intrinsic_resistant()] function can be used to only select antimicrobials that pose no intrinsic resistance for the microorganisms in the data set. For example, if a data set contains only microorganism codes or names of *E. coli* and *K. pneumoniae* and contains a column "vancomycin", this column will be removed (or rather, unselected) using this function. It currently applies `r format_eucast_version_nr(names(EUCAST_VERSION_EXPERT_RULES[1]))` to determine intrinsic resistance, using the [eucast_rules()] function internally. Because of this determination, this function is quite slow in terms of performance.
#' @export #' @export

View File

@ -34,7 +34,7 @@
#' #'
#' Adhering to previously described approaches (see *Source*) and especially the Bayesian WISCA model (Weighted-Incidence Syndromic Combination Antibiogram) by Bielicki *et al.*, these functions provide flexible output formats including plots and tables, ideal for integration with R Markdown and Quarto reports. #' Adhering to previously described approaches (see *Source*) and especially the Bayesian WISCA model (Weighted-Incidence Syndromic Combination Antibiogram) by Bielicki *et al.*, these functions provide flexible output formats including plots and tables, ideal for integration with R Markdown and Quarto reports.
#' @param x a [data.frame] containing at least a column with microorganisms and columns with antimicrobial results (class 'sir', see [as.sir()]) #' @param x a [data.frame] containing at least a column with microorganisms and columns with antimicrobial results (class 'sir', see [as.sir()])
#' @param antibiotics vector of any antimicrobial name or code (will be evaluated with [as.ab()], column name of `x`, or (any combinations of) [antimicrobial selectors][antimicrobial_class_selectors] such as [aminoglycosides()] or [carbapenems()]. For combination antibiograms, this can also be set to values separated with `"+"`, such as `"TZP+TOB"` or `"cipro + genta"`, given that columns resembling such antimicrobials exist in `x`. See *Examples*. #' @param antibiotics vector of any antimicrobial name or code (will be evaluated with [as.ab()], column name of `x`, or (any combinations of) [antimicrobial selectors][antimicrobial_selectors] such as [aminoglycosides()] or [carbapenems()]. For combination antibiograms, this can also be set to values separated with `"+"`, such as `"TZP+TOB"` or `"cipro + genta"`, given that columns resembling such antimicrobials exist in `x`. See *Examples*.
#' @param mo_transform a character to transform microorganism input - must be `"name"`, `"shortname"` (default), `"gramstain"`, or one of the column names of the [microorganisms] data set: `r vector_or(colnames(microorganisms), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input or `NA` to consider all microorganisms 'unknown'. #' @param mo_transform a character to transform microorganism input - must be `"name"`, `"shortname"` (default), `"gramstain"`, or one of the column names of the [microorganisms] data set: `r vector_or(colnames(microorganisms), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input or `NA` to consider all microorganisms 'unknown'.
#' @param ab_transform a character to transform antimicrobial input - must be one of the column names of the [antibiotics] data set (defaults to `"name"`): `r vector_or(colnames(antibiotics), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input. #' @param ab_transform a character to transform antimicrobial input - must be one of the column names of the [antibiotics] data set (defaults to `"name"`): `r vector_or(colnames(antibiotics), sort = FALSE, quotes = TRUE)`. Can also be `NULL` to not transform the input.
#' @param syndromic_group a column name of `x`, or values calculated to split rows of `x`, e.g. by using [ifelse()] or [`case_when()`][dplyr::case_when()]. See *Examples*. #' @param syndromic_group a column name of `x`, or values calculated to split rows of `x`, e.g. by using [ifelse()] or [`case_when()`][dplyr::case_when()]. See *Examples*.

View File

@ -191,7 +191,7 @@ reference:
- "`key_antimicrobials`" - "`key_antimicrobials`"
- "`mdro`" - "`mdro`"
- "`bug_drug_combinations`" - "`bug_drug_combinations`"
- "`antimicrobial_class_selectors`" - "`antimicrobial_selectors`"
- "`top_n_microorganisms`" - "`top_n_microorganisms`"
- "`mean_amr_distance`" - "`mean_amr_distance`"
- "`resistance_predict`" - "`resistance_predict`"

View File

@ -1,6 +1,6 @@
This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse.
First and foremost, you are trained on version 2.1.1.9150. Remember this whenever someone asks which AMR package version youre at. First and foremost, you are trained on version 2.1.1.9151. Remember this whenever someone asks which AMR package version youre at.
Below are the contents of the file, the file, and all the files (documentation) in the package. Every file content is split using 100 hypens. Below are the contents of the file, the file, and all the files (documentation) in the package. Every file content is split using 100 hypens.
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
@ -430,7 +430,7 @@ With the help of contributors from all corners of the world, the `AMR` package i
#### Filtering and selecting data #### Filtering and selecting data
One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called [antimicrobial class selectors](https://msberends.github.io/AMR/reference/antimicrobial_class_selectors.html), which work in base R, `dplyr` and `data.table`: One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called [antimicrobial selectors](https://msberends.github.io/AMR/reference/antimicrobial_selectors.html), which work in base R, `dplyr` and `data.table`.
```r ```r
# AMR works great with dplyr, but it's not required or neccesary # AMR works great with dplyr, but it's not required or neccesary
@ -463,45 +463,29 @@ With only having defined a row filter on Gram-negative bacteria with intrinsic r
|*Pseudomonas aeruginosa* | S | S | S | R | | S | |*Pseudomonas aeruginosa* | S | S | S | R | | S |
|*Pseudomonas aeruginosa* | S | S | S | R | S | S | |*Pseudomonas aeruginosa* | S | S | S | R | S | S |
A base R equivalent would be:
```r
library(AMR)
example_isolates$bacteria <- mo_fullname(example_isolates$mo)
example_isolates[which(mo_is_gram_negative() &
mo_is_intrinsic_resistant(ab = "cefotax")),
c("bacteria", aminoglycosides(), carbapenems())]
```
This base R code will work in any version of R since April 2013 (R-3.0). Moreover, this code works identically with the `data.table` package, only by starting with:
```r
example_isolates <- data.table::as.data.table(example_isolates)
```
#### Generating antibiograms #### Generating antibiograms
The `AMR` package supports generating traditional, combined, syndromic, and even weighted-incidence syndromic combination antibiograms (WISCA). The `AMR` package supports generating traditional, combined, syndromic, and even weighted-incidence syndromic combination antibiograms (WISCA).
If used inside R Markdown or Quarto, the table will be printed in the right output format automatically (such as markdown, LaTeX, HTML, etc.). If used inside [R Markdown](https://rmarkdown.rstudio.com) or [Quarto](https://quarto.org), the table will be printed in the right output format automatically (such as markdown, LaTeX, HTML, etc.).
```r ```r
antibiogram(example_isolates, antibiogram(example_isolates,
antibiotics = c(aminoglycosides(), carbapenems())) antibiotics = c(aminoglycosides(), carbapenems()))
``` ```
| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | | Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin |
|:------------------------|:----------------:|:---------------:|:----------------:|:----------------:|:----------------:|:----------------:| |:-----------------|:--------------:|:--------------:|:--------------:|:----------:|:--------------:|:--------------:|
| CoNS | 0% (0/43) | 86% (267/309) | 52% (25/48) | 0% (0/43) | 52% (25/48) | 22% (12/55) | | CoNS | 0% (0-8%) | 86% (82-90%) | 52% (37-67%) | 0% (0-8%) | 52% (37-67%) | 22% (12-35%) |
| *E. coli* | 100% (171/171) | 98% (451/460) | 100% (422/422) | | 100% (418/418) | 97% (450/462) | | *E. coli* | 100% (98-100%) | 98% (96-99%) | 100% (99-100%) | | 100% (99-100%) | 97% (96-99%) |
| *E. faecalis* | 0% (0/39) | 0% (0/39) | 100% (38/38) | 0% (0/39) | | 0% (0/39) | | *E. faecalis* | 0% (0-9%) | 0% (0-9%) | 100% (91-100%) | 0% (0-9%) | | 0% (0-9%) |
| *K. pneumoniae* | | 90% (52/58) | 100% (51/51) | | 100% (53/53) | 90% (52/58) | | *K. pneumoniae* | | 90% (79-96%) | 100% (93-100%) | | 100% (93-100%) | 90% (79-96%) |
| *P. aeruginosa* | | 100% (30/30) | | 0% (0/30) | | 100% (30/30) | | *P. aeruginosa* | | 100% (88-100%) | | 0% (0-12%) | | 100% (88-100%) |
| *P. mirabilis* | | 94% (32/34) | 94% (30/32) | | | 94% (32/34) | | *P. mirabilis* | | 94% (80-99%) | 94% (79-99%) | | | 94% (80-99%) |
| *S. aureus* | | 99% (231/233) | | | | 98% (84/86) | | *S. aureus* | | 99% (97-100%) | | | | 98% (92-100%) |
| *S. epidermidis* | 0% (0/44) | 79% (128/163) | | 0% (0/44) | | 51% (45/89) | | *S. epidermidis* | 0% (0-8%) | 79% (71-85%) | | 0% (0-8%) | | 51% (40-61%) |
| *S. hominis* | | 92% (74/80) | | | | 85% (53/62) | | *S. hominis* | | 92% (84-97%) | | | | 85% (74-93%) |
| *S. pneumoniae* | 0% (0/117) | 0% (0/117) | | 0% (0/117) | | 0% (0/117) | | *S. pneumoniae* | 0% (0-3%) | 0% (0-3%) | | 0% (0-3%) | | 0% (0-3%) |
In combination antibiograms, it is clear that combined antibiotics yield higher empiric coverage: In combination antibiograms, it is clear that combined antibiotics yield higher empiric coverage:
@ -511,10 +495,10 @@ antibiogram(example_isolates,
mo_transform = "gramstain") mo_transform = "gramstain")
``` ```
| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | |Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|:--------------|:-----------------------:|:-------------------------------------:|:------------------------------------:| |:-------------|:-----------------------:|:------------------------------------:|:------------------------------------:|
| Gram-negative | 88% (565/641) | 99% (681/691) | 98% (679/693) | |Gram-negative | 88% (85-91%) | 99% (97-99%) | 98% (97-99%) |
| Gram-positive | 86% (296/345) | 98% (1018/1044) | 95% (524/550) | |Gram-positive | 86% (82-89%) | 98% (96-98%) | 95% (93-97%) |
Like many other functions in this package, `antibiogram()` comes with support for 20 languages that are often detected automatically based on system language: Like many other functions in this package, `antibiogram()` comes with support for 20 languages that are often detected automatically based on system language:
@ -526,10 +510,47 @@ antibiogram(example_isolates,
language = "uk") # Ukrainian language = "uk") # Ukrainian
``` ```
| Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин | |Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин |
|:---------------|:--------------------:|:-------------------:|:------------------:| |:-------------|:------------:|:------------:|:--------------:|
| Грамнегативні | 96% (659/684) | 96% (658/686) | 91% (621/684) | |Грамнегативні | 96% (95-98%) | 96% (94-97%) | 91% (88-93%) |
| Грампозитивні | 63% (740/1170) | 34% (228/665) | 77% (560/724) | |Грампозитивні | 63% (60-66%) | 34% (31-38%) | 77% (74-80%) |
#### Interpreting and plotting MIC and SIR values
The `AMR` package allows interpretation of MIC and disk diffusion values based on CLSI and EUCAST. Moreover, the `ggplot2` package is extended with new scale functions, to allow plotting of log2-distributed MIC values and SIR values.
```r
library(ggplot2)
library(AMR)
# generate some random values
some_mic_values <- random_mic(size = 100)
some_groups <- sample(LETTERS[1:5], 20, replace = TRUE)
interpretation <- as.sir(some_mic_values,
guideline = "EUCAST 2024",
mo = "E. coli", # or any code or name resembling a known species
ab = "Cipro") # or any code or name resembling an antibiotic
# create the plot
ggplot(data.frame(mic = some_mic_values,
group = some_groups,
sir = interpretation),
aes(x = group, y = mic, colour = sir)) +
theme_minimal() +
geom_boxplot(fill = NA, colour = "grey") +
geom_jitter(width = 0.25) +
# NEW scale function: plot MIC values to x, y, colour or fill
scale_y_mic() +
# NEW scale function: write out S/I/R in any of the 20 supported languages
# and set colourblind-friendly colours
scale_colour_sir()
```
<a href="./reference/plotting.html" title="Plotting Helpers for AMR Data Analysis">
<img src="./plot_readme.png" style="max-width: 600px;">
</a>
#### Calculating resistance per group #### Calculating resistance per group
@ -546,13 +567,13 @@ example_isolates %>%
conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) conf_int = function(x) sir_confidence_interval(x, collapse = "-"))))
``` ```
|ward | GEN_total_R|GEN_conf_int | TOB_total_R|TOB_conf_int | |ward | GEN_total_R | GEN_conf_int | TOB_total_R | TOB_conf_int |
|:---------:|:----------:|:-----------:|:----------:|:-----------:| |:----------|:-----------:|:------------:|:-----------:|:------------:|
|Clinical | 0.229 |0.205-0.254 | 0.315 |0.284-0.347 | |Clinical | 0.2289362 | 0.205-0.254 | 0.3147503 | 0.284-0.347 |
|ICU | 0.290 |0.253-0.330 | 0.400 |0.353-0.449 | |ICU | 0.2902655 | 0.253-0.33 | 0.4004739 | 0.353-0.449 |
|Outpatient | 0.200 |0.131-0.285 | 0.368 |0.254-0.493 | |Outpatient | 0.2000000 | 0.131-0.285 | 0.3676471 | 0.254-0.493 |
Or use [antimicrobial class selectors](https://msberends.github.io/AMR/reference/antimicrobial_class_selectors.html) to select a series of antibiotic columns: Or use [antimicrobial selectors](https://msberends.github.io/AMR/reference/antimicrobial_selectors.html) to select a series of antibiotic columns:
```r ```r
library(AMR) library(AMR)
@ -1679,7 +1700,7 @@ retrieve_wisca_parameters(wisca_model, ...)
\arguments{ \arguments{
\item{x}{a \link{data.frame} containing at least a column with microorganisms and columns with antimicrobial results (class 'sir', see \code{\link[=as.sir]{as.sir()}})} \item{x}{a \link{data.frame} containing at least a column with microorganisms and columns with antimicrobial results (class 'sir', see \code{\link[=as.sir]{as.sir()}})}
\item{antibiotics}{vector of any antimicrobial name or code (will be evaluated with \code{\link[=as.ab]{as.ab()}}, column name of \code{x}, or (any combinations of) \link[=antimicrobial_class_selectors]{antimicrobial selectors} such as \code{\link[=aminoglycosides]{aminoglycosides()}} or \code{\link[=carbapenems]{carbapenems()}}. For combination antibiograms, this can also be set to values separated with \code{"+"}, such as \code{"TZP+TOB"} or \code{"cipro + genta"}, given that columns resembling such antimicrobials exist in \code{x}. See \emph{Examples}.} \item{antibiotics}{vector of any antimicrobial name or code (will be evaluated with \code{\link[=as.ab]{as.ab()}}, column name of \code{x}, or (any combinations of) \link[=antimicrobial_selectors]{antimicrobial selectors} such as \code{\link[=aminoglycosides]{aminoglycosides()}} or \code{\link[=carbapenems]{carbapenems()}}. For combination antibiograms, this can also be set to values separated with \code{"+"}, such as \code{"TZP+TOB"} or \code{"cipro + genta"}, given that columns resembling such antimicrobials exist in \code{x}. See \emph{Examples}.}
\item{mo_transform}{a character to transform microorganism input - must be \code{"name"}, \code{"shortname"} (default), \code{"gramstain"}, or one of the column names of the \link{microorganisms} data set: "mo", "fullname", "status", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "rank", "ref", "oxygen_tolerance", "source", "lpsn", "lpsn_parent", "lpsn_renamed_to", "mycobank", "mycobank_parent", "mycobank_renamed_to", "gbif", "gbif_parent", "gbif_renamed_to", "prevalence", or "snomed". Can also be \code{NULL} to not transform the input or \code{NA} to consider all microorganisms 'unknown'.} \item{mo_transform}{a character to transform microorganism input - must be \code{"name"}, \code{"shortname"} (default), \code{"gramstain"}, or one of the column names of the \link{microorganisms} data set: "mo", "fullname", "status", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "rank", "ref", "oxygen_tolerance", "source", "lpsn", "lpsn_parent", "lpsn_renamed_to", "mycobank", "mycobank_parent", "mycobank_renamed_to", "gbif", "gbif_parent", "gbif_renamed_to", "prevalence", or "snomed". Can also be \code{NULL} to not transform the input or \code{NA} to consider all microorganisms 'unknown'.}
@ -2164,13 +2185,13 @@ antivirals
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'man/antimicrobial_class_selectors.Rd': THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'man/antimicrobial_selectors.Rd':
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/amr_selectors.R % Please edit documentation in R/amr_selectors.R
\name{antimicrobial_class_selectors} \name{antimicrobial_selectors}
\alias{antimicrobial_class_selectors} \alias{antimicrobial_selectors}
\alias{amr_class} \alias{amr_class}
\alias{amr_selector} \alias{amr_selector}
\alias{aminoglycosides} \alias{aminoglycosides}

109
index.md
View File

@ -40,7 +40,7 @@ With the help of contributors from all corners of the world, the `AMR` package i
#### Filtering and selecting data #### Filtering and selecting data
One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called [antimicrobial class selectors](https://msberends.github.io/AMR/reference/antimicrobial_class_selectors.html), which work in base R, `dplyr` and `data.table`: One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called [antimicrobial selectors](https://msberends.github.io/AMR/reference/antimicrobial_selectors.html), which work in base R, `dplyr` and `data.table`.
```r ```r
# AMR works great with dplyr, but it's not required or neccesary # AMR works great with dplyr, but it's not required or neccesary
@ -73,45 +73,29 @@ With only having defined a row filter on Gram-negative bacteria with intrinsic r
|*Pseudomonas aeruginosa* | S | S | S | R | | S | |*Pseudomonas aeruginosa* | S | S | S | R | | S |
|*Pseudomonas aeruginosa* | S | S | S | R | S | S | |*Pseudomonas aeruginosa* | S | S | S | R | S | S |
A base R equivalent would be:
```r
library(AMR)
example_isolates$bacteria <- mo_fullname(example_isolates$mo)
example_isolates[which(mo_is_gram_negative() &
mo_is_intrinsic_resistant(ab = "cefotax")),
c("bacteria", aminoglycosides(), carbapenems())]
```
This base R code will work in any version of R since April 2013 (R-3.0). Moreover, this code works identically with the `data.table` package, only by starting with:
```r
example_isolates <- data.table::as.data.table(example_isolates)
```
#### Generating antibiograms #### Generating antibiograms
The `AMR` package supports generating traditional, combined, syndromic, and even weighted-incidence syndromic combination antibiograms (WISCA). The `AMR` package supports generating traditional, combined, syndromic, and even weighted-incidence syndromic combination antibiograms (WISCA).
If used inside R Markdown or Quarto, the table will be printed in the right output format automatically (such as markdown, LaTeX, HTML, etc.). If used inside [R Markdown](https://rmarkdown.rstudio.com) or [Quarto](https://quarto.org), the table will be printed in the right output format automatically (such as markdown, LaTeX, HTML, etc.).
```r ```r
antibiogram(example_isolates, antibiogram(example_isolates,
antibiotics = c(aminoglycosides(), carbapenems())) antibiotics = c(aminoglycosides(), carbapenems()))
``` ```
| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | | Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin |
|:------------------------|:----------------:|:---------------:|:----------------:|:----------------:|:----------------:|:----------------:| |:-----------------|:--------------:|:--------------:|:--------------:|:----------:|:--------------:|:--------------:|
| CoNS | 0% (0/43) | 86% (267/309) | 52% (25/48) | 0% (0/43) | 52% (25/48) | 22% (12/55) | | CoNS | 0% (0-8%) | 86% (82-90%) | 52% (37-67%) | 0% (0-8%) | 52% (37-67%) | 22% (12-35%) |
| *E. coli* | 100% (171/171) | 98% (451/460) | 100% (422/422) | | 100% (418/418) | 97% (450/462) | | *E. coli* | 100% (98-100%) | 98% (96-99%) | 100% (99-100%) | | 100% (99-100%) | 97% (96-99%) |
| *E. faecalis* | 0% (0/39) | 0% (0/39) | 100% (38/38) | 0% (0/39) | | 0% (0/39) | | *E. faecalis* | 0% (0-9%) | 0% (0-9%) | 100% (91-100%) | 0% (0-9%) | | 0% (0-9%) |
| *K. pneumoniae* | | 90% (52/58) | 100% (51/51) | | 100% (53/53) | 90% (52/58) | | *K. pneumoniae* | | 90% (79-96%) | 100% (93-100%) | | 100% (93-100%) | 90% (79-96%) |
| *P. aeruginosa* | | 100% (30/30) | | 0% (0/30) | | 100% (30/30) | | *P. aeruginosa* | | 100% (88-100%) | | 0% (0-12%) | | 100% (88-100%) |
| *P. mirabilis* | | 94% (32/34) | 94% (30/32) | | | 94% (32/34) | | *P. mirabilis* | | 94% (80-99%) | 94% (79-99%) | | | 94% (80-99%) |
| *S. aureus* | | 99% (231/233) | | | | 98% (84/86) | | *S. aureus* | | 99% (97-100%) | | | | 98% (92-100%) |
| *S. epidermidis* | 0% (0/44) | 79% (128/163) | | 0% (0/44) | | 51% (45/89) | | *S. epidermidis* | 0% (0-8%) | 79% (71-85%) | | 0% (0-8%) | | 51% (40-61%) |
| *S. hominis* | | 92% (74/80) | | | | 85% (53/62) | | *S. hominis* | | 92% (84-97%) | | | | 85% (74-93%) |
| *S. pneumoniae* | 0% (0/117) | 0% (0/117) | | 0% (0/117) | | 0% (0/117) | | *S. pneumoniae* | 0% (0-3%) | 0% (0-3%) | | 0% (0-3%) | | 0% (0-3%) |
In combination antibiograms, it is clear that combined antibiotics yield higher empiric coverage: In combination antibiograms, it is clear that combined antibiotics yield higher empiric coverage:
@ -121,10 +105,10 @@ antibiogram(example_isolates,
mo_transform = "gramstain") mo_transform = "gramstain")
``` ```
| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | |Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|:--------------|:-----------------------:|:-------------------------------------:|:------------------------------------:| |:-------------|:-----------------------:|:------------------------------------:|:------------------------------------:|
| Gram-negative | 88% (565/641) | 99% (681/691) | 98% (679/693) | |Gram-negative | 88% (85-91%) | 99% (97-99%) | 98% (97-99%) |
| Gram-positive | 86% (296/345) | 98% (1018/1044) | 95% (524/550) | |Gram-positive | 86% (82-89%) | 98% (96-98%) | 95% (93-97%) |
Like many other functions in this package, `antibiogram()` comes with support for 20 languages that are often detected automatically based on system language: Like many other functions in this package, `antibiogram()` comes with support for 20 languages that are often detected automatically based on system language:
@ -136,10 +120,47 @@ antibiogram(example_isolates,
language = "uk") # Ukrainian language = "uk") # Ukrainian
``` ```
| Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин | |Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин |
|:---------------|:--------------------:|:-------------------:|:------------------:| |:-------------|:------------:|:------------:|:--------------:|
| Грамнегативні | 96% (659/684) | 96% (658/686) | 91% (621/684) | |Грамнегативні | 96% (95-98%) | 96% (94-97%) | 91% (88-93%) |
| Грампозитивні | 63% (740/1170) | 34% (228/665) | 77% (560/724) | |Грампозитивні | 63% (60-66%) | 34% (31-38%) | 77% (74-80%) |
#### Interpreting and plotting MIC and SIR values
The `AMR` package allows interpretation of MIC and disk diffusion values based on CLSI and EUCAST. Moreover, the `ggplot2` package is extended with new scale functions, to allow plotting of log2-distributed MIC values and SIR values.
```r
library(ggplot2)
library(AMR)
# generate some random values
some_mic_values <- random_mic(size = 100)
some_groups <- sample(LETTERS[1:5], 20, replace = TRUE)
interpretation <- as.sir(some_mic_values,
guideline = "EUCAST 2024",
mo = "E. coli", # or any code or name resembling a known species
ab = "Cipro") # or any code or name resembling an antibiotic
# create the plot
ggplot(data.frame(mic = some_mic_values,
group = some_groups,
sir = interpretation),
aes(x = group, y = mic, colour = sir)) +
theme_minimal() +
geom_boxplot(fill = NA, colour = "grey") +
geom_jitter(width = 0.25) +
# NEW scale function: plot MIC values to x, y, colour or fill
scale_y_mic() +
# NEW scale function: write out S/I/R in any of the 20 supported languages
# and set colourblind-friendly colours
scale_colour_sir()
```
<a href="./reference/plotting.html" title="Plotting Helpers for AMR Data Analysis">
<img src="./plot_readme.png" style="max-width: 600px;">
</a>
#### Calculating resistance per group #### Calculating resistance per group
@ -156,13 +177,13 @@ example_isolates %>%
conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) conf_int = function(x) sir_confidence_interval(x, collapse = "-"))))
``` ```
|ward | GEN_total_R|GEN_conf_int | TOB_total_R|TOB_conf_int | |ward | GEN_total_R | GEN_conf_int | TOB_total_R | TOB_conf_int |
|:---------:|:----------:|:-----------:|:----------:|:-----------:| |:----------|:-----------:|:------------:|:-----------:|:------------:|
|Clinical | 0.229 |0.205-0.254 | 0.315 |0.284-0.347 | |Clinical | 0.2289362 | 0.205-0.254 | 0.3147503 | 0.284-0.347 |
|ICU | 0.290 |0.253-0.330 | 0.400 |0.353-0.449 | |ICU | 0.2902655 | 0.253-0.33 | 0.4004739 | 0.353-0.449 |
|Outpatient | 0.200 |0.131-0.285 | 0.368 |0.254-0.493 | |Outpatient | 0.2000000 | 0.131-0.285 | 0.3676471 | 0.254-0.493 |
Or use [antimicrobial class selectors](https://msberends.github.io/AMR/reference/antimicrobial_class_selectors.html) to select a series of antibiotic columns: Or use [antimicrobial selectors](https://msberends.github.io/AMR/reference/antimicrobial_selectors.html) to select a series of antibiotic columns:
```r ```r
library(AMR) library(AMR)

View File

@ -48,7 +48,7 @@ retrieve_wisca_parameters(wisca_model, ...)
\arguments{ \arguments{
\item{x}{a \link{data.frame} containing at least a column with microorganisms and columns with antimicrobial results (class 'sir', see \code{\link[=as.sir]{as.sir()}})} \item{x}{a \link{data.frame} containing at least a column with microorganisms and columns with antimicrobial results (class 'sir', see \code{\link[=as.sir]{as.sir()}})}
\item{antibiotics}{vector of any antimicrobial name or code (will be evaluated with \code{\link[=as.ab]{as.ab()}}, column name of \code{x}, or (any combinations of) \link[=antimicrobial_class_selectors]{antimicrobial selectors} such as \code{\link[=aminoglycosides]{aminoglycosides()}} or \code{\link[=carbapenems]{carbapenems()}}. For combination antibiograms, this can also be set to values separated with \code{"+"}, such as \code{"TZP+TOB"} or \code{"cipro + genta"}, given that columns resembling such antimicrobials exist in \code{x}. See \emph{Examples}.} \item{antibiotics}{vector of any antimicrobial name or code (will be evaluated with \code{\link[=as.ab]{as.ab()}}, column name of \code{x}, or (any combinations of) \link[=antimicrobial_selectors]{antimicrobial selectors} such as \code{\link[=aminoglycosides]{aminoglycosides()}} or \code{\link[=carbapenems]{carbapenems()}}. For combination antibiograms, this can also be set to values separated with \code{"+"}, such as \code{"TZP+TOB"} or \code{"cipro + genta"}, given that columns resembling such antimicrobials exist in \code{x}. See \emph{Examples}.}
\item{mo_transform}{a character to transform microorganism input - must be \code{"name"}, \code{"shortname"} (default), \code{"gramstain"}, or one of the column names of the \link{microorganisms} data set: "mo", "fullname", "status", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "rank", "ref", "oxygen_tolerance", "source", "lpsn", "lpsn_parent", "lpsn_renamed_to", "mycobank", "mycobank_parent", "mycobank_renamed_to", "gbif", "gbif_parent", "gbif_renamed_to", "prevalence", or "snomed". Can also be \code{NULL} to not transform the input or \code{NA} to consider all microorganisms 'unknown'.} \item{mo_transform}{a character to transform microorganism input - must be \code{"name"}, \code{"shortname"} (default), \code{"gramstain"}, or one of the column names of the \link{microorganisms} data set: "mo", "fullname", "status", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "rank", "ref", "oxygen_tolerance", "source", "lpsn", "lpsn_parent", "lpsn_renamed_to", "mycobank", "mycobank_parent", "mycobank_renamed_to", "gbif", "gbif_parent", "gbif_renamed_to", "prevalence", or "snomed". Can also be \code{NULL} to not transform the input or \code{NA} to consider all microorganisms 'unknown'.}

View File

@ -1,7 +1,7 @@
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/amr_selectors.R % Please edit documentation in R/amr_selectors.R
\name{antimicrobial_class_selectors} \name{antimicrobial_selectors}
\alias{antimicrobial_class_selectors} \alias{antimicrobial_selectors}
\alias{amr_class} \alias{amr_class}
\alias{amr_selector} \alias{amr_selector}
\alias{aminoglycosides} \alias{aminoglycosides}

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB