Generate Traditional, Combination, Syndromic, or WISCA Antibiograms
Source:R/antibiogram.R
antibiogram.Rd
Create detailed antibiograms with options for traditional, combination, syndromic, and Bayesian WISCA methods. Based on the approaches of Klinker et al., Barbieri et al., and the Bayesian WISCA model (Weighted-Incidence Syndromic Combination Antibiogram) by Bielicki et al., this function provides flexible output formats including plots and tables, ideal for integration with R Markdown and Quarto reports.
Usage
antibiogram(
x,
antibiotics = where(is.sir),
mo_transform = "shortname",
ab_transform = "name",
syndromic_group = NULL,
add_total_n = FALSE,
only_all_tested = FALSE,
digits = 0,
formatting_type = getOption("AMR_antibiogram_formatting_type", 10),
col_mo = NULL,
language = get_AMR_locale(),
minimum = 30,
combine_SI = TRUE,
sep = " + ",
info = interactive()
)
# S3 method for class 'antibiogram'
plot(x, ...)
# S3 method for class 'antibiogram'
autoplot(object, ...)
# S3 method for class 'antibiogram'
knit_print(
x,
italicise = TRUE,
na = getOption("knitr.kable.NA", default = ""),
...
)
Source
Bielicki JA et al. (2016). Selecting appropriate empirical antibiotic regimens for paediatric bloodstream infections: application of a Bayesian decision model to local and pooled antimicrobial resistance surveillance data Journal of Antimicrobial Chemotherapy 71(3); doi:10.1093/jac/dkv397
Klinker KP et al. (2021). Antimicrobial stewardship and antibiograms: importance of moving beyond traditional antibiograms. Therapeutic Advances in Infectious Disease, May 5;8:20499361211011373; doi:10.1177/20499361211011373
Barbieri E et al. (2021). Development of a Weighted-Incidence Syndromic Combination Antibiogram (WISCA) to guide the choice of the empiric antibiotic treatment for urinary tract infection in paediatric patients: a Bayesian approach Antimicrobial Resistance & Infection Control May 1;10(1):74; doi:10.1186/s13756-021-00939-2
M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 5th Edition, 2022, Clinical and Laboratory Standards Institute (CLSI). https://clsi.org/standards/products/microbiology/documents/m39/.
Arguments
- x
a data.frame containing at least a column with microorganisms and columns with antibiotic results (class 'sir', see
as.sir()
)- antibiotics
vector of any antibiotic name or code (will be evaluated with
as.ab()
, column name ofx
, or (any combinations of) antibiotic selectors such asaminoglycosides()
orcarbapenems()
. For combination antibiograms, this can also be set to values separated with"+"
, such as "TZP+TOB" or "cipro + genta", given that columns resembling such antibiotics exist inx
. See Examples.- mo_transform
a character to transform microorganism input - must be
"name"
,"shortname"
(default),"gramstain"
, or one of the column names of the microorganisms data set: "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", or "snomed". Can also beNULL
to not transform the input.- ab_transform
a character to transform antibiotic input - must be one of the column names of the antibiotics data set (defaults to
"name"
): "ab", "cid", "name", "group", "atc", "atc_group1", "atc_group2", "abbreviations", "synonyms", "oral_ddd", "oral_units", "iv_ddd", "iv_units", or "loinc". Can also beNULL
to not transform the input.- syndromic_group
a column name of
x
, or values calculated to split rows ofx
, e.g. by usingifelse()
orcase_when()
. See Examples.- add_total_n
a logical to indicate whether total available numbers per pathogen should be added to the table (default is
TRUE
). This will add the lowest and highest number of available isolate per antibiotic (e.g, if for E. coli 200 isolates are available for ciprofloxacin and 150 for amoxicillin, the returned number will be "150-200").- only_all_tested
(for combination antibiograms): a logical to indicate that isolates must be tested for all antibiotics, see Details
- digits
number of digits to use for rounding the susceptibility percentage
- formatting_type
numeric value (1–12) indicating how the 'cells' of the antibiogram table should be formatted. See Details > Formatting Type for a list of options.
- col_mo
column name of the names or codes of the microorganisms (see
as.mo()
) - the default is the first column of classmo
. Values will be coerced usingas.mo()
.- language
language to translate text, which defaults to the system language (see
get_AMR_locale()
)- minimum
the minimum allowed number of available (tested) isolates. Any isolate count lower than
minimum
will returnNA
with a warning. The default number of30
isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.- combine_SI
a logical to indicate whether all susceptibility should be determined by results of either S, SDD, or I, instead of only S (default is
TRUE
)- sep
a separating character for antibiotic columns in combination antibiograms
- info
a logical to indicate info should be printed - the default is
TRUE
only in interactive mode- ...
when used in R Markdown or Quarto: arguments passed on to
knitr::kable()
(otherwise, has no use)- object
an
antibiogram()
object- italicise
a logical to indicate whether the microorganism names in the knitr table should be made italic, using
italicise_taxonomy()
.- na
character to use for showing
NA
values
Details
This function returns a table with values between 0 and 100 for susceptibility, not resistance.
Remember that you should filter your data to let it contain only first isolates! This is needed to exclude duplicates and to reduce selection bias. Use first_isolate()
to determine them in your data set with one of the four available algorithms.
Formatting Type
The formatting of the 'cells' of the table can be set with the argument formatting_type
. In these examples, 5
is the susceptibility percentage, 15
the numerator, and 300
the denominator:
5
15
300
15/300
5 (300)
5% (300)
5 (N=300)
5% (N=300)
5 (15/300)
5% (15/300)
5 (N=15/300)
5% (N=15/300)
The default is 10
, which can be set globally with the package option AMR_antibiogram_formatting_type
, e.g. options(AMR_antibiogram_formatting_type = 5)
.
Set digits
(defaults to 0
) to alter the rounding of the susceptibility percentage.
Antibiogram Types
There are four antibiogram types, as summarised by Klinker et al. (2021, doi:10.1177/20499361211011373
), and they are all supported by antibiogram()
. Use WISCA whenever possible, since it provides precise coverage estimates by accounting for pathogen incidence and antimicrobial susceptibility. See the section Why Use WISCA? on this page.
The four antibiogram types:
Traditional Antibiogram
Case example: Susceptibility of Pseudomonas aeruginosa to piperacillin/tazobactam (TZP)
Code example:
antibiogram(your_data, antibiotics = "TZP")
Combination Antibiogram
Case example: Additional susceptibility of Pseudomonas aeruginosa to TZP + tobramycin versus TZP alone
Code example:
antibiogram(your_data, antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"))
Syndromic Antibiogram
Case example: Susceptibility of Pseudomonas aeruginosa to TZP among respiratory specimens (obtained among ICU patients only)
Code example:
antibiogram(your_data, antibiotics = penicillins(), syndromic_group = "ward")
Weighted-Incidence Syndromic Combination Antibiogram (WISCA)
WISCA enhances empirical antibiotic selection by weighting the incidence of pathogens in specific clinical syndromes and combining them with their susceptibility data. It provides an estimation of regimen coverage by aggregating pathogen incidences and susceptibilities across potential causative organisms. See also the section Why Use WISCA? on this page.
Case example: Susceptibility of Pseudomonas aeruginosa to TZP among respiratory specimens (obtained among ICU patients only) for male patients age >=65 years with heart failure
Code example:
library(dplyr) your_data %>% filter(ward == "ICU" & specimen_type == "Respiratory") %>% antibiogram(antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"), syndromic_group = ifelse(.$age >= 65 & .$gender == "Male" & .$condition == "Heart Disease", "Study Group", "Control Group"))
WISCA uses a sophisticated Bayesian decision model to combine both local and pooled antimicrobial resistance data. This approach not only evaluates local patterns but can also draw on multi-centre datasets to improve regimen accuracy, even in low-incidence infections like paediatric bloodstream infections (BSIs).
Inclusion in Combination Antibiogram and Syndromic Antibiogram
Note that for types 2 and 3 (Combination Antibiogram and Syndromic Antibiogram), it is important to realise that susceptibility can be calculated in two ways, which can be set with the only_all_tested
argument (default is FALSE
). See this example for two antibiotics, Drug A and Drug B, about how antibiogram()
works to calculate the %SI:
--------------------------------------------------------------------
only_all_tested = FALSE only_all_tested = TRUE
----------------------- -----------------------
Drug A Drug B include as include as include as include as
numerator denominator numerator denominator
-------- -------- ---------- ----------- ---------- -----------
S or I S or I X X X X
R S or I X X X X
<NA> S or I X X - -
S or I R X X X X
R R - X - X
<NA> R - - - -
S or I <NA> X X - -
R <NA> - - - -
<NA> <NA> - - - -
--------------------------------------------------------------------
Plotting
All types of antibiograms as listed above can be plotted (using ggplot2::autoplot()
or base R's plot()
and barplot()
).
THe outcome of antibiogram()
can also be used directly in R Markdown / Quarto (i.e., knitr
) for reports. In this case, knitr::kable()
will be applied automatically and microorganism names will even be printed in italics at default (see argument italicise
).
You can also use functions from specific 'table reporting' packages to transform the output of antibiogram()
to your needs, e.g. with flextable::as_flextable()
or gt::gt()
.
Why Use WISCA?
WISCA is a powerful tool for guiding empirical antibiotic therapy because it provides precise coverage estimates by accounting for pathogen incidence and antimicrobial susceptibility. This is particularly important in empirical treatment, where the causative pathogen is often unknown at the outset. Traditional antibiograms do not reflect the weighted likelihood of specific pathogens based on clinical syndromes, which can lead to suboptimal treatment choices.
The Bayesian WISCA, as described by Bielicki et al. (2016), improves on earlier methods by handling uncertainties common in smaller datasets, such as low-incidence infections. This method offers a significant advantage by:
Pooling Data from Multiple Sources:
WISCA uses pooled data from multiple hospitals or surveillance sources to overcome limitations of small sample sizes at individual institutions, allowing for more confident selection of narrow-spectrum antibiotics or combinations.Bayesian Framework:
The Bayesian decision tree model accounts for both local data and prior knowledge (such as inherent resistance patterns) to estimate regimen coverage. It allows for a more precise estimation of coverage, even in cases where susceptibility data is missing or incomplete.Incorporating Pathogen and Regimen Uncertainty:
WISCA allows clinicians to see the likelihood that an empirical regimen will be effective against all relevant pathogens, taking into account uncertainties related to both pathogen prevalence and antimicrobial resistance. This leads to better-informed, data-driven clinical decisions.Scenarios for Optimising Treatment:
For hospitals or settings with low-incidence infections, WISCA helps determine whether local data is sufficient or if pooling with external data is necessary. It also identifies statistically significant differences or similarities between antibiotic regimens, enabling clinicians to choose optimal therapies with greater confidence.
WISCA is essential in optimising empirical treatment by shifting away from broad-spectrum antibiotics, which are often overused in empirical settings. By offering precise estimates based on syndromic patterns and pooled data, WISCA supports antimicrobial stewardship by guiding more targeted therapy, reducing unnecessary broad-spectrum use, and combating the rise of antimicrobial resistance.
Examples
# example_isolates is a data set available in the AMR package.
# run ?example_isolates for more info.
example_isolates
#> # A tibble: 2,000 × 46
#> date patient age gender ward mo PEN OXA FLC AMX
#> <date> <chr> <dbl> <chr> <chr> <mo> <sir> <sir> <sir> <sir>
#> 1 2002-01-02 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 2 2002-01-03 A77334 65 F Clinical B_ESCHR_COLI R NA NA NA
#> 3 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 4 2002-01-07 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 5 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 6 2002-01-13 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 7 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 8 2002-01-14 462729 78 M Clinical B_STPHY_AURS R NA S R
#> 9 2002-01-16 067927 45 F ICU B_STPHY_EPDR R NA R NA
#> 10 2002-01-17 858515 79 F ICU B_STPHY_EPDR R NA S NA
#> # ℹ 1,990 more rows
#> # ℹ 36 more variables: AMC <sir>, AMP <sir>, TZP <sir>, CZO <sir>, FEP <sir>,
#> # CXM <sir>, FOX <sir>, CTX <sir>, CAZ <sir>, CRO <sir>, GEN <sir>,
#> # TOB <sir>, AMK <sir>, KAN <sir>, TMP <sir>, SXT <sir>, NIT <sir>,
#> # FOS <sir>, LNZ <sir>, CIP <sir>, MFX <sir>, VAN <sir>, TEC <sir>,
#> # TCY <sir>, TGC <sir>, DOX <sir>, ERY <sir>, CLI <sir>, AZM <sir>,
#> # IPM <sir>, MEM <sir>, MTR <sir>, CHL <sir>, COL <sir>, MUP <sir>, …
# \donttest{
# Traditional antibiogram ----------------------------------------------
antibiogram(example_isolates,
antibiotics = c(aminoglycosides(), carbapenems())
)
#> ℹ The function aminoglycosides() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(aminoglycosides())
#> • your_data %>% select(column_a, column_b, aminoglycosides())
#> • your_data %>% filter(any(aminoglycosides() == "R"))
#> • your_data[, aminoglycosides()]
#> • your_data[, c("column_a", "column_b", aminoglycosides())]
#>
#> Now returning a vector of all possible antimicrobials that
#> aminoglycosides() can select.
#> ℹ The function carbapenems() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(carbapenems())
#> • your_data %>% select(column_a, column_b, carbapenems())
#> • your_data %>% filter(any(carbapenems() == "R"))
#> • your_data[, carbapenems()]
#> • your_data[, c("column_a", "column_b", carbapenems())]
#>
#> Now returning a vector of all possible antimicrobials that carbapenems()
#> can select.
#> Warning: The following antibiotics were not available and ignored:
#> amikacin/fosfomycin, apramycin, arbekacin, astromicin, bekanamycin,
#> biapenem, dibekacin, doripenem, ertapenem, framycetin, gentamicin-high,
#> habekacin, hygromycin, imipenem/EDTA, imipenem/relebactam, isepamicin,
#> kanamycin-high, kanamycin/cephalexin, meropenem/nacubactam,
#> meropenem/vaborbactam, micronomicin, neomycin, netilmicin, panipenem,
#> pentisomicin, plazomicin, propikacin, razupenem, ribostamycin, ritipenem,
#> ritipenem acoxil, sisomicin, streptoduocin, streptomycin,
#> streptomycin-high, tebipenem, and tobramycin-high
#> # An Antibiogram: 10 × 7
#> Pathogen Amikacin Gentamicin Imipenem Kanamycin Meropenem Tobramycin
#> * <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 CoNS 0% (0/43) 86% (267/… 52% (25… 0% (0/43) 52% (25/… 22% (12/5…
#> 2 E. coli 100% (171/… 98% (451/… 100% (4… NA 100% (41… 97% (450/…
#> 3 E. faecalis 0% (0/39) 0% (0/39) 100% (3… 0% (0/39) NA 0% (0/39)
#> 4 K. pneumoniae NA 90% (52/5… 100% (5… NA 100% (53… 90% (52/5…
#> 5 P. aeruginosa NA 100% (30/… NA 0% (0/30) NA 100% (30/…
#> 6 P. mirabilis NA 94% (32/3… 94% (30… NA NA 94% (32/3…
#> 7 S. aureus NA 99% (231/… NA NA NA 98% (84/8…
#> 8 S. epidermidis 0% (0/44) 79% (128/… NA 0% (0/44) NA 51% (45/8…
#> 9 S. hominis NA 92% (74/8… NA NA NA 85% (53/6…
#> 10 S. pneumoniae 0% (0/117) 0% (0/117) NA 0% (0/11… NA 0% (0/117)
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
antibiogram(example_isolates,
antibiotics = aminoglycosides(),
ab_transform = "atc",
mo_transform = "gramstain"
)
#> ℹ The function aminoglycosides() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(aminoglycosides())
#> • your_data %>% select(column_a, column_b, aminoglycosides())
#> • your_data %>% filter(any(aminoglycosides() == "R"))
#> • your_data[, aminoglycosides()]
#> • your_data[, c("column_a", "column_b", aminoglycosides())]
#>
#> Now returning a vector of all possible antimicrobials that
#> aminoglycosides() can select.
#> Warning: The following antibiotics were not available and ignored:
#> amikacin/fosfomycin, apramycin, arbekacin, astromicin, bekanamycin,
#> dibekacin, framycetin, gentamicin-high, habekacin, hygromycin, isepamicin,
#> kanamycin-high, kanamycin/cephalexin, micronomicin, neomycin, netilmicin,
#> pentisomicin, plazomicin, propikacin, ribostamycin, sisomicin,
#> streptoduocin, streptomycin, streptomycin-high, and tobramycin-high
#> # An Antibiogram: 2 × 5
#> Pathogen J01GB01 J01GB03 J01GB04 J01GB06
#> * <chr> <chr> <chr> <chr> <chr>
#> 1 Gram-negative 96% (658/686) 96% (659/684) 0% (0/35) 98% (251/256)
#> 2 Gram-positive 34% (228/665) 63% (740/1170) 0% (0/436) 0% (0/436)
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
antibiogram(example_isolates,
antibiotics = carbapenems(),
ab_transform = "name",
mo_transform = "name"
)
#> ℹ The function carbapenems() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(carbapenems())
#> • your_data %>% select(column_a, column_b, carbapenems())
#> • your_data %>% filter(any(carbapenems() == "R"))
#> • your_data[, carbapenems()]
#> • your_data[, c("column_a", "column_b", carbapenems())]
#>
#> Now returning a vector of all possible antimicrobials that carbapenems()
#> can select.
#> Warning: The following antibiotics were not available and ignored: biapenem,
#> doripenem, ertapenem, imipenem/EDTA, imipenem/relebactam,
#> meropenem/nacubactam, meropenem/vaborbactam, panipenem, razupenem,
#> ritipenem, ritipenem acoxil, and tebipenem
#> # An Antibiogram: 5 × 3
#> Pathogen Imipenem Meropenem
#> * <chr> <chr> <chr>
#> 1 Coagulase-negative Staphylococcus (CoNS) 52% (25/48) 52% (25/48)
#> 2 Enterococcus faecalis 100% (38/38) NA
#> 3 Escherichia coli 100% (422/422) 100% (418/418)
#> 4 Klebsiella pneumoniae 100% (51/51) 100% (53/53)
#> 5 Proteus mirabilis 94% (30/32) NA
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
# Combined antibiogram -------------------------------------------------
# combined antibiotics yield higher empiric coverage
antibiogram(example_isolates,
antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"),
mo_transform = "gramstain"
)
#> # An Antibiogram: 2 × 4
#> Pathogen Piperacillin/tazobac…¹ Piperacillin/tazobac…² Piperacillin/tazobac…³
#> * <chr> <chr> <chr> <chr>
#> 1 Gram-neg… 88% (565/641) 99% (681/691) 98% (679/693)
#> 2 Gram-pos… 86% (296/345) 98% (1018/1044) 95% (524/550)
#> # ℹ abbreviated names: ¹`Piperacillin/tazobactam`,
#> # ²`Piperacillin/tazobactam + Gentamicin`,
#> # ³`Piperacillin/tazobactam + Tobramycin`
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
# names of antibiotics do not need to resemble columns exactly:
antibiogram(example_isolates,
antibiotics = c("Cipro", "cipro + genta"),
mo_transform = "gramstain",
ab_transform = "name",
sep = " & "
)
#> # An Antibiogram: 2 × 3
#> Pathogen Ciprofloxacin `Ciprofloxacin & Gentamicin`
#> * <chr> <chr> <chr>
#> 1 Gram-negative 91% (621/684) 99% (684/694)
#> 2 Gram-positive 77% (560/724) 93% (784/847)
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
# Syndromic antibiogram ------------------------------------------------
# the data set could contain a filter for e.g. respiratory specimens
antibiogram(example_isolates,
antibiotics = c(aminoglycosides(), carbapenems()),
syndromic_group = "ward"
)
#> ℹ The function aminoglycosides() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(aminoglycosides())
#> • your_data %>% select(column_a, column_b, aminoglycosides())
#> • your_data %>% filter(any(aminoglycosides() == "R"))
#> • your_data[, aminoglycosides()]
#> • your_data[, c("column_a", "column_b", aminoglycosides())]
#>
#> Now returning a vector of all possible antimicrobials that
#> aminoglycosides() can select.
#> ℹ The function carbapenems() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(carbapenems())
#> • your_data %>% select(column_a, column_b, carbapenems())
#> • your_data %>% filter(any(carbapenems() == "R"))
#> • your_data[, carbapenems()]
#> • your_data[, c("column_a", "column_b", carbapenems())]
#>
#> Now returning a vector of all possible antimicrobials that carbapenems()
#> can select.
#> Warning: The following antibiotics were not available and ignored:
#> amikacin/fosfomycin, apramycin, arbekacin, astromicin, bekanamycin,
#> biapenem, dibekacin, doripenem, ertapenem, framycetin, gentamicin-high,
#> habekacin, hygromycin, imipenem/EDTA, imipenem/relebactam, isepamicin,
#> kanamycin-high, kanamycin/cephalexin, meropenem/nacubactam,
#> meropenem/vaborbactam, micronomicin, neomycin, netilmicin, panipenem,
#> pentisomicin, plazomicin, propikacin, razupenem, ribostamycin, ritipenem,
#> ritipenem acoxil, sisomicin, streptoduocin, streptomycin,
#> streptomycin-high, tebipenem, and tobramycin-high
#> # An Antibiogram: 14 × 8
#> `Syndromic Group` Pathogen Amikacin Gentamicin Imipenem Kanamycin Meropenem
#> * <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Clinical CoNS NA 89% (183/… 57% (20… NA 57% (20/…
#> 2 ICU CoNS NA 79% (58/7… NA NA NA
#> 3 Outpatient CoNS NA 84% (26/3… NA NA NA
#> 4 Clinical E. coli 100% (1… 98% (291/… 100% (2… NA 100% (27…
#> 5 ICU E. coli 100% (5… 99% (135/… 100% (1… NA 100% (11…
#> 6 Clinical K. pneumo… NA 92% (47/5… 100% (4… NA 100% (46…
#> 7 Clinical P. mirabi… NA 100% (30/… NA NA NA
#> 8 Clinical S. aureus NA 99% (148/… NA NA NA
#> 9 ICU S. aureus NA 100% (66/… NA NA NA
#> 10 Clinical S. epider… NA 82% (65/7… NA NA NA
#> 11 ICU S. epider… NA 72% (54/7… NA NA NA
#> 12 Clinical S. hominis NA 96% (43/4… NA NA NA
#> 13 Clinical S. pneumo… 0% (0/7… 0% (0/78) NA 0% (0/78) NA
#> 14 ICU S. pneumo… 0% (0/3… 0% (0/30) NA 0% (0/30) NA
#> # ℹ 1 more variable: Tobramycin <chr>
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
# now define a data set with only E. coli
ex1 <- example_isolates[which(mo_genus() == "Escherichia"), ]
#> ℹ Using column 'mo' as input for mo_genus()
# with a custom language, though this will be determined automatically
# (i.e., this table will be in Spanish on Spanish systems)
antibiogram(ex1,
antibiotics = aminoglycosides(),
ab_transform = "name",
syndromic_group = ifelse(ex1$ward == "ICU",
"UCI", "No UCI"
),
language = "es"
)
#> ℹ The function aminoglycosides() should be used inside a dplyr verb or
#> data.frame call, e.g.:
#> • your_data %>% select(aminoglycosides())
#> • your_data %>% select(column_a, column_b, aminoglycosides())
#> • your_data %>% filter(any(aminoglycosides() == "R"))
#> • your_data[, aminoglycosides()]
#> • your_data[, c("column_a", "column_b", aminoglycosides())]
#>
#> Now returning a vector of all possible antimicrobials that
#> aminoglycosides() can select.
#> Warning: The following antibiotics were not available and ignored:
#> amikacin/fosfomycin, apramycin, arbekacin, astromicin, bekanamycin,
#> dibekacin, framycetin, gentamicin-high, habekacin, hygromycin, isepamicin,
#> kanamycin-high, kanamycin/cephalexin, micronomicin, neomycin, netilmicin,
#> pentisomicin, plazomicin, propikacin, ribostamycin, sisomicin,
#> streptoduocin, streptomycin, streptomycin-high, and tobramycin-high
#> # An Antibiogram: 2 × 5
#> `Grupo sindrómico` Patógeno Amikacina Gentamicina Tobramicina
#> * <chr> <chr> <chr> <chr> <chr>
#> 1 No UCI E. coli 100% (119/119) 98% (316/323) 98% (318/325)
#> 2 UCI E. coli 100% (52/52) 99% (135/137) 96% (132/137)
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
# Weighted-incidence syndromic combination antibiogram (WISCA) ---------
# the data set could contain a filter for e.g. respiratory specimens/ICU
antibiogram(example_isolates,
antibiotics = c("AMC", "AMC+CIP", "TZP", "TZP+TOB"),
mo_transform = "gramstain",
minimum = 10, # this should be >=30, but now just as example
syndromic_group = ifelse(example_isolates$age >= 65 &
example_isolates$gender == "M",
"WISCA Group 1", "WISCA Group 2"
)
)
#> # An Antibiogram: 4 × 6
#> `Syndromic Group` Pathogen Amoxicillin/clavulani…¹ Amoxicillin/clavulan…²
#> * <chr> <chr> <chr> <chr>
#> 1 WISCA Group 1 Gram-negative 76% (216/285) 95% (270/284)
#> 2 WISCA Group 2 Gram-negative 76% (336/441) 98% (432/442)
#> 3 WISCA Group 1 Gram-positive 76% (310/406) 89% (347/392)
#> 4 WISCA Group 2 Gram-positive 76% (556/732) 89% (617/695)
#> # ℹ abbreviated names: ¹`Amoxicillin/clavulanic acid`,
#> # ²`Amoxicillin/clavulanic acid + Ciprofloxacin`
#> # ℹ 2 more variables: `Piperacillin/tazobactam` <chr>,
#> # `Piperacillin/tazobactam + Tobramycin` <chr>
#> # Use `plot()` or `ggplot2::autoplot()` to create a plot of this antibiogram,
#> # or use it directly in R Markdown or https://quarto.org, see ?antibiogram
# Print the output for R Markdown / Quarto -----------------------------
ureido <- antibiogram(example_isolates,
antibiotics = ureidopenicillins(),
ab_transform = "name"
)
#> ℹ The function ureidopenicillins() should be used inside a dplyr verb
#> or data.frame call, e.g.:
#> • your_data %>% select(ureidopenicillins())
#> • your_data %>% select(column_a, column_b, ureidopenicillins())
#> • your_data %>% filter(any(ureidopenicillins() == "R"))
#> • your_data[, ureidopenicillins()]
#> • your_data[, c("column_a", "column_b", ureidopenicillins())]
#>
#> Now returning a vector of all possible antimicrobials that
#> ureidopenicillins() can select.
#> Warning: The following antibiotics were not available and ignored: azlocillin,
#> mezlocillin, and piperacillin
# in an Rmd file, you would just need to return `ureido` in a chunk,
# but to be explicit here:
if (requireNamespace("knitr")) {
cat(knitr::knit_print(ureido))
}
#>
#>
#> |Pathogen |Piperacillin/tazobactam |
#> |:---------------|:-----------------------|
#> |CoNS |30% (10/33) |
#> |*E. coli* |94% (393/416) |
#> |*K. pneumoniae* |89% (47/53) |
#> |*S. pneumoniae* |100% (112/112) |
# Generate plots with ggplot2 or base R --------------------------------
ab1 <- antibiogram(example_isolates,
antibiotics = c("AMC", "CIP", "TZP", "TZP+TOB"),
mo_transform = "gramstain"
)
ab2 <- antibiogram(example_isolates,
antibiotics = c("AMC", "CIP", "TZP", "TZP+TOB"),
mo_transform = "gramstain",
syndromic_group = "ward"
)
if (requireNamespace("ggplot2")) {
ggplot2::autoplot(ab1)
}
if (requireNamespace("ggplot2")) {
ggplot2::autoplot(ab2)
}
plot(ab1)
plot(ab2)
# }