mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 21:42:01 +02:00
added septic_patients
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
first_isolate(tbl, col_date, col_patient_id, col_genus, col_species,
|
||||
col_testcode = NA, col_specimen, col_icu, col_keyantibiotics = NA,
|
||||
episode_days = 365, testcodes_exclude = "", icu_exclude = FALSE,
|
||||
filter_specimen = NA, output_logical = TRUE, ignore_I = TRUE,
|
||||
filter_specimen = NA, output_logical = TRUE, points_threshold = 2,
|
||||
info = TRUE)
|
||||
}
|
||||
\arguments{
|
||||
@ -21,7 +21,7 @@ first_isolate(tbl, col_date, col_patient_id, col_genus, col_species,
|
||||
|
||||
\item{col_species}{column name of the species of the microorganisms}
|
||||
|
||||
\item{col_testcode}{column name of the test codes, see Details}
|
||||
\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.}
|
||||
|
||||
\item{col_specimen}{column name of the specimen type or group}
|
||||
|
||||
@ -39,7 +39,7 @@ first_isolate(tbl, col_date, col_patient_id, col_genus, col_species,
|
||||
|
||||
\item{output_logical}{return output as \code{logical} (will else the values \code{0} or \code{1})}
|
||||
|
||||
\item{ignore_I}{ignore \code{"I"} as antimicrobial interpretation of key antibiotics (with \code{FALSE}, changes in antibiograms from S to I and I to R will be interpreted as difference)}
|
||||
\item{points_threshold}{points until the comparison of key antibiotics will lead to inclusion of an isolate, see Details}
|
||||
|
||||
\item{info}{print progress}
|
||||
}
|
||||
@ -50,9 +50,10 @@ A vector to add to table, see Examples.
|
||||
Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type.
|
||||
}
|
||||
\details{
|
||||
To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode. 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 is 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 selection bias.
|
||||
|
||||
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.
|
||||
\strong{Why this is so important} \cr
|
||||
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}.
|
||||
\strong{\code{points_threshold}} \cr
|
||||
To compare key antibiotics, the difference between antimicrobial interpretations will be measured. 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.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
|
12
man/join.Rd
12
man/join.Rd
@ -13,22 +13,22 @@
|
||||
\usage{
|
||||
inner_join_bactlist(x, by = "bactid", ...)
|
||||
|
||||
left_join_bactlist(x, by = "bacteriecode", ...)
|
||||
left_join_bactlist(x, by = "bactid", ...)
|
||||
|
||||
right_join_bactlist(x, by = "bacteriecode", ...)
|
||||
right_join_bactlist(x, by = "bactid", ...)
|
||||
|
||||
full_join_bactlist(x, by = "bacteriecode", ...)
|
||||
full_join_bactlist(x, by = "bactid", ...)
|
||||
|
||||
semi_join_bactlist(x, by = "bacteriecode", ...)
|
||||
semi_join_bactlist(x, by = "bactid", ...)
|
||||
|
||||
anti_join_bactlist(x, by = "bacteriecode", ...)
|
||||
anti_join_bactlist(x, by = "bactid", ...)
|
||||
}
|
||||
\arguments{
|
||||
\item{x}{existing table to join}
|
||||
|
||||
\item{by}{a variable to join by - could be a column name of \code{x} with values that exist in \code{bactlist$bactid} (like \code{by = "bacteria_id"}), or another column in \code{\link{bactlist}} (but then it should be named, like \code{by = c("my_genus_species" = "fullname")})}
|
||||
|
||||
\item{...}{other parameters to pass trhough to \code{dplyr::\link[dplyr]{join}}.}
|
||||
\item{...}{other parameters to pass on to \code{dplyr::\link[dplyr]{join}}.}
|
||||
}
|
||||
\description{
|
||||
Join the list of microorganisms \code{\link{bactlist}} easily to an existing table.
|
||||
|
@ -12,9 +12,9 @@ rsi_predict(tbl, col_ab, col_date,
|
||||
\arguments{
|
||||
\item{tbl}{table that contains columns \code{col_ab} and \code{col_date}}
|
||||
|
||||
\item{col_ab}{column name of \code{tbl} with antimicrobial interpretations (\code{R}, \code{I} and \code{S})}
|
||||
\item{col_ab}{column name of \code{tbl} with antimicrobial interpretations (\code{R}, \code{I} and \code{S}), supports tidyverse-like quotation}
|
||||
|
||||
\item{col_date}{column name of the date, will be used to calculate years}
|
||||
\item{col_date}{column name of the date, will be used to calculate years if this column doesn't consist of years already, supports tidyverse-like quotation}
|
||||
|
||||
\item{year_max}{highest year to use in the prediction model, deafults to 15 years after today}
|
||||
|
||||
@ -32,30 +32,47 @@ rsi_predict(tbl, col_ab, col_date,
|
||||
\code{data.frame} with columns \code{year}, \code{probR}, \code{se_min} and \code{se_max}.
|
||||
}
|
||||
\description{
|
||||
Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns \code{se_min} and \code{se_max}.
|
||||
Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns \code{se_min} and \code{se_max}. See Examples for a real live example.
|
||||
}
|
||||
\examples{
|
||||
\dontrun{
|
||||
# use it directly:
|
||||
rsi_predict(tbl = tbl[which(first_isolate == TRUE & genus == "Haemophilus"),],
|
||||
col_ab = "amcl", coldate = "date")
|
||||
col_ab = "amcl", col_date = "date")
|
||||
|
||||
# or with dplyr so you can actually read it:
|
||||
library(dplyr)
|
||||
tbl \%>\%
|
||||
filter(first_isolate == TRUE,
|
||||
genus == "Haemophilus") \%>\%
|
||||
rsi_predict(col_ab = "amcl", coldate = "date")
|
||||
|
||||
tbl \%>\%
|
||||
filter(first_isolate_weighted == TRUE,
|
||||
genus == "Haemophilus") \%>\%
|
||||
rsi_predict(col_ab = "amcl",
|
||||
coldate = "date",
|
||||
year_max = 2050,
|
||||
year_every = 5)
|
||||
|
||||
rsi_predict(amcl, date)
|
||||
}
|
||||
|
||||
|
||||
# real live example:
|
||||
library(dplyr)
|
||||
septic_patients \%>\%
|
||||
# get bacteria properties like genus and species
|
||||
left_join_bactlist("bactid") \%>\%
|
||||
# calculate first isolates
|
||||
mutate(first_isolate =
|
||||
first_isolate(.,
|
||||
"date",
|
||||
"patient_id",
|
||||
"genus",
|
||||
"species",
|
||||
col_specimen = NA,
|
||||
col_icu = NA)) \%>\%
|
||||
# filter on first E. coli isolates
|
||||
filter(genus == "Escherichia",
|
||||
species == "coli",
|
||||
first_isolate == TRUE) \%>\%
|
||||
# predict resistance of cefotaxime for next years
|
||||
rsi_predict(col_ab = cfot,
|
||||
col_date = date,
|
||||
year_max = 2025,
|
||||
preserve_measurements = FALSE)
|
||||
|
||||
}
|
||||
\seealso{
|
||||
\code{\link{lm}} \cr \code{\link{glm}}
|
||||
|
29
man/septic_patients.Rd
Normal file
29
man/septic_patients.Rd
Normal file
@ -0,0 +1,29 @@
|
||||
% Generated by roxygen2: do not edit by hand
|
||||
% Please edit documentation in R/data.R
|
||||
\docType{data}
|
||||
\name{septic_patients}
|
||||
\alias{septic_patients}
|
||||
\title{Dataset with 2000 blood culture isolates of septic patients}
|
||||
\format{A data.frame with 2000 observations and 47 variables:
|
||||
\describe{
|
||||
\item{\code{date}}{date of receipt at the laboratory}
|
||||
\item{\code{hospital_id}}{ID of the hospital}
|
||||
\item{\code{ward_icu}}{logical to determine if ward is an intensive care unit}
|
||||
\item{\code{ward_clinical}}{logical to determine if ward is a regular clinical ward}
|
||||
\item{\code{ward_outpatient}}{logical to determine if ward is an outpatient clinic}
|
||||
\item{\code{age}}{age of the patient}
|
||||
\item{\code{sex}}{sex of the patient}
|
||||
\item{\code{patient_id}}{ID of the patient, first 10 characters of an SHA hash containing irretrievable information}
|
||||
\item{\code{bactid}}{ID of microorganism, see \code{\link{bactlist}}}
|
||||
\item{\code{peni:mupi}}{38 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}), these column names occur in \code{\link{ablist}} and can be translated with \code{\link{abname}}}
|
||||
}}
|
||||
\source{
|
||||
MOLIS (LIS of Certe) - \url{https://www.certe.nl}
|
||||
}
|
||||
\usage{
|
||||
septic_patients
|
||||
}
|
||||
\description{
|
||||
An anonymised dataset containing 2000 microbial blood culture isolates with their antibiogram of septic patients found in 5 different hospitals in the Netherlands, between 2001 and 2017. This data.frame can be used to practice AMR analysis e.g. with \code{\link{rsi}} or \code{\link{rsi_predict}}, or it can be used to practice other statistics.
|
||||
}
|
||||
\keyword{datasets}
|
Reference in New Issue
Block a user