mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 18:06:12 +01:00
more unit tests
This commit is contained in:
parent
d0a115d995
commit
510e8f22aa
8
NEWS.md
8
NEWS.md
@ -1,4 +1,6 @@
|
||||
# 0.2.0.90xx (development version)
|
||||
**Published on CRAN: (unpublished)**
|
||||
|
||||
#### New
|
||||
* **BREAKING**: `rsi_df` was removed in favour of new functions `R`, `IR`, `SI` and `S` to selectively calculate resistance or susceptibility. These functions use **hybrid evaluation**, which means that calculations are not done in R directly but rather in C++ using the `Rcpp` package, making them 20 to 30 times faster. The function `rsi` still works, but is deprecated.
|
||||
* **BREAKING**: the methodology for determining first weighted isolates was changed. The antibiotics that are compared between isolates (call *key antibiotics*) to include more first isolates (afterwards called first *weighted* isolates) are now as follows:
|
||||
@ -53,6 +55,8 @@
|
||||
* Unit testing for R 3.0 and the latest available release: https://travis-ci.org/msberends/AMR
|
||||
|
||||
# 0.2.0 (latest stable version)
|
||||
**Published on CRAN: 2018-05-03**
|
||||
|
||||
#### New
|
||||
* Full support for Windows, Linux and macOS
|
||||
* Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies)
|
||||
@ -88,6 +92,8 @@
|
||||
* Added line coverage checking using CodeCov (https://codecov.io/gh/msberends/AMR/tree/master/R)
|
||||
|
||||
# 0.1.1
|
||||
**Published on CRAN: 2018-03-14**
|
||||
|
||||
* `EUCAST_rules` applies for amoxicillin even if ampicillin is missing
|
||||
* Edited column names to comply with GLIMS, the laboratory information system
|
||||
* Added more valid MIC values
|
||||
@ -95,4 +101,6 @@
|
||||
* Added barplots for `rsi` and `mic` classes
|
||||
|
||||
# 0.1.0
|
||||
**Published on CRAN: 2018-02-22**
|
||||
|
||||
* First submission to CRAN.
|
||||
|
@ -275,7 +275,7 @@ EUCAST_rules <- function(tbl,
|
||||
|
||||
# join to microorganisms data set
|
||||
if (!tbl %>% pull(col_bactid) %>% is.bactid()) {
|
||||
# warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.")
|
||||
warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.")
|
||||
}
|
||||
tbl <- tbl %>% left_join_microorganisms(by = col_bactid, suffix = c("_tempmicroorganisms", ""))
|
||||
|
||||
|
@ -171,7 +171,7 @@ first_isolate <- function(tbl,
|
||||
|
||||
if (!is.na(col_bactid)) {
|
||||
if (!tbl %>% pull(col_bactid) %>% is.bactid()) {
|
||||
# warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.")
|
||||
warning("Improve integrity of the `", col_bactid, "` column by transforming it with 'as.bactid'.")
|
||||
}
|
||||
# join to microorganisms data set
|
||||
tbl <- tbl %>% left_join_microorganisms(by = col_bactid)
|
||||
|
@ -16,7 +16,8 @@ test_that("EUCAST rules work", {
|
||||
"ENTAER"), # Enterobacter aerogenes
|
||||
amox = "R", # Amoxicillin
|
||||
stringsAsFactors = FALSE)
|
||||
expect_identical(EUCAST_rules(a, info = FALSE), b)
|
||||
expect_warning(EUCAST_rules(a, info = FALSE))
|
||||
expect_identical(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
||||
expect_identical(suppressWarnings(interpretive_reading(a, info = TRUE)), b)
|
||||
|
||||
a <- data.frame(bactid =
|
||||
@ -29,7 +30,7 @@ test_that("EUCAST rules work", {
|
||||
"STCGRA"), # Streptococcus pyognenes (Lancefield Group A)
|
||||
coli = "R", # Colistin
|
||||
stringsAsFactors = FALSE)
|
||||
expect_equal(EUCAST_rules(a, info = FALSE), b)
|
||||
expect_equal(suppressWarnings(EUCAST_rules(a, info = FALSE)), b)
|
||||
})
|
||||
|
||||
test_that("MO properties work", {
|
||||
|
@ -66,5 +66,20 @@ test_that("frequency table works", {
|
||||
pull(age) %>%
|
||||
sort())
|
||||
|
||||
# check format
|
||||
expect_identical(septic_patients %>%
|
||||
freq(age) %>%
|
||||
format() %>%
|
||||
apply(2, class) %>%
|
||||
unname(),
|
||||
rep("character", 5))
|
||||
|
||||
# check tibble
|
||||
expect_identical(septic_patients %>%
|
||||
freq(age) %>%
|
||||
as_tibble() %>%
|
||||
class() %>%
|
||||
.[1],
|
||||
"tbl_df")
|
||||
})
|
||||
|
||||
|
@ -43,6 +43,25 @@ test_that("resistance works", {
|
||||
expect_warning(susceptibility(as.character(septic_patients$amcl,
|
||||
septic_patients$gent)))
|
||||
|
||||
|
||||
# check for errors
|
||||
expect_error(IR(septic_patients %>% select(amox, amcl)))
|
||||
expect_error(IR("test", minimum = "test"))
|
||||
expect_error(IR("test", as_percent = "test"))
|
||||
expect_error(S("test", minimum = "test"))
|
||||
expect_error(S("test", as_percent = "test"))
|
||||
expect_error(S(septic_patients %>% select(amox, amcl)))
|
||||
expect_error(S("R", septic_patients %>% select(amox, amcl)))
|
||||
|
||||
# check too low amount of isolates
|
||||
expect_identical(IR(septic_patients$amox, minimum = nrow(septic_patients) + 1),
|
||||
NA)
|
||||
expect_identical(S(septic_patients$amox, minimum = nrow(septic_patients) + 1),
|
||||
NA)
|
||||
|
||||
# warning for speed loss
|
||||
expect_warning(S(septic_patients$amcl, as.character(septic_patients$gent)))
|
||||
|
||||
})
|
||||
|
||||
test_that("old rsi works", {
|
||||
@ -129,4 +148,9 @@ test_that("prediction of rsi works", {
|
||||
col_ab = "amox",
|
||||
col_date = "NOT EXISTING COLUMN",
|
||||
info = TRUE))
|
||||
# almost all E. coli are mero S in the Netherlands :)
|
||||
expect_error(resistance_predict(tbl = filter(septic_patients, bactid == "ESCCOL"),
|
||||
col_ab = "mero",
|
||||
col_date = "date",
|
||||
info = TRUE))
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user