1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-21 12:13:20 +02:00

(v2.1.1.9144) new MIC scales and fix for rescale_mic()

This commit is contained in:
2025-02-11 08:48:37 +01:00
parent 2171f05951
commit 07757c933c
13 changed files with 191 additions and 79 deletions

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.9143. Remember this whenever someone asks which AMR package version youre at.
First and foremost, you are trained on version 2.1.1.9144. 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.
----------------------------------------------------------------------------------------------------
@ -332,6 +332,7 @@ export(resistance_predict)
export(retrieve_wisca_parameters)
export(rifamycins)
export(right_join_microorganisms)
export(scale_color_mic)
export(scale_colour_mic)
export(scale_fill_mic)
export(scale_sir_colours)
@ -2875,9 +2876,9 @@ rescale_mic(x, mic_range, keep_operators = "edges", as.mic = TRUE)
\item{keep_operators}{a \link{character} specifying how to handle operators (such as \code{>} and \code{<=}) in the input. Accepts one of three values: \code{"all"} (or \code{TRUE}) to keep all operators, \code{"none"} (or \code{FALSE}) to remove all operators, or \code{"edges"} to keep operators only at both ends of the range.}
\item{mic_range}{a manual range to limit the MIC values, e.g., \code{mic_range = c(0.001, 32)}. Use \code{NA} to set no limit on one side, e.g., \code{mic_range = c(NA, 32)}.}
\item{mic_range}{a manual range to limit the MIC values, e.g., \code{mic_range = c(0.001, 32)}. Use \code{NA} to prevent a limit on one side, e.g., \code{mic_range = c(NA, 32)}.}
\item{as.mic}{a \link{logical} to indicate whether the \code{mic} class should be kept - the default is \code{FALSE}}
\item{as.mic}{a \link{logical} to indicate whether the \code{mic} class should be kept - the default is \code{TRUE} for \code{\link[=rescale_mic]{rescale_mic()}} and \code{FALSE} for \code{\link[=droplevels]{droplevels()}}. When setting this to \code{FALSE} in \code{\link[=rescale_mic]{rescale_mic()}}, the output will have factor levels that acknowledge \code{mic_range}.}
\item{...}{arguments passed on to methods}
}
@ -7330,6 +7331,7 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'man/plot.Rd':
\alias{scale_x_mic}
\alias{scale_y_mic}
\alias{scale_colour_mic}
\alias{scale_color_mic}
\alias{scale_fill_mic}
\alias{plot.mic}
\alias{autoplot.mic}
@ -7347,17 +7349,15 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'man/plot.Rd':
\alias{labels_sir_count}
\title{Plotting Helpers for AMR Data Analysis}
\usage{
scale_x_mic(keep_operators = "edges", mic_range = NULL, drop = FALSE,
...)
scale_x_mic(keep_operators = "edges", mic_range = NULL, ...)
scale_y_mic(keep_operators = "edges", mic_range = NULL, drop = FALSE,
...)
scale_y_mic(keep_operators = "edges", mic_range = NULL, ...)
scale_colour_mic(keep_operators = "edges", mic_range = NULL,
drop = FALSE, ...)
scale_colour_mic(keep_operators = "edges", mic_range = NULL, ...)
scale_fill_mic(keep_operators = "edges", mic_range = NULL, drop = FALSE,
...)
scale_color_mic(keep_operators = "edges", mic_range = NULL, ...)
scale_fill_mic(keep_operators = "edges", mic_range = NULL, ...)
\method{plot}{mic}(x, mo = NULL, ab = NULL, guideline = "EUCAST",
main = deparse(substitute(x)), ylab = translate_AMR("Frequency", language
@ -7428,9 +7428,7 @@ labels_sir_count(position = NULL, x = "antibiotic",
\arguments{
\item{keep_operators}{a \link{character} specifying how to handle operators (such as \code{>} and \code{<=}) in the input. Accepts one of three values: \code{"all"} (or \code{TRUE}) to keep all operators, \code{"none"} (or \code{FALSE}) to remove all operators, or \code{"edges"} to keep operators only at both ends of the range.}
\item{mic_range}{a manual range to limit the MIC values, e.g., \code{mic_range = c(0.001, 32)}. Use \code{NA} to set no limit on one side, e.g., \code{mic_range = c(NA, 32)}.}
\item{drop}{a \link{logical} to remove intermediate MIC values, defaults to \code{FALSE}}
\item{mic_range}{a manual range to limit the MIC values, e.g., \code{mic_range = c(0.001, 32)}. Use \code{NA} to prevent a limit on one side, e.g., \code{mic_range = c(NA, 32)}.}
\item{...}{arguments passed on to methods}
@ -7521,7 +7519,7 @@ plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl")
# Plotting using scale_x_mic() ---------------------------------------------
# Plotting using scale_x_mic() -----------------------------------------
\donttest{
if (require("ggplot2")) {
mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
@ -7552,6 +7550,37 @@ if (require("ggplot2")) {
labs(title = "with scale_x_mic() using a manual 'outside' range")
}
# Plotting using scale_y_mic() -----------------------------------------
some_groups <- sample(LETTERS[1:5], 20, replace = TRUE)
if (require("ggplot2")) {
ggplot(data.frame(mic = some_mic_values,
group = some_groups),
aes(group, mic)) +
geom_boxplot() +
geom_violin(linetype = 2, colour = "grey", fill = NA) +
scale_y_mic()
}
if (require("ggplot2")) {
ggplot(data.frame(mic = some_mic_values,
group = some_groups),
aes(group, mic)) +
geom_boxplot() +
geom_violin(linetype = 2, colour = "grey", fill = NA) +
scale_y_mic(mic_range = c(NA, 2))
}
# Plotting using scale_fill_mic() -----------------------------------------
some_counts <- as.integer(runif(20, 5, 50))
if (require("ggplot2")) {
ggplot(data.frame(mic = some_mic_values,
group = some_groups,
counts = some_counts,
aes(group, counts, fill = mic)) +
geom_col() +
scale_fill_mic(mic_range = c(0.5, 16))
}
# Auto plotting --------------------------------------------------------
if (require("ggplot2")) {
autoplot(some_mic_values)
}
@ -7562,7 +7591,7 @@ if (require("ggplot2")) {
autoplot(some_sir_values)
}
# Plotting using scale_y_percent() -----------------------------------------
# Plotting using scale_y_percent() -------------------------------------
if (require("ggplot2")) {
p <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
counts = c(1, 1, 2, 2, 3, 3)),