diff --git a/DESCRIPTION b/DESCRIPTION index 0838f154..fa182d3b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9008 +Version: 2.1.1.9009 Date: 2024-02-24 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 6b0b1c92..a7a38e7a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9008 +# AMR 2.1.1.9009 *(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!)* diff --git a/R/aa_globals.R b/R/aa_globals.R index 3b519054..cd832ee5 100755 --- a/R/aa_globals.R +++ b/R/aa_globals.R @@ -86,8 +86,8 @@ EUCAST_VERSION_EXPERT_RULES <- list( TAXONOMY_VERSION <- list( GBIF = list( - accessed_date = as.Date("2022-12-11"), - citation = "GBIF Secretariat (2022). GBIF Backbone Taxonomy. Checklist dataset \\doi{10.15468/39omei}.", + accessed_date = as.Date("2024-01-08"), + citation = "GBIF Secretariat (2023). GBIF Backbone Taxonomy. Checklist dataset \\doi{10.15468/39omei}.", url = "https://www.gbif.org" ), LPSN = list( @@ -146,6 +146,8 @@ globalVariables(c( "group", "guideline", "hjust", + "host_index", + "host_match", "input", "intrinsic_resistant", "isolates", diff --git a/R/sir.R b/R/sir.R index b5648640..c42018b5 100755 --- a/R/sir.R +++ b/R/sir.R @@ -526,7 +526,7 @@ as.sir.data.frame <- function(x, meet_criteria(include_screening, allow_class = "logical", has_length = 1) meet_criteria(include_PKPD, allow_class = "logical", has_length = 1) meet_criteria(breakpoint_type, allow_class = "character", is_in = reference_data$type, has_length = 1) - meet_criteria(host, allow_class = "character", allow_NULL = TRUE, allow_NA = TRUE) + meet_criteria(host, allow_class = c("character", "factor"), allow_NULL = TRUE, allow_NA = TRUE) x.bak <- x for (i in seq_len(ncol(x))) { # don't keep factors, overwriting them is hard @@ -545,8 +545,8 @@ as.sir.data.frame <- function(x, if (breakpoint_type == "animal") { if (is.null(host)) { host <- search_type_in_df(x = x, type = "host", add_col_prefix = FALSE) - } else if (length(host) == 1 && host %in% colnames(x)) { - host <- x[[host]] + } else if (length(host) == 1 && as.character(host) %in% colnames(x)) { + host <- x[[as.character(host)]] } } @@ -745,7 +745,7 @@ get_guideline <- function(guideline, reference_data) { } convert_host <- function(x, lang = get_AMR_locale()) { - x <- trimws2(tolower(x)) + x <- trimws2(tolower(as.character(x))) x_out <- rep(NA_character_, length(x)) # this order is based on: clinical_breakpoints |> filter(type == "animal") |> count(host, sort = TRUE) x_out[is.na(x_out) & (x %like% "dog|canine" | x %like% translate_AMR("dog|dogs|canine", lang))] <- "dogs" @@ -785,7 +785,7 @@ as_sir_method <- function(method_short, meet_criteria(include_PKPD, allow_class = "logical", has_length = 1, .call_depth = -2) check_reference_data(reference_data, .call_depth = -2) meet_criteria(breakpoint_type, allow_class = "character", is_in = reference_data$type, has_length = 1, .call_depth = -2) - meet_criteria(host, allow_class = "character", allow_NULL = TRUE, allow_NA = TRUE, .call_depth = -2) + meet_criteria(host, allow_class = c("character", "factor"), allow_NULL = TRUE, allow_NA = TRUE, .call_depth = -2) # backward compatibilty dots <- list(...) @@ -804,7 +804,7 @@ as_sir_method <- function(method_short, } } } else { - if (!is.null(host) && !all(toupper(host) %in% c("HUMAN", "ECOFF"))) { + if (!is.null(host) && !all(toupper(as.character(host)) %in% c("HUMAN", "ECOFF"))) { if (message_not_thrown_before("as.sir", "assumed_breakpoint_animal")) { message_("Assuming `breakpoint_type = \"animal\"`, since `host` is set.", ifelse(guideline_coerced %like% "EUCAST", " Do you also need to set `guideline = \"CLSI\"`?", ""), "\n\n") }