mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 23:21:56 +02:00
(v1.4.0.9032) auto-data guessing for functions
This commit is contained in:
@ -50,7 +50,7 @@ filter_first_weighted_isolate(
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{a \link{data.frame} containing isolates.}
|
||||
\item{x}{a \link{data.frame} containing isolates. Can be omitted when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.}
|
||||
|
||||
\item{col_date}{column name of the result date (or date that is was received on the lab), defaults to the first column with a date class}
|
||||
|
||||
@ -93,6 +93,8 @@ A \code{\link{logical}} vector
|
||||
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use \code{\link[=is_new_episode]{is_new_episode()}} that also supports grouping with the \code{dplyr} package.
|
||||
}
|
||||
\details{
|
||||
These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} parameter can be omitted, please see \emph{Examples}.
|
||||
|
||||
The \code{\link[=first_isolate]{first_isolate()}} function is a wrapper around the \code{\link[=is_new_episode]{is_new_episode()}} function, but more efficient for data sets containing microorganism codes or names.
|
||||
|
||||
All isolates with a microbial ID of \code{NA} will be excluded as first isolate.
|
||||
@ -107,7 +109,7 @@ The functions \code{\link[=filter_first_isolate]{filter_first_isolate()}} and \c
|
||||
|
||||
The function \code{\link[=filter_first_isolate]{filter_first_isolate()}} is essentially equal to either:\preformatted{ x[first_isolate(x, ...), ]
|
||||
|
||||
x \%>\% filter(first_isolate(x, ...))
|
||||
x \%>\% filter(first_isolate(...))
|
||||
}
|
||||
|
||||
The function \code{\link[=filter_first_weighted_isolate]{filter_first_weighted_isolate()}} is essentially equal to:\preformatted{ x \%>\%
|
||||
@ -161,6 +163,8 @@ if (require("dplyr")) {
|
||||
filter(first_isolate == TRUE)
|
||||
|
||||
# short-hand versions:
|
||||
example_isolates \%>\%
|
||||
filter(first_isolate())
|
||||
example_isolates \%>\%
|
||||
filter_first_isolate()
|
||||
|
||||
|
@ -41,7 +41,7 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/
|
||||
|
||||
is_new_episode(example_isolates$date)
|
||||
is_new_episode(example_isolates$date, episode_days = 60)
|
||||
|
||||
#' \donttest{
|
||||
if (require("dplyr")) {
|
||||
# is_new_episode() can also be used in dplyr verbs to determine patient
|
||||
# episodes based on any (combination of) grouping variables:
|
||||
@ -78,3 +78,4 @@ if (require("dplyr")) {
|
||||
mutate(flag_episode = is_new_episode(date))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ key_antibiotics_equal(
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{a data.frame with antibiotics columns, like \code{AMX} or \code{amox}}
|
||||
\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be omitted when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.}
|
||||
|
||||
\item{col_mo}{column name of the IDs of the microorganisms (see \code{\link[=as.mo]{as.mo()}}), defaults to the first column of class \code{\link{mo}}. Values will be coerced using \code{\link[=as.mo]{as.mo()}}.}
|
||||
|
||||
@ -65,9 +65,11 @@ key_antibiotics_equal(
|
||||
\item{info}{print progress}
|
||||
}
|
||||
\description{
|
||||
These function can be used to determine first isolates (see \code{\link[=first_isolate]{first_isolate()}}). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first \emph{weighted} isolates.
|
||||
These function can be used to determine first isolates (see \code{\link[=first_isolate]{first_isolate()}}). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates can then be called first \emph{weighted} isolates.
|
||||
}
|
||||
\details{
|
||||
The \code{\link[=key_antibiotics]{key_antibiotics()}} function is context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} parameter can be omitted, please see \emph{Examples}.
|
||||
|
||||
The function \code{\link[=key_antibiotics]{key_antibiotics()}} returns a character vector with 12 antibiotic results for every isolate. These isolates can then be compared using \code{\link[=key_antibiotics_equal]{key_antibiotics_equal()}}, to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (\code{"."}) by \code{\link[=key_antibiotics]{key_antibiotics()}} and ignored by \code{\link[=key_antibiotics_equal]{key_antibiotics_equal()}}.
|
||||
|
||||
The \code{\link[=first_isolate]{first_isolate()}} function only uses this function on the same microbial species from the same patient. Using this, e.g. an MRSA will be included after a susceptible \emph{S. aureus} (MSSA) is found within the same patient episode. Without key antibiotic comparison it would not. See \code{\link[=first_isolate]{first_isolate()}} for more info.
|
||||
@ -136,30 +138,30 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/
|
||||
# `example_isolates` is a dataset available in the AMR package.
|
||||
# See ?example_isolates.
|
||||
|
||||
# output of the `key_antibiotics` function could be like this:
|
||||
# output of the `key_antibiotics()` function could be like this:
|
||||
strainA <- "SSSRR.S.R..S"
|
||||
strainB <- "SSSIRSSSRSSS"
|
||||
|
||||
# can those strings can be compared with:
|
||||
# those strings can be compared with:
|
||||
key_antibiotics_equal(strainA, strainB)
|
||||
# TRUE, because I is ignored (as well as missing values)
|
||||
|
||||
key_antibiotics_equal(strainA, strainB, ignore_I = FALSE)
|
||||
# FALSE, because I is not ignored and so the 4th value differs
|
||||
# FALSE, because I is not ignored and so the 4th character differs
|
||||
|
||||
\donttest{
|
||||
if (require("dplyr")) {
|
||||
# set key antibiotics to a new variable
|
||||
my_patients <- example_isolates \%>\%
|
||||
mutate(keyab = key_antibiotics(.)) \%>\%
|
||||
mutate(keyab = key_antibiotics()) \%>\% # no need to define `x`
|
||||
mutate(
|
||||
# now calculate first isolates
|
||||
first_regular = first_isolate(., col_keyantibiotics = FALSE),
|
||||
first_regular = first_isolate(col_keyantibiotics = FALSE),
|
||||
# and first WEIGHTED isolates
|
||||
first_weighted = first_isolate(., col_keyantibiotics = "keyab")
|
||||
first_weighted = first_isolate(col_keyantibiotics = "keyab")
|
||||
)
|
||||
|
||||
# Check the difference, in this data set it results in 7\% more isolates:
|
||||
# Check the difference, in this data set it results in a lot more isolates:
|
||||
sum(my_patients$first_regular, na.rm = TRUE)
|
||||
sum(my_patients$first_weighted, na.rm = TRUE)
|
||||
}
|
||||
|
30
man/mdro.Rd
30
man/mdro.Rd
@ -40,7 +40,7 @@ mdr_cmi2012(x, guideline = "CMI2012", ...)
|
||||
eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{data with antibiotic columns, such as \code{amox}, \code{AMX} and \code{AMC}}
|
||||
\item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be omitted when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.}
|
||||
|
||||
\item{guideline}{a specific guideline to follow. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, please see \emph{Details}.}
|
||||
|
||||
@ -72,21 +72,29 @@ Ordered \link{factor} with levels \code{Negative} < \verb{Positive, unconfirmed}
|
||||
Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines.
|
||||
}
|
||||
\details{
|
||||
These functions are context-aware when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}. This means that then the \code{x} parameter can be omitted, please see \emph{Examples}.
|
||||
|
||||
For the \code{pct_required_classes} argument, values above 1 will be divided by 100. This is to support both fractions (\code{0.75} or \code{3/4}) and percentages (\code{75}).
|
||||
|
||||
Currently supported guidelines are (case-insensitive):
|
||||
\itemize{
|
||||
\item \code{guideline = "CMI2012"}\cr
|
||||
\item \code{guideline = "CMI2012"} (default)
|
||||
|
||||
Magiorakos AP, Srinivasan A \emph{et al.} "Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance." Clinical Microbiology and Infection (2012) (\href{https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext}{link})
|
||||
\item \code{guideline = "EUCAST3.2"} (or simply \code{guideline = "EUCAST"})\cr
|
||||
\item \code{guideline = "EUCAST3.2"} (or simply \code{guideline = "EUCAST"})
|
||||
|
||||
The European international guideline - EUCAST Expert Rules Version 3.2 "Intrinsic Resistance and Unusual Phenotypes" (\href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf}{link})
|
||||
\item \code{guideline = "EUCAST3.1"}\cr
|
||||
\item \code{guideline = "EUCAST3.1"}
|
||||
|
||||
The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" (\href{https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf}{link})
|
||||
\item \code{guideline = "TB"}\cr
|
||||
\item \code{guideline = "TB"}
|
||||
|
||||
The international guideline for multi-drug resistant tuberculosis - World Health Organization "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis" (\href{https://www.who.int/tb/publications/pmdt_companionhandbook/en/}{link})
|
||||
\item \code{guideline = "MRGN"}\cr
|
||||
\item \code{guideline = "MRGN"}
|
||||
|
||||
The German national guideline - Mueller et al. (2015) Antimicrobial Resistance and Infection Control 4:7. DOI: 10.1186/s13756-015-0047-6
|
||||
\item \code{guideline = "BRMO"}\cr
|
||||
\item \code{guideline = "BRMO"}
|
||||
|
||||
The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu "WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) (ZKH)" (\href{https://www.rivm.nl/wip-richtlijn-brmo-bijzonder-resistente-micro-organismen-zkh}{link})
|
||||
}
|
||||
|
||||
@ -140,10 +148,12 @@ if (require("dplyr")) {
|
||||
mdro() \%>\%
|
||||
table()
|
||||
|
||||
# no need to define `x` when used inside dplyr verbs:
|
||||
example_isolates \%>\%
|
||||
mutate(EUCAST = eucast_exceptional_phenotypes(.),
|
||||
BRMO = brmo(.),
|
||||
MRGN = mrgn(.))
|
||||
mutate(MDRO = mdro(),
|
||||
EUCAST = eucast_exceptional_phenotypes(),
|
||||
BRMO = brmo(),
|
||||
MRGN = mrgn())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ ggplot_rsi_predict(
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{a \link{data.frame} containing isolates.}
|
||||
\item{x}{a \link{data.frame} containing isolates. Can be omitted when used inside \code{dplyr} verbs, such as \code{filter()}, \code{mutate()} and \code{summarise()}.}
|
||||
|
||||
\item{col_ab}{column name of \code{x} containing antimicrobial interpretations (\code{"R"}, \code{"I"} and \code{"S"})}
|
||||
|
||||
|
Reference in New Issue
Block a user