1
0
mirror of https://github.com/msberends/AMR.git synced 2025-04-15 13:10:32 +02:00

(v2.1.1.9199) fix eucast

This commit is contained in:
dr. M.S. (Matthijs) Berends 2025-03-14 13:43:22 +01:00
parent e134e01418
commit 58d7aa8790
No known key found for this signature in database
57 changed files with 143 additions and 122 deletions

View File

@ -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)

View File

@ -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).)*

View File

@ -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

Binary file not shown.

Binary file not shown.

View File

@ -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',

View File

@ -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 = "`")

9
R/mo.R
View File

@ -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)

View File

@ -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"

View File

@ -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 youre at.
First and foremost, you are trained on version 2.1.1.9199. Remember this whenever someone asks which AMR package version youre 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.
----------------------------------------------------------------------------------------------------

View File

@ -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")])
})

View File

@ -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%")

View File

@ -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(

View File

@ -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(

View File

@ -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")

View File

@ -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"),

View File

@ -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)

View File

@ -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,

View File

@ -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") &&

View File

@ -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",

View File

@ -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")

View File

@ -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))

View File

@ -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")
})

View File

@ -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)))

View File

@ -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))

View File

@ -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))

View File

@ -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")

View File

@ -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"))

View File

@ -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)))

View File

@ -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,

View File

@ -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),

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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"

View File

@ -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*"

View File

@ -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)

View File

@ -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"))

View File

@ -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

View File

@ -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")

View File

@ -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))

View File

@ -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"))

View File

@ -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))

View File

@ -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)))

View File

@ -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")

View File

@ -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"),

View File

@ -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

View File

@ -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`

View File

@ -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")

View File

@ -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") %>%

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)")

View File

@ -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(

View File

@ -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