1
0
mirror of https://github.com/msberends/AMR.git synced 2026-04-06 09:36:04 +02:00

(v3.0.1.9042) add EUCAST breakpoint table v16 to interpretive_rules()

This commit is contained in:
2026-04-02 11:42:19 +02:00
parent 3a736bc484
commit 26613d774b
33 changed files with 1765 additions and 1584 deletions

View File

@@ -30,6 +30,12 @@
# add new version numbers here, and add the rules themselves to "data-raw/eucast_rules.tsv" and clinical_breakpoints
# (sourcing "data-raw/_pre_commit_checks.R" will process the TSV file)
EUCAST_VERSION_BREAKPOINTS <- list(
"16.0" = list(
version_txt = "v16.0",
year = 2026,
title = "'EUCAST Clinical Breakpoint Tables'",
url = "https://www.eucast.org/bacteria/clinical-breakpoints-and-interpretation/clinical-breakpoint-tables/"
),
"15.0" = list(
version_txt = "v15.0",
year = 2025,

View File

@@ -359,9 +359,9 @@ stop_ifnot_installed <- function(package) {
if (any(!installed) && any(package == "rstudioapi")) {
stop("This function only works in RStudio when using R >= 3.2.", call. = FALSE)
} else if (any(!installed)) {
stop("This requires the ", vector_and(package[!installed]), " package.",
"\nTry to install with install.packages().",
call. = FALSE
stop_(
"This requires the ", vector_and(paste0("{.pkg ", package[!installed], "}"), quotes = FALSE), " package.",
"\nTry to install with {.fun install.packages}."
)
} else {
return(invisible())
@@ -747,7 +747,7 @@ format_included_data_number <- function(data) {
paste0(ifelse(rounder == 0, "", "~"), format(round(n, rounder), decimal.mark = ".", big.mark = " "))
}
vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_captital = FALSE, last_sep = " or ") {
vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_captital = FALSE, last_sep = " or ", documentation = FALSE) {
# makes unique and sorts, and this also removed NAs
v <- unique(v)
has_na <- anyNA(v)
@@ -761,17 +761,25 @@ vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_ca
v <- rev(v)
}
if (isTRUE(quotes)) {
quotes <- '"'
if (isTRUE(documentation)) {
quotes <- '"'
} else {
# use cli to format as values
quotes <- c("{.val ", "}")
}
} else if (isFALSE(quotes)) {
quotes <- ""
} else {
quotes <- quotes[1L]
}
if (length(quotes) == 1) {
quotes <- c(quotes, quotes)
}
if (isTRUE(initial_captital)) {
v[1] <- gsub("^([a-z])", "\\U\\1", v[1], perl = TRUE)
}
if (length(v) <= 1) {
return(paste0(quotes, v, quotes))
return(paste0(quotes[1], v, quotes[2]))
}
if (identical(v, c("I", "R", "S"))) {
# class 'sir' should be sorted like this
@@ -790,7 +798,7 @@ vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_ca
if (is.numeric(v)) {
v <- trimws(vapply(FUN.VALUE = character(1), v, format, scientific = FALSE))
}
quoted <- paste0(quotes, v, quotes)
quoted <- paste0(quotes[1], v, quotes[2])
quoted[NAs] <- "NA"
# all commas except for last item, so will become '"val1", "val2", "val3" or "val4"'
paste0(
@@ -799,10 +807,11 @@ vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_ca
)
}
vector_and <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_captital = FALSE) {
vector_and <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_captital = FALSE, documentation = FALSE) {
vector_or(
v = v, quotes = quotes, reverse = reverse, sort = sort,
initial_captital = initial_captital, last_sep = " and "
initial_captital = initial_captital, documentation = documentation,
last_sep = " and "
)
}

View File

@@ -857,7 +857,7 @@ all_any_amr_selector <- function(type, ..., na.rm = TRUE) {
cols_ab <- c(...)
result <- cols_ab[toupper(cols_ab) %in% VALID_SIR_LEVELS]
if (length(result) == 0) {
message_("Filtering ", type, " of columns ", vector_and(font_bold(cols_ab, collapse = NULL), quotes = "'"), ' to contain value "S", "I" or "R"')
message_("Filtering ", type, " of columns ", vector_and(paste0("{.field ", font_bold(cols_ab, collapse = NULL), "}"), quotes = FALSE), " to only contain values ", vector_or(VALID_SIR_LEVELS))
result <- VALID_SIR_LEVELS
}
cols_ab <- cols_ab[!cols_ab %in% result]

View File

@@ -80,7 +80,7 @@
#'
#' ### Using taxonomic properties in rules
#'
#' There is one exception in columns used for the rules: all column names of the [microorganisms] data set can also be used, but do not have to exist in the data set. These column names are: `r vector_and(colnames(microorganisms), sort = FALSE)`. Thus, this next example will work as well, despite the fact that the `df` data set does not contain a column `genus`:
#' There is one exception in columns used for the rules: all column names of the [microorganisms] data set can also be used, but do not have to exist in the data set. These column names are: `r vector_and(colnames(microorganisms), sort = FALSE, documentation = TRUE)`. Thus, this next example will work as well, despite the fact that the `df` data set does not contain a column `genus`:
#'
#' ```r
#' y <- custom_eucast_rules(

View File

@@ -76,7 +76,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) {
#' @param overwrite A [logical] indicating whether to overwrite existing SIR values (default: `FALSE`). When `FALSE`, only non-SIR values are modified (i.e., any value that is not already S, I or R). To ensure compliance with EUCAST guidelines, **this should remain** `FALSE`, as EUCAST notes often state that an organism "should be tested for susceptibility to individual agents or be reported resistant".
#' @inheritParams first_isolate
#' @details
#' **Note:** This function does not translate MIC values to SIR values. Use [as.sir()] for that. \cr
#' **Note:** This function does not translate MIC or disk values to SIR values. Use [as.sir()] for that. \cr
#' **Note:** When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance. \cr
#'
#' The file containing all EUCAST rules is located here: <https://github.com/msberends/AMR/blob/main/data-raw/eucast_rules.tsv>. **Note:** Old taxonomic names are replaced with the current taxonomy where applicable. For example, *Ochrobactrum anthropi* was renamed to *Brucella anthropi* in 2020; the original EUCAST rules v3.1 and v3.2 did not yet contain this new taxonomic name. The `AMR` package contains the full microbial taxonomy updated until `r documentation_date(max(TAXONOMY_VERSION$GBIF$accessed_date, TAXONOMY_VERSION$LPSN$accessed_date))`, see [microorganisms].
@@ -163,7 +163,7 @@ interpretive_rules <- function(x,
rules = getOption("AMR_interpretive_rules", default = c("breakpoints", "expected_phenotypes")),
guideline = getOption("AMR_guideline", "EUCAST"),
verbose = FALSE,
version_breakpoints = 15.0,
version_breakpoints = 16.0,
version_expected_phenotypes = 1.2,
version_expertrules = 3.3,
ampc_cephalosporin_resistance = NA,

2
R/mo.R
View File

@@ -249,7 +249,7 @@ as.mo <- function(x,
if (length(which(ind)) > 0 && isTRUE(info) && message_not_thrown_before("as.mo_microorganisms.codes", is.na(out), toupper(x))) {
message_(
"Retrieved value", ifelse(sum(ind) > 1, "s", ""),
" from the {.help [microorganisms.codes](AMR::microorganisms.codes)} data set for ", vector_and(paste0("{.val ", toupper(x)[ind], "}"), quotes = FALSE), "."
" from the {.help [microorganisms.codes](AMR::microorganisms.codes)} data set for ", vector_and(toupper(x)[ind]), "."
)
}
# From SNOMED ----

View File

@@ -1079,8 +1079,8 @@ get_guideline <- function(guideline, reference_data) {
guideline_param[guideline_param %unlike% " "] <- gsub("([a-z]+)([0-9]+)", "\\1 \\2", guideline_param[guideline_param %unlike% " "], ignore.case = TRUE)
stop_ifnot(guideline_param %in% reference_data$guideline,
"invalid guideline: '", guideline,
"'.\nValid guidelines are: ", vector_and(reference_data$guideline, quotes = TRUE, reverse = TRUE),
"invalid guideline: {.val ", guideline,
"}.\nValid guidelines are: ", vector_and(reference_data$guideline, reverse = TRUE),
call = FALSE
)

Binary file not shown.