mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 00:10:57 +01:00
- New sir_combine() to combine SIR results of multiple antimicrobials into one variable; antibiogram(), wisca() and the count/proportion functions now use the same engine (antibiogram() and wisca() output unchanged) - With multiple antimicrobials, count_*() and proportion_*() now follow the documented combination therapy rules: resistance() is the proportion of failing combinations, count_all() excludes isolates with an unknown combination result, and WT/NWT/NS/NI are handled correctly - where() is now decided at runtime instead of at installation, fixing antibiogram() and wisca() without tidyselect (e.g. CRAN binaries without dplyr) - Imports from data.table and cli moved to .onLoad(); data.table functions are only used while it is loaded; the like() example no longer unloads data.table, which crashed R - Static test that fails on code outside functions depending on suggested packages - New check-without-dplyr workflow: installs AMR with all suggested packages, removes dplyr (and tidyselect), then runs all unit tests and examples against the installed package - g.test() now returns the degrees of freedom as 'parameter', so they are printed - Fix R CMD check NOTEs (hidden .claude folder, lost braces in inherited g.test and ggplot_pca docs)
102 lines
6.5 KiB
R
102 lines
6.5 KiB
R
% Generated by roxygen2: do not edit by hand
|
|
% Please edit documentation in R/sir_combine.R
|
|
\name{sir_combine}
|
|
\alias{sir_combine}
|
|
\title{Combine SIR Results of Multiple Antimicrobials}
|
|
\usage{
|
|
sir_combine(
|
|
...,
|
|
only_all_tested = FALSE,
|
|
guideline = getOption("AMR_guideline", "EUCAST")
|
|
)
|
|
}
|
|
\arguments{
|
|
\item{...}{Two or more vectors (or columns) with antimicrobial interpretations, or a data frame with such columns. They will be transformed internally with \code{\link[=as.sir]{as.sir()}} if needed. All vectors must be of the same length.}
|
|
|
|
\item{only_all_tested}{A \link{logical} to indicate that isolates must be tested for all antimicrobials. If \code{TRUE}, the result is \code{NA} for isolates with a missing result for any of the antimicrobials. If \code{FALSE} (default), a missing result only leads to \code{NA} if a result for the missing antimicrobial could have changed the result of the combination, see \emph{Combination Therapy} below.}
|
|
|
|
\item{guideline}{Either \code{"EUCAST"} (default) or \code{"CLSI"}, to determine whether the 'I' category is considered susceptible. This only affects isolates with a missing result for any of the antimicrobials when \code{only_all_tested = FALSE}, see \emph{Combination Therapy} below. The default can be changed with the \code{AMR_guideline} option, see \link{AMR-options}.}
|
|
}
|
|
\value{
|
|
A \code{\link{sir}} vector with the same length as the input.
|
|
}
|
|
\description{
|
|
Combine the SIR results of two or more antimicrobials into one SIR result per isolate, e.g. to create a variable \code{TZP_GEN} for the combination therapy of piperacillin/tazobactam with gentamicin. The result is the best result of the antimicrobials, as a combination therapy covers the isolate if any of its antimicrobials is active. See \emph{Combination Therapy} below for the exact rules.
|
|
|
|
The same rules are used by \code{\link[=antibiogram]{antibiogram()}} and \code{\link[=wisca]{wisca()}} for combination antibiograms, and by the \code{\link[=count]{count_*()}} and \code{\link[=proportion]{proportion_*()}} functions when more than one variable is used, so the result of \code{\link[=sir_combine]{sir_combine()}} can be used in any further analysis.
|
|
}
|
|
\section{Combination Therapy}{
|
|
|
|
A combination of antimicrobials is considered as good as its most active antimicrobial. Results are ranked as follows, from best to worst:
|
|
\enumerate{
|
|
\item \code{"S"} and \code{"WT"}
|
|
\item \code{"SDD"}
|
|
\item \code{"I"}
|
|
\item \code{"R"}, \code{"NWT"}, and \code{"NS"}
|
|
}
|
|
|
|
The result of the combination is the best result of the antimicrobials, i.e., the result keeps its original category instead of being reduced to only S or R. If antimicrobials have an equally ranked result, \code{"S"} is preferred over \code{"WT"}, and \code{"R"} over \code{"NWT"} and \code{"NS"}. The value \code{"NI"} (non-interpretable) is considered a missing result.
|
|
|
|
A missing result can only be ignored if the result of the combination is susceptible regardless of the missing result, which depends on the \code{only_all_tested} argument and on the guideline: under EUCAST, the 'I' category is considered susceptible (\emph{susceptible, increased exposure}), and under CLSI, it is not. This is an example for two antimicrobials, Drug A and Drug B (the order of the antimicrobials does not matter):
|
|
|
|
\if{html}{\out{<div class="sourceCode">}}\preformatted{-------------------------------------------------------------------------
|
|
Result of the combination
|
|
-----------------------------------------------------
|
|
Drug A Drug B only_all_tested = FALSE only_all_tested = TRUE
|
|
-------- -------- ---------------------------- ----------------------
|
|
S S, I, R S S
|
|
I I, R I I
|
|
R R R R
|
|
S <NA> S <NA>
|
|
I <NA> I (EUCAST), <NA> (CLSI) <NA>
|
|
R <NA> <NA> <NA>
|
|
<NA> <NA> <NA> <NA>
|
|
-------------------------------------------------------------------------
|
|
}\if{html}{\out{</div>}}
|
|
|
|
The \code{\link[=count]{count_*()}} and \code{\link[=proportion]{proportion_*()}} functions, such as \code{\link[=susceptibility]{susceptibility()}} and \code{\link[=resistance]{resistance()}}, apply exactly these rules when more than one variable is used: an isolate is considered tested if the result of the combination is not \code{NA}, and is then counted by the result of the combination. Consequently, \code{\link[=count_susceptible]{count_susceptible()}} \code{+} \code{\link[=count_resistant]{count_resistant()}} \code{=} \code{\link[=count_all]{count_all()}}, and \code{\link[=susceptibility]{susceptibility()}} \code{+} \code{\link[=resistance]{resistance()}} \verb{= 1}, for both values of \code{only_all_tested}. The guideline is taken from their \code{guideline} argument if they have one, and otherwise from the \code{AMR_guideline} option.
|
|
|
|
In \code{\link[=antibiogram]{antibiogram()}} and \code{\link[=wisca]{wisca()}}, the 'I' and 'SDD' categories are considered susceptible if \code{combine_SI = TRUE} (default), and the result of the combination is then reduced to S or R.
|
|
}
|
|
|
|
\examples{
|
|
drug_a <- as.sir(c("S", "R", "R", "I", "I", NA, "R", "SDD"))
|
|
drug_b <- as.sir(c("R", "S", "R", "R", NA, NA, NA, "I"))
|
|
|
|
sir_combine(drug_a, drug_b)
|
|
sir_combine(drug_a, drug_b, guideline = "CLSI")
|
|
sir_combine(drug_a, drug_b, only_all_tested = TRUE)
|
|
|
|
# the count and proportion functions use the same rules
|
|
susceptibility(drug_a, drug_b, minimum = 0)
|
|
susceptibility(sir_combine(drug_a, drug_b), minimum = 0)
|
|
|
|
\donttest{
|
|
if (require("dplyr")) {
|
|
# create a new variable for piperacillin/tazobactam + gentamicin
|
|
example_isolates \%>\%
|
|
mutate(TZP_GEN = sir_combine(TZP, GEN)) \%>\%
|
|
select(mo, TZP, GEN, TZP_GEN)
|
|
}
|
|
if (require("dplyr")) {
|
|
# combine any number of antimicrobials
|
|
example_isolates \%>\%
|
|
mutate(any_aminoglycoside = sir_combine(GEN, TOB, AMK, KAN)) \%>\%
|
|
count(any_aminoglycoside)
|
|
}
|
|
if (require("dplyr")) {
|
|
# use the new variable in further analyses
|
|
example_isolates \%>\%
|
|
mutate(TZP_GEN = sir_combine(TZP, GEN)) \%>\%
|
|
group_by(ward) \%>\%
|
|
summarise(
|
|
TZP = susceptibility(TZP),
|
|
TZP_GEN = susceptibility(TZP_GEN)
|
|
)
|
|
}
|
|
}
|
|
}
|
|
\seealso{
|
|
\code{\link[=count]{count()}} and \code{\link[=proportion]{proportion()}} for counting and calculating susceptibility of (combinations of) antimicrobials, and \code{\link[=antibiogram]{antibiogram()}} for combination antibiograms.
|
|
}
|