Skip to contents

Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use format() on the result to prettify it to a publishable/printable format, see Examples.

Usage

bug_drug_combinations(x, col_mo = NULL, FUN = mo_shortname, ...)

# S3 method for bug_drug_combinations
format(
  x,
  translate_ab = "name (ab, atc)",
  language = get_AMR_locale(),
  minimum = 30,
  combine_SI = TRUE,
  add_ab_group = TRUE,
  remove_intrinsic_resistant = FALSE,
  decimal.mark = getOption("OutDec"),
  big.mark = ifelse(decimal.mark == ",", ".", ","),
  ...
)

Arguments

x

a data set with antibiotic columns, such as amox, AMX and AMC

col_mo

column name of the IDs of the microorganisms (see as.mo()), defaults to the first column of class mo. Values will be coerced using as.mo().

FUN

the function to call on the mo column to transform the microorganism codes, defaults to mo_shortname()

...

arguments passed on to FUN

translate_ab

a character of length 1 containing column names of the antibiotics data set

language

language of the returned text, defaults to system language (see get_AMR_locale()) and can also be set with the option AMR_locale. Use language = NULL or language = "" to prevent translation.

minimum

the minimum allowed number of available (tested) isolates. Any isolate count lower than minimum will return NA with a warning. The default number of 30 isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.

combine_SI

a logical to indicate whether values S and I should be summed, so resistance will be based on only R, defaults to TRUE

add_ab_group

a logical to indicate where the group of the antimicrobials must be included as a first column

remove_intrinsic_resistant

logical to indicate that rows and columns with 100% resistance for all tested antimicrobials must be removed from the table

decimal.mark

the character to be used to indicate the numeric decimal point.

big.mark

character; if not empty used as mark between every big.interval decimals before (hence big) the decimal point.

Value

The function bug_drug_combinations() returns a data.frame with columns "mo", "ab", "S", "I", "R" and "total".

Details

The function format() calculates the resistance per bug-drug combination. Use combine_SI = TRUE (default) to test R vs. S+I and combine_SI = FALSE to test R+I vs. S.

Examples

# \donttest{
x <- bug_drug_combinations(example_isolates)
head(x)
#> # A tibble: 6 × 6
#>   mo                ab        S     I     R total
#>   <chr>             <chr> <int> <int> <int> <int>
#> 1 (unknown species) PEN      14     0     1    15
#> 2 (unknown species) OXA       0     0     1     1
#> 3 (unknown species) FLC       0     0     0     0
#> 4 (unknown species) AMX      15     0     1    16
#> 5 (unknown species) AMC      15     0     0    15
#> 6 (unknown species) AMP      15     0     1    16
#> Use 'format()' on this result to get a publishable/printable format.
format(x, translate_ab = "name (atc)")
#> # A tibble: 39 × 12
#>    Group     Drug  CoNS  E. co…¹ E. fa…² K. pn…³ P. ae…⁴ P. mi…⁵ S. au…⁶ S. ep…⁷
#>    <chr>     <chr> <chr> <chr>   <chr>   <chr>   <chr>   <chr>   <chr>   <chr>  
#>  1 "Aminogl… Amik… "100… "  0.0… "100.0… ""      ""      ""      ""      "100.0…
#>  2 ""        Gent… " 13… "  2.0… "100.0… " 10.3… "  0.0… "  5.9… "  0.9… " 21.5…
#>  3 ""        Kana… "100… ""      "100.0… ""      "100.0… ""      ""      "100.0…
#>  4 ""        Tobr… " 78… "  2.6… "100.0… " 10.3… "  0.0… "  5.9… "  2.3… " 49.4…
#>  5 "Ampheni… Chlo… ""    ""      ""      ""      "100.0… ""      "  0.0… "  3.1…
#>  6 "Antimyc… Rifa… ""    "100.0… ""      "100.0… "100.0… "100.0… "  0.0… "  2.7…
#>  7 "Beta-la… Amox… " 93… " 50.0… ""      "100.0… "100.0… ""      " 93.9… " 98.9…
#>  8 ""        Amox… " 42… " 13.1… ""      " 10.3… "100.0… "  2.8… "  0.4… " 54.5…
#>  9 ""        Ampi… " 93… " 50.0… ""      "100.0… "100.0… ""      " 93.9… " 98.9…
#> 10 ""        Benz… " 77… "100.0… ""      "100.0… "100.0… "100.0… " 80.9… " 89.4…
#> # … with 29 more rows, 2 more variables: `S. hominis` <chr>,
#> #   `S. pneumoniae` <chr>, and abbreviated variable names ¹​`E. coli`,
#> #   ²​`E. faecalis`, ³​`K. pneumoniae`, ⁴​`P. aeruginosa`, ⁵​`P. mirabilis`,
#> #   ⁶​`S. aureus`, ⁷​`S. epidermidis`

# Use FUN to change to transformation of microorganism codes
bug_drug_combinations(example_isolates,
  FUN = mo_gramstain
)
#> # A tibble: 80 × 6
#>    mo            ab        S     I     R total
#>  * <chr>         <chr> <int> <int> <int> <int>
#>  1 Gram-negative PEN       8     0   717   725
#>  2 Gram-negative OXA       6     0     0     6
#>  3 Gram-negative FLC       6     0     0     6
#>  4 Gram-negative AMX     226     0   405   631
#>  5 Gram-negative AMC     463    89   174   726
#>  6 Gram-negative AMP     226     0   405   631
#>  7 Gram-negative TZP     554    11    76   641
#>  8 Gram-negative CZO      94     2   110   206
#>  9 Gram-negative FEP     470     1    14   485
#> 10 Gram-negative CXM     539    22   142   703
#> # … with 70 more rows
#> Use 'format()' on this result to get a publishable/printable format.

bug_drug_combinations(example_isolates,
  FUN = function(x) {
    ifelse(x == as.mo("Escherichia coli"),
      "E. coli",
      "Others"
    )
  }
)
#> # A tibble: 80 × 6
#>    mo      ab        S     I     R total
#>  * <chr>   <chr> <int> <int> <int> <int>
#>  1 E. coli PEN       0     0   467   467
#>  2 E. coli OXA       0     0     0     0
#>  3 E. coli FLC       0     0     0     0
#>  4 E. coli AMX     196     0   196   392
#>  5 E. coli AMC     332    74    61   467
#>  6 E. coli AMP     196     0   196   392
#>  7 E. coli TZP     388     5    23   416
#>  8 E. coli CZO      79     1     2    82
#>  9 E. coli FEP     308     0     9   317
#> 10 E. coli CXM     425    15    25   465
#> # … with 70 more rows
#> Use 'format()' on this result to get a publishable/printable format.
# }