mirror of
https://github.com/msberends/AMR.git
synced 2025-07-11 15:41:57 +02:00
(v2.1.1.9118) move ggplot2 plotting functions to general 'plotting' man page
This commit is contained in:
@ -274,7 +274,7 @@ setup(
|
||||
'numpy',
|
||||
'pandas',
|
||||
],
|
||||
author='Dr. Matthijs Berends',
|
||||
author='Matthijs Berends',
|
||||
author_email='m.s.berends@umcg.nl',
|
||||
description='A Python wrapper for the AMR R package',
|
||||
long_description=open('README.md').read(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
This files contains all context you must know about the AMR package for R.
|
||||
First and foremost, you are trained on version 2.1.1.9117. Remember this whenever someone asks which AMR package version you’re at.
|
||||
First and foremost, you are trained on version 2.1.1.9118. Remember this whenever someone asks which AMR package version you’re at.
|
||||
--------------------------------
|
||||
|
||||
THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'NAMESPACE':
|
||||
@ -5365,11 +5365,6 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'man/ggplot_sir.Rd':
|
||||
\name{ggplot_sir}
|
||||
\alias{ggplot_sir}
|
||||
\alias{geom_sir}
|
||||
\alias{facet_sir}
|
||||
\alias{scale_y_percent}
|
||||
\alias{scale_sir_colours}
|
||||
\alias{theme_sir}
|
||||
\alias{labels_sir_count}
|
||||
\title{AMR Plots with \code{ggplot2}}
|
||||
\usage{
|
||||
ggplot_sir(
|
||||
@ -5408,28 +5403,6 @@ geom_sir(
|
||||
combine_SI = TRUE,
|
||||
...
|
||||
)
|
||||
|
||||
facet_sir(facet = c("interpretation", "antibiotic"), nrow = NULL)
|
||||
|
||||
scale_y_percent(
|
||||
breaks = function(x) seq(0, max(x, na.rm = TRUE), 0.1),
|
||||
limits = NULL
|
||||
)
|
||||
|
||||
scale_sir_colours(..., aesthetics = "fill")
|
||||
|
||||
theme_sir()
|
||||
|
||||
labels_sir_count(
|
||||
position = NULL,
|
||||
x = "antibiotic",
|
||||
translate_ab = "name",
|
||||
minimum = 30,
|
||||
language = get_AMR_locale(),
|
||||
combine_SI = TRUE,
|
||||
datalabels.size = 3,
|
||||
datalabels.colour = "grey15"
|
||||
)
|
||||
}
|
||||
\arguments{
|
||||
\item{data}{a \link{data.frame} with column(s) of class \code{\link{sir}} (see \code{\link[=as.sir]{as.sir()}})}
|
||||
@ -5483,23 +5456,20 @@ Use these functions to create bar plots for AMR data analysis. All functions rel
|
||||
}
|
||||
\details{
|
||||
At default, the names of antibiotics will be shown on the plots using \code{\link[=ab_name]{ab_name()}}. This can be set with the \code{translate_ab} argument. See \code{\link[=count_df]{count_df()}}.
|
||||
\subsection{The Functions}{
|
||||
|
||||
\code{\link[=geom_sir]{geom_sir()}} will take any variable from the data that has an \code{\link{sir}} class (created with \code{\link[=as.sir]{as.sir()}}) using \code{\link[=sir_df]{sir_df()}} and will plot bars with the percentage S, I, and R. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.
|
||||
|
||||
\code{\link[=facet_sir]{facet_sir()}} creates 2d plots (at default based on S/I/R) using \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}.
|
||||
|
||||
\code{\link[=scale_y_percent]{scale_y_percent()}} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2:scale_continuous]{ggplot2::scale_y_continuous()}}.
|
||||
|
||||
\code{\link[=scale_sir_colours]{scale_sir_colours()}} sets colours to the bars (green for S, yellow for I, and red for R). with multilingual support. The default colours are colour-blind friendly, while maintaining the convention that e.g. 'susceptible' should be green and 'resistant' should be red.
|
||||
|
||||
\code{\link[=theme_sir]{theme_sir()}} is a [ggplot2 theme][\code{\link[ggplot2:theme]{ggplot2::theme()}} with minimal distraction.
|
||||
|
||||
\code{\link[=labels_sir_count]{labels_sir_count()}} print datalabels on the bars with percentage and amount of isolates using \code{\link[ggplot2:geom_text]{ggplot2::geom_text()}}.
|
||||
Additional functions include:
|
||||
\itemize{
|
||||
\item \code{\link[=facet_sir]{facet_sir()}} creates 2d plots (at default based on S/I/R) using \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}.
|
||||
\item \code{\link[=scale_y_percent]{scale_y_percent()}} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2:scale_continuous]{ggplot2::scale_y_continuous()}}.
|
||||
\item \code{\link[=scale_sir_colours]{scale_sir_colours()}} sets colours to the bars (green for S, yellow for I, and red for R). with multilingual support. The default colours are colour-blind friendly, while maintaining the convention that e.g. 'susceptible' should be green and 'resistant' should be red.
|
||||
\item \code{\link[=theme_sir]{theme_sir()}} is a [ggplot2 theme][\code{\link[ggplot2:theme]{ggplot2::theme()}} with minimal distraction.
|
||||
\item \code{\link[=labels_sir_count]{labels_sir_count()}} print datalabels on the bars with percentage and amount of isolates using \code{\link[ggplot2:geom_text]{ggplot2::geom_text()}}.
|
||||
}
|
||||
|
||||
\code{\link[=ggplot_sir]{ggplot_sir()}} is a wrapper around all above functions that uses data as first input. This makes it possible to use this function after a pipe (\verb{\%>\%}). See \emph{Examples}.
|
||||
}
|
||||
}
|
||||
\examples{
|
||||
\donttest{
|
||||
if (require("ggplot2") && require("dplyr")) {
|
||||
@ -7437,7 +7407,12 @@ THE PART HEREAFTER CONTAINS CONTENTS FROM FILE 'man/plot.Rd':
|
||||
\alias{plot.sir}
|
||||
\alias{autoplot.sir}
|
||||
\alias{fortify.sir}
|
||||
\title{Plotting for Classes \code{sir}, \code{mic} and \code{disk}}
|
||||
\alias{facet_sir}
|
||||
\alias{scale_y_percent}
|
||||
\alias{scale_sir_colours}
|
||||
\alias{theme_sir}
|
||||
\alias{labels_sir_count}
|
||||
\title{Plotting Helpers for AMR Data Analysis}
|
||||
\usage{
|
||||
scale_x_mic(keep_operators = "edges", mic_range = NULL, drop = FALSE, ...)
|
||||
|
||||
@ -7535,6 +7510,32 @@ scale_fill_mic(keep_operators = "edges", mic_range = NULL, drop = FALSE, ...)
|
||||
)
|
||||
|
||||
\method{fortify}{sir}(object, ...)
|
||||
|
||||
facet_sir(facet = c("interpretation", "antibiotic"), nrow = NULL)
|
||||
|
||||
scale_y_percent(
|
||||
breaks = function(x) seq(0, max(x, na.rm = TRUE), 0.1),
|
||||
limits = NULL
|
||||
)
|
||||
|
||||
scale_sir_colours(
|
||||
...,
|
||||
aesthetics = "fill",
|
||||
colours_SIR = c("#3CAEA3", "#F6D55C", "#ED553B")
|
||||
)
|
||||
|
||||
theme_sir()
|
||||
|
||||
labels_sir_count(
|
||||
position = NULL,
|
||||
x = "antibiotic",
|
||||
translate_ab = "name",
|
||||
minimum = 30,
|
||||
language = get_AMR_locale(),
|
||||
combine_SI = TRUE,
|
||||
datalabels.size = 3,
|
||||
datalabels.colour = "grey15"
|
||||
)
|
||||
}
|
||||
\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.}
|
||||
@ -7583,6 +7584,17 @@ The interpretation of "I" will be named "Increased exposure" for all EUCAST guid
|
||||
For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the \code{guideline} argument are: "EUCAST 2024", "EUCAST 2023", "EUCAST 2022", "EUCAST 2021", "EUCAST 2020", "EUCAST 2019", "EUCAST 2018", "EUCAST 2017", "EUCAST 2016", "EUCAST 2015", "EUCAST 2014", "EUCAST 2013", "EUCAST 2012", "EUCAST 2011", "CLSI 2024", "CLSI 2023", "CLSI 2022", "CLSI 2021", "CLSI 2020", "CLSI 2019", "CLSI 2018", "CLSI 2017", "CLSI 2016", "CLSI 2015", "CLSI 2014", "CLSI 2013", "CLSI 2012", and "CLSI 2011".
|
||||
|
||||
Simply using \code{"CLSI"} or \code{"EUCAST"} as input will automatically select the latest version of that guideline.
|
||||
\subsection{Additional \code{ggplot2} Functions}{
|
||||
|
||||
This package contains several functions that extend the \code{ggplot2} package, to help in visualising AMR data results. All these functions are internally used by \code{\link[=ggplot_sir]{ggplot_sir()}} too.
|
||||
\itemize{
|
||||
\item \code{\link[=facet_sir]{facet_sir()}} creates 2d plots (at default based on S/I/R) using \code{\link[ggplot2:facet_wrap]{ggplot2::facet_wrap()}}.
|
||||
\item \code{\link[=scale_y_percent]{scale_y_percent()}} transforms the y axis to a 0 to 100\% range using \code{\link[ggplot2:scale_continuous]{ggplot2::scale_y_continuous()}}.
|
||||
\item \code{\link[=scale_sir_colours]{scale_sir_colours()}} sets colours to the bars (green for S, yellow for I, and red for R). Has multilingual support. The default colours are colour-blind friendly, while maintaining the convention that e.g. 'susceptible' should be green and 'resistant' should be red.
|
||||
\item \code{\link[=theme_sir]{theme_sir()}} is a [ggplot2 theme][\code{\link[ggplot2:theme]{ggplot2::theme()}} with minimal distraction.
|
||||
\item \code{\link[=labels_sir_count]{labels_sir_count()}} print datalabels on the bars with percentage and number of isolates, using \code{\link[ggplot2:geom_text]{ggplot2::geom_text()}}.
|
||||
}
|
||||
}
|
||||
}
|
||||
\examples{
|
||||
some_mic_values <- random_mic(size = 100)
|
Reference in New Issue
Block a user