diff --git a/DESCRIPTION b/DESCRIPTION index 6277afe21..a05645f0e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 3.0.1.9044 -Date: 2026-04-04 +Version: 3.0.1.9045 +Date: 2026-04-05 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index d717f5de5..bbfe873e4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,4 @@ -<<<<<<< HEAD -# AMR 3.0.1.9044 +# AMR 3.0.1.9045 ### New * Support for clinical breakpoints of 2026 of both CLSI and EUCAST, by adding all of their over 5,700 new clinical breakpoints to the `clinical_breakpoints` data set for usage in `as.sir()`. EUCAST 2026 is now the new default guideline for all MIC and disk diffusion interpretations. diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index d611a940e..bae37579f 100644 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -766,7 +766,7 @@ vector_or <- function(v, quotes = TRUE, reverse = FALSE, sort = TRUE, initial_ca } if (isTRUE(quotes)) { if (isTRUE(documentation)) { - quotes <- '"' + quotes <- c("`\"", "\"`") } else { # use cli to format as values quotes <- c("{.val ", "}") diff --git a/R/data.R b/R/data.R index c387b4668..1a0beef0c 100755 --- a/R/data.R +++ b/R/data.R @@ -106,12 +106,12 @@ #' @format A [tibble][tibble::tibble] with `r format(nrow(microorganisms), big.mark = " ")` observations and `r ncol(microorganisms)` variables: #' - `mo`\cr ID of microorganism as used by this package. ***This is a unique identifier.*** #' - `fullname`\cr Full name, like `"Escherichia coli"`. For the taxonomic ranks genus, species and subspecies, this is the 'pasted' text of genus, species, and subspecies. For all taxonomic ranks higher than genus, this is the name of the taxon. ***This is a unique identifier.*** -#' - `status` \cr Status of the taxon, either `r vector_or(microorganisms$status)` +#' - `status` \cr Status of the taxon, either `r vector_or(microorganisms$status, documentation = TRUE)` #' - `kingdom`, `phylum`, `class`, `order`, `family`, `genus`, `species`, `subspecies`\cr Taxonomic rank of the microorganism. Note that for fungi, *phylum* is equal to their taxonomic *division*. Also, for fungi, *subkingdom* and *subdivision* were left out since they do not occur in the bacterial taxonomy. #' - `rank`\cr Text of the taxonomic rank of the microorganism, such as `"species"` or `"genus"` #' - `ref`\cr Author(s) and year of related scientific publication. This contains only the *first surname* and year of the *latest* authors, e.g. "Wallis *et al.* 2006 *emend.* Smith and Jones 2018" becomes "Smith *et al.*, 2018". This field is directly retrieved from the source specified in the column `source`. Moreover, accents were removed to comply with CRAN that only allows ASCII characters. -#' - `oxygen_tolerance` \cr Oxygen tolerance, either `r vector_or(microorganisms$oxygen_tolerance)`. These data were retrieved from BacDive (see *Source*). Items that contain "likely" are missing from BacDive and were extrapolated from other species within the same genus to guess the oxygen tolerance. Currently `r round(length(microorganisms$oxygen_tolerance[which(!is.na(microorganisms$oxygen_tolerance))]) / nrow(microorganisms[which(microorganisms$kingdom == "Bacteria"), ]) * 100, 1)`% of all `r format_included_data_number(nrow(microorganisms[which(microorganisms$kingdom == "Bacteria"), ]))` bacteria in the data set contain an oxygen tolerance. -#' - `source`\cr Either `r vector_or(microorganisms$source)` (see *Source*) +#' - `oxygen_tolerance` \cr Oxygen tolerance, either `r vector_or(microorganisms$oxygen_tolerance, documentation = TRUE)`. These data were retrieved from BacDive (see *Source*). Items that contain "likely" are missing from BacDive and were extrapolated from other species within the same genus to guess the oxygen tolerance. Currently `r round(length(microorganisms$oxygen_tolerance[which(!is.na(microorganisms$oxygen_tolerance))]) / nrow(microorganisms[which(microorganisms$kingdom == "Bacteria"), ]) * 100, 1)`% of all `r format_included_data_number(nrow(microorganisms[which(microorganisms$kingdom == "Bacteria"), ]))` bacteria in the data set contain an oxygen tolerance. +#' - `source`\cr Either `r vector_or(microorganisms$source, documentation = TRUE)` (see *Source*) #' - `lpsn`\cr Identifier ('Record number') of `r TAXONOMY_VERSION$LPSN$name`. This will be the first/highest LPSN identifier to keep one identifier per row. For example, *Acetobacter ascendens* has LPSN Record number 7864 and 11011. Only the first is available in the `microorganisms` data set. ***This is a unique identifier***, though available for only `r format_included_data_number(sum(!is.na(microorganisms$lpsn)))` records. #' - `lpsn_parent`\cr LPSN identifier of the parent taxon #' - `lpsn_renamed_to`\cr LPSN identifier of the currently valid taxon @@ -222,8 +222,8 @@ #' - `date`\cr Date of receipt at the laboratory #' - `patient`\cr ID of the patient #' - `age`\cr Age of the patient -#' - `gender`\cr Gender of the patient, either `r vector_or(example_isolates$gender)` -#' - `ward`\cr Ward type where the patient was admitted, either `r vector_or(example_isolates$ward)` +#' - `gender`\cr Gender of the patient, either `r vector_or(example_isolates$gender, documentation = TRUE)` +#' - `ward`\cr Ward type where the patient was admitted, either `r vector_or(example_isolates$ward, documentation = TRUE)` #' - `mo`\cr ID of microorganism created with [as.mo()], see also the [microorganisms] data set #' - `PEN:RIF`\cr `r sum(vapply(FUN.VALUE = logical(1), example_isolates, is.sir))` different antimicrobials with class [`sir`] (see [as.sir()]); these column names occur in the [antimicrobials] data set and can be translated with [set_ab_names()] or [ab_name()] #' @inheritSection AMR Download Our Reference Data @@ -292,9 +292,9 @@ #' Use [as.sir()] to transform MICs or disks measurements to SIR values. #' @format A [tibble][tibble::tibble] with `r format(nrow(clinical_breakpoints), big.mark = " ")` observations and `r ncol(clinical_breakpoints)` variables: #' - `guideline`\cr Name of the guideline -#' - `type`\cr Breakpoint type, either `r vector_or(clinical_breakpoints$type)` -#' - `host`\cr Host of infectious agent. This is mostly useful for veterinary breakpoints and is either `r vector_or(clinical_breakpoints$host)` -#' - `method`\cr Testing method, either `r vector_or(clinical_breakpoints$method)` +#' - `type`\cr Breakpoint type, either `r vector_or(clinical_breakpoints$type, documentation = TRUE)` +#' - `host`\cr Host of infectious agent. This is mostly useful for veterinary breakpoints and is either `r vector_or(clinical_breakpoints$host, documentation = TRUE)` +#' - `method`\cr Testing method, either `r vector_or(clinical_breakpoints$method, documentation = TRUE)` #' - `site`\cr Body site for which the breakpoint must be applied, e.g. "Oral" or "Respiratory" #' - `mo`\cr Microbial ID, see [as.mo()] #' - `rank_index`\cr Taxonomic rank index of `mo` from 1 (subspecies/infraspecies) to 5 (unknown microorganism) @@ -350,10 +350,10 @@ #' @format A [tibble][tibble::tibble] with `r format(nrow(dosage), big.mark = " ")` observations and `r ncol(dosage)` variables: #' - `ab`\cr Antimicrobial ID as used in this package (such as `AMC`), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available #' - `name`\cr Official name of the antimicrobial drug as used by WHONET/EARS-Net or the WHO -#' - `type`\cr Type of the dosage, either `r vector_or(dosage$type)` +#' - `type`\cr Type of the dosage, either `r vector_or(dosage$type, documentation = TRUE)` #' - `dose`\cr Dose, such as "2 g" or "25 mg/kg" #' - `dose_times`\cr Number of times a dose must be administered -#' - `administration`\cr Route of administration, either `r vector_or(dosage$administration)` +#' - `administration`\cr Route of administration, either `r vector_or(dosage$administration, documentation = TRUE)` #' - `notes`\cr Additional dosage notes #' - `original_txt`\cr Original text in the PDF file of EUCAST #' - `eucast_version`\cr Version number of the EUCAST Clinical Breakpoints guideline to which these dosages apply, either `r vector_or(dosage$eucast_version, quotes = FALSE, sort = TRUE, reverse = TRUE)` diff --git a/R/interpretive_rules.R b/R/interpretive_rules.R index 55b191045..fd53a919a 100755 --- a/R/interpretive_rules.R +++ b/R/interpretive_rules.R @@ -64,7 +64,7 @@ format_eucast_version_nr <- function(version, markdown = TRUE) { #' @param guideline A guideline name, either "EUCAST" (default) or "CLSI". This can be set with the package option [`AMR_guideline`][AMR-options]. #' @param rules A [character] vector that specifies which rules should be applied. Must be one or more of `"breakpoints"`, `"expected_phenotypes"`, `"expert"`, `"other"`, `"custom"`, `"all"`, and defaults to `c("breakpoints", "expected_phenotypes")`. The default value can be set to another value using the package option [`AMR_interpretive_rules`][AMR-options]: `options(AMR_interpretive_rules = "all")`. If using `"custom"`, be sure to fill in argument `custom_rules` too. Custom rules can be created with [custom_eucast_rules()]. #' @param verbose A [logical] to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time. -#' @param version_breakpoints The version number to use for the EUCAST Clinical Breakpoints guideline. Can be `r vector_or(names(EUCAST_VERSION_BREAKPOINTS), reverse = TRUE)`. +#' @param version_breakpoints The version number to use for the EUCAST Clinical Breakpoints guideline. Can be `r vector_or(names(EUCAST_VERSION_BREAKPOINTS), documentation = TRUE, reverse = TRUE)`. #' @param version_expected_phenotypes The version number to use for the EUCAST Expected Phenotypes. Can be `r vector_or(names(EUCAST_VERSION_EXPECTED_PHENOTYPES), reverse = TRUE)`. #' @param version_expertrules The version number to use for the EUCAST Expert Rules and Intrinsic Resistance guideline. Can be `r vector_or(names(EUCAST_VERSION_EXPERT_RULES), reverse = TRUE)`. #' @param ampc_cephalosporin_resistance (only applies when `rules` contains `"expert"` or `"all"`) a [character] value that should be applied to cefotaxime, ceftriaxone and ceftazidime for AmpC de-repressed cephalosporin-resistant mutants - the default is `NA`. Currently only works when `version_expertrules` is `3.2` and higher; these versions of '*EUCAST Expert Rules on Enterobacterales*' state that results of cefotaxime, ceftriaxone and ceftazidime should be reported with a note, or results should be suppressed (emptied) for these three drugs. A value of `NA` (the default) for this argument will remove results for these three drugs, while e.g. a value of `"R"` will make the results for these drugs resistant. Use `NULL` or `FALSE` to not alter results for these three drugs of AmpC de-repressed cephalosporin-resistant mutants. Using `TRUE` is equal to using `"R"`. \cr For *EUCAST Expert Rules* v3.2, this rule applies to: `r vector_and(gsub("[^a-zA-Z ]+", "", unlist(strsplit(EUCAST_RULES_DF[which(EUCAST_RULES_DF$reference.version %in% c(3.2, 3.3) & EUCAST_RULES_DF$reference.rule %like% "ampc"), "this_value"][1], "|", fixed = TRUE))), quotes = "*")`. @@ -188,6 +188,11 @@ interpretive_rules <- function(x, meet_criteria(overwrite, allow_class = "logical", has_length = 1) meet_criteria(add_if_missing, allow_class = "logical", has_length = 1) + stop_if( + !overwrite && !add_if_missing, + "Either set {.arg overwrite} or {.arg add_if_missing} to {.code TRUE}, or both." + ) + stop_if( guideline == "CLSI", "CLSI guideline is not yet supported." @@ -600,7 +605,7 @@ interpretive_rules <- function(x, } else { if (isTRUE(info)) { cat("\n") - message_("Skipping inhibitor-inheritance rules defined by this AMR package: setting S to drug+inhibitor where drug is S, and setting R to drug where drug+inhibitor is R. Add \"other\" or \"all\" to the {.arg rules} argument to apply those rules.") + message_("Skipping inhibitor-inheritance rules defined by this AMR package: setting S to drug+inhibitor where drug is S, and setting R to drug where drug+inhibitor is R. Add {.val other} or {.val all} to the {.arg rules} argument to apply those rules.") } } @@ -1171,6 +1176,7 @@ edit_sir <- function(x, } else { if (isFALSE(add_if_missing)) isSIR else non_SIR } +warning_("test", call = T) # aaaaaaa tryCatch( # insert into original table new_edits[rows, cols][apply_mask] <- to, diff --git a/man/clinical_breakpoints.Rd b/man/clinical_breakpoints.Rd index 7138abec3..4070bfeba 100644 --- a/man/clinical_breakpoints.Rd +++ b/man/clinical_breakpoints.Rd @@ -8,9 +8,9 @@ A \link[tibble:tibble]{tibble} with 45 730 observations and 14 variables: \itemize{ \item \code{guideline}\cr Name of the guideline -\item \code{type}\cr Breakpoint type, either {.val ECOFF}, {.val animal}, or {.val human} -\item \code{host}\cr Host of infectious agent. This is mostly useful for veterinary breakpoints and is either {.val ECOFF}, {.val aquatic}, {.val cats}, {.val cattle}, {.val dogs}, {.val horse}, {.val human}, {.val poultry}, or {.val swine} -\item \code{method}\cr Testing method, either {.val DISK} or {.val MIC} +\item \code{type}\cr Breakpoint type, either \code{"ECOFF"}, \code{"animal"}, or \code{"human"} +\item \code{host}\cr Host of infectious agent. This is mostly useful for veterinary breakpoints and is either \code{"ECOFF"}, \code{"aquatic"}, \code{"cats"}, \code{"cattle"}, \code{"dogs"}, \code{"horse"}, \code{"human"}, \code{"poultry"}, or \code{"swine"} +\item \code{method}\cr Testing method, either \code{"DISK"} or \code{"MIC"} \item \code{site}\cr Body site for which the breakpoint must be applied, e.g. "Oral" or "Respiratory" \item \code{mo}\cr Microbial ID, see \code{\link[=as.mo]{as.mo()}} \item \code{rank_index}\cr Taxonomic rank index of \code{mo} from 1 (subspecies/infraspecies) to 5 (unknown microorganism) diff --git a/man/custom_eucast_rules.Rd b/man/custom_eucast_rules.Rd index 1dcc03020..355578f88 100644 --- a/man/custom_eucast_rules.Rd +++ b/man/custom_eucast_rules.Rd @@ -61,7 +61,7 @@ eucast_rules(df, \subsection{Using taxonomic properties in rules}{ -There is one exception in columns used for the rules: all column names of the \link{microorganisms} data set can also be used, but do not have to exist in the data set. These column names are: "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", and "snomed". Thus, this next example will work as well, despite the fact that the \code{df} data set does not contain a column \code{genus}: +There is one exception in columns used for the rules: all column names of the \link{microorganisms} data set can also be used, but do not have to exist in the data set. These column names are: \code{"mo"}, \code{"fullname"}, \code{"status"}, \code{"kingdom"}, \code{"phylum"}, \code{"class"}, \code{"order"}, \code{"family"}, \code{"genus"}, \code{"species"}, \code{"subspecies"}, \code{"rank"}, \code{"ref"}, \code{"oxygen_tolerance"}, \code{"source"}, \code{"lpsn"}, \code{"lpsn_parent"}, \code{"lpsn_renamed_to"}, \code{"mycobank"}, \code{"mycobank_parent"}, \code{"mycobank_renamed_to"}, \code{"gbif"}, \code{"gbif_parent"}, \code{"gbif_renamed_to"}, \code{"prevalence"}, and \code{"snomed"}. Thus, this next example will work as well, despite the fact that the \code{df} data set does not contain a column \code{genus}: \if{html}{\out{