NEWS.md
- Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the eucast_rules()
function and in as.rsi()
to interpret MIC and disk diffusion values. This is now the default guideline in this package.
Data set dosage
to fuel the new eucast_dosage()
function and to make this data available in a structured way
Function eucast_dosage()
to get a data.frame
with advised dosages of a certain bug-drug combination, which is based on the new dosage
data set
Support for custom MDRO guidelines, using the new custom_mdro_guideline()
function, please see mdro()
for additional info
Function isolate_identifier()
, which will paste a microorganism code with all antimicrobial results of a data set into one string for each row. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available.
Function mo_is_yeast()
, which determines whether a microorganism is a member of the taxonomic class Saccharomycetes or the taxonomic order Saccharomycetales:
mdro()
brmo()
mrgn()
mdr_tb()
mdr_cmi2012()
eucast_exceptional_phenotypes()
mdro()
custom_mdro_guideline()
brmo()
mrgn()
mdr_tb()
mdr_cmi2012()
eucast_exceptional_phenotypes()
Determine multidrug-resistant organisms (MDRO)
Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines.
+Determine which isolates are multidrug-resistant organisms (MDRO) according to international, national and custom guidelines.
mdro( @@ -253,6 +253,8 @@ ... ) +custom_mdro_guideline(...) + brmo(x, guideline = "BRMO", ...) mrgn(x, guideline = "MRGN", ...) @@ -272,7 +274,7 @@
a specific guideline to follow. When left empty, the publication by Magiorakos et al. (2012, Clinical Microbiology and Infection) will be followed, please see Details.
a specific guideline to follow. Can also have custom_mdro_guideline()
as input. When left empty, the publication by Magiorakos et al. (2012, Clinical Microbiology and Infection) will be followed, please see Details.
Negative
< Mono-resistant
< Poly-resistant
< Multi-drug-resistant
< Extensively drug-resistant
German guideline - function mrgn()
or mdro(..., guideline = "MRGN")
:
Ordered factor with levels Negative
< 3MRGN
< 4MRGN
Everything else:
+
Everything else, except for custom guidelines:
Ordered factor with levels Negative
< Positive, unconfirmed
< Positive
. The value "Positive, unconfirmed"
means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests
dplyr
verbs, such as filter()
, mutate()
and summarise()
. This means that then the x
argument can be left blank, please see Examples.
For the pct_required_classes
argument, values above 1 will be divided by 100. This is to support both fractions (0.75
or 3/4
) and percentages (75
).
Note: Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named order Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu et al. in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this mdro()
function makes sure that results from before 2016 and after 2016 are identical.
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)
Please suggest your own (country-specific) guidelines by letting us know: https://github.com/msberends/AMR/issues/new.
-Note: Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named order Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu et al. in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this mdro()
function makes sure that results from before 2016 and after 2016 are identical.
Custom guidelines can be set with the custom_mdro_guideline()
function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data.
If you are familiar with case_when()
of the dplyr
package, you will recognise the input method to set your own rules. Rules must be set using what R considers to be the 'formula notation':
custom <- custom_mdro_guideline("CIP == 'R' & age > 60" ~ "Elderly Type A", + "ERY == 'R' & age > 60" ~ "Elderly Type B") ++ +
If a row/an isolate matches the first rule, the value after the first ~
(in this case 'Elderly Type A') will be set as MDRO value. Otherwise, the second rule will be tried and so on. The number of rules is unlimited.
You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.
custom +#> A set of custom MDRO rules: +#> 1. CIP == "R" & age > 60 -> "Elderly Type A" +#> 2. ERY == "R" & age > 60 -> "Elderly Type B" +#> 3. Otherwise -> "Negative" +#> +#> Unmatched rows will return NA. ++ +
The outcome of the function can be used for the guideline
argument in the mdro()
function:
x <- mdro(example_isolates, guideline = custom) +table(x) ++ +
The rules set (the custom
object in this case) could be exported to a shared file location using saveRDS()
if you collaborate with multiple users. The custom rules set could then be imported using readRDS()
,
mdro(example_isolates, guideline = "EUCAST") +mdro(example_isolates, + guideline = custom_mdro_guideline("AMX == 'R'" ~ "Custom MDRO 1", + "VAN == 'R'" ~ "Custom MDRO 2")) + # \donttest{ if (require("dplyr")) { example_isolates %>% diff --git a/docs/survey.html b/docs/survey.html index f73840db..1c39a2ac 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ diff --git a/man/mdro.Rd b/man/mdro.Rd index a1c16b5f..096759aa 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -8,6 +8,7 @@ \alias{BRMO} \alias{3MRGN} \alias{4MRGN} +\alias{custom_mdro_guideline} \alias{brmo} \alias{mrgn} \alias{mdr_tb} @@ -29,6 +30,8 @@ mdro( ... ) +custom_mdro_guideline(...) + brmo(x, guideline = "BRMO", ...) mrgn(x, guideline = "MRGN", ...) @@ -42,7 +45,7 @@ eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...) \arguments{ \item{x}{a \link{data.frame} with antibiotics columns, like \code{AMX} or \code{amox}. Can be left blank for automatic determination.} -\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}.} +\item{guideline}{a specific guideline to follow. Can also have \code{\link[=custom_mdro_guideline]{custom_mdro_guideline()}} as input. When left empty, the publication by Magiorakos \emph{et al.} (2012, Clinical Microbiology and Infection) will be followed, please see \emph{Details}.} \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()}}.} @@ -64,18 +67,21 @@ Ordered \link{factor} with levels \code{Negative} < \code{Multi-drug-resistant ( Ordered \link{factor} with levels \code{Negative} < \code{Mono-resistant} < \code{Poly-resistant} < \code{Multi-drug-resistant} < \verb{Extensively drug-resistant} \item German guideline - function \code{\link[=mrgn]{mrgn()}} or \code{\link[=mdro]{mdro(..., guideline = "MRGN")}}:\cr Ordered \link{factor} with levels \code{Negative} < \verb{3MRGN} < \verb{4MRGN} -\item Everything else:\cr +\item Everything else, except for custom guidelines:\cr Ordered \link{factor} with levels \code{Negative} < \verb{Positive, unconfirmed} < \code{Positive}. The value \code{"Positive, unconfirmed"} means that, according to the guideline, it is not entirely sure if the isolate is multi-drug resistant and this should be confirmed with additional (e.g. molecular) tests } } \description{ -Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines. +Determine which isolates are multidrug-resistant organisms (MDRO) according to international, national and custom 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} argument can be left blank, 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}). +\strong{Note:} Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named \emph{order} Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu \emph{et al.} in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this \code{\link[=mdro]{mdro()}} function makes sure that results from before 2016 and after 2016 are identical. +\subsection{International / National guidelines}{ + Currently supported guidelines are (case-insensitive): \itemize{ \item \code{guideline = "CMI2012"} (default) @@ -99,8 +105,33 @@ The Dutch national guideline - Rijksinstituut voor Volksgezondheid en Milieu "WI } Please suggest your own (country-specific) guidelines by letting us know: \url{https://github.com/msberends/AMR/issues/new}. +} -\strong{Note:} Every test that involves the Enterobacteriaceae family, will internally be performed using its newly named \emph{order} Enterobacterales, since the Enterobacteriaceae family has been taxonomically reclassified by Adeolu \emph{et al.} in 2016. Before that, Enterobacteriaceae was the only family under the Enterobacteriales (with an i) order. All species under the old Enterobacteriaceae family are still under the new Enterobacterales (without an i) order, but divided into multiple families. The way tests are performed now by this \code{\link[=mdro]{mdro()}} function makes sure that results from before 2016 and after 2016 are identical. +\subsection{Custom guidelines}{ + +Custom guidelines can be set with the \code{\link[=custom_mdro_guideline]{custom_mdro_guideline()}} function. This is of great importance if you have custom rules to determine MDROs in your hospital, e.g., rules that are dependent on ward, state of contact isolation or other variables in your data. + +If you are familiar with \code{case_when()} of the \code{dplyr} package, you will recognise the input method to set your own rules. Rules must be set using what \R considers to be the 'formula notation':\preformatted{custom <- custom_mdro_guideline("CIP == 'R' & age > 60" ~ "Elderly Type A", + "ERY == 'R' & age > 60" ~ "Elderly Type B") +} + +If a row/an isolate matches the first rule, the value after the first \code{~} (in this case \emph{'Elderly Type A'}) will be set as MDRO value. Otherwise, the second rule will be tried and so on. The number of rules is unlimited. + +You can print the rules set in the console for an overview. Colours will help reading it if your console supports colours.\preformatted{custom +#> A set of custom MDRO rules: +#> 1. CIP == "R" & age > 60 -> "Elderly Type A" +#> 2. ERY == "R" & age > 60 -> "Elderly Type B" +#> 3. Otherwise -> "Negative" +#> +#> Unmatched rows will return NA. +} + +The outcome of the function can be used for the \code{guideline} argument in the \code{\link[=mdro]{mdro()}} function:\preformatted{x <- mdro(example_isolates, guideline = custom) +table(x) +} + +The rules set (the \code{custom} object in this case) could be exported to a shared file location using \code{\link[=saveRDS]{saveRDS()}} if you collaborate with multiple users. The custom rules set could then be imported using \code{\link[=readRDS]{readRDS()}}, +} } \section{Stable lifecycle}{ @@ -142,6 +173,10 @@ On our website \url{https://msberends.github.io/AMR/} you can find \href{https:/ \examples{ mdro(example_isolates, guideline = "EUCAST") +mdro(example_isolates, + guideline = custom_mdro_guideline("AMX == 'R'" ~ "Custom MDRO 1", + "VAN == 'R'" ~ "Custom MDRO 2")) + \donttest{ if (require("dplyr")) { example_isolates \%>\% diff --git a/tests/testthat/test-mdro.R b/tests/testthat/test-mdro.R index e66c07d4..9ca66ce1 100755 --- a/tests/testthat/test-mdro.R +++ b/tests/testthat/test-mdro.R @@ -223,4 +223,15 @@ test_that("mdro works", { expect_equal(as.integer(mdro(acin)), c(1:4)) expect_s3_class(mdro(acin, verbose = TRUE), "data.frame") + # custom rules + custom <- custom_mdro_guideline("CIP == 'R' & age > 60" ~ "Elderly Type A", + "ERY == 'R' & age > 60" ~ "Elderly Type B") + expect_output(print(custom)) + x <- mdro(example_isolates, guideline = custom, info = TRUE) + expect_equal(as.double(table(x)), c(43, 891, 1066)) + expect_error(custom_mdro_guideline()) + expect_error(custom_mdro_guideline("test")) + expect_error(custom_mdro_guideline("test" ~ c(1:3))) + expect_error(custom_mdro_guideline("test" ~ A)) + })