mirror of
https://github.com/msberends/AMR.git
synced 2025-07-21 00:53:20 +02:00
(v2.1.1.9151) update readme
This commit is contained in:
109
index.md
109
index.md
@ -40,7 +40,7 @@ With the help of contributors from all corners of the world, the `AMR` package i
|
||||
|
||||
#### Filtering and selecting data
|
||||
|
||||
One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called [antimicrobial class selectors](https://msberends.github.io/AMR/reference/antimicrobial_class_selectors.html), which work in base R, `dplyr` and `data.table`:
|
||||
One of the most powerful functions of this package, aside from calculating and plotting AMR, is selecting and filtering based on antimicrobial columns. This can be done using the so-called [antimicrobial selectors](https://msberends.github.io/AMR/reference/antimicrobial_selectors.html), which work in base R, `dplyr` and `data.table`.
|
||||
|
||||
```r
|
||||
# AMR works great with dplyr, but it's not required or neccesary
|
||||
@ -73,45 +73,29 @@ With only having defined a row filter on Gram-negative bacteria with intrinsic r
|
||||
|*Pseudomonas aeruginosa* | S | S | S | R | | S |
|
||||
|*Pseudomonas aeruginosa* | S | S | S | R | S | S |
|
||||
|
||||
A base R equivalent would be:
|
||||
|
||||
```r
|
||||
library(AMR)
|
||||
example_isolates$bacteria <- mo_fullname(example_isolates$mo)
|
||||
example_isolates[which(mo_is_gram_negative() &
|
||||
mo_is_intrinsic_resistant(ab = "cefotax")),
|
||||
c("bacteria", aminoglycosides(), carbapenems())]
|
||||
```
|
||||
|
||||
This base R code will work in any version of R since April 2013 (R-3.0). Moreover, this code works identically with the `data.table` package, only by starting with:
|
||||
|
||||
```r
|
||||
example_isolates <- data.table::as.data.table(example_isolates)
|
||||
```
|
||||
|
||||
#### Generating antibiograms
|
||||
|
||||
The `AMR` package supports generating traditional, combined, syndromic, and even weighted-incidence syndromic combination antibiograms (WISCA).
|
||||
|
||||
If used inside R Markdown or Quarto, the table will be printed in the right output format automatically (such as markdown, LaTeX, HTML, etc.).
|
||||
If used inside [R Markdown](https://rmarkdown.rstudio.com) or [Quarto](https://quarto.org), the table will be printed in the right output format automatically (such as markdown, LaTeX, HTML, etc.).
|
||||
|
||||
```r
|
||||
antibiogram(example_isolates,
|
||||
antibiotics = c(aminoglycosides(), carbapenems()))
|
||||
```
|
||||
|
||||
| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin |
|
||||
|:------------------------|:----------------:|:---------------:|:----------------:|:----------------:|:----------------:|:----------------:|
|
||||
| CoNS | 0% (0/43) | 86% (267/309) | 52% (25/48) | 0% (0/43) | 52% (25/48) | 22% (12/55) |
|
||||
| *E. coli* | 100% (171/171) | 98% (451/460) | 100% (422/422) | | 100% (418/418) | 97% (450/462) |
|
||||
| *E. faecalis* | 0% (0/39) | 0% (0/39) | 100% (38/38) | 0% (0/39) | | 0% (0/39) |
|
||||
| *K. pneumoniae* | | 90% (52/58) | 100% (51/51) | | 100% (53/53) | 90% (52/58) |
|
||||
| *P. aeruginosa* | | 100% (30/30) | | 0% (0/30) | | 100% (30/30) |
|
||||
| *P. mirabilis* | | 94% (32/34) | 94% (30/32) | | | 94% (32/34) |
|
||||
| *S. aureus* | | 99% (231/233) | | | | 98% (84/86) |
|
||||
| *S. epidermidis* | 0% (0/44) | 79% (128/163) | | 0% (0/44) | | 51% (45/89) |
|
||||
| *S. hominis* | | 92% (74/80) | | | | 85% (53/62) |
|
||||
| *S. pneumoniae* | 0% (0/117) | 0% (0/117) | | 0% (0/117) | | 0% (0/117) |
|
||||
| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin |
|
||||
|:-----------------|:--------------:|:--------------:|:--------------:|:----------:|:--------------:|:--------------:|
|
||||
| CoNS | 0% (0-8%) | 86% (82-90%) | 52% (37-67%) | 0% (0-8%) | 52% (37-67%) | 22% (12-35%) |
|
||||
| *E. coli* | 100% (98-100%) | 98% (96-99%) | 100% (99-100%) | | 100% (99-100%) | 97% (96-99%) |
|
||||
| *E. faecalis* | 0% (0-9%) | 0% (0-9%) | 100% (91-100%) | 0% (0-9%) | | 0% (0-9%) |
|
||||
| *K. pneumoniae* | | 90% (79-96%) | 100% (93-100%) | | 100% (93-100%) | 90% (79-96%) |
|
||||
| *P. aeruginosa* | | 100% (88-100%) | | 0% (0-12%) | | 100% (88-100%) |
|
||||
| *P. mirabilis* | | 94% (80-99%) | 94% (79-99%) | | | 94% (80-99%) |
|
||||
| *S. aureus* | | 99% (97-100%) | | | | 98% (92-100%) |
|
||||
| *S. epidermidis* | 0% (0-8%) | 79% (71-85%) | | 0% (0-8%) | | 51% (40-61%) |
|
||||
| *S. hominis* | | 92% (84-97%) | | | | 85% (74-93%) |
|
||||
| *S. pneumoniae* | 0% (0-3%) | 0% (0-3%) | | 0% (0-3%) | | 0% (0-3%) |
|
||||
|
||||
In combination antibiograms, it is clear that combined antibiotics yield higher empiric coverage:
|
||||
|
||||
@ -121,10 +105,10 @@ antibiogram(example_isolates,
|
||||
mo_transform = "gramstain")
|
||||
```
|
||||
|
||||
| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|
||||
|:--------------|:-----------------------:|:-------------------------------------:|:------------------------------------:|
|
||||
| Gram-negative | 88% (565/641) | 99% (681/691) | 98% (679/693) |
|
||||
| Gram-positive | 86% (296/345) | 98% (1018/1044) | 95% (524/550) |
|
||||
|Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|
||||
|:-------------|:-----------------------:|:------------------------------------:|:------------------------------------:|
|
||||
|Gram-negative | 88% (85-91%) | 99% (97-99%) | 98% (97-99%) |
|
||||
|Gram-positive | 86% (82-89%) | 98% (96-98%) | 95% (93-97%) |
|
||||
|
||||
Like many other functions in this package, `antibiogram()` comes with support for 20 languages that are often detected automatically based on system language:
|
||||
|
||||
@ -136,10 +120,47 @@ antibiogram(example_isolates,
|
||||
language = "uk") # Ukrainian
|
||||
```
|
||||
|
||||
| Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин |
|
||||
|:---------------|:--------------------:|:-------------------:|:------------------:|
|
||||
| Грамнегативні | 96% (659/684) | 96% (658/686) | 91% (621/684) |
|
||||
| Грампозитивні | 63% (740/1170) | 34% (228/665) | 77% (560/724) |
|
||||
|Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин |
|
||||
|:-------------|:------------:|:------------:|:--------------:|
|
||||
|Грамнегативні | 96% (95-98%) | 96% (94-97%) | 91% (88-93%) |
|
||||
|Грампозитивні | 63% (60-66%) | 34% (31-38%) | 77% (74-80%) |
|
||||
|
||||
#### Interpreting and plotting MIC and SIR values
|
||||
|
||||
The `AMR` package allows interpretation of MIC and disk diffusion values based on CLSI and EUCAST. Moreover, the `ggplot2` package is extended with new scale functions, to allow plotting of log2-distributed MIC values and SIR values.
|
||||
|
||||
```r
|
||||
library(ggplot2)
|
||||
library(AMR)
|
||||
|
||||
# generate some random values
|
||||
some_mic_values <- random_mic(size = 100)
|
||||
some_groups <- sample(LETTERS[1:5], 20, replace = TRUE)
|
||||
interpretation <- as.sir(some_mic_values,
|
||||
guideline = "EUCAST 2024",
|
||||
mo = "E. coli", # or any code or name resembling a known species
|
||||
ab = "Cipro") # or any code or name resembling an antibiotic
|
||||
|
||||
# create the plot
|
||||
ggplot(data.frame(mic = some_mic_values,
|
||||
group = some_groups,
|
||||
sir = interpretation),
|
||||
aes(x = group, y = mic, colour = sir)) +
|
||||
theme_minimal() +
|
||||
geom_boxplot(fill = NA, colour = "grey") +
|
||||
geom_jitter(width = 0.25) +
|
||||
|
||||
# NEW scale function: plot MIC values to x, y, colour or fill
|
||||
scale_y_mic() +
|
||||
|
||||
# NEW scale function: write out S/I/R in any of the 20 supported languages
|
||||
# and set colourblind-friendly colours
|
||||
scale_colour_sir()
|
||||
```
|
||||
|
||||
<a href="./reference/plotting.html" title="Plotting Helpers for AMR Data Analysis">
|
||||
<img src="./plot_readme.png" style="max-width: 600px;">
|
||||
</a>
|
||||
|
||||
#### Calculating resistance per group
|
||||
|
||||
@ -156,13 +177,13 @@ example_isolates %>%
|
||||
conf_int = function(x) sir_confidence_interval(x, collapse = "-"))))
|
||||
```
|
||||
|
||||
|ward | GEN_total_R|GEN_conf_int | TOB_total_R|TOB_conf_int |
|
||||
|:---------:|:----------:|:-----------:|:----------:|:-----------:|
|
||||
|Clinical | 0.229 |0.205-0.254 | 0.315 |0.284-0.347 |
|
||||
|ICU | 0.290 |0.253-0.330 | 0.400 |0.353-0.449 |
|
||||
|Outpatient | 0.200 |0.131-0.285 | 0.368 |0.254-0.493 |
|
||||
|ward | GEN_total_R | GEN_conf_int | TOB_total_R | TOB_conf_int |
|
||||
|:----------|:-----------:|:------------:|:-----------:|:------------:|
|
||||
|Clinical | 0.2289362 | 0.205-0.254 | 0.3147503 | 0.284-0.347 |
|
||||
|ICU | 0.2902655 | 0.253-0.33 | 0.4004739 | 0.353-0.449 |
|
||||
|Outpatient | 0.2000000 | 0.131-0.285 | 0.3676471 | 0.254-0.493 |
|
||||
|
||||
Or use [antimicrobial class selectors](https://msberends.github.io/AMR/reference/antimicrobial_class_selectors.html) to select a series of antibiotic columns:
|
||||
Or use [antimicrobial selectors](https://msberends.github.io/AMR/reference/antimicrobial_selectors.html) to select a series of antibiotic columns:
|
||||
|
||||
```r
|
||||
library(AMR)
|
||||
|
Reference in New Issue
Block a user