implement EUCAST >= 2019 directly from their source files

This commit is contained in:
Matthijs Berends committed 2026-10-01 14:53:00 +01:00
1 parent aebad2ae47
commit 5d9974e2b9
23 files changed
+19941 -12249

No files matched your search

+5 -4
View File
@@ -317,11 +317,12 @@
#' From WHONET, imported were:
#'
#' * All CLSI breakpoints, including ECOFF
#' * EUCAST breakpoints between `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "human")$guideline)))` and 2018
#' * All non-human EUCAST breakpoints, including ECOFF
#' * Human EUCAST breakpoints between `r min(as.integer(gsub("[^0-9]", "", subset(AMR::clinical_breakpoints, guideline %like% "EUCAST" & type == "human")$guideline)))` and 2018
#'
#' EUCAST breakpoints from 2019 onwards, were retrieved directly from <https://www.eucast.org>.
#'
#' Our import and reproduction script can be found here: <https://github.com/msberends/AMR/blob/main/data-raw/_reproduction_scripts/reproduction_of_clinical_breakpoints.R>.
#' Human EUCAST breakpoints from 2019 onwards, were retrieved directly from <https://www.eucast.org> using [this script](https://github.com/msberends/AMR/blob/main/data-raw/_reproduction_scripts/reproduction_of_clinical_breakpoints_eucast.R).
#'
#' Our WHONET import script can be [found here](https://github.com/msberends/AMR/blob/main/data-raw/_reproduction_scripts/reproduction_of_clinical_breakpoints.R).
#'
#' ### Response From CLSI and EUCAST
#' The CEO of CLSI and the chairman of EUCAST have endorsed the work and public use of this `AMR` package (and consequently the use of their breakpoints) in June 2023, when future development of distributing clinical breakpoints was discussed in a meeting between CLSI, EUCAST, WHO, developers of WHONET software, and developers of this `AMR` package.
+22
View File
@@ -2340,6 +2340,28 @@ rep.sir <- function(x, ...) {
y
}
#' @method Ops sir
#' @export
#' @noRd
Ops.sir <- function(e1, e2) {
comparison_ops <- c("==", "!=", "<", ">", "<=", ">=")
if (nargs() == 2 && .Generic %in% comparison_ops) {
# coerce both sides to the current sir structure (identical levels),
# after which comparing the integer codes is exact, including ordering
e1 <- as.sir(e1)
e2 <- as.sir(e2)
return(get(.Generic, mode = "function")(as.integer(e1), as.integer(e2)))
}
NextMethod()
}
#' @rawNamespace if(getRversion() >= "4.3.0") S3method(chooseOpsMethod, sir)
#' @exportS3Method NULL
#' @noRd
chooseOpsMethod.sir <- function(x, y, mx, my, cl, reverse) {
TRUE
}
coerce_reference_data_columns <- function(x) {
ref <- AMR::clinical_breakpoints
for (col in names(ref)) {
BIN
View File
Binary file not shown.
+16 -14
View File
@@ -120,13 +120,14 @@ all_disk_predictors <- function() {
#' @rdname amr-tidymodels
#' @export
step_mic_log2 <- function(
recipe,
...,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("mic_log2")) {
recipe,
...,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("mic_log2")
) {
recipes::add_step(
recipe,
step_mic_log2_new(
@@ -195,13 +196,14 @@ tidy.step_mic_log2 <- function(x, ...) {
#' @rdname amr-tidymodels
#' @export
step_sir_numeric <- function(
recipe,
...,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("sir_numeric")) {
recipe,
...,
role = NA,
trained = FALSE,
columns = NULL,
skip = FALSE,
id = recipes::rand_id("sir_numeric")
) {
recipes::add_step(
recipe,
step_sir_numeric_new(
+8
View File
@@ -91,7 +91,9 @@
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_ptype2, sir.sir)
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_ptype2, character.sir)
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_cast, character.sir)
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_cast, factor.sir)
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_cast, sir.character)
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_cast, sir.factor)
#' @rawNamespace if(getRversion() >= "3.0.0") S3method(vctrs::vec_cast, sir.sir)
# S3: amr_selector ----
@@ -257,6 +259,12 @@ vec_cast.sir.sir <- function(x, to, ...) {
vec_cast.character.sir <- function(x, to, ...) {
as.character(x)
}
vec_cast.factor.sir <- function(x, to, ...) {
factor(as.sir(x))
}
vec_cast.sir.character <- function(x, to, ...) {
as.sir(x)
}
vec_cast.sir.factor <- function(x, to, ...) {
as.sir(x)
}