1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 11:11:54 +02:00

added mdr_tb()

This commit is contained in:
2019-05-23 16:58:59 +02:00
parent 07d26cd485
commit 60983a1640
60 changed files with 1479 additions and 626 deletions

79
vignettes/MDR.Rmd Normal file
View File

@ -0,0 +1,79 @@
---
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
# with the probabilities 50%-10%-40%
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)
```
And review the result with a frequency table:
```{r}
freq(my_TB_data$mdr)
```

View File

@ -128,7 +128,7 @@ septic_patients %>%
## Assigning a frequency table to an object
A frequency table is actaually a regular `data.frame`, with the exception that it contains an additional class.
A frequency table is actually a regular `data.frame`, with the exception that it contains an additional class.
```{r, echo = TRUE}
my_df <- septic_patients %>% freq(age)
@ -144,15 +144,17 @@ dim(my_df)
## Additional parameters
### Parameter `na.rm`
With the `na.rm` parameter (defaults to `TRUE`, but they will always be shown into the header), you can include `NA` values in the frequency table:
With the `na.rm` parameter you can remove `NA` values from the frequency table (defaults to `TRUE`, but the number of `NA` values will always be shown into the header):
```{r, echo = TRUE}
septic_patients %>%
freq(AMX, na.rm = FALSE)
septic_patients %>%
freq(AMX, na.rm = FALSE)
```
### Parameter `row.names`
The default frequency tables shows row indices. To remove them, use `row.names = FALSE`:
A frequency table shows row indices. To remove them, use `row.names = FALSE`:
```{r, echo = TRUE}
septic_patients %>%