1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 14:21:48 +02:00

(v2.1.1.9268) WISCA vignette, antibiogram sorting, fix translations

This commit is contained in:
2025-05-01 14:38:51 +02:00
parent 5e6bbdf3d1
commit 2461631bce
16 changed files with 156 additions and 134 deletions

View File

@ -1,11 +1,11 @@
---
title: "How to conduct AMR data analysis"
title: "Conduct AMR data analysis"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 3
vignette: >
%\VignetteIndexEntry{How to conduct AMR data analysis}
%\VignetteIndexEntry{Conduct AMR data analysis}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:

View File

@ -22,7 +22,7 @@ knitr::opts_chunk$set(
)
```
> This page was entirely written by our [AMR for R Assistant](https://chat.amr-for-r.org), a ChatGPT manually-trained model able to answer any question about the AMR package.
> This page was entirely written by our [AMR for R Assistant](https://chat.amr-for-r.org), a ChatGPT manually-trained model able to answer any question about the `AMR` package.
Antimicrobial resistance (AMR) is a global health crisis, and understanding resistance patterns is crucial for managing effective treatments. The `AMR` R package provides robust tools for analysing AMR data, including convenient antimicrobial selector functions like `aminoglycosides()` and `betalactams()`.

View File

@ -1,11 +1,11 @@
---
title: "How to apply EUCAST rules"
title: "Apply EUCAST rules"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 3
vignette: >
%\VignetteIndexEntry{How to apply EUCAST rules}
%\VignetteIndexEntry{Apply EUCAST rules}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:

View File

@ -1,10 +1,10 @@
---
title: "How to determine multi-drug resistance (MDR)"
title: "Determine multi-drug resistance (MDR)"
output:
rmarkdown::html_vignette:
toc: true
vignette: >
%\VignetteIndexEntry{How to determine multi-drug resistance (MDR)}
%\VignetteIndexEntry{Determine multi-drug resistance (MDR)}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:

View File

@ -1,11 +1,11 @@
---
title: "How to conduct principal component analysis (PCA) for AMR"
title: "Conduct principal component analysis (PCA) for AMR"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 3
vignette: >
%\VignetteIndexEntry{How to conduct principal component analysis (PCA) for AMR}
%\VignetteIndexEntry{Conduct principal component analysis (PCA) for AMR}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:

View File

@ -1,11 +1,11 @@
---
title: "How to work with WHONET data"
title: "Work with WHONET data"
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 3
vignette: >
%\VignetteIndexEntry{How to work with WHONET data}
%\VignetteIndexEntry{Work with WHONET data}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options:

View File

@ -22,202 +22,187 @@ knitr::opts_chunk$set(
)
```
> This explainer was largely written by our [AMR for R Assistant](https://chat.amr-for-r.org), a ChatGPT manually-trained model able to answer any question about the `AMR` package.
## Introduction
Clinical guidelines for empirical antimicrobial therapy require *probabilistic reasoning*: what is the chance that a regimen will cover the likely infecting organisms, before culture results are available?
This is the purpose of **WISCA**, or:
> **Weighted-Incidence Syndromic Combination Antibiogram**
This is the purpose of **WISCA**, or **Weighted-Incidence Syndromic Combination Antibiogram**.
WISCA is a Bayesian approach that integrates:
- **Pathogen prevalence** (how often each species causes the syndrome),
- **Regimen susceptibility** (how often a regimen works *if* the pathogen is known),
to estimate the **overall empirical coverage** of antimicrobial regimens with quantified uncertainty.
to estimate the **overall empirical coverage** of antimicrobial regimens, with quantified uncertainty.
This vignette explains how WISCA works, why it is useful, and how to apply it in **AMR**.
---
This vignette explains how WISCA works, why it is useful, and how to apply it using the `AMR` package.
## Why traditional antibiograms fall short
A standard antibiogram gives you:
``` Species → Antibiotic → Susceptibility %
```
Species → Antibiotic → Susceptibility %
```
But clinicians dont know the species *a priori*. They need to choose a regimen that covers the **likely pathogens** without knowing which one is present.
But clinicians dont know the species *a priori*. They need to choose a regimen that covers the **likely pathogens**, without knowing which one is present.
Traditional antibiograms calculate the susceptibility % as just the number of resistant isolates divided by the total number of tested isolates. Therefore, traditional antibiograms:
Traditional antibiograms:
- Fragment information by organism,
- Do not weight by real-world prevalence,
- Do not account for combination therapy or sample size,
- Do not provide uncertainty.
---
## The idea of WISCA
WISCA asks:
> What is the **probability** that this regimen **will cover** the pathogen, given the syndrome?
> "What is the **probability** that this regimen **will cover** the pathogen, given the syndrome?"
This means combining two things:
- **Incidence** of each pathogen in the syndrome,
- **Susceptibility** of each pathogen to the regimen.
We can write this as:
``` coverage = ∑ (pathogen incidence × susceptibility)
$$\text{Coverage} = \sum_i (\text{Incidence}_i \times \text{Susceptibility}_i)$$
For example, suppose:
- E. coli causes 60% of cases, and 90% of *E. coli* are susceptible to a drug.
- Klebsiella causes 40% of cases, and 70% of *Klebsiella* are susceptible.
- *E. coli* causes 60% of cases, and 90% of *E. coli* are susceptible to a drug.
- *Klebsiella* causes 40% of cases, and 70% of *Klebsiella* are susceptible.
Then:
``` coverage = (0.6 × 0.9) + (0.4 × 0.7) = 0.82
$$\text{Coverage} = (0.6 \times 0.9) + (0.4 \times 0.7) = 0.82$$
But in real data, incidence and susceptibility are **estimated from samples** so they carry uncertainty. WISCA models this **probabilistically**, using conjugate Bayesian distributions.
---
But in real data, incidence and susceptibility are **estimated from samples**, so they carry uncertainty. WISCA models this **probabilistically**, using conjugate Bayesian distributions.
## The Bayesian engine behind WISCA
### Pathogen incidence
Let:
- K be the number of pathogens,
- ``` α = (1, 1, ..., 1) be a **Dirichlet** prior (uniform),
- ``` n = (n₁, ..., nₖ) be the observed counts per species.
Then the posterior incidence follows:
- $K$ be the number of pathogens,
- $\alpha = (1, 1, \ldots, 1)$ be a **Dirichlet** prior (uniform),
- $n = (n_1, \ldots, n_K)$ be the observed counts per species.
``` incidence Dirichlet(α + n)
Then the posterior incidence is:
In simulations, we draw from this posterior using:
$$p \sim \text{Dirichlet}(\alpha_1 + n_1, \ldots, \alpha_K + n_K)$$
``` xᵢ Gamma(αᵢ + nᵢ, 1)
To simulate from this, we use:
``` incidenceᵢ = xᵢ / ∑ xⱼ
---
$$x_i \sim \text{Gamma}(\alpha_i + n_i,\ 1), \quad p_i = \frac{x_i}{\sum_{j=1}^{K} x_j}$$
### Susceptibility
Each pathogenregimen pair has:
- ``` prior: Beta(1, 1)
- ``` data: S susceptible out of N tested
Each pathogenregimen pair has a prior and data:
Then:
- Prior: $\text{Beta}(\alpha_0, \beta_0)$, with default $\alpha_0 = \beta_0 = 1$
- Data: $S$ susceptible out of $N$ tested
``` susceptibility Beta(1 + S, 1 + (N - S))
The $S$ category could also include values SDD (susceptible, dose-dependent) and I (intermediate [CLSI], or susceptible, increased exposure [EUCAST]).
In each simulation, we draw random susceptibility per species from this Beta distribution.
Then the posterior is:
---
$$\theta \sim \text{Beta}(\alpha_0 + S,\ \beta_0 + N - S)$$
### Final coverage estimate
Putting it together:
``` For each simulation:
- Draw incidence Dirichlet
- Draw susceptibility Beta
- Multiply → coverage estimate
1. Simulate pathogen incidence: $\boldsymbol{p} \sim \text{Dirichlet}$
2. Simulate susceptibility: $\theta_i \sim \text{Beta}(1 + S_i,\ 1 + R_i)$
3. Combine:
We repeat this (e.g. 1000×) and summarise:
- **Mean**: expected coverage
- **Quantiles**: credible interval (default 95%)
$$\text{Coverage} = \sum_{i=1}^{K} p_i \cdot \theta_i$$
---
Repeat this simulation (e.g. 1000×) and summarise:
## Practical use in AMR
- **Mean** = expected coverage
- **Quantiles** = credible interval
### Simulate a synthetic syndrome
## Practical use in the `AMR` package
### Prepare data and simulate synthetic syndrome
```{r}
library(AMR)
data <- example_isolates
# Add a fake syndrome column for stratification
data$syndrome <- ifelse(data$mo %like% "coli", "UTI", "Other")
# Structure of our data
data
# Add a fake syndrome column
data$syndrome <- ifelse(data$mo %like% "coli", "UTI", "No UTI")
```
### Basic WISCA antibiogram
```{r}
antibiogram(data,
wisca = TRUE)
wisca(data,
antimicrobials = c("AMC", "CIP", "GEN"))
```
### Use combination regimens
```{r}
wisca(data,
antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"))
```
### Stratify by syndrome
```{r}
antibiogram(data,
syndromic_group = "syndrome",
wisca = TRUE)
wisca(data,
antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"),
syndromic_group = "syndrome")
```
### Use combination regimens
The `antibiogram()` function supports combination regimens:
The `AMR` package is available in `r length(AMR:::LANGUAGES_SUPPORTED)` languages, which can all be used for the `wisca()` function too:
```{r}
antibiogram(data,
antimicrobials = c("AMC", "GEN", "AMC + GEN", "CIP"),
wisca = TRUE)
wisca(data,
antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"),
syndromic_group = gsub("UTI", "UCI", data$syndrome),
language = "Spanish")
```
---
## Interpretation
## Sensible defaults, which can be customised
Suppose you get this output:
| Regimen | Coverage | Lower_CI | Upper_CI |
|-------------|----------|----------|----------|
| AMC | 0.72 | 0.65 | 0.78 |
| AMC + GEN | 0.88 | 0.83 | 0.93 |
Interpretation:
> *“AMC + GEN covers 88% of expected pathogens for this syndrome, with 95% certainty that the true coverage lies between 83% and 93%.”*
Regimens with few tested isolates will show **wider intervals**.
---
## Sensible defaults, but you can customise
- `minimum = 30`: exclude regimens with <30 isolates tested.
- `simulations = 1000`: number of Monte Carlo samples.
- `conf_interval = 0.95`: coverage interval width.
- `combine_SI = TRUE`: count “I”/“SDD” as susceptible.
---
- `simulations = 1000`: number of Monte Carlo draws
- `conf_interval = 0.95`: coverage interval width
- `combine_SI = TRUE`: count "I" and "SDD" as susceptible
## Limitations
- WISCA does not model time trends or temporal resistance shifts.
- It assumes data are representative of current clinical practice.
- It does not account for patient-level covariates (yet).
- Species-specific data are abstracted into syndrome-level estimates.
- It assumes your data are representative
- No adjustment for patient-level covariates, although these could be passed onto the `syndromic_group` argument
- WISCA does not model resistance over time, you might want to use `tidymodels` for that, for which we [wrote a basic introduction](https://amr-for-r.org/articles/AMR_with_tidymodels.html)
---
## Summary
WISCA enables:
- Empirical regimen comparison,
- Syndrome-specific coverage estimation,
- Fully probabilistic interpretation.
It is available in the `AMR` package via either:
```r
wisca(...)
antibiogram(..., wisca = TRUE)
```
## Reference
Bielicki JA et al. (2016).
*Weighted-incidence syndromic combination antibiograms to guide empiric treatment in pediatric bloodstream infections.*
**J Antimicrob Chemother**, 71(2):529536. doi:10.1093/jac/dkv397
---
## Conclusion
WISCA shifts empirical therapy from simple percent susceptible toward **probabilistic, syndrome-based decision support**. It is a statistically principled, clinically intuitive method to guide regimen selection — and easy to use via the `antibiogram()` function in the **AMR** package.
For antimicrobial stewardship teams, it enables **disease-specific, reproducible, and data-driven guidance** — even in the face of sparse data.
Bielicki, JA, et al. (2016). *Selecting appropriate empirical antibiotic regimens for paediatric bloodstream infections: application of a Bayesian decision model to local and pooled antimicrobial resistance surveillance data.* **J Antimicrob Chemother**. 71(3):794-802. https://doi.org/10.1093/jac/dkv397

View File

@ -1,12 +1,12 @@
---
title: "Data sets for download / own use"
title: "Download data sets for download / own use"
date: '`r format(Sys.Date(), "%d %B %Y")`'
output:
rmarkdown::html_vignette:
toc: true
toc_depth: 1
vignette: >
%\VignetteIndexEntry{Data sets for download / own use}
%\VignetteIndexEntry{Download data sets for download / own use}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
editor_options: