1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-10 07:41:57 +02:00

(v1.6.0.9013) website update

This commit is contained in:
2021-04-29 17:16:30 +02:00
parent 5e06b20d43
commit a9fd4aa49f
41 changed files with 931 additions and 842 deletions

View File

@ -3,12 +3,21 @@
\name{AMR-deprecated}
\alias{AMR-deprecated}
\alias{p_symbol}
\alias{filter_first_weighted_isolate}
\alias{key_antibiotics}
\alias{key_antibiotics_equal}
\title{Deprecated Functions}
\usage{
p_symbol(p, emptychar = " ")
filter_first_weighted_isolate(
x = NULL,
col_date = NULL,
col_patient_id = NULL,
col_mo = NULL,
...
)
key_antibiotics(
x = NULL,
col_mo = NULL,

View File

@ -3,12 +3,13 @@
\name{first_isolate}
\alias{first_isolate}
\alias{filter_first_isolate}
\alias{filter_first_weighted_isolate}
\title{Determine First (Weighted) Isolates}
\source{
Methodology of this function is strictly based on:
\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/}.
\itemize{
\item \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/}.
\item Hindler JF and Stelling J (2007). \strong{Analysis and Presentation of Cumulative Antibiograms: A New Consensus Guideline from the Clinical and Laboratory Standards Institute.} Clinical Infectious Diseases, 44(6), 867873. \doi{10.1086/511864}
}
}
\usage{
first_isolate(
@ -39,16 +40,8 @@ filter_first_isolate(
col_date = NULL,
col_patient_id = NULL,
col_mo = NULL,
method = "episode-based",
...
)
filter_first_weighted_isolate(
x = NULL,
col_date = NULL,
col_patient_id = NULL,
col_mo = NULL,
method = "phenotype-based",
episode_days = 365,
method = c("phenotype-based", "episode-based", "patient-based", "isolate-based"),
...
)
}
@ -79,7 +72,7 @@ filter_first_weighted_isolate(
\item{type}{type to determine weighed isolates; can be \code{"keyantimicrobials"} or \code{"points"}, see \emph{Details}}
\item{method}{the algorithm to apply, either \code{"phenotype-based"}, \code{"episode-based"}, \code{"patient-based"} or \code{"isolate-based"} (can be abbreviated), see \emph{Details}}
\item{method}{the method to apply, either \code{"phenotype-based"}, \code{"episode-based"}, \code{"patient-based"} or \code{"isolate-based"} (can be abbreviated), see \emph{Details}. The default is \code{"phenotype-based"} if antimicrobial test results are present in the data, and \code{"episode-based"} otherwise.}
\item{ignore_I}{logical to indicate whether antibiotic interpretations with \code{"I"} will be ignored when \code{type = "keyantimicrobials"}, see \emph{Details}}
@ -91,43 +84,43 @@ filter_first_weighted_isolate(
\item{include_untested_rsi}{logical to indicate whether also rows without antibiotic results are still eligible for becoming a first isolate. Use \code{include_untested_rsi = FALSE} to always return \code{FALSE} for such rows. This checks the data set for columns of class \verb{<rsi>} and consequently requires transforming columns with antibiotic results using \code{\link[=as.rsi]{as.rsi()}} first.}
\item{...}{arguments passed on to \code{\link[=first_isolate]{first_isolate()}} when using \code{\link[=filter_first_isolate]{filter_first_isolate()}}, or arguments passed on to \code{\link[=key_antimicrobials]{key_antimicrobials()}} otherwise (such as \code{universal}, \code{gram_negative}, \code{gram_positive})}
\item{...}{arguments passed on to \code{\link[=first_isolate]{first_isolate()}} when using \code{\link[=filter_first_isolate]{filter_first_isolate()}}, otherwise arguments passed on to \code{\link[=key_antimicrobials]{key_antimicrobials()}} (such as \code{universal}, \code{gram_negative}, \code{gram_positive})}
}
\value{
A \code{\link{logical}} vector
}
\description{
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. To determine patient episodes not necessarily based on microorganisms, use \code{\link[=is_new_episode]{is_new_episode()}} that also supports grouping with the \code{dplyr} package.
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type. These functions support all four methods as summarised by Hindler \emph{et al.} in 2007 (\doi{10.1086/511864}). To determine patient episodes not necessarily based on microorganisms, use \code{\link[=is_new_episode]{is_new_episode()}} that also supports grouping with the \code{dplyr} package.
}
\details{
To conduct epidemiological analyses on antimicrobial resistance data, only so-called first isolates should be included to prevent overestimation and underestimation of antimicrobial resistance. Different algorithms can be used to do so, see below.
To conduct epidemiological analyses on antimicrobial resistance data, only so-called first isolates should be included to prevent overestimation and underestimation of antimicrobial resistance. Different methods can be used to do so, see below.
These functions are context-aware. This means that then the \code{x} argument can be left blank, see \emph{Examples}.
The \code{\link[=first_isolate]{first_isolate()}} function is a wrapper around the \code{\link[=is_new_episode]{is_new_episode()}} function, but more efficient for data sets containing microorganism codes or names.
All isolates with a microbial ID of \code{NA} will be excluded as first isolate.
\subsection{Different algorithms}{
\subsection{Different methods}{
According to Hindler \emph{et al.} (2007, \doi{10.1086/511864}), there are different algorithms to select first isolates with increasing reliability: isolate-based, patient-based, episode-based and phenotype-based. All algorithms select on a combination of the taxonomic genus and species (not subspecies).
According to Hindler \emph{et al.} (2007, \doi{10.1086/511864}), there are different methods (algorithms) to select first isolates with increasing reliability: isolate-based, patient-based, episode-based and phenotype-based. All methods select on a combination of the taxonomic genus and species (not subspecies).
All mentioned algorithms are covered in the \code{\link[=first_isolate]{first_isolate()}} function:\tabular{ll}{
\strong{Algorithm} \tab \strong{Function to apply} \cr
Isolate-based \tab \code{first_isolate(x, method = "isolate-based")} \cr
All mentioned methods are covered in the \code{\link[=first_isolate]{first_isolate()}} function:\tabular{ll}{
\strong{Method} \tab \strong{Function to apply} \cr
\strong{Isolate-based} \tab \code{first_isolate(x, method = "isolate-based")} \cr
\emph{(= all isolates)} \tab \cr
\tab \cr
\tab \cr
Patient-based \tab \code{first_isolate(x, method = "patient-based")} \cr
\strong{Patient-based} \tab \code{first_isolate(x, method = "patient-based")} \cr
\emph{(= first isolate per patient)} \tab \cr
\tab \cr
\tab \cr
Episode-based \tab \code{first_isolate(x, method = "episode-based")}, or: \cr
\strong{Episode-based} \tab \code{first_isolate(x, method = "episode-based")}, or: \cr
\emph{(= first isolate per episode)} \tab \cr
- 7-Day interval from initial isolate \tab - \code{first_isolate(x, method = "e", episode_days = 7)} \cr
- 30-Day interval from initial isolate \tab - \code{first_isolate(x, method = "e", episode_days = 30)} \cr
\tab \cr
\tab \cr
Phenotype-based \tab \code{first_isolate(x, method = "phenotype-based")}, or: \cr
\strong{Phenotype-based} \tab \code{first_isolate(x, method = "phenotype-based")}, or: \cr
\emph{(= first isolate per phenotype)} \tab \cr
- Major difference in any antimicrobial result \tab - \code{first_isolate(x, type = "points")} \cr
- Any difference in key antimicrobial results \tab - \code{first_isolate(x, type = "keyantimicrobials")} \cr
@ -135,24 +128,24 @@ All mentioned algorithms are covered in the \code{\link[=first_isolate]{first_is
\subsection{Isolate-based}{
This algorithm does not require any selection, as all isolates should be included. It does, however, respect all arguments set in the \code{\link[=first_isolate]{first_isolate()}} function. For example, the default setting for \code{include_unknown} (\code{FALSE}) will omit selection of rows without a microbial ID.
This method does not require any selection, as all isolates should be included. It does, however, respect all arguments set in the \code{\link[=first_isolate]{first_isolate()}} function. For example, the default setting for \code{include_unknown} (\code{FALSE}) will omit selection of rows without a microbial ID.
}
\subsection{Patient-based}{
To include every genus-species combination per patient once, set the \code{episode_days} to \code{Inf}. Although often inappropriate, this algorithm makes sure that no duplicate isolates are selected from the same patient.
To include every genus-species combination per patient once, set the \code{episode_days} to \code{Inf}. Although often inappropriate, this method makes sure that no duplicate isolates are selected from the same patient. In a large longitudinal data set, this could mean that isolates are \emph{excluded} that were found years after the initial isolate.
}
\subsection{Episode-based}{
To include every genus-species combination per patient episode once, set the \code{episode_days} to a sensible number of days. Depending on the type of analysis, this could be 14, 30, 60 or 365. Short episodes are common for analysing specific hospital or ward data, long episodes are common for analysing regional and national data.
This is the most common algorithm to correct for duplicate isolates. Patients are categorised into episodes based on their ID and dates (e.g., the date of specimen receipt or laboratory result). While this is a common algorithm, it does not take into account antimicrobial test results. This means that e.g. a methicillin-resistant \emph{Staphylococcus aureus} (MRSA) isolate cannot be differentiated from a wildtype \emph{Staphylococcus aureus} isolate.
This is the most common method to correct for duplicate isolates. Patients are categorised into episodes based on their ID and dates (e.g., the date of specimen receipt or laboratory result). While this is a common method, it does not take into account antimicrobial test results. This means that e.g. a methicillin-resistant \emph{Staphylococcus aureus} (MRSA) isolate cannot be differentiated from a wildtype \emph{Staphylococcus aureus} isolate.
}
\subsection{Phenotype-based}{
This is a more reliable algorithm, since it also \emph{weighs} the antibiogram (antimicrobial test results) yielding so-called 'first weighted isolates'. There are two different methods to weigh the antibiogram:
This is a more reliable method, since it also \emph{weighs} the antibiogram (antimicrobial test results) yielding so-called 'first weighted isolates'. There are two different methods to weigh the antibiogram:
\enumerate{
\item Using \code{type = "points"} and argument \code{points_threshold}
@ -166,7 +159,7 @@ This method only weighs specific antimicrobial agents, called \emph{key antimicr
Key antimicrobials are internally selected using the \code{\link[=key_antimicrobials]{key_antimicrobials()}} function, but can also be added manually as a variable to the data and set in the \code{col_keyantimicrobials} argument. Another option is to pass the output of the \code{\link[=key_antimicrobials]{key_antimicrobials()}} function directly to the \code{col_keyantimicrobials} argument.
}
The default algorithm is phenotype-based (using \code{type = "points"}) and episode-based (using \code{episode_days = 365}). This makes sure that every genus-species combination is selected per patient once per year, while taking into account all antimicrobial test results.
The default method is phenotype-based (using \code{type = "points"}) and episode-based (using \code{episode_days = 365}). This makes sure that every genus-species combination is selected per patient once per year, while taking into account all antimicrobial test results. If no antimicrobial test results are available in the data set, only the episode-based method is applied at default.
}
}
@ -201,11 +194,9 @@ if (require("dplyr")) {
example_isolates \%>\%
filter(first_isolate())
# short-hand versions:
# short-hand version:
example_isolates \%>\%
filter_first_isolate()
example_isolates \%>\%
filter_first_weighted_isolate()
# grouped determination of first isolates (also prints group names):
example_isolates \%>\%
@ -219,7 +210,7 @@ if (require("dplyr")) {
resistance = resistance(GEN)) # gentamicin resistance
B <- example_isolates \%>\%
filter_first_weighted_isolate() \%>\% # the 1st isolate filter
filter_first_isolate() \%>\% # the 1st isolate filter
group_by(hospital_id) \%>\%
summarise(count = n_rsi(GEN), # gentamicin availability
resistance = resistance(GEN)) # gentamicin resistance

View File

@ -14,7 +14,7 @@ is_new_episode(x, episode_days, ...)
\item{episode_days}{required episode length in days, can also be less than a day or \code{Inf}, see \emph{Details}}
\item{...}{currently not used}
\item{...}{ignored, only in place to allow future extensions}
}
\value{
\itemize{
@ -28,9 +28,9 @@ These functions determine which items in a vector can be considered (the start o
\details{
Dates are first sorted from old to new. The oldest date will mark the start of the first episode. After this date, the next date will be marked that is at least \code{episode_days} days later than the start of the first episode. From that second marked date on, the next date will be marked that is at least \code{episode_days} days later than the start of the second episode which will be the start of the third episode, and so on. Before the vector is being returned, the original order will be restored.
The \code{\link[=first_isolate]{first_isolate()}} function is a wrapper around the \code{\link[=is_new_episode]{is_new_episode()}} function, but is more efficient for data sets containing microorganism codes or names.
The \code{\link[=first_isolate]{first_isolate()}} function is a wrapper around the \code{\link[=is_new_episode]{is_new_episode()}} function, but is more efficient for data sets containing microorganism codes or names and allows for different isolate selection methods.
The \code{dplyr} package is not required for these functions to work, but these functions support \link[dplyr:group_by]{variable grouping} and work conveniently inside \code{dplyr} verbs such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.
The \code{dplyr} package is not required for these functions to work, but these functions do support \link[dplyr:group_by]{variable grouping} and work conveniently inside \code{dplyr} verbs such as \code{\link[dplyr:filter]{filter()}}, \code{\link[dplyr:mutate]{mutate()}} and \code{\link[dplyr:summarise]{summarise()}}.
}
\section{Stable Lifecycle}{
@ -87,8 +87,8 @@ if (require("dplyr")) {
n_episodes_30 = sum(is_new_episode(date, episode_days = 30)))
# grouping on patients and microorganisms leads to the same results
# as first_isolate():
# grouping on patients and microorganisms leads to the same
# results as first_isolate() when using 'episode-based':
x <- example_isolates \%>\%
filter_first_isolate(include_unknown = TRUE,
method = "episode-based")

View File

@ -100,7 +100,7 @@ ggplot_pca(
\item{base_textsize}{the text size for all plot elements except the labels and arrows}
\item{...}{Arguments passed on to functions}
\item{...}{arguments passed on to functions}
}
\description{
Produces a \code{ggplot2} variant of a so-called \href{https://en.wikipedia.org/wiki/Biplot}{biplot} for PCA (principal component analysis), but is more flexible and more appealing than the base \R \code{\link[=biplot]{biplot()}} function.

View File

@ -30,7 +30,7 @@ anti_join_microorganisms(x, by = NULL, ...)
\item{suffix}{if there are non-joined duplicate variables in \code{x} and \code{y}, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2.}
\item{...}{ignored}
\item{...}{ignored, only in place to allow future extensions}
}
\description{
Join the data set \link{microorganisms} easily to an existing table or character vector.

View File

@ -29,7 +29,6 @@ antimicrobials_equal(
type = c("points", "keyantimicrobials"),
ignore_I = TRUE,
points_threshold = 2,
info = FALSE,
...
)
}
@ -48,7 +47,7 @@ antimicrobials_equal(
\item{only_rsi_columns}{a logical to indicate whether only columns must be included that were transformed to class \verb{<rsi>} (see \code{\link[=as.rsi]{as.rsi()}}) on beforehand (defaults to \code{FALSE})}
\item{...}{ignored, allows for future extensions}
\item{...}{ignored, only in place to allow future extensions}
\item{y, z}{character vectors to compare}
@ -57,8 +56,6 @@ antimicrobials_equal(
\item{ignore_I}{logical to indicate whether antibiotic interpretations with \code{"I"} will be ignored when \code{type = "keyantimicrobials"}, see \emph{Details}}
\item{points_threshold}{minimum number of points to require before differences in the antibiogram will lead to inclusion of an isolate when \code{type = "points"}, see \emph{Details}}
\item{info}{unused - previously used to indicate whether a progress bar should print}
}
\description{
These functions can be used to determine first weighted isolates by considering the phenotype for isolate selection (see \code{\link[=first_isolate]{first_isolate()}}). Using a phenotype-based method to determine first isolates is more reliable than methods that disregard phenotypes.

View File

@ -20,7 +20,7 @@ random_rsi(size, prob_RSI = c(0.33, 0.33, 0.33), ...)
\item{ab}{any character that can be coerced to a valid antimicrobial agent code with \code{\link[=as.ab]{as.ab()}}}
\item{...}{extension for future versions, not used at the moment}
\item{...}{ignored, only in place to allow future extensions}
\item{prob_RSI}{a vector of length 3: the probabilities for R (1st value), S (2nd value) and I (3rd value)}
}