diff --git a/DESCRIPTION b/DESCRIPTION index 86c24480d..48985de19 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 2.1.1.9198 +Version: 2.1.1.9199 Date: 2025-03-14 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) diff --git a/NEWS.md b/NEWS.md index 2df2e8fd0..9dca0b846 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# AMR 2.1.1.9198 +# AMR 2.1.1.9199 *(this beta version will eventually become v3.0. We're happy to reach a new major milestone soon, which will be all about the new One Health support! Install this beta using [the instructions here](https://msberends.github.io/AMR/#latest-development-version).)* diff --git a/PythonPackage/AMR/AMR.egg-info/PKG-INFO b/PythonPackage/AMR/AMR.egg-info/PKG-INFO index d8b057d73..4087ca95d 100644 --- a/PythonPackage/AMR/AMR.egg-info/PKG-INFO +++ b/PythonPackage/AMR/AMR.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.2 Name: AMR -Version: 2.1.1.9198 +Version: 2.1.1.9199 Summary: A Python wrapper for the AMR R package Home-page: https://github.com/msberends/AMR Author: Matthijs Berends diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9198.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9198.tar.gz deleted file mode 100644 index c1a9a771f..000000000 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9198.tar.gz and /dev/null differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9198-py3-none-any.whl b/PythonPackage/AMR/dist/amr-2.1.1.9199-py3-none-any.whl similarity index 53% rename from PythonPackage/AMR/dist/amr-2.1.1.9198-py3-none-any.whl rename to PythonPackage/AMR/dist/amr-2.1.1.9199-py3-none-any.whl index 4cbfef939..e14381586 100644 Binary files a/PythonPackage/AMR/dist/amr-2.1.1.9198-py3-none-any.whl and b/PythonPackage/AMR/dist/amr-2.1.1.9199-py3-none-any.whl differ diff --git a/PythonPackage/AMR/dist/amr-2.1.1.9199.tar.gz b/PythonPackage/AMR/dist/amr-2.1.1.9199.tar.gz new file mode 100644 index 000000000..752187551 Binary files /dev/null and b/PythonPackage/AMR/dist/amr-2.1.1.9199.tar.gz differ diff --git a/PythonPackage/AMR/setup.py b/PythonPackage/AMR/setup.py index 314651419..d7e863aaf 100644 --- a/PythonPackage/AMR/setup.py +++ b/PythonPackage/AMR/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='AMR', - version='2.1.1.9198', + version='2.1.1.9199', packages=find_packages(), install_requires=[ 'rpy2', diff --git a/R/aa_helper_functions.R b/R/aa_helper_functions.R index 8f6e9be7f..73e60c8b1 100644 --- a/R/aa_helper_functions.R +++ b/R/aa_helper_functions.R @@ -532,9 +532,14 @@ word_wrap <- function(..., url = paste0("ide:run:AMR::", parts[cmds & parts %unlike% "[.]"]), txt = parts[cmds & parts %unlike% "[.]"] ) + # datasets should give help page as well + parts[parts %in% c("antimicrobials", "microorganisms", "microorganisms.codes", "microorganisms.groups")] <- font_url( + url = paste0("ide:help:AMR::", gsub("()", "", parts[parts %in% c("antimicrobials", "microorganisms", "microorganisms.codes", "microorganisms.groups")], fixed = TRUE)), + txt = parts[parts %in% c("antimicrobials", "microorganisms", "microorganisms.codes", "microorganisms.groups")] + ) # text starting with `?` must also lead to the help page parts[parts %like% "^[?]"] <- font_url( - url = paste0("ide:help:AMR::", gsub("()", "", gsub("^[?]", "", parts[parts %like% "^[?]"]), fixed = TRUE)), + url = paste0("ide:help:AMR::", parts[parts %like% "^[?]"]), txt = parts[parts %like% "^[?]"] ) msg <- paste0(parts, collapse = "`") diff --git a/R/mo.R b/R/mo.R index 8819968db..1904e4338 100755 --- a/R/mo.R +++ b/R/mo.R @@ -242,7 +242,14 @@ as.mo <- function(x, # one exception: "Fungi" matches the kingdom, but instead it should return the 'unknown' code for fungi out[out == "F_[KNG]_FUNGI"] <- "F_FUNGUS" # From known codes ---- - out[is.na(out) & toupper(x) %in% AMR::microorganisms.codes$code] <- AMR::microorganisms.codes$mo[match(toupper(x)[is.na(out) & toupper(x) %in% AMR::microorganisms.codes$code], AMR::microorganisms.codes$code)] + ind <- is.na(out) & toupper(x) %in% AMR::microorganisms.codes$code + out[ind] <- AMR::microorganisms.codes$mo[match(toupper(x)[ind], AMR::microorganisms.codes$code)] + if (length(which(ind)) > 0 && isTRUE(info) && message_not_thrown_before("as.mo_microorganisms.codes", is.na(out), toupper(x))) { + message_( + "Retrieved value", ifelse(sum(ind) > 1, "s", ""), + " from the `microorganisms.codes` data set for ", vector_and(toupper(x)[ind]), "." + ) + } # From SNOMED ---- # based on this extremely fast gem: https://stackoverflow.com/a/11002456/4575331 snomeds <- unlist(AMR_env$MO_lookup$snomed) diff --git a/_pkgdown.yml b/_pkgdown.yml index 89430a521..352e5ddb1 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -65,72 +65,70 @@ home: structure: [toc, links, authors] navbar: - title: "AMR (for R)" - left: - # - text: "Home" - # icon: "fa-home" - # href: "index.html" - - text: "How to" - icon: "fa-question-circle" - menu: - - text: "Conduct AMR Analysis" - icon: "fa-directions" - href: "articles/AMR.html" - - text: "Generate Antibiogram (Trad./Syndromic/WISCA)" - icon: "fa-file-prescription" - href: "reference/antibiogram.html" # reference instead of an article - - text: "Predict Antimicrobial Resistance" - icon: "fa-dice" - href: "articles/resistance_predict.html" - - text: "Download Data Sets for Own Use" - icon: "fa-database" - href: "articles/datasets.html" - - text: "Use AMR for Predictive Modelling (tidymodels)" - icon: "fa-square-root-variable" - href: "articles/AMR_with_tidymodels.html" - - text: "Set User- Or Team-specific Package Settings" - icon: "fa-gear" - href: "reference/AMR-options.html" - - text: "Conduct Principal Component Analysis for AMR" - icon: "fa-compress" - href: "articles/PCA.html" - - text: "Determine Multi-Drug Resistance (MDR)" - icon: "fa-skull-crossbones" - href: "articles/MDR.html" - - text: "Work with WHONET Data" - icon: "fa-globe-americas" - href: "articles/WHONET.html" - # - text: "Import Data From SPSS/Stata" - # icon: "fa-file-upload" - # href: "articles/SPSS.html" - - text: "Apply Eucast Rules" - icon: "fa-exchange-alt" - href: "articles/EUCAST.html" - - text: "Get Taxonomy of a Microorganism" - icon: "fa-bug" - href: "reference/mo_property.html" # reference instead of an article - - text: "Get Properties of an Antibiotic Drug" - icon: "fa-capsules" - href: "reference/ab_property.html" # reference instead of an article - - text: "Get Properties of an Antiviral Drug" - icon: "fa-capsules" - href: "reference/av_property.html" # reference instead of an article - - text: "AMR for Python" - icon: "fab fa-python" - href: "articles/AMR_for_Python.html" - - text: "Manual" - icon: "fa-book-open" - href: "reference/index.html" - - text: "Authors" - icon: "fa-users" - href: "authors.html" - right: - - text: "Changelog" - icon: "far fa-newspaper" - href: "news/index.html" - - text: "Source Code" - icon: "fab fa-github" - href: "https://github.com/msberends/AMR" + structure: + title: "AMR (for R)" + left: + - text: "How to" + icon: "fa-question-circle" + menu: + - text: "Conduct AMR Analysis" + icon: "fa-directions" + href: "articles/AMR.html" + - text: "Generate Antibiogram (Trad./Syndromic/WISCA)" + icon: "fa-file-prescription" + href: "reference/antibiogram.html" # reference instead of an article + - text: "Predict Antimicrobial Resistance" + icon: "fa-dice" + href: "articles/resistance_predict.html" + - text: "Download Data Sets for Own Use" + icon: "fa-database" + href: "articles/datasets.html" + - text: "Use AMR for Predictive Modelling (tidymodels)" + icon: "fa-square-root-variable" + href: "articles/AMR_with_tidymodels.html" + - text: "Set User- Or Team-specific Package Settings" + icon: "fa-gear" + href: "reference/AMR-options.html" + - text: "Conduct Principal Component Analysis for AMR" + icon: "fa-compress" + href: "articles/PCA.html" + - text: "Determine Multi-Drug Resistance (MDR)" + icon: "fa-skull-crossbones" + href: "articles/MDR.html" + - text: "Work with WHONET Data" + icon: "fa-globe-americas" + href: "articles/WHONET.html" + - text: "Apply Eucast Rules" + icon: "fa-exchange-alt" + href: "articles/EUCAST.html" + - text: "Get Taxonomy of a Microorganism" + icon: "fa-bug" + href: "reference/mo_property.html" # reference instead of an article + - text: "Get Properties of an Antibiotic Drug" + icon: "fa-capsules" + href: "reference/ab_property.html" # reference instead of an article + - text: "Get Properties of an Antiviral Drug" + icon: "fa-capsules" + href: "reference/av_property.html" # reference instead of an article + - text: "AMR for Python" + icon: "fab fa-python" + href: "articles/AMR_for_Python.html" + - text: "Manual" + icon: "fa-book-open" + href: "reference/index.html" + - text: "Authors" + icon: "fa-users" + href: "authors.html" + right: [search, amrchangelog, amrgit] + components: + amrchangelog: + icon: fa-newspaper + href: news/index.html + aria-label: Changelog + amrgit: + icon: fa-github + href: https://github.com/msberends/AMR" + aria-label: Source Code reference: - title: "Introduction to the package" diff --git a/data-raw/gpt_training_text_v2.1.1.9198.txt b/data-raw/gpt_training_text_v2.1.1.9199.txt similarity index 99% rename from data-raw/gpt_training_text_v2.1.1.9198.txt rename to data-raw/gpt_training_text_v2.1.1.9199.txt index 8f5223236..1fcc296ef 100644 --- a/data-raw/gpt_training_text_v2.1.1.9198.txt +++ b/data-raw/gpt_training_text_v2.1.1.9199.txt @@ -1,6 +1,6 @@ This knowledge base contains all context you must know about the AMR package for R. You are a GPT trained to be an assistant for the AMR package in R. You are an incredible R specialist, especially trained in this package and in the tidyverse. -First and foremost, you are trained on version 2.1.1.9198. Remember this whenever someone asks which AMR package version you’re at. +First and foremost, you are trained on version 2.1.1.9199. Remember this whenever someone asks which AMR package version you’re at. Below are the contents of the file, the file, and all the files (documentation) in the package. Every file content is split using 100 hypens. ---------------------------------------------------------------------------------------------------- diff --git a/tests/testthat/test-_deprecated.R b/tests/testthat/test-_deprecated.R index 9ff237722..c06a2fd5e 100644 --- a/tests/testthat/test-_deprecated.R +++ b/tests/testthat/test-_deprecated.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("deprecated works", { +test_that("test-_deprecated.R", { expect_warning(example_isolates[, ab_class("mycobact")]) expect_warning(example_isolates[, ab_selector(name %like% "trim")]) }) diff --git a/tests/testthat/test-_misc.R b/tests/testthat/test-_misc.R index 43d33d09f..fb8464ddd 100755 --- a/tests/testthat/test-_misc.R +++ b/tests/testthat/test-_misc.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("misc works", { +test_that("test-misc.R", { expect_equal(AMR:::percentage(0.25), "25%") expect_equal(AMR:::percentage(0.5), "50%") expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%") diff --git a/tests/testthat/test-ab.R b/tests/testthat/test-ab.R index ede941943..ed949c4a0 100755 --- a/tests/testthat/test-ab.R +++ b/tests/testthat/test-ab.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("ab works", { +test_that("test-ab.R", { ab_reset_session() expect_equal( diff --git a/tests/testthat/test-ab_from_text.R b/tests/testthat/test-ab_from_text.R index 2aab027ef..2151b8fb7 100644 --- a/tests/testthat/test-ab_from_text.R +++ b/tests/testthat/test-ab_from_text.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("ab_from_text works", { +test_that("test-ab_from_text.R", { ab_reset_session() expect_identical( diff --git a/tests/testthat/test-ab_property.R b/tests/testthat/test-ab_property.R index 5427122fa..55d88e10b 100644 --- a/tests/testthat/test-ab_property.R +++ b/tests/testthat/test-ab_property.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("ab_property works", { +test_that("test-ab_property.R", { ab_reset_session() expect_identical(ab_name("AMX", language = NULL), "Amoxicillin") diff --git a/tests/testthat/test-age.R b/tests/testthat/test-age.R index a92460097..86c979d9b 100644 --- a/tests/testthat/test-age.R +++ b/tests/testthat/test-age.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("age works", { +test_that("test-age.R", { expect_equal( age( x = c("1980-01-01", "1985-01-01", "1990-01-01"), diff --git a/tests/testthat/test-amr_selectors.R b/tests/testthat/test-amr_selectors.R index 73fdf971b..f71e74a1e 100644 --- a/tests/testthat/test-amr_selectors.R +++ b/tests/testthat/test-amr_selectors.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("amr selectors works", { +test_that("test-amr selectors.R", { # antibiotic class selectors expect_equal(ncol(example_isolates[, aminoglycosides(), drop = FALSE]), 4, tolerance = 0.5) expect_equal(ncol(example_isolates[, aminopenicillins(), drop = FALSE]), 2, tolerance = 0.5) diff --git a/tests/testthat/test-antibiogram.R b/tests/testthat/test-antibiogram.R index ab0af208f..9ffc146b0 100644 --- a/tests/testthat/test-antibiogram.R +++ b/tests/testthat/test-antibiogram.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("antibiogram works", { +test_that("test-antibiogram.R", { # Traditional antibiogram ---------------------------------------------- ab1 <- antibiogram(example_isolates, diff --git a/tests/testthat/test-atc_online.R b/tests/testthat/test-atc_online.R index 7e9d49539..b4591e920 100644 --- a/tests/testthat/test-atc_online.R +++ b/tests/testthat/test-atc_online.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("atc_online works", { +test_that("test-atc_online.R", { if (AMR:::pkg_is_available("curl") && AMR:::pkg_is_available("rvest") && AMR:::pkg_is_available("xml2") && diff --git a/tests/testthat/test-av.R b/tests/testthat/test-av.R index 47c16718f..fb9ffd10f 100755 --- a/tests/testthat/test-av.R +++ b/tests/testthat/test-av.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("av works", { +test_that("test-av.R", { expect_equal( as.character(as.av(c( "J05AB01", diff --git a/tests/testthat/test-av_from_text.R b/tests/testthat/test-av_from_text.R index 4fd6d900a..6393d5b0f 100644 --- a/tests/testthat/test-av_from_text.R +++ b/tests/testthat/test-av_from_text.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("av_from_text works", { +test_that("test-av_from_text.R", { expect_identical( av_from_text("28/03/2020 regular aciclovir 500mg po tds")[[1]], as.av("Aciclovir") diff --git a/tests/testthat/test-av_property.R b/tests/testthat/test-av_property.R index d7abd14e4..7a3f4380b 100644 --- a/tests/testthat/test-av_property.R +++ b/tests/testthat/test-av_property.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("ab_property works", { +test_that("test-ab_property.R", { expect_identical(av_name("ACI", language = NULL), "Aciclovir") expect_identical(av_atc("ACI"), "J05AB01") expect_identical(av_cid("ACI"), as.integer(135398513)) diff --git a/tests/testthat/test-availability.R b/tests/testthat/test-availability.R index a6e08f0b3..e3545e226 100644 --- a/tests/testthat/test-availability.R +++ b/tests/testthat/test-availability.R @@ -27,6 +27,6 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("availibility works", { +test_that("test-availibility.R", { expect_inherits(availability(example_isolates), "data.frame") }) diff --git a/tests/testthat/test-bug_drug_combinations.R b/tests/testthat/test-bug_drug_combinations.R index c9b80697c..032e82b79 100644 --- a/tests/testthat/test-bug_drug_combinations.R +++ b/tests/testthat/test-bug_drug_combinations.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("bug/drug works", { +test_that("test-bug/drug.R", { b <- suppressWarnings(bug_drug_combinations(example_isolates)) expect_inherits(b, "bug_drug_combinations") expect_output(suppressMessages(print(b))) diff --git a/tests/testthat/test-count.R b/tests/testthat/test-count.R index 061697674..fffb88122 100644 --- a/tests/testthat/test-count.R +++ b/tests/testthat/test-count.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("count works", { +test_that("test-count.R", { expect_equal(count_resistant(example_isolates$AMX), count_R(example_isolates$AMX)) expect_equal(count_susceptible(example_isolates$AMX), count_SI(example_isolates$AMX)) expect_equal(count_all(example_isolates$AMX), n_sir(example_isolates$AMX)) diff --git a/tests/testthat/test-custom_antimicrobials.R b/tests/testthat/test-custom_antimicrobials.R index 121919ef0..b092b9b59 100644 --- a/tests/testthat/test-custom_antimicrobials.R +++ b/tests/testthat/test-custom_antimicrobials.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("custom ab works", { +test_that("test-custom ab.R", { ab_reset_session() expect_message(as.ab("testab", info = TRUE)) diff --git a/tests/testthat/test-custom_microorganisms.R b/tests/testthat/test-custom_microorganisms.R index 1e3e1ff0a..e504cb837 100644 --- a/tests/testthat/test-custom_microorganisms.R +++ b/tests/testthat/test-custom_microorganisms.R @@ -28,7 +28,7 @@ # ==================================================================== # -test_that("custom mo works", { +test_that("test-custom mo.R", { expect_identical( as.mo("Enterobacter asburiae/cloacae"), as.mo("Enterobacter asburiae") diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R index 6291a38b0..1277d4bb1 100644 --- a/tests/testthat/test-data.R +++ b/tests/testthat/test-data.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("data works", { +test_that("test-data.R", { # IDs should always be unique expect_identical(nrow(microorganisms), length(unique(microorganisms$mo))) expect_identical(class(microorganisms$mo), c("mo", "character")) diff --git a/tests/testthat/test-disk.R b/tests/testthat/test-disk.R index 395bc313e..ee5b360e3 100755 --- a/tests/testthat/test-disk.R +++ b/tests/testthat/test-disk.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("disk works", { +test_that("test-disk.R", { expect_true(as.disk(8) == as.disk("8")) expect_true(is.disk(as.disk(8))) diff --git a/tests/testthat/test-eucast_rules.R b/tests/testthat/test-eucast_rules.R index f3ae05d23..f5b1972e9 100755 --- a/tests/testthat/test-eucast_rules.R +++ b/tests/testthat/test-eucast_rules.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("eucast_rules works", { +test_that("test-eucast_rules.R", { # thoroughly check input table expect_equal( colnames(AMR:::EUCAST_RULES_DF), @@ -42,8 +42,14 @@ test_that("eucast_rules works", { ) MOs_mentioned <- unique(AMR:::EUCAST_RULES_DF$this_value) MOs_mentioned <- sort(trimws(unlist(strsplit(MOs_mentioned[!AMR:::is_valid_regex(MOs_mentioned)], ",", fixed = TRUE)))) - MOs_test <- suppressWarnings(suppressMessages(mo_name(MOs_mentioned, keep_synonyms = TRUE, language = NULL))) - expect_true(length(MOs_mentioned[MOs_test != MOs_mentioned]) == 0) + MOs_test <- suppressWarnings( + trimws(paste( + mo_genus(MOs_mentioned, keep_synonyms = TRUE, language = NULL), + mo_species(MOs_mentioned, keep_synonyms = TRUE, language = NULL) + )) + ) + MOs_test[MOs_test == ""] <- mo_fullname(MOs_mentioned[MOs_test == ""], keep_synonyms = TRUE, language = NULL) + expect_equal(MOs_mentioned, MOs_test) expect_error(suppressWarnings(eucast_rules(example_isolates, col_mo = "Non-existing"))) expect_error(eucast_rules(x = "text")) @@ -108,7 +114,7 @@ test_that("eucast_rules works", { TIC = as.sir("R"), PIP = as.sir("S") ) %>% - eucast_rules(col_mo = "mo", version_expertrules = 3.1, info = FALSE) %>% + eucast_rules(col_mo = "mo", version_expertrules = 3.1, info = FALSE, overwrite = TRUE) %>% pull(PIP) %>% unique() %>% as.character() @@ -127,6 +133,7 @@ test_that("eucast_rules works", { stringsAsFactors = FALSE ), version_expertrules = 3.1, + overwrite = TRUE, only_sir_columns = FALSE )$CLR)) b <- example_isolates$ERY @@ -168,6 +175,7 @@ test_that("eucast_rules works", { cefotax = as.sir(c("S", "S")) ), ampc_cephalosporin_resistance = TRUE, + overwrite = TRUE, info = FALSE )$cefotax, as.sir(c("S", "R")) @@ -180,6 +188,7 @@ test_that("eucast_rules works", { cefotax = as.sir(c("S", "S")) ), ampc_cephalosporin_resistance = NA, + overwrite = TRUE, info = FALSE )$cefotax, as.sir(c("S", NA)) @@ -192,6 +201,7 @@ test_that("eucast_rules works", { cefotax = as.sir(c("S", "S")) ), ampc_cephalosporin_resistance = NULL, + overwrite = TRUE, info = FALSE )$cefotax, as.sir(c("S", "S")) @@ -218,6 +228,7 @@ test_that("eucast_rules works", { rules = "custom", custom_rules = x, info = FALSE, + overwrite = TRUE, verbose = TRUE )), 8, diff --git a/tests/testthat/test-first_isolate.R b/tests/testthat/test-first_isolate.R index d7564cf4a..769873e03 100755 --- a/tests/testthat/test-first_isolate.R +++ b/tests/testthat/test-first_isolate.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("first_isolate works", { +test_that("test-first_isolate.R", { # all four methods expect_equal( sum(first_isolate(x = example_isolates, method = "isolate-based", info = TRUE), na.rm = TRUE), diff --git a/tests/testthat/test-g.test.R b/tests/testthat/test-g.test.R index f5e54064c..ed8dae731 100644 --- a/tests/testthat/test-g.test.R +++ b/tests/testthat/test-g.test.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("g.test works", { +test_that("test-g.test.R", { # GOODNESS-OF-FIT # example 1: clearfield rice vs. red rice diff --git a/tests/testthat/test-get_episode.R b/tests/testthat/test-get_episode.R index 2c8d37f93..1eb7c8e65 100644 --- a/tests/testthat/test-get_episode.R +++ b/tests/testthat/test-get_episode.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("get_episode works", { +test_that("test-get_episode.R", { x <- data.frame(dates = as.Date(c("2021-01-01", "2021-01-02", "2021-01-05", "2021-01-08", "2021-02-21", "2021-02-22", "2021-02-23", "2021-02-24", "2021-03-01", "2021-03-01"))) x$absolute <- get_episode(x$dates, episode_days = 7) x$relative <- get_episode(x$dates, case_free_days = 7) diff --git a/tests/testthat/test-ggplot_sir.R b/tests/testthat/test-ggplot_sir.R index 6f482fef2..a9788ea90 100644 --- a/tests/testthat/test-ggplot_sir.R +++ b/tests/testthat/test-ggplot_sir.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("ggplot_sir works", { +test_that("test-ggplot_sir.R", { if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE) && AMR:::pkg_is_available("ggplot2", also_load = TRUE)) { pdf(NULL) # prevent Rplots.pdf being created diff --git a/tests/testthat/test-guess_ab_col.R b/tests/testthat/test-guess_ab_col.R index 5a03b36cc..c288570a9 100644 --- a/tests/testthat/test-guess_ab_col.R +++ b/tests/testthat/test-guess_ab_col.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("guess_ab_col works", { +test_that("test-guess_ab_col.R", { expect_equal( guess_ab_col(example_isolates, "amox"), "AMX" diff --git a/tests/testthat/test-italicise_taxonomy.R b/tests/testthat/test-italicise_taxonomy.R index 5c16a1216..f5af8249d 100644 --- a/tests/testthat/test-italicise_taxonomy.R +++ b/tests/testthat/test-italicise_taxonomy.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("italicise_taxonomy works", { +test_that("test-italicise_taxonomy.R", { expect_identical( italicise_taxonomy("test for E. coli"), "test for *E. coli*" diff --git a/tests/testthat/test-join_microorganisms.R b/tests/testthat/test-join_microorganisms.R index 47261712a..601ac68af 100755 --- a/tests/testthat/test-join_microorganisms.R +++ b/tests/testthat/test-join_microorganisms.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("join_microorganisms works", { +test_that("test-join_microorganisms.R", { unjoined <- example_isolates inner <- inner_join_microorganisms(example_isolates) left <- left_join_microorganisms(example_isolates) diff --git a/tests/testthat/test-key_antimicrobials.R b/tests/testthat/test-key_antimicrobials.R index 5c2a0a8e6..2ad85231c 100644 --- a/tests/testthat/test-key_antimicrobials.R +++ b/tests/testthat/test-key_antimicrobials.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("key_antimicrobials works", { +test_that("test-key_antimicrobials.R", { expect_equal(length(key_antimicrobials(example_isolates, antifungal = NULL)), nrow(example_isolates)) expect_false(all(is.na(key_antimicrobials(example_isolates, antifungal = NULL)))) expect_true(antimicrobials_equal("SSS", "SSS", type = "points")) diff --git a/tests/testthat/test-kurtosis.R b/tests/testthat/test-kurtosis.R index 425c1a3a0..d6cde993c 100644 --- a/tests/testthat/test-kurtosis.R +++ b/tests/testthat/test-kurtosis.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("kurtosis works", { +test_that("test-kurtosis.R", { expect_equal(kurtosis(example_isolates$age), 5.227999, tolerance = 0.00001 diff --git a/tests/testthat/test-like.R b/tests/testthat/test-like.R index 16192836c..5475beed9 100644 --- a/tests/testthat/test-like.R +++ b/tests/testthat/test-like.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("like works", { +test_that("test-like.R", { expect_true(sum("test" %like% c("^t", "^s")) == 1) expect_true("test" %like% "test") diff --git a/tests/testthat/test-mdro.R b/tests/testthat/test-mdro.R index 08f6b1dae..118b32f0c 100755 --- a/tests/testthat/test-mdro.R +++ b/tests/testthat/test-mdro.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("mdro works", { +test_that("test-mdro.R", { expect_error(mdro(example_isolates, guideline = c("BRMO", "MRGN"), info = TRUE)) expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE)) diff --git a/tests/testthat/test-mean_amr_distance.R b/tests/testthat/test-mean_amr_distance.R index 52a4f1dc2..4f2d72567 100644 --- a/tests/testthat/test-mean_amr_distance.R +++ b/tests/testthat/test-mean_amr_distance.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("mean_amr_distance works", { +test_that("test-mean_amr_distance.R", { vctr_disk <- as.disk(c(20:25)) vctr_mic <- as.mic(2^c(0:5)) vctr_sir <- as.sir(c("S", "S", "I", "I", "R", "R")) diff --git a/tests/testthat/test-mic.R b/tests/testthat/test-mic.R index 44d08cba3..48c79f3b8 100755 --- a/tests/testthat/test-mic.R +++ b/tests/testthat/test-mic.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("mic works", { +test_that("test-mic.R", { # used in multiple functions, also in plotting expect_true(all(as.mic(AMR:::COMMON_MIC_VALUES) %in% AMR:::VALID_MIC_LEVELS)) expect_true(all(paste0("<=", as.mic(AMR:::COMMON_MIC_VALUES)) %in% AMR:::VALID_MIC_LEVELS)) diff --git a/tests/testthat/test-mo.R b/tests/testthat/test-mo.R index a3dc10ca6..b5ff2b91a 100644 --- a/tests/testthat/test-mo.R +++ b/tests/testthat/test-mo.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("mo works", { +test_that("test-mo.R", { MOs <- subset(microorganisms, !is.na(mo) & nchar(mo) > 3) expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo, keep_synonyms = TRUE))) diff --git a/tests/testthat/test-mo_property.R b/tests/testthat/test-mo_property.R index 9c0490696..4e3461e47 100644 --- a/tests/testthat/test-mo_property.R +++ b/tests/testthat/test-mo_property.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("mo_property works", { +test_that("test-mo_property.R", { expect_equal(mo_kingdom("Escherichia coli"), "Bacteria") expect_equal(mo_kingdom("Escherichia coli"), mo_domain("Escherichia coli")) expect_equal(mo_phylum("Escherichia coli"), "Pseudomonadota") diff --git a/tests/testthat/test-pca.R b/tests/testthat/test-pca.R index 482caa450..558061530 100644 --- a/tests/testthat/test-pca.R +++ b/tests/testthat/test-pca.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("pca works", { +test_that("test-pca.R", { resistance_data <- structure( list( order = c("Bacillales", "Enterobacterales", "Enterobacterales"), diff --git a/tests/testthat/test-plotting.R b/tests/testthat/test-plotting.R index 85fdb0101..6ab51d9f8 100644 --- a/tests/testthat/test-plotting.R +++ b/tests/testthat/test-plotting.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("plotting works", { +test_that("test-plotting.R", { if (AMR:::pkg_is_available("ggplot2", also_load = TRUE)) { pdf(NULL) # prevent Rplots.pdf being created diff --git a/tests/testthat/test-proportion.R b/tests/testthat/test-proportion.R index d67da1e2b..e2c30e738 100755 --- a/tests/testthat/test-proportion.R +++ b/tests/testthat/test-proportion.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("proportion works", { +test_that("test-proportion.R", { expect_equal(proportion_R(example_isolates$AMX), resistance(example_isolates$AMX)) expect_equal(proportion_SI(example_isolates$AMX), susceptibility(example_isolates$AMX)) # AMX resistance in `example_isolates` diff --git a/tests/testthat/test-random.R b/tests/testthat/test-random.R index 039c200ad..7c83bed70 100644 --- a/tests/testthat/test-random.R +++ b/tests/testthat/test-random.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("random works", { +test_that("test-random.R", { expect_inherits(random_mic(100), "mic") expect_inherits(random_mic(100, mo = "Klebsiella pneumoniae"), "mic") expect_inherits(random_mic(100, mo = "Klebsiella pneumoniae", ab = "meropenem"), "mic") diff --git a/tests/testthat/test-resistance_predict.R b/tests/testthat/test-resistance_predict.R index ad878805f..a3d74cc7e 100644 --- a/tests/testthat/test-resistance_predict.R +++ b/tests/testthat/test-resistance_predict.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("resistance_predict works", { +test_that("test-resistance_predict.R", { if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) { expect_output(AMX_R <- example_isolates %>% filter(mo == "B_ESCHR_COLI") %>% diff --git a/tests/testthat/test-sir.R b/tests/testthat/test-sir.R index e354f9aea..b94d1262a 100644 --- a/tests/testthat/test-sir.R +++ b/tests/testthat/test-sir.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("sir works", { +test_that("test-sir.R", { # Existing SIR ------------------------------------------------------------ # we must only have EUCAST and CLSI, because otherwise the rules in as.sir() will fail diff --git a/tests/testthat/test-skewness.R b/tests/testthat/test-skewness.R index 294e2aa92..ad64ea6e8 100644 --- a/tests/testthat/test-skewness.R +++ b/tests/testthat/test-skewness.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("skewness works", { +test_that("test-skewness.R", { expect_equal(skewness(example_isolates$age), -1.212888, tolerance = 0.00001 diff --git a/tests/testthat/test-top_n_microorganisms.R b/tests/testthat/test-top_n_microorganisms.R index 09fdebf98..91b484d11 100644 --- a/tests/testthat/test-top_n_microorganisms.R +++ b/tests/testthat/test-top_n_microorganisms.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("top_n_microorganisms works", { +test_that("test-top_n_microorganisms.R", { out1 <- top_n_microorganisms(example_isolates, n = 3) out2 <- top_n_microorganisms(example_isolates, n = 5, property = "genus") out3 <- top_n_microorganisms(example_isolates, n = 5, property = "genus", n_for_each = 3) diff --git a/tests/testthat/test-translate.R b/tests/testthat/test-translate.R index 50740393d..022bcc975 100644 --- a/tests/testthat/test-translate.R +++ b/tests/testthat/test-translate.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("translate works", { +test_that("test-translate.R", { expect_identical(mo_genus("B_GRAMP", language = "pt"), "(gênero desconhecido)") expect_identical(mo_fullname("CoNS", "cs"), "Koaguláza-negativní stafylokok (KNS)") diff --git a/tests/testthat/test-vctrs.R b/tests/testthat/test-vctrs.R index 944e2b346..4960f5918 100755 --- a/tests/testthat/test-vctrs.R +++ b/tests/testthat/test-vctrs.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("vctrs works", { +test_that("test-vctrs.R", { # extra tests for {vctrs} pkg support if (AMR:::pkg_is_available("tibble")) { test <- tibble::tibble( diff --git a/tests/testthat/test-zzz.R b/tests/testthat/test-zzz.R index 476ea70d9..3036c6162 100644 --- a/tests/testthat/test-zzz.R +++ b/tests/testthat/test-zzz.R @@ -27,7 +27,7 @@ # how to conduct AMR data analysis: https://msberends.github.io/AMR/ # # ==================================================================== # -test_that("zzz works", { +test_that("test-zzz.R", { # Check if these functions still exist in their package (all are in Suggests field) # Since GitHub Actions runs every night, we will get emailed when a dependency fails based on this unit test