mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 10:31:53 +02:00
(v1.6.0.9000) custom EUCAST rules
This commit is contained in:
43
man/custom_eucast_rules.Rd
Normal file
43
man/custom_eucast_rules.Rd
Normal file
@ -0,0 +1,43 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/custom_eucast_rules.R
|
||||
\name{custom_eucast_rules}
|
||||
\alias{custom_eucast_rules}
|
||||
\title{Create Custom EUCAST Rules}
|
||||
\usage{
|
||||
custom_eucast_rules(...)
|
||||
}
|
||||
\arguments{
|
||||
\item{...}{rules in formula notation, see \emph{Examples}}
|
||||
}
|
||||
\description{
|
||||
Create Custom EUCAST Rules
|
||||
}
|
||||
\details{
|
||||
This documentation page will be updated shortly. \strong{This function is experimental.}
|
||||
}
|
||||
\section{How it works}{
|
||||
|
||||
..
|
||||
|
||||
It is also possible to define antibiotic groups instead of single antibiotics. The following groups are allowed (case-insensitive): \code{aminoglycosides}, \code{aminopenicillins}, \code{betalactams}, \code{carbapenems}, \code{cephalosporins}, \code{cephalosporins_1st}, \code{cephalosporins_2nd}, \code{cephalosporins_3rd}, \code{cephalosporins_except_caz}, \code{fluoroquinolones}, \code{glycopeptides}, \code{glycopeptides_except_lipo}, \code{lincosamides}, \code{lipoglycopeptides}, \code{macrolides}, \code{oxazolidinones}, \code{penicillins}, \code{polymyxins}, \code{streptogramins}, \code{tetracyclines}, \code{tetracyclines_except_tgc} and \code{ureidopenicillins}.
|
||||
}
|
||||
|
||||
\section{Experimental Lifecycle}{
|
||||
|
||||
\if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \cr}
|
||||
The \link[=lifecycle]{lifecycle} of this function is \strong{experimental}. An experimental function is in early stages of development. The unlying code might be changing frequently. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions are only available in development versions of this \code{AMR} package and will thus not be included in releases that are submitted to CRAN, since such functions have not yet matured enough.
|
||||
}
|
||||
|
||||
\examples{
|
||||
x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||
eucast_rules(example_isolates,
|
||||
rules = "custom",
|
||||
custom_rules = x,
|
||||
info = FALSE)
|
||||
|
||||
# combine rule sets
|
||||
x2 <- c(x,
|
||||
custom_eucast_rules(TZP == "R" ~ carbapenems == "R"))
|
||||
x2
|
||||
}
|
@ -27,6 +27,7 @@ eucast_rules(
|
||||
version_expertrules = 3.2,
|
||||
ampc_cephalosporin_resistance = NA,
|
||||
only_rsi_columns = FALSE,
|
||||
custom_rules = NULL,
|
||||
...
|
||||
)
|
||||
|
||||
@ -39,7 +40,7 @@ eucast_dosage(ab, administration = "iv", version_breakpoints = 11)
|
||||
|
||||
\item{info}{a logical to indicate whether progress should be printed to the console, defaults to only print while in interactive sessions}
|
||||
|
||||
\item{rules}{a character vector that specifies which rules should be applied. Must be one or more of \code{"breakpoints"}, \code{"expert"}, \code{"other"}, \code{"all"}, and defaults to \code{c("breakpoints", "expert")}. The default value can be set to another value, e.g. using \code{options(AMR_eucastrules = "all")}.}
|
||||
\item{rules}{a character vector that specifies which rules should be applied. Must be one or more of \code{"breakpoints"}, \code{"expert"}, \code{"other"}, \code{"custom"}, \code{"all"}, and defaults to \code{c("breakpoints", "expert")}. The default value can be set to another value, e.g. using \code{options(AMR_eucastrules = "all")}. If using \code{"custom"}, be sure to fill in argument \code{custom_rules} too. Custom rules can be created with \code{\link[=custom_eucast_rules]{custom_eucast_rules()}}.}
|
||||
|
||||
\item{verbose}{a \link{logical} to turn Verbose mode on and off (default is off). In Verbose mode, the function does not apply rules to the data, but instead returns a data set in logbook form with extensive info about which rows and columns would be effected and in which way. Using Verbose mode takes a lot more time.}
|
||||
|
||||
@ -51,6 +52,8 @@ eucast_dosage(ab, administration = "iv", version_breakpoints = 11)
|
||||
|
||||
\item{only_rsi_columns}{a logical to indicate whether only antibiotic columns must be detected that were transformed to class \verb{<rsi>} (see \code{\link[=as.rsi]{as.rsi()}}) on beforehand (defaults to \code{FALSE})}
|
||||
|
||||
\item{custom_rules}{custom rules to apply, created with \code{\link[=custom_eucast_rules]{custom_eucast_rules()}}}
|
||||
|
||||
\item{...}{column name of an antibiotic, see section \emph{Antibiotics} below}
|
||||
|
||||
\item{ab}{any (vector of) text that can be coerced to a valid antibiotic code with \code{\link[=as.ab]{as.ab()}}}
|
||||
@ -70,6 +73,15 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
|
||||
\strong{Note:} When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.
|
||||
|
||||
The file containing all EUCAST rules is located here: \url{https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv}.
|
||||
\subsection{Custom Rules}{
|
||||
|
||||
Custom rules can be created using \code{\link[=custom_eucast_rules]{custom_eucast_rules()}}, e.g.:\preformatted{x <- custom_eucast_rules(AMC == "R" & genus == "Klebsiella" ~ aminopenicillins == "R",
|
||||
AMC == "I" & genus == "Klebsiella" ~ aminopenicillins == "I")
|
||||
|
||||
eucast_rules(example_isolates, rules = "custom", custom_rules = x)
|
||||
}
|
||||
}
|
||||
|
||||
\subsection{'Other' Rules}{
|
||||
|
||||
Before further processing, two non-EUCAST rules about drug combinations can be applied to improve the efficacy of the EUCAST rules, and the reliability of your data (analysis). These rules are:
|
||||
|
10
man/like.Rd
10
man/like.Rd
@ -4,9 +4,9 @@
|
||||
\alias{like}
|
||||
\alias{\%like\%}
|
||||
\alias{\%like_case\%}
|
||||
\title{Pattern Matching with Keyboard Shortcut}
|
||||
\title{Vectorised Pattern Matching with Keyboard Shortcut}
|
||||
\source{
|
||||
Idea from the \href{https://github.com/Rdatatable/data.table/blob/master/R/like.R}{\code{like} function from the \code{data.table} package}
|
||||
Idea from the \href{https://github.com/Rdatatable/data.table/blob/ec1259af1bf13fc0c96a1d3f9e84d55d8106a9a4/R/like.R}{\code{like} function from the \code{data.table} package}
|
||||
}
|
||||
\usage{
|
||||
like(x, pattern, ignore.case = TRUE)
|
||||
@ -23,7 +23,7 @@ x \%like_case\% pattern
|
||||
\item{ignore.case}{if \code{FALSE}, the pattern matching is \emph{case sensitive} and if \code{TRUE}, case is ignored during matching.}
|
||||
}
|
||||
\value{
|
||||
A \code{\link{logical}} vector
|
||||
A \link{logical} vector
|
||||
}
|
||||
\description{
|
||||
Convenient wrapper around \code{\link[=grepl]{grepl()}} to match a pattern: \code{x \%like\% pattern}. It always returns a \code{\link{logical}} vector and is always case-insensitive (use \code{x \%like_case\% pattern} for case-sensitive matching). Also, \code{pattern} can be as long as \code{x} to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.
|
||||
@ -34,7 +34,7 @@ The \verb{\%like\%} function:
|
||||
\item Is case-insensitive (use \verb{\%like_case\%} for case-sensitive matching)
|
||||
\item Supports multiple patterns
|
||||
\item Checks if \code{pattern} is a regular expression and sets \code{fixed = TRUE} if not, to greatly improve speed
|
||||
\item Always uses compatibility with Perl
|
||||
\item Always uses compatibility with Perl unless \code{fixed = TRUE}, to greatly improve speed
|
||||
}
|
||||
|
||||
Using RStudio? The text \verb{\%like\%} can also be directly inserted in your code from the Addins menu and can have its own Keyboard Shortcut like \code{Ctrl+Shift+L} or \code{Cmd+Shift+L} (see \code{Tools} > \verb{Modify Keyboard Shortcuts...}).
|
||||
@ -75,7 +75,7 @@ a \%like\% b[1]
|
||||
\donttest{
|
||||
if (require("dplyr")) {
|
||||
example_isolates \%>\%
|
||||
filter(mo_name(mo) \%like\% "^ent")
|
||||
filter(mo_name() \%like\% "^ent")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
15
man/mdro.Rd
15
man/mdro.Rd
@ -134,10 +134,19 @@ You can print the rules set in the console for an overview. Colours will help re
|
||||
#> Unmatched rows will return NA.
|
||||
}
|
||||
|
||||
The outcome of the function can be used for the \code{guideline} argument in the \code{\link[=mdro]{mdro()}} function:\preformatted{x <- mdro(example_isolates, guideline = custom)
|
||||
The outcome of the function can be used for the \code{guideline} argument in the \code{\link[=mdro]{mdro()}} function:\preformatted{x <- mdro(example_isolates,
|
||||
guideline = custom)
|
||||
table(x)
|
||||
#> Elderly Type A Elderly Type B Negative
|
||||
#> 43 891 1066
|
||||
#> Negative Elderly Type A Elderly Type B
|
||||
#> 1070 198 732
|
||||
}
|
||||
|
||||
Rules can also be combined with other custom rules by using \code{\link[=c]{c()}}:\preformatted{x <- mdro(example_isolates,
|
||||
guideline = c(custom,
|
||||
custom_mdro_guideline(ERY == "R" & age > 50 ~ "Elderly Type C")))
|
||||
table(x)
|
||||
#> Negative Elderly Type A Elderly Type B Elderly Type C
|
||||
#> 961 198 732 109
|
||||
}
|
||||
|
||||
The rules set (the \code{custom} object in this case) could be exported to a shared file location using \code{\link[=saveRDS]{saveRDS()}} if you collaborate with multiple users. The custom rules set could then be imported using \code{\link[=readRDS]{readRDS()}}.
|
||||
|
@ -83,6 +83,7 @@
|
||||
xlab = "Antimicrobial Interpretation",
|
||||
ylab = "Frequency",
|
||||
colours_RSI = c("#ED553B", "#3CAEA3", "#F6D55C"),
|
||||
language = get_locale(),
|
||||
...
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user