AMR/vignettes/MDR.Rmd

86 lines
2.7 KiB
Plaintext
Raw Normal View History

2019-05-23 16:58:59 +02:00
---
title: "How to determine multi-drug resistance (MDR)"
author: "Matthijs S. Berends"
date: '`r format(Sys.Date(), "%d %B %Y")`'
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,
comment = "#"
)
library(AMR)
```
With the function `mdro()`, you can determine multi-drug resistant organisms (MDRO). It currently support these guidelines:
* "Intrinsic Resistance and Exceptional Phenotypes Tables", by EUCAST (European Committee on Antimicrobial Susceptibility Testing)
* "Companion handbook to the WHO guidelines for the programmatic management of drug-resistant tuberculosis", by WHO (World Health Organization)
* "WIP-Richtlijn Bijzonder Resistente Micro-organismen (BRMO)", by RIVM (Rijksinstituut voor de Volksgezondheid, the Netherlands National Institute for Public Health and the Environment)
As an example, I will make a data set to determine multi-drug resistant TB:
```{r}
# a helper function to get a random vector with values S, I and R
2019-09-26 21:58:06 +02:00
# with the probabilities 50% - 10% - 40%
2019-05-23 16:58:59 +02:00
sample_rsi <- function() {
sample(c("S", "I", "R"),
size = 5000,
prob = c(0.5, 0.1, 0.4),
replace = TRUE)
}
my_TB_data <- data.frame(rifampicin = sample_rsi(),
isoniazid = sample_rsi(),
gatifloxacin = sample_rsi(),
ethambutol = sample_rsi(),
pyrazinamide = sample_rsi(),
moxifloxacin = sample_rsi(),
kanamycin = sample_rsi())
```
Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:
```{r, eval = FALSE}
my_TB_data <- data.frame(RIF = sample_rsi(),
INH = sample_rsi(),
GAT = sample_rsi(),
ETH = sample_rsi(),
PZA = sample_rsi(),
MFX = sample_rsi(),
KAN = sample_rsi())
```
The data set looks like this now:
```{r}
head(my_TB_data)
```
We can now add the interpretation of MDR-TB to our data set:
```{r}
my_TB_data$mdr <- mdr_tb(my_TB_data)
```
2019-07-29 13:33:48 +02:00
We also created a package dedicated to data cleaning and checking, called the `clean` package. It gets automatically installed with the `AMR` package, so we only have to load it:
```{r lib clean, message = FALSE}
library(clean)
```
It contains the `freq()` function, to create a frequency table:
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)
```