mirror of
https://github.com/msberends/AMR.git
synced 2024-12-25 06:46:11 +01:00
(v1.5.0.9007) updated unit tests
This commit is contained in:
parent
4eab095306
commit
27f084d819
8
.github/workflows/check.yaml
vendored
8
.github/workflows/check.yaml
vendored
@ -64,8 +64,8 @@ jobs:
|
||||
- {os: ubuntu-20.04, r: '3.5', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.4', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.3', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
# - {os: ubuntu-20.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-20.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
|
||||
- {os: ubuntu-16.04, r: 'devel', 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"}
|
||||
@ -75,8 +75,8 @@ jobs:
|
||||
- {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: 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.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.2', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
# - {os: ubuntu-16.04, r: '3.1', allowfail: true, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
- {os: ubuntu-16.04, r: '3.0', allowfail: false, rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
|
||||
|
||||
env:
|
||||
|
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 1.5.0.9006
|
||||
Version: 1.5.0.9007
|
||||
Date: 2021-01-18
|
||||
Title: Antimicrobial Resistance Analysis
|
||||
Authors@R: c(
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 1.5.0.9006
|
||||
# AMR 1.5.0.9007
|
||||
## <small>Last updated: 18 January 2021</small>
|
||||
|
||||
### New
|
||||
|
4
R/mdro.R
4
R/mdro.R
@ -805,6 +805,7 @@ mdro <- function(x,
|
||||
x[which(x$genus == "Escherichia" & x$species == "hermannii"), ab_NA(c(TCC, TZP))] <- NA
|
||||
x[which((x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
| (x$genus == "Morganella" & x$species == "morganii")
|
||||
@ -824,6 +825,7 @@ mdro <- function(x,
|
||||
x[which((x$genus == "Citrobacter" & x$species == "koseri")
|
||||
| (x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Escherichia" & x$species == "hermannii")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
@ -836,6 +838,7 @@ mdro <- function(x,
|
||||
| (x$genus == "Serratia" & x$species == "marcescens")), ab_NA(AMP)] <- NA
|
||||
x[which((x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
| (x$genus == "Morganella" & x$species == "morganii")
|
||||
@ -845,6 +848,7 @@ mdro <- function(x,
|
||||
x[which((x$genus == "Citrobacter" & x$species == "freundii")
|
||||
| (x$genus == "Citrobacter" & x$species == "koseri")
|
||||
| (x$genus == "Enterobacter" & x$species == "aerogenes")
|
||||
| (x$genus == "Klebsiella" & x$species == "aerogenes") # new name (2017)
|
||||
| (x$genus == "Enterobacter" & x$species == "cloacae")
|
||||
| (x$genus == "Hafnia" & x$species == "alvei")
|
||||
| (x$genus == "Providencia" & x$species == "rettgeri")
|
||||
|
Binary file not shown.
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -236,9 +236,9 @@
|
||||
<small>Source: <a href='https://github.com/msberends/AMR/blob/master/NEWS.md'><code>NEWS.md</code></a></small>
|
||||
</div>
|
||||
|
||||
<div id="amr-1509006" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.5.0.9006">
|
||||
<a href="#amr-1509006" class="anchor"></a>AMR 1.5.0.9006<small> Unreleased </small>
|
||||
<div id="amr-1509007" class="section level1">
|
||||
<h1 class="page-header" data-toc-text="1.5.0.9007">
|
||||
<a href="#amr-1509007" class="anchor"></a>AMR 1.5.0.9007<small> Unreleased </small>
|
||||
</h1>
|
||||
<div id="last-updated-18-january-2021" class="section level2">
|
||||
<h2 class="hasAnchor">
|
||||
|
@ -12,7 +12,7 @@ articles:
|
||||
datasets: datasets.html
|
||||
resistance_predict: resistance_predict.html
|
||||
welcome_to_AMR: welcome_to_AMR.html
|
||||
last_built: 2021-01-18T15:57Z
|
||||
last_built: 2021-01-18T17:45Z
|
||||
urls:
|
||||
reference: https://msberends.github.io/AMR//reference
|
||||
article: https://msberends.github.io/AMR//articles
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
</button>
|
||||
<span class="navbar-brand">
|
||||
<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.5.0.9006</span>
|
||||
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.5.0.9007</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
@ -50,20 +50,21 @@ test_that("EUCAST rules work", {
|
||||
expect_warning(eucast_rules(data.frame(mo = "Escherichia coli", vancomycin = "S", stringsAsFactors = TRUE)))
|
||||
|
||||
expect_identical(colnames(example_isolates),
|
||||
colnames(suppressWarnings(eucast_rules(example_isolates))))
|
||||
colnames(suppressWarnings(eucast_rules(example_isolates, info = FALSE))))
|
||||
expect_output(suppressMessages(eucast_rules(example_isolates, info = TRUE)))
|
||||
|
||||
a <- data.frame(mo = c("Klebsiella pneumoniae",
|
||||
"Pseudomonas aeruginosa",
|
||||
"Enterobacter aerogenes"),
|
||||
"Enterobacter cloacae"),
|
||||
amox = "-", # Amoxicillin
|
||||
stringsAsFactors = FALSE)
|
||||
b <- data.frame(mo = c("Klebsiella pneumoniae",
|
||||
"Pseudomonas aeruginosa",
|
||||
"Enterobacter aerogenes"),
|
||||
"Enterobacter cloacae"),
|
||||
amox = "R", # Amoxicillin
|
||||
stringsAsFactors = FALSE)
|
||||
expect_identical(suppressWarnings(eucast_rules(a, "mo", info = FALSE)), b)
|
||||
expect_identical(suppressWarnings(eucast_rules(a, "mo", info = TRUE)), b)
|
||||
expect_output(suppressMessages(suppressWarnings(eucast_rules(a, "mo", info = TRUE))))
|
||||
|
||||
a <- data.frame(mo = c("Staphylococcus aureus",
|
||||
"Streptococcus group A"),
|
||||
@ -81,8 +82,8 @@ test_that("EUCAST rules work", {
|
||||
example_isolates %>%
|
||||
mutate(TIC = as.rsi("R"),
|
||||
PIP = as.rsi("S")) %>%
|
||||
eucast_rules(col_mo = "mo", version_expertrules = 3.1) %>%
|
||||
left_join_microorganisms() %>%
|
||||
eucast_rules(col_mo = "mo", version_expertrules = 3.1, info = FALSE) %>%
|
||||
left_join_microorganisms(by = "mo") %>%
|
||||
filter(family == "Enterobacteriaceae") %>%
|
||||
pull(PIP) %>%
|
||||
unique() %>%
|
||||
|
@ -34,13 +34,13 @@ test_that("mdro works", {
|
||||
expect_error(mdro(example_isolates, guideline = c("BRMO", "MRGN"), info = TRUE))
|
||||
expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE))
|
||||
|
||||
outcome <- suppressWarnings(mdro(example_isolates))
|
||||
outcome <- mdro(example_isolates, "eucast3.1", info = TRUE)
|
||||
outcome <- eucast_exceptional_phenotypes(example_isolates, info = TRUE)
|
||||
expect_output(suppressMessages(suppressWarnings(mdro(example_isolates, info = TRUE))))
|
||||
expect_output(suppressMessages(suppressWarnings(mdro(example_isolates, "eucast3.1", info = TRUE))))
|
||||
expect_output(outcome <- suppressMessages(suppressWarnings(eucast_exceptional_phenotypes(example_isolates, info = TRUE))))
|
||||
# check class
|
||||
expect_equal(class(outcome), c("ordered", "factor"))
|
||||
|
||||
outcome <- mdro(example_isolates, "nl", info = TRUE)
|
||||
expect_output(outcome <- mdro(example_isolates, "nl", info = TRUE))
|
||||
# check class
|
||||
expect_equal(class(outcome), c("ordered", "factor"))
|
||||
|
||||
@ -228,15 +228,14 @@ test_that("mdro works", {
|
||||
"ERY == 'R' & age > 60" ~ "Elderly Type B",
|
||||
as_factor = TRUE)
|
||||
expect_output(print(custom))
|
||||
x <- mdro(example_isolates, guideline = custom, info = TRUE)
|
||||
expect_equal(as.double(table(x)), c(43, 891, 1066))
|
||||
expect_output(x <- mdro(example_isolates, guideline = custom, info = TRUE))
|
||||
expect_equal(as.double(table(x)), c(1066, 43, 891))
|
||||
|
||||
expect_output(print(custom_mdro_guideline(AMX == "R" ~ "test", as_factor = FALSE)))
|
||||
expect_error(custom_mdro_guideline())
|
||||
expect_error(custom_mdro_guideline("test"))
|
||||
expect_error(custom_mdro_guideline("test" ~ c(1:3)))
|
||||
expect_error(custom_mdro_guideline("test" ~ A))
|
||||
expect_error(custom_mdro_guideline(test ~ "A"))
|
||||
expect_warning(mdro(example_isolates,
|
||||
# since `test` gives an error, it will be ignored with a warning
|
||||
guideline = custom_mdro_guideline(test ~ "A"),
|
||||
|
@ -27,25 +27,25 @@ context("resistance_predict.R")
|
||||
|
||||
test_that("prediction of rsi works", {
|
||||
skip_on_cran()
|
||||
AMX_R <- example_isolates %>%
|
||||
filter(mo == "B_ESCHR_COLI") %>%
|
||||
rsi_predict(col_ab = "AMX",
|
||||
col_date = "date",
|
||||
model = "binomial",
|
||||
minimum = 10,
|
||||
info = TRUE) %>%
|
||||
pull("value")
|
||||
|
||||
library(dplyr)
|
||||
expect_output(AMX_R <- example_isolates %>%
|
||||
filter(mo == "B_ESCHR_COLI") %>%
|
||||
rsi_predict(col_ab = "AMX",
|
||||
col_date = "date",
|
||||
model = "binomial",
|
||||
minimum = 10,
|
||||
info = TRUE) %>%
|
||||
pull("value"))
|
||||
# AMX resistance will increase according to data set `example_isolates`
|
||||
expect_true(AMX_R[3] < AMX_R[20])
|
||||
|
||||
x <- resistance_predict(example_isolates, col_ab = "AMX", year_min = 2010, model = "binomial")
|
||||
|
||||
expect_output(x <- suppressMessages(resistance_predict(example_isolates, col_ab = "AMX", year_min = 2010, model = "binomial", info = TRUE)))
|
||||
pdf(NULL) # prevent Rplots.pdf being created
|
||||
expect_silent(plot(x))
|
||||
expect_silent(ggplot_rsi_predict(x))
|
||||
expect_error(ggplot_rsi_predict(example_isolates))
|
||||
|
||||
library(dplyr, warn.conflicts = FALSE)
|
||||
|
||||
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COLI"),
|
||||
model = "binomial",
|
||||
col_ab = "AMX",
|
||||
|
Loading…
Reference in New Issue
Block a user