EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called interpretive reading and is part of the eucast_rules()
function as well:
A more convenient function is mo_is_intrinsic_resistant()
that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics:
+mo_is_intrinsic_resistant(c("Klebsiella", "Escherichia"), + "ampicillin") +# [1] TRUE FALSE + +mo_is_intrinsic_resistant("Klebsiella", + c("ampicillin", "kanamycin")) +# [1] TRUE FALSE
EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called interpretive reading, is basically a form of imputation, and is part of the eucast_rules()
function as well:
data <- data.frame(mo = c("Staphylococcus aureus", "Enterococcus faecalis", "Escherichia coli", @@ -243,7 +252,7 @@ PEN = "S", # Benzylenicillin FOX = "S", # Cefoxitin stringsAsFactors = FALSE)
+data
+eucast_rules(data)
1 | Mono-resistant | -3262 | -65.24% | -3262 | -65.24% | +3313 | +66.26% | +3313 | +66.26% | |||
2 | Negative | -664 | -13.28% | -3926 | -78.52% | +631 | +12.62% | +3944 | +78.88% | |||
3 | Multi-drug-resistant | -609 | -12.18% | -4535 | -90.70% | +575 | +11.50% | +4519 | +90.38% | |||
4 | Poly-resistant | -283 | -5.66% | -4818 | -96.36% | +275 | +5.50% | +4794 | +95.88% | |||
5 | Extensively drug-resistant | -182 | -3.64% | +206 | +4.12% | 5000 | 100.00% | |||||
x | -a data.frame containing isolates. |
+ a data.frame containing isolates. Can be omitted when used inside |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
col_date | @@ -366,7 +366,8 @@||||||||||||
x | -a data.frame with antibiotics columns, like |
+ a data.frame with antibiotics columns, like |
||||||||||
col_mo | @@ -331,7 +331,8 @@||||||||||||
x | -data with antibiotic columns, such as |
+ a data.frame with antibiotics columns, like |
||||||||||
guideline | @@ -319,20 +319,21 @@ Ordered factor with levels||||||||||||
x | -a data.frame containing isolates. |
+ a data.frame containing isolates. Can be omitted when used inside |
||||||||||
col_ab | diff --git a/docs/survey.html b/docs/survey.html index 6751d323..5724d0ba 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index 8f5bdba8..5c81f4cd 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -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() diff --git a/man/is_new_episode.Rd b/man/is_new_episode.Rd index fd8bf1a0..1873f3ba 100644 --- a/man/is_new_episode.Rd +++ b/man/is_new_episode.Rd @@ -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)) } } +} diff --git a/man/key_antibiotics.Rd b/man/key_antibiotics.Rd index 51607a9e..8e747281 100755 --- a/man/key_antibiotics.Rd +++ b/man/key_antibiotics.Rd @@ -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) } diff --git a/man/mdro.Rd b/man/mdro.Rd index db9cd275..acc575ff 100644 --- a/man/mdro.Rd +++ b/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()) } } } diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index 94ee7d5e..d14e56e8 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -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"})} diff --git a/vignettes/EUCAST.Rmd b/vignettes/EUCAST.Rmd index 84f1c90a..6f2bcef7 100644 --- a/vignettes/EUCAST.Rmd +++ b/vignettes/EUCAST.Rmd @@ -47,7 +47,17 @@ oops eucast_rules(oops, info = FALSE) ``` -EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called *interpretive reading* and is part of the `eucast_rules()` function as well: +A more convenient function is `mo_is_intrinsic_resistant()` that uses the same guideline, but allows to check for one or more specific microorganisms or antibiotics: + +```{r, warning = FALSE, message = FALSE} +mo_is_intrinsic_resistant(c("Klebsiella", "Escherichia"), + "ampicillin") + +mo_is_intrinsic_resistant("Klebsiella", + c("ampicillin", "kanamycin")) +``` + +EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called *interpretive reading*, is basically a form of imputation, and is part of the `eucast_rules()` function as well: ```{r, warning = FALSE, message = FALSE} data <- data.frame(mo = c("Staphylococcus aureus", diff --git a/vignettes/MDR.Rmd b/vignettes/MDR.Rmd index ec2d839a..4a26b9ec 100644 --- a/vignettes/MDR.Rmd +++ b/vignettes/MDR.Rmd @@ -32,20 +32,30 @@ For WHONET data (and most other data), all settings are automatically set correc The function support multiple guidelines. You can select a guideline with the `guideline` parameter. Currently supported guidelines are (case-insensitive): * `guideline = "CMI2012"` (default) - + Magiorakos AP, Srinivasan A *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) ([link](https://www.clinicalmicrobiologyandinfection.com/article/S1198-743X(14)61632-3/fulltext)) -* `guideline = "EUCAST"` +* `guideline = "EUCAST3.2"` (or simply `guideline = "EUCAST"`) + + The European international guideline - EUCAST Expert Rules Version 3.2 "Intrinsic Resistance and Unusual Phenotypes" ([link](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/2020/Intrinsic_Resistance_and_Unusual_Phenotypes_Tables_v3.2_20200225.pdf)) + +* `guideline = "EUCAST3.1"` + The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" ([link](https://www.eucast.org/fileadmin/src/media/PDFs/EUCAST_files/Expert_Rules/Expert_rules_intrinsic_exceptional_V3.1.pdf)) + * `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" ([link](https://www.who.int/tb/publications/pmdt_companionhandbook/en/)) + * `guideline = "MRGN"` + + The German national guideline - Mueller et al. (2015) Antimicrobial Resistance and Infection Control 4:7. DOI: 10.1186/s13756-015-0047-6 - The German national guideline - Mueller et al. (2015) Antimicrobial Resistance and Infection Control 4:7. ([link](https://doi.org/10.1186/s13756-015-0047-6)) * `guideline = "BRMO"` + + The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu "WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) (ZKH)" ([link](https://www.rivm.nl/wip-richtlijn-brmo-bijzonder-resistente-micro-organismen-zkh)) - The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu "WIP-richtlijn BRMO (Bijzonder Resistente Micro-Organismen) [ZKH]" ([link](https://www.rivm.nl/Documenten_en_publicaties/Professioneel_Praktisch/Richtlijnen/Infectieziekten/WIP_Richtlijnen/WIP_Richtlijnen/Ziekenhuizen/WIP_richtlijn_BRMO_Bijzonder_Resistente_Micro_Organismen_ZKH)) +Please suggest your own (country-specific) guidelines by letting us know: