mirror of
https://github.com/msberends/AMR.git
synced 2024-12-27 12:46:12 +01:00
Compare commits
No commits in common. "29756977cfcab269f2ebbcd8dd61d658a75c7652" and "ef8ef28650bd8705e33b77f4bef0aad37db7304a" have entirely different histories.
29756977cf
...
ef8ef28650
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9073
|
||||
Version: 2.1.1.9071
|
||||
Date: 2024-09-19
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 2.1.1.9073
|
||||
# AMR 2.1.1.9071
|
||||
|
||||
*(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://msberends.github.io/AMR/#latest-development-version).)*
|
||||
|
||||
|
17
R/sir.R
17
R/sir.R
@ -623,7 +623,7 @@ as.sir.data.frame <- function(x,
|
||||
}
|
||||
|
||||
# -- host
|
||||
if (missing(breakpoint_type) && any(host %in% clinical_breakpoints$host[!clinical_breakpoints$host %in% c("human", "ECOFF")], na.rm = TRUE)) {
|
||||
if (missing(breakpoint_type) && any(host %in% AMR_env$host_preferred_order, 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,7 +865,16 @@ 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
|
||||
}
|
||||
@ -920,9 +929,9 @@ as_sir_method <- function(method_short,
|
||||
# get host
|
||||
if (breakpoint_type == "animal") {
|
||||
if (is.null(host)) {
|
||||
host <- "dogs"
|
||||
host <- AMR_env$host_preferred_order[1]
|
||||
if (message_not_thrown_before("as.sir", "host_missing")) {
|
||||
message_("Animal hosts not set in `host`, assuming `host = \"dogs\"`, since these have the highest breakpoint availability.\n\n")
|
||||
message_("Animal hosts not set in `host`, assuming `host = \"", host, "\"`, since these have the highest breakpoint availability.\n\n")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
2
R/zzz.R
2
R/zzz.R
@ -205,6 +205,8 @@ 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) {
|
||||
|
@ -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", "mycobank", "gbif", "group_members"
|
||||
"url", "ref", "snomed", "lpsn", "gbif", "group_members"
|
||||
))
|
||||
expect_inherits(mo_info(c("Escherichia coli", "Staphylococcus aureus")), "list")
|
||||
expect_true(length(mo_group_members("B_HACEK")) > 1)
|
||||
|
@ -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 2023")
|
||||
out_vet <- as.sir(vet, host = vet$animal, guideline = "CLSI")
|
||||
# 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", 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)))
|
||||
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")))
|
||||
|
||||
out_vet <- as.sir(vet, host = "animal", guideline = "EUCAST 2023")
|
||||
expect_identical(out_vet$PRA, rep(NA_sir_, 11))
|
||||
@ -327,10 +327,9 @@ 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", "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"))
|
||||
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"))
|
||||
|
||||
# ECOFF -------------------------------------------------------------------
|
||||
|
||||
|
@ -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 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$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$SNOMED$citation` URL: <`r AMR:::TAXONOMY_VERSION$SNOMED$url`>
|
||||
|
||||
### Example content
|
||||
|
Loading…
Reference in New Issue
Block a user