diff --git a/R/sir.R b/R/sir.R index 158377aa..24e7a7ab 100755 --- a/R/sir.R +++ b/R/sir.R @@ -623,7 +623,7 @@ as.sir.data.frame <- function(x, } # -- host - if (missing(breakpoint_type) && any(host %in% AMR_env$host_preferred_order, na.rm = TRUE)) { + if (missing(breakpoint_type) && any(host %in% clinical_breakpoints$host[!clinical_breakpoints$host %in% c("human", "ECOFF")], na.rm = TRUE)) { message_("Assuming `breakpoint_type = \"animal\"` since `host` contains animal species.") breakpoint_type <- "animal" } else if (any(!suppressMessages(convert_host(host)) %in% c("human", "ECOFF"), na.rm = TRUE)) { @@ -865,16 +865,7 @@ convert_host <- function(x, lang = get_AMR_locale()) { x_out[is.na(x_out) & (x %like% "sheep|ovine" | x %like% translate_AMR("sheep|sheeps|ovine", lang))] <- "sheep" x_out[is.na(x_out) & (x %like% "snake|serpentine" | x %like% translate_AMR("snake|snakes|serpentine", lang))] <- "snakes" x_out[is.na(x_out) & (x %like% "turkey|meleagrine" | x %like% translate_AMR("turkey|turkeys|meleagrine", lang))] <- "turkey" - if (any(x_out %in% c(NA_character_, "animal"))) { - x_out[is.na(x_out) & x == "animal"] <- AMR_env$host_preferred_order[1] - if (message_not_thrown_before("as.sir", "convert_host_missing")) { - message_(ifelse(any(is.na(x_out) & !is.na(x), na.rm = TRUE), - paste0("The following host(s) are invalid: ", vector_and(x[is.na(x_out) & !is.na(x)]), ". "), - ""), - "For missing animal hosts, assuming \"", AMR_env$host_preferred_order[1], "\", since these have the highest breakpoint availability.") - x_out[is.na(x_out)] <- AMR_env$host_preferred_order[1] - } - } + x_out[x_out == "ecoff"] <- "ECOFF" x_out } @@ -929,9 +920,9 @@ as_sir_method <- function(method_short, # get host if (breakpoint_type == "animal") { if (is.null(host)) { - host <- AMR_env$host_preferred_order[1] + host <- "dogs" if (message_not_thrown_before("as.sir", "host_missing")) { - message_("Animal hosts not set in `host`, assuming `host = \"", host, "\"`, since these have the highest breakpoint availability.\n\n") + message_("Animal hosts not set in `host`, assuming `host = \"dogs\"`, since these have the highest breakpoint availability.\n\n") } } } else { diff --git a/R/zzz.R b/R/zzz.R index 2dcb0bf4..d6112a58 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -205,8 +205,6 @@ AMR_env$cli_abort <- import_fn("cli_abort", "cli", error_on_fail = FALSE) # they cannot be part of R/sysdata.rda since CRAN thinks it would make the package too large (+3 MB) AMR_env$AB_lookup <- cbind(AMR::antibiotics, AB_LOOKUP) AMR_env$AV_lookup <- cbind(AMR::antivirals, AV_LOOKUP) - - AMR_env$host_preferred_order <- names(sort(table(AMR::clinical_breakpoints$host[!AMR::clinical_breakpoints$host %in% AMR::clinical_breakpoints$type]), decreasing = TRUE)) } .onAttach <- function(lib, pkg) { diff --git a/inst/tinytest/test-mo_property.R b/inst/tinytest/test-mo_property.R index 0051c6b7..02492b37 100644 --- a/inst/tinytest/test-mo_property.R +++ b/inst/tinytest/test-mo_property.R @@ -97,7 +97,7 @@ expect_equal(names(mo_info("Escherichia coli")), c( "mo", "kingdom", "phylum", "class", "order", "family", "genus", "species", "subspecies", "status", "synonyms", "gramstain", "oxygen_tolerance", - "url", "ref", "snomed", "lpsn", "gbif", "group_members" + "url", "ref", "snomed", "lpsn", "mycobank", "gbif", "group_members" )) expect_inherits(mo_info(c("Escherichia coli", "Staphylococcus aureus")), "list") expect_true(length(mo_group_members("B_HACEK")) > 1) diff --git a/inst/tinytest/test-sir.R b/inst/tinytest/test-sir.R index cfd6667b..39a0c55d 100644 --- a/inst/tinytest/test-sir.R +++ b/inst/tinytest/test-sir.R @@ -312,14 +312,14 @@ vet <- data.frame(animal = c(rep("cat", 3), rep("dogs", 3), "canine", "equine", FLR = mics, mo = mo_name(rep(c("B_ESCHR_COLI", "B_PSTRL_MLTC", "B_MNNHM_HMLY"), 4)[-1])) -out_vet <- as.sir(vet, host = vet$animal, guideline = "CLSI") +out_vet <- as.sir(vet, host = vet$animal, guideline = "CLSI 2023") # host column name instead of values expect_identical(out_vet, as.sir(vet, host = "animal", guideline = "CLSI 2023")) # check outcomes -expect_identical(out_vet$PRA, as.sir(c("S", NA, "S", "R", NA, "R", "R", NA, "R", "R", NA))) -expect_identical(out_vet$FLR, as.sir(c("S", "S", NA, "S", "S", NA, "I", "R", NA, "R", "R"))) +expect_identical(out_vet$PRA, as.sir(c("S", NA, "S", NA, NA, "R", NA, NA, NA, "I", NA))) +expect_identical(out_vet$FLR, as.sir(c(NA, NA, NA, NA, NA, NA, NA, NA, NA, "R", NA))) out_vet <- as.sir(vet, host = "animal", guideline = "EUCAST 2023") expect_identical(out_vet$PRA, rep(NA_sir_, 11)) @@ -327,9 +327,10 @@ expect_identical(out_vet$FLR, as.sir(c("S", "S", NA, "S", "S", NA, "I", "R", NA, sir_history <- sir_interpretation_history() expect_identical(sort(sir_history$host), - c("cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", - "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "dogs", - "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "horse", "horse", "horse", "horse", "horse", "poultry","poultry")) + c("cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", "cats", + "cats", "cats", "cats", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "cattle", "dogs", + "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", "dogs", + "horse", "horse", "horse", "horse", "horse", "horse", "horse", "horse", "horse", "poultry","poultry","poultry","poultry")) # ECOFF ------------------------------------------------------------------- diff --git a/vignettes/datasets.Rmd b/vignettes/datasets.Rmd index 7611e80b..d4dd9bd2 100644 --- a/vignettes/datasets.Rmd +++ b/vignettes/datasets.Rmd @@ -131,10 +131,10 @@ The tab-separated text file and Microsoft Excel workbook both contain all SNOMED This data set contains the full microbial taxonomy of `r AMR:::nr2char(length(unique(AMR::microorganisms$kingdom[!AMR::microorganisms$kingdom %like% "unknown"])))` kingdoms from the `r AMR:::TAXONOMY_VERSION$LPSN$name`, `r AMR:::TAXONOMY_VERSION$MycoBank$name`, and the `r AMR:::TAXONOMY_VERSION$GBIF$name`: -* `r AMR:::TAXONOMY_VERSION$LPSN$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$LPSN$url`> on `r documentation_date(AMR:::TAXONOMY_VERSION$LPSN$accessed_date)`. -* `r AMR:::TAXONOMY_VERSION$MycoBank$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$MycoBank$url`> on `r documentation_date(AMR:::TAXONOMY_VERSION$MycoBank$accessed_date)`. -* `r AMR:::TAXONOMY_VERSION$GBIF$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$GBIF$url`> on `r documentation_date(AMR:::TAXONOMY_VERSION$GBIF$accessed_date)`. -* `r AMR:::TAXONOMY_VERSION$BacDive$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$BacDive$url`> on `r documentation_date(AMR:::TAXONOMY_VERSION$BacDive$accessed_date)`. +* `r AMR:::TAXONOMY_VERSION$LPSN$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$LPSN$url`> on `r AMR:::documentation_date(AMR:::TAXONOMY_VERSION$LPSN$accessed_date)`. +* `r AMR:::TAXONOMY_VERSION$MycoBank$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$MycoBank$url`> on `r AMR:::documentation_date(AMR:::TAXONOMY_VERSION$MycoBank$accessed_date)`. +* `r AMR:::TAXONOMY_VERSION$GBIF$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$GBIF$url`> on `r AMR:::documentation_date(AMR:::TAXONOMY_VERSION$GBIF$accessed_date)`. +* `r AMR:::TAXONOMY_VERSION$BacDive$citation` Accessed from <`r AMR:::TAXONOMY_VERSION$BacDive$url`> on `r AMR:::documentation_date(AMR:::TAXONOMY_VERSION$BacDive$accessed_date)`. * `r AMR:::TAXONOMY_VERSION$SNOMED$citation` URL: <`r AMR:::TAXONOMY_VERSION$SNOMED$url`> ### Example content