mirror of
https://github.com/msberends/AMR.git
synced 2025-04-19 08:33:49 +02:00
(v2.1.1.9191) unit tests
This commit is contained in:
parent
a2c2be23c1
commit
32024e597a
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 2.1.1.9190
|
Version: 2.1.1.9191
|
||||||
Date: 2025-03-09
|
Date: 2025-03-10
|
||||||
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)
|
||||||
data analysis and to work with microbial and antimicrobial properties by
|
data analysis and to work with microbial and antimicrobial properties by
|
||||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
|||||||
# AMR 2.1.1.9190
|
# AMR 2.1.1.9191
|
||||||
|
|
||||||
*(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).)*
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.2
|
Metadata-Version: 2.2
|
||||||
Name: AMR
|
Name: AMR
|
||||||
Version: 2.1.1.9190
|
Version: 2.1.1.9191
|
||||||
Summary: A Python wrapper for the AMR R package
|
Summary: A Python wrapper for the AMR R package
|
||||||
Home-page: https://github.com/msberends/AMR
|
Home-page: https://github.com/msberends/AMR
|
||||||
Author: Matthijs Berends
|
Author: Matthijs Berends
|
||||||
|
BIN
PythonPackage/AMR/dist/amr-2.1.1.9190.tar.gz
vendored
BIN
PythonPackage/AMR/dist/amr-2.1.1.9190.tar.gz
vendored
Binary file not shown.
Binary file not shown.
BIN
PythonPackage/AMR/dist/amr-2.1.1.9191.tar.gz
vendored
Normal file
BIN
PythonPackage/AMR/dist/amr-2.1.1.9191.tar.gz
vendored
Normal file
Binary file not shown.
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='AMR',
|
name='AMR',
|
||||||
version='2.1.1.9190',
|
version='2.1.1.9191',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
'rpy2',
|
'rpy2',
|
||||||
|
@ -870,7 +870,9 @@ antibiogram.default <- function(x,
|
|||||||
if (formatting_type == 20) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), "% (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), "%,", n_susceptible, "/", n_tested, ")"))
|
if (formatting_type == 20) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), "% (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), "%,", n_susceptible, "/", n_tested, ")"))
|
||||||
if (formatting_type == 21) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), " (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), ",N=", n_susceptible, "/", n_tested, ")"))
|
if (formatting_type == 21) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), " (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), ",N=", n_susceptible, "/", n_tested, ")"))
|
||||||
if (formatting_type == 22) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), "% (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), "%,N=", n_susceptible, "/", n_tested, ")"))
|
if (formatting_type == 22) out <- out %pm>% pm_summarise(out_value = paste0(round(coverage * 100, digits = digits), "% (", round(lower_ci * 100, digits = digits), "-", round(upper_ci * 100, digits = digits), "%,N=", n_susceptible, "/", n_tested, ")"))
|
||||||
out$out_value[out$out_value %like% "^NA"] <- NA_character_
|
if (formatting_type >= 4) {
|
||||||
|
out$out_value[out$out_value %like% "^NA"] <- NA_character_
|
||||||
|
}
|
||||||
|
|
||||||
# transform names of antimicrobials
|
# transform names of antimicrobials
|
||||||
ab_naming_function <- function(x, t, l, s) {
|
ab_naming_function <- function(x, t, l, s) {
|
||||||
@ -1260,6 +1262,15 @@ autoplot.antibiogram <- function(object, ...) {
|
|||||||
if (!"mo" %in% colnames(df)) {
|
if (!"mo" %in% colnames(df)) {
|
||||||
df$mo <- ""
|
df$mo <- ""
|
||||||
}
|
}
|
||||||
|
groups <- colnames(df)[seq_len(which(colnames(df) %in% c("mo", "ab"))[1] - 1)]
|
||||||
|
group_name <- paste(groups, collapse = "/")
|
||||||
|
if (length(groups) > 1) {
|
||||||
|
df$syndromic_group <- apply(df[groups], 1, function(x) {
|
||||||
|
paste(stats::na.omit(x), collapse = "/")
|
||||||
|
})
|
||||||
|
} else if ("syndromic_group" %in% colnames(df)) {
|
||||||
|
group_name <- colnames(object)[1]
|
||||||
|
}
|
||||||
out <- ggplot2::ggplot(df,
|
out <- ggplot2::ggplot(df,
|
||||||
mapping = ggplot2::aes(
|
mapping = ggplot2::aes(
|
||||||
x = ab,
|
x = ab,
|
||||||
@ -1272,7 +1283,6 @@ autoplot.antibiogram <- function(object, ...) {
|
|||||||
)
|
)
|
||||||
) +
|
) +
|
||||||
ggplot2::geom_col(position = ggplot2::position_dodge2(preserve = "single")) +
|
ggplot2::geom_col(position = ggplot2::position_dodge2(preserve = "single")) +
|
||||||
ggplot2::facet_wrap("mo") +
|
|
||||||
ggplot2::geom_errorbar(
|
ggplot2::geom_errorbar(
|
||||||
mapping = ggplot2::aes(ymin = lower_ci * 100, ymax = upper_ci * 100),
|
mapping = ggplot2::aes(ymin = lower_ci * 100, ymax = upper_ci * 100),
|
||||||
position = ggplot2::position_dodge2(preserve = "single", width = 1)
|
position = ggplot2::position_dodge2(preserve = "single", width = 1)
|
||||||
@ -1281,11 +1291,15 @@ autoplot.antibiogram <- function(object, ...) {
|
|||||||
y = ifelse(isTRUE(attributes(object)$combine_SI), "%SI", "%S"),
|
y = ifelse(isTRUE(attributes(object)$combine_SI), "%SI", "%S"),
|
||||||
x = NULL,
|
x = NULL,
|
||||||
fill = if ("syndromic_group" %in% colnames(df)) {
|
fill = if ("syndromic_group" %in% colnames(df)) {
|
||||||
colnames(object)[1]
|
group_name
|
||||||
} else {
|
} else {
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if (!all(df$mo == "", na.rm = TRUE)) {
|
||||||
|
out <- out +
|
||||||
|
ggplot2::facet_wrap("mo")
|
||||||
|
}
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.9190. Remember this whenever someone asks which AMR package version you’re at.
|
First and foremost, you are trained on version 2.1.1.9191. 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.
|
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.
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
@ -31,18 +31,18 @@ test_that("antibiogram works", {
|
|||||||
# Traditional antibiogram ----------------------------------------------
|
# Traditional antibiogram ----------------------------------------------
|
||||||
|
|
||||||
ab1 <- antibiogram(example_isolates,
|
ab1 <- antibiogram(example_isolates,
|
||||||
antibiotics = c(aminoglycosides(), carbapenems())
|
antimicrobials = c(aminoglycosides(), carbapenems())
|
||||||
)
|
)
|
||||||
|
|
||||||
ab2 <- antibiogram(example_isolates,
|
ab2 <- antibiogram(example_isolates,
|
||||||
antibiotics = aminoglycosides(),
|
antimicrobials = aminoglycosides(),
|
||||||
ab_transform = "atc",
|
ab_transform = "atc",
|
||||||
mo_transform = "gramstain",
|
mo_transform = "gramstain",
|
||||||
add_total_n = TRUE
|
add_total_n = TRUE
|
||||||
)
|
)
|
||||||
|
|
||||||
ab3 <- antibiogram(example_isolates,
|
ab3 <- antibiogram(example_isolates,
|
||||||
antibiotics = carbapenems(),
|
antimicrobials = carbapenems(),
|
||||||
ab_transform = "ab",
|
ab_transform = "ab",
|
||||||
mo_transform = "name",
|
mo_transform = "name",
|
||||||
formatting_type = 1
|
formatting_type = 1
|
||||||
@ -58,14 +58,14 @@ test_that("antibiogram works", {
|
|||||||
|
|
||||||
# Combined antibiogram -------------------------------------------------
|
# Combined antibiogram -------------------------------------------------
|
||||||
|
|
||||||
# combined antibiotics yield higher empiric coverage
|
# combined antibiogram yield higher empiric coverage
|
||||||
ab4 <- antibiogram(example_isolates,
|
ab4 <- antibiogram(example_isolates,
|
||||||
antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"),
|
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
||||||
mo_transform = "gramstain"
|
mo_transform = "gramstain"
|
||||||
)
|
)
|
||||||
|
|
||||||
ab5 <- antibiogram(example_isolates,
|
ab5 <- antibiogram(example_isolates,
|
||||||
antibiotics = c("TZP", "TZP+TOB"),
|
antimicrobials = c("TZP", "TZP+TOB"),
|
||||||
mo_transform = "gramstain",
|
mo_transform = "gramstain",
|
||||||
ab_transform = "name",
|
ab_transform = "name",
|
||||||
sep = " & ",
|
sep = " & ",
|
||||||
@ -81,7 +81,7 @@ test_that("antibiogram works", {
|
|||||||
|
|
||||||
# the data set could contain a filter for e.g. respiratory specimens
|
# the data set could contain a filter for e.g. respiratory specimens
|
||||||
ab6 <- antibiogram(example_isolates,
|
ab6 <- antibiogram(example_isolates,
|
||||||
antibiotics = c(aminoglycosides(), carbapenems()),
|
antimicrobials = c(aminoglycosides(), carbapenems()),
|
||||||
syndromic_group = "ward",
|
syndromic_group = "ward",
|
||||||
ab_transform = NULL
|
ab_transform = NULL
|
||||||
)
|
)
|
||||||
@ -90,7 +90,7 @@ test_that("antibiogram works", {
|
|||||||
# (i.e., this table will be in Dutch on Dutch systems)
|
# (i.e., this table will be in Dutch on Dutch systems)
|
||||||
ex1 <- example_isolates[which(mo_genus() == "Escherichia"), ]
|
ex1 <- example_isolates[which(mo_genus() == "Escherichia"), ]
|
||||||
ab7 <- antibiogram(ex1,
|
ab7 <- antibiogram(ex1,
|
||||||
antibiotics = aminoglycosides(),
|
antimicrobials = aminoglycosides(),
|
||||||
ab_transform = "name",
|
ab_transform = "name",
|
||||||
syndromic_group = ifelse(ex1$ward == "ICU",
|
syndromic_group = ifelse(ex1$ward == "ICU",
|
||||||
"IC", "Geen IC"
|
"IC", "Geen IC"
|
||||||
@ -108,7 +108,7 @@ test_that("antibiogram works", {
|
|||||||
|
|
||||||
# the data set could contain a filter for e.g. respiratory specimens
|
# the data set could contain a filter for e.g. respiratory specimens
|
||||||
ab8 <- suppressWarnings(antibiogram(example_isolates,
|
ab8 <- suppressWarnings(antibiogram(example_isolates,
|
||||||
antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"),
|
antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"),
|
||||||
wisca = TRUE
|
wisca = TRUE
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -118,11 +118,12 @@ test_that("antibiogram works", {
|
|||||||
expect_equal(colnames(ab8), c("Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin"))
|
expect_equal(colnames(ab8), c("Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin"))
|
||||||
|
|
||||||
# grouped tibbles
|
# grouped tibbles
|
||||||
|
|
||||||
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)) {
|
||||||
ab9 <- example_isolates %>%
|
expect_warning(
|
||||||
group_by(ward, gender) %>%
|
ab9 <- example_isolates %>%
|
||||||
wisca(antibiotics = c("TZP", "TZP+TOB", "TZP+GEN"))
|
group_by(ward, gender) %>%
|
||||||
|
wisca(antimicrobials = c("TZP", "TZP+TOB", "TZP+GEN"))
|
||||||
|
)
|
||||||
expect_equal(colnames(ab9), c("ward", "gender", "Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin"))
|
expect_equal(colnames(ab9), c("ward", "gender", "Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user