diff --git a/DESCRIPTION b/DESCRIPTION index cdfea16ed..bdc9a28a3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 2.1.1.9285 -Date: 2025-05-21 +Version: 2.1.1.9286 +Date: 2025-06-01 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/NAMESPACE b/NAMESPACE index 8d3cb326f..35d997aef 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,12 +1,14 @@ # Generated by roxygen2: do not edit by hand S3method("!=",amr_selector) +S3method("$",deprecated_amr_dataset) S3method("&",amr_selector) S3method("+",ab) S3method("+",amr_selector) S3method("==",amr_selector) S3method("[",ab) S3method("[",av) +S3method("[",deprecated_amr_dataset) S3method("[",disk) S3method("[",mic) S3method("[",mo) @@ -18,6 +20,7 @@ S3method("[<-",mo) S3method("[<-",sir) S3method("[[",ab) S3method("[[",av) +S3method("[[",deprecated_amr_dataset) S3method("[[",disk) S3method("[[",mic) S3method("[[",mo) @@ -40,6 +43,7 @@ S3method(any,amr_selector) S3method(any,amr_selector_any_all) S3method(as.data.frame,ab) S3method(as.data.frame,av) +S3method(as.data.frame,deprecated_amr_dataset) S3method(as.data.frame,mic) S3method(as.data.frame,mo) S3method(as.double,mic) @@ -93,6 +97,7 @@ S3method(print,av) S3method(print,bug_drug_combinations) S3method(print,custom_eucast_rules) S3method(print,custom_mdro_guideline) +S3method(print,deprecated_amr_dataset) S3method(print,disk) S3method(print,mic) S3method(print,mo) diff --git a/NEWS.md b/NEWS.md index bdbe675e4..1642cbf9d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9285 +# AMR 2.1.1.9286 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://amr-for-r.org/#get-this-package).)* diff --git a/R/sysdata.rda b/R/sysdata.rda index df3af75dd..0094643ea 100755 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/R/zz_deprecated.R b/R/zz_deprecated.R index 80de0413a..080122e77 100755 --- a/R/zz_deprecated.R +++ b/R/zz_deprecated.R @@ -36,9 +36,45 @@ NULL #' @rdname AMR-deprecated -#' @usage NULL +#' @usage antibiotics #' @export -"antibiotics" +antibiotics <- local({ + warned <- FALSE + value <- AMR::antimicrobials + structure( + value, + class = c("deprecated_amr_dataset", class(value)) + ) +}) +.amr_deprecation_warn <- function() { + deprecation_warning(old = "antibiotics", new = "antimicrobials", is_dataset = TRUE) + invisible(NULL) +} +#' @export +`[.deprecated_amr_dataset` <- function(x, ...) { + .amr_deprecation_warn() + NextMethod("[") +} +#' @export +`[[.deprecated_amr_dataset` <- function(x, ...) { + .amr_deprecation_warn() + NextMethod("[[") +} +#' @export +`$.deprecated_amr_dataset` <- function(x, name) { + .amr_deprecation_warn() + NextMethod("$") +} +#' @export +print.deprecated_amr_dataset <- function(x, ...) { + .amr_deprecation_warn() + NextMethod("print") +} +#' @export +as.data.frame.deprecated_amr_dataset <- function(x, ...) { + .amr_deprecation_warn() + NextMethod("as.data.frame") +} # REMEMBER to search for `deprecation_warning` in the package code to find all instances. # currently deprecated arguments at least: diff --git a/R/zzz.R b/R/zzz.R index dfc245632..0d0cda4f9 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -110,14 +110,6 @@ AMR_env$cross_icon <- if (isTRUE(base::l10n_info()$`UTF-8`)) "\u00d7" else "x" AB_LOOKUP <- create_AB_AV_lookup(AMR::antimicrobials) } - # deprecated antibiotics data set - makeActiveBinding("antibiotics", function() { - if (interactive()) { - deprecation_warning(old = "antibiotics", new = "antimicrobials", is_dataset = TRUE) - } - AMR::antimicrobials - }, env = asNamespace(pkgname)) - AMR_env$AB_lookup <- cbind(AMR::antimicrobials, AB_LOOKUP) AMR_env$AV_lookup <- cbind(AMR::antivirals, AV_LOOKUP) } diff --git a/data-raw/_reproduction_scripts/reproduction_of_antimicrobials.R b/data-raw/_reproduction_scripts/reproduction_of_antimicrobials.R index 48ba5c6f8..a2b31ad5f 100644 --- a/data-raw/_reproduction_scripts/reproduction_of_antimicrobials.R +++ b/data-raw/_reproduction_scripts/reproduction_of_antimicrobials.R @@ -948,6 +948,8 @@ get_atc_code <- function(ab) { # exception for imipenem if (ab_name == "imipenem") ab_name <- "imipenem/cilastatin" if (ab_name == "imipenem/relebactam") ab_name <- "imipenem/cilastatin/relebactam" + if (ab_name == "ceftaroline") ab_name <- "ceftaroline fosamil" + ab_name.bak <- ab_name if (ab_name %like% "/") { ab_name <- strsplit(ab_name, "[/ ]")[[1]] } @@ -971,28 +973,33 @@ get_atc_code <- function(ab) { } else if (ab_name_full %like% " and " && ab_name_bla %in% atc_tbl[[2]]) { out <- atc_tbl[[1]][which(atc_tbl[[2]] == ab_name_bla)] } else { + if (any(atc_tbl_human$X1 %like% ab_name.bak, na.rm = TRUE)) { + message("returning NA, but DO MIND: ", ab_name.bak, " resembles ATC name(s) ", toString(atc_tbl_human$X1), appendLF = FALSE) + } out <- NA_character_ } unique(out) } +# update all: +to_update <- 1:nrow(antimicrobials) +# or just the empty ones: +to_update <- which(sapply(antimicrobials$atc, function(x) length(x[!is.na(x)])) == 0) + updated_atc <- lapply(seq_len(length(to_update)), function(x) NA_character_) -to_update <- 1:nrow(antimicrobials) -# or just the empty ones: -to_update <- which(sapply(antimicrobials$atc, length) == 0) -# this takes around 10 minutes (some are skipped and go faster) +# this takes around 10 minutes for the whole table (some ABx are skipped and go faster) for (i in to_update) { - message(percentage(i / length(updated_atc), digits = 1), + message(percentage(which(to_update == i) / length(updated_atc), digits = 1), " - Downloading ", antimicrobials$name[i], appendLF = FALSE ) atcs <- get_atc_code(antimicrobials$name[i]) if (length(atcs[!is.na(atcs)]) > 0) { updated_atc[[i]] <- atcs - message(" (", length(atcs[!is.na(atcs)]), " results: ", toString(atcs[!is.na(atcs)]), ")") + message(font_blue(paste0(" (", length(atcs[!is.na(atcs)]), " results: ", toString(atcs[!is.na(atcs)]), ")"))) # let the WHO server rest for a second - they might have a limitation on the queries per second Sys.sleep(1) } else { @@ -1001,7 +1008,8 @@ for (i in to_update) { } updated_atc <- lapply(updated_atc, function(x) sort(x[!is.na(x)])) -antimicrobials$atc <- updated_atc +antimicrobials$atc[to_update] <- updated_atc[to_update] + # DO NOT FORGET TO UPDATE R/aa_globals.R! diff --git a/data-raw/ab.md5 b/data-raw/ab.md5 index e38d1aada..923fdd937 100644 --- a/data-raw/ab.md5 +++ b/data-raw/ab.md5 @@ -1 +1 @@ -959459b92fe6ff57c02bab08381a73a8 +228840b3941753c4adee2b781d901590 diff --git a/data-raw/datasets/antimicrobials.dta b/data-raw/datasets/antimicrobials.dta index 18229fcc2..5e58e9977 100644 Binary files a/data-raw/datasets/antimicrobials.dta and b/data-raw/datasets/antimicrobials.dta differ diff --git a/data-raw/datasets/antimicrobials.feather b/data-raw/datasets/antimicrobials.feather index 9e8ba94e4..3b2d04dd4 100644 Binary files a/data-raw/datasets/antimicrobials.feather and b/data-raw/datasets/antimicrobials.feather differ diff --git a/data-raw/datasets/antimicrobials.parquet b/data-raw/datasets/antimicrobials.parquet index af3765174..20a3d1272 100644 Binary files a/data-raw/datasets/antimicrobials.parquet and b/data-raw/datasets/antimicrobials.parquet differ diff --git a/data-raw/datasets/antimicrobials.rds b/data-raw/datasets/antimicrobials.rds index e0b8c4702..3dd764c5f 100644 Binary files a/data-raw/datasets/antimicrobials.rds and b/data-raw/datasets/antimicrobials.rds differ diff --git a/data-raw/datasets/antimicrobials.sav b/data-raw/datasets/antimicrobials.sav index 988d398ef..bf62b41b1 100644 Binary files a/data-raw/datasets/antimicrobials.sav and b/data-raw/datasets/antimicrobials.sav differ diff --git a/data-raw/datasets/antimicrobials.txt b/data-raw/datasets/antimicrobials.txt index b2691f9d0..76ef1a26a 100644 --- a/data-raw/datasets/antimicrobials.txt +++ b/data-raw/datasets/antimicrobials.txt @@ -114,7 +114,7 @@ "CRD" 5284529 "Cefroxadine" "Cephalosporins (1st gen.)" "J01DB11,QJ01DB11" "Other beta-lactam antibacterials" "First-generation cephalosporins" "ceftix" "cefroxadin,cefroxadino,cefroxadinum,oraspor" 2.1 "g" "NA" "CFS" 656575 "Cefsulodin" "Cephalosporins (3rd gen.)" "J01DD03,QJ01DD03" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "cefsul,cfsl,cfsu" "cefomonil,cefonomil,cefsulodine,cefsulodinhydrate,cefsulodino,cefsulodinum,pseudocef,pseudomonil,pyocefal,sulcephalosporin,takesulin,tilmapor,ulfaret" 4 "g" "127-1,128-9,129-7,130-5,131-3,18892-0,25242-9,55647-2" "CSU" 68718 "Cefsumide" "Cephalosporins (unclassified gen.)" "NA" "NA" "cefsulmid,cefsumido,cefsumidum" "NA" -"CPT" 56841980 "Ceftaroline" "Cephalosporins (5th gen.)" "NA" "ceftar,cfro" "ceftaroine,teflaro,zinforo" "73604-1,73605-8,73626-4,73627-2,73649-6,73650-4,74170-2" +"CPT" 56841980 "Ceftaroline" "Cephalosporins (5th gen.)" "J01DI02,QJ01DI02" "ceftar,cfro" "ceftaroine,teflaro,zinforo" "73604-1,73605-8,73626-4,73627-2,73649-6,73650-4,74170-2" "CPA" "Ceftaroline/avibactam" "Cephalosporins (5th gen.)" "NA" "NA" "NA" "73604-1,73626-4,73649-6" "CAZ" 5481173 "Ceftazidime" "Cephalosporins (3rd gen.)" "J01DD02,QJ01DD02" "Other beta-lactam antibacterials" "Third-generation cephalosporins" "caz,cefta,ceftaz,cfta,cftz,taz,tz,xtz" "ceftazimide,ceptaz,fortam,fortaz,fortum,glazidim,kefazim,modacin,pentacef,tazicef,tizime" 4 "g" "101481-0,101482-8,101483-6,132-1,133-9,134-7,135-4,18893-8,21151-6,3449-6,35774-9,35775-6,35776-4,42352-5,55648-0,55649-8,55650-6,55651-4,58705-5,6995-5,73603-3,73625-6,73648-8,80960-8,87734-0,90850-9" "CZA" 90643431 "Ceftazidime/avibactam" "Cephalosporins (3rd gen.)" "J01DD52,QJ01DD52" "cfav" "avycaz,zavicefta" 6 "g" "101483-6,73603-3,73625-6,73648-8,87734-0" diff --git a/data-raw/datasets/antimicrobials.xlsx b/data-raw/datasets/antimicrobials.xlsx index 5e6cc3c32..fb66e5e0f 100644 Binary files a/data-raw/datasets/antimicrobials.xlsx and b/data-raw/datasets/antimicrobials.xlsx differ diff --git a/data/antimicrobials.rda b/data/antimicrobials.rda index 8c460457a..41426f2d3 100644 Binary files a/data/antimicrobials.rda and b/data/antimicrobials.rda differ diff --git a/man/AMR-deprecated.Rd b/man/AMR-deprecated.Rd index 9d9a9c63d..881d24955 100644 --- a/man/AMR-deprecated.Rd +++ b/man/AMR-deprecated.Rd @@ -8,9 +8,11 @@ \alias{ab_selector} \title{Deprecated Functions, Arguments, or Datasets} \format{ -An object of class \code{tbl_df} (inherits from \code{tbl}, \code{data.frame}) with 497 rows and 14 columns. +An object of class \code{deprecated_amr_dataset} (inherits from \code{tbl_df}, \code{tbl}, \code{data.frame}) with 497 rows and 14 columns. } \usage{ +antibiotics + ab_class(...) ab_selector(...)