mirror of
https://github.com/msberends/AMR.git
synced 2025-07-12 23:41:57 +02:00
Remove RSI from package, add extra MIC scale functions
This commit is contained in:
@ -1,59 +0,0 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/zz_deprecated.R
|
||||
\docType{data}
|
||||
\name{AMR-deprecated}
|
||||
\alias{AMR-deprecated}
|
||||
\alias{NA_rsi_}
|
||||
\alias{as.rsi}
|
||||
\alias{facet_rsi}
|
||||
\alias{geom_rsi}
|
||||
\alias{ggplot_rsi}
|
||||
\alias{ggplot_rsi_predict}
|
||||
\alias{is.rsi}
|
||||
\alias{is.rsi.eligible}
|
||||
\alias{labels_rsi_count}
|
||||
\alias{n_rsi}
|
||||
\alias{random_rsi}
|
||||
\alias{rsi_df}
|
||||
\alias{rsi_predict}
|
||||
\alias{scale_rsi_colours}
|
||||
\alias{theme_rsi}
|
||||
\title{Deprecated Functions}
|
||||
\format{
|
||||
An object of class \code{rsi} (inherits from \code{ordered}, \code{factor}) of length 1.
|
||||
}
|
||||
\usage{
|
||||
NA_rsi_
|
||||
|
||||
as.rsi(x, ...)
|
||||
|
||||
facet_rsi(...)
|
||||
|
||||
geom_rsi(...)
|
||||
|
||||
ggplot_rsi(...)
|
||||
|
||||
ggplot_rsi_predict(...)
|
||||
|
||||
is.rsi(...)
|
||||
|
||||
is.rsi.eligible(...)
|
||||
|
||||
labels_rsi_count(...)
|
||||
|
||||
n_rsi(...)
|
||||
|
||||
random_rsi(...)
|
||||
|
||||
rsi_df(...)
|
||||
|
||||
rsi_predict(...)
|
||||
|
||||
scale_rsi_colours(...)
|
||||
|
||||
theme_rsi(...)
|
||||
}
|
||||
\description{
|
||||
These functions are so-called '\link{Deprecated}'. \strong{They will be removed in a future release.} Using the functions will give a warning with the name of the function it has been replaced by (if there is one).
|
||||
}
|
||||
\keyword{internal}
|
@ -4,16 +4,19 @@
|
||||
\name{as.mic}
|
||||
\alias{as.mic}
|
||||
\alias{mic}
|
||||
\alias{NA_mic_}
|
||||
\alias{is.mic}
|
||||
\alias{NA_mic_}
|
||||
\alias{rescale_mic}
|
||||
\alias{droplevels.mic}
|
||||
\title{Transform Input to Minimum Inhibitory Concentrations (MIC)}
|
||||
\usage{
|
||||
as.mic(x, na.rm = FALSE, keep_operators = "all")
|
||||
|
||||
is.mic(x)
|
||||
|
||||
NA_mic_
|
||||
|
||||
is.mic(x)
|
||||
rescale_mic(x, mic_range, keep_operators = "edges", as.mic = TRUE)
|
||||
|
||||
\method{droplevels}{mic}(x, as.mic = FALSE, ...)
|
||||
}
|
||||
@ -24,6 +27,8 @@ is.mic(x)
|
||||
|
||||
\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 plot 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{as.mic}{a \link{logical} to indicate whether the \code{mic} class should be kept - the default is \code{FALSE}}
|
||||
|
||||
\item{...}{arguments passed on to methods}
|
||||
@ -77,6 +82,8 @@ Using \code{\link[=as.double]{as.double()}} or \code{\link[=as.numeric]{as.numer
|
||||
|
||||
Use \code{\link[=droplevels]{droplevels()}} to drop unused levels. At default, it will return a plain factor. Use \code{droplevels(..., as.mic = TRUE)} to maintain the \code{mic} class.
|
||||
|
||||
With \code{\link[=rescale_mic]{rescale_mic()}}, existing MIC ranges can be rescaled to a defined range of MIC values. This can be useful to better compare MIC distributions.
|
||||
|
||||
\code{NA_mic_} is a missing value of the new \code{mic} class, analogous to e.g. base \R's \code{\link[base:NA]{NA_character_}}.
|
||||
}
|
||||
\examples{
|
||||
@ -92,6 +99,9 @@ fivenum(mic_data)
|
||||
quantile(mic_data)
|
||||
all(mic_data < 512)
|
||||
|
||||
# rescale MICs using rescale_mic()
|
||||
rescale_mic(mic_data, mic_range = c(4, 16))
|
||||
|
||||
# interpret MIC values
|
||||
as.sir(
|
||||
x = as.mic(2),
|
||||
|
@ -130,16 +130,18 @@ if (require("dplyr")) {
|
||||
summary(pca_result)
|
||||
|
||||
# old base R plotting method:
|
||||
biplot(pca_result)
|
||||
biplot(pca_result, main = "Base R biplot")
|
||||
|
||||
# new ggplot2 plotting method using this package:
|
||||
if (require("ggplot2")) {
|
||||
ggplot_pca(pca_result)
|
||||
|
||||
ggplot_pca(pca_result) +
|
||||
labs(title = "ggplot2 biplot")
|
||||
}
|
||||
if (require("ggplot2")) {
|
||||
# still extendible with any ggplot2 function
|
||||
ggplot_pca(pca_result) +
|
||||
scale_colour_viridis_d() +
|
||||
labs(title = "Title here")
|
||||
labs(title = "ggplot2 biplot")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
60
man/plot.Rd
60
man/plot.Rd
@ -2,10 +2,13 @@
|
||||
% Please edit documentation in R/plot.R
|
||||
\name{plot}
|
||||
\alias{plot}
|
||||
\alias{scale_x_mic}
|
||||
\alias{scale_y_mic}
|
||||
\alias{scale_colour_mic}
|
||||
\alias{scale_fill_mic}
|
||||
\alias{plot.mic}
|
||||
\alias{autoplot.mic}
|
||||
\alias{fortify.mic}
|
||||
\alias{scale_x_mic}
|
||||
\alias{plot.disk}
|
||||
\alias{autoplot.disk}
|
||||
\alias{fortify.disk}
|
||||
@ -14,6 +17,14 @@
|
||||
\alias{fortify.sir}
|
||||
\title{Plotting for Classes \code{sir}, \code{mic} and \code{disk}}
|
||||
\usage{
|
||||
scale_x_mic(keep_operators = "edges", mic_range = NULL, ...)
|
||||
|
||||
scale_y_mic(keep_operators = "edges", mic_range = NULL, ...)
|
||||
|
||||
scale_colour_mic(keep_operators = "edges", mic_range = NULL, ...)
|
||||
|
||||
scale_fill_mic(keep_operators = "edges", mic_range = NULL, ...)
|
||||
|
||||
\method{plot}{mic}(
|
||||
x,
|
||||
mo = NULL,
|
||||
@ -48,16 +59,6 @@
|
||||
|
||||
\method{fortify}{mic}(object, ...)
|
||||
|
||||
scale_x_mic(
|
||||
keep_operators = "edges",
|
||||
mic_range = NULL,
|
||||
...,
|
||||
drop = FALSE,
|
||||
guide = waiver(),
|
||||
position = "bottom",
|
||||
na.translate = TRUE
|
||||
)
|
||||
|
||||
\method{plot}{disk}(
|
||||
x,
|
||||
main = deparse(substitute(x)),
|
||||
@ -114,6 +115,12 @@ scale_x_mic(
|
||||
\method{fortify}{sir}(object, ...)
|
||||
}
|
||||
\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 plot 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{...}{arguments passed on to methods}
|
||||
|
||||
\item{x, object}{values created with \code{\link[=as.mic]{as.mic()}}, \code{\link[=as.disk]{as.disk()}} or \code{\link[=as.sir]{as.sir()}} (or their \verb{random_*} variants, such as \code{\link[=random_mic]{random_mic()}})}
|
||||
|
||||
\item{mo}{any (vector of) text that can be coerced to a valid microorganism code with \code{\link[=as.mo]{as.mo()}}}
|
||||
@ -135,14 +142,6 @@ scale_x_mic(
|
||||
\item{include_PKPD}{a \link{logical} to indicate that PK/PD clinical breakpoints must be applied as a last resort - the default is \code{TRUE}. Can also be set with the \link[=AMR-options]{package option} \code{\link[=AMR-options]{AMR_include_PKPD}}.}
|
||||
|
||||
\item{breakpoint_type}{the type of breakpoints to use, either "ECOFF", "animal", or "human". ECOFF stands for Epidemiological Cut-Off values. The default is \code{"human"}, which can also be set with the \link[=AMR-options]{package option} \code{\link[=AMR-options]{AMR_breakpoint_type}}.}
|
||||
|
||||
\item{...}{arguments passed on to methods}
|
||||
|
||||
\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 plot 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, guide, position, na.translate}{arguments passed on to \code{\link[ggplot2:scale_discrete]{ggplot2::scale_x_discrete()}}}
|
||||
}
|
||||
\value{
|
||||
The \code{autoplot()} functions return a \code{\link[ggplot2:ggplot]{ggplot}} model that is extendible with any \code{ggplot2} function.
|
||||
@ -152,7 +151,7 @@ The \code{fortify()} functions return a \link{data.frame} as an extension for us
|
||||
\description{
|
||||
Functions to plot classes \code{sir}, \code{mic} and \code{disk}, with support for base \R and \code{ggplot2}.
|
||||
|
||||
Especially \code{\link[=scale_x_mic]{scale_x_mic()}} is a relevant wrapper to plot MIC values for \code{ggplot2}. It allows custom MIC ranges and to plot intermediate log2 levels for missing MIC values.
|
||||
Especially the \code{\link[=scale_*_mic]{scale_*_mic()}} functions are relevant wrappers to plot MIC values for \code{ggplot2}. They allows custom MIC ranges and to plot intermediate log2 levels for missing MIC values.
|
||||
}
|
||||
\details{
|
||||
The interpretation of "I" will be named "Increased exposure" for all EUCAST guidelines since 2019, and will be named "Intermediate" in all other cases.
|
||||
@ -175,17 +174,6 @@ 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{
|
||||
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_x_mic()
|
||||
\donttest{
|
||||
@ -212,5 +200,15 @@ if (require("ggplot2")) {
|
||||
scale_x_mic(mic_range = c(1, 128)) +
|
||||
labs(title = "with scale_x_mic() using a manual range")
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user