Interpret MIC values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class rsi, which is an ordered factor with levels S < I < R. Invalid antimicrobial interpretations will be translated as NA with a warning.

as.rsi(x, ...)

# S3 method for mic
as.rsi(
  x,
  mo,
  ab = deparse(substitute(x)),
  guideline = "EUCAST",
  uti = FALSE,
  ...
)

# S3 method for disk
as.rsi(
  x,
  mo,
  ab = deparse(substitute(x)),
  guideline = "EUCAST",
  uti = FALSE,
  ...
)

# S3 method for data.frame
as.rsi(x, col_mo = NULL, guideline = "EUCAST", uti = NULL, ...)

is.rsi(x)

is.rsi.eligible(x, threshold = 0.05)

Arguments

x

vector of values (for class mic: an MIC value in mg/L, for class disk: a disk diffusion radius in millimetres)

...

parameters passed on to methods

mo

any (vector of) text that can be coerced to a valid microorganism code with as.mo()

ab

any (vector of) text that can be coerced to a valid antimicrobial code with as.ab()

guideline

defaults to the latest included EUCAST guideline, see Details for all options

uti

(Urinary Tract Infection) A vector with logicals (TRUE or FALSE) to specify whether a UTI specific interpretation from the guideline should be chosen. For using as.rsi() on a data.frame, this can also be a column containing logicals or when left blank, the data set will be search for a 'specimen' and rows containing 'urin' in that column will be regarded isolates from a UTI. See Examples.

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

threshold

maximum fraction of invalid antimicrobial interpretations of x, please see Examples

Value

Ordered factor with new class rsi

Details

When using as.rsi() on untransformed data, the data will be cleaned to only contain values S, I and R. When using the function on data with class mic (using as.mic()) or class disk (using as.disk()), the data will be interpreted based on the guideline set with the guideline parameter.

Supported guidelines to be used as input for the guideline parameter are: "CLSI 2010", "CLSI 2011", "CLSI 2012", "CLSI 2013", "CLSI 2014", "CLSI 2015", "CLSI 2016", "CLSI 2017", "CLSI 2018", "CLSI 2019", "EUCAST 2011", "EUCAST 2012", "EUCAST 2013", "EUCAST 2014", "EUCAST 2015", "EUCAST 2016", "EUCAST 2017", "EUCAST 2018", "EUCAST 2019", "EUCAST 2020". Simply using "CLSI" or "EUCAST" for input will automatically select the latest version of that guideline.

The repository of this package contains a machine readable version of all guidelines. This is a CSV file consisting of 18,964 rows and 10 columns. This file is machine readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. This allows for easy implementation of these rules in laboratory information systems (LIS).

After using as.rsi(), you can use eucast_rules() to (1) apply inferred susceptibility and resistance based on results of other antimicrobials and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.

The function is.rsi.eligible() returns TRUE when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and FALSE otherwise. The threshold of 5% can be set with the threshold parameter.

Interpretation of R and S/I

In 2019, the European Committee on Antimicrobial Susceptibility Testing (EUCAST) has decided to change the definitions of susceptibility testing categories R and S/I as shown below (http://www.eucast.org/newsiandr/).

  • R = Resistant
    A microorganism is categorised as Resistant when there is a high likelihood of therapeutic failure even when there is increased exposure. Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.

  • S = Susceptible
    A microorganism is categorised as Susceptible, standard dosing regimen, when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.

  • I = Increased exposure, but still susceptible
    A microorganism is categorised as Susceptible, Increased exposure when there is a high likelihood of therapeutic success because exposure to the agent is increased by adjusting the dosing regimen or by its concentration at the site of infection.

This AMR package honours this new insight. Use susceptibility() (equal to proportion_SI()) to determine antimicrobial susceptibility and count_susceptible() (equal to count_SI()) to count susceptible isolates.

Stable lifecycle


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

If the unlying code needs breaking changes, they will occur gradually. To begin with, the function or argument will be deprecated; it will 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.gitlab.io/AMR you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions (which reads a lot easier than here in R) and an example analysis using WHONET data.

See also

Examples

# For INTERPRETING disk diffusion and MIC values -----------------------

# a whole data set, even with combined MIC values and disk zones
df <- data.frame(microorganism = "E. coli",
                 AMP = as.mic(8),
                 CIP = as.mic(0.256),
                 GEN = as.disk(18),
                 TOB = as.disk(16),
                 NIT = as.mic(32))
as.rsi(df)

if (FALSE) {

# the dplyr way
library(dplyr)
df %>%
  mutate_at(vars(AMP:TOB), as.rsi, mo = "E. coli")

df %>%
  mutate_at(vars(AMP:TOB), as.rsi, mo = .$microorganism)

# to include information about urinary tract infections (UTI)
data.frame(mo = "E. coli",
           NIT = c("<= 2", 32),
           from_the_bladder = c(TRUE, FALSE)) %>%
  as.rsi(uti = "from_the_bladder")

data.frame(mo = "E. coli",
           NIT = c("<= 2", 32),
           specimen = c("urine", "blood")) %>%
  as.rsi() # automatically determines urine isolates

df %>%
  mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)
}

# for single values
as.rsi(x = as.mic(2),
       mo = as.mo("S. pneumoniae"),
       ab = "AMP",
       guideline = "EUCAST")

as.rsi(x = as.disk(18),
       mo = "Strep pneu",  # `mo` will be coerced with as.mo()
       ab = "ampicillin",  # and `ab` with as.ab()
       guideline = "EUCAST")


# For CLEANING existing R/SI values ------------------------------------

as.rsi(c("S", "I", "R", "A", "B", "C"))
as.rsi("<= 0.002; S") # will return "S"

rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
is.rsi(rsi_data)
plot(rsi_data)    # for percentages
barplot(rsi_data) # for frequencies

if (FALSE) {
library(dplyr)
example_isolates %>%
  mutate_at(vars(PEN:RIF), as.rsi)

# fastest way to transform all columns with already valid AMR results to class `rsi`:
example_isolates %>%
  mutate_if(is.rsi.eligible, as.rsi)

# note: from dplyr 1.0.0 on, this will be: 
# example_isolates %>%
#   mutate(across(is.rsi.eligible, as.rsi))

# default threshold of `is.rsi.eligible` is 5%.
is.rsi.eligible(WHONET$`First name`) # fails, >80% is invalid
is.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
}