1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-28 04:46:11 +01:00
AMR/vignettes/MDR.Rmd

164 lines
6.4 KiB
Plaintext
Raw Normal View History

2019-05-23 16:58:59 +02:00
---
title: "How to determine multi-drug resistance (MDR)"
output:
rmarkdown::html_vignette:
toc: true
vignette: >
%\VignetteIndexEntry{How to determine multi-drug resistance (MDR)}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---
```{r setup, include = FALSE, results = 'markup'}
knitr::opts_chunk$set(
collapse = TRUE,
2023-02-18 11:57:17 +01:00
comment = "#>"
2019-05-23 16:58:59 +02:00
)
library(AMR)
```
With the function `mdro()`, you can determine which micro-organisms are multi-drug resistant organisms (MDRO).
2019-05-23 16:58:59 +02:00
### Type of input
2019-05-23 16:58:59 +02:00
The `mdro()` function takes a data set as input, such as a regular `data.frame`. It tries to automatically determine the right columns for info about your isolates, such as the name of the species and all columns with results of antimicrobial agents. See the help page for more info about how to set the right settings for your data with the command `?mdro`.
2019-11-09 11:33:22 +01:00
For WHONET data (and most other data), all settings are automatically set correctly.
### Guidelines
2019-11-09 11:33:22 +01:00
The `mdro()` function support multiple guidelines. You can select a guideline with the `guideline` parameter. Currently supported guidelines are (case-insensitive):
2019-11-09 11:33:22 +01:00
* `guideline = "CMI2012"` (default)
2019-11-09 11:33:22 +01:00
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 = "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"`
2020-10-08 11:16:03 +02:00
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))
2019-11-09 11:33:22 +01:00
* `guideline = "TB"`
2019-11-09 11:33:22 +01:00
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/))
2019-11-09 11:33:22 +01:00
* `guideline = "MRGN"`
The German national guideline - Mueller *et al.* (2015) Antimicrobial Resistance and Infection Control 4:7. DOI: 10.1186/s13756-015-0047-6
2019-11-09 11:33:22 +01:00
* `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))
2019-11-09 11:33:22 +01:00
Please suggest your own (country-specific) guidelines by letting us know: <https://github.com/msberends/AMR/issues/new>.
#### Custom Guidelines
You can also use your own custom guideline. 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':
```{r}
2022-08-28 10:31:50 +02:00
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 maximum 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.
```{r}
custom
```
The outcome of the function can be used for the `guideline` argument in the `mdro()` function:
```{r}
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()`.
2019-11-09 11:33:22 +01:00
### Examples
2019-11-09 11:33:22 +01:00
The `mdro()` function always returns an ordered `factor` for predefined guidelines. For example, the output of the default guideline by Magiorakos *et al.* returns a `factor` with levels 'Negative', 'MDR', 'XDR' or 'PDR' in that order.
The next example uses the `example_isolates` data set. This is a data set included with this package and contains full antibiograms of 2,000 microbial isolates. It reflects reality and can be used to practise AMR data analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:
2019-11-09 11:33:22 +01:00
```{r, message = FALSE}
2022-08-28 10:31:50 +02:00
library(dplyr) # to support pipes: %>%
2020-05-19 14:16:45 +02:00
library(cleaner) # to create frequency tables
2019-11-09 11:33:22 +01:00
```
```{r, results = 'hide'}
2022-08-28 10:31:50 +02:00
example_isolates %>%
mdro() %>%
2019-11-09 11:33:22 +01:00
freq() # show frequency table of the result
```
```{r, echo = FALSE, results = 'asis', message = FALSE, warning = FALSE}
2022-08-28 10:31:50 +02:00
example_isolates %>%
mdro(info = FALSE) %>%
2019-11-09 11:33:22 +01:00
freq() # show frequency table of the result
```
For another example, I will create a data set to determine multi-drug resistant TB:
2019-05-23 16:58:59 +02:00
```{r}
2023-01-21 23:47:20 +01:00
# random_sir() is a helper function to generate
# a random vector with values S, I and R
2022-08-28 10:31:50 +02:00
my_TB_data <- data.frame(
2023-01-21 23:47:20 +01:00
rifampicin = random_sir(5000),
isoniazid = random_sir(5000),
gatifloxacin = random_sir(5000),
ethambutol = random_sir(5000),
pyrazinamide = random_sir(5000),
moxifloxacin = random_sir(5000),
kanamycin = random_sir(5000)
2022-08-28 10:31:50 +02:00
)
2019-05-23 16:58:59 +02:00
```
Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same way:
2019-05-23 16:58:59 +02:00
```{r, eval = FALSE}
2022-08-28 10:31:50 +02:00
my_TB_data <- data.frame(
2023-01-21 23:47:20 +01:00
RIF = random_sir(5000),
INH = random_sir(5000),
GAT = random_sir(5000),
ETH = random_sir(5000),
PZA = random_sir(5000),
MFX = random_sir(5000),
KAN = random_sir(5000)
2022-08-28 10:31:50 +02:00
)
2019-05-23 16:58:59 +02:00
```
2019-11-09 11:33:22 +01:00
The data set now looks like this:
2019-05-23 16:58:59 +02:00
```{r}
head(my_TB_data)
```
2019-11-09 11:33:22 +01:00
We can now add the interpretation of MDR-TB to our data set. You can use:
2019-05-23 16:58:59 +02:00
2019-11-09 11:33:22 +01:00
```r
mdro(my_TB_data, guideline = "TB")
2019-05-23 16:58:59 +02:00
```
2019-11-09 11:33:22 +01:00
or its shortcut `mdr_tb()`:
2019-07-29 13:33:48 +02:00
2019-11-09 11:33:22 +01:00
```{r}
my_TB_data$mdr <- mdr_tb(my_TB_data)
2019-07-29 13:33:48 +02:00
```
2019-11-09 11:33:22 +01:00
Create a frequency table of the results:
2019-05-23 16:58:59 +02:00
2019-05-23 18:53:18 +02:00
```{r, results = 'asis'}
2019-05-23 16:58:59 +02:00
freq(my_TB_data$mdr)
```