mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 08:32:04 +02:00
(v1.6.0.9000) custom EUCAST rules
This commit is contained in:
@ -80,11 +80,10 @@ test_that("EUCAST rules work", {
|
||||
library(dplyr, warn.conflicts = FALSE)
|
||||
expect_equal(suppressWarnings(
|
||||
example_isolates %>%
|
||||
filter(mo_family(mo) == "Enterobacteriaceae") %>%
|
||||
mutate(TIC = as.rsi("R"),
|
||||
PIP = as.rsi("S")) %>%
|
||||
eucast_rules(col_mo = "mo", version_expertrules = 3.1, info = FALSE) %>%
|
||||
left_join_microorganisms(by = "mo") %>%
|
||||
filter(family == "Enterobacteriaceae") %>%
|
||||
pull(PIP) %>%
|
||||
unique() %>%
|
||||
as.character()),
|
||||
@ -145,3 +144,21 @@ test_that("EUCAST rules work", {
|
||||
expect_s3_class(eucast_dosage(c("tobra", "genta", "cipro")), "data.frame")
|
||||
|
||||
})
|
||||
|
||||
test_that("Custom EUCAST rules work", {
|
||||
|
||||
skip_on_cran()
|
||||
x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||
expect_output(print(x))
|
||||
expect_output(print(c(x, x)))
|
||||
expect_output(print(as.list(x, x)))
|
||||
|
||||
# this custom rules makes 8 changes
|
||||
expect_equal(nrow(eucast_rules(example_isolates,
|
||||
rules = "custom",
|
||||
custom_rules = x,
|
||||
info = FALSE,
|
||||
verbose = TRUE)),
|
||||
8)
|
||||
})
|
||||
|
@ -28,20 +28,20 @@ context("kurtosis.R")
|
||||
test_that("kurtosis works", {
|
||||
skip_on_cran()
|
||||
expect_equal(kurtosis(example_isolates$age),
|
||||
3.549319,
|
||||
5.227999,
|
||||
tolerance = 0.00001)
|
||||
|
||||
expect_equal(unname(kurtosis(data.frame(example_isolates$age))),
|
||||
3.549319,
|
||||
5.227999,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(unname(kurtosis(data.frame(example_isolates$age), excess = TRUE)),
|
||||
0.549319,
|
||||
2.227999,
|
||||
tolerance = 0.00001)
|
||||
|
||||
expect_equal(kurtosis(matrix(example_isolates$age)),
|
||||
3.549319,
|
||||
5.227999,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(kurtosis(matrix(example_isolates$age), excess = TRUE),
|
||||
0.549319,
|
||||
2.227999,
|
||||
tolerance = 0.00001)
|
||||
})
|
||||
|
@ -228,8 +228,11 @@ test_that("mdro works", {
|
||||
"ERY == 'R' & age > 60" ~ "Elderly Type B",
|
||||
as_factor = TRUE)
|
||||
expect_output(print(custom))
|
||||
expect_output(print(c(custom, custom)))
|
||||
expect_output(print(as.list(custom, custom)))
|
||||
|
||||
expect_output(x <- mdro(example_isolates, guideline = custom, info = TRUE))
|
||||
expect_equal(as.double(table(x)), c(1066, 43, 891))
|
||||
expect_equal(as.double(table(x)), c(1070, 198, 732))
|
||||
|
||||
expect_output(print(custom_mdro_guideline(AMX == "R" ~ "test", as_factor = FALSE)))
|
||||
expect_error(custom_mdro_guideline())
|
||||
|
@ -28,12 +28,12 @@ context("skewness.R")
|
||||
test_that("skewness works", {
|
||||
skip_on_cran()
|
||||
expect_equal(skewness(example_isolates$age),
|
||||
-0.8958019,
|
||||
-1.212888,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(unname(skewness(data.frame(example_isolates$age))),
|
||||
-0.8958019,
|
||||
-1.212888,
|
||||
tolerance = 0.00001)
|
||||
expect_equal(skewness(matrix(example_isolates$age)),
|
||||
-0.8958019,
|
||||
-1.212888,
|
||||
tolerance = 0.00001)
|
||||
})
|
||||
|
Reference in New Issue
Block a user