mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 16:02:02 +02:00
(v1.1.0.9010) lose dependencies
This commit is contained in:
@ -520,7 +520,7 @@ eucast_rules <- function(x,
|
||||
x[, col_mo] <- as.mo(x[, col_mo, drop = TRUE])
|
||||
x <- x %>%
|
||||
left_join_microorganisms(by = col_mo, suffix = c("_oldcols", ""))
|
||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE])
|
||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||
x$genus_species <- paste(x$genus, x$species)
|
||||
|
||||
if (ab_missing(AMP) & !ab_missing(AMX)) {
|
||||
@ -658,7 +658,7 @@ eucast_rules <- function(x,
|
||||
rule_group_current %like% "expert",
|
||||
paste0("\nEUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (",
|
||||
font_red(paste0("v", EUCAST_VERSION_EXPERT_RULES)), ")\n"),
|
||||
"\nOther rules by this AMR package\n"))))
|
||||
"\nOther rules by this AMR package (turn on/off with 'rules' parameter)\n"))))
|
||||
}
|
||||
# Print rule -------------------------------------------------------------
|
||||
if (rule_current != rule_previous) {
|
||||
@ -678,32 +678,27 @@ eucast_rules <- function(x,
|
||||
like_is_one_of <- eucast_rules_df[i, 2]
|
||||
|
||||
# be sure to comprise all coagulase-negative/-positive Staphylococci when they are mentioned
|
||||
if (eucast_rules_df[i, 3] %like% "coagulase-") {
|
||||
suppressWarnings(
|
||||
all_staph <- microorganisms %>%
|
||||
filter(genus == "Staphylococcus") %>%
|
||||
mutate(CNS_CPS = mo_name(mo, Becker = "all"))
|
||||
)
|
||||
if (eucast_rules_df[i, 3] %like% "coagulase-") {
|
||||
eucast_rules_df[i, 3] <- paste0("^(",
|
||||
paste0(all_staph %>%
|
||||
filter(CNS_CPS %like% "coagulase-negative") %>%
|
||||
pull(fullname),
|
||||
collapse = "|"),
|
||||
if (eucast_rules_df[i, 3] %like% "coagulase") {
|
||||
all_staph <- microorganisms[which(microorganisms$genus == "Staphylococcus"), ]
|
||||
all_staph$CNS_CPS <- suppressWarnings(mo_name(all_staph$mo, Becker = "all", language = NULL))
|
||||
if (eucast_rules_df[i, 3] %like% "coagulase") {
|
||||
eucast_rules_df[i, 3] <- paste0("^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "negative"),
|
||||
"fullname",
|
||||
drop = TRUE],
|
||||
collapse = "|"),
|
||||
")$")
|
||||
} else {
|
||||
eucast_rules_df[i, 3] <- paste0("^(",
|
||||
paste0(all_staph %>%
|
||||
filter(CNS_CPS %like% "coagulase-positive") %>%
|
||||
pull(fullname),
|
||||
collapse = "|"),
|
||||
eucast_rules_df[i, 3] <- paste0("^(", paste0(all_staph[which(all_staph$CNS_CPS %like% "positive"),
|
||||
"fullname",
|
||||
drop = TRUE],
|
||||
collapse = "|"),
|
||||
")$")
|
||||
}
|
||||
like_is_one_of <- "like"
|
||||
}
|
||||
|
||||
if (like_is_one_of == "is") {
|
||||
# so 'Enterococcus' will turn into '^Enterococcus$'
|
||||
# so e.g. 'Enterococcus' will turn into '^Enterococcus$'
|
||||
mo_value <- paste0("^", eucast_rules_df[i, 3], "$")
|
||||
} else if (like_is_one_of == "one_of") {
|
||||
# so 'Clostridium, Actinomyces, ...' will turn into '^(Clostridium|Actinomyces|...)$'
|
||||
|
@ -79,8 +79,8 @@ guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE) {
|
||||
if (search_string.ab %in% colnames(x)) {
|
||||
ab_result <- colnames(x)[colnames(x) == search_string.ab][1L]
|
||||
|
||||
} else if (any(tolower(colnames(x)) %in% tolower(unlist(ab_property(search_string.ab, "abbreviations"))))) {
|
||||
ab_result <- colnames(x)[tolower(colnames(x)) %in% tolower(unlist(ab_property(search_string.ab, "abbreviations")))][1L]
|
||||
} else if (any(tolower(colnames(x)) %in% tolower(unlist(ab_property(search_string.ab, "abbreviations", language = NULL))))) {
|
||||
ab_result <- colnames(x)[tolower(colnames(x)) %in% tolower(unlist(ab_property(search_string.ab, "abbreviations", language = NULL)))][1L]
|
||||
|
||||
} else {
|
||||
# sort colnames on length - longest first
|
||||
@ -96,13 +96,13 @@ guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE) {
|
||||
if (length(ab_result) == 0) {
|
||||
if (verbose == TRUE) {
|
||||
message(paste0("No column found as input for `", search_string,
|
||||
"` (", ab_name(search_string, language = "en", tolower = TRUE), ")."))
|
||||
"` (", ab_name(search_string, language = NULL, tolower = TRUE), ")."))
|
||||
}
|
||||
return(NULL)
|
||||
} else {
|
||||
if (verbose == TRUE) {
|
||||
message(font_blue(paste0("NOTE: Using column `", font_bold(ab_result), "` as input for `", search_string,
|
||||
"` (", ab_name(search_string, language = "en", tolower = TRUE), ").")))
|
||||
"` (", ab_name(search_string, language = NULL, tolower = TRUE), ").")))
|
||||
}
|
||||
return(ab_result)
|
||||
}
|
||||
@ -173,11 +173,11 @@ get_column_abx <- function(x,
|
||||
for (i in seq_len(length(x))) {
|
||||
if (verbose == TRUE & !names(x[i]) %in% names(duplicates)) {
|
||||
message(font_blue(paste0("NOTE: Using column `", font_bold(x[i]), "` as input for `", names(x)[i],
|
||||
"` (", ab_name(names(x)[i], tolower = TRUE), ").")))
|
||||
"` (", ab_name(names(x)[i], tolower = TRUE, language = NULL), ").")))
|
||||
}
|
||||
if (names(x[i]) %in% names(duplicates)) {
|
||||
warning(font_red(paste0("Using column `", font_bold(x[i]), "` as input for `", names(x)[i],
|
||||
"` (", ab_name(names(x)[i], tolower = TRUE),
|
||||
"` (", ab_name(names(x)[i], tolower = TRUE, language = NULL),
|
||||
"), although it was matched for multiple antibiotics or columns.")),
|
||||
call. = FALSE,
|
||||
immediate. = verbose)
|
||||
@ -210,7 +210,7 @@ get_column_abx <- function(x,
|
||||
}
|
||||
|
||||
generate_warning_abs_missing <- function(missing, any = FALSE) {
|
||||
missing <- paste0(missing, " (", ab_name(missing, tolower = TRUE), ")")
|
||||
missing <- paste0(missing, " (", ab_name(missing, tolower = TRUE, language = NULL), ")")
|
||||
if (any == TRUE) {
|
||||
any_txt <- c(" any of", "is")
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user