mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 08:52:15 +02:00
(v0.7.1.9005) new rsi calculations, atc class removal
This commit is contained in:
@ -88,12 +88,9 @@ This means that looking up human pathogenic microorganisms takes less time than
|
||||
\strong{Uncertain results} \cr
|
||||
The algorithm can additionally use three different levels of uncertainty to guess valid results. The default is \code{allow_uncertain = TRUE}, which is equal to uncertainty level 2. Using \code{allow_uncertain = FALSE} will skip all of these additional rules:
|
||||
\itemize{
|
||||
\item{(uncertainty level 1): It tries to look for only matching genera}
|
||||
\item{(uncertainty level 1): It tries to look for previously accepted (but now invalid) taxonomic names}
|
||||
\item{(uncertainty level 2): It strips off values between brackets and the brackets itself, and re-evaluates the input with all previous rules}
|
||||
\item{(uncertainty level 2): It strips off words from the end one by one and re-evaluates the input with all previous rules}
|
||||
\item{(uncertainty level 3): It strips off words from the start one by one and re-evaluates the input with all previous rules}
|
||||
\item{(uncertainty level 3): It tries any part of the name}
|
||||
\item{(uncertainty level 1): It tries to look for only matching genera, previously accepted (but now invalid) taxonomic names and misspelled input}
|
||||
\item{(uncertainty level 2): It removed parts between brackets, strips off words from the end one by one and re-evaluates the input with all previous rules}
|
||||
\item{(uncertainty level 3): It strips off words from the start one by one and tries any part of the name}
|
||||
}
|
||||
|
||||
You can also use e.g. \code{as.mo(..., allow_uncertain = 1)} to only allow up to level 1 uncertainty.
|
||||
|
@ -52,7 +52,7 @@ The function \code{is.rsi.eligible} returns \code{TRUE} when a columns contains
|
||||
}
|
||||
\section{Interpretation of S, I and R}{
|
||||
|
||||
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
|
||||
\itemize{
|
||||
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
|
||||
@ -62,9 +62,7 @@ In 2019, EUCAST has decided to change the definitions of susceptibility testing
|
||||
|
||||
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
|
||||
|
||||
Source: \url{http://www.eucast.org/newsiandr/}.
|
||||
|
||||
\strong{This AMR package honours this new insight.}
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
|
84
man/count.Rd
84
man/count.Rd
@ -15,19 +15,19 @@
|
||||
Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 2014. \url{http://vita.had.co.nz/papers/tidy-data.html}
|
||||
}
|
||||
\usage{
|
||||
count_R(..., also_single_tested = FALSE)
|
||||
count_R(..., only_all_tested = FALSE)
|
||||
|
||||
count_IR(..., also_single_tested = FALSE)
|
||||
count_IR(..., only_all_tested = FALSE)
|
||||
|
||||
count_I(..., also_single_tested = FALSE)
|
||||
count_I(..., only_all_tested = FALSE)
|
||||
|
||||
count_SI(..., also_single_tested = FALSE)
|
||||
count_SI(..., only_all_tested = FALSE)
|
||||
|
||||
count_S(..., also_single_tested = FALSE)
|
||||
count_S(..., only_all_tested = FALSE)
|
||||
|
||||
count_all(..., also_single_tested = FALSE)
|
||||
count_all(..., only_all_tested = FALSE)
|
||||
|
||||
n_rsi(..., also_single_tested = FALSE)
|
||||
n_rsi(..., only_all_tested = FALSE)
|
||||
|
||||
count_df(data, translate_ab = "name", language = get_locale(),
|
||||
combine_SI = TRUE, combine_IR = FALSE)
|
||||
@ -35,7 +35,7 @@ count_df(data, translate_ab = "name", language = get_locale(),
|
||||
\arguments{
|
||||
\item{...}{one or more vectors (or columns) with antibiotic interpretations. They will be transformed internally with \code{\link{as.rsi}} if needed.}
|
||||
|
||||
\item{also_single_tested}{a logical to indicate whether for combination therapies also observations should be included where not all antibiotics were tested, but at least one of the tested antibiotics contains a target interpretation (e.g. S in case of \code{portion_S} and R in case of \code{portion_R}). \strong{This could lead to selection bias.}}
|
||||
\item{only_all_tested}{(for combination therapies, i.e. using more than one variable for \code{...}) a logical to indicate that isolates must be tested for all antibiotics, see section \emph{Combination therapy} below}
|
||||
|
||||
\item{data}{a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}})}
|
||||
|
||||
@ -66,7 +66,7 @@ The function \code{rsi_df} works exactly like \code{count_df}, but adds the perc
|
||||
}
|
||||
\section{Interpretation of S, I and R}{
|
||||
|
||||
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
|
||||
\itemize{
|
||||
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
|
||||
@ -76,9 +76,51 @@ In 2019, EUCAST has decided to change the definitions of susceptibility testing
|
||||
|
||||
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
|
||||
|
||||
Source: \url{http://www.eucast.org/newsiandr/}.
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
}
|
||||
|
||||
\strong{This AMR package honours this new insight.}
|
||||
\section{Combination therapy}{
|
||||
|
||||
When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
|
||||
|
||||
\preformatted{
|
||||
-------------------------------------------------------------------------
|
||||
only_all_tested = FALSE only_all_tested = TRUE
|
||||
Antibiotic Antibiotic ----------------------- -----------------------
|
||||
A B include as include as include as include as
|
||||
numerator denominator numerator denominator
|
||||
---------- ---------- ---------- ----------- ---------- -----------
|
||||
S S X X X X
|
||||
I S X X X X
|
||||
R S X X X X
|
||||
not tested S X X - -
|
||||
S I X X X X
|
||||
I I X X X X
|
||||
R I X X X X
|
||||
not tested I X X - -
|
||||
S R X X X X
|
||||
I R X X X X
|
||||
R R - X - X
|
||||
not tested R - - - -
|
||||
S not tested X X - -
|
||||
I not tested X X - -
|
||||
R not tested - - - -
|
||||
not tested not tested - - - -
|
||||
-------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Please note that for \code{only_all_tested = TRUE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
}
|
||||
and that for \code{only_all_tested = FALSE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
}
|
||||
|
||||
Using \code{only_all_tested} has no impact when only using one antibiotic as input.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
@ -105,8 +147,8 @@ n_rsi(septic_patients$AMX)
|
||||
# Since n_rsi counts available isolates, you can
|
||||
# calculate back to count e.g. non-susceptible isolates.
|
||||
# This results in the same:
|
||||
count_IR(septic_patients$AMX)
|
||||
portion_IR(septic_patients$AMX) * n_rsi(septic_patients$AMX)
|
||||
count_SI(septic_patients$AMX)
|
||||
portion_SI(septic_patients$AMX) * n_rsi(septic_patients$AMX)
|
||||
|
||||
library(dplyr)
|
||||
septic_patients \%>\%
|
||||
@ -120,17 +162,17 @@ septic_patients \%>\%
|
||||
|
||||
# Count co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
# so we can see that combination therapy does a lot more than mono therapy.
|
||||
# Please mind that `portion_S` calculates percentages right away instead.
|
||||
count_S(septic_patients$AMC) # S = 1342 (71.4\%)
|
||||
count_all(septic_patients$AMC) # n = 1879
|
||||
# Please mind that `portion_SI` calculates percentages right away instead.
|
||||
count_SI(septic_patients$AMC) # 1433
|
||||
count_all(septic_patients$AMC) # 1879
|
||||
|
||||
count_S(septic_patients$GEN) # S = 1372 (74.0\%)
|
||||
count_all(septic_patients$GEN) # n = 1855
|
||||
count_SI(septic_patients$GEN) # 1399
|
||||
count_all(septic_patients$GEN) # 1855
|
||||
|
||||
with(septic_patients,
|
||||
count_S(AMC, GEN)) # S = 1660 (92.3\%)
|
||||
with(septic_patients, # n = 1798
|
||||
n_rsi(AMC, GEN))
|
||||
count_SI(AMC, GEN)) # 1764
|
||||
with(septic_patients,
|
||||
n_rsi(AMC, GEN)) # 1936
|
||||
|
||||
# Get portions S/I/R immediately of all rsi columns
|
||||
septic_patients \%>\%
|
||||
|
114
man/portion.Rd
114
man/portion.Rd
@ -17,19 +17,19 @@ Wickham H. \strong{Tidy Data.} The Journal of Statistical Software, vol. 59, 201
|
||||
}
|
||||
\usage{
|
||||
portion_R(..., minimum = 30, as_percent = FALSE,
|
||||
also_single_tested = FALSE)
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_IR(..., minimum = 30, as_percent = FALSE,
|
||||
also_single_tested = FALSE)
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_I(..., minimum = 30, as_percent = FALSE,
|
||||
also_single_tested = FALSE)
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_SI(..., minimum = 30, as_percent = FALSE,
|
||||
also_single_tested = FALSE)
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_S(..., minimum = 30, as_percent = FALSE,
|
||||
also_single_tested = FALSE)
|
||||
only_all_tested = FALSE)
|
||||
|
||||
portion_df(data, translate_ab = "name", language = get_locale(),
|
||||
minimum = 30, as_percent = FALSE, combine_SI = TRUE,
|
||||
@ -46,7 +46,7 @@ rsi_df(data, translate_ab = "name", language = get_locale(),
|
||||
|
||||
\item{as_percent}{a logical to indicate whether the output must be returned as a hundred fold with \% sign (a character). A value of \code{0.123456} will then be returned as \code{"12.3\%"}.}
|
||||
|
||||
\item{also_single_tested}{a logical to indicate whether for combination therapies also observations should be included where not all antibiotics were tested, but at least one of the tested antibiotics contains a target interpretation (e.g. S in case of \code{portion_S} and R in case of \code{portion_R}). \strong{This could lead to selection bias.}}
|
||||
\item{only_all_tested}{(for combination therapies, i.e. using more than one variable for \code{...}) a logical to indicate that isolates must be tested for all antibiotics, see section \emph{Combination therapy} below}
|
||||
|
||||
\item{data}{a \code{data.frame} containing columns with class \code{rsi} (see \code{\link{as.rsi}})}
|
||||
|
||||
@ -67,31 +67,61 @@ These functions can be used to calculate the (co-)resistance of microbial isolat
|
||||
\code{portion_R} and \code{portion_IR} can be used to calculate resistance, \code{portion_S} and \code{portion_SI} can be used to calculate susceptibility.\cr
|
||||
}
|
||||
\details{
|
||||
\strong{Remember that you should filter your table to let it contain only first isolates!} Use \code{\link{first_isolate}} to determine them in your data set.
|
||||
\strong{Remember that you should filter your table to let it contain only first isolates!} This is needed to exclude duplicates and to reduce selection bias. Use \code{\link{first_isolate}} to determine them in your data set.
|
||||
|
||||
These functions are not meant to count isolates, but to calculate the portion of resistance/susceptibility. Use the \code{\link[AMR]{count}} functions to count isolates. \emph{Low counts can infuence the outcome - these \code{portion} functions may camouflage this, since they only return the portion albeit being dependent on the \code{minimum} parameter.}
|
||||
|
||||
The function \code{portion_df} takes any variable from \code{data} that has an \code{"rsi"} class (created with \code{\link{as.rsi}}) and calculates the portions R, I and S. The resulting \emph{tidy data} (see Source) \code{data.frame} will have three rows (S/I/R) and a column for each group and each variable with class \code{"rsi"}.
|
||||
|
||||
The function \code{rsi_df} works exactly like \code{portion_df}, but adds the number of isolates.
|
||||
\if{html}{
|
||||
\cr\cr
|
||||
To calculate the probability (\emph{p}) of susceptibility of one antibiotic, we use this formula:
|
||||
\out{<div style="text-align: center;">}\figure{combi_therapy_2.png}\out{</div>}
|
||||
To calculate the probability (\emph{p}) of susceptibility of more antibiotics (i.e. combination therapy), we need to check whether one of them has a susceptible result (as numerator) and count all cases where all antibiotics were tested (as denominator). \cr
|
||||
\cr
|
||||
For two antibiotics:
|
||||
\out{<div style="text-align: center;">}\figure{combi_therapy_2.png}\out{</div>}
|
||||
\cr
|
||||
For three antibiotics:
|
||||
\out{<div style="text-align: center;">}\figure{combi_therapy_2.png}\out{</div>}
|
||||
\cr
|
||||
And so on.
|
||||
}
|
||||
\section{Combination therapy}{
|
||||
|
||||
When using more than one variable for \code{...} (= combination therapy)), use \code{only_all_tested} to only count isolates that are tested for all antibiotics/variables that you test them for. See this example for two antibiotics, Antibiotic A and Antibiotic B, about how \code{portion_SI} works to calculate the \%SI:
|
||||
|
||||
\preformatted{
|
||||
-------------------------------------------------------------------------
|
||||
only_all_tested = FALSE only_all_tested = TRUE
|
||||
Antibiotic Antibiotic ----------------------- -----------------------
|
||||
A B include as include as include as include as
|
||||
numerator denominator numerator denominator
|
||||
---------- ---------- ---------- ----------- ---------- -----------
|
||||
S S X X X X
|
||||
I S X X X X
|
||||
R S X X X X
|
||||
not tested S X X - -
|
||||
S I X X X X
|
||||
I I X X X X
|
||||
R I X X X X
|
||||
not tested I X X - -
|
||||
S R X X X X
|
||||
I R X X X X
|
||||
R R - X - X
|
||||
not tested R - - - -
|
||||
S not tested X X - -
|
||||
I not tested X X - -
|
||||
R not tested - - - -
|
||||
not tested not tested - - - -
|
||||
-------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
Please note that for \code{only_all_tested = TRUE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() == count_all()
|
||||
portion_S() + portion_I() + portion_R() == 1
|
||||
}
|
||||
and that for \code{only_all_tested = FALSE} applies that:
|
||||
\preformatted{
|
||||
count_S() + count_I() + count_R() >= count_all()
|
||||
portion_S() + portion_I() + portion_R() >= 1
|
||||
}
|
||||
|
||||
Using \code{only_all_tested} has no impact when only using one antibiotic as input.
|
||||
}
|
||||
|
||||
\section{Interpretation of S, I and R}{
|
||||
|
||||
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below. Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
In 2019, EUCAST has decided to change the definitions of susceptibility testing categories S, I and R as shown below (\url{http://www.eucast.org/newsiandr/}). Results of several consultations on the new definitions are available on the EUCAST website under "Consultations".
|
||||
|
||||
\itemize{
|
||||
\item{\strong{S} - }{Susceptible, standard dosing regimen: A microorganism is categorised as "Susceptible, standard dosing regimen", when there is a high likelihood of therapeutic success using a standard dosing regimen of the agent.}
|
||||
@ -101,9 +131,7 @@ In 2019, EUCAST has decided to change the definitions of susceptibility testing
|
||||
|
||||
Exposure is a function of how the mode of administration, dose, dosing interval, infusion time, as well as distribution and excretion of the antimicrobial agent will influence the infecting organism at the site of infection.
|
||||
|
||||
Source: \url{http://www.eucast.org/newsiandr/}.
|
||||
|
||||
\strong{This AMR package honours this new insight.}
|
||||
This AMR package honours this new insight. Use \code{\link{portion_SI}} to determine antimicrobial susceptibility and \code{\link{count_SI}} to count susceptible isolates.
|
||||
}
|
||||
|
||||
\section{Read more on our website!}{
|
||||
@ -132,7 +160,7 @@ septic_patients \%>\% portion_SI(AMX)
|
||||
|
||||
septic_patients \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(p = portion_S(CIP),
|
||||
summarise(p = portion_SI(CIP),
|
||||
n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr
|
||||
|
||||
septic_patients \%>\%
|
||||
@ -146,32 +174,38 @@ septic_patients \%>\%
|
||||
|
||||
# Calculate co-resistance between amoxicillin/clav acid and gentamicin,
|
||||
# so we can see that combination therapy does a lot more than mono therapy:
|
||||
septic_patients \%>\% portion_S(AMC) # S = 71.4\%
|
||||
septic_patients \%>\% count_all(AMC) # n = 1879
|
||||
septic_patients \%>\% portion_SI(AMC) # \%SI = 76.3\%
|
||||
septic_patients \%>\% count_all(AMC) # n = 1879
|
||||
|
||||
septic_patients \%>\% portion_S(GEN) # S = 74.0\%
|
||||
septic_patients \%>\% count_all(GEN) # n = 1855
|
||||
septic_patients \%>\% portion_SI(GEN) # \%SI = 75.4\%
|
||||
septic_patients \%>\% count_all(GEN) # n = 1855
|
||||
|
||||
septic_patients \%>\% portion_S(AMC, GEN) # S = 92.3\%
|
||||
septic_patients \%>\% count_all(AMC, GEN) # n = 1798
|
||||
septic_patients \%>\% portion_SI(AMC, GEN) # \%SI = 94.1\%
|
||||
septic_patients \%>\% count_all(AMC, GEN) # n = 1939
|
||||
|
||||
# Using `also_single_tested` can be useful ...
|
||||
|
||||
# See Details on how `only_all_tested` works. Example:
|
||||
septic_patients \%>\%
|
||||
portion_S(AMC, GEN,
|
||||
also_single_tested = TRUE) # S = 92.6\%
|
||||
# ... but can also lead to selection bias - the data only has 2,000 rows:
|
||||
summarise(numerator = count_SI(AMC, GEN),
|
||||
denominator = count_all(AMC, GEN),
|
||||
portion = portion_SI(AMC, GEN))
|
||||
# numerator denominator portion
|
||||
# 1764 1936 0.9408
|
||||
septic_patients \%>\%
|
||||
count_all(AMC, GEN,
|
||||
also_single_tested = TRUE) # n = 2555
|
||||
summarise(numerator = count_SI(AMC, GEN, only_all_tested = TRUE),
|
||||
denominator = count_all(AMC, GEN, only_all_tested = TRUE),
|
||||
portion = portion_SI(AMC, GEN, only_all_tested = TRUE))
|
||||
# numerator denominator portion
|
||||
# 1687 1798 0.9383
|
||||
|
||||
|
||||
septic_patients \%>\%
|
||||
group_by(hospital_id) \%>\%
|
||||
summarise(cipro_p = portion_S(CIP, as_percent = TRUE),
|
||||
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
|
||||
cipro_n = count_all(CIP),
|
||||
genta_p = portion_S(GEN, as_percent = TRUE),
|
||||
genta_p = portion_SI(GEN, as_percent = TRUE),
|
||||
genta_n = count_all(GEN),
|
||||
combination_p = portion_S(CIP, GEN, as_percent = TRUE),
|
||||
combination_p = portion_SI(CIP, GEN, as_percent = TRUE),
|
||||
combination_n = count_all(CIP, GEN))
|
||||
|
||||
# Get portions S/I/R immediately of all rsi columns
|
||||
|
Reference in New Issue
Block a user