mirror of
https://github.com/msberends/AMR.git
synced 2025-04-19 08:33:49 +02:00
(v2.1.1.9154) documentation fix
This commit is contained in:
parent
abb5602532
commit
226d10f546
@ -1,5 +1,5 @@
|
||||
Package: AMR
|
||||
Version: 2.1.1.9153
|
||||
Version: 2.1.1.9154
|
||||
Date: 2025-02-22
|
||||
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.9153
|
||||
# AMR 2.1.1.9154
|
||||
|
||||
*(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.9153
|
||||
Version: 2.1.1.9154
|
||||
Summary: A Python wrapper for the AMR R package
|
||||
Home-page: https://github.com/msberends/AMR
|
||||
Author: Matthijs Berends
|
||||
|
Binary file not shown.
BIN
PythonPackage/AMR/dist/amr-2.1.1.9153.tar.gz
vendored
BIN
PythonPackage/AMR/dist/amr-2.1.1.9153.tar.gz
vendored
Binary file not shown.
BIN
PythonPackage/AMR/dist/amr-2.1.1.9154.tar.gz
vendored
Normal file
BIN
PythonPackage/AMR/dist/amr-2.1.1.9154.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.9153',
|
||||
version='2.1.1.9154',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'rpy2',
|
||||
|
86
R/plotting.R
86
R/plotting.R
@ -81,20 +81,24 @@
|
||||
#' some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30))
|
||||
#'
|
||||
#'
|
||||
#' # Plotting using base R's plot() ---------------------------------------
|
||||
#'
|
||||
#' plot(some_mic_values)
|
||||
#' plot(some_disk_values)
|
||||
#' plot(some_sir_values)
|
||||
#'
|
||||
#' # when providing the microorganism and antibiotic, colours will show interpretations:
|
||||
#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
|
||||
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl")
|
||||
#' \donttest{
|
||||
#' # Plotting using ggplot2's autoplot() for MIC, disk, and SIR -----------
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(some_mic_values)
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' # when providing the microorganism and antibiotic, colours will show interpretations:
|
||||
#' autoplot(some_mic_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' # support for 20 languages, various guidelines, and many options
|
||||
#' autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro",
|
||||
#' guideline = "CLSI 2024", language = "no",
|
||||
#' title = "Disk diffusion from the North")
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' # 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")),
|
||||
#' counts = c(1, 1, 2, 2, 3, 3)),
|
||||
@ -142,22 +146,10 @@
|
||||
#' aes(group, mic)) +
|
||||
#' geom_boxplot() +
|
||||
#' geom_violin(linetype = 2, colour = "grey", fill = NA) +
|
||||
#' scale_y_mic(mic_range = c(NA, 2))
|
||||
#' scale_y_mic(mic_range = c(NA, 0.25))
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' # 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))
|
||||
#' }
|
||||
#'
|
||||
#' # Plotting using scale_x_sir() -----------------------------------------
|
||||
#' if (require("ggplot2")) {
|
||||
#' ggplot(data.frame(x = c("I", "R", "S"),
|
||||
@ -191,42 +183,22 @@
|
||||
#' if (require("ggplot2")) {
|
||||
#' plain +
|
||||
#' scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") +
|
||||
#' scale_colour_sir(language = "nl", eucast_I = FALSE,
|
||||
#' name = "In Dutch!")
|
||||
#' scale_colour_sir(language = "pt",
|
||||
#' name = "Support in 20 languages")
|
||||
#' }
|
||||
#'
|
||||
#'
|
||||
#' # Plotting using ggplot2's autoplot() ----------------------------------
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(some_mic_values)
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#' }
|
||||
#' if (require("ggplot2")) {
|
||||
#' autoplot(some_sir_values)
|
||||
#' }
|
||||
#' # Plotting using base R's plot() ---------------------------------------
|
||||
#'
|
||||
#' plot(some_mic_values)
|
||||
#' # when providing the microorganism and antibiotic, colours will show interpretations:
|
||||
#' plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
|
||||
#'
|
||||
#' plot(some_disk_values)
|
||||
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
#' plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl")
|
||||
#'
|
||||
#' # 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)),
|
||||
#' aes(mics, counts / sum(counts))) +
|
||||
#' geom_col()
|
||||
#' print(p)
|
||||
#'
|
||||
#' p2 <- p +
|
||||
#' scale_y_percent() +
|
||||
#' theme_sir()
|
||||
#' print(p2)
|
||||
#'
|
||||
#' p +
|
||||
#' scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1),
|
||||
#' limits = c(0, 1)) +
|
||||
#' theme_sir()
|
||||
#' }
|
||||
#' }
|
||||
#' plot(some_sir_values)
|
||||
NULL
|
||||
|
||||
create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) {
|
||||
@ -243,12 +215,12 @@ create_scale_mic <- function(aest, keep_operators, mic_range = NULL, ...) {
|
||||
scale$mic_limits_set <- limits_set
|
||||
|
||||
scale$transform <- function(x) {
|
||||
as.double(rescale_mic(x = as.double(x), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE))
|
||||
as.double(rescale_mic(x = as.double(as.mic(x)), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE))
|
||||
}
|
||||
scale$transform_df <- function(self, df) {
|
||||
stop_if(all(is.na(df[[aest]])),
|
||||
"`scale_", aest, "_mic()`: All MIC values are `NA`. Check your input data.", call = FALSE)
|
||||
self$mic_values_rescaled <- rescale_mic(x = as.double(df[[aest]]), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE)
|
||||
self$mic_values_rescaled <- rescale_mic(x = as.double(as.mic(df[[aest]])), keep_operators = keep_operators, mic_range = mic_range, as.mic = TRUE)
|
||||
# create new breaks and labels here
|
||||
lims <- range(self$mic_values_rescaled, na.rm = TRUE)
|
||||
# support inner and outer mic_range settings (e.g., data ranges 0.5-8 and mic_range is set to 0.025-64)
|
||||
|
@ -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.9153. Remember this whenever someone asks which AMR package version you’re at.
|
||||
First and foremost, you are trained on version 2.1.1.9154. 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.
|
||||
----------------------------------------------------------------------------------------------------
|
||||
@ -7540,159 +7540,6 @@ The interpretation of "I" will be named "Increased exposure" for all EUCAST guid
|
||||
For interpreting MIC values as well as disk diffusion diameters, the default guideline is EUCAST 2024, unless the package option \code{\link[=AMR-options]{AMR_guideline}} is set. See \code{\link[=as.sir]{as.sir()}} for more information.
|
||||
}
|
||||
}
|
||||
\examples{
|
||||
some_mic_values <- random_mic(size = 100)
|
||||
some_disk_values <- random_disk(size = 100, mo = "Escherichia coli", ab = "cipro")
|
||||
some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30))
|
||||
|
||||
|
||||
# Plotting using base R's plot() ---------------------------------------
|
||||
|
||||
plot(some_mic_values)
|
||||
plot(some_disk_values)
|
||||
plot(some_sir_values)
|
||||
|
||||
# when providing the microorganism and antibiotic, colours will show interpretations:
|
||||
plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
|
||||
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() -----------------------------------------
|
||||
\donttest{
|
||||
if (require("ggplot2")) {
|
||||
mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
|
||||
counts = c(1, 1, 2, 2, 3, 3)),
|
||||
aes(mics, counts)) +
|
||||
geom_col()
|
||||
mic_plot +
|
||||
labs(title = "without scale_x_mic()")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic() +
|
||||
labs(title = "with scale_x_mic()")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic(keep_operators = "all") +
|
||||
labs(title = "with scale_x_mic() keeping all operators")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic(mic_range = c(1, 16)) +
|
||||
labs(title = "with scale_x_mic() using a manual 'within' range")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic(mic_range = c(0.032, 256)) +
|
||||
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))
|
||||
}
|
||||
|
||||
# Plotting using scale_x_sir() -----------------------------------------
|
||||
if (require("ggplot2")) {
|
||||
ggplot(data.frame(x = c("I", "R", "S"),
|
||||
y = c(45,323, 573)),
|
||||
aes(x, y)) +
|
||||
geom_col() +
|
||||
scale_x_sir()
|
||||
}
|
||||
|
||||
|
||||
# Plotting using scale_y_mic() and scale_colour_sir() ------------------
|
||||
if (require("ggplot2")) {
|
||||
plain <- ggplot(data.frame(mic = some_mic_values,
|
||||
group = some_groups,
|
||||
sir = as.sir(some_mic_values,
|
||||
mo = "E. coli",
|
||||
ab = "cipro")),
|
||||
aes(x = group, y = mic, colour = sir)) +
|
||||
theme_minimal() +
|
||||
geom_boxplot(fill = NA, colour = "grey") +
|
||||
geom_jitter(width = 0.25)
|
||||
|
||||
plain
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
# and now with our MIC and SIR scale functions:
|
||||
plain +
|
||||
scale_y_mic() +
|
||||
scale_colour_sir()
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
plain +
|
||||
scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") +
|
||||
scale_colour_sir(language = "nl", eucast_I = FALSE,
|
||||
name = "In Dutch!")
|
||||
}
|
||||
|
||||
|
||||
# Plotting using ggplot2's autoplot() ----------------------------------
|
||||
if (require("ggplot2")) {
|
||||
autoplot(some_mic_values)
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
autoplot(some_sir_values)
|
||||
}
|
||||
|
||||
|
||||
# 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)),
|
||||
aes(mics, counts / sum(counts))) +
|
||||
geom_col()
|
||||
print(p)
|
||||
|
||||
p2 <- p +
|
||||
scale_y_percent() +
|
||||
theme_sir()
|
||||
print(p2)
|
||||
|
||||
p +
|
||||
scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1),
|
||||
limits = c(0, 1)) +
|
||||
theme_sir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
153
man/plot.Rd
153
man/plot.Rd
@ -196,156 +196,3 @@ The interpretation of "I" will be named "Increased exposure" for all EUCAST guid
|
||||
For interpreting MIC values as well as disk diffusion diameters, the default guideline is EUCAST 2024, unless the package option \code{\link[=AMR-options]{AMR_guideline}} is set. See \code{\link[=as.sir]{as.sir()}} for more information.
|
||||
}
|
||||
}
|
||||
\examples{
|
||||
some_mic_values <- random_mic(size = 100)
|
||||
some_disk_values <- random_disk(size = 100, mo = "Escherichia coli", ab = "cipro")
|
||||
some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30))
|
||||
|
||||
|
||||
# Plotting using base R's plot() ---------------------------------------
|
||||
|
||||
plot(some_mic_values)
|
||||
plot(some_disk_values)
|
||||
plot(some_sir_values)
|
||||
|
||||
# when providing the microorganism and antibiotic, colours will show interpretations:
|
||||
plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
|
||||
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() -----------------------------------------
|
||||
\donttest{
|
||||
if (require("ggplot2")) {
|
||||
mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
|
||||
counts = c(1, 1, 2, 2, 3, 3)),
|
||||
aes(mics, counts)) +
|
||||
geom_col()
|
||||
mic_plot +
|
||||
labs(title = "without scale_x_mic()")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic() +
|
||||
labs(title = "with scale_x_mic()")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic(keep_operators = "all") +
|
||||
labs(title = "with scale_x_mic() keeping all operators")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic(mic_range = c(1, 16)) +
|
||||
labs(title = "with scale_x_mic() using a manual 'within' range")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
mic_plot +
|
||||
scale_x_mic(mic_range = c(0.032, 256)) +
|
||||
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))
|
||||
}
|
||||
|
||||
# Plotting using scale_x_sir() -----------------------------------------
|
||||
if (require("ggplot2")) {
|
||||
ggplot(data.frame(x = c("I", "R", "S"),
|
||||
y = c(45,323, 573)),
|
||||
aes(x, y)) +
|
||||
geom_col() +
|
||||
scale_x_sir()
|
||||
}
|
||||
|
||||
|
||||
# Plotting using scale_y_mic() and scale_colour_sir() ------------------
|
||||
if (require("ggplot2")) {
|
||||
plain <- ggplot(data.frame(mic = some_mic_values,
|
||||
group = some_groups,
|
||||
sir = as.sir(some_mic_values,
|
||||
mo = "E. coli",
|
||||
ab = "cipro")),
|
||||
aes(x = group, y = mic, colour = sir)) +
|
||||
theme_minimal() +
|
||||
geom_boxplot(fill = NA, colour = "grey") +
|
||||
geom_jitter(width = 0.25)
|
||||
|
||||
plain
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
# and now with our MIC and SIR scale functions:
|
||||
plain +
|
||||
scale_y_mic() +
|
||||
scale_colour_sir()
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
plain +
|
||||
scale_y_mic(mic_range = c(0.005, 32), name = "Our MICs!") +
|
||||
scale_colour_sir(language = "nl", eucast_I = FALSE,
|
||||
name = "In Dutch!")
|
||||
}
|
||||
|
||||
|
||||
# Plotting using ggplot2's autoplot() ----------------------------------
|
||||
if (require("ggplot2")) {
|
||||
autoplot(some_mic_values)
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
autoplot(some_sir_values)
|
||||
}
|
||||
|
||||
|
||||
# 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)),
|
||||
aes(mics, counts / sum(counts))) +
|
||||
geom_col()
|
||||
print(p)
|
||||
|
||||
p2 <- p +
|
||||
scale_y_percent() +
|
||||
theme_sir()
|
||||
print(p2)
|
||||
|
||||
p +
|
||||
scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1),
|
||||
limits = c(0, 1)) +
|
||||
theme_sir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user