1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-26 18:06:11 +01:00
AMR/man/first_isolate.Rd

156 lines
6.9 KiB
Plaintext
Raw Normal View History

2018-02-21 11:52:31 +01:00
% Generated by roxygen2: do not edit by hand
2018-07-23 14:14:03 +02:00
% Please edit documentation in R/first_isolate.R
2018-02-21 11:52:31 +01:00
\name{first_isolate}
\alias{first_isolate}
\title{Determine first (weighted) isolates}
2018-04-20 13:45:34 +02:00
\source{
2018-07-29 22:14:51 +02:00
Methodology of this function is 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/}.
2018-04-20 13:45:34 +02:00
}
2018-02-21 11:52:31 +01:00
\usage{
2018-08-31 13:36:19 +02:00
first_isolate(tbl, col_date, col_patient_id, col_mo = NA,
col_testcode = NA, col_specimen = NA, col_icu = NA,
2018-08-11 21:30:00 +02:00
col_keyantibiotics = NA, episode_days = 365,
testcodes_exclude = "", icu_exclude = FALSE, filter_specimen = NA,
output_logical = TRUE, type = "keyantibiotics", ignore_I = TRUE,
2018-08-31 13:36:19 +02:00
points_threshold = 2, info = TRUE, col_bactid = NA,
col_genus = NA, col_species = NA)
2018-02-21 11:52:31 +01:00
}
\arguments{
\item{tbl}{a \code{data.frame} containing isolates.}
2018-04-02 11:11:21 +02:00
\item{col_date}{column name of the result date (or date that is was received on the lab)}
2018-02-21 11:52:31 +01:00
2018-04-02 11:11:21 +02:00
\item{col_patient_id}{column name of the unique IDs of the patients}
2018-02-21 11:52:31 +01:00
2018-08-31 13:36:19 +02:00
\item{col_mo}{column name of the unique IDs of the microorganisms, see \code{\link{mo}}. If this column has another class than \code{"mo"}, values will be coerced using \code{\link{as.mo}}.}
2018-02-21 11:52:31 +01:00
\item{col_testcode}{column name of the test codes. Use \code{col_testcode = NA} to \strong{not} exclude certain test codes (like test codes for screening). In that case \code{testcodes_exclude} will be ignored. Supports tidyverse-like quotation.}
2018-02-21 11:52:31 +01:00
2018-04-02 11:11:21 +02:00
\item{col_specimen}{column name of the specimen type or group}
2018-02-21 11:52:31 +01:00
2018-04-02 11:11:21 +02:00
\item{col_icu}{column name of the logicals (\code{TRUE}/\code{FALSE}) whether a ward or department is an Intensive Care Unit (ICU)}
2018-02-21 11:52:31 +01:00
\item{col_keyantibiotics}{column name of the key antibiotics to determine first \emph{weighted} isolates, see \code{\link{key_antibiotics}}. Supports tidyverse-like quotation.}
2018-02-21 11:52:31 +01:00
\item{episode_days}{episode in days after which a genus/species combination will be determined as 'first isolate' again}
\item{testcodes_exclude}{character vector with test codes that should be excluded (case-insensitive)}
2018-02-21 11:52:31 +01:00
\item{icu_exclude}{logical whether ICU isolates should be excluded}
\item{filter_specimen}{specimen group or type that should be excluded}
\item{output_logical}{return output as \code{logical} (will else be the values \code{0} or \code{1})}
2018-02-21 11:52:31 +01:00
\item{type}{type to determine weighed isolates; can be \code{"keyantibiotics"} or \code{"points"}, see Details}
\item{ignore_I}{logical to determine whether antibiotic interpretations with \code{"I"} will be ignored when \code{type = "keyantibiotics"}, see Details}
\item{points_threshold}{points until the comparison of key antibiotics will lead to inclusion of an isolate when \code{type = "points"}, see Details}
2018-02-21 11:52:31 +01:00
\item{info}{print progress}
2018-08-31 13:36:19 +02:00
\item{col_bactid}{(deprecated, use \code{col_mo} instead)}
2018-08-31 13:36:19 +02:00
\item{col_genus}{(deprecated, use \code{col_mo} instead) column name of the genus of the microorganisms}
\item{col_species}{(deprecated, use \code{col_mo} instead) column name of the species of the microorganisms}
2018-02-21 11:52:31 +01:00
}
\value{
A vector to add to table, see Examples.
}
\description{
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type.
}
\details{
\strong{WHY THIS IS SO IMPORTANT} \cr
2018-02-27 20:01:02 +01:00
To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode \href{https://www.ncbi.nlm.nih.gov/pubmed/17304462}{[1]}. If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all \emph{S. aureus} isolates would be overestimated, because you included this MRSA more than once. It would be \href{https://en.wikipedia.org/wiki/Selection_bias}{selection bias}.
2018-07-17 13:02:05 +02:00
}
\section{Key antibiotics}{
There are two ways to determine whether isolates can be included as first \emph{weighted} isolates which will give generally the same results: \cr
2018-03-13 11:57:30 +01:00
2018-03-19 21:23:21 +01:00
\strong{1. Using} \code{type = "keyantibiotics"} \strong{and parameter} \code{ignore_I} \cr
2018-07-17 13:02:05 +02:00
Any difference from S to R (or vice versa) will (re)select an isolate as a first weighted isolate. With \code{ignore_I = FALSE}, also differences from I to S|R (or vice versa) will lead to this. This is a reliable method and 30-35 times faster than method 2. \cr
2018-03-19 21:23:21 +01:00
\strong{2. Using} \code{type = "points"} \strong{and parameter} \code{points_threshold} \cr
2018-07-17 13:02:05 +02:00
A difference from I to S|R (or vice versa) means 0.5 points, a difference from S to R (or vice versa) means 1 point. When the sum of points exceeds \code{points_threshold}, an isolate will be (re)selected as a first weighted isolate.
2018-02-21 11:52:31 +01:00
}
2018-07-17 13:02:05 +02:00
2018-02-21 11:52:31 +01:00
\examples{
# septic_patients is a dataset available in the AMR package. It is true, genuine data.
?septic_patients
library(dplyr)
2018-08-10 15:01:05 +02:00
my_patients <- septic_patients \%>\%
mutate(first_isolate = first_isolate(.,
col_date = "date",
col_patient_id = "patient_id",
2018-08-31 13:36:19 +02:00
col_mo = "mo"))
2018-04-02 11:11:21 +02:00
# Now let's see if first isolates matter:
A <- my_patients \%>\%
group_by(hospital_id) \%>\%
2018-08-10 15:01:05 +02:00
summarise(count = n_rsi(gent), # gentamicin availability
resistance = portion_IR(gent)) # gentamicin resistance
B <- my_patients \%>\%
2018-08-10 15:01:05 +02:00
filter(first_isolate == TRUE) \%>\% # the 1st isolate filter
group_by(hospital_id) \%>\%
2018-08-10 15:01:05 +02:00
summarise(count = n_rsi(gent), # gentamicin availability
resistance = portion_IR(gent)) # gentamicin resistance
2018-08-10 15:01:05 +02:00
# Have a look at A and B.
# B is more reliable because every isolate is only counted once.
# Gentamicin resitance in hospital D appears to be 5.4\% higher than
# when you (erroneously) would have used all isolates!
## OTHER EXAMPLES:
2018-02-21 11:52:31 +01:00
\dontrun{
2018-02-22 20:48:48 +01:00
# set key antibiotics to a new variable
2018-02-21 11:52:31 +01:00
tbl$keyab <- key_antibiotics(tbl)
tbl$first_isolate <-
first_isolate(tbl)
tbl$first_isolate_weighed <-
first_isolate(tbl,
col_keyantibiotics = 'keyab')
tbl$first_blood_isolate <-
first_isolate(tbl,
filter_specimen = 'Blood')
tbl$first_blood_isolate_weighed <-
first_isolate(tbl,
filter_specimen = 'Blood',
col_keyantibiotics = 'keyab')
tbl$first_urine_isolate <-
first_isolate(tbl,
filter_specimen = 'Urine')
tbl$first_urine_isolate_weighed <-
first_isolate(tbl,
filter_specimen = 'Urine',
col_keyantibiotics = 'keyab')
tbl$first_resp_isolate <-
first_isolate(tbl,
filter_specimen = 'Respiratory')
tbl$first_resp_isolate_weighed <-
first_isolate(tbl,
filter_specimen = 'Respiratory',
col_keyantibiotics = 'keyab')
}
}
2018-07-17 13:02:05 +02:00
\seealso{
2018-07-17 14:48:11 +02:00
\code{\link{key_antibiotics}}
2018-07-17 13:02:05 +02:00
}
2018-02-21 11:52:31 +01:00
\keyword{first}
\keyword{isolate}
\keyword{isolates}