diff --git a/404.html b/404.html index 07d518e8c..eecd18100 100644 --- a/404.html +++ b/404.html @@ -31,7 +31,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/CLAUDE.html b/CLAUDE.html index 555771133..a943a3e2e 100644 --- a/CLAUDE.html +++ b/CLAUDE.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -73,7 +73,7 @@ pkgdown::build_site() # Code coverage report -covr::package_coverage() +covr::package_coverage() From the shell: # CRAN check from parent directory R CMD check AMR @@ -92,13 +92,13 @@ _pkgdown.yml # pkgdown website configuration R Source File Conventions Naming conventions in R/: -Prefix/Name +Prefix/Name Purpose -aa_*.R +aa_*.R Loaded first (helpers, globals, options, package docs) -zz_deprecated.R +zz_deprecated.R Deprecated function wrappers -zzz.R +zzz.R .onLoad / .onAttach initialization Key source files: @@ -136,46 +136,46 @@ _pkgdown.yml # pkgdown website configuration Custom S3 Classes The package defines five S3 classes with full print/format/plot/vctrs support: -Class +Class Created by Represents -<mo> +<mo> as.mo() Microorganism code -<ab> +<ab> as.ab() Antimicrobial drug code -<av> +<av> as.av() Antiviral drug code -<sir> +<sir> as.sir() SIR value (S/I/R/SDD) -<mic> +<mic> as.mic() Minimum inhibitory concentration -<disk> +<disk> as.disk() Disk diffusion diameter Data Files Pre-compiled in data/ (do not edit directly; regenerate via data-raw/ scripts): -File +File Contents -microorganisms.rda +microorganisms.rda ~79,000 microbial species with full taxonomy -antimicrobials.rda +antimicrobials.rda ~620 antimicrobial drugs with ATC codes -antivirals.rda +antivirals.rda Antiviral drugs -clinical_breakpoints.rda +clinical_breakpoints.rda EUCAST + CLSI breakpoints (2011–2025) -intrinsic_resistant.rda +intrinsic_resistant.rda Intrinsic resistance patterns -example_isolates.rda +example_isolates.rda Example AMR dataset for documentation/testing -WHONET.rda +WHONET.rda Example WHONET-format dataset diff --git a/CLAUDE.md b/CLAUDE.md index 2dceee299..947c7607b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,6 +23,7 @@ Concentration (MIC) and disk diffusion handling - Multilingual output All commands run inside an R session: ``` r + # Rebuild documentation (roxygen2 → .Rd files + NAMESPACE) devtools::document() @@ -94,14 +95,14 @@ R CMD check AMR The package defines five S3 classes with full print/format/plot/vctrs support: -| Class | Created by | Represents | -|----------|-----------------------------------------------------------|----------------------------------| -| `` | [`as.mo()`](https://amr-for-r.org/reference/as.mo.md) | Microorganism code | -| `` | [`as.ab()`](https://amr-for-r.org/reference/as.ab.md) | Antimicrobial drug code | -| `` | [`as.av()`](https://amr-for-r.org/reference/as.av.md) | Antiviral drug code | -| `` | [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) | SIR value (S/I/R/SDD) | -| `` | [`as.mic()`](https://amr-for-r.org/reference/as.mic.md) | Minimum inhibitory concentration | -| `` | [`as.disk()`](https://amr-for-r.org/reference/as.disk.md) | Disk diffusion diameter | +| Class | Created by | Represents | +|----|----|----| +| `` | [`as.mo()`](https://amr-for-r.org/reference/as.mo.md) | Microorganism code | +| `` | [`as.ab()`](https://amr-for-r.org/reference/as.ab.md) | Antimicrobial drug code | +| `` | [`as.av()`](https://amr-for-r.org/reference/as.av.md) | Antiviral drug code | +| `` | [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) | SIR value (S/I/R/SDD) | +| `` | [`as.mic()`](https://amr-for-r.org/reference/as.mic.md) | Minimum inhibitory concentration | +| `` | [`as.disk()`](https://amr-for-r.org/reference/as.disk.md) | Disk diffusion diameter | ## Data Files @@ -125,6 +126,7 @@ integrations (ggplot2, dplyr, data.table, tidymodels, cli, crayon, etc.) are listed in `Suggests` and guarded with: ``` r + if (requireNamespace("pkg", quietly = TRUE)) { ... } ``` diff --git a/LICENSE-text.html b/LICENSE-text.html index f10a14420..a2a98cc9d 100644 --- a/LICENSE-text.html +++ b/LICENSE-text.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/articles/AMR.html b/articles/AMR.html index 96aa10e2c..175f01068 100644 --- a/articles/AMR.html +++ b/articles/AMR.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -91,7 +91,7 @@ website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was -generated on 25 April 2026. +generated on 30 April 2026. Introduction @@ -147,21 +147,21 @@ make the structure of your data generally look like this: -2026-04-25 +2026-04-30 abcd Escherichia coli S S -2026-04-25 +2026-04-30 abcd Escherichia coli S R -2026-04-25 +2026-04-30 efgh Escherichia coli R diff --git a/articles/AMR.md b/articles/AMR.md index 3d89d6df1..e9f2ee4d6 100644 --- a/articles/AMR.md +++ b/articles/AMR.md @@ -3,7 +3,7 @@ **Note:** values on this page will change with every website update since they are based on randomly created values and the page was written in [R Markdown](https://rmarkdown.rstudio.com/). However, the -methodology remains unchanged. This page was generated on 25 April 2026. +methodology remains unchanged. This page was generated on 30 April 2026. ## Introduction @@ -51,9 +51,9 @@ structure of your data generally look like this: | date | patient_id | mo | AMX | CIP | |:----------:|:----------:|:----------------:|:---:|:---:| -| 2026-04-25 | abcd | Escherichia coli | S | S | -| 2026-04-25 | abcd | Escherichia coli | S | R | -| 2026-04-25 | efgh | Escherichia coli | R | S | +| 2026-04-30 | abcd | Escherichia coli | S | S | +| 2026-04-30 | abcd | Escherichia coli | S | R | +| 2026-04-30 | efgh | Escherichia coli | R | S | ### Needed R packages @@ -69,6 +69,7 @@ We will also use the `cleaner` package, that can be used for cleaning data and creating frequency tables. ``` r + library(dplyr) library(ggplot2) library(AMR) @@ -81,6 +82,7 @@ The `AMR` package contains a data set `example_isolates_unclean`, which might look data that users have extracted from their laboratory systems: ``` r + example_isolates_unclean #> # A tibble: 3,000 × 8 #> patient_id hospital date bacteria AMX AMC CIP GEN @@ -119,6 +121,7 @@ still human readable. More importantly, of input: ``` r + as.mo("Klebsiella pneumoniae") #> Class #> [1] B_KLBSL_PNMN @@ -143,6 +146,7 @@ Gram-stain. They all start with `mo_` and they use that still any arbitrary user input can be used: ``` r + mo_family("K. pneumoniae") #> [1] "Enterobacteriaceae" mo_genus("K. pneumoniae") @@ -165,6 +169,7 @@ mo_snomed("K. pneumoniae") Now we can thus clean our data: ``` r + our_data$bacteria <- as.mo(our_data$bacteria, info = TRUE) #> ℹ Retrieved values from the `microorganisms.codes` data set for "ESCCOL", #> "KLEPNE", "STAAUR", and "STRPNE". @@ -177,6 +182,7 @@ Apparently, there was some uncertainty about the translation to taxonomic codes. Let’s check this: ``` r + mo_uncertainties() #> Matching scores are based on the resemblance between the input and the full #> taxonomic name, and the pathogenicity in humans. See `mo_matching_score()`. @@ -231,6 +237,7 @@ diffusion values, read more about that on the For now, we will just clean the SIR columns in our data using dplyr: ``` r + # method 1, be explicit about the columns: our_data <- our_data %>% mutate_at(vars(AMX:GEN), as.sir) @@ -308,6 +315,7 @@ page. The outcome of the function can easily be added to our data: ``` r + our_data <- our_data %>% mutate(first = first_isolate(info = TRUE)) #> ℹ Determining first isolates using an episode length of 365 days @@ -326,6 +334,7 @@ with the [`filter()`](https://dplyr.tidyverse.org/reference/filter.html) function, also from the `dplyr` package: ``` r + our_data_1st <- our_data %>% filter(first == TRUE) ``` @@ -333,6 +342,7 @@ our_data_1st <- our_data %>% For future use, the above two syntaxes can be shortened: ``` r + our_data_1st <- our_data %>% filter_first_isolate() ``` @@ -340,6 +350,7 @@ our_data_1st <- our_data %>% So we end up with 2 724 isolates for analysis. Now our data looks like: ``` r + our_data_1st #> # A tibble: 2,724 × 9 #> patient_id hospital date bacteria AMX AMC CIP GEN first @@ -366,6 +377,7 @@ gives a good first impression, as it comes with support for the new `mo` and `sir` classes that we now have in our data set: ``` r + summary(our_data_1st) #> patient_id hospital date bacteria #> Length :2724 Length :2724 Min. :2011-01-01 Class :mo @@ -417,6 +429,7 @@ table with [`count()`](https://amr-for-r.org/reference/count.md) based on the name of the microorganisms: ``` r + our_data %>% count(mo_name(bacteria), sort = TRUE) #> # A tibble: 4 × 2 @@ -445,6 +458,7 @@ columns based on the antibiotic class that your antibiotic results are in: ``` r + our_data_1st %>% select(date, aminoglycosides()) #> ℹ For `aminoglycosides()` using column GEN @@ -590,6 +604,7 @@ function to create any of the above antibiogram types. For starters, this is what the included `example_isolates` data set looks like: ``` r + example_isolates #> # A tibble: 2,000 × 46 #> date patient age gender ward mo PEN OXA FLC AMX @@ -622,6 +637,7 @@ function supports any (combination) of the previously mentioned antibiotic class selectors: ``` r + antibiogram(example_isolates, antibiotics = c(aminoglycosides(), carbapenems()) ) @@ -630,18 +646,18 @@ antibiogram(example_isolates, #> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) ``` -| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | -|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------| -| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | -| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | -| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | -| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | -| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | -| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | -| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | -| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | -| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | -| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | +| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | +|:---|:---|:---|:---|:---|:---|:---| +| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | +| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | +| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | +| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | +| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | +| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | +| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | +| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | +| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | +| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | Notice that the [`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md) @@ -659,6 +675,7 @@ Ukrainian, Urdu, or Vietnamese. In this next example, we force the language to be Spanish using the `language` argument: ``` r + antibiogram(example_isolates, mo_transform = "gramstain", antibiotics = aminoglycosides(), @@ -669,10 +686,10 @@ antibiogram(example_isolates, #> (amikacin), and KAN (kanamycin) ``` -| Patógeno | Amikacina | Gentamicina | Kanamicina | Tobramicina | -|:--------------|:-------------------|:--------------------|:----------------|:-------------------| -| Gram negativo | 98% (96-99%,N=256) | 96% (95-98%,N=684) | 0% (0-10%,N=35) | 96% (94-97%,N=686) | -| Gram positivo | 0% (0-1%,N=436) | 63% (60-66%,N=1170) | 0% (0-1%,N=436) | 34% (31-38%,N=665) | +| Patógeno | Amikacina | Gentamicina | Kanamicina | Tobramicina | +|:---|:---|:---|:---|:---| +| Gram negativo | 98% (96-99%,N=256) | 96% (95-98%,N=684) | 0% (0-10%,N=35) | 96% (94-97%,N=686) | +| Gram positivo | 0% (0-1%,N=436) | 63% (60-66%,N=1170) | 0% (0-1%,N=436) | 34% (31-38%,N=665) | #### Combined Antibiogram @@ -680,6 +697,7 @@ To create a combined antibiogram, use antibiotic codes or names with a plus `+` character like this: ``` r + combined_ab <- antibiogram(example_isolates, antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"), ab_transform = NULL @@ -687,17 +705,17 @@ combined_ab <- antibiogram(example_isolates, combined_ab ``` -| Pathogen | TZP | TZP + GEN | TZP + TOB | -|:-----------------|:---------------------|:---------------------|:---------------------| -| CoNS | 30% (16-49%,N=33) | 97% (95-99%,N=274) | NA | -| *E. coli* | 94% (92-96%,N=416) | 100% (98-100%,N=459) | 99% (97-100%,N=461) | -| *K. pneumoniae* | 89% (77-96%,N=53) | 93% (83-98%,N=58) | 93% (83-98%,N=58) | -| *P. aeruginosa* | NA | 100% (88-100%,N=30) | 100% (88-100%,N=30) | -| *P. mirabilis* | NA | 100% (90-100%,N=34) | 100% (90-100%,N=34) | -| *S. aureus* | NA | 100% (98-100%,N=231) | 100% (96-100%,N=91) | -| *S. epidermidis* | NA | 100% (97-100%,N=128) | 100% (92-100%,N=46) | -| *S. hominis* | NA | 100% (95-100%,N=74) | 100% (93-100%,N=53) | -| *S. pneumoniae* | 100% (97-100%,N=112) | 100% (97-100%,N=112) | 100% (97-100%,N=112) | +| Pathogen | TZP | TZP + GEN | TZP + TOB | +|:---|:---|:---|:---| +| CoNS | 30% (16-49%,N=33) | 97% (95-99%,N=274) | NA | +| *E. coli* | 94% (92-96%,N=416) | 100% (98-100%,N=459) | 99% (97-100%,N=461) | +| *K. pneumoniae* | 89% (77-96%,N=53) | 93% (83-98%,N=58) | 93% (83-98%,N=58) | +| *P. aeruginosa* | NA | 100% (88-100%,N=30) | 100% (88-100%,N=30) | +| *P. mirabilis* | NA | 100% (90-100%,N=34) | 100% (90-100%,N=34) | +| *S. aureus* | NA | 100% (98-100%,N=231) | 100% (96-100%,N=91) | +| *S. epidermidis* | NA | 100% (97-100%,N=128) | 100% (92-100%,N=46) | +| *S. hominis* | NA | 100% (95-100%,N=74) | 100% (93-100%,N=53) | +| *S. pneumoniae* | 100% (97-100%,N=112) | 100% (97-100%,N=112) | 100% (97-100%,N=112) | #### Syndromic Antibiogram @@ -707,6 +725,7 @@ be used. This can be any column in the data, or e.g. an on certain columns: ``` r + antibiogram(example_isolates, antibiotics = c(aminoglycosides(), carbapenems()), syndromic_group = "ward" @@ -716,22 +735,22 @@ antibiogram(example_isolates, #> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) ``` -| Syndromic Group | Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | -|:----------------|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------| -| Clinical | CoNS | NA | 89% (84-93%,N=205) | 57% (39-74%,N=35) | NA | 57% (39-74%,N=35) | 26% (12-45%,N=31) | -| ICU | CoNS | NA | 79% (68-88%,N=73) | NA | NA | NA | NA | -| Outpatient | CoNS | NA | 84% (66-95%,N=31) | NA | NA | NA | NA | -| Clinical | *E. coli* | 100% (97-100%,N=104) | 98% (96-99%,N=297) | 100% (99-100%,N=266) | NA | 100% (99-100%,N=276) | 98% (96-99%,N=299) | -| ICU | *E. coli* | 100% (93-100%,N=52) | 99% (95-100%,N=137) | 100% (97-100%,N=133) | NA | 100% (97-100%,N=118) | 96% (92-99%,N=137) | -| Clinical | *K. pneumoniae* | NA | 92% (81-98%,N=51) | 100% (92-100%,N=44) | NA | 100% (92-100%,N=46) | 92% (81-98%,N=51) | -| Clinical | *P. mirabilis* | NA | 100% (88-100%,N=30) | NA | NA | NA | 100% (88-100%,N=30) | -| Clinical | *S. aureus* | NA | 99% (95-100%,N=150) | NA | NA | NA | 97% (89-100%,N=63) | -| ICU | *S. aureus* | NA | 100% (95-100%,N=66) | NA | NA | NA | NA | -| Clinical | *S. epidermidis* | NA | 82% (72-90%,N=79) | NA | NA | NA | 55% (39-70%,N=44) | -| ICU | *S. epidermidis* | NA | 72% (60-82%,N=75) | NA | NA | NA | 41% (26-58%,N=41) | -| Clinical | *S. hominis* | NA | 96% (85-99%,N=45) | NA | NA | NA | 94% (79-99%,N=31) | -| Clinical | *S. pneumoniae* | 0% (0-5%,N=78) | 0% (0-5%,N=78) | NA | 0% (0-5%,N=78) | NA | 0% (0-5%,N=78) | -| ICU | *S. pneumoniae* | 0% (0-12%,N=30) | 0% (0-12%,N=30) | NA | 0% (0-12%,N=30) | NA | 0% (0-12%,N=30) | +| Syndromic Group | Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | +|:---|:---|:---|:---|:---|:---|:---|:---| +| Clinical | CoNS | NA | 89% (84-93%,N=205) | 57% (39-74%,N=35) | NA | 57% (39-74%,N=35) | 26% (12-45%,N=31) | +| ICU | CoNS | NA | 79% (68-88%,N=73) | NA | NA | NA | NA | +| Outpatient | CoNS | NA | 84% (66-95%,N=31) | NA | NA | NA | NA | +| Clinical | *E. coli* | 100% (97-100%,N=104) | 98% (96-99%,N=297) | 100% (99-100%,N=266) | NA | 100% (99-100%,N=276) | 98% (96-99%,N=299) | +| ICU | *E. coli* | 100% (93-100%,N=52) | 99% (95-100%,N=137) | 100% (97-100%,N=133) | NA | 100% (97-100%,N=118) | 96% (92-99%,N=137) | +| Clinical | *K. pneumoniae* | NA | 92% (81-98%,N=51) | 100% (92-100%,N=44) | NA | 100% (92-100%,N=46) | 92% (81-98%,N=51) | +| Clinical | *P. mirabilis* | NA | 100% (88-100%,N=30) | NA | NA | NA | 100% (88-100%,N=30) | +| Clinical | *S. aureus* | NA | 99% (95-100%,N=150) | NA | NA | NA | 97% (89-100%,N=63) | +| ICU | *S. aureus* | NA | 100% (95-100%,N=66) | NA | NA | NA | NA | +| Clinical | *S. epidermidis* | NA | 82% (72-90%,N=79) | NA | NA | NA | 55% (39-70%,N=44) | +| ICU | *S. epidermidis* | NA | 72% (60-82%,N=75) | NA | NA | NA | 41% (26-58%,N=41) | +| Clinical | *S. hominis* | NA | 96% (85-99%,N=45) | NA | NA | NA | 94% (79-99%,N=31) | +| Clinical | *S. pneumoniae* | 0% (0-5%,N=78) | 0% (0-5%,N=78) | NA | 0% (0-5%,N=78) | NA | 0% (0-5%,N=78) | +| ICU | *S. pneumoniae* | 0% (0-12%,N=30) | 0% (0-12%,N=30) | NA | 0% (0-12%,N=30) | NA | 0% (0-12%,N=30) | #### Weighted-Incidence Syndromic Combination Antibiogram (WISCA) @@ -745,6 +764,7 @@ susceptibility estimates, weighted by pathogen incidence and antimicrobial susceptibility patterns. ``` r + example_isolates %>% wisca( antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"), @@ -753,8 +773,8 @@ example_isolates %>% ``` | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | -|:------------------------|:-------------------------------------|:-------------------------------------| -| 69.4% (64.3-74.3%) | 92.6% (91.1-93.9%) | 88.7% (85.8-91.2%) | +|:---|:---|:---| +| 69.4% (64.3-74.3%) | 92.6% (91.1-93.9%) | 88.7% (85.8-91.2%) | WISCA uses a **Bayesian decision model** to integrate data from multiple pathogens, improving empirical therapy guidance, especially for @@ -775,6 +795,7 @@ grouped `tibble`, i.e., using first: ``` r + example_isolates %>% top_n_microorganisms(n = 10) %>% group_by( @@ -785,15 +806,15 @@ example_isolates %>% ``` | age_group | gender | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | -|:----------|:-------|:------------------------|:-------------------------------------|:-------------------------------------| -| 0-24 | F | 56.6% (25.2-83.9%) | 73.6% (48-91.6%) | 68.6% (42.9-89.5%) | -| 0-24 | M | 60.3% (28.4-87.1%) | 79.7% (57.6-94.2%) | 60.1% (29.5-87.7%) | -| 25-49 | F | 66.6% (45.6-85.5%) | 91.7% (84.6-96.7%) | 83% (67.9-94%) | -| 25-49 | M | 56.4% (29.1-81.7%) | 89.2% (80.3-95.7%) | 72.4% (49.7-90%) | -| 50-74 | F | 67.8% (55.8-80.1%) | 95.6% (93.2-97.5%) | 88.1% (80.4-94.6%) | -| 50-74 | M | 66.2% (54.8-75.8%) | 95.2% (92.4-97.4%) | 84.4% (74.4-92.5%) | -| 75+ | F | 71.7% (61-81.7%) | 96.6% (94.4-98.2%) | 90.6% (84.6-95.3%) | -| 75+ | M | 72.9% (63.8-82%) | 96.6% (94.6-98.1%) | 92.8% (87.8-96.5%) | +|:---|:---|:---|:---|:---| +| 0-24 | F | 56.6% (25.2-83.9%) | 73.6% (48-91.6%) | 68.6% (42.9-89.5%) | +| 0-24 | M | 60.3% (28.4-87.1%) | 79.7% (57.6-94.2%) | 60.1% (29.5-87.7%) | +| 25-49 | F | 66.6% (45.6-85.5%) | 91.7% (84.6-96.7%) | 83% (67.9-94%) | +| 25-49 | M | 56.4% (29.1-81.7%) | 89.2% (80.3-95.7%) | 72.4% (49.7-90%) | +| 50-74 | F | 67.8% (55.8-80.1%) | 95.6% (93.2-97.5%) | 88.1% (80.4-94.6%) | +| 50-74 | M | 66.2% (54.8-75.8%) | 95.2% (92.4-97.4%) | 84.4% (74.4-92.5%) | +| 75+ | F | 71.7% (61-81.7%) | 96.6% (94.4-98.2%) | 90.6% (84.6-95.3%) | +| 75+ | M | 72.9% (63.8-82%) | 96.6% (94.6-98.1%) | 92.8% (87.8-96.5%) | #### Plotting antibiograms @@ -803,6 +824,7 @@ from the `ggplot2` packages, since this `AMR` package provides an extension to that function: ``` r + autoplot(combined_ab) ``` @@ -847,6 +869,7 @@ equal to These functions can be used on their own: ``` r + our_data_1st %>% resistance(AMX) #> ℹ `resistance()` assumes the EUCAST guideline and thus considers the 'I' #> category susceptible. Set the `guideline` argument or the `AMR_guideline` @@ -861,6 +884,7 @@ Or can be used in conjunction with both from the `dplyr` package: ``` r + our_data_1st %>% group_by(hospital) %>% summarise(amoxicillin = resistance(AMX)) @@ -881,6 +905,7 @@ example with randomly generated MIC values for *Klebsiella pneumoniae* and ciprofloxacin: ``` r + set.seed(123) mic_values <- random_mic(100) sir_values <- as.sir(mic_values, mo = "K. pneumoniae", ab = "cipro", guideline = "EUCAST 2024") @@ -916,6 +941,7 @@ y-axis and colour-code SIR categories. ``` r + # add a group my_data$group <- rep(c("A", "B", "C", "D"), each = 25) @@ -946,6 +972,7 @@ has been extended by this package to directly plot MIC and disk diffusion values: ``` r + autoplot(mic_values) ``` @@ -953,6 +980,7 @@ autoplot(mic_values) ``` r + # by providing `mo` and `ab`, colours will indicate the SIR interpretation: autoplot(mic_values, mo = "K. pneumoniae", ab = "cipro", guideline = "EUCAST 2024") ``` diff --git a/articles/AMR_for_Python.html b/articles/AMR_for_Python.html index 3c5d232ef..582ea7c6f 100644 --- a/articles/AMR_for_Python.html +++ b/articles/AMR_for_Python.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/articles/AMR_for_Python.md b/articles/AMR_for_Python.md index 550ffccbd..2ee907a0c 100644 --- a/articles/AMR_for_Python.md +++ b/articles/AMR_for_Python.md @@ -168,37 +168,37 @@ regular Python data frames: AMR.microorganisms ``` -| mo | fullname | status | kingdom | gbif | gbif_parent | gbif_renamed_to | prevalence | -|--------------|------------------------------------|----------|----------|----------|-------------|-----------------|------------| -| B_GRAMN | (unknown Gram-negatives) | unknown | Bacteria | None | None | None | 2.0 | -| B_GRAMP | (unknown Gram-positives) | unknown | Bacteria | None | None | None | 2.0 | -| B_ANAER-NEG | (unknown anaerobic Gram-negatives) | unknown | Bacteria | None | None | None | 2.0 | -| B_ANAER-POS | (unknown anaerobic Gram-positives) | unknown | Bacteria | None | None | None | 2.0 | -| B_ANAER | (unknown anaerobic bacteria) | unknown | Bacteria | None | None | None | 2.0 | -| … | … | … | … | … | … | … | … | -| B_ZYMMN_POMC | Zymomonas pomaceae | accepted | Bacteria | 10744418 | 3221412 | None | 2.0 | -| B_ZYMPH | Zymophilus | synonym | Bacteria | None | 9475166 | None | 2.0 | -| B_ZYMPH_PCVR | Zymophilus paucivorans | synonym | Bacteria | None | None | None | 2.0 | -| B_ZYMPH_RFFN | Zymophilus raffinosivorans | synonym | Bacteria | None | None | None | 2.0 | -| F_ZYZYG | Zyzygomyces | unknown | Fungi | None | 7581 | None | 2.0 | +| mo | fullname | status | kingdom | gbif | gbif_parent | gbif_renamed_to | prevalence | +|----|----|----|----|----|----|----|----| +| B_GRAMN | (unknown Gram-negatives) | unknown | Bacteria | None | None | None | 2.0 | +| B_GRAMP | (unknown Gram-positives) | unknown | Bacteria | None | None | None | 2.0 | +| B_ANAER-NEG | (unknown anaerobic Gram-negatives) | unknown | Bacteria | None | None | None | 2.0 | +| B_ANAER-POS | (unknown anaerobic Gram-positives) | unknown | Bacteria | None | None | None | 2.0 | +| B_ANAER | (unknown anaerobic bacteria) | unknown | Bacteria | None | None | None | 2.0 | +| … | … | … | … | … | … | … | … | +| B_ZYMMN_POMC | Zymomonas pomaceae | accepted | Bacteria | 10744418 | 3221412 | None | 2.0 | +| B_ZYMPH | Zymophilus | synonym | Bacteria | None | 9475166 | None | 2.0 | +| B_ZYMPH_PCVR | Zymophilus paucivorans | synonym | Bacteria | None | None | None | 2.0 | +| B_ZYMPH_RFFN | Zymophilus raffinosivorans | synonym | Bacteria | None | None | None | 2.0 | +| F_ZYZYG | Zyzygomyces | unknown | Fungi | None | 7581 | None | 2.0 | ``` python AMR.antimicrobials ``` -| ab | cid | name | group | oral_ddd | oral_units | iv_ddd | iv_units | -|-----|------------|-----------------------|--------------------------|----------|------------|--------|----------| -| AMA | 4649.0 | 4-aminosalicylic acid | Antimycobacterials | 12.00 | g | NaN | None | -| ACM | 6450012.0 | Acetylmidecamycin | Macrolides/lincosamides | NaN | None | NaN | None | -| ASP | 49787020.0 | Acetylspiramycin | Macrolides/lincosamides | NaN | None | NaN | None | -| ALS | 8954.0 | Aldesulfone sodium | Other antibacterials | 0.33 | g | NaN | None | -| AMK | 37768.0 | Amikacin | Aminoglycosides | NaN | None | 1.0 | g | -| … | … | … | … | … | … | … | … | -| VIR | 11979535.0 | Virginiamycine | Other antibacterials | NaN | None | NaN | None | -| VOR | 71616.0 | Voriconazole | Antifungals/antimycotics | 0.40 | g | 0.4 | g | -| XBR | 72144.0 | Xibornol | Other antibacterials | NaN | None | NaN | None | -| ZID | 77846445.0 | Zidebactam | Other antibacterials | NaN | None | NaN | None | -| ZFD | NaN | Zoliflodacin | None | NaN | None | NaN | None | +| ab | cid | name | group | oral_ddd | oral_units | iv_ddd | iv_units | +|----|----|----|----|----|----|----|----| +| AMA | 4649.0 | 4-aminosalicylic acid | Antimycobacterials | 12.00 | g | NaN | None | +| ACM | 6450012.0 | Acetylmidecamycin | Macrolides/lincosamides | NaN | None | NaN | None | +| ASP | 49787020.0 | Acetylspiramycin | Macrolides/lincosamides | NaN | None | NaN | None | +| ALS | 8954.0 | Aldesulfone sodium | Other antibacterials | 0.33 | g | NaN | None | +| AMK | 37768.0 | Amikacin | Aminoglycosides | NaN | None | 1.0 | g | +| … | … | … | … | … | … | … | … | +| VIR | 11979535.0 | Virginiamycine | Other antibacterials | NaN | None | NaN | None | +| VOR | 71616.0 | Voriconazole | Antifungals/antimycotics | 0.40 | g | 0.4 | g | +| XBR | 72144.0 | Xibornol | Other antibacterials | NaN | None | NaN | None | +| ZID | 77846445.0 | Zidebactam | Other antibacterials | NaN | None | NaN | None | +| ZFD | NaN | Zoliflodacin | None | NaN | None | NaN | None | ## Conclusion diff --git a/articles/AMR_with_tidymodels.html b/articles/AMR_with_tidymodels.html index 5cc26df07..4a594f924 100644 --- a/articles/AMR_with_tidymodels.html +++ b/articles/AMR_with_tidymodels.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/articles/AMR_with_tidymodels.md b/articles/AMR_with_tidymodels.md index 95083e61c..e392de029 100644 --- a/articles/AMR_with_tidymodels.md +++ b/articles/AMR_with_tidymodels.md @@ -49,6 +49,7 @@ We begin by loading the required libraries and preparing the `example_isolates` dataset from the `AMR` package. ``` r + # Load required libraries library(AMR) # For AMR data analysis library(tidymodels) # For machine learning workflows, and data manipulation (dplyr, tidyr, ...) @@ -57,6 +58,7 @@ library(tidymodels) # For machine learning workflows, and data manipulation (dpl Prepare the data: ``` r + # Your data could look like this: example_isolates #> # A tibble: 2,000 × 46 @@ -127,6 +129,7 @@ preprocessing, model specification, and fitting. We create a recipe to preprocess the data for modelling. ``` r + # Define the recipe for data preprocessing resistance_recipe <- recipe(mo ~ ., data = data) %>% step_corr(c(aminoglycosides(), betalactams()), threshold = 0.9) @@ -148,6 +151,7 @@ have with `step_corr()`, the necessary parameters can be estimated from a training set using `prep()`: ``` r + prep(resistance_recipe) #> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK #> (amikacin), and KAN (kanamycin) @@ -201,6 +205,7 @@ We define a logistic regression model since resistance prediction is a binary classification task. ``` r + # Specify a logistic regression model logistic_model <- logistic_reg() %>% set_engine("glm") # Use the Generalised Linear Model engine @@ -221,6 +226,7 @@ We bundle the recipe and model together into a `workflow`, which organises the entire modelling process. ``` r + # Combine the recipe and model into a workflow resistance_workflow <- workflow() %>% add_recipe(resistance_recipe) %>% # Add the preprocessing recipe @@ -248,6 +254,7 @@ Then, we fit the workflow on the training set and evaluate its performance. ``` r + # Split data into training and testing sets set.seed(123) # For reproducibility data_split <- initial_split(data, prop = 0.8) # 80% training, 20% testing @@ -271,6 +278,7 @@ they are stored in the recipe. Next, we evaluate the model on the testing data. ``` r + # Make predictions on the testing set predictions <- fitted_workflow %>% predict(testing_data) # Generate predictions @@ -338,6 +346,7 @@ AMR results of only aminoglycosides and beta-lactam antibiotics. The ROC curve looks like this: ``` r + predictions %>% roc_curve(mo, `.pred_Gram-negative`) %>% autoplot() @@ -390,6 +399,7 @@ Our goal is to: We use the `esbl_isolates` dataset that comes with the AMR package. ``` r + # Load required libraries library(AMR) library(tidymodels) @@ -437,6 +447,7 @@ selected using the new [`all_mic_predictors()`](https://amr-for-r.org/reference/amr-tidymodels.md): ``` r + # Split into training and testing sets set.seed(123) split <- initial_split(data) @@ -480,6 +491,7 @@ manual](https://parsnip.tidymodels.org/reference/details_boost_tree_xgboost.html could be much more precise. ``` r + # Define the model model <- logistic_reg(mode = "classification") %>% set_engine("glm") @@ -498,6 +510,7 @@ model #### 3. Building the Workflow ``` r + # Create workflow workflow_model <- workflow() %>% add_recipe(mic_recipe) %>% @@ -522,6 +535,7 @@ workflow_model ### **Training and Evaluating the Model** ``` r + # Fit the model fitted <- fit(workflow_model, training_data) @@ -566,6 +580,7 @@ We can visualise predictions by comparing predicted and actual ESBL status. ``` r + library(ggplot2) ggplot(predictions, aes(x = esbl, fill = .pred_class)) + @@ -583,6 +598,7 @@ ggplot(predictions, aes(x = esbl, fill = .pred_class)) + And plot the certainties too - how certain were the actual predictions? ``` r + predictions %>% mutate( certainty = ifelse(.pred_class == "FALSE", @@ -646,6 +662,7 @@ We start by transforming the `example_isolates` dataset into a structured time-series format. ``` r + # Load required libraries library(AMR) library(tidymodels) @@ -706,6 +723,7 @@ step, a model specification, and the fitting process. #### 1. Preprocessing with a Recipe ``` r + # Define the recipe resistance_recipe_time <- recipe(res_AMX ~ year + gramstain, data = data_time) %>% step_dummy(gramstain, one_hot = TRUE) %>% # Convert categorical to numerical @@ -739,6 +757,7 @@ resistance_recipe_time We use a linear regression model to predict resistance trends. ``` r + # Define the linear regression model lm_model <- linear_reg() %>% set_engine("lm") # Use linear regression @@ -759,6 +778,7 @@ lm_model We combine the preprocessing recipe and model into a workflow. ``` r + # Create workflow resistance_workflow_time <- workflow() %>% add_recipe(resistance_recipe_time) %>% @@ -788,6 +808,7 @@ We split the data into training and testing sets, fit the model, and evaluate performance. ``` r + # Split the data set.seed(123) data_split_time <- initial_split(data_time, prop = 0.8) @@ -829,6 +850,7 @@ metrics_time We plot resistance trends over time for amoxicillin. ``` r + library(ggplot2) # Plot actual vs predicted resistance over time @@ -849,6 +871,7 @@ Additionally, we can visualise resistance trends in `ggplot2` and directly add linear models there: ``` r + ggplot(data_time, aes(x = year, y = res_AMX, color = gramstain)) + geom_line() + labs( diff --git a/articles/EUCAST.html b/articles/EUCAST.html index e28f1367c..72737118e 100644 --- a/articles/EUCAST.html +++ b/articles/EUCAST.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/articles/EUCAST.md b/articles/EUCAST.md index 336dbc8c9..426ad2934 100644 --- a/articles/EUCAST.md +++ b/articles/EUCAST.md @@ -36,6 +36,7 @@ function resolves this, by applying the latest ‘EUCAST Expected Resistant Phenotypes’ guideline: ``` r + oops <- tibble::tibble( mo = c( "Klebsiella pneumoniae", @@ -64,6 +65,7 @@ that uses the same guideline, but allows to check for one or more specific microorganisms or antimicrobials: ``` r + mo_is_intrinsic_resistant( c("Klebsiella pneumoniae", "Escherichia coli"), "ampicillin" @@ -83,6 +85,7 @@ other antimicrobials drugs. This process is called *interpretive reading*, and is basically a form of imputation: ``` r + data <- tibble::tibble( mo = c( "Staphylococcus aureus", @@ -102,6 +105,7 @@ data <- tibble::tibble( ``` ``` r + data ``` @@ -114,6 +118,7 @@ data | Pseudomonas aeruginosa | \- | \- | \- | \- | \- | S | S | ``` r + eucast_rules(data, overwrite = TRUE) ``` diff --git a/articles/PCA.html b/articles/PCA.html index 1b04c4f19..6b2c664af 100644 --- a/articles/PCA.html +++ b/articles/PCA.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/articles/PCA.md b/articles/PCA.md index fb76acece..879ba066a 100644 --- a/articles/PCA.md +++ b/articles/PCA.md @@ -11,6 +11,7 @@ For PCA, we need to transform our AMR data first. This is what the `example_isolates` data set in this package looks like: ``` r + library(AMR) library(dplyr) glimpse(example_isolates) @@ -68,6 +69,7 @@ Now to transform this to a data set with only resistance percentages per taxonomic order and genus: ``` r + resistance_data <- example_isolates %>% group_by( order = mo_order(mo), # group on anything, like order @@ -103,6 +105,7 @@ automatically filter on rows that contain numeric values in all selected variables, so we now only need to do: ``` r + pca_result <- pca(resistance_data) #> ℹ Columns selected for PCA: "\033[1mAMC\033[22m", "\033[1mCAZ\033[22m", #> "\033[1mCTX\033[22m", "\033[1mCXM\033[22m", "\033[1mGEN\033[22m", @@ -114,6 +117,7 @@ The result can be reviewed with the good old [`summary()`](https://rdrr.io/r/base/summary.html) function: ``` r + summary(pca_result) #> Groups (n=4, named as 'order'): #> [1] "Caryophanales" "Enterobacterales" "Lactobacillales" "Pseudomonadales" @@ -137,6 +141,7 @@ microorganism. ## Plotting the results ``` r + biplot(pca_result) ``` @@ -148,6 +153,7 @@ better with our new function, that automatically adds the right labels and even groups: ``` r + ggplot_pca(pca_result) ``` @@ -156,6 +162,7 @@ ggplot_pca(pca_result) You can also print an ellipse per group, and edit the appearance: ``` r + ggplot_pca(pca_result, ellipse = TRUE) + ggplot2::labs(title = "An AMR/PCA biplot!") ``` diff --git a/articles/WHONET.html b/articles/WHONET.html index f85809145..5af6395ba 100644 --- a/articles/WHONET.html +++ b/articles/WHONET.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/articles/WHONET.md b/articles/WHONET.md index be56ef42d..e3e035082 100644 --- a/articles/WHONET.md +++ b/articles/WHONET.md @@ -11,6 +11,7 @@ date fields are imported correctly. An example syntax could look like this: ``` r + library(readxl) data <- read_excel(path = "path/to/your/file.xlsx") ``` @@ -27,6 +28,7 @@ I suggest you read about it on their website: . ``` r + library(dplyr) # part of tidyverse library(ggplot2) # part of tidyverse library(AMR) # this package @@ -50,6 +52,7 @@ analysis: for. ``` r + # transform variables data <- WHONET %>% # get microbial ID based on given organism @@ -68,6 +71,7 @@ function can be used to create frequency tables. So let’s check our data, with a couple of frequency tables: ``` r + # our newly created `mo` variable, put in the mo_name() function data %>% freq(mo_name(mo), nmax = 10) ``` @@ -82,22 +86,23 @@ Unique: 38 Shortest: 11 Longest: 40 -| | Item | Count | Percent | Cum. Count | Cum. Percent | -|:----|:-----------------------------------------|------:|--------:|-----------:|-------------:| -| 1 | Escherichia coli | 245 | 49.0% | 245 | 49.0% | -| 2 | Coagulase-negative Staphylococcus (CoNS) | 74 | 14.8% | 319 | 63.8% | -| 3 | Staphylococcus epidermidis | 38 | 7.6% | 357 | 71.4% | -| 4 | Streptococcus pneumoniae | 31 | 6.2% | 388 | 77.6% | -| 5 | Staphylococcus hominis | 21 | 4.2% | 409 | 81.8% | -| 6 | Proteus mirabilis | 9 | 1.8% | 418 | 83.6% | -| 7 | Enterococcus faecium | 8 | 1.6% | 426 | 85.2% | -| 8 | Staphylococcus capitis urealyticus | 8 | 1.6% | 434 | 86.8% | -| 9 | Enterobacter cloacae | 5 | 1.0% | 439 | 87.8% | -| 10 | Enterococcus columbae | 4 | 0.8% | 443 | 88.6% | +| | Item | Count | Percent | Cum. Count | Cum. Percent | +|:---|:---|---:|---:|---:|---:| +| 1 | Escherichia coli | 245 | 49.0% | 245 | 49.0% | +| 2 | Coagulase-negative Staphylococcus (CoNS) | 74 | 14.8% | 319 | 63.8% | +| 3 | Staphylococcus epidermidis | 38 | 7.6% | 357 | 71.4% | +| 4 | Streptococcus pneumoniae | 31 | 6.2% | 388 | 77.6% | +| 5 | Staphylococcus hominis | 21 | 4.2% | 409 | 81.8% | +| 6 | Proteus mirabilis | 9 | 1.8% | 418 | 83.6% | +| 7 | Enterococcus faecium | 8 | 1.6% | 426 | 85.2% | +| 8 | Staphylococcus capitis urealyticus | 8 | 1.6% | 434 | 86.8% | +| 9 | Enterobacter cloacae | 5 | 1.0% | 439 | 87.8% | +| 10 | Enterococcus columbae | 4 | 0.8% | 443 | 88.6% | (omitted 28 entries, n = 57 \[11.4%\]) ``` r + # our transformed antibiotic columns # amoxicillin/clavulanic acid (J01CR02) as an example data %>% freq(AMC_ND2) @@ -132,6 +137,7 @@ included [`ggplot_sir()`](https://amr-for-r.org/reference/ggplot_sir.md) function: ``` r + data %>% group_by(Country) %>% select(Country, AMP_ND2, AMC_ED20, CAZ_ED10, CIP_ED5) %>% diff --git a/articles/WISCA.html b/articles/WISCA.html index ccb456907..334b1105b 100644 --- a/articles/WISCA.html +++ b/articles/WISCA.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -151,7 +151,7 @@ isolates. Therefore, traditional antibiograms: regimen. We can write this as: -Coverage=∑i(Incidencei×Susceptibilityi)\text{Coverage} = \sum_i (\text{Incidence}_i \times \text{Susceptibility}_i) +Coverage=∑i(Incidencei×Susceptibilityi)\text{Coverage} = \sum_i (\text{Incidence}_i \times \text{Susceptibility}_i) For example, suppose: @@ -162,7 +162,7 @@ are susceptible to a drug. 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 +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 @@ -180,16 +180,16 @@ distributions. KK be the number of pathogens, -α=(1,1,…,1)\alpha = (1, 1, \ldots, 1) +α=(1,1,…,1)\alpha = (1, 1, \ldots, 1) be a Dirichlet prior (uniform), -n=(n1,…,nK)n = (n_1, \ldots, n_K) +n=(n1,…,nK)n = (n_1, \ldots, n_K) be the observed counts per species. Then the posterior incidence is: -p∼Dirichlet(α1+n1,…,αK+nK)p \sim \text{Dirichlet}(\alpha_1 + n_1, \ldots, \alpha_K + n_K) +p∼Dirichlet(α1+n1,…,αK+nK)p \sim \text{Dirichlet}(\alpha_1 + n_1, \ldots, \alpha_K + n_K) To simulate from this, we use: -xi∼Gamma(αi+ni,1),pi=xi∑j=1Kxjx_i \sim \text{Gamma}(\alpha_i + n_i,\ 1), \quad p_i = \frac{x_i}{\sum_{j=1}^{K} x_j} +xi∼Gamma(αi+ni,1),pi=xi∑j=1Kxjx_i \sim \text{Gamma}(\alpha_i + n_i,\ 1), \quad p_i = \frac{x_i}{\sum_{j=1}^{K} x_j} Susceptibility @@ -197,7 +197,7 @@ be the observed counts per species. Each pathogen–regimen pair has a prior and data: Prior: -Beta(α0,β0)\text{Beta}(\alpha_0, \beta_0), +Beta(α0,β0)\text{Beta}(\alpha_0, \beta_0), with default α0=β0=1\alpha_0 = \beta_0 = 1 @@ -213,7 +213,7 @@ category could also include values SDD (susceptible, dose-dependent) and I (intermediate [CLSI], or susceptible, increased exposure [EUCAST]). Then the posterior is: -θ∼Beta(α0+S,β0+N−S)\theta \sim \text{Beta}(\alpha_0 + S,\ \beta_0 + N - S) +θ∼Beta(α0+S,β0+N−S)\theta \sim \text{Beta}(\alpha_0 + S,\ \beta_0 + N - S) Final coverage estimate @@ -224,7 +224,7 @@ I (intermediate [CLSI], or susceptible, increased exposure 𝐩∼Dirichlet\boldsymbol{p} \sim \text{Dirichlet} Simulate susceptibility: -θi∼Beta(1+Si,1+Ri)\theta_i \sim \text{Beta}(1 + S_i,\ 1 + R_i) +θi∼Beta(1+Si,1+Ri)\theta_i \sim \text{Beta}(1 + S_i,\ 1 + R_i) Combine: diff --git a/articles/WISCA.md b/articles/WISCA.md index 780a67391..20a6aa8ea 100644 --- a/articles/WISCA.md +++ b/articles/WISCA.md @@ -58,7 +58,9 @@ This means combining two things: We can write this as: -$$\text{Coverage} = \sum\limits_{i}\left( \text{Incidence}_{i} \times \text{Susceptibility}_{i} \right)$$ +``` math +\text{Coverage} = \sum_i (\text{Incidence}_i \times \text{Susceptibility}_i) +``` For example, suppose: @@ -69,7 +71,9 @@ For example, suppose: Then: -$$\text{Coverage} = (0.6 \times 0.9) + (0.4 \times 0.7) = 0.82$$ +``` math +\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 @@ -81,45 +85,53 @@ samples**, so they carry uncertainty. WISCA models this Let: -- $K$ be the number of pathogens, -- $\alpha = (1,1,\ldots,1)$ be a **Dirichlet** prior (uniform), -- $n = \left( n_{1},\ldots,n_{K} \right)$ be the observed counts per - species. +- $`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. Then the posterior incidence is: -$$p \sim \text{Dirichlet}\left( \alpha_{1} + n_{1},\ldots,\alpha_{K} + n_{K} \right)$$ +``` math +p \sim \text{Dirichlet}(\alpha_1 + n_1, \ldots, \alpha_K + n_K) +``` To simulate from this, we use: -$$x_{i} \sim \text{Gamma}\left( \alpha_{i} + n_{i},\ 1 \right),\quad p_{i} = \frac{x_{i}}{\sum\limits_{j = 1}^{K}x_{j}}$$ +``` math +x_i \sim \text{Gamma}(\alpha_i + n_i,\ 1), \quad p_i = \frac{x_i}{\sum_{j=1}^{K} x_j} +``` ### Susceptibility Each pathogen–regimen pair has a prior and data: -- Prior: $\text{Beta}\left( \alpha_{0},\beta_{0} \right)$, with default - $\alpha_{0} = \beta_{0} = 1$ -- Data: $S$ susceptible out of $N$ tested +- Prior: $`\text{Beta}(\alpha_0, \beta_0)`$, with default + $`\alpha_0 = \beta_0 = 1`$ +- Data: $`S`$ susceptible out of $`N`$ tested -The $S$ category could also include values SDD (susceptible, +The $`S`$ category could also include values SDD (susceptible, dose-dependent) and I (intermediate \[CLSI\], or susceptible, increased exposure \[EUCAST\]). Then the posterior is: -$$\theta \sim \text{Beta}\left( \alpha_{0} + S,\ \beta_{0} + N - S \right)$$ +``` math +\theta \sim \text{Beta}(\alpha_0 + S,\ \beta_0 + N - S) +``` ### Final coverage estimate Putting it together: -1. Simulate pathogen incidence: $\mathbf{p} \sim \text{Dirichlet}$ +1. Simulate pathogen incidence: + $`\boldsymbol{p} \sim \text{Dirichlet}`$ 2. Simulate susceptibility: - $\theta_{i} \sim \text{Beta}\left( 1 + S_{i},\ 1 + R_{i} \right)$ + $`\theta_i \sim \text{Beta}(1 + S_i,\ 1 + R_i)`$ 3. Combine: -$$\text{Coverage} = \sum\limits_{i = 1}^{K}p_{i} \cdot \theta_{i}$$ +``` math +\text{Coverage} = \sum_{i=1}^{K} p_i \cdot \theta_i +``` Repeat this simulation (e.g. 1000×) and summarise: @@ -131,6 +143,7 @@ Repeat this simulation (e.g. 1000×) and summarise: ### Prepare data and simulate synthetic syndrome ``` r + library(AMR) data <- example_isolates @@ -164,6 +177,7 @@ data$syndrome <- ifelse(data$mo %like% "coli", "UTI", "No UTI") ### Basic WISCA antibiogram ``` r + wisca(data, antimicrobials = c("AMC", "CIP", "GEN") ) @@ -176,18 +190,20 @@ wisca(data, ### Use combination regimens ``` r + wisca(data, antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN") ) ``` | Amoxicillin/clavulanic acid | Amoxicillin/clavulanic acid + Ciprofloxacin | Amoxicillin/clavulanic acid + Gentamicin | -|:----------------------------|:--------------------------------------------|:-----------------------------------------| -| 73.8% (71.8-75.7%) | 87.5% (85.9-89%) | 89.7% (88.2-91.1%) | +|:---|:---|:---| +| 73.8% (71.8-75.7%) | 87.5% (85.9-89%) | 89.7% (88.2-91.1%) | ### Stratify by syndrome ``` r + wisca(data, antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"), syndromic_group = "syndrome" @@ -195,15 +211,16 @@ wisca(data, ``` | Syndromic Group | Amoxicillin/clavulanic acid | Amoxicillin/clavulanic acid + Ciprofloxacin | Amoxicillin/clavulanic acid + Gentamicin | -|:----------------|:----------------------------|:--------------------------------------------|:-----------------------------------------| -| No UTI | 70.1% (67.8-72.3%) | 85.2% (83.1-87.2%) | 87.1% (85.3-88.7%) | -| UTI | 80.9% (77.7-83.8%) | 88.2% (85.7-90.5%) | 90.9% (88.7-93%) | +|:---|:---|:---|:---| +| No UTI | 70.1% (67.8-72.3%) | 85.2% (83.1-87.2%) | 87.1% (85.3-88.7%) | +| UTI | 80.9% (77.7-83.8%) | 88.2% (85.7-90.5%) | 90.9% (88.7-93%) | The `AMR` package is available in 28 languages, which can all be used for the [`wisca()`](https://amr-for-r.org/reference/antibiogram.md) function too: ``` r + wisca(data, antimicrobials = c("AMC", "AMC + CIP", "AMC + GEN"), syndromic_group = gsub("UTI", "UCI", data$syndrome), @@ -212,9 +229,9 @@ wisca(data, ``` | Grupo sindrómico | Amoxicilina/ácido clavulánico | Amoxicilina/ácido clavulánico + Ciprofloxacina | Amoxicilina/ácido clavulánico + Gentamicina | -|:-----------------|:------------------------------|:-----------------------------------------------|:--------------------------------------------| -| No UCI | 70% (67.8-72.4%) | 85.3% (83.3-87.2%) | 87% (85.3-88.8%) | -| UCI | 80.9% (77.7-83.9%) | 88.2% (85.5-90.6%) | 90.9% (88.7-93%) | +|:---|:---|:---|:---| +| No UCI | 70% (67.8-72.4%) | 85.3% (83.3-87.2%) | 87% (85.3-88.8%) | +| UCI | 80.9% (77.7-83.9%) | 88.2% (85.5-90.6%) | 90.9% (88.7-93%) | ## Sensible defaults, which can be customised @@ -242,6 +259,7 @@ WISCA enables: It is available in the `AMR` package via either: ``` r + wisca(...) antibiogram(..., wisca = TRUE) diff --git a/articles/datasets.html b/articles/datasets.html index 36708c44d..d3969fa4f 100644 --- a/articles/datasets.html +++ b/articles/datasets.html @@ -30,7 +30,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -80,7 +80,7 @@ Download data sets for download / own use - 25 April 2026 + 30 April 2026 Source: vignettes/datasets.Rmd datasets.Rmd diff --git a/articles/datasets.md b/articles/datasets.md index 105a10730..421f2d14a 100644 --- a/articles/datasets.md +++ b/articles/datasets.md @@ -78,14 +78,14 @@ Included (sub)species per taxonomic kingdom: First 6 rows when filtering on genus *Escherichia*: -| mo | fullname | status | kingdom | phylum | class | order | family | genus | species | subspecies | rank | ref | oxygen_tolerance | source | lpsn | lpsn_parent | lpsn_renamed_to | mycobank | mycobank_parent | mycobank_renamed_to | gbif | gbif_parent | gbif_renamed_to | prevalence | snomed | -|:-----------------:|:--------------------------:|:--------:|:--------:|:--------------:|:-------------------:|:----------------:|:------------------:|:-----------:|:--------------:|:----------:|:----------:|:-----------------------:|:---------------------------:|:------:|:------:|:-----------:|:---------------:|:--------:|:---------------:|:-------------------:|:--------:|:-----------:|:---------------:|:----------:|:-----------------------------------------:| -| B_ESCHR | Escherichia | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | | | genus | Castellani et al., 1919 | facultative anaerobe | LPSN | 515602 | 482 | | | | | | 11158430 | | 1 | 407310004, 407251000, 407281008, … | -| B_ESCHR_ADCR | Escherichia adecarboxylata | synonym | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | adecarboxylata | | species | Leclerc, 1962 | likely facultative anaerobe | LPSN | 776052 | 515602 | 777447 | | | | | | | 1 | | -| B_ESCHR_ALBR | Escherichia albertii | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | albertii | | species | Huys et al., 2003 | facultative anaerobe | LPSN | 776053 | 515602 | | | | | 5427575 | | | 1 | 419388003 | -| B_ESCHR_BLTT | Escherichia blattae | synonym | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | blattae | | species | Burgess et al., 1973 | likely facultative anaerobe | LPSN | 776056 | 515602 | 788468 | | | | | | | 1 | | -| B_ESCHR_COLI | Escherichia coli | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | coli | | species | Castellani et al., 1919 | facultative anaerobe | LPSN | 776057 | 515602 | | | | | 11286021 | | | 1 | 1095001000112106, 715307006, 737528008, … | -| B_ESCHR_COLI_COLI | Escherichia coli coli | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | coli | coli | subspecies | | | GBIF | | 776057 | | | | | 12233256 | 11286021 | | 1 | | +| mo | fullname | status | kingdom | phylum | class | order | family | genus | species | subspecies | rank | ref | oxygen_tolerance | source | lpsn | lpsn_parent | lpsn_renamed_to | mycobank | mycobank_parent | mycobank_renamed_to | gbif | gbif_parent | gbif_renamed_to | prevalence | snomed | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| B_ESCHR | Escherichia | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | | | genus | Castellani et al., 1919 | facultative anaerobe | LPSN | 515602 | 482 | | | | | | 11158430 | | 1 | 407310004, 407251000, 407281008, … | +| B_ESCHR_ADCR | Escherichia adecarboxylata | synonym | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | adecarboxylata | | species | Leclerc, 1962 | likely facultative anaerobe | LPSN | 776052 | 515602 | 777447 | | | | | | | 1 | | +| B_ESCHR_ALBR | Escherichia albertii | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | albertii | | species | Huys et al., 2003 | facultative anaerobe | LPSN | 776053 | 515602 | | | | | 5427575 | | | 1 | 419388003 | +| B_ESCHR_BLTT | Escherichia blattae | synonym | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | blattae | | species | Burgess et al., 1973 | likely facultative anaerobe | LPSN | 776056 | 515602 | 788468 | | | | | | | 1 | | +| B_ESCHR_COLI | Escherichia coli | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | coli | | species | Castellani et al., 1919 | facultative anaerobe | LPSN | 776057 | 515602 | | | | | 11286021 | | | 1 | 1095001000112106, 715307006, 737528008, … | +| B_ESCHR_COLI_COLI | Escherichia coli coli | accepted | Bacteria | Pseudomonadota | Gammaproteobacteria | Enterobacterales | Enterobacteriaceae | Escherichia | coli | coli | subspecies | | | GBIF | | 776057 | | | | | 12233256 | 11286021 | | 1 | | ------------------------------------------------------------------------ @@ -134,14 +134,14 @@ as comma separated values. **Example content** -| ab | cid | name | group | atc | atc_group1 | atc_group2 | abbreviations | synonyms | oral_ddd | oral_units | iv_ddd | iv_units | loinc | -|:---:|:--------:|:---------------------------:|:----------------------------------------------:|:------------------------------:|:-------------------------------------------:|:------------------------------------------------------------:|:-------------------:|:-------------------------------------------------------:|:--------:|:----------:|:------:|:--------:|:------------------------------:| -| AMK | 37768 | Amikacin | Aminoglycosides | D06AX12, J01GB06, QD06AX12, … | Aminoglycoside antibacterials | Other aminoglycosides | ak, ami, amik, … | amikacillin, amikacina, amikacine, … | | | 1.0 | g | 101493-5, 11-7, 12-5, … | -| AMX | 33613 | Amoxicillin | Aminopenicillins, Penicillins, Beta-lactams | J01CA04, QG51AA03, QJ01CA04 | Beta-lactam antibacterials, penicillins | Penicillins with extended spectrum | ac, amox, amoxic, … | acuotricina, alfamox, alfida, … | 1.5 | g | 3.0 | g | 101498-4, 15-8, 16-6, … | -| AMC | 23665637 | Amoxicillin/clavulanic acid | Aminopenicillins, Penicillins, Beta-lactams, … | J01CR02, QJ01CR02 | Beta-lactam antibacterials, penicillins | Combinations of penicillins, incl. beta-lactamase inhibitors | a/c, amcl, aml, … | amocla, amoclan, amoclav, … | 1.5 | g | 3.0 | g | | -| AMP | 6249 | Ampicillin | Aminopenicillins, Penicillins, Beta-lactams | J01CA01, QJ01CA01, QJ51CA01, … | Beta-lactam antibacterials, penicillins | Penicillins with extended spectrum | am, amp, amp100, … | adobacillin, alpen, amblosin, … | 2.0 | g | 6.0 | g | 101477-8, 101478-6, 18864-9, … | -| AZM | 447043 | Azithromycin | Macrolides | J01FA10, QJ01FA10, QS01AA26, … | Macrolides, lincosamides and streptogramins | Macrolides | az, azi, azit, … | aritromicina, aruzilina, azasite, … | 0.3 | g | 0.5 | g | 100043-9, 16420-2, 16421-0, … | -| PEN | 5904 | Benzylpenicillin | Penicillins, Beta-lactams | J01CE01, QJ01CE01, QJ51CE01, … | Combinations of antibacterials | Combinations of antibacterials | bepe, pen, peni, … | bencilpenicilina, benzopenicillin, benzylpenicilline, … | | | 3.6 | g | | +| ab | cid | name | group | atc | atc_group1 | atc_group2 | abbreviations | synonyms | oral_ddd | oral_units | iv_ddd | iv_units | loinc | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| AMK | 37768 | Amikacin | Aminoglycosides | D06AX12, J01GB06, QD06AX12, … | Aminoglycoside antibacterials | Other aminoglycosides | ak, ami, amik, … | amikacillin, amikacina, amikacine, … | | | 1.0 | g | 101493-5, 11-7, 12-5, … | +| AMX | 33613 | Amoxicillin | Aminopenicillins, Penicillins, Beta-lactams | J01CA04, QG51AA03, QJ01CA04 | Beta-lactam antibacterials, penicillins | Penicillins with extended spectrum | ac, amox, amoxic, … | acuotricina, alfamox, alfida, … | 1.5 | g | 3.0 | g | 101498-4, 15-8, 16-6, … | +| AMC | 23665637 | Amoxicillin/clavulanic acid | Aminopenicillins, Penicillins, Beta-lactams, … | J01CR02, QJ01CR02 | Beta-lactam antibacterials, penicillins | Combinations of penicillins, incl. beta-lactamase inhibitors | a/c, amcl, aml, … | amocla, amoclan, amoclav, … | 1.5 | g | 3.0 | g | | +| AMP | 6249 | Ampicillin | Aminopenicillins, Penicillins, Beta-lactams | J01CA01, QJ01CA01, QJ51CA01, … | Beta-lactam antibacterials, penicillins | Penicillins with extended spectrum | am, amp, amp100, … | adobacillin, alpen, amblosin, … | 2.0 | g | 6.0 | g | 101477-8, 101478-6, 18864-9, … | +| AZM | 447043 | Azithromycin | Macrolides | J01FA10, QJ01FA10, QS01AA26, … | Macrolides, lincosamides and streptogramins | Macrolides | az, azi, azit, … | aritromicina, aruzilina, azasite, … | 0.3 | g | 0.5 | g | 100043-9, 16420-2, 16421-0, … | +| PEN | 5904 | Benzylpenicillin | Penicillins, Beta-lactams | J01CE01, QJ01CE01, QJ51CE01, … | Combinations of antibacterials | Combinations of antibacterials | bepe, pen, peni, … | bencilpenicilina, benzopenicillin, benzylpenicilline, … | | | 3.6 | g | | ------------------------------------------------------------------------ @@ -186,14 +186,14 @@ here](https://amr-for-r.org/reference/clinical_breakpoints.html). **Example content** -| guideline | type | host | method | site | mo | mo_name | rank_index | ab | ab_name | ref_tbl | disk_dose | breakpoint_S | breakpoint_R | uti | is_SDD | -|:-----------:|:-----:|:-----:|:------:|:----:|:-------------:|:--------------------------:|:----------:|:---:|:-----------------------------:|:---------------:|:--------------:|:------------:|:------------:|:-----:|:------:| -| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | MEM | Meropenem | A. xylosoxidans | 10 mcg | 26.000 | 20.000 | FALSE | FALSE | -| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | MEM | Meropenem | A. xylosoxidans | | 1.000 | 4.000 | FALSE | FALSE | -| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | SXT | Trimethoprim/sulfamethoxazole | A. xylosoxidans | 1.25/23.75 mcg | 26.000 | 26.000 | FALSE | FALSE | -| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | SXT | Trimethoprim/sulfamethoxazole | A. xylosoxidans | | 0.125 | 0.125 | FALSE | FALSE | -| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | TZP | Piperacillin/tazobactam | A. xylosoxidans | 30/6 mcg | 26.000 | 26.000 | FALSE | FALSE | -| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | TZP | Piperacillin/tazobactam | A. xylosoxidans | | 4.000 | 4.000 | FALSE | FALSE | +| guideline | type | host | method | site | mo | mo_name | rank_index | ab | ab_name | ref_tbl | disk_dose | breakpoint_S | breakpoint_R | uti | is_SDD | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | MEM | Meropenem | A. xylosoxidans | 10 mcg | 26.000 | 20.000 | FALSE | FALSE | +| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | MEM | Meropenem | A. xylosoxidans | | 1.000 | 4.000 | FALSE | FALSE | +| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | SXT | Trimethoprim/sulfamethoxazole | A. xylosoxidans | 1.25/23.75 mcg | 26.000 | 26.000 | FALSE | FALSE | +| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | SXT | Trimethoprim/sulfamethoxazole | A. xylosoxidans | | 0.125 | 0.125 | FALSE | FALSE | +| EUCAST 2026 | human | human | DISK | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | TZP | Piperacillin/tazobactam | A. xylosoxidans | 30/6 mcg | 26.000 | 26.000 | FALSE | FALSE | +| EUCAST 2026 | human | human | MIC | | B_ACHRMB_XYLS | Achromobacter xylosoxidans | 2 | TZP | Piperacillin/tazobactam | A. xylosoxidans | | 4.000 | 4.000 | FALSE | FALSE | ------------------------------------------------------------------------ @@ -236,14 +236,14 @@ here](https://amr-for-r.org/reference/microorganisms.groups.html). **Example content** -| mo_group | mo | mo_group_name | mo_name | -|:--------------:|:------------:|:-------------------------------:|:---------------------------:| -| B_ACNTB_BMNN-C | B_ACNTB_BMNN | Acinetobacter baumannii complex | Acinetobacter baumannii | +| mo_group | mo | mo_group_name | mo_name | +|:--:|:--:|:--:|:--:| +| B_ACNTB_BMNN-C | B_ACNTB_BMNN | Acinetobacter baumannii complex | Acinetobacter baumannii | | B_ACNTB_BMNN-C | B_ACNTB_CLCC | Acinetobacter baumannii complex | Acinetobacter calcoaceticus | | B_ACNTB_BMNN-C | B_ACNTB_LCTC | Acinetobacter baumannii complex | Acinetobacter dijkshoorniae | -| B_ACNTB_BMNN-C | B_ACNTB_NSCM | Acinetobacter baumannii complex | Acinetobacter nosocomialis | -| B_ACNTB_BMNN-C | B_ACNTB_PITT | Acinetobacter baumannii complex | Acinetobacter pittii | -| B_ACNTB_BMNN-C | B_ACNTB_SFRT | Acinetobacter baumannii complex | Acinetobacter seifertii | +| B_ACNTB_BMNN-C | B_ACNTB_NSCM | Acinetobacter baumannii complex | Acinetobacter nosocomialis | +| B_ACNTB_BMNN-C | B_ACNTB_PITT | Acinetobacter baumannii complex | Acinetobacter pittii | +| B_ACNTB_BMNN-C | B_ACNTB_SFRT | Acinetobacter baumannii complex | Acinetobacter seifertii | ------------------------------------------------------------------------ @@ -394,14 +394,14 @@ here](https://amr-for-r.org/reference/dosage.html). **Example content** -| ab | name | type | dose | dose_times | administration | notes | original_txt | eucast_version | -|:---:|:-----------:|:-----------------:|:-----------:|:----------:|:--------------:|:-----:|:------------------:|:--------------:| -| AMK | Amikacin | standard_dosage | 25-30 mg/kg | 1 | iv | | 25-30 mg/kg x 1 iv | 15 | -| AMX | Amoxicillin | high_dosage | 2 g | 6 | iv | | 2 g x 6 iv | 15 | -| AMX | Amoxicillin | standard_dosage | 1 g | 3 | iv | | 1 g x 3-4 iv | 15 | -| AMX | Amoxicillin | high_dosage | 0.75-1 g | 3 | oral | | 0.75-1 g x 3 oral | 15 | -| AMX | Amoxicillin | standard_dosage | 0.5 g | 3 | oral | | 0.5 g x 3 oral | 15 | -| AMX | Amoxicillin | uncomplicated_uti | 0.5 g | 3 | oral | | 0.5 g x 3 oral | 15 | +| ab | name | type | dose | dose_times | administration | notes | original_txt | eucast_version | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| AMK | Amikacin | standard_dosage | 25-30 mg/kg | 1 | iv | | 25-30 mg/kg x 1 iv | 15 | +| AMX | Amoxicillin | high_dosage | 2 g | 6 | iv | | 2 g x 6 iv | 15 | +| AMX | Amoxicillin | standard_dosage | 1 g | 3 | iv | | 1 g x 3-4 iv | 15 | +| AMX | Amoxicillin | high_dosage | 0.75-1 g | 3 | oral | | 0.75-1 g x 3 oral | 15 | +| AMX | Amoxicillin | standard_dosage | 0.5 g | 3 | oral | | 0.5 g x 3 oral | 15 | +| AMX | Amoxicillin | uncomplicated_uti | 0.5 g | 3 | oral | | 0.5 g x 3 oral | 15 | ------------------------------------------------------------------------ @@ -424,14 +424,14 @@ here](https://amr-for-r.org/reference/example_isolates.html). **Example content** -| date | patient | age | gender | ward | mo | PEN | OXA | FLC | AMX | AMC | AMP | TZP | CZO | FEP | CXM | FOX | CTX | CAZ | CRO | GEN | TOB | AMK | KAN | TMP | SXT | NIT | FOS | LNZ | CIP | MFX | VAN | TEC | TCY | TGC | DOX | ERY | CLI | AZM | IPM | MEM | MTR | CHL | COL | MUP | RIF | -|:----------:|:-------:|:---:|:------:|:--------:|:------------:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| -| 2002-01-02 | A77334 | 65 | F | Clinical | B_ESCHR_COLI | R | | | | I | | | | | I | | | | | | | | | R | R | | | R | | | R | R | R | | | R | R | R | | | | | | | R | -| 2002-01-03 | A77334 | 65 | F | Clinical | B_ESCHR_COLI | R | | | | I | | | | | I | | | | | | | | | R | R | | | R | | | R | R | R | | | R | R | R | | | | | | | R | -| 2002-01-07 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | S | S | | | | | | S | | S | S | S | R | | R | | | | | R | | | -| 2002-01-07 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | S | S | | | | | | S | | S | S | S | R | | R | | | | | R | | | -| 2002-01-13 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | R | | | | | | | S | | S | S | S | R | | R | | | | | R | | | -| 2002-01-13 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | R | | | | | | | S | | S | S | S | R | R | R | | | | | R | | | +| date | patient | age | gender | ward | mo | PEN | OXA | FLC | AMX | AMC | AMP | TZP | CZO | FEP | CXM | FOX | CTX | CAZ | CRO | GEN | TOB | AMK | KAN | TMP | SXT | NIT | FOS | LNZ | CIP | MFX | VAN | TEC | TCY | TGC | DOX | ERY | CLI | AZM | IPM | MEM | MTR | CHL | COL | MUP | RIF | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| 2002-01-02 | A77334 | 65 | F | Clinical | B_ESCHR_COLI | R | | | | I | | | | | I | | | | | | | | | R | R | | | R | | | R | R | R | | | R | R | R | | | | | | | R | +| 2002-01-03 | A77334 | 65 | F | Clinical | B_ESCHR_COLI | R | | | | I | | | | | I | | | | | | | | | R | R | | | R | | | R | R | R | | | R | R | R | | | | | | | R | +| 2002-01-07 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | S | S | | | | | | S | | S | S | S | R | | R | | | | | R | | | +| 2002-01-07 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | S | S | | | | | | S | | S | S | S | R | | R | | | | | R | | | +| 2002-01-13 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | R | | | | | | | S | | S | S | S | R | | R | | | | | R | | | +| 2002-01-13 | 067927 | 45 | F | ICU | B_STPHY_EPDR | R | | R | | | | | | | R | | | R | | | | | | R | | | | | | | S | | S | S | S | R | R | R | | | | | R | | | ------------------------------------------------------------------------ @@ -555,11 +555,11 @@ contain the trade names and LOINC codes as comma separated values. **Example content** -| av | name | atc | cid | atc_group | synonyms | oral_ddd | oral_units | iv_ddd | iv_units | loinc | -|:---:|:------------------:|:-------:|:---------:|:------------------------------------------------------------------:|:-----------------------------------------------------:|:--------:|:----------:|:------:|:--------:|:----------------------------:| -| ABA | Abacavir | J05AF06 | 441300 | Nucleoside and nucleotide reverse transcriptase inhibitors | abacavir sulfate, avacavir, ziagen | 0.6 | g | | | 29113-8, 30273-7, 30287-7, … | -| ACI | Aciclovir | J05AB01 | 135398513 | Nucleosides and nucleotides excl. reverse transcriptase inhibitors | acicloftal, aciclovier, aciclovirum, … | 4.0 | g | 4 | g | | -| ADD | Adefovir dipivoxil | J05AF08 | 60871 | Nucleoside and nucleotide reverse transcriptase inhibitors | adefovir di, adefovir di ester, adefovir dipivoxyl, … | 10.0 | mg | | | | -| AME | Amenamevir | J05AX26 | 11397521 | Other antivirals | amenalief | 0.4 | g | | | | -| AMP | Amprenavir | J05AE05 | 65016 | Protease inhibitors | agenerase, carbamate, prozei | 1.2 | g | | | 29114-6, 30296-8, 30297-6, … | -| ASU | Asunaprevir | J05AP06 | 16076883 | Antivirals for treatment of HCV infections | sunvepra, sunvepratrade | 0.2 | g | | | | +| av | name | atc | cid | atc_group | synonyms | oral_ddd | oral_units | iv_ddd | iv_units | loinc | +|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:| +| ABA | Abacavir | J05AF06 | 441300 | Nucleoside and nucleotide reverse transcriptase inhibitors | abacavir sulfate, avacavir, ziagen | 0.6 | g | | | 29113-8, 30273-7, 30287-7, … | +| ACI | Aciclovir | J05AB01 | 135398513 | Nucleosides and nucleotides excl. reverse transcriptase inhibitors | acicloftal, aciclovier, aciclovirum, … | 4.0 | g | 4 | g | | +| ADD | Adefovir dipivoxil | J05AF08 | 60871 | Nucleoside and nucleotide reverse transcriptase inhibitors | adefovir di, adefovir di ester, adefovir dipivoxyl, … | 10.0 | mg | | | | +| AME | Amenamevir | J05AX26 | 11397521 | Other antivirals | amenalief | 0.4 | g | | | | +| AMP | Amprenavir | J05AE05 | 65016 | Protease inhibitors | agenerase, carbamate, prozei | 1.2 | g | | | 29114-6, 30296-8, 30297-6, … | +| ASU | Asunaprevir | J05AP06 | 16076883 | Antivirals for treatment of HCV infections | sunvepra, sunvepratrade | 0.2 | g | | | | diff --git a/articles/index.html b/articles/index.html index 2a3723b23..0d63db1d9 100644 --- a/articles/index.html +++ b/articles/index.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/authors.html b/authors.html index 3876b1d33..5ee17cc48 100644 --- a/authors.html +++ b/authors.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/index.html b/index.html index aa37266ac..7ddd7d47e 100644 --- a/index.html +++ b/index.html @@ -33,7 +33,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -145,24 +145,26 @@ #> ℹ Using column mo as input for `mo_fullname()` #> ℹ Using column mo as input for `mo_is_gram_negative()` #> ℹ Using column mo as input for `mo_is_intrinsic_resistant()` -#> ℹ Determining intrinsic resistance based on 'EUCAST Expected Resistant -#> Phenotypes' v1.2 (2023). This note will be shown once per session. -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ Determining intrinsic resistance based on 'EUCAST Expected +#> Resistant Phenotypes' v1.2 (2023). This note will be shown +#> once per session. +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) #> # A tibble: 35 × 7 -#> bacteria GEN TOB AMK KAN IPM MEM -#> <chr> <sir> <sir> <sir> <sir> <sir> <sir> -#> 1 Pseudomonas aeruginosa I S NA R S NA -#> 2 Pseudomonas aeruginosa I S NA R S NA -#> 3 Pseudomonas aeruginosa I S NA R S NA -#> 4 Pseudomonas aeruginosa S S S R NA S -#> 5 Pseudomonas aeruginosa S S S R S S -#> 6 Pseudomonas aeruginosa S S S R S S -#> 7 Stenotrophomonas maltophilia R R R R R R -#> 8 Pseudomonas aeruginosa S S S R NA S -#> 9 Pseudomonas aeruginosa S S S R NA S -#> 10 Pseudomonas aeruginosa S S S R S S +#> bacteria GEN TOB AMK KAN IPM MEM +#> <chr> <sir> <sir> <sir> <sir> <sir> <sir> +#> 1 Pseudomonas aer… I S NA R S NA +#> 2 Pseudomonas aer… I S NA R S NA +#> 3 Pseudomonas aer… I S NA R S NA +#> 4 Pseudomonas aer… S S S R NA S +#> 5 Pseudomonas aer… S S S R S S +#> 6 Pseudomonas aer… S S S R S S +#> 7 Stenotrophomona… R R R R R R +#> 8 Pseudomonas aer… S S S R NA S +#> 9 Pseudomonas aer… S S S R NA S +#> 10 Pseudomonas aer… S S S R S S #> # ℹ 25 more rows With only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (mo_is_gram_negative() and mo_is_intrinsic_resistant()) and a column selection on two antibiotic groups (aminoglycosides() and carbapenems()), the reference data about all microorganisms and all antimicrobials in the AMR package make sure you get what you meant. @@ -174,20 +176,21 @@ antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems())) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) - +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) + + + - - - - - + + + - + Pathogen Amikacin Gentamicin @@ -197,7 +200,7 @@ Tobramycin - + CoNS 0% (0-8%,N=43) 86% (82-90%,N=309) @@ -206,7 +209,7 @@ 52% (37-67%,N=48) 22% (12-35%,N=55) - + E. coli 100% (98-100%,N=171) 98% (96-99%,N=460) @@ -215,7 +218,7 @@ 100% (99-100%,N=418) 97% (96-99%,N=462) - + E. faecalis 0% (0-9%,N=39) 0% (0-9%,N=39) @@ -224,7 +227,7 @@ NA 0% (0-9%,N=39) - + K. pneumoniae NA 90% (79-96%,N=58) @@ -233,7 +236,7 @@ 100% (93-100%,N=53) 90% (79-96%,N=58) - + P. aeruginosa NA 100% (88-100%,N=30) @@ -242,7 +245,7 @@ NA 100% (88-100%,N=30) - + P. mirabilis NA 94% (80-99%,N=34) @@ -251,7 +254,7 @@ NA 94% (80-99%,N=34) - + S. aureus NA 99% (97-100%,N=233) @@ -260,7 +263,7 @@ NA 98% (92-100%,N=86) - + S. epidermidis 0% (0-8%,N=44) 79% (71-85%,N=163) @@ -269,7 +272,7 @@ NA 51% (40-61%,N=89) - + S. hominis NA 92% (84-97%,N=80) @@ -278,7 +281,7 @@ NA 85% (74-93%,N=62) - + S. pneumoniae 0% (0-3%,N=117) 0% (0-3%,N=117) @@ -296,25 +299,25 @@ mo_transform = "gramstain") - - - - + + + + - + Pathogen Piperacillin/tazobactam Piperacillin/tazobactam + Gentamicin Piperacillin/tazobactam + Tobramycin - + Gram-negative 88% (85-91%,N=641) 99% (97-99%,N=691) 98% (97-99%,N=693) - + Gram-positive 86% (82-89%,N=345) 98% (96-98%,N=1044) @@ -336,20 +339,20 @@ - + Збудник Гентаміцин Тобраміцин Ципрофлоксацин - + Грамнегативні 96% (95-98%,N=684) 96% (94-97%,N=686) 91% (88-93%,N=684) - + Грампозитивні 63% (60-66%,N=1170) 34% (31-38%,N=665) @@ -404,16 +407,18 @@ summarise(across(c(GEN, TOB), list(total_R = resistance, conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) -#> ℹ `resistance()` assumes the EUCAST guideline and thus considers the 'I' -#> category susceptible. Set the `guideline` argument or the `AMR_guideline` -#> option to either "CLSI" or "EUCAST", see `?AMR-options`. +#> ℹ `resistance()` assumes the EUCAST guideline and thus +#> considers the 'I' category susceptible. Set the `guideline` +#> argument or the `AMR_guideline` option to either "CLSI" or +#> "EUCAST", see `?AMR-options`. #> ℹ This message will be shown once per session. #> # A tibble: 3 × 5 -#> ward GEN_total_R GEN_conf_int TOB_total_R TOB_conf_int -#> <chr> <dbl> <chr> <dbl> <chr> -#> 1 Clinical 0.229 0.205-0.254 0.315 0.284-0.347 -#> 2 ICU 0.290 0.253-0.33 0.400 0.353-0.449 -#> 3 Outpatient 0.2 0.131-0.285 0.368 0.254-0.493 +#> ward GEN_total_R GEN_conf_int TOB_total_R +#> <chr> <dbl> <chr> <dbl> +#> 1 Clinical 0.229 0.205-0.254 0.315 +#> 2 ICU 0.290 0.253-0.33 0.400 +#> 3 Outpatient 0.2 0.131-0.285 0.368 +#> # ℹ 1 more variable: TOB_conf_int <chr> Or use antimicrobial selectors to select a series of antibiotic columns: library(AMR) @@ -425,15 +430,16 @@ # calculate AMR using resistance(), over all aminoglycosides and polymyxins: summarise(across(c(aminoglycosides(), polymyxins()), resistance)) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) #> ℹ For `polymyxins()` using column COL (colistin) #> Warning: There was 1 warning in `summarise()`. -#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), resistance)`. +#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), +#> resistance)`. #> ℹ In group 3: `ward = "Outpatient"`. #> Caused by warning: -#> ! Introducing NA: only 23 results available for KAN in group: ward = "Outpatient" -#> (whilst `minimum = 30`). +#> ! Introducing NA: only 23 results available for KAN in group: +#> ward = "Outpatient" (whilst `minimum = 30`). out #> # A tibble: 3 × 6 #> ward GEN TOB AMK KAN COL @@ -445,11 +451,12 @@ # transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889 +#> ward gentamicin tobramycin amikacin kanamycin +#> <chr> <dbl> <dbl> <dbl> <dbl> +#> 1 Clinical 0.229 0.315 0.626 1 +#> 2 ICU 0.290 0.400 0.662 1 +#> 3 Outpatient 0.2 0.368 0.605 NA +#> # ℹ 1 more variable: colistin <dbl> # transform the antibiotic column to ATC codes: out %>% set_ab_names(property = "atc") diff --git a/index.md b/index.md index e57b8a9bc..bd0c1276f 100644 --- a/index.md +++ b/index.md @@ -100,6 +100,7 @@ selectors](https://amr-for-r.org/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 library(AMR) library(dplyr, warn.conflicts = FALSE) @@ -116,24 +117,26 @@ example_isolates %>% #> ℹ Using column mo as input for `mo_fullname()` #> ℹ Using column mo as input for `mo_is_gram_negative()` #> ℹ Using column mo as input for `mo_is_intrinsic_resistant()` -#> ℹ Determining intrinsic resistance based on 'EUCAST Expected Resistant -#> Phenotypes' v1.2 (2023). This note will be shown once per session. -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ Determining intrinsic resistance based on 'EUCAST Expected +#> Resistant Phenotypes' v1.2 (2023). This note will be shown +#> once per session. +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) #> # A tibble: 35 × 7 -#> bacteria GEN TOB AMK KAN IPM MEM -#> -#> 1 Pseudomonas aeruginosa I S NA R S NA -#> 2 Pseudomonas aeruginosa I S NA R S NA -#> 3 Pseudomonas aeruginosa I S NA R S NA -#> 4 Pseudomonas aeruginosa S S S R NA S -#> 5 Pseudomonas aeruginosa S S S R S S -#> 6 Pseudomonas aeruginosa S S S R S S -#> 7 Stenotrophomonas maltophilia R R R R R R -#> 8 Pseudomonas aeruginosa S S S R NA S -#> 9 Pseudomonas aeruginosa S S S R NA S -#> 10 Pseudomonas aeruginosa S S S R S S +#> bacteria GEN TOB AMK KAN IPM MEM +#> +#> 1 Pseudomonas aer… I S NA R S NA +#> 2 Pseudomonas aer… I S NA R S NA +#> 3 Pseudomonas aer… I S NA R S NA +#> 4 Pseudomonas aer… S S S R NA S +#> 5 Pseudomonas aer… S S S R S S +#> 6 Pseudomonas aer… S S S R S S +#> 7 Stenotrophomona… R R R R R R +#> 8 Pseudomonas aer… S S S R NA S +#> 9 Pseudomonas aer… S S S R NA S +#> 10 Pseudomonas aer… S S S R S S #> # ℹ 25 more rows ``` @@ -161,39 +164,42 @@ If used inside [R Markdown](https://rmarkdown.rstudio.com) or output format automatically (such as markdown, LaTeX, HTML, etc.). ``` r + antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems())) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) ``` -| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | -|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------| -| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | -| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | -| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | -| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | -| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | -| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | -| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | -| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | -| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | -| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | +| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | +|:---|:---|:---|:---|:---|:---|:---| +| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | +| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | +| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | +| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | +| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | +| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | +| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | +| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | +| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | +| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | In combination antibiograms, it is clear that combined antimicrobials yield higher empiric coverage: ``` r + antibiogram(example_isolates, antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"), mo_transform = "gramstain") ``` -| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | -|:--------------|:------------------------|:-------------------------------------|:-------------------------------------| -| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | -| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | +| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | +|:---|:---|:---|:---| +| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | +| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | Like many other functions in this package, [`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md) comes @@ -201,6 +207,7 @@ with support for 28 languages that are often detected automatically based on system language: ``` r + antibiogram(example_isolates, antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work mo_transform = "gramstain", @@ -221,6 +228,7 @@ with new scale functions, to allow plotting of log2-distributed MIC values and SIR values. ``` r + library(ggplot2) library(AMR) @@ -258,6 +266,7 @@ For a manual approach, you can use the `resistance` or function: ``` r + example_isolates %>% # group by ward: group_by(ward) %>% @@ -266,16 +275,18 @@ example_isolates %>% summarise(across(c(GEN, TOB), list(total_R = resistance, conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) -#> ℹ `resistance()` assumes the EUCAST guideline and thus considers the 'I' -#> category susceptible. Set the `guideline` argument or the `AMR_guideline` -#> option to either "CLSI" or "EUCAST", see `?AMR-options`. +#> ℹ `resistance()` assumes the EUCAST guideline and thus +#> considers the 'I' category susceptible. Set the `guideline` +#> argument or the `AMR_guideline` option to either "CLSI" or +#> "EUCAST", see `?AMR-options`. #> ℹ This message will be shown once per session. #> # A tibble: 3 × 5 -#> ward GEN_total_R GEN_conf_int TOB_total_R TOB_conf_int -#> -#> 1 Clinical 0.229 0.205-0.254 0.315 0.284-0.347 -#> 2 ICU 0.290 0.253-0.33 0.400 0.353-0.449 -#> 3 Outpatient 0.2 0.131-0.285 0.368 0.254-0.493 +#> ward GEN_total_R GEN_conf_int TOB_total_R +#> +#> 1 Clinical 0.229 0.205-0.254 0.315 +#> 2 ICU 0.290 0.253-0.33 0.400 +#> 3 Outpatient 0.2 0.131-0.285 0.368 +#> # ℹ 1 more variable: TOB_conf_int ``` Or use [antimicrobial @@ -283,6 +294,7 @@ selectors](https://amr-for-r.org/reference/antimicrobial_selectors.html) to select a series of antibiotic columns: ``` r + library(AMR) library(dplyr) @@ -292,15 +304,16 @@ out <- example_isolates %>% # calculate AMR using resistance(), over all aminoglycosides and polymyxins: summarise(across(c(aminoglycosides(), polymyxins()), resistance)) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) #> ℹ For `polymyxins()` using column COL (colistin) #> Warning: There was 1 warning in `summarise()`. -#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), resistance)`. +#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), +#> resistance)`. #> ℹ In group 3: `ward = "Outpatient"`. #> Caused by warning: -#> ! Introducing NA: only 23 results available for KAN in group: ward = "Outpatient" -#> (whilst `minimum = 30`). +#> ! Introducing NA: only 23 results available for KAN in group: +#> ward = "Outpatient" (whilst `minimum = 30`). out #> # A tibble: 3 × 6 #> ward GEN TOB AMK KAN COL @@ -311,17 +324,20 @@ out ``` ``` r + # transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889 +#> ward gentamicin tobramycin amikacin kanamycin +#> +#> 1 Clinical 0.229 0.315 0.626 1 +#> 2 ICU 0.290 0.400 0.662 1 +#> 3 Outpatient 0.2 0.368 0.605 NA +#> # ℹ 1 more variable: colistin ``` ``` r + # transform the antibiotic column to ATC codes: out %>% set_ab_names(property = "atc") #> # A tibble: 3 × 6 @@ -393,6 +409,7 @@ This package is available [here on the official R network R from CRAN by using the command: ``` r + install.packages("AMR") ``` @@ -417,6 +434,7 @@ here](https://github.com/msberends/AMR/wiki/Developer-Guideline). To install the latest and unpublished beta version: ``` r + install.packages("AMR", repos = "beta.amr-for-r.org") # if this does not work, try to install directly from GitHub using the 'remotes' package: diff --git a/llms.txt b/llms.txt index 2c7a590b7..2d147432c 100644 --- a/llms.txt +++ b/llms.txt @@ -100,6 +100,7 @@ selectors](https://amr-for-r.org/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 library(AMR) library(dplyr, warn.conflicts = FALSE) @@ -116,24 +117,26 @@ example_isolates %>% #> ℹ Using column mo as input for `mo_fullname()` #> ℹ Using column mo as input for `mo_is_gram_negative()` #> ℹ Using column mo as input for `mo_is_intrinsic_resistant()` -#> ℹ Determining intrinsic resistance based on 'EUCAST Expected Resistant -#> Phenotypes' v1.2 (2023). This note will be shown once per session. -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ Determining intrinsic resistance based on 'EUCAST Expected +#> Resistant Phenotypes' v1.2 (2023). This note will be shown +#> once per session. +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) #> # A tibble: 35 × 7 -#> bacteria GEN TOB AMK KAN IPM MEM -#> -#> 1 Pseudomonas aeruginosa I S NA R S NA -#> 2 Pseudomonas aeruginosa I S NA R S NA -#> 3 Pseudomonas aeruginosa I S NA R S NA -#> 4 Pseudomonas aeruginosa S S S R NA S -#> 5 Pseudomonas aeruginosa S S S R S S -#> 6 Pseudomonas aeruginosa S S S R S S -#> 7 Stenotrophomonas maltophilia R R R R R R -#> 8 Pseudomonas aeruginosa S S S R NA S -#> 9 Pseudomonas aeruginosa S S S R NA S -#> 10 Pseudomonas aeruginosa S S S R S S +#> bacteria GEN TOB AMK KAN IPM MEM +#> +#> 1 Pseudomonas aer… I S NA R S NA +#> 2 Pseudomonas aer… I S NA R S NA +#> 3 Pseudomonas aer… I S NA R S NA +#> 4 Pseudomonas aer… S S S R NA S +#> 5 Pseudomonas aer… S S S R S S +#> 6 Pseudomonas aer… S S S R S S +#> 7 Stenotrophomona… R R R R R R +#> 8 Pseudomonas aer… S S S R NA S +#> 9 Pseudomonas aer… S S S R NA S +#> 10 Pseudomonas aer… S S S R S S #> # ℹ 25 more rows ``` @@ -161,39 +164,42 @@ If used inside [R Markdown](https://rmarkdown.rstudio.com) or output format automatically (such as markdown, LaTeX, HTML, etc.). ``` r + antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems())) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) ``` -| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | -|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------| -| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | -| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | -| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | -| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | -| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | -| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | -| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | -| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | -| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | -| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | +| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | +|:---|:---|:---|:---|:---|:---|:---| +| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | +| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | +| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | +| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | +| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | +| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | +| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | +| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | +| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | +| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | In combination antibiograms, it is clear that combined antimicrobials yield higher empiric coverage: ``` r + antibiogram(example_isolates, antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"), mo_transform = "gramstain") ``` -| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | -|:--------------|:------------------------|:-------------------------------------|:-------------------------------------| -| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | -| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | +| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | +|:---|:---|:---|:---| +| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | +| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | Like many other functions in this package, [`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md) comes @@ -201,6 +207,7 @@ with support for 28 languages that are often detected automatically based on system language: ``` r + antibiogram(example_isolates, antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work mo_transform = "gramstain", @@ -221,6 +228,7 @@ with new scale functions, to allow plotting of log2-distributed MIC values and SIR values. ``` r + library(ggplot2) library(AMR) @@ -258,6 +266,7 @@ For a manual approach, you can use the `resistance` or function: ``` r + example_isolates %>% # group by ward: group_by(ward) %>% @@ -266,16 +275,18 @@ example_isolates %>% summarise(across(c(GEN, TOB), list(total_R = resistance, conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) -#> ℹ `resistance()` assumes the EUCAST guideline and thus considers the 'I' -#> category susceptible. Set the `guideline` argument or the `AMR_guideline` -#> option to either "CLSI" or "EUCAST", see `?AMR-options`. +#> ℹ `resistance()` assumes the EUCAST guideline and thus +#> considers the 'I' category susceptible. Set the `guideline` +#> argument or the `AMR_guideline` option to either "CLSI" or +#> "EUCAST", see `?AMR-options`. #> ℹ This message will be shown once per session. #> # A tibble: 3 × 5 -#> ward GEN_total_R GEN_conf_int TOB_total_R TOB_conf_int -#> -#> 1 Clinical 0.229 0.205-0.254 0.315 0.284-0.347 -#> 2 ICU 0.290 0.253-0.33 0.400 0.353-0.449 -#> 3 Outpatient 0.2 0.131-0.285 0.368 0.254-0.493 +#> ward GEN_total_R GEN_conf_int TOB_total_R +#> +#> 1 Clinical 0.229 0.205-0.254 0.315 +#> 2 ICU 0.290 0.253-0.33 0.400 +#> 3 Outpatient 0.2 0.131-0.285 0.368 +#> # ℹ 1 more variable: TOB_conf_int ``` Or use [antimicrobial @@ -283,6 +294,7 @@ selectors](https://amr-for-r.org/reference/antimicrobial_selectors.html) to select a series of antibiotic columns: ``` r + library(AMR) library(dplyr) @@ -292,15 +304,16 @@ out <- example_isolates %>% # calculate AMR using resistance(), over all aminoglycosides and polymyxins: summarise(across(c(aminoglycosides(), polymyxins()), resistance)) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) #> ℹ For `polymyxins()` using column COL (colistin) #> Warning: There was 1 warning in `summarise()`. -#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), resistance)`. +#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), +#> resistance)`. #> ℹ In group 3: `ward = "Outpatient"`. #> Caused by warning: -#> ! Introducing NA: only 23 results available for KAN in group: ward = "Outpatient" -#> (whilst `minimum = 30`). +#> ! Introducing NA: only 23 results available for KAN in group: +#> ward = "Outpatient" (whilst `minimum = 30`). out #> # A tibble: 3 × 6 #> ward GEN TOB AMK KAN COL @@ -311,17 +324,20 @@ out ``` ``` r + # transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889 +#> ward gentamicin tobramycin amikacin kanamycin +#> +#> 1 Clinical 0.229 0.315 0.626 1 +#> 2 ICU 0.290 0.400 0.662 1 +#> 3 Outpatient 0.2 0.368 0.605 NA +#> # ℹ 1 more variable: colistin ``` ``` r + # transform the antibiotic column to ATC codes: out %>% set_ab_names(property = "atc") #> # A tibble: 3 × 6 @@ -393,6 +409,7 @@ This package is available [here on the official R network R from CRAN by using the command: ``` r + install.packages("AMR") ``` @@ -417,6 +434,7 @@ here](https://github.com/msberends/AMR/wiki/Developer-Guideline). To install the latest and unpublished beta version: ``` r + install.packages("AMR", repos = "beta.amr-for-r.org") # if this does not work, try to install directly from GitHub using the 'remotes' package: diff --git a/news/index.html b/news/index.html index 91be66e82..3c3006bb3 100644 --- a/news/index.html +++ b/news/index.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -49,11 +49,17 @@ -AMR 3.0.1.9052 +AMR 3.0.1.9053 +This will become release v3.1.0, intended for launch end of May. -New +New Support for clinical breakpoints of 2026 of both CLSI and EUCAST, by adding all of their over 5,700 new clinical breakpoints to the clinical_breakpoints data set for usage in as.sir(). EUCAST 2026 is now the new default guideline for all MIC and disk diffusion interpretations. -Integration with the tidymodels framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via recipes +Support for the future package and its framework, as the previous implementation of parallel computing was slow + +Breaking change: as.sir() with parallel = TRUE now requires a non-sequential future::plan() to be active before the call — e.g., future::plan(future::multisession) — and throws an informative error if none is set. +New all-core usage setup: when the number of AB columns is smaller than the number of available cores, rows are now split into batches so all cores stay active (row-batch mode). Previously, a 6-column dataset on a 16-core machine would only use 6 cores; now all 16 are used, with each worker processing a smaller row slice (lower per-worker memory pressure and processing time) + +Integration with the tidymodels framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via recipes step_mic_log2() to transform <mic> columns with log2, and step_sir_numeric() to convert <sir> columns to numeric New tidyselect helpers: @@ -86,9 +92,8 @@ Two new NA objects, NA_ab_ and NA_mo_, analogous to base R’s NA_character_ and NA_integer_, for use in pipelines that require typed missing values -Fixes -Fixed multiple bugs in the parallel = TRUE mode of as.sir() for data frames -Fixed a bug in as.sir() where values that were purely numeric (e.g., "1") and matched the broad SIR-matching regex would be incorrectly stripped of all content by the Unicode letter filter +Fixes +Fixed a bug in as.sir() where values that were purely numeric (e.g., "1") and matched the broad SIR-matching regex would be incorrectly stripped of all content by the Unicode letter filter Fixed a bug in as.mic() where MIC values in scientific notation (e.g., "1e-3") were incorrectly handled because the letter e was removed along with other Unicode letters; scientific notation e is now preserved Fixed a bug in as.ab() where certain AB codes containing “PH” or “TH” (such as ETH, MTH, PHE, PHN, STH, THA, THI1) would incorrectly return NA when combined in a vector with any untranslatable value (#245) Fixed a bug in antibiogram() for when no antimicrobials are set @@ -104,12 +109,10 @@ Fixed BRMO classification by including bacterial complexes (#275) Fixed as.sir() for data frames silently deleting columns whose AB class was already <sir> when called a second time (re-running on already-converted data) (#278) Fixed as.sir() for data frames incorrectly treating metadata columns (e.g. patient, ward) as antibiotic columns when their names coincidentally matched an antibiotic code; column content is now validated against AMR data patterns before inclusion -Improved parallel computing in as.sir(): when the number of AB columns is smaller than the number of available cores, rows are now split into batches so all cores stay active (row-batch mode). Previously, a 6-column dataset on a 16-core machine would only use 6 cores; now all 16 are used, with each worker processing a smaller row slice (lower per-worker memory pressure) -Fixed as.sir() ignoring info = FALSE for columns with no breakpoints (e.g. cefoxitin against E. coli): an operator-precedence bug (&&/||) caused the “Interpreting MIC values” intro message to fire unconditionally when nrow(breakpoints) == 0, regardless of info; the progress bar title was also not gated by info - +Fixed as.sir() ignoring info = FALSE for columns with no breakpoints (e.g. cefoxitin against E. coli) -Updates +Updates as.sir() with reference_data: custom guideline names now correctly classify values as R using EUCAST convention (> breakpoint_R for MIC, < breakpoint_R for disk); custom breakpoints with host = NA now serve as a host-agnostic fallback when no host-specific row matches (#239) Extensive cli integration for better message handling and clickable links in messages and warnings (#191, #265) @@ -134,7 +137,6 @@ ab_group() now returns values consist with the AMR selectors (#246) -Added two new NA objects, NA_ab_ and NA_mo_, analogous to base R’s NA_character_ and NA_integer_, for use in pipelines that require typed missing values diff --git a/news/index.md b/news/index.md index efab6a365..8cdf9539b 100644 --- a/news/index.md +++ b/news/index.md @@ -1,6 +1,8 @@ # Changelog -## AMR 3.0.1.9052 +## AMR 3.0.1.9053 + +This will become release v3.1.0, intended for launch end of May. #### New @@ -10,7 +12,23 @@ [`as.sir()`](https://amr-for-r.org/reference/as.sir.md). EUCAST 2026 is now the new default guideline for all MIC and disk diffusion interpretations. -- Integration with the **tidymodels** framework to allow seamless use of +- Support for the [`future`](https://future.futureverse.org) package and + its framework, as the previous implementation of parallel computing + was slow + - **Breaking change**: + [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) with + `parallel = TRUE` now requires a non-sequential + [`future::plan()`](https://future.futureverse.org/reference/plan.html) + to be active before the call — e.g., + `future::plan(future::multisession)` — and throws an informative + error if none is set. + - New all-core usage setup: when the number of AB columns is smaller + than the number of available cores, rows are now split into batches + so all cores stay active (row-batch mode). Previously, a 6-column + dataset on a 16-core machine would only use 6 cores; now all 16 are + used, with each worker processing a smaller row slice (lower + per-worker memory pressure and processing time) +- Integration with the *tidymodels* framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via `recipes` - [`step_mic_log2()`](https://amr-for-r.org/reference/amr-tidymodels.md) to transform `` columns with log2, and @@ -63,9 +81,6 @@ #### Fixes -- Fixed multiple bugs in the `parallel = TRUE` mode of - [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) for data - frames - Fixed a bug in [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) where values that were purely numeric (e.g., `"1"`) and matched the broad SIR-matching regex would be incorrectly stripped of all content @@ -111,19 +126,9 @@ as antibiotic columns when their names coincidentally matched an antibiotic code; column content is now validated against AMR data patterns before inclusion -- Improved parallel computing in - [`as.sir()`](https://amr-for-r.org/reference/as.sir.md): when the - number of AB columns is smaller than the number of available cores, - rows are now split into batches so all cores stay active (row-batch - mode). Previously, a 6-column dataset on a 16-core machine would only - use 6 cores; now all 16 are used, with each worker processing a - smaller row slice (lower per-worker memory pressure) - Fixed [`as.sir()`](https://amr-for-r.org/reference/as.sir.md) ignoring `info = FALSE` for columns with no breakpoints (e.g. cefoxitin against - *E. coli*): an operator-precedence bug (`&&`/`||`) caused the - “Interpreting MIC values” intro message to fire unconditionally when - `nrow(breakpoints) == 0`, regardless of `info`; the progress bar title - was also not gated by `info` + *E. coli*) #### Updates @@ -184,9 +189,6 @@ - [`ab_group()`](https://amr-for-r.org/reference/ab_property.md) now returns values consist with the AMR selectors ([\#246](https://github.com/msberends/AMR/issues/246)) -- Added two new `NA` objects, `NA_ab_` and `NA_mo_`, analogous to base - R’s `NA_character_` and `NA_integer_`, for use in pipelines that - require typed missing values ## AMR 3.0.1 diff --git a/pkgdown.yml b/pkgdown.yml index 54d942efe..d1c86685e 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -1,4 +1,4 @@ -pandoc: 3.1.11 +pandoc: 3.8.3 pkgdown: 2.2.0 pkgdown_sha: ~ articles: @@ -10,7 +10,7 @@ articles: PCA: PCA.html WHONET: WHONET.html WISCA: WISCA.html -last_built: 2026-04-25T14:24Z +last_built: 2026-04-30T08:02Z urls: reference: https://amr-for-r.org/reference article: https://amr-for-r.org/articles diff --git a/reference/AMR-deprecated.html b/reference/AMR-deprecated.html index 91a4e50a2..4bd08c140 100644 --- a/reference/AMR-deprecated.html +++ b/reference/AMR-deprecated.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/AMR-options.html b/reference/AMR-options.html index d1412ba3c..216da2700 100644 --- a/reference/AMR-options.html +++ b/reference/AMR-options.html @@ -9,7 +9,7 @@ options(AMR_guideline = "CLSI")'>AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/AMR.html b/reference/AMR.html index 37c766f6b..9e85b94cb 100644 --- a/reference/AMR.html +++ b/reference/AMR.html @@ -21,7 +21,7 @@ The AMR package is available in English, Arabic, Bengali, Chinese, Czech, Danish AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/AMR.md b/reference/AMR.md index f4d3d1922..b09770627 100644 --- a/reference/AMR.md +++ b/reference/AMR.md @@ -57,6 +57,7 @@ Data." *Journal of Statistical Software*, *104*(3), 1-31. A BibTeX entry for LaTeX users is: + @Article{, title = {{AMR}: An {R} Package for Working with Antimicrobial Resistance Data}, author = {Matthijs S. Berends and Christian F. Luz and Alexander W. Friedrich and Bhanu N. M. Sinha and Casper J. Albers and Corinna Glasner}, diff --git a/reference/WHOCC.html b/reference/WHOCC.html index 241063696..886a77b1f 100644 --- a/reference/WHOCC.html +++ b/reference/WHOCC.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/WHONET.html b/reference/WHONET.html index 4e62b17d3..daf062c76 100644 --- a/reference/WHONET.html +++ b/reference/WHONET.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/ab_from_text.html b/reference/ab_from_text.html index 6b3499ef7..3d50b5a2c 100644 --- a/reference/ab_from_text.html +++ b/reference/ab_from_text.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/ab_property.html b/reference/ab_property.html index ad3d3bc65..b2be699f2 100644 --- a/reference/ab_property.html +++ b/reference/ab_property.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/add_custom_antimicrobials.html b/reference/add_custom_antimicrobials.html index f7d652ade..792a55036 100644 --- a/reference/add_custom_antimicrobials.html +++ b/reference/add_custom_antimicrobials.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/add_custom_microorganisms.html b/reference/add_custom_microorganisms.html index c33de5249..563256978 100644 --- a/reference/add_custom_microorganisms.html +++ b/reference/add_custom_microorganisms.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 diff --git a/reference/age.html b/reference/age.html index 9afeee631..39ea31f3e 100644 --- a/reference/age.html +++ b/reference/age.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -112,16 +112,16 @@ df #> birth_date age age_exact age_at_y2k -#> 1 1999-06-30 26 26.81918 0 -#> 2 1968-01-29 58 58.23562 31 -#> 3 1965-12-05 60 60.38630 34 -#> 4 1980-03-01 46 46.15068 19 -#> 5 1949-11-01 76 76.47945 50 -#> 6 1947-02-14 79 79.19178 52 -#> 7 1940-02-19 86 86.17808 59 -#> 8 1988-01-10 38 38.28767 11 -#> 9 1997-08-27 28 28.66027 2 -#> 10 1978-01-26 48 48.24384 21 +#> 1 1999-06-30 26 26.83288 0 +#> 2 1968-01-29 58 58.24932 31 +#> 3 1965-12-05 60 60.40000 34 +#> 4 1980-03-01 46 46.16438 19 +#> 5 1949-11-01 76 76.49315 50 +#> 6 1947-02-14 79 79.20548 52 +#> 7 1940-02-19 86 86.19178 59 +#> 8 1988-01-10 38 38.30137 11 +#> 9 1997-08-27 28 28.67397 2 +#> 10 1978-01-26 48 48.25753 21
From the shell:
# CRAN check from parent directory R CMD check AMR
Naming conventions in R/:
R/
aa_*.R
zz_deprecated.R
zzz.R
.onLoad
.onAttach
Key source files:
The package defines five S3 classes with full print/format/plot/vctrs support:
<mo>
as.mo()
<ab>
as.ab()
<av>
as.av()
<sir>
as.sir()
<mic>
as.mic()
<disk>
as.disk()
Pre-compiled in data/ (do not edit directly; regenerate via data-raw/ scripts):
data/
data-raw/
microorganisms.rda
antimicrobials.rda
antivirals.rda
clinical_breakpoints.rda
intrinsic_resistant.rda
example_isolates.rda
WHONET.rda
We can write this as:
Coverage=∑i(Incidencei×Susceptibilityi)\text{Coverage} = \sum_i (\text{Incidence}_i \times \text{Susceptibility}_i)
For example, suppose:
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 @@ -180,16 +180,16 @@ distributions.
Then the posterior incidence is:
p∼Dirichlet(α1+n1,…,αK+nK)p \sim \text{Dirichlet}(\alpha_1 + n_1, \ldots, \alpha_K + n_K)
To simulate from this, we use:
xi∼Gamma(αi+ni,1),pi=xi∑j=1Kxjx_i \sim \text{Gamma}(\alpha_i + n_i,\ 1), \quad p_i = \frac{x_i}{\sum_{j=1}^{K} x_j}
Each pathogen–regimen pair has a prior and data:
Then the posterior is:
θ∼Beta(α0+S,β0+N−S)\theta \sim \text{Beta}(\alpha_0 + S,\ \beta_0 + N - S)
vignettes/datasets.Rmd
datasets.Rmd
With only having defined a row filter on Gram-negative bacteria with intrinsic resistance to cefotaxime (mo_is_gram_negative() and mo_is_intrinsic_resistant()) and a column selection on two antibiotic groups (aminoglycosides() and carbapenems()), the reference data about all microorganisms and all antimicrobials in the AMR package make sure you get what you meant.
mo_is_gram_negative()
mo_is_intrinsic_resistant()
aminoglycosides()
carbapenems()
AMR
antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems())) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem)
Or use antimicrobial selectors to select a series of antibiotic columns:
library(AMR) @@ -425,15 +430,16 @@ # calculate AMR using resistance(), over all aminoglycosides and polymyxins: summarise(across(c(aminoglycosides(), polymyxins()), resistance)) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) #> ℹ For `polymyxins()` using column COL (colistin) #> Warning: There was 1 warning in `summarise()`. -#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), resistance)`. +#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), +#> resistance)`. #> ℹ In group 3: `ward = "Outpatient"`. #> Caused by warning: -#> ! Introducing NA: only 23 results available for KAN in group: ward = "Outpatient" -#> (whilst `minimum = 30`). +#> ! Introducing NA: only 23 results available for KAN in group: +#> ward = "Outpatient" (whilst `minimum = 30`). out #> # A tibble: 3 × 6 #> ward GEN TOB AMK KAN COL @@ -445,11 +451,12 @@ # transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889
# transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889
# transform the antibiotic column to ATC codes: out %>% set_ab_names(property = "atc") diff --git a/index.md b/index.md index e57b8a9bc..bd0c1276f 100644 --- a/index.md +++ b/index.md @@ -100,6 +100,7 @@ selectors](https://amr-for-r.org/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 library(AMR) library(dplyr, warn.conflicts = FALSE) @@ -116,24 +117,26 @@ example_isolates %>% #> ℹ Using column mo as input for `mo_fullname()` #> ℹ Using column mo as input for `mo_is_gram_negative()` #> ℹ Using column mo as input for `mo_is_intrinsic_resistant()` -#> ℹ Determining intrinsic resistance based on 'EUCAST Expected Resistant -#> Phenotypes' v1.2 (2023). This note will be shown once per session. -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ Determining intrinsic resistance based on 'EUCAST Expected +#> Resistant Phenotypes' v1.2 (2023). This note will be shown +#> once per session. +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) #> # A tibble: 35 × 7 -#> bacteria GEN TOB AMK KAN IPM MEM -#> -#> 1 Pseudomonas aeruginosa I S NA R S NA -#> 2 Pseudomonas aeruginosa I S NA R S NA -#> 3 Pseudomonas aeruginosa I S NA R S NA -#> 4 Pseudomonas aeruginosa S S S R NA S -#> 5 Pseudomonas aeruginosa S S S R S S -#> 6 Pseudomonas aeruginosa S S S R S S -#> 7 Stenotrophomonas maltophilia R R R R R R -#> 8 Pseudomonas aeruginosa S S S R NA S -#> 9 Pseudomonas aeruginosa S S S R NA S -#> 10 Pseudomonas aeruginosa S S S R S S +#> bacteria GEN TOB AMK KAN IPM MEM +#> +#> 1 Pseudomonas aer… I S NA R S NA +#> 2 Pseudomonas aer… I S NA R S NA +#> 3 Pseudomonas aer… I S NA R S NA +#> 4 Pseudomonas aer… S S S R NA S +#> 5 Pseudomonas aer… S S S R S S +#> 6 Pseudomonas aer… S S S R S S +#> 7 Stenotrophomona… R R R R R R +#> 8 Pseudomonas aer… S S S R NA S +#> 9 Pseudomonas aer… S S S R NA S +#> 10 Pseudomonas aer… S S S R S S #> # ℹ 25 more rows ``` @@ -161,39 +164,42 @@ If used inside [R Markdown](https://rmarkdown.rstudio.com) or output format automatically (such as markdown, LaTeX, HTML, etc.). ``` r + antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems())) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) ``` -| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | -|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------| -| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | -| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | -| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | -| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | -| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | -| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | -| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | -| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | -| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | -| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | +| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | +|:---|:---|:---|:---|:---|:---|:---| +| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | +| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | +| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | +| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | +| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | +| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | +| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | +| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | +| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | +| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | In combination antibiograms, it is clear that combined antimicrobials yield higher empiric coverage: ``` r + antibiogram(example_isolates, antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"), mo_transform = "gramstain") ``` -| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | -|:--------------|:------------------------|:-------------------------------------|:-------------------------------------| -| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | -| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | +| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | +|:---|:---|:---|:---| +| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | +| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | Like many other functions in this package, [`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md) comes @@ -201,6 +207,7 @@ with support for 28 languages that are often detected automatically based on system language: ``` r + antibiogram(example_isolates, antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work mo_transform = "gramstain", @@ -221,6 +228,7 @@ with new scale functions, to allow plotting of log2-distributed MIC values and SIR values. ``` r + library(ggplot2) library(AMR) @@ -258,6 +266,7 @@ For a manual approach, you can use the `resistance` or function: ``` r + example_isolates %>% # group by ward: group_by(ward) %>% @@ -266,16 +275,18 @@ example_isolates %>% summarise(across(c(GEN, TOB), list(total_R = resistance, conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) -#> ℹ `resistance()` assumes the EUCAST guideline and thus considers the 'I' -#> category susceptible. Set the `guideline` argument or the `AMR_guideline` -#> option to either "CLSI" or "EUCAST", see `?AMR-options`. +#> ℹ `resistance()` assumes the EUCAST guideline and thus +#> considers the 'I' category susceptible. Set the `guideline` +#> argument or the `AMR_guideline` option to either "CLSI" or +#> "EUCAST", see `?AMR-options`. #> ℹ This message will be shown once per session. #> # A tibble: 3 × 5 -#> ward GEN_total_R GEN_conf_int TOB_total_R TOB_conf_int -#> -#> 1 Clinical 0.229 0.205-0.254 0.315 0.284-0.347 -#> 2 ICU 0.290 0.253-0.33 0.400 0.353-0.449 -#> 3 Outpatient 0.2 0.131-0.285 0.368 0.254-0.493 +#> ward GEN_total_R GEN_conf_int TOB_total_R +#> +#> 1 Clinical 0.229 0.205-0.254 0.315 +#> 2 ICU 0.290 0.253-0.33 0.400 +#> 3 Outpatient 0.2 0.131-0.285 0.368 +#> # ℹ 1 more variable: TOB_conf_int ``` Or use [antimicrobial @@ -283,6 +294,7 @@ selectors](https://amr-for-r.org/reference/antimicrobial_selectors.html) to select a series of antibiotic columns: ``` r + library(AMR) library(dplyr) @@ -292,15 +304,16 @@ out <- example_isolates %>% # calculate AMR using resistance(), over all aminoglycosides and polymyxins: summarise(across(c(aminoglycosides(), polymyxins()), resistance)) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) #> ℹ For `polymyxins()` using column COL (colistin) #> Warning: There was 1 warning in `summarise()`. -#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), resistance)`. +#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), +#> resistance)`. #> ℹ In group 3: `ward = "Outpatient"`. #> Caused by warning: -#> ! Introducing NA: only 23 results available for KAN in group: ward = "Outpatient" -#> (whilst `minimum = 30`). +#> ! Introducing NA: only 23 results available for KAN in group: +#> ward = "Outpatient" (whilst `minimum = 30`). out #> # A tibble: 3 × 6 #> ward GEN TOB AMK KAN COL @@ -311,17 +324,20 @@ out ``` ``` r + # transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889 +#> ward gentamicin tobramycin amikacin kanamycin +#> +#> 1 Clinical 0.229 0.315 0.626 1 +#> 2 ICU 0.290 0.400 0.662 1 +#> 3 Outpatient 0.2 0.368 0.605 NA +#> # ℹ 1 more variable: colistin ``` ``` r + # transform the antibiotic column to ATC codes: out %>% set_ab_names(property = "atc") #> # A tibble: 3 × 6 @@ -393,6 +409,7 @@ This package is available [here on the official R network R from CRAN by using the command: ``` r + install.packages("AMR") ``` @@ -417,6 +434,7 @@ here](https://github.com/msberends/AMR/wiki/Developer-Guideline). To install the latest and unpublished beta version: ``` r + install.packages("AMR", repos = "beta.amr-for-r.org") # if this does not work, try to install directly from GitHub using the 'remotes' package: diff --git a/llms.txt b/llms.txt index 2c7a590b7..2d147432c 100644 --- a/llms.txt +++ b/llms.txt @@ -100,6 +100,7 @@ selectors](https://amr-for-r.org/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 library(AMR) library(dplyr, warn.conflicts = FALSE) @@ -116,24 +117,26 @@ example_isolates %>% #> ℹ Using column mo as input for `mo_fullname()` #> ℹ Using column mo as input for `mo_is_gram_negative()` #> ℹ Using column mo as input for `mo_is_intrinsic_resistant()` -#> ℹ Determining intrinsic resistance based on 'EUCAST Expected Resistant -#> Phenotypes' v1.2 (2023). This note will be shown once per session. -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ Determining intrinsic resistance based on 'EUCAST Expected +#> Resistant Phenotypes' v1.2 (2023). This note will be shown +#> once per session. +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) #> # A tibble: 35 × 7 -#> bacteria GEN TOB AMK KAN IPM MEM -#> -#> 1 Pseudomonas aeruginosa I S NA R S NA -#> 2 Pseudomonas aeruginosa I S NA R S NA -#> 3 Pseudomonas aeruginosa I S NA R S NA -#> 4 Pseudomonas aeruginosa S S S R NA S -#> 5 Pseudomonas aeruginosa S S S R S S -#> 6 Pseudomonas aeruginosa S S S R S S -#> 7 Stenotrophomonas maltophilia R R R R R R -#> 8 Pseudomonas aeruginosa S S S R NA S -#> 9 Pseudomonas aeruginosa S S S R NA S -#> 10 Pseudomonas aeruginosa S S S R S S +#> bacteria GEN TOB AMK KAN IPM MEM +#> +#> 1 Pseudomonas aer… I S NA R S NA +#> 2 Pseudomonas aer… I S NA R S NA +#> 3 Pseudomonas aer… I S NA R S NA +#> 4 Pseudomonas aer… S S S R NA S +#> 5 Pseudomonas aer… S S S R S S +#> 6 Pseudomonas aer… S S S R S S +#> 7 Stenotrophomona… R R R R R R +#> 8 Pseudomonas aer… S S S R NA S +#> 9 Pseudomonas aer… S S S R NA S +#> 10 Pseudomonas aer… S S S R S S #> # ℹ 25 more rows ``` @@ -161,39 +164,42 @@ If used inside [R Markdown](https://rmarkdown.rstudio.com) or output format automatically (such as markdown, LaTeX, HTML, etc.). ``` r + antibiogram(example_isolates, antimicrobials = c(aminoglycosides(), carbapenems())) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) -#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM (meropenem) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) +#> ℹ For `carbapenems()` using columns IPM (imipenem) and MEM +#> (meropenem) ``` -| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | -|:-----------------|:---------------------|:--------------------|:---------------------|:----------------|:---------------------|:--------------------| -| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | -| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | -| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | -| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | -| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | -| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | -| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | -| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | -| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | -| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | +| Pathogen | Amikacin | Gentamicin | Imipenem | Kanamycin | Meropenem | Tobramycin | +|:---|:---|:---|:---|:---|:---|:---| +| CoNS | 0% (0-8%,N=43) | 86% (82-90%,N=309) | 52% (37-67%,N=48) | 0% (0-8%,N=43) | 52% (37-67%,N=48) | 22% (12-35%,N=55) | +| *E. coli* | 100% (98-100%,N=171) | 98% (96-99%,N=460) | 100% (99-100%,N=422) | NA | 100% (99-100%,N=418) | 97% (96-99%,N=462) | +| *E. faecalis* | 0% (0-9%,N=39) | 0% (0-9%,N=39) | 100% (91-100%,N=38) | 0% (0-9%,N=39) | NA | 0% (0-9%,N=39) | +| *K. pneumoniae* | NA | 90% (79-96%,N=58) | 100% (93-100%,N=51) | NA | 100% (93-100%,N=53) | 90% (79-96%,N=58) | +| *P. aeruginosa* | NA | 100% (88-100%,N=30) | NA | 0% (0-12%,N=30) | NA | 100% (88-100%,N=30) | +| *P. mirabilis* | NA | 94% (80-99%,N=34) | 94% (79-99%,N=32) | NA | NA | 94% (80-99%,N=34) | +| *S. aureus* | NA | 99% (97-100%,N=233) | NA | NA | NA | 98% (92-100%,N=86) | +| *S. epidermidis* | 0% (0-8%,N=44) | 79% (71-85%,N=163) | NA | 0% (0-8%,N=44) | NA | 51% (40-61%,N=89) | +| *S. hominis* | NA | 92% (84-97%,N=80) | NA | NA | NA | 85% (74-93%,N=62) | +| *S. pneumoniae* | 0% (0-3%,N=117) | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | NA | 0% (0-3%,N=117) | In combination antibiograms, it is clear that combined antimicrobials yield higher empiric coverage: ``` r + antibiogram(example_isolates, antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"), mo_transform = "gramstain") ``` -| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | -|:--------------|:------------------------|:-------------------------------------|:-------------------------------------| -| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | -| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | +| Pathogen | Piperacillin/tazobactam | Piperacillin/tazobactam + Gentamicin | Piperacillin/tazobactam + Tobramycin | +|:---|:---|:---|:---| +| Gram-negative | 88% (85-91%,N=641) | 99% (97-99%,N=691) | 98% (97-99%,N=693) | +| Gram-positive | 86% (82-89%,N=345) | 98% (96-98%,N=1044) | 95% (93-97%,N=550) | Like many other functions in this package, [`antibiogram()`](https://amr-for-r.org/reference/antibiogram.md) comes @@ -201,6 +207,7 @@ with support for 28 languages that are often detected automatically based on system language: ``` r + antibiogram(example_isolates, antimicrobials = c("cipro", "tobra", "genta"), # any arbitrary name or code will work mo_transform = "gramstain", @@ -221,6 +228,7 @@ with new scale functions, to allow plotting of log2-distributed MIC values and SIR values. ``` r + library(ggplot2) library(AMR) @@ -258,6 +266,7 @@ For a manual approach, you can use the `resistance` or function: ``` r + example_isolates %>% # group by ward: group_by(ward) %>% @@ -266,16 +275,18 @@ example_isolates %>% summarise(across(c(GEN, TOB), list(total_R = resistance, conf_int = function(x) sir_confidence_interval(x, collapse = "-")))) -#> ℹ `resistance()` assumes the EUCAST guideline and thus considers the 'I' -#> category susceptible. Set the `guideline` argument or the `AMR_guideline` -#> option to either "CLSI" or "EUCAST", see `?AMR-options`. +#> ℹ `resistance()` assumes the EUCAST guideline and thus +#> considers the 'I' category susceptible. Set the `guideline` +#> argument or the `AMR_guideline` option to either "CLSI" or +#> "EUCAST", see `?AMR-options`. #> ℹ This message will be shown once per session. #> # A tibble: 3 × 5 -#> ward GEN_total_R GEN_conf_int TOB_total_R TOB_conf_int -#> -#> 1 Clinical 0.229 0.205-0.254 0.315 0.284-0.347 -#> 2 ICU 0.290 0.253-0.33 0.400 0.353-0.449 -#> 3 Outpatient 0.2 0.131-0.285 0.368 0.254-0.493 +#> ward GEN_total_R GEN_conf_int TOB_total_R +#> +#> 1 Clinical 0.229 0.205-0.254 0.315 +#> 2 ICU 0.290 0.253-0.33 0.400 +#> 3 Outpatient 0.2 0.131-0.285 0.368 +#> # ℹ 1 more variable: TOB_conf_int ``` Or use [antimicrobial @@ -283,6 +294,7 @@ selectors](https://amr-for-r.org/reference/antimicrobial_selectors.html) to select a series of antibiotic columns: ``` r + library(AMR) library(dplyr) @@ -292,15 +304,16 @@ out <- example_isolates %>% # calculate AMR using resistance(), over all aminoglycosides and polymyxins: summarise(across(c(aminoglycosides(), polymyxins()), resistance)) -#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB (tobramycin), AMK -#> (amikacin), and KAN (kanamycin) +#> ℹ For `aminoglycosides()` using columns GEN (gentamicin), TOB +#> (tobramycin), AMK (amikacin), and KAN (kanamycin) #> ℹ For `polymyxins()` using column COL (colistin) #> Warning: There was 1 warning in `summarise()`. -#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), resistance)`. +#> ℹ In argument: `across(c(aminoglycosides(), polymyxins()), +#> resistance)`. #> ℹ In group 3: `ward = "Outpatient"`. #> Caused by warning: -#> ! Introducing NA: only 23 results available for KAN in group: ward = "Outpatient" -#> (whilst `minimum = 30`). +#> ! Introducing NA: only 23 results available for KAN in group: +#> ward = "Outpatient" (whilst `minimum = 30`). out #> # A tibble: 3 × 6 #> ward GEN TOB AMK KAN COL @@ -311,17 +324,20 @@ out ``` ``` r + # transform the antibiotic columns to names: out %>% set_ab_names() #> # A tibble: 3 × 6 -#> ward gentamicin tobramycin amikacin kanamycin colistin -#> -#> 1 Clinical 0.229 0.315 0.626 1 0.780 -#> 2 ICU 0.290 0.400 0.662 1 0.857 -#> 3 Outpatient 0.2 0.368 0.605 NA 0.889 +#> ward gentamicin tobramycin amikacin kanamycin +#> +#> 1 Clinical 0.229 0.315 0.626 1 +#> 2 ICU 0.290 0.400 0.662 1 +#> 3 Outpatient 0.2 0.368 0.605 NA +#> # ℹ 1 more variable: colistin ``` ``` r + # transform the antibiotic column to ATC codes: out %>% set_ab_names(property = "atc") #> # A tibble: 3 × 6 @@ -393,6 +409,7 @@ This package is available [here on the official R network R from CRAN by using the command: ``` r + install.packages("AMR") ``` @@ -417,6 +434,7 @@ here](https://github.com/msberends/AMR/wiki/Developer-Guideline). To install the latest and unpublished beta version: ``` r + install.packages("AMR", repos = "beta.amr-for-r.org") # if this does not work, try to install directly from GitHub using the 'remotes' package: diff --git a/news/index.html b/news/index.html index 91be66e82..3c3006bb3 100644 --- a/news/index.html +++ b/news/index.html @@ -7,7 +7,7 @@ AMR (for R) - 3.0.1.9052 + 3.0.1.9053 @@ -49,11 +49,17 @@
This will become release v3.1.0, intended for launch end of May.
clinical_breakpoints
recipes
future
parallel = TRUE
future::plan()
future::plan(future::multisession)
step_mic_log2()
step_sir_numeric()
tidyselect
NA
NA_ab_
NA_mo_
NA_character_
NA_integer_
"1"
"1e-3"
e
ETH
MTH
PHE
PHN
STH
THA
THI1
antibiogram()
patient
ward
info = FALSE
&&
||
nrow(breakpoints) == 0
info
reference_data
> breakpoint_R
< breakpoint_R
host = NA
cli
ab_group()