mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 00:02:38 +02:00
(v1.2.0.9008) ab_class improvement
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
% Please edit documentation in R/ab_class_selectors.R
|
||||
\name{antibiotic_class_selectors}
|
||||
\alias{antibiotic_class_selectors}
|
||||
\alias{ab_class}
|
||||
\alias{aminoglycosides}
|
||||
\alias{carbapenems}
|
||||
\alias{cephalosporins}
|
||||
@ -17,6 +18,8 @@
|
||||
\alias{tetracyclines}
|
||||
\title{Antibiotic class selectors}
|
||||
\usage{
|
||||
ab_class(ab_class)
|
||||
|
||||
aminoglycosides()
|
||||
|
||||
carbapenems()
|
||||
@ -43,6 +46,9 @@ penicillins()
|
||||
|
||||
tetracyclines()
|
||||
}
|
||||
\arguments{
|
||||
\item{ab_class}{an antimicrobial class, like \code{"carbapenems"}. The columns \code{group}, \code{atc_group1} and \code{atc_group2} of the \link{antibiotics} data set will be searched (case-insensitive) for this value.}
|
||||
}
|
||||
\description{
|
||||
Use these selection helpers inside any function that allows \href{https://tidyselect.r-lib.org/reference/language.html}{Tidyverse selections}, like \code{dplyr::select()} or \code{tidyr::pivot_longer()}. They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.
|
||||
}
|
||||
@ -58,16 +64,27 @@ if (require("dplyr")) {
|
||||
example_isolates \%>\%
|
||||
select(carbapenems())
|
||||
|
||||
|
||||
# this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
|
||||
example_isolates \%>\%
|
||||
select(mo, aminoglycosides())
|
||||
|
||||
# this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
|
||||
example_isolates \%>\%
|
||||
select(mo, ab_class("mycobact"))
|
||||
|
||||
|
||||
# get bug/drug combinations for only macrolides in Gram-positives:
|
||||
example_isolates \%>\%
|
||||
filter(mo_gramstain(mo) \%like\% "pos") \%>\%
|
||||
select(mo, macrolides()) \%>\%
|
||||
bug_drug_combinations() \%>\%
|
||||
format()
|
||||
|
||||
|
||||
data.frame(irrelevant = "value",
|
||||
J01CA01 = "S") \%>\% # ATC code of ampicillin
|
||||
select(penicillins()) # so the 'J01CA01' column is selected
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
\seealso{
|
||||
|
@ -192,7 +192,7 @@ mo_gramstain("E. coli") # returns "Gram negative"
|
||||
\dontrun{
|
||||
df$mo <- as.mo(df$microorganism_name)
|
||||
|
||||
# the select function of tidyverse is also supported:
|
||||
# the select function of the Tidyverse is also supported:
|
||||
library(dplyr)
|
||||
df$mo <- df \%>\%
|
||||
select(microorganism_name) \%>\%
|
||||
|
@ -4,10 +4,10 @@
|
||||
\alias{lifecycle}
|
||||
\title{Lifecycles of functions in the \code{AMR} package}
|
||||
\description{
|
||||
Functions in this \code{AMR} package are categorised using \href{https://www.tidyverse.org/lifecycle}{the lifecycle circle of the \code{tidyverse} as found on www.tidyverse.org/lifecycle}.
|
||||
Functions in this \code{AMR} package are categorised using \href{https://www.Tidyverse.org/lifecycle}{the lifecycle circle of the Tidyverse as found on www.tidyverse.org/lifecycle}.
|
||||
|
||||
\if{html}{\figure{lifecycle_tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
|
||||
This page contains a section for every lifecycle (with text borrowed from the aforementioned \code{tidyverse} website), so they can be used in the manual pages of the functions.
|
||||
\if{html}{\figure{lifecycle_Tidyverse.svg}{options: height=200px style=margin-bottom:5px} \cr}
|
||||
This page contains a section for every lifecycle (with text borrowed from the aforementioned Tidyverse website), so they can be used in the manual pages of the functions.
|
||||
}
|
||||
\section{Experimental lifecycle}{
|
||||
|
||||
|
@ -83,7 +83,7 @@ The function \code{\link[=resistance]{resistance()}} is equal to the function \c
|
||||
|
||||
\strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link[=first_isolate]{first_isolate()}} to determine them in your data set.
|
||||
|
||||
These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{count()}][AMR::count()] functions to count isolates. The function \code{\link[=susceptibility]{susceptibility()}} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can influence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (albeit being dependent on the \code{minimum} parameter).}
|
||||
These functions are not meant to count isolates, but to calculate the proportion of resistance/susceptibility. Use the \code{\link[AMR:count]{count()}} functions to count isolates. The function \code{\link[=susceptibility]{susceptibility()}} is essentially equal to \code{count_susceptible() / count_all()}. \emph{Low counts can influence the outcome - the \code{proportion} functions may camouflage this, since they only return the proportion (albeit being dependent on the \code{minimum} parameter).}
|
||||
|
||||
The function \code{\link[=proportion_df]{proportion_df()}} takes any variable from \code{data} that has an \code{\link{rsi}} class (created with \code{\link[=as.rsi]{as.rsi()}}) and calculates the proportions R, I and S. It also supports grouped variables. The function \code{\link[=rsi_df]{rsi_df()}} works exactly like \code{\link[=proportion_df]{proportion_df()}}, but adds the number of isolates.
|
||||
}
|
||||
|
Reference in New Issue
Block a user