These functions can be used to determine first weighted isolates by considering the phenotype for isolate selection (see first_isolate()). Using a phenotype-based method to determine first isolates is more reliable than methods that disregard phenotypes.

key_antimicrobials(
  x = NULL,
  col_mo = NULL,
  universal = c("ampicillin", "amoxicillin/clavulanic acid", "cefuroxime",
    "piperacillin/tazobactam", "ciprofloxacin", "trimethoprim/sulfamethoxazole"),
  gram_negative = c("gentamicin", "tobramycin", "colistin", "cefotaxime",
    "ceftazidime", "meropenem"),
  gram_positive = c("vancomycin", "teicoplanin", "tetracycline", "erythromycin",
    "oxacillin", "rifampin"),
  antifungal = c("anidulafungin", "caspofungin", "fluconazole", "miconazole",
    "nystatin", "voriconazole"),
  only_rsi_columns = FALSE,
  ...
)

all_antimicrobials(x = NULL, only_rsi_columns = FALSE, ...)

antimicrobials_equal(
  y,
  z,
  type = c("points", "keyantimicrobials"),
  ignore_I = TRUE,
  points_threshold = 2,
  info = FALSE,
  ...
)

Arguments

x

a data.frame with antibiotics columns, like AMX or amox. Can be left blank to determine automatically

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().

universal

names of broad-spectrum antimicrobial agents, case-insensitive. Set to NULL to ignore. See Details for the default agents.

gram_negative

names of antibiotic agents for Gram-positives, case-insensitive. Set to NULL to ignore. See Details for the default agents.

gram_positive

names of antibiotic agents for Gram-negatives, case-insensitive. Set to NULL to ignore. See Details for the default agents.

antifungal

names of antifungal agents for fungi, case-insensitive. Set to NULL to ignore. See Details for the default agents.

...

ignored, allows for future extensions

y, z

character vectors to compare

type

type to determine weighed isolates; can be "keyantimicrobials" or "points", see Details

ignore_I

logical to indicate whether antibiotic interpretations with "I" will be ignored when type = "keyantimicrobials", see Details

points_threshold

minimum number of points to require before differences in the antibiogram will lead to inclusion of an isolate when type = "points", see Details

info

unused - previously used to indicate whether a progress bar should print

Details

The key_antimicrobials() and all_antimicrobials() functions are context-aware. This means that then the x argument can be left blank, see Examples.

The function key_antimicrobials() returns a character vector with 12 antimicrobial results for every isolate. The function all_antimicrobials() returns a character vector with all antimicrobial results for every isolate. These vectors can then be compared using antimicrobials_equal(), to check if two isolates have generally the same antibiogram. Missing and invalid values are replaced with a dot (".") by key_antimicrobials() and ignored by antimicrobials_equal().

Please see the first_isolate() function how these important functions enable the 'phenotype-based' method for determination of first isolates.

The default antimicrobial agents used for all rows (set in universal) are:

  • Ampicillin

  • Amoxicillin/clavulanic acid

  • Cefuroxime

  • Ciprofloxacin

  • Piperacillin/tazobactam

  • Trimethoprim/sulfamethoxazole

The default antimicrobial agents used for Gram-negative bacteria (set in gram_negative) are:

  • Cefotaxime

  • Ceftazidime

  • Colistin

  • Gentamicin

  • Meropenem

  • Tobramycin

The default antimicrobial agents used for Gram-positive bacteria (set in gram_positive) are:

  • Erythromycin

  • Oxacillin

  • Rifampin

  • Teicoplanin

  • Tetracycline

  • Vancomycin

The default antimicrobial agents used for fungi (set in antifungal) are:

  • Anidulafungin

  • Caspofungin

  • Fluconazole

  • Miconazole

  • Nystatin

  • Voriconazole

Stable Lifecycle


The lifecycle of this function is stable. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.

If the unlying code needs breaking changes, they will occur gradually. For example, a argument will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.

Read more on Our Website!

On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR data analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

See also

Examples

# `example_isolates` is a data set available in the AMR package.
# See ?example_isolates.

# output of the `key_antimicrobials()` function could be like this:
strainA <- "SSSRR.S.R..S"
strainB <- "SSSIRSSSRSSS"

# those strings can be compared with:
antimicrobials_equal(strainA, strainB, type = "keyantimicrobials")
# TRUE, because I is ignored (as well as missing values)

antimicrobials_equal(strainA, strainB, type = "keyantimicrobials", ignore_I = FALSE)
# FALSE, because I is not ignored and so the 4th character differs

# \donttest{
if (require("dplyr")) {
  # set key antibiotics to a new variable
  my_patients <- example_isolates %>%
    mutate(keyab = key_antimicrobials(antifungal = NULL)) %>% # no need to define `x`
    mutate(
      # now calculate first isolates
      first_regular = first_isolate(col_keyantimicrobials = FALSE),
      # and first WEIGHTED isolates
      first_weighted = first_isolate(col_keyantimicrobials = "keyab")
    )
 
  # Check the difference, in this data set it results in more isolates:
  sum(my_patients$first_regular, na.rm = TRUE)
  sum(my_patients$first_weighted, na.rm = TRUE)
}
# }