1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-27 09:26:11 +01:00
AMR/man/rsi.Rd

97 lines
4.0 KiB
Plaintext
Raw Normal View History

2018-02-21 11:52:31 +01:00
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rsi_analysis.R
\name{rsi}
\alias{rsi}
2018-05-02 14:56:25 +02:00
\alias{rsi_df}
\alias{n_rsi}
2018-02-21 11:52:31 +01:00
\title{Resistance of isolates}
\usage{
2018-05-02 14:56:25 +02:00
rsi(ab1, ab2 = NA, interpretation = "IR", minimum = 30,
as_percent = FALSE, info = FALSE, warning = TRUE)
rsi_df(tbl, ab, interpretation = "IR", minimum = 30, as_percent = FALSE,
info = TRUE, warning = TRUE)
n_rsi(ab1, ab2 = NA)
2018-02-21 11:52:31 +01:00
}
\arguments{
2018-05-02 14:56:25 +02:00
\item{ab1, ab2}{vector of antibiotic interpretations, they will be transformed internally with \code{\link{as.rsi}}}
2018-02-21 11:52:31 +01:00
\item{interpretation}{antimicrobial interpretation of which the portion must be calculated. Valid values are \code{"S"}, \code{"SI"}, \code{"I"}, \code{"IR"} or \code{"R"}.}
\item{minimum}{minimal amount of available isolates. Any number lower than \code{minimum} will return \code{NA} with a warning (when \code{warning = TRUE}).}
2018-05-02 14:56:25 +02:00
\item{as_percent}{return output as percent (text), will else (at default) be a double}
2018-02-21 11:52:31 +01:00
\item{info}{calculate the amount of available isolates and print it, like \code{n = 423}}
\item{warning}{show a warning when the available amount of isolates is below \code{minimum}}
2018-05-02 14:56:25 +02:00
\item{tbl}{\code{data.frame} containing columns with antibiotic interpretations.}
\item{ab}{character vector with 1, 2 or 3 antibiotics that occur as column names in \code{tbl}, like \code{ab = c("amox", "amcl")}}
2018-02-21 11:52:31 +01:00
}
\value{
2018-05-02 14:56:25 +02:00
Double or, when \code{as_percent = TRUE}, a character.
2018-02-21 11:52:31 +01:00
}
\description{
2018-05-02 14:56:25 +02:00
This functions can be used to calculate the (co-)resistance of isolates (i.e. percentage S, SI, I, IR or R [of a vector] of isolates). The functions \code{rsi} and \code{n_rsi} can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
2018-02-21 11:52:31 +01:00
}
\details{
2018-05-02 14:56:25 +02:00
Remember that you should filter your table to let it contain \strong{only first isolates}!
\if{html}{
2018-05-03 10:19:02 +02:00
\cr \cr
To calculate the probability (\emph{p}) of susceptibility of one antibiotic, we use this formula:
2018-05-02 14:56:25 +02:00
\out{<div style="text-align: center">}\figure{mono_therapy.png}\out{</div>}
2018-05-03 10:19:02 +02:00
To calculate the probability (\emph{p}) of susceptibility of more antibiotics (i.e. combination therapy), we need to check whether one of them has a susceptible result (as numerator) and count all cases where all antibiotics were tested (as denominator). \cr
For two antibiotics:
2018-05-02 14:56:25 +02:00
\out{<div style="text-align: center">}\figure{combi_therapy_2.png}\out{</div>}
2018-05-03 10:19:02 +02:00
\cr
For three antibiotics:
2018-05-02 14:56:25 +02:00
\out{<div style="text-align: center">}\figure{combi_therapy_3.png}\out{</div>}
}
2018-02-21 11:52:31 +01:00
}
\examples{
2018-05-02 14:56:25 +02:00
library(dplyr)
2018-04-02 16:05:09 +02:00
2018-05-02 14:56:25 +02:00
septic_patients \%>\%
group_by(hospital_id) \%>\%
summarise(cipro_susceptibility = rsi(cipr, interpretation = "S"),
n = n_rsi(cipr)) # n_rsi works like n_distinct in dplyr
2018-04-02 16:05:09 +02:00
2018-05-02 14:56:25 +02:00
septic_patients \%>\%
group_by(hospital_id) \%>\%
summarise(cipro_S = rsi(cipr, interpretation = "S",
as_percent = TRUE, warning = FALSE),
cipro_n = n_rsi(cipr),
genta_S = rsi(gent, interpretation = "S",
as_percent = TRUE, warning = FALSE),
genta_n = n_rsi(gent),
combination_S = rsi(cipr, gent, interpretation = "S",
as_percent = TRUE, warning = FALSE),
combination_n = n_rsi(cipr, gent))
2018-02-21 11:52:31 +01:00
2018-05-02 14:56:25 +02:00
# calculate resistance
rsi(septic_patients$amox)
# or susceptibility
rsi(septic_patients$amox, interpretation = "S")
# calculate co-resistance between amoxicillin/clav acid and gentamicin,
# so we can review that combination therapy does a lot more than mono therapy:
septic_patients \%>\% rsi_df(ab = "amcl", interpretation = "S") # = 67.8\%
septic_patients \%>\% rsi_df(ab = "gent", interpretation = "S") # = 69.1\%
septic_patients \%>\% rsi_df(ab = c("amcl", "gent"), interpretation = "S") # = 90.6\%
\dontrun{
# calculate current empiric combination therapy of Helicobacter gastritis:
my_table \%>\%
filter(first_isolate == TRUE,
genus == "Helicobacter") \%>\%
rsi_df(ab = c("amox", "metr")) # amoxicillin with metronidazole
2018-02-21 11:52:31 +01:00
}
}
\keyword{antibiotics}
\keyword{isolate}
\keyword{isolates}
\keyword{rsi}