diff --git a/DESCRIPTION b/DESCRIPTION index 213aaf15a..fe75420f9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.0.0.9004 +Version: 1.0.0.9005 Date: 2020-02-21 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 0aa54ceda..ab0091e61 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 1.0.0.9004 +# AMR 1.0.0.9005 ## Last updated: 21-Feb-2020 ### Changed @@ -13,6 +13,7 @@ ``` * Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole * Added `uti` (as abbreviation of urinary tract infections) as parameter to `as.rsi()`, so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs +* Info printing in functions `eucast_rules()`, `first_isolate()`, `mdro()` and `resistance_predict()` will now at default only print when R is in an interactive mode (i.e. not in RMarkdown) # AMR 1.0.0 diff --git a/R/eucast_rules.R b/R/eucast_rules.R index 0fb430719..8c277eb39 100755 --- a/R/eucast_rules.R +++ b/R/eucast_rules.R @@ -197,7 +197,7 @@ EUCAST_VERSION_EXPERT_RULES <- "3.1, 2016" #' } eucast_rules <- function(x, col_mo = NULL, - info = TRUE, + info = interactive(), rules = c("breakpoints", "expert", "other", "all"), verbose = FALSE, ...) { diff --git a/R/first_isolate.R b/R/first_isolate.R index c4ac12f65..f421aea15 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -148,7 +148,7 @@ first_isolate <- function(x, type = "keyantibiotics", ignore_I = TRUE, points_threshold = 2, - info = TRUE, + info = interactive(), include_unknown = FALSE, ...) { diff --git a/R/mdro.R b/R/mdro.R index af1a1b1bd..00184bda0 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -84,7 +84,7 @@ mdro <- function(x, guideline = "CMI2012", col_mo = NULL, - info = TRUE, + info = interactive(), pct_required_classes = 0.5, combine_SI = TRUE, verbose = FALSE, diff --git a/R/misc.R b/R/misc.R index 0b375c1f3..d007bf7a3 100755 --- a/R/misc.R +++ b/R/misc.R @@ -125,6 +125,7 @@ search_type_in_df <- function(x, type) { found <- colnames(x)[colnames(x) %like% "(urine|urinary)"][1] } if (!is.null(found)) { + # this column should contain logicals if (!is.logical(x[, found, drop = TRUE])) { message(red(paste0("NOTE: Column `", bold(found), "` found as input for `col_", type, "`, but this column does not contain 'logical' values (TRUE/FALSE) and was ignored."))) diff --git a/R/resistance_predict.R b/R/resistance_predict.R index 838788c79..48af6e3e7 100755 --- a/R/resistance_predict.R +++ b/R/resistance_predict.R @@ -121,7 +121,7 @@ resistance_predict <- function(x, model = NULL, I_as_S = TRUE, preserve_measurements = TRUE, - info = TRUE, + info = interactive(), ...) { if (nrow(x) == 0) { diff --git a/_pkgdown.yml b/_pkgdown.yml index e6248314a..c6b8a71c8 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -135,6 +135,7 @@ reference: - "`antibiotics`" - "`antivirals`" - "`example_isolates`" + - "`example_isolates_unclean`" - "`microorganisms.codes`" - "`microorganisms.old`" - "`microorganisms`" diff --git a/docs/404.html b/docs/404.html index 412f36d9e..ebc5ede15 100644 --- a/docs/404.html +++ b/docs/404.html @@ -78,7 +78,7 @@ diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index c2ef2b190..8bf2e8a11 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -78,7 +78,7 @@ diff --git a/docs/articles/index.html b/docs/articles/index.html index 6c2231f88..5fed4963f 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -78,7 +78,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 87a9651c3..0851da00f 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -78,7 +78,7 @@ diff --git a/docs/index.html b/docs/index.html index c8d397a0a..3c0ed56a2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ diff --git a/docs/news/index.html b/docs/news/index.html index 8cf9bcb1c..e87af7e1b 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -78,7 +78,7 @@ @@ -219,9 +219,9 @@ -
Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole
Added uti (as abbreviation of urinary tract infections) as parameter to as.rsi(), so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs
Info printing in functions eucast_rules(), first_isolate(), mdro() and resistance_predict() will now at default only print when R is in an interactive mode (i.e. not in RMarkdown)
eucast_rules( x, col_mo = NULL, - info = TRUE, + info = interactive(), rules = c("breakpoints", "expert", "other", "all"), verbose = FALSE, ... diff --git a/docs/reference/example_isolates_unclean.html b/docs/reference/example_isolates_unclean.html index 7d98a1fc7..a104e387d 100644 --- a/docs/reference/example_isolates_unclean.html +++ b/docs/reference/example_isolates_unclean.html @@ -79,7 +79,7 @@ diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 60d8f6eae..26ddd36fd 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -79,7 +79,7 @@ @@ -241,7 +241,7 @@ type = "keyantibiotics", ignore_I = TRUE, points_threshold = 2, - info = TRUE, + info = interactive(), include_unknown = FALSE, ... ) diff --git a/docs/reference/index.html b/docs/reference/index.html index 6b1c899bb..f7c2ee1e4 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -78,7 +78,7 @@ @@ -451,6 +451,12 @@Data set with 2,000 example isolates
+ + + ++ Data set with unclean data
+ diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 084d51a3f..95ac99366 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -79,7 +79,7 @@ @@ -229,7 +229,7 @@ x, guideline = "CMI2012", col_mo = NULL, - info = TRUE, + info = interactive(), pct_required_classes = 0.5, combine_SI = TRUE, verbose = FALSE, diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 6a25eb111..58fef3c23 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -79,7 +79,7 @@ @@ -236,7 +236,7 @@ model = NULL, I_as_S = TRUE, preserve_measurements = TRUE, - info = TRUE, + info = interactive(), ... ) @@ -251,7 +251,7 @@ model = NULL, I_as_S = TRUE, preserve_measurements = TRUE, - info = TRUE, + info = interactive(), ... ) diff --git a/man/eucast_rules.Rd b/man/eucast_rules.Rd index e2a6b4d1d..c1b1f37b0 100644 --- a/man/eucast_rules.Rd +++ b/man/eucast_rules.Rd @@ -19,7 +19,7 @@ Leclercq et al. \strong{EUCAST expert rules in antimicrobial susceptibility test eucast_rules( x, col_mo = NULL, - info = TRUE, + info = interactive(), rules = c("breakpoints", "expert", "other", "all"), verbose = FALSE, ... diff --git a/man/first_isolate.Rd b/man/first_isolate.Rd index a3b30774d..cd9f51c97 100755 --- a/man/first_isolate.Rd +++ b/man/first_isolate.Rd @@ -27,7 +27,7 @@ first_isolate( type = "keyantibiotics", ignore_I = TRUE, points_threshold = 2, - info = TRUE, + info = interactive(), include_unknown = FALSE, ... ) diff --git a/man/mdro.Rd b/man/mdro.Rd index 727dc1916..a7f3e9be2 100644 --- a/man/mdro.Rd +++ b/man/mdro.Rd @@ -22,7 +22,7 @@ mdro( x, guideline = "CMI2012", col_mo = NULL, - info = TRUE, + info = interactive(), pct_required_classes = 0.5, combine_SI = TRUE, verbose = FALSE, diff --git a/man/resistance_predict.Rd b/man/resistance_predict.Rd index 6f07acabc..3356f1b38 100644 --- a/man/resistance_predict.Rd +++ b/man/resistance_predict.Rd @@ -18,7 +18,7 @@ resistance_predict( model = NULL, I_as_S = TRUE, preserve_measurements = TRUE, - info = TRUE, + info = interactive(), ... ) @@ -33,7 +33,7 @@ rsi_predict( model = NULL, I_as_S = TRUE, preserve_measurements = TRUE, - info = TRUE, + info = interactive(), ... ) diff --git a/tests/testthat/test-disk.R b/tests/testthat/test-disk.R index 850426e38..f463319fc 100755 --- a/tests/testthat/test-disk.R +++ b/tests/testthat/test-disk.R @@ -31,5 +31,9 @@ test_that("disk works", { expect_silent(as.disk(levels(as.disk(15)))) expect_warning(as.disk("INVALID VALUE")) + + expect_output(print(as.disk(12))) + library(tibble) + expect_output(print(tibble(d = as.disk(12)))) }) diff --git a/tests/testthat/test-eucast_rules.R b/tests/testthat/test-eucast_rules.R index 531791a33..5d5ca8b5b 100755 --- a/tests/testthat/test-eucast_rules.R +++ b/tests/testthat/test-eucast_rules.R @@ -110,9 +110,9 @@ test_that("EUCAST rules work", { "S") # also test norf - expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S")))) + expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"), info = TRUE))) # check verbose output - expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE))) + expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE, info = TRUE))) }) diff --git a/tests/testthat/test-first_isolate.R b/tests/testthat/test-first_isolate.R index 5adf13b03..73c5cf6a7 100755 --- a/tests/testthat/test-first_isolate.R +++ b/tests/testthat/test-first_isolate.R @@ -141,7 +141,8 @@ test_that("first isolates work", { mutate(first = first_isolate(., "date", "patient_id", col_mo = "mo", col_specimen = "specimen", - filter_specimen = "something_unexisting"))) + filter_specimen = "something_unexisting", + info = TRUE))) # printing of exclusion message expect_message(example_isolates %>% @@ -149,7 +150,8 @@ test_that("first isolates work", { col_mo = "mo", col_patient_id = "patient_id", col_testcode = "gender", - testcodes_exclude = "M")) + testcodes_exclude = "M", + info = TRUE)) # errors expect_error(first_isolate("date", "patient_id", col_mo = "mo"))