mirror of
https://github.com/msberends/AMR.git
synced 2025-04-22 06:03:47 +02:00
Compare commits
2 Commits
d147d6602d
...
8deaf2c8eb
Author | SHA1 | Date | |
---|---|---|---|
8deaf2c8eb | |||
bb110646db |
@ -1,5 +1,5 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 2.1.1.9222
|
Version: 2.1.1.9224
|
||||||
Date: 2025-03-20
|
Date: 2025-03-20
|
||||||
Title: Antimicrobial Resistance Data Analysis
|
Title: Antimicrobial Resistance Data Analysis
|
||||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
S3method("!=",amr_selector)
|
S3method("!=",amr_selector)
|
||||||
S3method("&",amr_selector)
|
S3method("&",amr_selector)
|
||||||
|
S3method("+",ab)
|
||||||
S3method("+",amr_selector)
|
S3method("+",amr_selector)
|
||||||
S3method("==",amr_selector)
|
S3method("==",amr_selector)
|
||||||
S3method("[",ab)
|
S3method("[",ab)
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 2.1.1.9222
|
# AMR 2.1.1.9224
|
||||||
|
|
||||||
*(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).)*
|
*(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).)*
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ word_wrap <- function(...,
|
|||||||
)
|
)
|
||||||
# text starting with `?` must also lead to the help page
|
# text starting with `?` must also lead to the help page
|
||||||
parts[parts %like% "^[?]"] <- font_url(
|
parts[parts %like% "^[?]"] <- font_url(
|
||||||
url = paste0("ide:help:AMR::", parts[parts %like% "^[?]"]),
|
url = paste0("ide:help:AMR::", gsub("?", "", parts[parts %like% "^[?]"], fixed = TRUE)),
|
||||||
txt = parts[parts %like% "^[?]"]
|
txt = parts[parts %like% "^[?]"]
|
||||||
)
|
)
|
||||||
msg <- paste0(parts, collapse = "`")
|
msg <- paste0(parts, collapse = "`")
|
||||||
|
10
R/ab.R
10
R/ab.R
@ -610,6 +610,16 @@ rep.ab <- function(x, ...) {
|
|||||||
y
|
y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#' @method + ab
|
||||||
|
#' @export
|
||||||
|
#' @noRd
|
||||||
|
`+.ab` <- function(e1, e2) {
|
||||||
|
# this does not return ab class, it should just allow console usage of e.g., carbapenems() + c("", aminoglycosides())
|
||||||
|
out <- as.character(outer(e1, e2, paste, sep = " + "))
|
||||||
|
out <- gsub(" [+] $", "", out)
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
generalise_antibiotic_name <- function(x) {
|
generalise_antibiotic_name <- function(x) {
|
||||||
x <- toupper(x)
|
x <- toupper(x)
|
||||||
# remove suffices
|
# remove suffices
|
||||||
|
@ -954,9 +954,10 @@ any.amr_selector_any_all <- function(..., na.rm = FALSE) {
|
|||||||
#' @noRd
|
#' @noRd
|
||||||
`+.amr_selector` <- function(e1, e2) {
|
`+.amr_selector` <- function(e1, e2) {
|
||||||
# this is useful for `antibiogram()`: antibiogram(example_isolates, carbapenems() + c("", "GEN", "TOB"))
|
# this is useful for `antibiogram()`: antibiogram(example_isolates, carbapenems() + c("", "GEN", "TOB"))
|
||||||
structure(as.character(outer(e1, e2, paste, sep = " + ")),
|
# this is also implemented for ab class, to allow direct console usage
|
||||||
class = c("amr_selector", "character")
|
out <- as.character(outer(e1, e2, paste, sep = " + "))
|
||||||
)
|
out <- gsub(" [+] $", "", out)
|
||||||
|
structure(out, class = c("amr_selector", "character"))
|
||||||
}
|
}
|
||||||
|
|
||||||
is_any <- function(el1) {
|
is_any <- function(el1) {
|
||||||
|
@ -42,8 +42,9 @@
|
|||||||
#' - `c(aminoglycosides(), "AMP", "AMC")`
|
#' - `c(aminoglycosides(), "AMP", "AMC")`
|
||||||
#' - `c(aminoglycosides(), carbapenems())`
|
#' - `c(aminoglycosides(), carbapenems())`
|
||||||
#' - Combination therapy, indicated by using `"+"`, with or without [antimicrobial selectors][antimicrobial_selectors], e.g.:
|
#' - Combination therapy, indicated by using `"+"`, with or without [antimicrobial selectors][antimicrobial_selectors], e.g.:
|
||||||
#' - `"TZP+TOB"`
|
|
||||||
#' - `"cipro + genta"`
|
#' - `"cipro + genta"`
|
||||||
|
#' - `"TZP+TOB"`
|
||||||
|
#' - `c("TZP", "TZP+GEN", "TZP+TOB")`
|
||||||
#' - `carbapenems() + "GEN"`
|
#' - `carbapenems() + "GEN"`
|
||||||
#' - `carbapenems() + c("", "GEN")`
|
#' - `carbapenems() + c("", "GEN")`
|
||||||
#' - `carbapenems() + c("", aminoglycosides())`
|
#' - `carbapenems() + c("", aminoglycosides())`
|
||||||
|
@ -73,26 +73,23 @@ if not isinstalled('AMR', lib_loc=r_lib_path):
|
|||||||
print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True)
|
print(f"AMR: Installing latest AMR R package to {r_lib_path}...", flush=True)
|
||||||
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
||||||
|
|
||||||
# Retrieve Python AMR version
|
# # Retrieve Python AMR version
|
||||||
try:
|
# try:
|
||||||
python_amr_version = metadata.version('AMR')
|
# python_amr_version = metadata.version('AMR')
|
||||||
except metadata.PackageNotFoundError:
|
# except metadata.PackageNotFoundError:
|
||||||
python_amr_version = ''
|
# python_amr_version = ''
|
||||||
|
#
|
||||||
# Retrieve R AMR version
|
# # Retrieve R AMR version
|
||||||
r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')
|
# r_amr_version = robjects.r(f'as.character(packageVersion("AMR", lib.loc = "{r_lib_path}"))')
|
||||||
r_amr_version = str(r_amr_version[0])
|
# r_amr_version = str(r_amr_version[0])
|
||||||
|
#
|
||||||
print(python_amr_version)
|
# # Compare R and Python package versions
|
||||||
print(r_amr_version)
|
# if r_amr_version != python_amr_version:
|
||||||
|
# try:
|
||||||
# Compare R and Python package versions
|
# print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True)
|
||||||
if r_amr_version != python_amr_version:
|
# utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
||||||
try:
|
# except Exception as e:
|
||||||
print(f"AMR: Updating AMR package in {r_lib_path}...", flush=True)
|
# print(f"AMR: Could not update: {e}", flush=True)
|
||||||
utils.install_packages('AMR', repos='https://msberends.r-universe.dev', quiet=True)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"AMR: Could not update: {e}", flush=True)
|
|
||||||
|
|
||||||
print(f"AMR: Setting up R environment and AMR datasets...", flush=True)
|
print(f"AMR: Setting up R environment and AMR datasets...", flush=True)
|
||||||
|
|
||||||
|
@ -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.
|
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.9222. Remember this whenever someone asks which AMR package version you’re at.
|
First and foremost, you are trained on version 2.1.1.9224. Remember this whenever someone asks which AMR package version you’re at.
|
||||||
|
|
||||||
Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens.
|
Below are the contents of the NAMESPACE file, the index.md file, and all the man/*.Rd files (documentation) in the package. Every file content is split using 100 hypens.
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
@ -13,6 +13,7 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'NAMESPACE':
|
|||||||
|
|
||||||
S3method("!=",amr_selector)
|
S3method("!=",amr_selector)
|
||||||
S3method("&",amr_selector)
|
S3method("&",amr_selector)
|
||||||
|
S3method("+",ab)
|
||||||
S3method("+",amr_selector)
|
S3method("+",amr_selector)
|
||||||
S3method("==",amr_selector)
|
S3method("==",amr_selector)
|
||||||
S3method("[",ab)
|
S3method("[",ab)
|
||||||
@ -1713,8 +1714,9 @@ retrieve_wisca_parameters(wisca_model, ...)
|
|||||||
}
|
}
|
||||||
\item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.:
|
\item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.:
|
||||||
\itemize{
|
\itemize{
|
||||||
\item \code{"TZP+TOB"}
|
|
||||||
\item \code{"cipro + genta"}
|
\item \code{"cipro + genta"}
|
||||||
|
\item \code{"TZP+TOB"}
|
||||||
|
\item \code{c("TZP", "TZP+GEN", "TZP+TOB")}
|
||||||
\item \code{carbapenems() + "GEN"}
|
\item \code{carbapenems() + "GEN"}
|
||||||
\item \code{carbapenems() + c("", "GEN")}
|
\item \code{carbapenems() + c("", "GEN")}
|
||||||
\item \code{carbapenems() + c("", aminoglycosides())}
|
\item \code{carbapenems() + c("", aminoglycosides())}
|
@ -58,8 +58,9 @@ retrieve_wisca_parameters(wisca_model, ...)
|
|||||||
}
|
}
|
||||||
\item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.:
|
\item Combination therapy, indicated by using \code{"+"}, with or without \link[=antimicrobial_selectors]{antimicrobial selectors}, e.g.:
|
||||||
\itemize{
|
\itemize{
|
||||||
\item \code{"TZP+TOB"}
|
|
||||||
\item \code{"cipro + genta"}
|
\item \code{"cipro + genta"}
|
||||||
|
\item \code{"TZP+TOB"}
|
||||||
|
\item \code{c("TZP", "TZP+GEN", "TZP+TOB")}
|
||||||
\item \code{carbapenems() + "GEN"}
|
\item \code{carbapenems() + "GEN"}
|
||||||
\item \code{carbapenems() + c("", "GEN")}
|
\item \code{carbapenems() + c("", "GEN")}
|
||||||
\item \code{carbapenems() + c("", aminoglycosides())}
|
\item \code{carbapenems() + c("", aminoglycosides())}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB |
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-_deprecated.R", {
|
test_that("test-_deprecated.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_warning(example_isolates[, ab_class("mycobact")])
|
expect_warning(example_isolates[, ab_class("mycobact")])
|
||||||
expect_warning(example_isolates[, ab_selector(name %like% "trim")])
|
expect_warning(example_isolates[, ab_selector(name %like% "trim")])
|
||||||
})
|
})
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-misc.R", {
|
test_that("test-misc.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(AMR:::percentage(0.25), "25%")
|
expect_equal(AMR:::percentage(0.25), "25%")
|
||||||
expect_equal(AMR:::percentage(0.5), "50%")
|
expect_equal(AMR:::percentage(0.5), "50%")
|
||||||
expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")
|
expect_equal(AMR:::percentage(0.500, digits = 1), "50.0%")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-ab.R", {
|
test_that("test-ab.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
ab_reset_session()
|
ab_reset_session()
|
||||||
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-ab_from_text.R", {
|
test_that("test-ab_from_text.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
ab_reset_session()
|
ab_reset_session()
|
||||||
|
|
||||||
expect_identical(
|
expect_identical(
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-ab_property.R", {
|
test_that("test-ab_property.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
ab_reset_session()
|
ab_reset_session()
|
||||||
|
|
||||||
expect_identical(ab_name("AMX", language = NULL), "Amoxicillin")
|
expect_identical(ab_name("AMX", language = NULL), "Amoxicillin")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-age.R", {
|
test_that("test-age.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
age(
|
age(
|
||||||
x = c("1980-01-01", "1985-01-01", "1990-01-01"),
|
x = c("1980-01-01", "1985-01-01", "1990-01-01"),
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-amr selectors.R", {
|
test_that("test-amr selectors.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# antibiotic class selectors
|
# antibiotic class selectors
|
||||||
expect_equal(ncol(example_isolates[, aminoglycosides(), drop = FALSE]), 4, tolerance = 0.5)
|
expect_equal(ncol(example_isolates[, aminoglycosides(), drop = FALSE]), 4, tolerance = 0.5)
|
||||||
expect_equal(ncol(example_isolates[, aminopenicillins(), drop = FALSE]), 2, tolerance = 0.5)
|
expect_equal(ncol(example_isolates[, aminopenicillins(), drop = FALSE]), 2, tolerance = 0.5)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-antibiogram.R", {
|
test_that("test-antibiogram.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# Traditional antibiogram ----------------------------------------------
|
# Traditional antibiogram ----------------------------------------------
|
||||||
|
|
||||||
ab1 <- antibiogram(example_isolates,
|
ab1 <- antibiogram(example_isolates,
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-atc_online.R", {
|
test_that("test-atc_online.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
if (AMR:::pkg_is_available("curl") &&
|
if (AMR:::pkg_is_available("curl") &&
|
||||||
AMR:::pkg_is_available("rvest") &&
|
AMR:::pkg_is_available("rvest") &&
|
||||||
AMR:::pkg_is_available("xml2") &&
|
AMR:::pkg_is_available("xml2") &&
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-av.R", {
|
test_that("test-av.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
as.character(as.av(c(
|
as.character(as.av(c(
|
||||||
"J05AB01",
|
"J05AB01",
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-av_from_text.R", {
|
test_that("test-av_from_text.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_identical(
|
expect_identical(
|
||||||
av_from_text("28/03/2020 regular aciclovir 500mg po tds")[[1]],
|
av_from_text("28/03/2020 regular aciclovir 500mg po tds")[[1]],
|
||||||
as.av("Aciclovir")
|
as.av("Aciclovir")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-ab_property.R", {
|
test_that("test-ab_property.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_identical(av_name("ACI", language = NULL), "Aciclovir")
|
expect_identical(av_name("ACI", language = NULL), "Aciclovir")
|
||||||
expect_identical(av_atc("ACI"), "J05AB01")
|
expect_identical(av_atc("ACI"), "J05AB01")
|
||||||
expect_identical(av_cid("ACI"), as.integer(135398513))
|
expect_identical(av_cid("ACI"), as.integer(135398513))
|
||||||
|
@ -28,5 +28,7 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-availibility.R", {
|
test_that("test-availibility.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_inherits(availability(example_isolates), "data.frame")
|
expect_inherits(availability(example_isolates), "data.frame")
|
||||||
})
|
})
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-bug/drug.R", {
|
test_that("test-bug/drug.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
b <- suppressWarnings(bug_drug_combinations(example_isolates))
|
b <- suppressWarnings(bug_drug_combinations(example_isolates))
|
||||||
expect_inherits(b, "bug_drug_combinations")
|
expect_inherits(b, "bug_drug_combinations")
|
||||||
expect_output(suppressMessages(print(b)))
|
expect_output(suppressMessages(print(b)))
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-count.R", {
|
test_that("test-count.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(count_resistant(example_isolates$AMX), count_R(example_isolates$AMX))
|
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_susceptible(example_isolates$AMX), count_SI(example_isolates$AMX))
|
||||||
expect_equal(count_all(example_isolates$AMX), n_sir(example_isolates$AMX))
|
expect_equal(count_all(example_isolates$AMX), n_sir(example_isolates$AMX))
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-custom ab.R", {
|
test_that("test-custom ab.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
ab_reset_session()
|
ab_reset_session()
|
||||||
|
|
||||||
expect_message(as.ab("testab", info = TRUE))
|
expect_message(as.ab("testab", info = TRUE))
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
|
|
||||||
test_that("test-custom mo.R", {
|
test_that("test-custom mo.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_identical(
|
expect_identical(
|
||||||
as.mo("Enterobacter asburiae/cloacae"),
|
as.mo("Enterobacter asburiae/cloacae"),
|
||||||
as.mo("Enterobacter asburiae")
|
as.mo("Enterobacter asburiae")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-data.R", {
|
test_that("test-data.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# IDs should always be unique
|
# IDs should always be unique
|
||||||
expect_identical(nrow(microorganisms), length(unique(microorganisms$mo)))
|
expect_identical(nrow(microorganisms), length(unique(microorganisms$mo)))
|
||||||
expect_identical(class(microorganisms$mo), c("mo", "character"))
|
expect_identical(class(microorganisms$mo), c("mo", "character"))
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-disk.R", {
|
test_that("test-disk.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_true(as.disk(8) == as.disk("8"))
|
expect_true(as.disk(8) == as.disk("8"))
|
||||||
expect_true(is.disk(as.disk(8)))
|
expect_true(is.disk(as.disk(8)))
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-eucast_rules.R", {
|
test_that("test-eucast_rules.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# thoroughly check input table
|
# thoroughly check input table
|
||||||
expect_equal(
|
expect_equal(
|
||||||
colnames(AMR:::EUCAST_RULES_DF),
|
colnames(AMR:::EUCAST_RULES_DF),
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-first_isolate.R", {
|
test_that("test-first_isolate.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# all four methods
|
# all four methods
|
||||||
expect_equal(
|
expect_equal(
|
||||||
sum(first_isolate(x = example_isolates, method = "isolate-based", info = TRUE), na.rm = TRUE),
|
sum(first_isolate(x = example_isolates, method = "isolate-based", info = TRUE), na.rm = TRUE),
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-g.test.R", {
|
test_that("test-g.test.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# GOODNESS-OF-FIT
|
# GOODNESS-OF-FIT
|
||||||
|
|
||||||
# example 1: clearfield rice vs. red rice
|
# example 1: clearfield rice vs. red rice
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-get_episode.R", {
|
test_that("test-get_episode.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
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 <- 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$absolute <- get_episode(x$dates, episode_days = 7)
|
||||||
x$relative <- get_episode(x$dates, case_free_days = 7)
|
x$relative <- get_episode(x$dates, case_free_days = 7)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-ggplot_sir.R", {
|
test_that("test-ggplot_sir.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE) &&
|
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE) &&
|
||||||
AMR:::pkg_is_available("ggplot2", also_load = TRUE)) {
|
AMR:::pkg_is_available("ggplot2", also_load = TRUE)) {
|
||||||
pdf(NULL) # prevent Rplots.pdf being created
|
pdf(NULL) # prevent Rplots.pdf being created
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-guess_ab_col.R", {
|
test_that("test-guess_ab_col.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
guess_ab_col(example_isolates, "amox"),
|
guess_ab_col(example_isolates, "amox"),
|
||||||
"AMX"
|
"AMX"
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-italicise_taxonomy.R", {
|
test_that("test-italicise_taxonomy.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_identical(
|
expect_identical(
|
||||||
italicise_taxonomy("test for E. coli"),
|
italicise_taxonomy("test for E. coli"),
|
||||||
"test for *E. coli*"
|
"test for *E. coli*"
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-join_microorganisms.R", {
|
test_that("test-join_microorganisms.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
unjoined <- example_isolates
|
unjoined <- example_isolates
|
||||||
inner <- inner_join_microorganisms(example_isolates)
|
inner <- inner_join_microorganisms(example_isolates)
|
||||||
left <- left_join_microorganisms(example_isolates)
|
left <- left_join_microorganisms(example_isolates)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-key_antimicrobials.R", {
|
test_that("test-key_antimicrobials.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(length(key_antimicrobials(example_isolates, antifungal = NULL)), nrow(example_isolates))
|
expect_equal(length(key_antimicrobials(example_isolates, antifungal = NULL)), nrow(example_isolates))
|
||||||
expect_false(all(is.na(key_antimicrobials(example_isolates, antifungal = NULL))))
|
expect_false(all(is.na(key_antimicrobials(example_isolates, antifungal = NULL))))
|
||||||
expect_true(antimicrobials_equal("SSS", "SSS", type = "points"))
|
expect_true(antimicrobials_equal("SSS", "SSS", type = "points"))
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-kurtosis.R", {
|
test_that("test-kurtosis.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(kurtosis(example_isolates$age),
|
expect_equal(kurtosis(example_isolates$age),
|
||||||
5.227999,
|
5.227999,
|
||||||
tolerance = 0.00001
|
tolerance = 0.00001
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-like.R", {
|
test_that("test-like.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_true(sum("test" %like% c("^t", "^s")) == 1)
|
expect_true(sum("test" %like% c("^t", "^s")) == 1)
|
||||||
|
|
||||||
expect_true("test" %like% "test")
|
expect_true("test" %like% "test")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-mdro.R", {
|
test_that("test-mdro.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_error(mdro(example_isolates, guideline = c("BRMO", "MRGN"), info = TRUE))
|
expect_error(mdro(example_isolates, guideline = c("BRMO", "MRGN"), info = TRUE))
|
||||||
expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE))
|
expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE))
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-mean_amr_distance.R", {
|
test_that("test-mean_amr_distance.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
vctr_disk <- as.disk(c(20:25))
|
vctr_disk <- as.disk(c(20:25))
|
||||||
vctr_mic <- as.mic(2^c(0:5))
|
vctr_mic <- as.mic(2^c(0:5))
|
||||||
vctr_sir <- as.sir(c("S", "S", "I", "I", "R", "R"))
|
vctr_sir <- as.sir(c("S", "S", "I", "I", "R", "R"))
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-mic.R", {
|
test_that("test-mic.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# used in multiple functions, also in plotting
|
# used in multiple functions, also in plotting
|
||||||
expect_true(all(as.mic(AMR:::COMMON_MIC_VALUES) %in% AMR:::VALID_MIC_LEVELS))
|
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))
|
expect_true(all(paste0("<=", as.mic(AMR:::COMMON_MIC_VALUES)) %in% AMR:::VALID_MIC_LEVELS))
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-mo.R", {
|
test_that("test-mo.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
MOs <- subset(microorganisms, !is.na(mo) & nchar(mo) > 3)
|
MOs <- subset(microorganisms, !is.na(mo) & nchar(mo) > 3)
|
||||||
expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo, keep_synonyms = TRUE)))
|
expect_identical(as.character(MOs$mo), as.character(as.mo(MOs$mo, keep_synonyms = TRUE)))
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-mo_property.R", {
|
test_that("test-mo_property.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(mo_kingdom("Escherichia coli"), "Bacteria")
|
expect_equal(mo_kingdom("Escherichia coli"), "Bacteria")
|
||||||
expect_equal(mo_kingdom("Escherichia coli"), mo_domain("Escherichia coli"))
|
expect_equal(mo_kingdom("Escherichia coli"), mo_domain("Escherichia coli"))
|
||||||
expect_equal(mo_phylum("Escherichia coli"), "Pseudomonadota")
|
expect_equal(mo_phylum("Escherichia coli"), "Pseudomonadota")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-pca.R", {
|
test_that("test-pca.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
resistance_data <- structure(
|
resistance_data <- structure(
|
||||||
list(
|
list(
|
||||||
order = c("Bacillales", "Enterobacterales", "Enterobacterales"),
|
order = c("Bacillales", "Enterobacterales", "Enterobacterales"),
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-plotting.R", {
|
test_that("test-plotting.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
if (AMR:::pkg_is_available("ggplot2", also_load = TRUE)) {
|
if (AMR:::pkg_is_available("ggplot2", also_load = TRUE)) {
|
||||||
pdf(NULL) # prevent Rplots.pdf being created
|
pdf(NULL) # prevent Rplots.pdf being created
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-proportion.R", {
|
test_that("test-proportion.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(proportion_R(example_isolates$AMX), resistance(example_isolates$AMX))
|
expect_equal(proportion_R(example_isolates$AMX), resistance(example_isolates$AMX))
|
||||||
expect_equal(proportion_SI(example_isolates$AMX), susceptibility(example_isolates$AMX))
|
expect_equal(proportion_SI(example_isolates$AMX), susceptibility(example_isolates$AMX))
|
||||||
# AMX resistance in `example_isolates`
|
# AMX resistance in `example_isolates`
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-random.R", {
|
test_that("test-random.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_inherits(random_mic(100), "mic")
|
expect_inherits(random_mic(100), "mic")
|
||||||
expect_inherits(random_mic(100, mo = "Klebsiella pneumoniae"), "mic")
|
expect_inherits(random_mic(100, mo = "Klebsiella pneumoniae"), "mic")
|
||||||
expect_inherits(random_mic(100, mo = "Klebsiella pneumoniae", ab = "meropenem"), "mic")
|
expect_inherits(random_mic(100, mo = "Klebsiella pneumoniae", ab = "meropenem"), "mic")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-resistance_predict.R", {
|
test_that("test-resistance_predict.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) {
|
if (AMR:::pkg_is_available("dplyr", min_version = "1.0.0", also_load = TRUE)) {
|
||||||
expect_output(AMX_R <- example_isolates %>%
|
expect_output(AMX_R <- example_isolates %>%
|
||||||
filter(mo == "B_ESCHR_COLI") %>%
|
filter(mo == "B_ESCHR_COLI") %>%
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-sir.R", {
|
test_that("test-sir.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# Existing SIR ------------------------------------------------------------
|
# Existing SIR ------------------------------------------------------------
|
||||||
|
|
||||||
# we must only have EUCAST and CLSI, because otherwise the rules in as.sir() will fail
|
# we must only have EUCAST and CLSI, because otherwise the rules in as.sir() will fail
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-skewness.R", {
|
test_that("test-skewness.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_equal(skewness(example_isolates$age),
|
expect_equal(skewness(example_isolates$age),
|
||||||
-1.212888,
|
-1.212888,
|
||||||
tolerance = 0.00001
|
tolerance = 0.00001
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-top_n_microorganisms.R", {
|
test_that("test-top_n_microorganisms.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
out1 <- top_n_microorganisms(example_isolates, n = 3)
|
out1 <- top_n_microorganisms(example_isolates, n = 3)
|
||||||
out2 <- top_n_microorganisms(example_isolates, n = 5, property = "genus")
|
out2 <- top_n_microorganisms(example_isolates, n = 5, property = "genus")
|
||||||
out3 <- top_n_microorganisms(example_isolates, n = 5, property = "genus", n_for_each = 3)
|
out3 <- top_n_microorganisms(example_isolates, n = 5, property = "genus", n_for_each = 3)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-translate.R", {
|
test_that("test-translate.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
expect_identical(mo_genus("B_GRAMP", language = "pt"), "(gênero desconhecido)")
|
expect_identical(mo_genus("B_GRAMP", language = "pt"), "(gênero desconhecido)")
|
||||||
|
|
||||||
expect_identical(mo_fullname("CoNS", "cs"), "Koaguláza-negativní stafylokok (KNS)")
|
expect_identical(mo_fullname("CoNS", "cs"), "Koaguláza-negativní stafylokok (KNS)")
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-vctrs.R", {
|
test_that("test-vctrs.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# extra tests for {vctrs} pkg support
|
# extra tests for {vctrs} pkg support
|
||||||
if (AMR:::pkg_is_available("tibble")) {
|
if (AMR:::pkg_is_available("tibble")) {
|
||||||
test <- tibble::tibble(
|
test <- tibble::tibble(
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
# ==================================================================== #
|
# ==================================================================== #
|
||||||
|
|
||||||
test_that("test-zzz.R", {
|
test_that("test-zzz.R", {
|
||||||
|
skip_on_cran()
|
||||||
|
|
||||||
# Check if these functions still exist in their package (all are in Suggests field)
|
# 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
|
# Since GitHub Actions runs every night, we will get emailed when a dependency fails based on this unit test
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ if (identical(Sys.getenv("R_RUN_TINYTEST"), "true")) {
|
|||||||
code
|
code
|
||||||
}
|
}
|
||||||
expect_output <- tinytest::expect_stdout
|
expect_output <- tinytest::expect_stdout
|
||||||
|
skip_on_cran <- function() invisible(NULL)
|
||||||
|
|
||||||
# set language
|
# set language
|
||||||
set_AMR_locale("English")
|
set_AMR_locale("English")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user