|
|
|
@ -1,9 +1,9 @@
|
|
|
|
|
% Generated by roxygen2: do not edit by hand
|
|
|
|
|
% Please edit documentation in R/ab_selectors.R
|
|
|
|
|
\name{antibiotic_class_selectors}
|
|
|
|
|
\alias{antibiotic_class_selectors}
|
|
|
|
|
\alias{ab_class}
|
|
|
|
|
\alias{ab_selector}
|
|
|
|
|
% Please edit documentation in R/amr_selectors.R
|
|
|
|
|
\name{antimicrobial_class_selectors}
|
|
|
|
|
\alias{antimicrobial_class_selectors}
|
|
|
|
|
\alias{amr_class}
|
|
|
|
|
\alias{amr_selector}
|
|
|
|
|
\alias{aminoglycosides}
|
|
|
|
|
\alias{aminopenicillins}
|
|
|
|
|
\alias{antifungals}
|
|
|
|
@ -36,73 +36,110 @@
|
|
|
|
|
\alias{administrable_per_os}
|
|
|
|
|
\alias{administrable_iv}
|
|
|
|
|
\alias{not_intrinsic_resistant}
|
|
|
|
|
\title{Antibiotic Selectors}
|
|
|
|
|
\title{Antimicrobial Selectors}
|
|
|
|
|
\usage{
|
|
|
|
|
ab_class(ab_class, only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
amr_class(
|
|
|
|
|
amr_class,
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ab_selector(filter, only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
amr_selector(
|
|
|
|
|
filter,
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
aminoglycosides(only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
aminoglycosides(
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
aminopenicillins(only_sir_columns = FALSE, ...)
|
|
|
|
|
aminopenicillins(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
antifungals(only_sir_columns = FALSE, ...)
|
|
|
|
|
antifungals(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
antimycobacterials(only_sir_columns = FALSE, ...)
|
|
|
|
|
antimycobacterials(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
betalactams(only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
betalactams(
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
betalactams_with_inhibitor(only_sir_columns = FALSE, ...)
|
|
|
|
|
betalactams_with_inhibitor(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
carbapenems(only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
carbapenems(
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
cephalosporins(only_sir_columns = FALSE, ...)
|
|
|
|
|
cephalosporins(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
cephalosporins_1st(only_sir_columns = FALSE, ...)
|
|
|
|
|
cephalosporins_1st(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
cephalosporins_2nd(only_sir_columns = FALSE, ...)
|
|
|
|
|
cephalosporins_2nd(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
cephalosporins_3rd(only_sir_columns = FALSE, ...)
|
|
|
|
|
cephalosporins_3rd(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
cephalosporins_4th(only_sir_columns = FALSE, ...)
|
|
|
|
|
cephalosporins_4th(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
cephalosporins_5th(only_sir_columns = FALSE, ...)
|
|
|
|
|
cephalosporins_5th(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
fluoroquinolones(only_sir_columns = FALSE, ...)
|
|
|
|
|
fluoroquinolones(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
glycopeptides(only_sir_columns = FALSE, ...)
|
|
|
|
|
glycopeptides(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
lincosamides(only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
lincosamides(
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
lipoglycopeptides(only_sir_columns = FALSE, ...)
|
|
|
|
|
lipoglycopeptides(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
macrolides(only_sir_columns = FALSE, ...)
|
|
|
|
|
macrolides(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
nitrofurans(only_sir_columns = FALSE, ...)
|
|
|
|
|
nitrofurans(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
oxazolidinones(only_sir_columns = FALSE, ...)
|
|
|
|
|
oxazolidinones(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
penicillins(only_sir_columns = FALSE, ...)
|
|
|
|
|
penicillins(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
phenicols(only_sir_columns = FALSE, ...)
|
|
|
|
|
phenicols(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
polymyxins(only_sir_columns = FALSE, only_treatable = TRUE, ...)
|
|
|
|
|
polymyxins(
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
|
only_treatable = TRUE,
|
|
|
|
|
return_all = TRUE,
|
|
|
|
|
...
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
quinolones(only_sir_columns = FALSE, ...)
|
|
|
|
|
quinolones(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
rifamycins(only_sir_columns = FALSE, ...)
|
|
|
|
|
rifamycins(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
streptogramins(only_sir_columns = FALSE, ...)
|
|
|
|
|
streptogramins(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
tetracyclines(only_sir_columns = FALSE, ...)
|
|
|
|
|
tetracyclines(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
trimethoprims(only_sir_columns = FALSE, ...)
|
|
|
|
|
trimethoprims(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
ureidopenicillins(only_sir_columns = FALSE, ...)
|
|
|
|
|
ureidopenicillins(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
administrable_per_os(only_sir_columns = FALSE, ...)
|
|
|
|
|
administrable_per_os(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
administrable_iv(only_sir_columns = FALSE, ...)
|
|
|
|
|
administrable_iv(only_sir_columns = FALSE, return_all = TRUE, ...)
|
|
|
|
|
|
|
|
|
|
not_intrinsic_resistant(
|
|
|
|
|
only_sir_columns = FALSE,
|
|
|
|
@ -112,12 +149,14 @@ not_intrinsic_resistant(
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
\arguments{
|
|
|
|
|
\item{ab_class}{an antimicrobial class or a part of it, such as \code{"carba"} and \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.}
|
|
|
|
|
\item{amr_class}{an antimicrobial class or a part of it, such as \code{"carba"} and \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.}
|
|
|
|
|
|
|
|
|
|
\item{only_sir_columns}{a \link{logical} to indicate whether only columns of class \code{sir} must be selected (default is \code{FALSE}), see \code{\link[=as.sir]{as.sir()}}}
|
|
|
|
|
|
|
|
|
|
\item{only_treatable}{a \link{logical} to indicate whether antimicrobial drugs should be excluded that are only for laboratory tests (default is \code{TRUE}), such as gentamicin-high (\code{GEH}) and imipenem/EDTA (\code{IPE})}
|
|
|
|
|
|
|
|
|
|
\item{return_all}{a \link{logical} to indicate whether all matched columns must be returned (default is \code{TRUE}). With \code{FALSE}, only the first of each unique antimicrobial will be returned, e.g. if both columns \code{"genta"} and \code{"gentamicin"} exist in the data, only the first hit for gentamicin will be returned.}
|
|
|
|
|
|
|
|
|
|
\item{...}{ignored, only in place to allow future extensions}
|
|
|
|
|
|
|
|
|
|
\item{filter}{an \link{expression} to be evaluated in the \link{antibiotics} data set, such as \code{name \%like\% "trim"}}
|
|
|
|
@ -127,27 +166,34 @@ not_intrinsic_resistant(
|
|
|
|
|
\item{version_expertrules}{the version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be "3.3", "3.2", or "3.1".}
|
|
|
|
|
}
|
|
|
|
|
\value{
|
|
|
|
|
When used inside selecting or filtering, this returns a \link{character} vector of column names, with additional class \code{"ab_selector"}. When used individually, this returns an \link[=as.ab]{'ab' vector} with all possible antimicrobials that the function would be able to select or filter.
|
|
|
|
|
When used inside selecting or filtering, this returns a \link{character} vector of column names, with additional class \code{"amr_selector"}. When used individually, this returns an \link[=as.ab]{'ab' vector} with all possible antimicrobials that the function would be able to select or filter.
|
|
|
|
|
}
|
|
|
|
|
\description{
|
|
|
|
|
These functions allow for filtering rows and selecting columns based on antibiotic test results that are of a specific antibiotic class or group (according to the \link{antibiotics} data set), without the need to define the columns or antibiotic abbreviations.
|
|
|
|
|
These functions allow for filtering rows and selecting columns based on antimicrobial test results that are of a specific antimicrobial class or group, without the need to define the columns or antimicrobial abbreviations.
|
|
|
|
|
|
|
|
|
|
In short, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "kefzol", "CZO" and "J01DB04" will all be picked up by \code{\link[=cephalosporins]{cephalosporins()}}.
|
|
|
|
|
In short, if you have a column name that resembles an antimicrobial drug, it will be picked up by any of these functions that matches its pharmaceutical class: "cefazolin", "kefzol", "CZO" and "J01DB04" will all be picked up using:
|
|
|
|
|
|
|
|
|
|
\if{html}{\out{<div class="sourceCode r">}}\preformatted{library(dplyr)
|
|
|
|
|
my_data_with_all_these_columns \%>\%
|
|
|
|
|
select(cephalosporins())
|
|
|
|
|
}\if{html}{\out{</div>}}
|
|
|
|
|
}
|
|
|
|
|
\details{
|
|
|
|
|
These functions can be used in data set calls for selecting columns and filtering rows. They work with base \R, the Tidyverse, and \code{data.table}. They are heavily inspired by the \link[tidyselect:language]{Tidyverse selection helpers} such as \code{\link[tidyselect:everything]{everything()}}, but are not limited to \code{dplyr} verbs. Nonetheless, they are very convenient to use with \code{dplyr} functions such as \code{\link[dplyr:select]{select()}}, \code{\link[dplyr:filter]{filter()}} and \code{\link[dplyr:summarise]{summarise()}}, see \emph{Examples}.
|
|
|
|
|
|
|
|
|
|
All columns in the data in which these functions are called will be searched for known antibiotic names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) according to the \link{antibiotics} data set. This means that a selector such as \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
|
|
|
|
All selectors can also be used in \code{tidymodels} packages such as \code{recipe} and \code{parsnip}. See for more info \href{https://msberends.github.io/AMR/articles/AMR_with_tidymodels.html}{our tutorial} on using these AMR functions for predictive modelling.
|
|
|
|
|
|
|
|
|
|
The \code{\link[=ab_class]{ab_class()}} function can be used to filter/select on a manually defined antibiotic class. It searches for results in the \link{antibiotics} data set within the columns \code{group}, \code{atc_group1} and \code{atc_group2}.
|
|
|
|
|
All columns in the data in which these functions are called will be searched for known antimicrobial names, abbreviations, brand names, and codes (ATC, EARS-Net, WHO, etc.) according to the \link{antibiotics} data set. This means that a selector such as \code{\link[=aminoglycosides]{aminoglycosides()}} will pick up column names like 'gen', 'genta', 'J01GB03', 'tobra', 'Tobracin', etc.
|
|
|
|
|
|
|
|
|
|
The \code{\link[=ab_selector]{ab_selector()}} function can be used to internally filter the \link{antibiotics} data set on any results, see \emph{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.
|
|
|
|
|
The \code{\link[=amr_class]{amr_class()}} function can be used to filter/select on a manually defined antimicrobial class. It searches for results in the \link{antibiotics} data set within the columns \code{group}, \code{atc_group1} and \code{atc_group2}.
|
|
|
|
|
|
|
|
|
|
The \code{\link[=administrable_per_os]{administrable_per_os()}} and \code{\link[=administrable_iv]{administrable_iv()}} functions also rely on the \link{antibiotics} data set - antibiotic columns will be matched where a DDD (defined daily dose) for resp. oral and IV treatment is available in the \link{antibiotics} data set.
|
|
|
|
|
The \code{\link[=amr_selector]{amr_selector()}} function can be used to internally filter the \link{antibiotics} data set on any results, see \emph{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.
|
|
|
|
|
|
|
|
|
|
The \code{\link[=not_intrinsic_resistant]{not_intrinsic_resistant()}} function can be used to only select antibiotic columns 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 \emph{E. coli} and \emph{K. pneumoniae} and contains a column "vancomycin", this column will be removed (or rather, unselected) using this function. It currently applies \href{https://www.eucast.org/expert_rules_and_expected_phenotypes}{'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.3} (2021) to determine intrinsic resistance, using the \code{\link[=eucast_rules]{eucast_rules()}} function internally. Because of this determination, this function is quite slow in terms of performance.
|
|
|
|
|
The \code{\link[=administrable_per_os]{administrable_per_os()}} and \code{\link[=administrable_iv]{administrable_iv()}} functions also rely on the \link{antibiotics} data set - antimicrobials will be matched where a DDD (defined daily dose) for resp. oral and IV treatment is available in the \link{antibiotics} data set.
|
|
|
|
|
|
|
|
|
|
The \code{\link[=not_intrinsic_resistant]{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 \emph{E. coli} and \emph{K. pneumoniae} and contains a column "vancomycin", this column will be removed (or rather, unselected) using this function. It currently applies \href{https://www.eucast.org/expert_rules_and_expected_phenotypes}{'EUCAST Expert Rules' and 'EUCAST Intrinsic Resistance and Unusual Phenotypes' v3.3} (2021) to determine intrinsic resistance, using the \code{\link[=eucast_rules]{eucast_rules()}} function internally. Because of this determination, this function is quite slow in terms of performance.
|
|
|
|
|
}
|
|
|
|
|
\section{Full list of supported (antibiotic) classes}{
|
|
|
|
|
\section{Full list of supported (antimicrobial) classes}{
|
|
|
|
|
|
|
|
|
|
\itemize{
|
|
|
|
|
\item \code{\link[=aminoglycosides]{aminoglycosides()}} can select: \cr amikacin (AMK), amikacin/fosfomycin (AKF), apramycin (APR), arbekacin (ARB), astromicin (AST), bekanamycin (BEK), dibekacin (DKB), framycetin (FRM), gentamicin (GEN), gentamicin-high (GEH), habekacin (HAB), hygromycin (HYG), isepamicin (ISE), kanamycin (KAN), kanamycin-high (KAH), kanamycin/cephalexin (KAC), micronomicin (MCR), neomycin (NEO), netilmicin (NET), pentisomicin (PIM), plazomicin (PLZ), propikacin (PKA), ribostamycin (RST), sisomicin (SIS), streptoduocin (STR), streptomycin (STR1), streptomycin-high (STH), tobramycin (TOB), and tobramycin-high (TOH)
|
|
|
|
@ -215,7 +261,7 @@ example_isolates \%>\% select(mo, aminoglycosides())
|
|
|
|
|
# e.g., for betalactams, but not the ones with an enzyme inhibitor:
|
|
|
|
|
example_isolates \%>\% select(betalactams(), -betalactams_with_inhibitor())
|
|
|
|
|
|
|
|
|
|
# select only antibiotic columns with DDDs for oral treatment
|
|
|
|
|
# select only antimicrobials with DDDs for oral treatment
|
|
|
|
|
example_isolates \%>\% select(administrable_per_os())
|
|
|
|
|
|
|
|
|
|
# get AMR for all aminoglycosides e.g., per ward:
|
|
|
|
@ -235,11 +281,11 @@ example_isolates \%>\%
|
|
|
|
|
summarise_at(not_intrinsic_resistant(),
|
|
|
|
|
resistance)
|
|
|
|
|
|
|
|
|
|
# get susceptibility for antibiotics whose name contains "trim":
|
|
|
|
|
# get susceptibility for antimicrobials whose name contains "trim":
|
|
|
|
|
example_isolates \%>\%
|
|
|
|
|
filter(first_isolate()) \%>\%
|
|
|
|
|
group_by(ward) \%>\%
|
|
|
|
|
summarise(across(ab_selector(name \%like\% "trim"), susceptibility))
|
|
|
|
|
summarise(across(amr_selector(name \%like\% "trim"), susceptibility))
|
|
|
|
|
|
|
|
|
|
# this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
|
|
|
|
|
example_isolates \%>\%
|
|
|
|
@ -266,7 +312,7 @@ example_isolates \%>\%
|
|
|
|
|
|
|
|
|
|
# this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
|
|
|
|
example_isolates \%>\%
|
|
|
|
|
select(mo, ab_class("mycobact"))
|
|
|
|
|
select(mo, amr_class("mycobact"))
|
|
|
|
|
|
|
|
|
|
# get bug/drug combinations for only glycopeptides in Gram-positives:
|
|
|
|
|
example_isolates \%>\%
|
|
|
|
@ -296,7 +342,7 @@ example_isolates[, carbapenems()]
|
|
|
|
|
# select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB'
|
|
|
|
|
example_isolates[, c("mo", aminoglycosides())]
|
|
|
|
|
|
|
|
|
|
# select only antibiotic columns with DDDs for oral treatment
|
|
|
|
|
# select only antimicrobials with DDDs for oral treatment
|
|
|
|
|
example_isolates[, administrable_per_os()]
|
|
|
|
|
|
|
|
|
|
# filter using any() or all()
|
|
|
|
@ -307,7 +353,7 @@ subset(example_isolates, any(carbapenems() == "R"))
|
|
|
|
|
example_isolates[any(carbapenems()), ]
|
|
|
|
|
example_isolates[all(carbapenems()), ]
|
|
|
|
|
|
|
|
|
|
# filter with multiple antibiotic selectors using c()
|
|
|
|
|
# filter with multiple antimicrobial selectors using c()
|
|
|
|
|
example_isolates[all(c(carbapenems(), aminoglycosides()) == "R"), ]
|
|
|
|
|
|
|
|
|
|
# filter + select in one go: get penicillins in carbapenem-resistant strains
|
|
|
|
@ -320,10 +366,10 @@ example_isolates[any(carbapenems() == "R"), penicillins()]
|
|
|
|
|
# and erythromycin is not a penicillin:
|
|
|
|
|
example_isolates[, penicillins() & administrable_per_os()]
|
|
|
|
|
|
|
|
|
|
# ab_selector() applies a filter in the `antibiotics` data set and is thus
|
|
|
|
|
# very flexible. For instance, to select antibiotic columns with an oral DDD
|
|
|
|
|
# amr_selector() applies a filter in the `antibiotics` data set and is thus
|
|
|
|
|
# very flexible. For instance, to select antimicrobials with an oral DDD
|
|
|
|
|
# of at least 1 gram:
|
|
|
|
|
example_isolates[, ab_selector(oral_ddd > 1 & oral_units == "g")]
|
|
|
|
|
example_isolates[, amr_selector(oral_ddd > 1 & oral_units == "g")]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# data.table --------------------------------------------------------------
|