mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 08:06:12 +01:00
(v1.4.0.9011) message formatting
This commit is contained in:
parent
98773aa859
commit
5a607abb36
26
.github/workflows/check.yaml
vendored
26
.github/workflows/check.yaml
vendored
@ -50,18 +50,20 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
config:
|
config:
|
||||||
- {os: macOS-latest, r: 'devel', allowfail = false}
|
- {os: macOS-latest, r: 'devel', allowfail: false}
|
||||||
- {os: macOS-latest, r: 'release', allowfail = false}
|
- {os: macOS-latest, r: 'release', allowfail: false}
|
||||||
- {os: macOS-latest, r: 'oldrel', allowfail = false}
|
- {os: macOS-latest, r: 'oldrel', allowfail: false}
|
||||||
- {os: windows-latest, r: 'devel', allowfail = false}
|
- {os: windows-latest, r: 'devel', allowfail: false}
|
||||||
- {os: windows-latest, r: 'release', allowfail = false}
|
- {os: windows-latest, r: 'release', allowfail: false}
|
||||||
- {os: windows-latest, r: 'oldrel', allowfail = false}
|
- {os: windows-latest, r: 'oldrel', allowfail: false}
|
||||||
- {os: ubuntu-16.04, r: 'release', allowfail = false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: 'devel', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '4.0', allowfail = false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: 'release', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.6', allowfail = false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: 'oldrel', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.5', allowfail = false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '4.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.4', allowfail = true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.6', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
- {os: ubuntu-16.04, r: '3.3', allowfail = true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
- {os: ubuntu-16.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
|
- {os: ubuntu-16.04, r: '3.4', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
|
- {os: ubuntu-16.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||||
|
|
||||||
env:
|
env:
|
||||||
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 1.4.0.9009
|
Version: 1.4.0.9011
|
||||||
Date: 2020-10-26
|
Date: 2020-10-27
|
||||||
Title: Antimicrobial Resistance Analysis
|
Title: Antimicrobial Resistance Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(role = c("aut", "cre"),
|
person(role = c("aut", "cre"),
|
||||||
|
4
NEWS.md
4
NEWS.md
@ -1,5 +1,5 @@
|
|||||||
# AMR 1.4.0.9009
|
# AMR 1.4.0.9011
|
||||||
## <small>Last updated: 26 October 2020</small>
|
## <small>Last updated: 27 October 2020</small>
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Functions `is_gram_negative()` and `is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE`, thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
|
* Functions `is_gram_negative()` and `is_gram_positive()` as wrappers around `mo_gramstain()`. They always return `TRUE` or `FALSE`, thus always return `FALSE` for species outside the taxonomic kingdom of Bacteria.
|
||||||
|
@ -209,19 +209,20 @@ search_type_in_df <- function(x, type, info = TRUE) {
|
|||||||
if (!is.null(found)) {
|
if (!is.null(found)) {
|
||||||
# this column should contain logicals
|
# this column should contain logicals
|
||||||
if (!is.logical(x[, found, drop = TRUE])) {
|
if (!is.logical(x[, found, drop = TRUE])) {
|
||||||
message(font_red(paste0("NOTE: Column `", font_bold(found), "` found as input for `col_", type,
|
message_("Column `", font_bold(found), "` found as input for `col_", type,
|
||||||
"`, but this column does not contain 'logical' values (TRUE/FALSE) and was ignored.")))
|
"`, but this column does not contain 'logical' values (TRUE/FALSE) and was ignored.",
|
||||||
|
add_fn = font_red)
|
||||||
found <- NULL
|
found <- NULL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is.null(found) & info == TRUE) {
|
if (!is.null(found) & info == TRUE) {
|
||||||
msg <- paste0("NOTE: Using column `", font_bold(found), "` as input for `col_", type, "`.")
|
msg <- paste0("Using column `", font_bold(found), "` as input for `col_", type, "`.")
|
||||||
if (type %in% c("keyantibiotics", "specimen")) {
|
if (type %in% c("keyantibiotics", "specimen")) {
|
||||||
msg <- paste(msg, "Use", font_bold(paste0("col_", type), "= FALSE"), "to prevent this.")
|
msg <- paste(msg, "Use", font_bold(paste0("col_", type), "= FALSE"), "to prevent this.")
|
||||||
}
|
}
|
||||||
message(font_blue(msg))
|
message_(msg)
|
||||||
}
|
}
|
||||||
found
|
found
|
||||||
}
|
}
|
||||||
@ -297,6 +298,8 @@ message_ <- function(..., appendLF = TRUE, add_fn = list(font_blue), as_note = T
|
|||||||
|
|
||||||
if (msg_stripped %like% "^NOTE: ") {
|
if (msg_stripped %like% "^NOTE: ") {
|
||||||
indentation <- 6
|
indentation <- 6
|
||||||
|
} else if (msg_stripped %like% "^=> ") {
|
||||||
|
indentation <- 3
|
||||||
} else {
|
} else {
|
||||||
indentation <- 0
|
indentation <- 0
|
||||||
}
|
}
|
||||||
|
4
R/ab.R
4
R/ab.R
@ -123,8 +123,8 @@ as.ab <- function(x, flag_multiple_results = TRUE, info = TRUE, ...) {
|
|||||||
abnames <- abnames[!abnames == "clavulanic acid"]
|
abnames <- abnames[!abnames == "clavulanic acid"]
|
||||||
}
|
}
|
||||||
if (length(abnames) > 1) {
|
if (length(abnames) > 1) {
|
||||||
message(font_blue(paste0("NOTE: more than one result was found for item ", index, ": ",
|
message_("More than one result was found for item ", index, ": ",
|
||||||
paste0(abnames, collapse = ", "))))
|
paste0(abnames, collapse = ", "))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
found[1L]
|
found[1L]
|
||||||
|
@ -158,7 +158,7 @@ ab_selector <- function(ab_class, function_name) {
|
|||||||
ab_in_data <- get_column_abx(vars_df, info = FALSE)
|
ab_in_data <- get_column_abx(vars_df, info = FALSE)
|
||||||
|
|
||||||
if (length(ab_in_data) == 0) {
|
if (length(ab_in_data) == 0) {
|
||||||
message(font_blue("NOTE: no antimicrobial agents found."))
|
message_("No antimicrobial agents found.")
|
||||||
return(NULL)
|
return(NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,13 +176,13 @@ ab_selector <- function(ab_class, function_name) {
|
|||||||
# get the columns with a group names in the chosen ab class
|
# get the columns with a group names in the chosen ab class
|
||||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||||
if (length(agents) == 0) {
|
if (length(agents) == 0) {
|
||||||
message(font_blue(paste0("NOTE: No antimicrobial agents of class ", ab_group,
|
message_("No antimicrobial agents of class ", ab_group, " found", examples, ".")
|
||||||
" found", examples, ".")))
|
|
||||||
} else {
|
} else {
|
||||||
message(font_blue(paste0("Selecting ", ab_group, ": ",
|
message_("Selecting ", ab_group, ": ",
|
||||||
paste(paste0("`", font_bold(agents, collapse = NULL),
|
paste(paste0("`", font_bold(agents, collapse = NULL),
|
||||||
"` (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
"` (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
||||||
collapse = ", "))))
|
collapse = ", "),
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
unname(agents)
|
unname(agents)
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,9 @@ atc_online_property <- function(atc_code,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!has_internet()) {
|
if (!has_internet()) {
|
||||||
message("There appears to be no internet connection, returning NA.")
|
message_("There appears to be no internet connection, returning NA.",
|
||||||
|
add_fn = font_red,
|
||||||
|
as_note = FALSE)
|
||||||
return(rep(NA, length(atc_code)))
|
return(rep(NA, length(atc_code)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,5 +245,5 @@ print.bug_drug_combinations <- function(x, ...) {
|
|||||||
x_class <- class(x)
|
x_class <- class(x)
|
||||||
print(structure(x, class = x_class[x_class != "bug_drug_combinations"]),
|
print(structure(x, class = x_class[x_class != "bug_drug_combinations"]),
|
||||||
...)
|
...)
|
||||||
message(font_blue("NOTE: Use 'format()' on this result to get a publishable/printable format."))
|
message_("Use 'format()' on this result to get a publishable/printable format.", as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ eucast_rules <- function(x,
|
|||||||
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
|
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
|
||||||
}
|
}
|
||||||
if (q_continue %in% c(FALSE, 2)) {
|
if (q_continue %in% c(FALSE, 2)) {
|
||||||
message("Cancelled, returning original data")
|
message_("Cancelled, returning original data", add_fn = font_red, as_note = FALSE)
|
||||||
return(x)
|
return(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -443,14 +443,14 @@ eucast_rules <- function(x,
|
|||||||
if (ab_missing(AMP) & !ab_missing(AMX)) {
|
if (ab_missing(AMP) & !ab_missing(AMX)) {
|
||||||
# ampicillin column is missing, but amoxicillin is available
|
# ampicillin column is missing, but amoxicillin is available
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue(paste0("NOTE: Using column `", font_bold(AMX), "` as input for ampicillin since many EUCAST rules depend on it.")))
|
message_("Using column `", font_bold(AMX), "` as input for ampicillin since many EUCAST rules depend on it.")
|
||||||
}
|
}
|
||||||
AMP <- AMX
|
AMP <- AMX
|
||||||
}
|
}
|
||||||
|
|
||||||
# data preparation ----
|
# data preparation ----
|
||||||
if (info == TRUE & NROW(x) > 10000) {
|
if (info == TRUE & NROW(x) > 10000) {
|
||||||
message(font_blue("NOTE: Preparing data..."), appendLF = FALSE)
|
message_("Preparing data...", appendLF = FALSE, as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
# nolint start
|
# nolint start
|
||||||
@ -583,7 +583,7 @@ eucast_rules <- function(x,
|
|||||||
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
x$gramstain <- mo_gramstain(x[, col_mo, drop = TRUE], language = NULL)
|
||||||
x$genus_species <- paste(x$genus, x$species)
|
x$genus_species <- paste(x$genus, x$species)
|
||||||
if (info == TRUE & NROW(x) > 10000) {
|
if (info == TRUE & NROW(x) > 10000) {
|
||||||
message(font_blue("OK."))
|
message_("OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (any(x$genus == "Staphylococcus", na.rm = TRUE)) {
|
if (any(x$genus == "Staphylococcus", na.rm = TRUE)) {
|
||||||
|
@ -108,7 +108,7 @@ filter_ab_class <- function(x,
|
|||||||
# get all columns in data with names that resemble antibiotics
|
# get all columns in data with names that resemble antibiotics
|
||||||
ab_in_data <- get_column_abx(x, info = FALSE)
|
ab_in_data <- get_column_abx(x, info = FALSE)
|
||||||
if (length(ab_in_data) == 0) {
|
if (length(ab_in_data) == 0) {
|
||||||
message(font_blue("NOTE: no columns with class <rsi> found (see ?as.rsi), data left unchanged."))
|
message_("No columns with class <rsi> found (see ?as.rsi), data left unchanged.")
|
||||||
return(x.bak)
|
return(x.bak)
|
||||||
}
|
}
|
||||||
# get reference data
|
# get reference data
|
||||||
@ -122,15 +122,15 @@ filter_ab_class <- function(x,
|
|||||||
atc_group2 %like% ab_class)
|
atc_group2 %like% ab_class)
|
||||||
ab_group <- find_ab_group(ab_class)
|
ab_group <- find_ab_group(ab_class)
|
||||||
if (ab_group == "") {
|
if (ab_group == "") {
|
||||||
message(font_blue(paste0("NOTE: unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")))
|
message_("Unknown antimicrobial class '", ab_class.bak, "', data left unchanged.")
|
||||||
return(x.bak)
|
return(x.bak)
|
||||||
}
|
}
|
||||||
# get the columns with a group names in the chosen ab class
|
# get the columns with a group names in the chosen ab class
|
||||||
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
agents <- ab_in_data[names(ab_in_data) %in% ab_reference$ab]
|
||||||
if (length(agents) == 0) {
|
if (length(agents) == 0) {
|
||||||
message(font_blue(paste0("NOTE: no antimicrobial agents of class ", ab_group,
|
message_("NOTE: no antimicrobial agents of class ", ab_group,
|
||||||
" found (such as ", find_ab_names(ab_class, 2),
|
" found (such as ", find_ab_names(ab_class, 2),
|
||||||
"), data left unchanged.")))
|
"), data left unchanged.")
|
||||||
return(x.bak)
|
return(x.bak)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,11 +158,11 @@ filter_ab_class <- function(x,
|
|||||||
# sort columns on official name
|
# sort columns on official name
|
||||||
agents <- agents[order(ab_name(names(agents), language = NULL))]
|
agents <- agents[order(ab_name(names(agents), language = NULL))]
|
||||||
|
|
||||||
message(font_blue(paste0("Filtering on ", ab_group, ": ", scope,
|
message_("Filtering on ", ab_group, ": ", scope,
|
||||||
paste(paste0("`", font_bold(agents, collapse = NULL),
|
paste(paste0("`", font_bold(agents, collapse = NULL),
|
||||||
"` (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
"` (", ab_name(names(agents), tolower = TRUE, language = NULL), ")"),
|
||||||
collapse = scope_txt),
|
collapse = scope_txt),
|
||||||
operator, toString(result))))
|
operator, toString(result), as_note = FALSE)
|
||||||
x_transposed <- as.list(as.data.frame(t(x[, agents, drop = FALSE])))
|
x_transposed <- as.list(as.data.frame(t(x[, agents, drop = FALSE])))
|
||||||
filtered <- sapply(x_transposed, function(y) scope_fn(y %in% result, na.rm = TRUE))
|
filtered <- sapply(x_transposed, function(y) scope_fn(y %in% result, na.rm = TRUE))
|
||||||
x <- x[which(filtered), , drop = FALSE]
|
x <- x[which(filtered), , drop = FALSE]
|
||||||
|
@ -201,7 +201,7 @@ first_isolate <- function(x,
|
|||||||
# WHONET support
|
# WHONET support
|
||||||
x$patient_id <- paste(x$`First name`, x$`Last name`, x$Sex)
|
x$patient_id <- paste(x$`First name`, x$`Last name`, x$Sex)
|
||||||
col_patient_id <- "patient_id"
|
col_patient_id <- "patient_id"
|
||||||
message(font_blue(paste0("NOTE: Using combined columns `", font_bold("First name"), "`, `", font_bold("Last name"), "` and `", font_bold("Sex"), "` as input for `col_patient_id`")))
|
message_("Using combined columns `", font_bold("First name"), "`, `", font_bold("Last name"), "` and `", font_bold("Sex"), "` as input for `col_patient_id`")
|
||||||
} else {
|
} else {
|
||||||
col_patient_id <- search_type_in_df(x = x, type = "patient_id")
|
col_patient_id <- search_type_in_df(x = x, type = "patient_id")
|
||||||
}
|
}
|
||||||
@ -250,7 +250,9 @@ first_isolate <- function(x,
|
|||||||
}
|
}
|
||||||
# remove testcodes
|
# remove testcodes
|
||||||
if (!is.null(testcodes_exclude) & info == TRUE) {
|
if (!is.null(testcodes_exclude) & info == TRUE) {
|
||||||
message(font_black(paste0("[Criterion] Exclude test codes: ", toString(paste0("'", testcodes_exclude, "'")))))
|
message_("[Criterion] Exclude test codes: ", toString(paste0("'", testcodes_exclude, "'")),
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is.null(col_specimen)) {
|
if (is.null(col_specimen)) {
|
||||||
@ -261,7 +263,9 @@ first_isolate <- function(x,
|
|||||||
if (!is.null(specimen_group)) {
|
if (!is.null(specimen_group)) {
|
||||||
check_columns_existance(col_specimen, x)
|
check_columns_existance(col_specimen, x)
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_black(paste0("[Criterion] Exclude other than specimen group '", specimen_group, "'")))
|
message_("[Criterion] Exclude other than specimen group '", specimen_group, "'",
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is.null(col_keyantibiotics)) {
|
if (!is.null(col_keyantibiotics)) {
|
||||||
@ -298,7 +302,7 @@ first_isolate <- function(x,
|
|||||||
# no isolates found
|
# no isolates found
|
||||||
if (abs(row.start) == Inf | abs(row.end) == Inf) {
|
if (abs(row.start) == Inf | abs(row.end) == Inf) {
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(paste("=> Found", font_bold("no isolates")))
|
message_("=> Found ", font_bold("no isolates"), as_note = FALSE)
|
||||||
}
|
}
|
||||||
return(rep(FALSE, nrow(x)))
|
return(rep(FALSE, nrow(x)))
|
||||||
}
|
}
|
||||||
@ -350,13 +354,17 @@ first_isolate <- function(x,
|
|||||||
weighted.notice <- "weighted "
|
weighted.notice <- "weighted "
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
if (type == "keyantibiotics") {
|
if (type == "keyantibiotics") {
|
||||||
message(font_black(paste0("[Criterion] Base inclusion on key antibiotics, ",
|
message_("[Criterion] Base inclusion on key antibiotics, ",
|
||||||
ifelse(ignore_I == FALSE, "not ", ""),
|
ifelse(ignore_I == FALSE, "not ", ""),
|
||||||
"ignoring I")))
|
"ignoring I",
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
if (type == "points") {
|
if (type == "points") {
|
||||||
message(font_black(paste0("[Criterion] Base inclusion on key antibiotics, using points threshold of "
|
message_("[Criterion] Base inclusion on key antibiotics, using points threshold of "
|
||||||
, points_threshold)))
|
, points_threshold,
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
type_param <- type
|
type_param <- type
|
||||||
@ -393,10 +401,14 @@ first_isolate <- function(x,
|
|||||||
}
|
}
|
||||||
if (!is.null(col_icu)) {
|
if (!is.null(col_icu)) {
|
||||||
if (icu_exclude == TRUE) {
|
if (icu_exclude == TRUE) {
|
||||||
message(font_black("[Criterion] Exclude isolates from ICU.\n"))
|
message_("[Criterion] Exclude isolates from ICU.",
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
x[which(as.logical(x[, col_icu, drop = TRUE])), "newvar_first_isolate"] <- FALSE
|
x[which(as.logical(x[, col_icu, drop = TRUE])), "newvar_first_isolate"] <- FALSE
|
||||||
} else {
|
} else {
|
||||||
message(font_black("[Criterion] Include isolates from ICU.\n"))
|
message_("[Criterion] Include isolates from ICU.",
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,18 +417,18 @@ first_isolate <- function(x,
|
|||||||
|
|
||||||
# handle empty microorganisms
|
# handle empty microorganisms
|
||||||
if (any(x$newvar_mo == "UNKNOWN", na.rm = TRUE) & info == TRUE) {
|
if (any(x$newvar_mo == "UNKNOWN", na.rm = TRUE) & info == TRUE) {
|
||||||
message(font_blue(paste0("NOTE: ", ifelse(include_unknown == TRUE, "Included ", "Excluded "),
|
message_(ifelse(include_unknown == TRUE, "Included ", "Excluded "),
|
||||||
format(sum(x$newvar_mo == "UNKNOWN", na.rm = TRUE),
|
format(sum(x$newvar_mo == "UNKNOWN", na.rm = TRUE),
|
||||||
decimal.mark = decimal.mark, big.mark = big.mark),
|
decimal.mark = decimal.mark, big.mark = big.mark),
|
||||||
" isolates with a microbial ID 'UNKNOWN' (column `", font_bold(col_mo), "`)")))
|
" isolates with a microbial ID 'UNKNOWN' (column `", font_bold(col_mo), "`)")
|
||||||
}
|
}
|
||||||
x[which(x$newvar_mo == "UNKNOWN"), "newvar_first_isolate"] <- include_unknown
|
x[which(x$newvar_mo == "UNKNOWN"), "newvar_first_isolate"] <- include_unknown
|
||||||
|
|
||||||
# exclude all NAs
|
# exclude all NAs
|
||||||
if (any(is.na(x$newvar_mo)) & info == TRUE) {
|
if (any(is.na(x$newvar_mo)) & info == TRUE) {
|
||||||
message(font_blue(paste0("NOTE: Excluded ", format(sum(is.na(x$newvar_mo), na.rm = TRUE),
|
message_("Excluded ", format(sum(is.na(x$newvar_mo), na.rm = TRUE),
|
||||||
decimal.mark = decimal.mark, big.mark = big.mark),
|
decimal.mark = decimal.mark, big.mark = big.mark),
|
||||||
" isolates with a microbial ID 'NA' (column `", font_bold(col_mo), "`)")))
|
" isolates with a microbial ID 'NA' (column `", font_bold(col_mo), "`)")
|
||||||
}
|
}
|
||||||
x[which(is.na(x$newvar_mo)), "newvar_first_isolate"] <- FALSE
|
x[which(is.na(x$newvar_mo)), "newvar_first_isolate"] <- FALSE
|
||||||
|
|
||||||
@ -445,7 +457,7 @@ first_isolate <- function(x,
|
|||||||
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
font_bold(paste0(n_found, " first ", weighted.notice, "isolates")),
|
||||||
" (", p_found_total, " of total where a microbial ID was available)")
|
" (", p_found_total, " of total where a microbial ID was available)")
|
||||||
}
|
}
|
||||||
message(font_black(msg_txt))
|
message_(msg_txt, add_fn = font_black, as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
x$newvar_first_isolate
|
x$newvar_first_isolate
|
||||||
|
@ -94,14 +94,16 @@ guess_ab_col <- function(x = NULL, search_string = NULL, verbose = FALSE) {
|
|||||||
|
|
||||||
if (length(ab_result) == 0) {
|
if (length(ab_result) == 0) {
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
message(paste0("No column found as input for `", search_string,
|
message_("No column found as input for `", search_string,
|
||||||
"` (", ab_name(search_string, language = NULL, tolower = TRUE), ")."))
|
"` (", ab_name(search_string, language = NULL, tolower = TRUE), ").",
|
||||||
|
add_fn = font_black,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
return(NULL)
|
return(NULL)
|
||||||
} else {
|
} else {
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
message(font_blue(paste0("NOTE: Using column `", font_bold(ab_result), "` as input for `", search_string,
|
message_("Using column `", font_bold(ab_result), "` as input for `", search_string,
|
||||||
"` (", ab_name(search_string, language = NULL, tolower = TRUE), ").")))
|
"` (", ab_name(search_string, language = NULL, tolower = TRUE), ").")
|
||||||
}
|
}
|
||||||
return(ab_result)
|
return(ab_result)
|
||||||
}
|
}
|
||||||
@ -120,18 +122,20 @@ get_column_abx <- function(x,
|
|||||||
meet_criteria(info, allow_class = "logical", has_length = 1)
|
meet_criteria(info, allow_class = "logical", has_length = 1)
|
||||||
|
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue("NOTE: Auto-guessing columns suitable for analysis"), appendLF = FALSE)
|
message_("Auto-guessing columns suitable for analysis", appendLF = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
x <- as.data.frame(x, stringsAsFactors = FALSE)
|
||||||
if (NROW(x) > 10000) {
|
if (NROW(x) > 10000) {
|
||||||
# only test maximum of 10,000 values per column
|
# only test maximum of 10,000 values per column
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue(paste0(" (using only ", font_bold("the first 10,000 rows"), ")...")), appendLF = FALSE)
|
message_(" (using only ", font_bold("the first 10,000 rows"), ")...",
|
||||||
|
appendLF = FALSE,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
x <- x[1:10000, , drop = FALSE]
|
x <- x[1:10000, , drop = FALSE]
|
||||||
} else if (info == TRUE) {
|
} else if (info == TRUE) {
|
||||||
message(font_blue("..."), appendLF = FALSE)
|
message_("...", appendLF = FALSE, as_note = FALSE)
|
||||||
}
|
}
|
||||||
x_bak <- x
|
x_bak <- x
|
||||||
# only check columns that are a valid AB code, ATC code, name, abbreviation or synonym,
|
# only check columns that are a valid AB code, ATC code, name, abbreviation or synonym,
|
||||||
@ -178,7 +182,7 @@ get_column_abx <- function(x,
|
|||||||
|
|
||||||
if (length(x) == 0) {
|
if (length(x) == 0) {
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue("No columns found."))
|
message_("No columns found.")
|
||||||
}
|
}
|
||||||
return(x)
|
return(x)
|
||||||
}
|
}
|
||||||
@ -192,13 +196,13 @@ get_column_abx <- function(x,
|
|||||||
|
|
||||||
# succeeded with auto-guessing
|
# succeeded with auto-guessing
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue("OK."))
|
message_("OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in seq_len(length(x))) {
|
for (i in seq_len(length(x))) {
|
||||||
if (info == TRUE & verbose == TRUE & !names(x[i]) %in% names(duplicates)) {
|
if (info == TRUE & 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],
|
message_("Using column `", font_bold(x[i]), "` as input for `", names(x)[i],
|
||||||
"` (", ab_name(names(x)[i], tolower = TRUE, language = NULL), ").")))
|
"` (", ab_name(names(x)[i], tolower = TRUE, language = NULL), ").")
|
||||||
}
|
}
|
||||||
if (info == TRUE & names(x[i]) %in% names(duplicates)) {
|
if (info == TRUE & names(x[i]) %in% names(duplicates)) {
|
||||||
warning(font_red(paste0("Using column `", font_bold(x[i]), "` as input for `", names(x)[i],
|
warning(font_red(paste0("Using column `", font_bold(x[i]), "` as input for `", names(x)[i],
|
||||||
@ -225,15 +229,10 @@ get_column_abx <- function(x,
|
|||||||
# missing a soft dependency may lower the reliability
|
# missing a soft dependency may lower the reliability
|
||||||
missing <- soft_dependencies[!soft_dependencies %in% names(x)]
|
missing <- soft_dependencies[!soft_dependencies %in% names(x)]
|
||||||
missing_msg <- paste(paste0(ab_name(missing, tolower = TRUE, language = NULL),
|
missing_msg <- paste(paste0(ab_name(missing, tolower = TRUE, language = NULL),
|
||||||
" (", missing, ")"),
|
" (", font_bold(missing, collapse = NULL), ")"),
|
||||||
collapse = ", ")
|
collapse = ", ")
|
||||||
missing_msg <- paste("NOTE: Reliability would be improved if these antimicrobial results would be available too:",
|
message_("Reliability would be improved if these antimicrobial results would be available too: ",
|
||||||
missing_msg)
|
missing_msg)
|
||||||
wrapped <- strwrap(missing_msg,
|
|
||||||
width = 0.95 * getOption("width"),
|
|
||||||
exdent = 6)
|
|
||||||
wrapped <- gsub("\\((.*?)\\)", paste0("(", font_bold("\\1"), ")"), wrapped) # add bold abbreviations
|
|
||||||
message(font_blue(wrapped, collapse = "\n"))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x
|
x
|
||||||
|
@ -255,7 +255,7 @@ joins_check_df <- function(x, by) {
|
|||||||
stop("Cannot join - no column found with name 'mo' or with class <mo>.", call. = FALSE)
|
stop("Cannot join - no column found with name 'mo' or with class <mo>.", call. = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
message('Joining, by = "', by, '"') # message same as dplyr::join functions
|
message_('Joining, by = "', by, '"', add_fn = font_black, as_note = FALSE) # message same as dplyr::join functions
|
||||||
}
|
}
|
||||||
if (is.null(names(by))) {
|
if (is.null(names(by))) {
|
||||||
joinby <- colnames(microorganisms)[1]
|
joinby <- colnames(microorganisms)[1]
|
||||||
|
20
R/mdro.R
20
R/mdro.R
@ -114,7 +114,7 @@ mdro <- function(x,
|
|||||||
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
|
q_continue <- utils::menu(choices = c("OK", "Cancel"), graphics = FALSE, title = txt)
|
||||||
}
|
}
|
||||||
if (q_continue %in% c(FALSE, 2)) {
|
if (q_continue %in% c(FALSE, 2)) {
|
||||||
message("Cancelled, returning original data")
|
message_("Cancelled, returning original data", add_fn = font_red, as_note = FALSE)
|
||||||
return(x)
|
return(x)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,10 +162,10 @@ mdro <- function(x,
|
|||||||
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
col_mo <- search_type_in_df(x = x, type = "mo", info = info)
|
||||||
}
|
}
|
||||||
if (is.null(col_mo) & guideline$code == "tb") {
|
if (is.null(col_mo) & guideline$code == "tb") {
|
||||||
message(font_blue("NOTE: No column found as input for `col_mo`,",
|
message_("No column found as input for `col_mo`, ",
|
||||||
font_bold("assuming all records contain", font_italic("Mycobacterium tuberculosis."))))
|
font_bold("assuming all records contain", font_italic("Mycobacterium tuberculosis.")))
|
||||||
x$mo <- as.mo("Mycobacterium tuberculosis")
|
x$mo <- as.mo("Mycobacterium tuberculosis")
|
||||||
col_mo <- "mo"
|
col_mo <- "mo"
|
||||||
}
|
}
|
||||||
stop_if(is.null(col_mo), "`col_mo` must be set")
|
stop_if(is.null(col_mo), "`col_mo` must be set")
|
||||||
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
stop_ifnot(col_mo %in% colnames(x), "column '", col_mo, "' (`col_mo`) not found")
|
||||||
@ -599,7 +599,7 @@ mdro <- function(x,
|
|||||||
}
|
}
|
||||||
trans_tbl2 <- function(txt, rows, lst) {
|
trans_tbl2 <- function(txt, rows, lst) {
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue(txt, "..."), appendLF = FALSE)
|
message_(txt, "...", appendLF = FALSE, as_note = FALSE)
|
||||||
}
|
}
|
||||||
if (length(rows) > 0) {
|
if (length(rows) > 0) {
|
||||||
# function specific for the CMI paper of 2012 (Magiorakos et al.)
|
# function specific for the CMI paper of 2012 (Magiorakos et al.)
|
||||||
@ -633,7 +633,7 @@ mdro <- function(x,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (info == TRUE) {
|
if (info == TRUE) {
|
||||||
message(font_blue(" OK"))
|
message_(" OK", as_note = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,20 +653,20 @@ mdro <- function(x,
|
|||||||
# take amoxicillin if ampicillin is unavailable
|
# take amoxicillin if ampicillin is unavailable
|
||||||
if (is.na(AMP) & !is.na(AMX)) {
|
if (is.na(AMP) & !is.na(AMX)) {
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
message(font_blue("NOTE: Filling ampicillin (AMP) results with amoxicillin (AMX) results"))
|
message_("Filling ampicillin (AMP) results with amoxicillin (AMX) results")
|
||||||
}
|
}
|
||||||
AMP <- AMX
|
AMP <- AMX
|
||||||
}
|
}
|
||||||
# take ceftriaxone if cefotaxime is unavailable and vice versa
|
# take ceftriaxone if cefotaxime is unavailable and vice versa
|
||||||
if (is.na(CRO) & !is.na(CTX)) {
|
if (is.na(CRO) & !is.na(CTX)) {
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
message(font_blue("NOTE: Filling ceftriaxone (CRO) results with cefotaxime (CTX) results"))
|
message_("Filling ceftriaxone (CRO) results with cefotaxime (CTX) results")
|
||||||
}
|
}
|
||||||
CRO <- CTX
|
CRO <- CTX
|
||||||
}
|
}
|
||||||
if (is.na(CTX) & !is.na(CRO)) {
|
if (is.na(CTX) & !is.na(CRO)) {
|
||||||
if (verbose == TRUE) {
|
if (verbose == TRUE) {
|
||||||
message(font_blue("NOTE: Filling cefotaxime (CTX) results with ceftriaxone (CRO) results"))
|
message_("Filling cefotaxime (CTX) results with ceftriaxone (CRO) results")
|
||||||
}
|
}
|
||||||
CTX <- CRO
|
CTX <- CRO
|
||||||
}
|
}
|
||||||
|
33
R/mo.R
33
R/mo.R
@ -1761,9 +1761,7 @@ print.mo_uncertainties <- function(x, ...) {
|
|||||||
if (NROW(x) == 0) {
|
if (NROW(x) == 0) {
|
||||||
return(NULL)
|
return(NULL)
|
||||||
}
|
}
|
||||||
cat(font_blue(strwrap("Matching scores are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. Please see ?mo_matching_score.",
|
message_("Matching scores are based on human pathogenic prevalence and the resemblance between the input and the full taxonomic name. Please see ?mo_matching_score.", as_note = FALSE)
|
||||||
width = 0.98 * getOption("width")),
|
|
||||||
collapse = "\n"))
|
|
||||||
cat("\n")
|
cat("\n")
|
||||||
|
|
||||||
msg <- ""
|
msg <- ""
|
||||||
@ -1838,16 +1836,19 @@ print.mo_renamed <- function(x, ...) {
|
|||||||
return(invisible())
|
return(invisible())
|
||||||
}
|
}
|
||||||
for (i in seq_len(nrow(x))) {
|
for (i in seq_len(nrow(x))) {
|
||||||
message(font_blue(paste0("NOTE: ",
|
message_(font_italic(x$old_name[i]),
|
||||||
font_italic(x$old_name[i]), ifelse(x$old_ref[i] %in% c("", NA), "",
|
ifelse(x$old_ref[i] %in% c("", NA),
|
||||||
paste0(" (", gsub("et al.", font_italic("et al."), x$old_ref[i]), ")")),
|
"",
|
||||||
" was renamed ",
|
paste0(" (", gsub("et al.", font_italic("et al."), x$old_ref[i]), ")")),
|
||||||
ifelse(as.integer(gsub("[^0-9]", "", x$new_ref[i])) < as.integer(gsub("[^0-9]", "", x$old_ref[i])),
|
" was renamed ",
|
||||||
font_bold("back to "),
|
ifelse(as.integer(gsub("[^0-9]", "", x$new_ref[i])) < as.integer(gsub("[^0-9]", "", x$old_ref[i])),
|
||||||
""),
|
font_bold("back to "),
|
||||||
font_italic(x$new_name[i]), ifelse(x$new_ref[i] %in% c("", NA), "",
|
""),
|
||||||
paste0(" (", gsub("et al.", font_italic("et al."), x$new_ref[i]), ")")),
|
font_italic(x$new_name[i]),
|
||||||
" [", x$mo[i], "]")))
|
ifelse(x$new_ref[i] %in% c("", NA),
|
||||||
|
"",
|
||||||
|
paste0(" (", gsub("et al.", font_italic("et al."), x$new_ref[i]), ")")),
|
||||||
|
" [", x$mo[i], "]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1945,9 +1946,9 @@ replace_ignore_pattern <- function(x, ignore_pattern) {
|
|||||||
if (!is.null(ignore_pattern) && !identical(trimws2(ignore_pattern), "")) {
|
if (!is.null(ignore_pattern) && !identical(trimws2(ignore_pattern), "")) {
|
||||||
ignore_cases <- x %like% ignore_pattern
|
ignore_cases <- x %like% ignore_pattern
|
||||||
if (sum(ignore_cases) > 0) {
|
if (sum(ignore_cases) > 0) {
|
||||||
message(font_blue(paste0("NOTE: the following input was ignored by `ignore_pattern = \"", ignore_pattern, "\"`: ",
|
message_("The following input was ignored by `ignore_pattern = \"", ignore_pattern, "\"`: ",
|
||||||
paste0("'", sort(unique(x[x %like% ignore_pattern])), "'", collapse = ", "),
|
paste0("'", sort(unique(x[x %like% ignore_pattern])), "'", collapse = ", "),
|
||||||
collapse = ", ")))
|
collapse = ", ")
|
||||||
x[x %like% ignore_pattern] <- NA_character_
|
x[x %like% ignore_pattern] <- NA_character_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,9 @@ set_mo_source <- function(path) {
|
|||||||
options(mo_source_timestamp = NULL)
|
options(mo_source_timestamp = NULL)
|
||||||
if (file.exists(file_location)) {
|
if (file.exists(file_location)) {
|
||||||
unlink(file_location)
|
unlink(file_location)
|
||||||
message(font_red(paste0("Removed mo_source file '", font_bold(file_location), "'")))
|
message_("Removed mo_source file '", font_bold(file_location), "'",
|
||||||
|
add_fn = font_red,
|
||||||
|
as_note = FALSE)
|
||||||
}
|
}
|
||||||
return(invisible())
|
return(invisible())
|
||||||
}
|
}
|
||||||
@ -199,10 +201,9 @@ set_mo_source <- function(path) {
|
|||||||
saveRDS(df, file_location)
|
saveRDS(df, file_location)
|
||||||
options(mo_source = path)
|
options(mo_source = path)
|
||||||
options(mo_source_timestamp = as.character(file.info(path)$mtime))
|
options(mo_source_timestamp = as.character(file.info(path)$mtime))
|
||||||
message(font_blue(paste0("NOTE: ",
|
message_(action, " mo_source file '", font_bold(file_location), "'",
|
||||||
action, " mo_source file '", font_bold(file_location), "'",
|
" from '", font_bold(path), "'",
|
||||||
" from '", font_bold(path), "'",
|
'(columns "', colnames(df)[1], '" and "', colnames(df)[2], '")')
|
||||||
'\n (columns "', colnames(df)[1], '" and "', colnames(df)[2], '")')))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#' @rdname mo_source
|
#' @rdname mo_source
|
||||||
@ -215,7 +216,7 @@ get_mo_source <- function() {
|
|||||||
if (!file.exists(path.expand("~/mo_source.rds"))) {
|
if (!file.exists(path.expand("~/mo_source.rds"))) {
|
||||||
options(mo_source = NULL)
|
options(mo_source = NULL)
|
||||||
options(mo_source_timestamp = NULL)
|
options(mo_source_timestamp = NULL)
|
||||||
message(font_blue("NOTE: Removed references to deleted mo_source file (see ?mo_source)"))
|
message_("Removed references to deleted mo_source file (see ?mo_source)")
|
||||||
return(NULL)
|
return(NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
4
R/pca.R
4
R/pca.R
@ -116,8 +116,8 @@ pca <- function(x,
|
|||||||
|
|
||||||
pca_data <- x[, which(sapply(x, function(x) is.numeric(x)))]
|
pca_data <- x[, which(sapply(x, function(x) is.numeric(x)))]
|
||||||
|
|
||||||
message(font_blue(paste0("NOTE: Columns selected for PCA: ", paste0(font_bold(colnames(pca_data)), collapse = "/"),
|
message_("Columns selected for PCA: ", paste0(font_bold(colnames(pca_data)), collapse = "/"),
|
||||||
".\n Total observations available: ", nrow(pca_data), ".")))
|
". Total observations available: ", nrow(pca_data), ".")
|
||||||
|
|
||||||
pca_model <- prcomp(pca_data, retx = retx, center = center, scale. = scale., tol = tol, rank. = rank.)
|
pca_model <- prcomp(pca_data, retx = retx, center = center, scale. = scale., tol = tol, rank. = rank.)
|
||||||
attr(pca_model, "non_numeric_cols") <- x[, sapply(x, function(y) !is.numeric(y) & !all(is.na(y))), drop = FALSE]
|
attr(pca_model, "non_numeric_cols") <- x[, sapply(x, function(y) !is.numeric(y) & !all(is.na(y))), drop = FALSE]
|
||||||
|
60
R/rsi.R
60
R/rsi.R
@ -340,7 +340,10 @@ as.rsi.mic <- function(x,
|
|||||||
mo_coerced <- suppressWarnings(as.mo(mo))
|
mo_coerced <- suppressWarnings(as.mo(mo))
|
||||||
guideline_coerced <- get_guideline(guideline)
|
guideline_coerced <- get_guideline(guideline)
|
||||||
if (is.na(ab_coerced)) {
|
if (is.na(ab_coerced)) {
|
||||||
message(font_red(paste0("Returning NAs for unknown drug: `", font_bold(ab), "`. Rename this column to a drug name or code, and check the output with as.ab().")))
|
message_("Returning NAs for unknown drug: `", font_bold(ab),
|
||||||
|
"`. Rename this column to a drug name or code, and check the output with as.ab().",
|
||||||
|
add_fn = font_red,
|
||||||
|
as_note = FALSE)
|
||||||
return(as.rsi(rep(NA, length(x))))
|
return(as.rsi(rep(NA, length(x))))
|
||||||
}
|
}
|
||||||
if (length(mo_coerced) == 1) {
|
if (length(mo_coerced) == 1) {
|
||||||
@ -350,11 +353,12 @@ as.rsi.mic <- function(x,
|
|||||||
uti <- rep(uti, length(x))
|
uti <- rep(uti, length(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
message(font_blue(paste0("=> Interpreting MIC values of `", font_bold(ab), "` (",
|
message_("=> Interpreting MIC values of `", font_bold(ab), "` (",
|
||||||
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
|
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
|
||||||
ab_name(ab_coerced, tolower = TRUE), ")", mo_var_found,
|
ab_name(ab_coerced, tolower = TRUE), ")", mo_var_found,
|
||||||
" according to ", font_bold(guideline_coerced), " ... ")),
|
" according to ", font_bold(guideline_coerced), " ... ",
|
||||||
appendLF = FALSE)
|
appendLF = FALSE,
|
||||||
|
as_note = FALSE)
|
||||||
|
|
||||||
result <- exec_as.rsi(method = "mic",
|
result <- exec_as.rsi(method = "mic",
|
||||||
x = x,
|
x = x,
|
||||||
@ -363,7 +367,7 @@ as.rsi.mic <- function(x,
|
|||||||
guideline = guideline_coerced,
|
guideline = guideline_coerced,
|
||||||
uti = uti,
|
uti = uti,
|
||||||
conserve_capped_values = conserve_capped_values,
|
conserve_capped_values = conserve_capped_values,
|
||||||
add_intrinsic_resistance = add_intrinsic_resistance) # exec_as.rsi will return message(font_blue(" OK."))
|
add_intrinsic_resistance = add_intrinsic_resistance) # exec_as.rsi will return message_(" OK.")
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +424,10 @@ as.rsi.disk <- function(x,
|
|||||||
mo_coerced <- suppressWarnings(as.mo(mo))
|
mo_coerced <- suppressWarnings(as.mo(mo))
|
||||||
guideline_coerced <- get_guideline(guideline)
|
guideline_coerced <- get_guideline(guideline)
|
||||||
if (is.na(ab_coerced)) {
|
if (is.na(ab_coerced)) {
|
||||||
message(font_red(paste0("Returning NAs for unknown drug: `", font_bold(ab), "`. Rename this column to a drug name or code, and check the output with as.ab().")))
|
message_("Returning NAs for unknown drug: `", font_bold(ab),
|
||||||
|
"`. Rename this column to a drug name or code, and check the output with as.ab().",
|
||||||
|
add_fn = font_red,
|
||||||
|
as_note = FALSE)
|
||||||
return(as.rsi(rep(NA, length(x))))
|
return(as.rsi(rep(NA, length(x))))
|
||||||
}
|
}
|
||||||
if (length(mo_coerced) == 1) {
|
if (length(mo_coerced) == 1) {
|
||||||
@ -430,10 +437,11 @@ as.rsi.disk <- function(x,
|
|||||||
uti <- rep(uti, length(x))
|
uti <- rep(uti, length(x))
|
||||||
}
|
}
|
||||||
|
|
||||||
message(font_blue(paste0("=> Interpreting disk zones of `", font_bold(ab), "` (",
|
message_("=> Interpreting disk zones of `", font_bold(ab), "` (",
|
||||||
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
|
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
|
||||||
ab_name(ab_coerced, tolower = TRUE), ") using guideline ", font_bold(guideline_coerced), " ... ")),
|
ab_name(ab_coerced, tolower = TRUE), ") using guideline ", font_bold(guideline_coerced), " ... ",
|
||||||
appendLF = FALSE)
|
appendLF = FALSE,
|
||||||
|
as_note = FALSE)
|
||||||
result <- exec_as.rsi(method = "disk",
|
result <- exec_as.rsi(method = "disk",
|
||||||
x = x,
|
x = x,
|
||||||
mo = mo_coerced,
|
mo = mo_coerced,
|
||||||
@ -441,7 +449,7 @@ as.rsi.disk <- function(x,
|
|||||||
guideline = guideline_coerced,
|
guideline = guideline_coerced,
|
||||||
uti = uti,
|
uti = uti,
|
||||||
conserve_capped_values = FALSE,
|
conserve_capped_values = FALSE,
|
||||||
add_intrinsic_resistance = add_intrinsic_resistance) # exec_as.rsi will return message(font_blue(" OK."))
|
add_intrinsic_resistance = add_intrinsic_resistance) # exec_as.rsi will return message_(" OK.")
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -497,10 +505,11 @@ as.rsi.data.frame <- function(x,
|
|||||||
} else {
|
} else {
|
||||||
plural <- c("", "s", "a ")
|
plural <- c("", "s", "a ")
|
||||||
}
|
}
|
||||||
message(font_blue(paste0("NOTE: Assuming value", plural[1], " ",
|
message_("Assuming value", plural[1], " ",
|
||||||
paste(paste0('"', values, '"'), collapse = ", "),
|
paste(paste0('"', values, '"'), collapse = ", "),
|
||||||
" in column `", font_bold(col_specimen),
|
" in column `", font_bold(col_specimen),
|
||||||
"` reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1], ".\n Use `as.rsi(uti = FALSE)` to prevent this.")))
|
"` reflect", plural[2], " ", plural[3], "urinary tract infection", plural[1],
|
||||||
|
".\n Use `as.rsi(uti = FALSE)` to prevent this.")
|
||||||
} else {
|
} else {
|
||||||
# no data about UTI's found
|
# no data about UTI's found
|
||||||
uti <- FALSE
|
uti <- FALSE
|
||||||
@ -573,12 +582,13 @@ as.rsi.data.frame <- function(x,
|
|||||||
} else if (types[i] == "rsi") {
|
} else if (types[i] == "rsi") {
|
||||||
ab <- ab_cols[i]
|
ab <- ab_cols[i]
|
||||||
ab_coerced <- suppressWarnings(as.ab(ab))
|
ab_coerced <- suppressWarnings(as.ab(ab))
|
||||||
message(font_blue(paste0("=> Cleaning values in column `", font_bold(ab), "` (",
|
message_("=> Cleaning values in column `", font_bold(ab), "` (",
|
||||||
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
|
ifelse(ab_coerced != ab, paste0(ab_coerced, ", "), ""),
|
||||||
ab_name(ab_coerced, tolower = TRUE), ")... ")),
|
ab_name(ab_coerced, tolower = TRUE), ")... ",
|
||||||
appendLF = FALSE)
|
appendLF = FALSE,
|
||||||
|
as_note = FALSE)
|
||||||
x[, ab_cols[i]] <- as.rsi.default(x = x %pm>% pm_pull(ab_cols[i]))
|
x[, ab_cols[i]] <- as.rsi.default(x = x %pm>% pm_pull(ab_cols[i]))
|
||||||
message(font_green("OK."))
|
message_("OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +656,7 @@ exec_as.rsi <- function(method,
|
|||||||
|
|
||||||
guideline_coerced <- get_guideline(guideline)
|
guideline_coerced <- get_guideline(guideline)
|
||||||
if (guideline_coerced != guideline) {
|
if (guideline_coerced != guideline) {
|
||||||
message(font_blue(paste0("Note: Using guideline ", font_bold(guideline_coerced), " as input for `guideline`.")))
|
message_("Using guideline ", font_bold(guideline_coerced), " as input for `guideline`.")
|
||||||
}
|
}
|
||||||
|
|
||||||
new_rsi <- rep(NA_character_, length(x))
|
new_rsi <- rep(NA_character_, length(x))
|
||||||
@ -664,7 +674,7 @@ exec_as.rsi <- function(method,
|
|||||||
lookup_other <- paste(mo_other, ab)
|
lookup_other <- paste(mo_other, ab)
|
||||||
|
|
||||||
if (all(trans$uti == TRUE, na.rm = TRUE) & all(uti == FALSE)) {
|
if (all(trans$uti == TRUE, na.rm = TRUE) & all(uti == FALSE)) {
|
||||||
message(font_red("WARNING."))
|
message_("WARNING.", add_fn = list(font_red, font_bold), as_note = FALSE)
|
||||||
warning("Interpretation of ", font_bold(ab_name(ab, tolower = TRUE)), " for some microorganisms is only available for (uncomplicated) urinary tract infections (UTI).\n Use parameter 'uti' to set which isolates are from urine. See ?as.rsi.", call. = FALSE)
|
warning("Interpretation of ", font_bold(ab_name(ab, tolower = TRUE)), " for some microorganisms is only available for (uncomplicated) urinary tract infections (UTI).\n Use parameter 'uti' to set which isolates are from urine. See ?as.rsi.", call. = FALSE)
|
||||||
warned <- TRUE
|
warned <- TRUE
|
||||||
}
|
}
|
||||||
@ -744,7 +754,7 @@ exec_as.rsi <- function(method,
|
|||||||
pm_pull(new_rsi)
|
pm_pull(new_rsi)
|
||||||
|
|
||||||
if (warned == FALSE) {
|
if (warned == FALSE) {
|
||||||
message(font_green("OK."))
|
message_("OK.", add_fn = list(font_green, font_bold), as_note = FALSE)
|
||||||
}
|
}
|
||||||
|
|
||||||
load_mo_failures_uncertainties_renamed(metadata_mo)
|
load_mo_failures_uncertainties_renamed(metadata_mo)
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
<a class="navbar-link" href="https://msberends.github.io/AMR//index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -236,13 +236,13 @@
|
|||||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="amr-1409009" class="section level1">
|
<div id="amr-1409011" class="section level1">
|
||||||
<h1 class="page-header" data-toc-text="1.4.0.9009">
|
<h1 class="page-header" data-toc-text="1.4.0.9011">
|
||||||
<a href="#amr-1409009" class="anchor"></a>AMR 1.4.0.9009<small> Unreleased </small>
|
<a href="#amr-1409011" class="anchor"></a>AMR 1.4.0.9011<small> Unreleased </small>
|
||||||
</h1>
|
</h1>
|
||||||
<div id="last-updated-26-october-2020" class="section level2">
|
<div id="last-updated-27-october-2020" class="section level2">
|
||||||
<h2 class="hasAnchor">
|
<h2 class="hasAnchor">
|
||||||
<a href="#last-updated-26-october-2020" class="anchor"></a><small>Last updated: 26 October 2020</small>
|
<a href="#last-updated-27-october-2020" class="anchor"></a><small>Last updated: 27 October 2020</small>
|
||||||
</h2>
|
</h2>
|
||||||
<div id="new" class="section level3">
|
<div id="new" class="section level3">
|
||||||
<h3 class="hasAnchor">
|
<h3 class="hasAnchor">
|
||||||
|
@ -12,7 +12,7 @@ articles:
|
|||||||
datasets: datasets.html
|
datasets: datasets.html
|
||||||
resistance_predict: resistance_predict.html
|
resistance_predict: resistance_predict.html
|
||||||
welcome_to_AMR: welcome_to_AMR.html
|
welcome_to_AMR: welcome_to_AMR.html
|
||||||
last_built: 2020-10-26T14:49Z
|
last_built: 2020-10-27T14:41Z
|
||||||
urls:
|
urls:
|
||||||
reference: https://msberends.github.io/AMR//reference
|
reference: https://msberends.github.io/AMR//reference
|
||||||
article: https://msberends.github.io/AMR//articles
|
article: https://msberends.github.io/AMR//articles
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
<a class="navbar-link" href="../index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<span class="navbar-brand">
|
<span class="navbar-brand">
|
||||||
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
<a class="navbar-link" href="index.html">AMR (for R)</a>
|
||||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9009</span>
|
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.4.0.9011</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user