mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 00:10:57 +01:00
(v3.1.0.9012) Use the native R pipe throughout the examples on the website home page, and fix a typo
This commit is contained in:
1 parent
944078c4bc
commit
aab0fcc479
4 files changed
+62
-58
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 3.1.0.9011
|
Version: 3.1.0.9012
|
||||||
Date: 2026-10-30
|
Date: 2026-10-30
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# AMR 3.1.0.9011
|
# AMR 3.1.0.9012
|
||||||
|
|
||||||
This version fixes a critical bug in WISCA that biased all coverage estimates of `wisca()` and `antibiogram(..., wisca = TRUE)` downwards since AMR 3.0.0. Users are strongly advised to re-run their WISCA analyses.
|
This version fixes a critical bug in WISCA that biased all coverage estimates of `wisca()` and `antibiogram(..., wisca = TRUE)` downwards since AMR 3.0.0. Users are strongly advised to re-run their WISCA analyses.
|
||||||
|
|
||||||
|
|||||||
@@ -70,15 +70,15 @@ With the help of contributors from all corners of the world, the `AMR` package i
|
|||||||
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://amr-for-r.org/reference/antimicrobial_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://amr-for-r.org/reference/antimicrobial_selectors.html), which work in base R, `dplyr` and `data.table`.
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
# AMR works great with dplyr, but it's not required or neccesary
|
# AMR works great with dplyr, but it's not required or necessary
|
||||||
library(AMR)
|
library(AMR)
|
||||||
library(dplyr, warn.conflicts = FALSE)
|
library(dplyr, warn.conflicts = FALSE)
|
||||||
|
|
||||||
example_isolates %>%
|
example_isolates |>
|
||||||
mutate(bacteria = mo_fullname()) %>%
|
mutate(bacteria = mo_fullname()) |>
|
||||||
# filtering functions for microorganisms:
|
# filtering functions for microorganisms:
|
||||||
filter(mo_is_gram_negative(),
|
filter(mo_is_gram_negative(),
|
||||||
mo_is_intrinsic_resistant(ab = "cefotax")) %>%
|
mo_is_intrinsic_resistant(ab = "cefotax")) |>
|
||||||
# antimicrobial selectors:
|
# antimicrobial selectors:
|
||||||
select(bacteria,
|
select(bacteria,
|
||||||
aminoglycosides(),
|
aminoglycosides(),
|
||||||
@@ -94,44 +94,46 @@ The `AMR` package supports four types of antibiograms, with support for `r lengt
|
|||||||
**For empirical therapy guidance (i.e., coverage estimates), use WISCA** (Weighted-Incidence Syndromic Combination Antibiogram). When a clinician starts empirical treatment, the causative pathogen is unknown. The relevant question is not *"what percentage of E. coli is susceptible?"* but *"what is the probability that this regimen will cover whatever pathogen is causing the infection?"*. WISCA answers that question directly, weighting susceptibility by pathogen incidence and providing credible intervals via Bayesian simulation. See `vignette("WISCA")` for the full explanation.
|
**For empirical therapy guidance (i.e., coverage estimates), use WISCA** (Weighted-Incidence Syndromic Combination Antibiogram). When a clinician starts empirical treatment, the causative pathogen is unknown. The relevant question is not *"what percentage of E. coli is susceptible?"* but *"what is the probability that this regimen will cover whatever pathogen is causing the infection?"*. WISCA answers that question directly, weighting susceptibility by pathogen incidence and providing credible intervals via Bayesian simulation. See `vignette("WISCA")` for the full explanation.
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
wisca(top_n_microorganisms(example_isolates, n = 10), # 10 most common species
|
example_isolates |>
|
||||||
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
top_n_microorganisms(n = 10) |> # 10 most common species
|
||||||
minimum = 10) # Recommended threshold: >=30
|
wisca(antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
||||||
|
minimum = 10) # Recommended threshold: >=30
|
||||||
```
|
```
|
||||||
|
|
||||||
WISCA supports stratification by any clinical variable, so you can generate syndrome-specific or ward-specific coverage estimates:
|
WISCA supports stratification by any clinical variable, so you can generate syndrome-specific or ward-specific coverage estimates:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
wisca(top_n_microorganisms(example_isolates, n = 10),
|
example_isolates |>
|
||||||
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
top_n_microorganisms(n = 10) |>
|
||||||
syndromic_group = "ward",
|
wisca(antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
||||||
minimum = 10) # Recommended threshold: >=30
|
syndromic_group = "ward",
|
||||||
|
minimum = 10) # Recommended threshold: >=30
|
||||||
```
|
```
|
||||||
|
|
||||||
**For AMR surveillance**, traditional antibiograms remain the right tool for tracking resistance per species over time:
|
**For AMR surveillance**, traditional antibiograms remain the right tool for tracking resistance per species over time:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
antibiogram(example_isolates,
|
example_isolates |>
|
||||||
mo_transform = "gramstain",
|
antibiogram(mo_transform = "gramstain",
|
||||||
antimicrobials = c("AMC", carbapenems(), "TZP"))
|
antimicrobials = c("AMC", carbapenems(), "TZP"))
|
||||||
```
|
```
|
||||||
|
|
||||||
Combination antibiograms show the additional coverage gained by adding a second agent, stratified by species:
|
Combination antibiograms show the additional coverage gained by adding a second agent, stratified by species:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
antibiogram(example_isolates,
|
example_isolates |>
|
||||||
mo_transform = "gramstain",
|
antibiogram(mo_transform = "gramstain",
|
||||||
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"))
|
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"))
|
||||||
```
|
```
|
||||||
|
|
||||||
Like many other functions in this package, `antibiogram()` and `wisca()` come with support for `r length(AMR:::LANGUAGES_SUPPORTED)` languages that are often detected automatically based on system language:
|
Like many other functions in this package, `antibiogram()` and `wisca()` come with support for `r length(AMR:::LANGUAGES_SUPPORTED)` languages that are often detected automatically based on system language:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
antibiogram(example_isolates,
|
example_isolates |>
|
||||||
antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work
|
antibiogram(antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work
|
||||||
mo_transform = "gramstain",
|
mo_transform = "gramstain",
|
||||||
ab_transform = "name",
|
ab_transform = "name",
|
||||||
language = "uk") # Ukrainian
|
language = "uk") # Ukrainian
|
||||||
```
|
```
|
||||||
|
|
||||||
### Interpreting and plotting MIC and SIR values
|
### Interpreting and plotting MIC and SIR values
|
||||||
@@ -176,9 +178,9 @@ ggplot(data.frame(mic = some_mic_values,
|
|||||||
For a manual approach, you can use the `resistance` or `susceptibility()` function:
|
For a manual approach, you can use the `resistance` or `susceptibility()` function:
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
example_isolates %>%
|
example_isolates |>
|
||||||
# group by ward:
|
# group by ward:
|
||||||
group_by(ward) %>%
|
group_by(ward) |>
|
||||||
# calculate AMR using resistance() for gentamicin and tobramycin
|
# calculate AMR using resistance() for gentamicin and tobramycin
|
||||||
# and get their 95% confidence intervals using sir_confidence_interval():
|
# and get their 95% confidence intervals using sir_confidence_interval():
|
||||||
summarise(across(c(GEN, TOB),
|
summarise(across(c(GEN, TOB),
|
||||||
@@ -192,9 +194,9 @@ Or use [antimicrobial selectors](https://amr-for-r.org/reference/antimicrobial_s
|
|||||||
library(AMR)
|
library(AMR)
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
|
|
||||||
out <- example_isolates %>%
|
out <- example_isolates |>
|
||||||
# group by ward:
|
# group by ward:
|
||||||
group_by(ward) %>%
|
group_by(ward) |>
|
||||||
# calculate AMR using resistance(), over all aminoglycosides and polymyxins:
|
# calculate AMR using resistance(), over all aminoglycosides and polymyxins:
|
||||||
summarise(across(c(aminoglycosides(), polymyxins()),
|
summarise(across(c(aminoglycosides(), polymyxins()),
|
||||||
resistance))
|
resistance))
|
||||||
@@ -203,12 +205,12 @@ out
|
|||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
# transform the antibiotic columns to names:
|
# transform the antibiotic columns to names:
|
||||||
out %>% set_ab_names()
|
out |> set_ab_names()
|
||||||
```
|
```
|
||||||
|
|
||||||
```{r}
|
```{r}
|
||||||
# transform the antibiotic column to ATC codes:
|
# transform the antibiotic column to ATC codes:
|
||||||
out %>% set_ab_names(property = "atc")
|
out |> set_ab_names(property = "atc")
|
||||||
```
|
```
|
||||||
|
|
||||||
## What else can you do with this package?
|
## What else can you do with this package?
|
||||||
|
|||||||
@@ -154,15 +154,15 @@ selectors](https://amr-for-r.org/reference/antimicrobial_selectors.html),
|
|||||||
which work in base R, `dplyr` and `data.table`.
|
which work in base R, `dplyr` and `data.table`.
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
# AMR works great with dplyr, but it's not required or neccesary
|
# AMR works great with dplyr, but it's not required or necessary
|
||||||
library(AMR)
|
library(AMR)
|
||||||
library(dplyr, warn.conflicts = FALSE)
|
library(dplyr, warn.conflicts = FALSE)
|
||||||
|
|
||||||
example_isolates %>%
|
example_isolates |>
|
||||||
mutate(bacteria = mo_fullname()) %>%
|
mutate(bacteria = mo_fullname()) |>
|
||||||
# filtering functions for microorganisms:
|
# filtering functions for microorganisms:
|
||||||
filter(mo_is_gram_negative(),
|
filter(mo_is_gram_negative(),
|
||||||
mo_is_intrinsic_resistant(ab = "cefotax")) %>%
|
mo_is_intrinsic_resistant(ab = "cefotax")) |>
|
||||||
# antimicrobial selectors:
|
# antimicrobial selectors:
|
||||||
select(bacteria,
|
select(bacteria,
|
||||||
aminoglycosides(),
|
aminoglycosides(),
|
||||||
@@ -217,9 +217,10 @@ credible intervals via Bayesian simulation. See `vignette("WISCA")` for
|
|||||||
the full explanation.
|
the full explanation.
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
wisca(top_n_microorganisms(example_isolates, n = 10), # 10 most common species
|
example_isolates |>
|
||||||
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
top_n_microorganisms(n = 10) |> # 10 most common species
|
||||||
minimum = 10) # Recommended threshold: >=30
|
wisca(antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
||||||
|
minimum = 10) # Recommended threshold: >=30
|
||||||
```
|
```
|
||||||
|
|
||||||
| Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|
| Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|
||||||
@@ -230,10 +231,11 @@ WISCA supports stratification by any clinical variable, so you can
|
|||||||
generate syndrome-specific or ward-specific coverage estimates:
|
generate syndrome-specific or ward-specific coverage estimates:
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
wisca(top_n_microorganisms(example_isolates, n = 10),
|
example_isolates |>
|
||||||
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
top_n_microorganisms(n = 10) |>
|
||||||
syndromic_group = "ward",
|
wisca(antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
||||||
minimum = 10) # Recommended threshold: >=30
|
syndromic_group = "ward",
|
||||||
|
minimum = 10) # Recommended threshold: >=30
|
||||||
#> Warning: In 3 of 9 WISCA regimen(s) or group(s), the prior weight of 1 per pathogen accounts for more than
|
#> Warning: In 3 of 9 WISCA regimen(s) or group(s), the prior weight of 1 per pathogen accounts for more than
|
||||||
#> 5% of the pathogen incidence (up to 6.4%), since there are few isolates relative to the number of
|
#> 5% of the pathogen incidence (up to 6.4%), since there are few isolates relative to the number of
|
||||||
#> pathogens, i.e., rare pathogens or a small group. Because WISCA gives every pathogen a prior weight
|
#> pathogens, i.e., rare pathogens or a small group. Because WISCA gives every pathogen a prior weight
|
||||||
@@ -252,9 +254,9 @@ wisca(top_n_microorganisms(example_isolates, n = 10),
|
|||||||
for tracking resistance per species over time:
|
for tracking resistance per species over time:
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
antibiogram(example_isolates,
|
example_isolates |>
|
||||||
mo_transform = "gramstain",
|
antibiogram(mo_transform = "gramstain",
|
||||||
antimicrobials = c("AMC", carbapenems(), "TZP"))
|
antimicrobials = c("AMC", carbapenems(), "TZP"))
|
||||||
#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem)
|
#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -267,9 +269,9 @@ Combination antibiograms show the additional coverage gained by adding a
|
|||||||
second agent, stratified by species:
|
second agent, stratified by species:
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
antibiogram(example_isolates,
|
example_isolates |>
|
||||||
mo_transform = "gramstain",
|
antibiogram(mo_transform = "gramstain",
|
||||||
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"))
|
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"))
|
||||||
```
|
```
|
||||||
|
|
||||||
| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|
| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin |
|
||||||
@@ -282,11 +284,11 @@ come with support for 28 languages that are often detected automatically
|
|||||||
based on system language:
|
based on system language:
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
antibiogram(example_isolates,
|
example_isolates |>
|
||||||
antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work
|
antibiogram(antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work
|
||||||
mo_transform = "gramstain",
|
mo_transform = "gramstain",
|
||||||
ab_transform = "name",
|
ab_transform = "name",
|
||||||
language = "uk") # Ukrainian
|
language = "uk") # Ukrainian
|
||||||
```
|
```
|
||||||
|
|
||||||
| Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин |
|
| Збудник | Гентаміцин | Тобраміцин | Ципрофлоксацин |
|
||||||
@@ -340,9 +342,9 @@ For a manual approach, you can use the `resistance` or
|
|||||||
`susceptibility()` function:
|
`susceptibility()` function:
|
||||||
|
|
||||||
``` r
|
``` r
|
||||||
example_isolates %>%
|
example_isolates |>
|
||||||
# group by ward:
|
# group by ward:
|
||||||
group_by(ward) %>%
|
group_by(ward) |>
|
||||||
# calculate AMR using resistance() for gentamicin and tobramycin
|
# calculate AMR using resistance() for gentamicin and tobramycin
|
||||||
# and get their 95% confidence intervals using sir_confidence_interval():
|
# and get their 95% confidence intervals using sir_confidence_interval():
|
||||||
summarise(across(c(GEN, TOB),
|
summarise(across(c(GEN, TOB),
|
||||||
@@ -364,9 +366,9 @@ to select a series of antibiotic columns:
|
|||||||
library(AMR)
|
library(AMR)
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
|
|
||||||
out <- example_isolates %>%
|
out <- example_isolates |>
|
||||||
# group by ward:
|
# group by ward:
|
||||||
group_by(ward) %>%
|
group_by(ward) |>
|
||||||
# calculate AMR using resistance(), over all aminoglycosides and polymyxins:
|
# calculate AMR using resistance(), over all aminoglycosides and polymyxins:
|
||||||
summarise(across(c(aminoglycosides(), polymyxins()),
|
summarise(across(c(aminoglycosides(), polymyxins()),
|
||||||
resistance))
|
resistance))
|
||||||
@@ -390,7 +392,7 @@ out
|
|||||||
|
|
||||||
``` r
|
``` r
|
||||||
# transform the antibiotic columns to names:
|
# transform the antibiotic columns to names:
|
||||||
out %>% set_ab_names()
|
out |> set_ab_names()
|
||||||
#> # A tibble: 3 × 6
|
#> # A tibble: 3 × 6
|
||||||
#> ward gentamicin tobramycin amikacin kanamycin colistin
|
#> ward gentamicin tobramycin amikacin kanamycin colistin
|
||||||
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
|
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
|
||||||
@@ -401,7 +403,7 @@ out %>% set_ab_names()
|
|||||||
|
|
||||||
``` r
|
``` r
|
||||||
# transform the antibiotic column to ATC codes:
|
# transform the antibiotic column to ATC codes:
|
||||||
out %>% set_ab_names(property = "atc")
|
out |> set_ab_names(property = "atc")
|
||||||
#> # A tibble: 3 × 6
|
#> # A tibble: 3 × 6
|
||||||
#> ward J01GB03 J01GB01 J01GB06 J01GB04 J01XB01
|
#> ward J01GB03 J01GB01 J01GB06 J01GB04 J01XB01
|
||||||
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
|
#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
|
||||||
|
|||||||
Reference in new issue
Block a user