mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 18:22:02 +02:00
(v0.8.0.9021) update vignettes
This commit is contained in:
@ -144,13 +144,9 @@ Now, let's start the cleaning and the analysis!
|
||||
|
||||
# Cleaning the data
|
||||
|
||||
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:
|
||||
We also created a package dedicated to data cleaning and checking, called the `cleaner` package. It gets automatically installed with the `AMR` package. For its `freq()` function to create frequency tables, you don't even need to load it yourself as it is available through the `AMR` package as well.
|
||||
|
||||
```{r lib clean, message = FALSE}
|
||||
library(clean)
|
||||
```
|
||||
|
||||
Use the frequency table function `freq()` from this `clean` package to look specifically for unique values in any variable. For example, for the `gender` variable:
|
||||
For example, for the `gender` variable:
|
||||
|
||||
```{r freq gender 1, eval = FALSE}
|
||||
data %>% freq(gender) # this would be the same: freq(data$gender)
|
||||
@ -210,7 +206,7 @@ data <- data %>%
|
||||
mutate(first = first_isolate(.))
|
||||
```
|
||||
|
||||
So only `r AMR:::percentage(sum(data$first) / nrow(data))` is suitable for resistance analysis! We can now filter on it with the `filter()` function, also from the `dplyr` package:
|
||||
So only `r cleaner::percentage(sum(data$first) / nrow(data))` is suitable for resistance analysis! We can now filter on it with the `filter()` function, also from the `dplyr` package:
|
||||
|
||||
```{r 1st isolate filter}
|
||||
data_1st <- data %>%
|
||||
@ -230,7 +226,7 @@ data_1st <- data %>%
|
||||
weighted_df <- data %>%
|
||||
filter(bacteria == as.mo("E. coli")) %>%
|
||||
# only most prevalent patient
|
||||
filter(patient_id == top_freq(freq(., patient_id), 1)[1]) %>%
|
||||
filter(patient_id == cleaner::top_freq(freq(., patient_id), 1)[1]) %>%
|
||||
arrange(date) %>%
|
||||
select(date, patient_id, bacteria, AMX:GEN, first) %>%
|
||||
# maximum of 10 rows
|
||||
@ -260,7 +256,7 @@ data <- data %>%
|
||||
weighted_df2 <- data %>%
|
||||
filter(bacteria == as.mo("E. coli")) %>%
|
||||
# only most prevalent patient
|
||||
filter(patient_id == top_freq(freq(., patient_id), 1)[1]) %>%
|
||||
filter(patient_id == cleaner::top_freq(freq(., patient_id), 1)[1]) %>%
|
||||
arrange(date) %>%
|
||||
select(date, patient_id, bacteria, AMX:GEN, first, first_weighted) %>%
|
||||
# maximum of 10 rows
|
||||
@ -272,7 +268,7 @@ weighted_df2 %>%
|
||||
knitr::kable(align = "c")
|
||||
```
|
||||
|
||||
Instead of `r sum(weighted_df$first)`, now `r sum(weighted_df2$first_weighted)` isolates are flagged. In total, `r AMR:::percentage(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r AMR:::percentage((sum(data$first_weighted) / nrow(data)) - (sum(data$first) / nrow(data)))` more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
|
||||
Instead of `r sum(weighted_df$first)`, now `r sum(weighted_df2$first_weighted)` isolates are flagged. In total, `r cleaner::percentage(sum(data$first_weighted) / nrow(data))` of all isolates are marked 'first weighted' - `r cleaner::percentage((sum(data$first_weighted) / nrow(data)) - (sum(data$first) / nrow(data)))` more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
|
||||
|
||||
As with `filter_first_isolate()`, there's a shortcut for this new algorithm too:
|
||||
```{r 1st isolate filter 3, results = 'hide', message = FALSE, warning = FALSE}
|
||||
|
@ -21,6 +21,7 @@ knitr::opts_chunk$set(
|
||||
fig.width = 7.5,
|
||||
fig.height = 4.5
|
||||
)
|
||||
library(AMR)
|
||||
```
|
||||
|
||||
## Introduction
|
||||
@ -31,12 +32,17 @@ What are EUCAST rules? The European Committee on Antimicrobial Susceptibility Te
|
||||
|
||||
In Europe, a lot of medical microbiological laboratories already apply these rules ([Brown *et al.*, 2015](https://www.eurosurveillance.org/content/10.2807/1560-7917.ES2015.20.2.21008)). Our package features their latest insights on intrinsic resistance and exceptional phenotypes (version 9.0, 2019). Moreover, the `eucast_rules()` function we use for this purpose can also apply additional rules, like forcing <help title="ATC: J01CA01">ampicillin</help> = R in isolates when <help title="ATC: J01CR02">amoxicillin/clavulanic acid</help> = R.
|
||||
|
||||
*(more will be available soon)*
|
||||
|
||||
### Benefit for empiric therapy success estimation
|
||||
|
||||
*(will be available soon)*
|
||||
|
||||
## Examples
|
||||
|
||||
*(will be available soon)*
|
||||
These rules can be used to discard impossible bug-drug combinations in your data. For example, *Klebsiella* produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, every strain of *Klebsiella* is resistant to ampicillin.
|
||||
|
||||
Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, *Klebsiella*). EUCAST expert rules solves this:
|
||||
|
||||
```{r, warning = FALSE, message = FALSE}
|
||||
oops <- data.frame(mo = c("Klebsiella",
|
||||
"Escherichia"),
|
||||
ampicillin = "S")
|
||||
oops
|
||||
|
||||
eucast_rules(oops, info = FALSE)
|
||||
```
|
||||
|
@ -21,13 +21,54 @@ knitr::opts_chunk$set(
|
||||
library(AMR)
|
||||
```
|
||||
|
||||
With the function `mdro()`, you can determine multi-drug resistant organisms (MDRO). It currently support these guidelines:
|
||||
With the function `mdro()`, you can determine multi-drug resistant organisms (MDRO).
|
||||
|
||||
* "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)
|
||||
#### Type of input
|
||||
|
||||
As an example, I will make a data set to determine multi-drug resistant TB:
|
||||
The `mdro()` takes a data set as input, such as a regular `data.frame`. It automatically determines the right columns for info about your isolates, like 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`.
|
||||
|
||||
For WHONET data (and most other data), all settings are automatically set correctly.
|
||||
|
||||
#### Guidelines
|
||||
|
||||
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"`
|
||||
|
||||
The European international guideline - EUCAST Expert Rules Version 3.1 "Intrinsic Resistance and Exceptional Phenotypes Tables" ([link](http://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. ([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/Documenten_en_publicaties/Professioneel_Praktisch/Richtlijnen/Infectieziekten/WIP_Richtlijnen/WIP_Richtlijnen/Ziekenhuizen/WIP_richtlijn_BRMO_Bijzonder_Resistente_Micro_Organismen_ZKH))
|
||||
|
||||
#### Examples
|
||||
|
||||
The `mdro()` function always returns an ordered `factor`. 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. If we test that guideline on the included `example_isolates` data set, we get:
|
||||
|
||||
```{r, message = FALSE}
|
||||
library(dplyr) # to support pipes: %>%
|
||||
```
|
||||
```{r, results = 'hide'}
|
||||
example_isolates %>%
|
||||
mdro() %>%
|
||||
freq() # show frequency table of the result
|
||||
```
|
||||
```{r, echo = FALSE, results = 'asis', message = FALSE, warning = FALSE}
|
||||
library(dplyr) # to support pipes: %>%
|
||||
example_isolates %>%
|
||||
mdro(info = FALSE) %>%
|
||||
freq() # show frequency table of the result
|
||||
```
|
||||
|
||||
For another example, I will create a data set to determine multi-drug resistant TB:
|
||||
|
||||
```{r}
|
||||
# a helper function to get a random vector with values S, I and R
|
||||
@ -60,25 +101,25 @@ my_TB_data <- data.frame(RIF = sample_rsi(),
|
||||
KAN = sample_rsi())
|
||||
```
|
||||
|
||||
The data set looks like this now:
|
||||
The data set now looks like this:
|
||||
|
||||
```{r}
|
||||
head(my_TB_data)
|
||||
```
|
||||
|
||||
We can now add the interpretation of MDR-TB to our data set:
|
||||
We can now add the interpretation of MDR-TB to our data set. You can use:
|
||||
|
||||
```r
|
||||
mdro(my_TB_data, guideline = "TB")
|
||||
```
|
||||
|
||||
or its shortcut `mdr_tb()`:
|
||||
|
||||
```{r}
|
||||
my_TB_data$mdr <- mdr_tb(my_TB_data)
|
||||
```
|
||||
|
||||
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:
|
||||
Create a frequency table of the results:
|
||||
|
||||
```{r, results = 'asis'}
|
||||
freq(my_TB_data$mdr)
|
||||
|
@ -23,7 +23,7 @@ knitr::opts_chunk$set(
|
||||
)
|
||||
```
|
||||
|
||||
# Import of data
|
||||
### Import of data
|
||||
|
||||
This tutorial assumes you already imported the WHONET data with e.g. the [`readxl` package](https://readxl.tidyverse.org/). In RStudio, this can be done using the menu button 'Import Dataset' in the tab 'Environment'. Choose the option 'From Excel' and select your exported file. Make sure date fields are imported correctly.
|
||||
|
||||
@ -36,7 +36,7 @@ data <- read_excel(path = "path/to/your/file.xlsx")
|
||||
|
||||
This package comes with an [example data set `WHONET`](https://msberends.gitlab.io/AMR/reference/WHONET.html). We will use it for this analysis.
|
||||
|
||||
# Preparation
|
||||
### Preparation
|
||||
|
||||
First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don't know it yet, I suggest you read about it on their website: https://www.tidyverse.org/.
|
||||
|
||||
@ -62,13 +62,7 @@ data <- WHONET %>%
|
||||
|
||||
No errors or warnings, so all values are transformed succesfully.
|
||||
|
||||
We 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 frequency tables.
|
||||
We also created a package dedicated to data cleaning and checking, called the `cleaner` package. It gets automatically installed with the `AMR` package. For its `freq()` function to create frequency tables, you don't even need to load it yourself as it is available through the `AMR` package as well.
|
||||
|
||||
So let's check our data, with a couple of frequency tables:
|
||||
|
||||
@ -81,7 +75,10 @@ data %>% freq(mo, nmax = 10)
|
||||
data %>% freq(AMC_ND2)
|
||||
```
|
||||
|
||||
# Analysis
|
||||
### A first glimpse at results
|
||||
|
||||
*(more will be available soon)*
|
||||
An easy ggplot will already give a lot of information, using the included `ggplot_rsi()` function:
|
||||
|
||||
```{r}
|
||||
ggplot_rsi(data, translate_ab = 'ab')
|
||||
```
|
||||
|
Reference in New Issue
Block a user