mirror of
https://github.com/msberends/AMR.git
synced 2026-03-30 10:16:05 +02:00
Compare commits
2 Commits
eae14d44bf
...
3e4983ff93
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e4983ff93 | ||
|
|
7218812c99 |
@@ -166,7 +166,12 @@ echo "$currentversion"
|
|||||||
The `+ 1` accounts for the fact that this PR's squash commit is not yet on the default branch. Set **both** of these files to the resulting version string (and only once per PR, even across multiple commits):
|
The `+ 1` accounts for the fact that this PR's squash commit is not yet on the default branch. Set **both** of these files to the resulting version string (and only once per PR, even across multiple commits):
|
||||||
|
|
||||||
1. **`DESCRIPTION`** — the `Version:` field
|
1. **`DESCRIPTION`** — the `Version:` field
|
||||||
2. **`NEWS.md`** — the top-level heading `# AMR <version>`
|
2. **`NEWS.md`** — **only replace line 1** (the `# AMR <version>` heading) with the new version number; do **not** create a new section. `NEWS.md` is a **continuous log** for the entire current `x.y.z.9nnn` development series: all changes since the last stable release accumulate under that single heading. After updating line 1, append the new change as a bullet under the appropriate sub-heading (`### New`, `### Fixes`, or `### Updates`).
|
||||||
|
|
||||||
|
Style rules for `NEWS.md` entries:
|
||||||
|
- Be **extremely concise** — one short line per item
|
||||||
|
- Do **not** end with a full stop (period)
|
||||||
|
- No verbose explanations; just the essential fact
|
||||||
|
|
||||||
If `git describe` fails (e.g. no tags exist in the environment), fall back to reading the current version from `DESCRIPTION` and adding 1 to the last numeric component — but only if no bump has already been made in this PR.
|
If `git describe` fails (e.g. no tags exist in the environment), fall back to reading the current version from `DESCRIPTION` and adding 1 to the last numeric component — but only if no bump has already been made in this PR.
|
||||||
|
|
||||||
|
|||||||
13
NEWS.md
13
NEWS.md
@@ -1,13 +1,5 @@
|
|||||||
# AMR 3.0.1.9036
|
# AMR 3.0.1.9036
|
||||||
|
|
||||||
### Updates
|
|
||||||
* Modernised messaging infrastructure: `message_()`, `warning_()`, and `stop_()` now use `cli` for rich formatting (colours, inline markup, hyperlinks) when the `cli` package is installed, with a fully functional plain-text fallback when `cli` is absent
|
|
||||||
* Removed `add_fn` parameter from `message_()`, `warning_()`, and `word_wrap()` — styling is now handled by `cli` markup or dropped from the plain-text path
|
|
||||||
* New internal helper `cli_to_plain()` converts cli inline markup (`{.fun}`, `{.arg}`, `{.val}`, etc.) to plain-text equivalents for the non-cli fallback path
|
|
||||||
* Call sites across all R source files updated from `paste0()`-based string construction to cli glue syntax (e.g. `{.fun as.mo}`, `{.arg col_mo}`, `{n} results`)
|
|
||||||
|
|
||||||
# AMR 3.0.1.9035
|
|
||||||
|
|
||||||
### New
|
### New
|
||||||
* Integration with the **tidymodels** framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via `recipes`
|
* Integration with the **tidymodels** framework to allow seamless use of SIR, MIC and disk data in modelling pipelines via `recipes`
|
||||||
- `step_mic_log2()` to transform `<mic>` columns with log2, and `step_sir_numeric()` to convert `<sir>` columns to numeric
|
- `step_mic_log2()` to transform `<mic>` columns with log2, and `step_sir_numeric()` to convert `<sir>` columns to numeric
|
||||||
@@ -52,6 +44,11 @@
|
|||||||
* Removed the `"inverse"` option, which has now become redundant
|
* Removed the `"inverse"` option, which has now become redundant
|
||||||
* `ab_group()` now returns values consist with the AMR selectors (#246)
|
* `ab_group()` now returns values consist with the AMR selectors (#246)
|
||||||
* Added two new `NA` objects, `NA_ab_` and `NA_mo_`, analogous to base R's `NA_character_` and `NA_integer_`, for use in pipelines that require typed missing values
|
* Added two new `NA` objects, `NA_ab_` and `NA_mo_`, analogous to base R's `NA_character_` and `NA_integer_`, for use in pipelines that require typed missing values
|
||||||
|
* `message_()`, `warning_()`, `stop_()` now use `cli` markup when available, with plain-text fallback; removed `add_fn` parameter from `message_()`, `warning_()`, `word_wrap()`
|
||||||
|
* New internal `cli_to_plain()` converts `cli` markup to plain text for non-cli path
|
||||||
|
* All internal call sites updated to `cli` glue syntax
|
||||||
|
* CI dev-version and old-tinytest workflows now only run on `main` branch pushes
|
||||||
|
* Single-quoted literal values in messaging calls replaced with `{.val}`, `{.cls}`, `{.field}`, or `{.code}` markup throughout
|
||||||
|
|
||||||
|
|
||||||
# AMR 3.0.1
|
# AMR 3.0.1
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ ab_from_text <- function(text,
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
stop_("{.arg type} must be either 'drug', 'dose' or 'administration'")
|
stop_("{.arg type} must be either {.val drug}, {.val dose} or {.val administration}")
|
||||||
}
|
}
|
||||||
|
|
||||||
# collapse text if needed
|
# collapse text if needed
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ av_from_text <- function(text,
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
stop_("{.arg type} must be either 'drug', 'dose' or 'administration'")
|
stop_("{.arg type} must be either {.val drug}, {.val dose} or {.val administration}")
|
||||||
}
|
}
|
||||||
|
|
||||||
# collapse text if needed
|
# collapse text if needed
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ check_validity_mo_source <- function(x, refer_to_name = "`reference_df`", stop_o
|
|||||||
}
|
}
|
||||||
if (!"mo" %in% colnames(x)) {
|
if (!"mo" %in% colnames(x)) {
|
||||||
if (stop_on_error == TRUE) {
|
if (stop_on_error == TRUE) {
|
||||||
stop_(refer_to_name, " must contain a column 'mo'", call = FALSE)
|
stop_(refer_to_name, " must contain a column {.field mo}", call = FALSE)
|
||||||
} else {
|
} else {
|
||||||
return(FALSE)
|
return(FALSE)
|
||||||
}
|
}
|
||||||
|
|||||||
10
R/sir.R
10
R/sir.R
@@ -985,7 +985,7 @@ as.sir.data.frame <- function(x,
|
|||||||
} else if (!is.sir(x.bak[, ab, drop = TRUE])) {
|
} else if (!is.sir(x.bak[, ab, drop = TRUE])) {
|
||||||
show_message <- TRUE
|
show_message <- TRUE
|
||||||
if (isTRUE(info)) {
|
if (isTRUE(info)) {
|
||||||
message_("Assigning class 'sir' to already clean column '", font_bold(ab), "' (",
|
message_("Assigning class {.cls sir} to already clean column '", font_bold(ab), "' (",
|
||||||
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
ifelse(ab_coerced != toupper(ab), paste0(ab_coerced, ", "), ""),
|
||||||
ab_name(ab_coerced, tolower = TRUE, language = NULL, info = info), ")... ",
|
ab_name(ab_coerced, tolower = TRUE, language = NULL, info = info), ")... ",
|
||||||
appendLF = FALSE,
|
appendLF = FALSE,
|
||||||
@@ -1276,7 +1276,7 @@ as_sir_method <- function(method_short,
|
|||||||
mo_var_found <- ""
|
mo_var_found <- ""
|
||||||
}
|
}
|
||||||
if (is.null(mo)) {
|
if (is.null(mo)) {
|
||||||
stop_("No information was supplied about the microorganisms (missing argument {.arg mo} and no column of class 'mo' found). See {.help [{.fun as.sir}](AMR::as.sir)}.\n\n",
|
stop_("No information was supplied about the microorganisms (missing argument {.arg mo} and no column of class {.cls mo} found). See {.help [{.fun as.sir}](AMR::as.sir)}.\n\n",
|
||||||
"To transform certain columns with e.g. mutate(), use ", highlight_code("data %>% mutate(across(..., as.sir, mo = x))"), ", where x is your column with microorganisms.\n",
|
"To transform certain columns with e.g. mutate(), use ", highlight_code("data %>% mutate(across(..., as.sir, mo = x))"), ", where x is your column with microorganisms.\n",
|
||||||
"To transform all ", method_long, " in a data set, use ", highlight_code("data %>% as.sir()"), " or ", highlight_code(paste0("data %>% mutate_if(is.", method_short, ", as.sir)")), ".",
|
"To transform all ", method_long, " in a data set, use ", highlight_code("data %>% as.sir()"), " or ", highlight_code(paste0("data %>% mutate_if(is.", method_short, ", as.sir)")), ".",
|
||||||
call = FALSE
|
call = FALSE
|
||||||
@@ -1988,7 +1988,7 @@ sir_interpretation_history <- function(clean = FALSE) {
|
|||||||
#' @noRd
|
#' @noRd
|
||||||
print.sir_log <- function(x, ...) {
|
print.sir_log <- function(x, ...) {
|
||||||
if (NROW(x) == 0) {
|
if (NROW(x) == 0) {
|
||||||
message_("No results to print. First run {.help [{.fun as.sir}](AMR::as.sir)} on MIC values or disk diffusion zones (or on a {.cls data.frame} containing any of these) to print a 'logbook' data set here.")
|
message_("No results to print. First run {.help [{.fun as.sir}](AMR::as.sir)} on MIC values or disk diffusion zones (or on a {.cls data.frame} containing any of these) to print a {.val logbook} data set here.")
|
||||||
return(invisible(NULL))
|
return(invisible(NULL))
|
||||||
}
|
}
|
||||||
class(x) <- class(x)[class(x) != "sir_log"]
|
class(x) <- class(x)[class(x) != "sir_log"]
|
||||||
@@ -2227,10 +2227,10 @@ check_reference_data <- function(reference_data, .call_depth) {
|
|||||||
class_sir <- vapply(FUN.VALUE = character(1), AMR::clinical_breakpoints, function(x) paste0("<", class(x), ">", collapse = " and "))
|
class_sir <- vapply(FUN.VALUE = character(1), AMR::clinical_breakpoints, function(x) paste0("<", class(x), ">", collapse = " and "))
|
||||||
class_ref <- vapply(FUN.VALUE = character(1), reference_data, function(x) paste0("<", class(x), ">", collapse = " and "))
|
class_ref <- vapply(FUN.VALUE = character(1), reference_data, function(x) paste0("<", class(x), ">", collapse = " and "))
|
||||||
if (!all(names(class_sir) == names(class_ref))) {
|
if (!all(names(class_sir) == names(class_ref))) {
|
||||||
stop_("{.arg reference_data} must have the same column names as the 'clinical_breakpoints' data set.", call = .call_depth)
|
stop_("{.arg reference_data} must have the same column names as the {.code clinical_breakpoints} data set.", call = .call_depth)
|
||||||
}
|
}
|
||||||
if (!all(class_sir == class_ref)) {
|
if (!all(class_sir == class_ref)) {
|
||||||
stop_("{.arg reference_data} must be the same structure as the 'clinical_breakpoints' data set. Column '", names(class_ref[class_sir != class_ref][1]), "' is of class ", class_ref[class_sir != class_ref][1], ", but should be of class ", class_sir[class_sir != class_ref][1], ".", call = .call_depth)
|
stop_("{.arg reference_data} must be the same structure as the {.code clinical_breakpoints} data set. Column '", names(class_ref[class_sir != class_ref][1]), "' is of class ", class_ref[class_sir != class_ref][1], ", but should be of class ", class_sir[class_sir != class_ref][1], ".", call = .call_depth)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ sir_calc <- function(...,
|
|||||||
FUN = min
|
FUN = min
|
||||||
)
|
)
|
||||||
if ("SDD" %in% ab_result && "SDD" %in% y && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) {
|
if ("SDD" %in% ab_result && "SDD" %in% y && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) {
|
||||||
message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
|
message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, {.val SDD}. This note will be shown once for this session.", as_note = FALSE)
|
||||||
}
|
}
|
||||||
numerator <- sum(!is.na(y) & y %in% as.double(ab_result), na.rm = TRUE)
|
numerator <- sum(!is.na(y) & y %in% as.double(ab_result), na.rm = TRUE)
|
||||||
denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(anyNA(y))))
|
denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(anyNA(y))))
|
||||||
@@ -152,7 +152,7 @@ sir_calc <- function(...,
|
|||||||
# may contain NAs in any column
|
# may contain NAs in any column
|
||||||
other_values <- setdiff(c(NA, denominator_vals), ab_result)
|
other_values <- setdiff(c(NA, denominator_vals), ab_result)
|
||||||
if ("SDD" %in% ab_result && "SDD" %in% unlist(x_transposed) && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) {
|
if ("SDD" %in% ab_result && "SDD" %in% unlist(x_transposed) && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) {
|
||||||
message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
|
message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, {.val SDD}. This note will be shown once for this session.", as_note = FALSE)
|
||||||
}
|
}
|
||||||
numerator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) any(y %in% ab_result, na.rm = TRUE)))
|
numerator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) any(y %in% ab_result, na.rm = TRUE)))
|
||||||
denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(all(y %in% other_values) & anyNA(y))))
|
denominator <- sum(vapply(FUN.VALUE = logical(1), x_transposed, function(y) !(all(y %in% other_values) & anyNA(y))))
|
||||||
@@ -164,7 +164,7 @@ sir_calc <- function(...,
|
|||||||
print_warning <- TRUE
|
print_warning <- TRUE
|
||||||
}
|
}
|
||||||
if ("SDD" %in% ab_result && "SDD" %in% x && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) {
|
if ("SDD" %in% ab_result && "SDD" %in% x && message_not_thrown_before("sir_calc", only_count, ab_result, entire_session = TRUE)) {
|
||||||
message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, 'SDD'. This note will be shown once for this session.", as_note = FALSE)
|
message_("Note that `", ifelse(only_count, "count", "proportion"), "_", ifelse("S" %in% ab_result, "S", ""), "I", ifelse("R" %in% ab_result, "R", ""), "()` will also include dose-dependent susceptibility, {.val SDD}. This note will be shown once for this session.", as_note = FALSE)
|
||||||
}
|
}
|
||||||
numerator <- sum(x %in% ab_result, na.rm = TRUE)
|
numerator <- sum(x %in% ab_result, na.rm = TRUE)
|
||||||
denominator <- sum(x %in% denominator_vals, na.rm = TRUE)
|
denominator <- sum(x %in% denominator_vals, na.rm = TRUE)
|
||||||
@@ -172,7 +172,7 @@ sir_calc <- function(...,
|
|||||||
|
|
||||||
if (print_warning == TRUE) {
|
if (print_warning == TRUE) {
|
||||||
if (message_not_thrown_before("sir_calc")) {
|
if (message_not_thrown_before("sir_calc")) {
|
||||||
warning_("Increase speed by transforming to class 'sir' on beforehand:\n",
|
warning_("Increase speed by transforming to class {.cls sir} on beforehand:\n",
|
||||||
highlight_code(" your_data %>% mutate_if(is_sir_eligible, as.sir)"),
|
highlight_code(" your_data %>% mutate_if(is_sir_eligible, as.sir)"),
|
||||||
call = FALSE
|
call = FALSE
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user