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

improvement for forecasting resistance

This commit is contained in:
2018-07-26 16:30:42 +02:00
parent d9e204031d
commit 498e88b5cf
13 changed files with 438 additions and 145 deletions

View File

@ -15,20 +15,20 @@ EUCAST Expert Rules Version 2.0: \cr
\usage{
EUCAST_rules(tbl, col_bactid = "bactid", info = TRUE, amcl = "amcl",
amik = "amik", amox = "amox", ampi = "ampi", azit = "azit",
aztr = "aztr", cefa = "cefa", cfra = "cfra", cfep = "cfep",
cfot = "cfot", cfox = "cfox", cfta = "cfta", cftr = "cftr",
cfur = "cfur", chlo = "chlo", cipr = "cipr", clar = "clar",
clin = "clin", clox = "clox", coli = "coli", czol = "czol",
dapt = "dapt", doxy = "doxy", erta = "erta", eryt = "eryt",
fosf = "fosf", fusi = "fusi", gent = "gent", imip = "imip",
kana = "kana", levo = "levo", linc = "linc", line = "line",
mero = "mero", mino = "mino", moxi = "moxi", nali = "nali",
neom = "neom", neti = "neti", nitr = "nitr", novo = "novo",
norf = "norf", oflo = "oflo", peni = "peni", pita = "pita",
poly = "poly", qida = "qida", rifa = "rifa", roxi = "roxi",
siso = "siso", teic = "teic", tetr = "tetr", tica = "tica",
tige = "tige", tobr = "tobr", trim = "trim", trsu = "trsu",
vanc = "vanc")
azlo = "azlo", aztr = "aztr", cefa = "cefa", cfep = "cfep",
cfot = "cfot", cfox = "cfox", cfra = "cfra", cfta = "cfta",
cftr = "cftr", cfur = "cfur", chlo = "chlo", cipr = "cipr",
clar = "clar", clin = "clin", clox = "clox", coli = "coli",
czol = "czol", dapt = "dapt", doxy = "doxy", erta = "erta",
eryt = "eryt", fosf = "fosf", fusi = "fusi", gent = "gent",
imip = "imip", kana = "kana", levo = "levo", linc = "linc",
line = "line", mero = "mero", mezl = "mezl", mino = "mino",
moxi = "moxi", nali = "nali", neom = "neom", neti = "neti",
nitr = "nitr", norf = "norf", novo = "novo", oflo = "oflo",
peni = "peni", pita = "pita", poly = "poly", pris = "pris",
qida = "qida", rifa = "rifa", roxi = "roxi", siso = "siso",
teic = "teic", tetr = "tetr", tica = "tica", tige = "tige",
tobr = "tobr", trim = "trim", trsu = "trsu", vanc = "vanc")
interpretive_reading(...)
}
@ -39,7 +39,7 @@ interpretive_reading(...)
\item{info}{print progress}
\item{amcl, amik, amox, ampi, azit, aztr, cefa, cfra, cfep, cfot, cfox, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mino, moxi, nali, neom, neti, nitr, novo, norf, oflo, peni, pita, poly, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column names of antibiotics. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing column will be skipped.}
\item{amcl, amik, amox, ampi, azit, azlo, aztr, cefa, cfep, cfot, cfox, cfra, cfta, cftr, cfur, chlo, cipr, clar, clin, clox, coli, czol, dapt, doxy, erta, eryt, fosf, fusi, gent, imip, kana, levo, linc, line, mero, mezl, mino, moxi, nali, neom, neti, nitr, norf, novo, oflo, peni, pita, poly, pris, qida, rifa, roxi, siso, teic, tetr, tica, tige, tobr, trim, trsu, vanc}{column names of antibiotics. Use \code{NA} to skip a column, like \code{tica = NA}. Non-existing columns will anyway be skipped. See the Antibiotics section for an explanation of the abbreviations.}
\item{...}{parameters that are passed on to \code{EUCAST_rules}}
}
@ -49,6 +49,73 @@ table with edited variables of antibiotics.
\description{
Apply expert rules (like intrinsic resistance), as defined by the European Committee on Antimicrobial Susceptibility Testing (EUCAST, \url{http://eucast.org}), see \emph{Source}.
}
\section{Abbrevations of antibiotics}{
Abbrevations of the column containing antibiotics:
\strong{amcl}: amoxicillin and beta-lactamase inhibitor (\emph{J01CR02}),
\strong{amik}: amikacin (\emph{J01GB06}),
\strong{amox}: amoxicillin (\emph{J01CA04}),
\strong{ampi}: ampicillin (\emph{J01CA01}),
\strong{azit}: azithromycin (\emph{J01FA10}),
\strong{azlo}: azlocillin (\emph{J01CA09}),
\strong{aztr}: aztreonam (\emph{J01DF01}),
\strong{cefa}: cefaloridine (\emph{J01DB02}),
\strong{cfep}: cefepime (\emph{J01DE01}),
\strong{cfot}: cefotaxime (\emph{J01DD01}),
\strong{cfox}: cefoxitin (\emph{J01DC01}),
\strong{cfra}: cefradine (\emph{J01DB09}),
\strong{cfta}: ceftazidime (\emph{J01DD02}),
\strong{cftr}: ceftriaxone (\emph{J01DD04}),
\strong{cfur}: cefuroxime (\emph{J01DC02}),
\strong{chlo}: chloramphenicol (\emph{J01BA01}),
\strong{cipr}: ciprofloxacin (\emph{J01MA02}),
\strong{clar}: clarithromycin (\emph{J01FA09}),
\strong{clin}: clindamycin (\emph{J01FF01}),
\strong{clox}: flucloxacillin (\emph{J01CF05}),
\strong{coli}: colistin (\emph{J01XB01}),
\strong{czol}: cefazolin (\emph{J01DB04}),
\strong{dapt}: daptomycin (\emph{J01XX09}),
\strong{doxy}: doxycycline (\emph{J01AA02}),
\strong{erta}: ertapenem (\emph{J01DH03}),
\strong{eryt}: erythromycin (\emph{J01FA01}),
\strong{fosf}: fosfomycin (\emph{J01XX01}),
\strong{fusi}: fusidic acid (\emph{J01XC01}),
\strong{gent}: gentamicin (\emph{J01GB03}),
\strong{imip}: imipenem and cilastatin (\emph{J01DH51}),
\strong{kana}: kanamycin (\emph{J01GB04}),
\strong{levo}: levofloxacin (\emph{J01MA12}),
\strong{linc}: lincomycin (\emph{J01FF02}),
\strong{line}: linezolid (\emph{J01XX08}),
\strong{mero}: meropenem (\emph{J01DH02}),
\strong{mezl}: mezlocillin (\emph{J01CA10}),
\strong{mino}: minocycline (\emph{J01AA08}),
\strong{moxi}: moxifloxacin (\emph{J01MA14}),
\strong{nali}: nalidixic acid (\emph{J01MB02}),
\strong{neom}: neomycin (\emph{J01GB05}),
\strong{neti}: netilmicin (\emph{J01GB07}),
\strong{nitr}: nitrofurantoin (\emph{J01XE01}),
\strong{norf}: norfloxacin (\emph{J01MA06}),
\strong{novo}: novobiocin (an ATCvet code: \emph{QJ01XX95}),
\strong{oflo}: ofloxacin (\emph{J01MA01}),
\strong{peni}: penicillins, combinations with other antibacterials (\emph{J01RA01}),
\strong{pita}: piperacillin and beta-lactamase inhibitor (\emph{J01CR05}),
\strong{poly}: polymyxin B (\emph{J01XB02}),
\strong{pris}: pristinamycin (\emph{J01FG01}),
\strong{qida}: quinupristin/dalfopristin (\emph{J01FG02}),
\strong{rifa}: rifampicin (\emph{J04AB02}),
\strong{roxi}: roxithromycin (\emph{J01FA06}),
\strong{siso}: sisomicin (\emph{J01GB08}),
\strong{teic}: teicoplanin (\emph{J01XA02}),
\strong{tetr}: tetracycline (\emph{J01AA07}),
\strong{tica}: ticarcillin (\emph{J01CA13}),
\strong{tige}: tigecycline (\emph{J01AA12}),
\strong{tobr}: tobramycin (\emph{J01GB01}),
\strong{trim}: trimethoprim (\emph{J01EA01}),
\strong{trsu}: sulfamethoxazole and trimethoprim (\emph{J01EE01}),
\strong{vanc}: vancomycin (\emph{J01XA01}).
}
\examples{
a <- EUCAST_rules(septic_patients)
a <- data.frame(bactid = c("STAAUR", # Staphylococcus aureus
@ -67,3 +134,7 @@ a
b <- EUCAST_rules(a)
b
}
\keyword{eucast}
\keyword{interpretive}
\keyword{reading}
\keyword{resistance}

View File

@ -92,13 +92,13 @@ A <- my_patients \%>\%
resistance = resistance(gent))
B <- my_patients \%>\%
filter(first_isolate == TRUE) \%>\%
filter(first_isolate == TRUE) \%>\% # the 1st isolate filter
group_by(hospital_id) \%>\%
summarise(count = n_rsi(gent), # gentamicin
summarise(count = n_rsi(gent),
resistance = resistance(gent))
# Have a look at A and B. B is more reliable because every isolate is
# counted once. Gentamicin resitance in hospital D seems to be 5\%
# counted once. Gentamicin resitance in hospital D appears to be 5\%
# higher than originally thought.
## OTHER EXAMPLES:

View File

@ -5,53 +5,64 @@
\alias{rsi_predict}
\title{Predict antimicrobial resistance}
\usage{
resistance_predict(tbl, col_ab, col_date,
year_max = as.integer(format(as.Date(Sys.Date()), "\%Y")) + 15,
year_every = 1, model = "binomial", I_as_R = TRUE,
resistance_predict(tbl, col_ab, col_date, year_min = NULL, year_max = NULL,
year_every = 1, minimum = 30, model = "binomial", I_as_R = TRUE,
preserve_measurements = TRUE, info = TRUE)
rsi_predict(tbl, col_ab, col_date,
year_max = as.integer(format(as.Date(Sys.Date()), "\%Y")) + 15,
year_every = 1, model = "binomial", I_as_R = TRUE,
rsi_predict(tbl, col_ab, col_date, year_min = NULL, year_max = NULL,
year_every = 1, minimum = 30, model = "binomial", I_as_R = TRUE,
preserve_measurements = TRUE, info = TRUE)
}
\arguments{
\item{tbl}{table that contains columns \code{col_ab} and \code{col_date}}
\item{tbl}{a \code{data.frame} containing isolates.}
\item{col_ab}{column name of \code{tbl} with antimicrobial interpretations (\code{R}, \code{I} and \code{S}), supports tidyverse-like quotation}
\item{col_ab}{column name of \code{tbl} with antimicrobial interpretations (\code{R}, \code{I} and \code{S})}
\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{col_date}{column name of the date, will be used to calculate years if this column doesn't consist of years already}
\item{year_max}{highest year to use in the prediction model, deafults to 15 years after today}
\item{year_min}{lowest year to use in the prediction model, dafaults the lowest year in \code{col_date}}
\item{year_max}{highest year to use in the prediction model, defaults to 15 years after today}
\item{year_every}{unit of sequence between lowest year found in the data and \code{year_max}}
\item{minimum}{minimal amount of available isolates per year to include. Years containing less observations will be estimated by the model.}
\item{model}{the statistical model of choice. Valid values are \code{"binomial"} (or \code{"binom"} or \code{"logit"}) or \code{"loglin"} or \code{"linear"} (or \code{"lin"}).}
\item{I_as_R}{treat \code{I} as \code{R}}
\item{preserve_measurements}{overwrite predictions of years that are actually available in the data, with the original data. The standard errors of those years will be \code{NA}.}
\item{preserve_measurements}{logical to indicate whether predictions of years that are actually available in the data should be overwritten with the original data. The standard errors of those years will be \code{NA}.}
\item{info}{print textual analysis with the name and \code{\link{summary}} of the model.}
}
\value{
\code{data.frame} with columns \code{year}, \code{probR}, \code{se_min} and \code{se_max}.
\code{data.frame} with columns:
\itemize{
\item{\code{year}}
\item{\code{resistance}, the same as \code{estimated} when \code{preserve_measurements = FALSE}, and a combination of \code{observed} and \code{estimated} otherwise}
\item{\code{se_min}, the lower bound of the standard error with a minimum of \code{0}}
\item{\code{se_max} the upper bound of the standard error with a maximum of \code{1}}
\item{\code{observations}, the total number of observations, i.e. S + I + R}
\item{\code{observed}, the original observed values}
\item{\code{estimated}, the estimated values, calculated by the model}
}
}
\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}. 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", col_date = "date")
# use it with base R:
resistance_predict(tbl = tbl[which(first_isolate == TRUE & genus == "Haemophilus"),],
col_ab = "amcl", col_date = "date")
# or with dplyr so you can actually read it:
# or use dplyr so you can actually read it:
library(dplyr)
tbl \%>\%
filter(first_isolate == TRUE,
genus == "Haemophilus") \%>\%
rsi_predict(amcl, date)
resistance_predict(amcl, date)
}
@ -73,11 +84,38 @@ septic_patients \%>\%
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)
resistance_predict(col_ab = "cfot",
col_date = "date",
year_max = 2025,
preserve_measurements = TRUE,
minimum = 0)
# create nice plots with ggplot
if (!require(ggplot2)) {
data <- septic_patients \%>\%
filter(bactid == "ESCCOL") \%>\%
resistance_predict(col_ab = "amox",
col_date = "date",
info = FALSE,
minimum = 15)
ggplot(data,
aes(x = year)) +
geom_col(aes(y = resistance),
fill = "grey75") +
geom_errorbar(aes(ymin = se_min,
ymax = se_max),
colour = "grey50") +
scale_y_continuous(limits = c(0, 1),
breaks = seq(0, 1, 0.1),
labels = paste0(seq(0, 100, 10), "\%")) +
labs(title = expression(paste("Forecast of amoxicillin resistance in ",
italic("E. coli"))),
y = "\%IR",
x = "Year") +
theme_minimal(base_size = 13)
}
}
\seealso{
\code{\link{resistance}} \cr \code{\link{lm}} \code{\link{glm}}