1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-09 08:11:58 +02:00

(v0.7.0.9008) T. vaginalis, rsi_df

This commit is contained in:
2019-06-13 14:28:46 +02:00
parent 699e87ab4a
commit 254745061c
32 changed files with 382 additions and 259 deletions

View File

@ -58,9 +58,11 @@ These functions can be used to count resistant/susceptible microbial isolates. A
\details{
These functions are meant to count isolates. Use the \code{\link{portion}_*} functions to calculate microbial resistance.
\code{n_rsi} is an alias of \code{count_all}. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to \code{\link{n_distinct}}. Their function is equal to \code{count_S(...) + count_IR(...)}.
The function \code{n_rsi} is an alias of \code{count_all}. They can be used to count all available isolates, i.e. where all input antibiotics have an available result (S, I or R). Their use is equal to \code{\link{n_distinct}}. Their function is equal to \code{count_S(...) + count_IR(...)}.
\code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the amounts of R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}.
The function \code{count_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and counts the amounts of S, I and R. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}.
The function \code{rsi_df} works exactly like \code{count_df}, but add the percentage of S, I and R.
}
\section{Interpretation of S, I and R}{

View File

@ -10,8 +10,8 @@
\alias{labels_rsi_count}
\title{AMR plots with \code{ggplot2}}
\usage{
ggplot_rsi(data, position = NULL, x = "Antibiotic",
fill = "Interpretation", facet = NULL, breaks = seq(0, 1, 0.1),
ggplot_rsi(data, position = NULL, x = "antibiotic",
fill = "interpretation", facet = NULL, breaks = seq(0, 1, 0.1),
limits = NULL, translate_ab = "name", combine_SI = TRUE,
combine_IR = FALSE, language = get_locale(), fun = count_df,
nrow = NULL, colours = c(S = "#61a8ff", SI = "#61a8ff", I =
@ -20,12 +20,12 @@ ggplot_rsi(data, position = NULL, x = "Antibiotic",
subtitle = NULL, caption = NULL, x.title = NULL, y.title = NULL,
...)
geom_rsi(position = NULL, x = c("Antibiotic", "Interpretation"),
fill = "Interpretation", translate_ab = "name",
geom_rsi(position = NULL, x = c("antibiotic", "interpretation"),
fill = "interpretation", translate_ab = "name",
language = get_locale(), combine_SI = TRUE, combine_IR = FALSE,
fun = count_df, ...)
facet_rsi(facet = c("Interpretation", "Antibiotic"), nrow = NULL)
facet_rsi(facet = c("interpretation", "antibiotic"), nrow = NULL)
scale_y_percent(breaks = seq(0, 1, 0.1), limits = NULL)
@ -34,7 +34,7 @@ scale_rsi_colours(colours = c(S = "#61a8ff", SI = "#61a8ff", I =
theme_rsi()
labels_rsi_count(position = NULL, x = "Antibiotic",
labels_rsi_count(position = NULL, x = "antibiotic",
translate_ab = "name", combine_SI = TRUE, combine_IR = FALSE,
datalabels.size = 3, datalabels.colour = "gray15")
}
@ -43,11 +43,11 @@ labels_rsi_count(position = NULL, x = "Antibiotic",
\item{position}{position adjustment of bars, either \code{"fill"} (default when \code{fun} is \code{\link{count_df}}), \code{"stack"} (default when \code{fun} is \code{\link{portion_df}}) or \code{"dodge"}}
\item{x}{variable to show on x axis, either \code{"Antibiotic"} (default) or \code{"Interpretation"} or a grouping variable}
\item{x}{variable to show on x axis, either \code{"antibiotic"} (default) or \code{"interpretation"} or a grouping variable}
\item{fill}{variable to categorise using the plots legend, either \code{"Antibiotic"} (default) or \code{"Interpretation"} or a grouping variable}
\item{fill}{variable to categorise using the plots legend, either \code{"antibiotic"} (default) or \code{"interpretation"} or a grouping variable}
\item{facet}{variable to split plots by, either \code{"Interpretation"} (default) or \code{"Antibiotic"} or a grouping variable}
\item{facet}{variable to split plots by, either \code{"interpretation"} (default) or \code{"antibiotic"} or a grouping variable}
\item{breaks}{numeric vector of positions}
@ -178,7 +178,7 @@ septic_patients \%>\%
select(hospital_id, AMX, NIT, FOS, TMP, CIP) \%>\%
group_by(hospital_id) \%>\%
ggplot_rsi(x = "hospital_id",
facet = "Antibiotic",
facet = "antibiotic",
nrow = 1,
title = "AMR of Anti-UTI Drugs Per Hospital",
x.title = "Hospital",
@ -199,7 +199,7 @@ septic_patients \%>\%
# group by MO
group_by(bug) \%>\%
# plot the thing, putting MOs on the facet
ggplot_rsi(x = "Antibiotic",
ggplot_rsi(x = "antibiotic",
facet = "bug",
translate_ab = FALSE,
nrow = 1,

View File

@ -4,7 +4,7 @@
\name{microorganisms}
\alias{microorganisms}
\title{Data set with ~65,000 microorganisms}
\format{A \code{\link{data.frame}} with 67,903 observations and 16 variables:
\format{A \code{\link{data.frame}} with 67,906 observations and 16 variables:
\describe{
\item{\code{mo}}{ID of microorganism as used by this package}
\item{\code{col_id}}{Catalogue of Life ID}
@ -30,9 +30,10 @@ A data set containing the microbial taxonomy of six kingdoms from the Catalogue
\details{
Manually added were:
\itemize{
\item{9 species of \emph{Streptococcus} (beta haemolytic groups A, B, C, D, F, G, H, K and unspecified)}
\item{2 species of \emph{Staphylococcus} (coagulase-negative [CoNS] and coagulase-positive [CoPS])}
\item{3 other undefined (unknown, unknown Gram negatives and unknown Gram positives)}
\item{9 entries of \emph{Streptococcus} (beta haemolytic groups A, B, C, D, F, G, H, K and unspecified)}
\item{2 entries of \emph{Staphylococcus} (coagulase-negative [CoNS] and coagulase-positive [CoPS])}
\item{3 entries of Trichomonas (Trichomonas vaginalis, and its family and genus)}
\item{3 other 'undefined' entries (unknown, unknown Gram negatives and unknown Gram positives)}
\item{8,830 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) that are not in the Catalogue of Life}
}
}

View File

@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/portion.R
% Please edit documentation in R/portion.R, R/rsi_df.R
\name{portion}
\alias{portion}
\alias{portion_R}
@ -8,6 +8,7 @@
\alias{portion_SI}
\alias{portion_S}
\alias{portion_df}
\alias{rsi_df}
\title{Calculate resistance of isolates}
\source{
\strong{M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition}, 2014, \emph{Clinical and Laboratory Standards Institute (CLSI)}. \url{https://clsi.org/standards/products/microbiology/documents/m39/}.
@ -33,6 +34,10 @@ portion_S(..., minimum = 30, as_percent = FALSE,
portion_df(data, translate_ab = "name", language = get_locale(),
minimum = 30, as_percent = FALSE, combine_SI = TRUE,
combine_IR = FALSE)
rsi_df(data, translate_ab = "name", language = get_locale(),
minimum = 30, as_percent = FALSE, combine_SI = TRUE,
combine_IR = FALSE)
}
\arguments{
\item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed. Use multiple columns to calculate (the lack of) co-resistance: the probability where one of two drugs have a resistant or susceptible result. See Examples.}
@ -66,7 +71,9 @@ These functions can be used to calculate the (co-)resistance of microbial isolat
These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. \emph{Low counts can infuence the outcome - these \code{portion} functions may camouflage this, since they only return the portion albeit being dependent on the \code{minimum} parameter.}
\code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each variable with class \code{"rsi"}.
The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
The function \code{rsi_df} works exactly like \code{portion_df}, but add the number of isolates.
\if{html}{
\cr\cr
To calculate the probability (\emph{p}) of susceptibility of one antibiotic, we use this formula: