mirror of
https://github.com/msberends/AMR.git
synced 2026-11-16 06:30:48 +01:00
Let aggregated analyses follow the guideline for the 'I' category in count_df(), proportion_df(), sir_df(), the plotting functions, antibiogram(), wisca(), and bug_drug_combinations(), deprecate combine_SI in favour of guideline, fix format() on bug_drug_combinations() counting I as resistant, and add a shared section 'Interpretation of SIR'
This commit is contained in:
1 parent
dbd95ffa46
commit
0efc8826c8
32 files changed
+511
-199
No files matched your search
@@ -35,6 +35,24 @@ test_that("test-bug/drug.R", {
|
||||
expect_output(suppressMessages(print(b)))
|
||||
expect_true(is.data.frame(format(b)))
|
||||
expect_true(is.data.frame(format(b, add_ab_group = FALSE)))
|
||||
|
||||
# format() calculates resistance following the guideline, taken from bug_drug_combinations() unless set
|
||||
b_eucast <- suppressMessages(bug_drug_combinations(example_isolates, FUN = function(x) x, guideline = "EUCAST"))
|
||||
b_clsi <- suppressMessages(bug_drug_combinations(example_isolates, FUN = function(x) x, guideline = "CLSI"))
|
||||
expect_identical(attr(b_clsi, "guideline"), "CLSI")
|
||||
cons_gen <- subset(b_eucast, mo == "B_STPHY_CONS" & ab == "GEN")
|
||||
n_R <- cons_gen$R + cons_gen$NWT + cons_gen$NS
|
||||
n_IR <- n_R + cons_gen$I
|
||||
get_cons_gen <- function(f) f[f$Drug %like% "GEN", "B_STPHY_CONS", drop = TRUE]
|
||||
expect_true(grepl(paste0("(", n_R, "/", cons_gen$total, ")"), get_cons_gen(format(b_eucast, translate_ab = "ab", language = "en")), fixed = TRUE))
|
||||
expect_true(grepl(paste0("(", n_IR, "/", cons_gen$total, ")"), get_cons_gen(format(b_clsi, translate_ab = "ab", language = "en")), fixed = TRUE))
|
||||
expect_identical(format(b_eucast, guideline = "CLSI"), format(b_clsi))
|
||||
# with guideline = NULL, format() requires its own guideline
|
||||
b_none <- suppressMessages(bug_drug_combinations(example_isolates, FUN = function(x) x, guideline = NULL))
|
||||
expect_error(format(b_none))
|
||||
expect_identical(format(b_none, guideline = "CLSI"), format(b_clsi))
|
||||
# the deprecated combine_SI must be followed literally if set, regardless of the guideline
|
||||
expect_identical(suppressWarnings(format(b_clsi, combine_SI = TRUE)), format(b_eucast))
|
||||
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) {
|
||||
expect_true(example_isolates %>%
|
||||
group_by(ward) %>%
|
||||
|
||||
Reference in new issue
Block a user