mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 17:41:59 +02:00
quasiquotation, alpha for geom_rsi
This commit is contained in:
16
man/count.Rd
16
man/count.Rd
@ -13,23 +13,21 @@
|
||||
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
}
|
||||
\usage{
|
||||
count_R(ab1, ab2 = NULL)
|
||||
count_R(...)
|
||||
|
||||
count_IR(ab1, ab2 = NULL)
|
||||
count_IR(...)
|
||||
|
||||
count_I(ab1)
|
||||
count_I(...)
|
||||
|
||||
count_SI(ab1, ab2 = NULL)
|
||||
count_SI(...)
|
||||
|
||||
count_S(ab1, ab2 = NULL)
|
||||
count_S(...)
|
||||
|
||||
count_df(data, translate_ab = getOption("get_antibiotic_names",
|
||||
"official"))
|
||||
}
|
||||
\arguments{
|
||||
\item{ab1}{vector of antibiotic interpretations, they will be transformed internally with \code{\link{as.rsi}} if needed}
|
||||
|
||||
\item{ab2}{like \code{ab}, a vector of antibiotic interpretations. Use this to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
|
||||
\item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
|
||||
|
||||
\item{data}{a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}})}
|
||||
|
||||
@ -39,7 +37,7 @@ count_df(data, translate_ab = getOption("get_antibiotic_names",
|
||||
Integer
|
||||
}
|
||||
\description{
|
||||
These functions can be used to count resistant/susceptible microbial isolates. All functions can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
These functions can be used to count resistant/susceptible microbial isolates. All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
|
||||
\code{count_R} and \code{count_IR} can be used to count resistant isolates, \code{count_S} and \code{count_SI} can be used to count susceptible isolates.\cr
|
||||
}
|
||||
|
@ -11,10 +11,10 @@
|
||||
\usage{
|
||||
ggplot_rsi(data, position = NULL, x = "Antibiotic",
|
||||
fill = "Interpretation", facet = NULL, translate_ab = "official",
|
||||
fun = portion_df, ...)
|
||||
alpha = 1, fun = portion_df, ...)
|
||||
|
||||
geom_rsi(position = NULL, x = c("Antibiotic", "Interpretation"),
|
||||
fill = "Interpretation", translate_ab = "official",
|
||||
fill = "Interpretation", translate_ab = "official", alpha = 1,
|
||||
fun = portion_df)
|
||||
|
||||
facet_rsi(facet = c("Interpretation", "Antibiotic"), ...)
|
||||
@ -38,6 +38,8 @@ theme_rsi()
|
||||
|
||||
\item{translate_ab}{a column name of the \code{\link{antibiotics}} data set to translate the antibiotic abbreviations into, using \code{\link{abname}}. Default behaviour is to translate to official names according to the WHO. Use \code{translate_ab = FALSE} to disable translation.}
|
||||
|
||||
\item{alpha}{opacity of the fill colours}
|
||||
|
||||
\item{fun}{function to transform \code{data}, either \code{\link{portion_df}} (default) or \code{\link{count_df}}}
|
||||
|
||||
\item{...}{other parameters passed on to \code{\link[ggplot2]{facet_wrap}}}
|
||||
|
@ -4,13 +4,13 @@
|
||||
\alias{n_rsi}
|
||||
\title{Count cases with antimicrobial results}
|
||||
\usage{
|
||||
n_rsi(ab1, ab2 = NULL)
|
||||
n_rsi(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{ab1, ab2}{vector of antibiotic interpretations, they will be transformed internally with \code{\link{as.rsi}} if needed}
|
||||
\item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
|
||||
}
|
||||
\description{
|
||||
This counts all cases where antimicrobial interpretations are available. Its use is equal to \code{\link{n_distinct}}.
|
||||
This counts all cases where antimicrobial interpretations are available. The way it can be used is equal to \code{\link{n_distinct}}. Its function is equal to \code{count_S(...) + count_IR(...)}.
|
||||
}
|
||||
\examples{
|
||||
library(dplyr)
|
||||
@ -25,5 +25,6 @@ septic_patients \%>\%
|
||||
combination_n = n_rsi(cipr, gent))
|
||||
}
|
||||
\seealso{
|
||||
The \code{\link{portion}} functions to calculate resistance and susceptibility.
|
||||
\code{\link[AMR]{count}_*} to count resistant and susceptibile isolates per interpretation type.\cr
|
||||
\code{\link{portion}_*} to calculate microbial resistance and susceptibility.
|
||||
}
|
||||
|
@ -15,23 +15,21 @@
|
||||
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
}
|
||||
\usage{
|
||||
portion_R(ab1, ab2 = NULL, minimum = 30, as_percent = FALSE)
|
||||
portion_R(..., minimum = 30, as_percent = FALSE)
|
||||
|
||||
portion_IR(ab1, ab2 = NULL, minimum = 30, as_percent = FALSE)
|
||||
portion_IR(..., minimum = 30, as_percent = FALSE)
|
||||
|
||||
portion_I(ab1, minimum = 30, as_percent = FALSE)
|
||||
portion_I(..., minimum = 30, as_percent = FALSE)
|
||||
|
||||
portion_SI(ab1, ab2 = NULL, minimum = 30, as_percent = FALSE)
|
||||
portion_SI(..., minimum = 30, as_percent = FALSE)
|
||||
|
||||
portion_S(ab1, ab2 = NULL, minimum = 30, as_percent = FALSE)
|
||||
portion_S(..., minimum = 30, as_percent = FALSE)
|
||||
|
||||
portion_df(data, translate_ab = getOption("get_antibiotic_names",
|
||||
"official"), minimum = 30, as_percent = FALSE)
|
||||
}
|
||||
\arguments{
|
||||
\item{ab1}{vector of antibiotic interpretations, they will be transformed internally with \code{\link{as.rsi}} if needed}
|
||||
|
||||
\item{ab2}{like \code{ab}, a vector of antibiotic interpretations. Use this to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
|
||||
\item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
|
||||
|
||||
\item{minimum}{minimal amount of available isolates. Any number lower than \code{minimum} will return \code{NA}. The default number of \code{30} isolates is advised by the CLSI as best practice, see Source.}
|
||||
|
||||
@ -45,7 +43,7 @@ portion_df(data, translate_ab = getOption("get_antibiotic_names",
|
||||
Double or, when \code{as_percent = TRUE}, a character.
|
||||
}
|
||||
\description{
|
||||
These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage S, SI, I, IR or R). All functions can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
These functions can be used to calculate the (co-)resistance of microbial isolates (i.e. percentage S, SI, I, IR or R). All functions support quasiquotation with pipes, can be used in \code{dplyr}s \code{\link[dplyr]{summarise}} and support grouped variables, see \emph{Examples}.
|
||||
|
||||
\code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr
|
||||
}
|
||||
@ -66,8 +64,10 @@ The old \code{\link{rsi}} function is still available for backwards compatibilit
|
||||
For two antibiotics:
|
||||
\out{<div style="text-align: center">}\figure{combi_therapy_2.png}\out{</div>}
|
||||
\cr
|
||||
Theoretically for three antibiotics:
|
||||
For three antibiotics:
|
||||
\out{<div style="text-align: center">}\figure{combi_therapy_3.png}\out{</div>}
|
||||
\cr
|
||||
And so on.
|
||||
}
|
||||
}
|
||||
\examples{
|
||||
@ -82,11 +82,13 @@ portion_IR(septic_patients$amox)
|
||||
portion_S(septic_patients$amox)
|
||||
portion_SI(septic_patients$amox)
|
||||
|
||||
# Since n_rsi counts available isolates (and is used as denominator),
|
||||
# you can calculate back to count e.g. non-susceptible isolates:
|
||||
portion_IR(septic_patients$amox) * n_rsi(septic_patients$amox)
|
||||
|
||||
# Do the above with pipes:
|
||||
library(dplyr)
|
||||
septic_patients \%>\% portion_R(amox)
|
||||
septic_patients \%>\% portion_IR(amox)
|
||||
septic_patients \%>\% portion_S(amox)
|
||||
septic_patients \%>\% portion_SI(amox)
|
||||
|
||||
septic_patients \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(p = portion_S(cipr),
|
||||
@ -102,16 +104,15 @@ septic_patients \%>\%
|
||||
|
||||
# Calculate co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
# so we can see that combination therapy does a lot more than mono therapy:
|
||||
portion_S(septic_patients$amcl) # S = 67.3\%
|
||||
n_rsi(septic_patients$amcl) # n = 1570
|
||||
septic_patients \%>\% portion_S(amcl) # S = 67.3\%
|
||||
septic_patients \%>\% n_rsi(amcl) # n = 1570
|
||||
|
||||
portion_S(septic_patients$gent) # S = 74.0\%
|
||||
n_rsi(septic_patients$gent) # n = 1842
|
||||
septic_patients \%>\% portion_S(gent) # S = 74.0\%
|
||||
septic_patients \%>\% n_rsi(gent) # n = 1842
|
||||
|
||||
septic_patients \%>\% portion_S(amcl, gent) # S = 92.1\%
|
||||
septic_patients \%>\% n_rsi(amcl, gent) # n = 1504
|
||||
|
||||
with(septic_patients,
|
||||
portion_S(amcl, gent)) # S = 92.1\%
|
||||
with(septic_patients, # n = 1504
|
||||
n_rsi(amcl, gent))
|
||||
|
||||
septic_patients \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
|
@ -8,9 +8,7 @@ rsi(ab1, ab2 = NULL, interpretation = "IR", minimum = 30,
|
||||
as_percent = FALSE, ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{ab1}{vector of antibiotic interpretations, they will be transformed internally with \code{\link{as.rsi}} if needed}
|
||||
|
||||
\item{ab2}{like \code{ab}, a vector of antibiotic interpretations. Use this to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
|
||||
\item{ab1, ab2}{vector (or column) with antibiotic interpretations. It will be transformed internally with \code{\link{as.rsi}} if needed.}
|
||||
|
||||
\item{interpretation}{antimicrobial interpretation to check for}
|
||||
|
||||
|
Reference in New Issue
Block a user