mirror of
https://github.com/msberends/AMR.git
synced 2025-04-15 13:10:32 +02:00
(v2.1.1.9188) fix antibiogram plot
This commit is contained in:
parent
b67613ce08
commit
245483e41c
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9187
|
||||
Version: 2.1.1.9188
|
||||
Date: 2025-03-07
|
||||
Title: Antimicrobial Resistance Data Analysis
|
||||
Description: Functions to simplify and standardise antimicrobial resistance (AMR)
|
||||
|
2
NEWS.md
2
NEWS.md
@ -1,4 +1,4 @@
|
||||
# AMR 2.1.1.9187
|
||||
# AMR 2.1.1.9188
|
||||
|
||||
*(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
|
||||
Name: AMR
|
||||
Version: 2.1.1.9187
|
||||
Version: 2.1.1.9188
|
||||
Summary: A Python wrapper for the AMR R package
|
||||
Home-page: https://github.com/msberends/AMR
|
||||
Author: Matthijs Berends
|
||||
|
BIN
PythonPackage/AMR/dist/amr-2.1.1.9187.tar.gz
vendored
BIN
PythonPackage/AMR/dist/amr-2.1.1.9187.tar.gz
vendored
Binary file not shown.
Binary file not shown.
BIN
PythonPackage/AMR/dist/amr-2.1.1.9188.tar.gz
vendored
Normal file
BIN
PythonPackage/AMR/dist/amr-2.1.1.9188.tar.gz
vendored
Normal file
Binary file not shown.
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='AMR',
|
||||
version='2.1.1.9187',
|
||||
version='2.1.1.9188',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'rpy2',
|
||||
|
@ -769,6 +769,32 @@ antibiogram.default <- function(x,
|
||||
# prepare for definitive output
|
||||
out <- out_wisca
|
||||
wisca_parameters <- wisca_parameters[, colnames(wisca_parameters)[!colnames(wisca_parameters) %in% c(levels(NA_sir_), "lower_ci", "upper_ci", "group")], drop = FALSE]
|
||||
if (isTRUE(has_syndromic_group)) {
|
||||
long_numeric <- out_wisca %pm>%
|
||||
pm_ungroup() %pm>%
|
||||
pm_select(
|
||||
syndromic_group = syndromic_group,
|
||||
ab = ab,
|
||||
coverage = coverage,
|
||||
lower_ci = lower_ci,
|
||||
upper_ci = upper_ci,
|
||||
n_total = n_total,
|
||||
n_tested = n_tested,
|
||||
n_susceptible = n_susceptible
|
||||
)
|
||||
} else {
|
||||
long_numeric <- out_wisca %pm>%
|
||||
pm_ungroup() %pm>%
|
||||
pm_select(
|
||||
ab = ab,
|
||||
coverage = coverage,
|
||||
lower_ci = lower_ci,
|
||||
upper_ci = upper_ci,
|
||||
n_total = n_total,
|
||||
n_tested = n_tested,
|
||||
n_susceptible = n_susceptible
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
out$digits <- digits # since pm_sumarise() cannot work with an object outside the current frame
|
||||
@ -1170,9 +1196,7 @@ tbl_format_footer.antibiogram <- function(x, ...) {
|
||||
plot.antibiogram <- function(x, ...) {
|
||||
df <- attributes(x)$long_numeric
|
||||
if (!"mo" %in% colnames(df)) {
|
||||
stop_("Plotting antibiograms using `plot()` is only possible if they were not created using dplyr groups. See `?antibiogram` for how to retrieve numeric values in a long format for advanced plotting.",
|
||||
call = FALSE
|
||||
)
|
||||
df$mo <- ""
|
||||
}
|
||||
if ("syndromic_group" %in% colnames(df)) {
|
||||
# barplot in base R does not support facets - paste columns together
|
||||
@ -1226,9 +1250,7 @@ barplot.antibiogram <- function(height, ...) {
|
||||
autoplot.antibiogram <- function(object, ...) {
|
||||
df <- attributes(object)$long_numeric
|
||||
if (!"mo" %in% colnames(df)) {
|
||||
stop_("Plotting antibiograms using `autoplot()` is only possible if they were not created using dplyr groups. See `?antibiogram` for how to retrieve numeric values in a long format for advanced plotting.",
|
||||
call = FALSE
|
||||
)
|
||||
df$mo <- ""
|
||||
}
|
||||
out <- ggplot2::ggplot(df,
|
||||
mapping = ggplot2::aes(
|
||||
@ -1243,6 +1265,10 @@ autoplot.antibiogram <- function(object, ...) {
|
||||
) +
|
||||
ggplot2::geom_col(position = ggplot2::position_dodge2(preserve = "single")) +
|
||||
ggplot2::facet_wrap("mo") +
|
||||
ggplot2::geom_errorbar(
|
||||
mapping = ggplot2::aes(ymin = lower_ci * 100, ymax = upper_ci * 100),
|
||||
position = ggplot2::position_dodge2(preserve = "single", width = 1)
|
||||
) +
|
||||
ggplot2::labs(
|
||||
y = ifelse(isTRUE(attributes(object)$combine_SI), "%SI", "%S"),
|
||||
x = NULL,
|
||||
@ -1252,14 +1278,6 @@ autoplot.antibiogram <- function(object, ...) {
|
||||
NULL
|
||||
}
|
||||
)
|
||||
if (isTRUE(attributes(object)$wisca)) {
|
||||
out <- out +
|
||||
ggplot2::geom_errorbar(
|
||||
mapping = ggplot2::aes(ymin = lower_ci * 100, ymax = upper_ci * 100),
|
||||
position = ggplot2::position_dodge2(preserve = "single"),
|
||||
width = 0.5
|
||||
)
|
||||
}
|
||||
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.
|
||||
|
||||
First and foremost, you are trained on version 2.1.1.9187. Remember this whenever someone asks which AMR package version you’re at.
|
||||
First and foremost, you are trained on version 2.1.1.9188. 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.
|
||||
----------------------------------------------------------------------------------------------------
|
@ -113,6 +113,8 @@ test_that("antibiogram works", {
|
||||
))
|
||||
|
||||
expect_inherits(ab8, "antibiogram")
|
||||
expect_inherits(retrieve_wisca_parameters(ab8), "data.frame")
|
||||
expect_inherits(attributes(ab8)$long_numeric, "data.frame")
|
||||
expect_equal(colnames(ab8), c("Piperacillin/tazobactam", "Piperacillin/tazobactam + Gentamicin", "Piperacillin/tazobactam + Tobramycin"))
|
||||
|
||||
# grouped tibbles
|
||||
|
Loading…
x
Reference in New Issue
Block a user