(v0.7.1.9063) septic_patients -> example_isolates

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-08-27 16:45:42 +02:00
parent 7a6fce4eb8
commit 93be16484b
92 changed files with 1143 additions and 818 deletions

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.7.1.9062
Date: 2019-08-26
Version: 0.7.1.9063
Date: 2019-08-27
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),

View File

@ -1,4 +1,4 @@
# AMR 0.7.1.9062
# AMR 0.7.1.9063
### Breaking
* Determination of first isolates now **excludes** all 'unknown' microorganisms at default, i.e. microbial code `"UNKNOWN"`. They can be included with the new parameter `include_unknown`:
@ -37,7 +37,7 @@
```
You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R `format()` function:
```r
format(x)
format(x, combine_SI = TRUE)
```
* Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for `portion_*` functions or `count_*` functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter `only_all_tested` (**which defaults to `FALSE`**) replaces the old `also_single_tested` and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the `portion` and `count` help pages), where the %SI is being determined:
@ -71,7 +71,8 @@
```
### Changed
* Function: `eucast_rules()`
* Renamed data set `septic_patients` to `example_isolates`
* Function `eucast_rules()`:
* Fixed a bug for *Yersinia pseudotuberculosis*
* Added more informative errors and warnings
* Printed info now distinguishes between added and changes values

View File

@ -129,7 +129,7 @@ age <- function(x, reference = Sys.Date(), exact = FALSE) {
#'
#' # resistance of ciprofloxacine per age group
#' library(dplyr)
#' septic_patients %>%
#' example_isolates %>%
#' filter_first_isolate() %>%
#' filter(mo == as.mo("E. coli")) %>%
#' group_by(age_group = age_groups(age)) %>%

View File

@ -29,16 +29,16 @@
#' @inheritSection AMR Read more on our website!
#' @export
#' @examples
#' availability(septic_patients)
#' availability(example_isolates)
#'
#' library(dplyr)
#' septic_patients %>% availability()
#' example_isolates %>% availability()
#'
#' septic_patients %>%
#' example_isolates %>%
#' select_if(is.rsi) %>%
#' availability()
#'
#' septic_patients %>%
#' example_isolates %>%
#' filter(mo == as.mo("E. coli")) %>%
#' select_if(is.rsi) %>%
#' availability()

View File

@ -23,16 +23,18 @@
#'
#' Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use \code{format} on the result to prettify it to a printable format, see Examples.
#' @inheritParams eucast_rules
#' @param combine_RI logical to indicate whether values R and I should be summed
#' @inheritParams rsi_df
#' @importFrom dplyr rename
#' @importFrom tidyr spread
#' @importFrom clean freq
#' @details The function \code{format} calculated the resistance per bug-drug combination. Use \code{combine_RI = FALSE} (default) to test R vs. S+I and \code{combine_RI = TRUE} to test R+I vs. S.
#' @export
#' @source \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/}.
#' @inheritSection AMR Read more on our website!
#' @examples
#' \donttest{
#' x <- bug_drug_combinations(septic_patients)
#' x <- bug_drug_combinations(example_isolates)
#' x
#' format(x)
#' }
@ -70,8 +72,8 @@ bug_drug_combinations <- function(x, col_mo = NULL, minimum = 30) {
#' @importFrom tidyr spread
#' @exportMethod format.bugdrug
#' @export
format.bugdrug <- function(x, combine_SI = TRUE, add_ab_group = TRUE, ...) {
if (combine_SI == TRUE) {
format.bugdrug <- function(x, combine_RI = FALSE, add_ab_group = TRUE, ...) {
if (combine_RI == FALSE) {
x$isolates <- x$R
} else {
x$isolates <- x$R + x$I

View File

@ -44,29 +44,29 @@
#' @export
#' @inheritSection AMR Read more on our website!
#' @examples
#' # septic_patients is a data set available in the AMR package. It is true, genuine data.
#' ?septic_patients
#' # example_isolates is a data set available in the AMR package.
#' ?example_isolates
#'
#' # Count resistant isolates
#' count_R(septic_patients$AMX)
#' count_IR(septic_patients$AMX)
#' count_R(example_isolates$AMX)
#' count_IR(example_isolates$AMX)
#'
#' # Or susceptible isolates
#' count_S(septic_patients$AMX)
#' count_SI(septic_patients$AMX)
#' count_S(example_isolates$AMX)
#' count_SI(example_isolates$AMX)
#'
#' # Count all available isolates
#' count_all(septic_patients$AMX)
#' n_rsi(septic_patients$AMX)
#' count_all(example_isolates$AMX)
#' n_rsi(example_isolates$AMX)
#'
#' # Since n_rsi counts available isolates, you can
#' # calculate back to count e.g. non-susceptible isolates.
#' # This results in the same:
#' count_SI(septic_patients$AMX)
#' portion_SI(septic_patients$AMX) * n_rsi(septic_patients$AMX)
#' count_SI(example_isolates$AMX)
#' portion_SI(example_isolates$AMX) * n_rsi(example_isolates$AMX)
#'
#' library(dplyr)
#' septic_patients %>%
#' example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(R = count_R(CIP),
#' I = count_I(CIP),
@ -78,24 +78,24 @@
#' # 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_SI` calculates percentages right away instead.
#' count_SI(septic_patients$AMC) # 1433
#' count_all(septic_patients$AMC) # 1879
#' count_SI(example_isolates$AMC) # 1433
#' count_all(example_isolates$AMC) # 1879
#'
#' count_SI(septic_patients$GEN) # 1399
#' count_all(septic_patients$GEN) # 1855
#' count_SI(example_isolates$GEN) # 1399
#' count_all(example_isolates$GEN) # 1855
#'
#' with(septic_patients,
#' with(example_isolates,
#' count_SI(AMC, GEN)) # 1764
#' with(septic_patients,
#' with(example_isolates,
#' n_rsi(AMC, GEN)) # 1936
#'
#' # Get portions S/I/R immediately of all rsi columns
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, CIP) %>%
#' count_df(translate = FALSE)
#'
#' # It also supports grouping variables
#' septic_patients %>%
#' example_isolates %>%
#' select(hospital_id, AMX, CIP) %>%
#' group_by(hospital_id) %>%
#' count_df(translate = FALSE)

View File

@ -125,7 +125,7 @@ catalogue_of_life <- list(
#' Data set with 2,000 blood culture isolates from septic patients
#'
#' An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
#' An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
#' @format A \code{\link{data.frame}} with 2,000 observations and 49 variables:
#' \describe{
#' \item{\code{date}}{date of receipt at the laboratory}
@ -140,11 +140,11 @@ catalogue_of_life <- list(
#' \item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{ab_name}}}
#' }
#' @inheritSection AMR Read more on our website!
"septic_patients"
"example_isolates"
#' Data set with 500 isolates - WHONET example
#'
#' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our \code{\link{septic_patients}} data set.
#' This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our \code{\link{example_isolates}} data set.
#' @format A \code{\link{data.frame}} with 500 observations and 53 variables:
#' \describe{
#' \item{\code{Identification number}}{ID of the sample}

View File

@ -37,29 +37,29 @@
#' library(dplyr)
#'
#' # filter on isolates that have any result for any aminoglycoside
#' septic_patients %>% filter_aminoglycosides()
#' example_isolates %>% filter_aminoglycosides()
#'
#' # this is essentially the same as (but without determination of column names):
#' septic_patients %>%
#' example_isolates %>%
#' filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")),
#' .vars_predicate = any_vars(. %in% c("S", "I", "R")))
#'
#'
#' # filter on isolates that show resistance to ANY aminoglycoside
#' septic_patients %>% filter_aminoglycosides("R")
#' example_isolates %>% filter_aminoglycosides("R")
#'
#' # filter on isolates that show resistance to ALL aminoglycosides
#' septic_patients %>% filter_aminoglycosides("R", "all")
#' example_isolates %>% filter_aminoglycosides("R", "all")
#'
#' # filter on isolates that show resistance to
#' # any aminoglycoside and any fluoroquinolone
#' septic_patients %>%
#' example_isolates %>%
#' filter_aminoglycosides("R") %>%
#' filter_fluoroquinolones("R")
#'
#' # filter on isolates that show resistance to
#' # all aminoglycosides and all fluoroquinolones
#' septic_patients %>%
#' example_isolates %>%
#' filter_aminoglycosides("R", "all") %>%
#' filter_fluoroquinolones("R", "all")
filter_ab_class <- function(x,

View File

@ -79,12 +79,12 @@
#' @source 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/}.
#' @inheritSection AMR Read more on our website!
#' @examples
#' # `septic_patients` is a dataset available in the AMR package. It is true, genuine data.
#' # See ?septic_patients.
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
#' library(dplyr)
#' # Filter on first isolates:
#' septic_patients %>%
#' example_isolates %>%
#' mutate(first_isolate = first_isolate(.,
#' col_date = "date",
#' col_patient_id = "patient_id",
@ -92,19 +92,19 @@
#' filter(first_isolate == TRUE)
#'
#' # Which can be shortened to:
#' septic_patients %>%
#' example_isolates %>%
#' filter_first_isolate()
#' # or for first weighted isolates:
#' septic_patients %>%
#' example_isolates %>%
#' filter_first_weighted_isolate()
#'
#' # Now let's see if first isolates matter:
#' A <- septic_patients %>%
#' A <- example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(count = n_rsi(GEN), # gentamicin availability
#' resistance = portion_IR(GEN)) # gentamicin resistance
#'
#' B <- septic_patients %>%
#' B <- example_isolates %>%
#' filter_first_weighted_isolate() %>% # the 1st isolate filter
#' group_by(hospital_id) %>%
#' summarise(count = n_rsi(GEN), # gentamicin availability

View File

@ -66,11 +66,11 @@
#' library(ggplot2)
#'
#' # get antimicrobial results for drugs against a UTI:
#' ggplot(septic_patients %>% select(AMX, NIT, FOS, TMP, CIP)) +
#' ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) +
#' geom_rsi()
#'
#' # prettify the plot using some additional functions:
#' df <- septic_patients %>% select(AMX, NIT, FOS, TMP, CIP)
#' df <- example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)
#' ggplot(df) +
#' geom_rsi() +
#' scale_y_percent() +
@ -79,17 +79,17 @@
#' theme_rsi()
#'
#' # or better yet, simplify this using the wrapper function - a single command:
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%
#' ggplot_rsi()
#'
#' # get only portions and no counts:
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%
#' ggplot_rsi(datalabels = FALSE)
#'
#' # add other ggplot2 parameters as you like:
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%
#' ggplot_rsi(width = 0.5,
#' colour = "black",
@ -97,12 +97,12 @@
#' linetype = 2,
#' alpha = 0.25)
#'
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX) %>%
#' ggplot_rsi(colours = c(SI = "yellow"))
#'
#' # resistance of ciprofloxacine per age group
#' septic_patients %>%
#' example_isolates %>%
#' mutate(first_isolate = first_isolate(.)) %>%
#' filter(first_isolate == TRUE,
#' mo == as.mo("E. coli")) %>%
@ -114,17 +114,17 @@
#' \donttest{
#'
#' # for colourblind mode, use divergent colours from the viridis package:
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%
#' ggplot_rsi() + scale_fill_viridis_d()
#' # a shorter version which also adjusts data label colours:
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, NIT, FOS, TMP, CIP) %>%
#' ggplot_rsi(colours = FALSE)
#'
#'
#' # it also supports groups (don't forget to use the group var on `x` or `facet`):
#' septic_patients %>%
#' example_isolates %>%
#' select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
#' group_by(hospital_id) %>%
#' ggplot_rsi(x = "hospital_id",
@ -135,7 +135,7 @@
#' datalabels = FALSE)
#'
#' # genuine analysis: check 3 most prevalent microorganisms
#' septic_patients %>%
#' example_isolates %>%
#' # create new bacterial ID's, with all CoNS under the same group (Becker et al.)
#' mutate(mo = as.mo(mo, Becker = TRUE)) %>%
#' # filter on top three bacterial ID's

View File

@ -129,7 +129,7 @@ get_column_abx <- function(x,
names(x) <- df_trans$abcode
# add from self-defined dots (...):
# get_column_abx(septic_patients %>% rename(thisone = AMX), amox = "thisone")
# get_column_abx(example_isolates %>% rename(thisone = AMX), amox = "thisone")
dots <- list(...)
if (length(dots) > 0) {
newnames <- suppressWarnings(as.ab(names(dots)))

View File

@ -37,7 +37,7 @@
#' left_join_microorganisms("B_KLBSL_PNE")
#'
#' library(dplyr)
#' septic_patients %>% left_join_microorganisms()
#' example_isolates %>% left_join_microorganisms()
#'
#' df <- data.frame(date = seq(from = as.Date("2018-01-01"),
#' to = as.Date("2018-01-07"),

View File

@ -48,12 +48,12 @@
#' @seealso \code{\link{first_isolate}}
#' @inheritSection AMR Read more on our website!
#' @examples
#' # `septic_patients` is a dataset available in the AMR package. It is true, genuine data.
#' # See ?septic_patients.
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
#' library(dplyr)
#' # set key antibiotics to a new variable
#' my_patients <- septic_patients %>%
#' my_patients <- example_isolates %>%
#' mutate(keyab = key_antibiotics(.)) %>%
#' mutate(
#' # now calculate first isolates

View File

@ -49,7 +49,7 @@
#' # get frequencies of bacteria whose name start with 'Ent' or 'ent'
#' library(dplyr)
#' library(clean)
#' septic_patients %>%
#' example_isolates %>%
#' left_join_microorganisms() %>%
#' filter(genus %like% '^ent') %>%
#' freq(genus, species)

View File

@ -54,7 +54,7 @@
#' @examples
#' library(dplyr)
#'
#' septic_patients %>%
#' example_isolates %>%
#' mutate(EUCAST = mdro(.),
#' BRMO = brmo(.))
mdro <- function(x,

View File

@ -86,31 +86,31 @@
#' @export
#' @inheritSection AMR Read more on our website!
#' @examples
#' # septic_patients is a data set available in the AMR package. It is true, genuine data.
#' ?septic_patients
#' # example_isolates is a data set available in the AMR package.
#' ?example_isolates
#'
#' # Calculate resistance
#' portion_R(septic_patients$AMX)
#' portion_IR(septic_patients$AMX)
#' portion_R(example_isolates$AMX)
#' portion_IR(example_isolates$AMX)
#'
#' # Or susceptibility
#' portion_S(septic_patients$AMX)
#' portion_SI(septic_patients$AMX)
#' portion_S(example_isolates$AMX)
#' portion_SI(example_isolates$AMX)
#'
#' # Do the above with pipes:
#' library(dplyr)
#' septic_patients %>% portion_R(AMX)
#' septic_patients %>% portion_IR(AMX)
#' septic_patients %>% portion_S(AMX)
#' septic_patients %>% portion_SI(AMX)
#' example_isolates %>% portion_R(AMX)
#' example_isolates %>% portion_IR(AMX)
#' example_isolates %>% portion_S(AMX)
#' example_isolates %>% portion_SI(AMX)
#'
#' septic_patients %>%
#' example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(p = portion_SI(CIP),
#' n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr
#'
#' septic_patients %>%
#' example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(R = portion_R(CIP, as_percent = TRUE),
#' I = portion_I(CIP, as_percent = TRUE),
@ -121,24 +121,24 @@
#'
#' # 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_SI(AMC) # %SI = 76.3%
#' septic_patients %>% count_all(AMC) # n = 1879
#' example_isolates %>% portion_SI(AMC) # %SI = 76.3%
#' example_isolates %>% count_all(AMC) # n = 1879
#'
#' septic_patients %>% portion_SI(GEN) # %SI = 75.4%
#' septic_patients %>% count_all(GEN) # n = 1855
#' example_isolates %>% portion_SI(GEN) # %SI = 75.4%
#' example_isolates %>% count_all(GEN) # n = 1855
#'
#' septic_patients %>% portion_SI(AMC, GEN) # %SI = 94.1%
#' septic_patients %>% count_all(AMC, GEN) # n = 1939
#' example_isolates %>% portion_SI(AMC, GEN) # %SI = 94.1%
#' example_isolates %>% count_all(AMC, GEN) # n = 1939
#'
#'
#' # See Details on how `only_all_tested` works. Example:
#' septic_patients %>%
#' example_isolates %>%
#' 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 %>%
#' example_isolates %>%
#' 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))
@ -146,7 +146,7 @@
#' # 1687 1798 0.9383
#'
#'
#' septic_patients %>%
#' example_isolates %>%
#' group_by(hospital_id) %>%
#' summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
#' cipro_n = count_all(CIP),
@ -156,12 +156,12 @@
#' combination_n = count_all(CIP, GEN))
#'
#' # Get portions S/I/R immediately of all rsi columns
#' septic_patients %>%
#' example_isolates %>%
#' select(AMX, CIP) %>%
#' portion_df(translate = FALSE)
#'
#' # It also supports grouping variables
#' septic_patients %>%
#' example_isolates %>%
#' select(hospital_id, AMX, CIP) %>%
#' group_by(hospital_id) %>%
#' portion_df(translate = FALSE)

View File

@ -61,13 +61,13 @@
#' @importFrom dplyr %>% pull mutate mutate_at n group_by_at summarise filter filter_at all_vars n_distinct arrange case_when n_groups transmute ungroup
#' @inheritSection AMR Read more on our website!
#' @examples
#' x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010, model = "binomial")
#' x <- resistance_predict(example_isolates, col_ab = "AMX", year_min = 2010, model = "binomial")
#' plot(x)
#' ggplot_rsi_predict(x)
#'
#' # use dplyr so you can actually read it:
#' library(dplyr)
#' x <- septic_patients %>%
#' x <- example_isolates %>%
#' filter_first_isolate() %>%
#' filter(mo_genus(mo) == "Staphylococcus") %>%
#' resistance_predict("PEN", model = "binomial")
@ -82,7 +82,7 @@
#' # create nice plots with ggplot2 yourself
#' if (!require(ggplot2)) {
#'
#' data <- septic_patients %>%
#' data <- example_isolates %>%
#' filter(mo == as.mo("E. coli")) %>%
#' resistance_predict(col_ab = "AMX",
#' col_date = "date",

View File

@ -79,12 +79,12 @@
#'
#' # using dplyr's mutate
#' library(dplyr)
#' septic_patients %>%
#' example_isolates %>%
#' mutate_at(vars(PEN:RIF), as.rsi)
#'
#'
#' # fastest way to transform all columns with already valid AB results to class `rsi`:
#' septic_patients %>%
#' example_isolates %>%
#' mutate_if(is.rsi.eligible,
#' as.rsi)
#'

View File

@ -67,11 +67,11 @@ rsi_calc <- function(...,
if ("data.frame" %in% class(dots_df)) {
# data.frame passed with other columns, like:
# septic_patients %>% portion_S(amcl, gent)
# example_isolates %>% portion_S(amcl, gent)
dots <- as.character(dots)
dots <- dots[dots != "."]
if (length(dots) == 0 | all(dots == "df")) {
# for complete data.frames, like septic_patients %>% select(amcl, gent) %>% portion_S()
# for complete data.frames, like example_isolates %>% select(amcl, gent) %>% portion_S()
# and the old rsi function, that has "df" as name of the first parameter
x <- dots_df
} else {
@ -79,16 +79,16 @@ rsi_calc <- function(...,
}
} else if (ndots == 1) {
# only 1 variable passed (can also be data.frame), like:
# portion_S(septic_patients$amcl)
# septic_patients$amcl %>% portion_S()
# portion_S(example_isolates$amcl)
# example_isolates$amcl %>% portion_S()
x <- dots_df
} else {
# multiple variables passed without pipe, like:
# portion_S(septic_patients$amcl, septic_patients$gent)
# portion_S(example_isolates$amcl, example_isolates$gent)
x <- NULL
try(x <- as.data.frame(dots), silent = TRUE)
if (is.null(x)) {
# support for: with(septic_patients, portion_S(amcl, gent))
# support for: with(example_isolates, portion_S(amcl, gent))
x <- as.data.frame(rlang::list2(...))
}
}

View File

@ -143,7 +143,7 @@ reference:
contents:
- "`antibiotics`"
- "`microorganisms`"
- "`septic_patients`"
- "`example_isolates`"
- "`WHONET`"
- "`microorganisms.codes`"
- "`microorganisms.old`"

BIN
data/example_isolates.rda Normal file

Binary file not shown.

Binary file not shown.

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -185,7 +185,7 @@
<h1>How to conduct AMR analysis</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">13 August 2019</h4>
<h4 class="date">27 August 2019</h4>
<div class="hidden name"><code>AMR.Rmd</code></div>
@ -194,7 +194,7 @@
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 13 August 2019.</p>
<p><strong>Note:</strong> values on this page will change with every website update since they are based on randomly created values and the page was written in <a href="https://rmarkdown.rstudio.com/">R Markdown</a>. However, the methodology remains unchanged. This page was generated on 27 August 2019.</p>
<div id="introduction" class="section level1">
<h1 class="hasAnchor">
<a href="#introduction" class="anchor"></a>Introduction</h1>
@ -210,21 +210,21 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2019-08-13</td>
<td align="center">2019-08-27</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
</tr>
<tr class="even">
<td align="center">2019-08-13</td>
<td align="center">2019-08-27</td>
<td align="center">abcd</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
</tr>
<tr class="odd">
<td align="center">2019-08-13</td>
<td align="center">2019-08-27</td>
<td align="center">efgh</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
@ -320,10 +320,54 @@
</tr></thead>
<tbody>
<tr class="odd">
<td align="center">2012-12-02</td>
<td align="center">V1</td>
<td align="center">2014-06-23</td>
<td align="center">O4</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2016-10-05</td>
<td align="center">W5</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2017-12-26</td>
<td align="center">S8</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2011-11-26</td>
<td align="center">Z1</td>
<td align="center">Hospital A</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2014-04-03</td>
<td align="center">Y7</td>
<td align="center">Hospital B</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">I</td>
<td align="center">S</td>
@ -331,59 +375,15 @@
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2014-02-14</td>
<td align="center">E4</td>
<td align="center">Hospital D</td>
<td align="center">Staphylococcus aureus</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">M</td>
</tr>
<tr class="odd">
<td align="center">2011-11-09</td>
<td align="center">E3</td>
<td align="center">Hospital A</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
</tr>
<tr class="even">
<td align="center">2011-11-19</td>
<td align="center">S8</td>
<td align="center">2012-06-06</td>
<td align="center">F9</td>
<td align="center">Hospital B</td>
<td align="center">Escherichia coli</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="odd">
<td align="center">2016-07-28</td>
<td align="center">X9</td>
<td align="center">Hospital D</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">F</td>
</tr>
<tr class="even">
<td align="center">2010-03-04</td>
<td align="center">T4</td>
<td align="center">Hospital A</td>
<td align="center">Streptococcus pneumoniae</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">M</td>
</tr>
</tbody>
</table>
@ -406,8 +406,8 @@
#
# Item Count Percent Cum. Count Cum. Percent
# --- ----- ------- -------- ----------- -------------
# 1 M 10,486 52.4% 10,486 52.4%
# 2 F 9,514 47.6% 20,000 100.0%</code></pre>
# 1 M 10,514 52.6% 10,514 52.6%
# 2 F 9,486 47.4% 20,000 100.0%</code></pre>
<p>So, we can draw at least two conclusions immediately. From a data scientists perspective, the data looks clean: only values <code>M</code> and <code>F</code>. From a researchers perspective: there are slightly more men. Nothing we didnt already know.</p>
<p>The data is already quite clean, but we still need to transform some variables. The <code>bacteria</code> column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The <code><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate()</a></code> function of the <code>dplyr</code> package makes this really easy:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb13-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span></a>
@ -437,14 +437,14 @@
<a class="sourceLine" id="cb15-18" data-line-number="18"><span class="co"># Pasteurella multocida (no changes)</span></a>
<a class="sourceLine" id="cb15-19" data-line-number="19"><span class="co"># Staphylococcus (no changes)</span></a>
<a class="sourceLine" id="cb15-20" data-line-number="20"><span class="co"># Streptococcus groups A, B, C, G (no changes)</span></a>
<a class="sourceLine" id="cb15-21" data-line-number="21"><span class="co"># Streptococcus pneumoniae (1,452 values changed)</span></a>
<a class="sourceLine" id="cb15-21" data-line-number="21"><span class="co"># Streptococcus pneumoniae (1,504 values changed)</span></a>
<a class="sourceLine" id="cb15-22" data-line-number="22"><span class="co"># Viridans group streptococci (no changes)</span></a>
<a class="sourceLine" id="cb15-23" data-line-number="23"><span class="co"># </span></a>
<a class="sourceLine" id="cb15-24" data-line-number="24"><span class="co"># EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)</span></a>
<a class="sourceLine" id="cb15-25" data-line-number="25"><span class="co"># Table 01: Intrinsic resistance in Enterobacteriaceae (1,313 values changed)</span></a>
<a class="sourceLine" id="cb15-25" data-line-number="25"><span class="co"># Table 01: Intrinsic resistance in Enterobacteriaceae (1,298 values changed)</span></a>
<a class="sourceLine" id="cb15-26" data-line-number="26"><span class="co"># Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb15-27" data-line-number="27"><span class="co"># Table 03: Intrinsic resistance in other Gram-negative bacteria (no changes)</span></a>
<a class="sourceLine" id="cb15-28" data-line-number="28"><span class="co"># Table 04: Intrinsic resistance in Gram-positive bacteria (2,715 values changed)</span></a>
<a class="sourceLine" id="cb15-28" data-line-number="28"><span class="co"># Table 04: Intrinsic resistance in Gram-positive bacteria (2,705 values changed)</span></a>
<a class="sourceLine" id="cb15-29" data-line-number="29"><span class="co"># Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)</span></a>
<a class="sourceLine" id="cb15-30" data-line-number="30"><span class="co"># Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)</span></a>
<a class="sourceLine" id="cb15-31" data-line-number="31"><span class="co"># Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)</span></a>
@ -452,24 +452,24 @@
<a class="sourceLine" id="cb15-33" data-line-number="33"><span class="co"># Table 13: Interpretive rules for quinolones (no changes)</span></a>
<a class="sourceLine" id="cb15-34" data-line-number="34"><span class="co"># </span></a>
<a class="sourceLine" id="cb15-35" data-line-number="35"><span class="co"># Other rules</span></a>
<a class="sourceLine" id="cb15-36" data-line-number="36"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,240 values changed)</span></a>
<a class="sourceLine" id="cb15-37" data-line-number="37"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (123 values changed)</span></a>
<a class="sourceLine" id="cb15-36" data-line-number="36"><span class="co"># Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (2,323 values changed)</span></a>
<a class="sourceLine" id="cb15-37" data-line-number="37"><span class="co"># Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (118 values changed)</span></a>
<a class="sourceLine" id="cb15-38" data-line-number="38"><span class="co"># Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)</span></a>
<a class="sourceLine" id="cb15-39" data-line-number="39"><span class="co"># Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)</span></a>
<a class="sourceLine" id="cb15-40" data-line-number="40"><span class="co"># Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)</span></a>
<a class="sourceLine" id="cb15-41" data-line-number="41"><span class="co"># Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)</span></a>
<a class="sourceLine" id="cb15-42" data-line-number="42"><span class="co"># </span></a>
<a class="sourceLine" id="cb15-43" data-line-number="43"><span class="co"># --------------------------------------------------------------------------</span></a>
<a class="sourceLine" id="cb15-44" data-line-number="44"><span class="co"># EUCAST rules affected 6,513 out of 20,000 rows, making a total of 7,843 edits</span></a>
<a class="sourceLine" id="cb15-44" data-line-number="44"><span class="co"># EUCAST rules affected 6,559 out of 20,000 rows, making a total of 7,948 edits</span></a>
<a class="sourceLine" id="cb15-45" data-line-number="45"><span class="co"># =&gt; added 0 test results</span></a>
<a class="sourceLine" id="cb15-46" data-line-number="46"><span class="co"># </span></a>
<a class="sourceLine" id="cb15-47" data-line-number="47"><span class="co"># =&gt; changed 7,843 test results</span></a>
<a class="sourceLine" id="cb15-48" data-line-number="48"><span class="co"># - 111 test results changed from S to I</span></a>
<a class="sourceLine" id="cb15-49" data-line-number="49"><span class="co"># - 4,735 test results changed from S to R</span></a>
<a class="sourceLine" id="cb15-50" data-line-number="50"><span class="co"># - 1,034 test results changed from I to S</span></a>
<a class="sourceLine" id="cb15-51" data-line-number="51"><span class="co"># - 316 test results changed from I to R</span></a>
<a class="sourceLine" id="cb15-52" data-line-number="52"><span class="co"># - 1,612 test results changed from R to S</span></a>
<a class="sourceLine" id="cb15-53" data-line-number="53"><span class="co"># - 35 test results changed from R to I</span></a>
<a class="sourceLine" id="cb15-47" data-line-number="47"><span class="co"># =&gt; changed 7,948 test results</span></a>
<a class="sourceLine" id="cb15-48" data-line-number="48"><span class="co"># - 115 test results changed from S to I</span></a>
<a class="sourceLine" id="cb15-49" data-line-number="49"><span class="co"># - 4,723 test results changed from S to R</span></a>
<a class="sourceLine" id="cb15-50" data-line-number="50"><span class="co"># - 1,098 test results changed from I to S</span></a>
<a class="sourceLine" id="cb15-51" data-line-number="51"><span class="co"># - 338 test results changed from I to R</span></a>
<a class="sourceLine" id="cb15-52" data-line-number="52"><span class="co"># - 1,648 test results changed from R to S</span></a>
<a class="sourceLine" id="cb15-53" data-line-number="53"><span class="co"># - 26 test results changed from R to I</span></a>
<a class="sourceLine" id="cb15-54" data-line-number="54"><span class="co"># --------------------------------------------------------------------------</span></a>
<a class="sourceLine" id="cb15-55" data-line-number="55"><span class="co"># </span></a>
<a class="sourceLine" id="cb15-56" data-line-number="56"><span class="co"># Use eucast_rules(..., verbose = TRUE) (on your original data) to get a data.frame with all specified edits instead.</span></a></code></pre></div>
@ -497,7 +497,7 @@
<a class="sourceLine" id="cb17-3" data-line-number="3"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `bacteria` as input for `col_mo`.</span></a>
<a class="sourceLine" id="cb17-4" data-line-number="4"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `date` as input for `col_date`.</span></a>
<a class="sourceLine" id="cb17-5" data-line-number="5"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb17-6" data-line-number="6"><span class="co"># =&gt; Found 5,643 first isolates (28.2% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb17-6" data-line-number="6"><span class="co"># =&gt; Found 5,672 first isolates (28.4% of total)</span></a></code></pre></div>
<p>So only is suitable for resistance analysis! We can now filter on it with the <code><a href="https://dplyr.tidyverse.org/reference/filter.html">filter()</a></code> function, also from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb18-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb18-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(first <span class="op">==</span><span class="st"> </span><span class="ot">TRUE</span>)</a></code></pre></div>
@ -508,7 +508,7 @@
<div id="first-weighted-isolates" class="section level2">
<h2 class="hasAnchor">
<a href="#first-weighted-isolates" class="anchor"></a>First <em>weighted</em> isolates</h2>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient Q10, sorted on date:</p>
<p>We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient K7, sorted on date:</p>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -524,32 +524,32 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-01-12</td>
<td align="center">Q10</td>
<td align="center">2010-02-15</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-01-16</td>
<td align="center">Q10</td>
<td align="center">2010-03-24</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-03-09</td>
<td align="center">Q10</td>
<td align="center">2010-06-05</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -557,21 +557,21 @@
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-03-31</td>
<td align="center">Q10</td>
<td align="center">2010-07-16</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-04-06</td>
<td align="center">Q10</td>
<td align="center">2010-09-22</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -579,8 +579,8 @@
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-05-24</td>
<td align="center">Q10</td>
<td align="center">2011-01-18</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -590,8 +590,8 @@
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-05-25</td>
<td align="center">Q10</td>
<td align="center">2011-01-26</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -601,32 +601,32 @@
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-07-08</td>
<td align="center">Q10</td>
<td align="center">2011-02-11</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-10-22</td>
<td align="center">Q10</td>
<td align="center">2011-02-17</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-11-30</td>
<td align="center">Q10</td>
<td align="center">2011-04-01</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -634,7 +634,7 @@
</tr>
</tbody>
</table>
<p>Only 1 isolates are marked as first according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>Only 2 isolates are marked as first according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The <code><a href="../reference/key_antibiotics.html">key_antibiotics()</a></code> function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.</p>
<p>If a column exists with a name like key(…)ab the <code><a href="../reference/first_isolate.html">first_isolate()</a></code> function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:</p>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb20-1" data-line-number="1">data &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb20-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/mutate.html">mutate</a></span>(<span class="dt">keyab =</span> <span class="kw"><a href="../reference/key_antibiotics.html">key_antibiotics</a></span>(.)) <span class="op">%&gt;%</span><span class="st"> </span></a>
@ -645,7 +645,7 @@
<a class="sourceLine" id="cb20-7" data-line-number="7"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `patient_id` as input for `col_patient_id`.</span></a>
<a class="sourceLine" id="cb20-8" data-line-number="8"><span class="co"># </span><span class="al">NOTE</span><span class="co">: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.</span></a>
<a class="sourceLine" id="cb20-9" data-line-number="9"><span class="co"># [Criterion] Inclusion based on key antibiotics, ignoring I.</span></a>
<a class="sourceLine" id="cb20-10" data-line-number="10"><span class="co"># =&gt; Found 15,004 first weighted isolates (75.0% of total)</span></a></code></pre></div>
<a class="sourceLine" id="cb20-10" data-line-number="10"><span class="co"># =&gt; Found 15,107 first weighted isolates (75.5% of total)</span></a></code></pre></div>
<table class="table">
<thead><tr class="header">
<th align="center">isolate</th>
@ -662,11 +662,11 @@
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2010-01-12</td>
<td align="center">Q10</td>
<td align="center">2010-02-15</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">TRUE</td>
@ -674,11 +674,11 @@
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2010-01-16</td>
<td align="center">Q10</td>
<td align="center">2010-03-24</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">FALSE</td>
@ -686,10 +686,10 @@
</tr>
<tr class="odd">
<td align="center">3</td>
<td align="center">2010-03-09</td>
<td align="center">Q10</td>
<td align="center">2010-06-05</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
@ -698,20 +698,32 @@
</tr>
<tr class="even">
<td align="center">4</td>
<td align="center">2010-03-31</td>
<td align="center">Q10</td>
<td align="center">2010-07-16</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-09-22</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">5</td>
<td align="center">2010-04-06</td>
<td align="center">Q10</td>
<tr class="even">
<td align="center">6</td>
<td align="center">2011-01-18</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -720,22 +732,10 @@
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">6</td>
<td align="center">2010-05-24</td>
<td align="center">Q10</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">FALSE</td>
</tr>
<tr class="odd">
<td align="center">7</td>
<td align="center">2010-05-25</td>
<td align="center">Q10</td>
<td align="center">2011-01-26</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -746,34 +746,34 @@
</tr>
<tr class="even">
<td align="center">8</td>
<td align="center">2010-07-08</td>
<td align="center">Q10</td>
<td align="center">2011-02-11</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td align="center">9</td>
<td align="center">2010-10-22</td>
<td align="center">Q10</td>
<td align="center">2011-02-17</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">I</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">FALSE</td>
<td align="center">TRUE</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td align="center">10</td>
<td align="center">2010-11-30</td>
<td align="center">Q10</td>
<td align="center">2011-04-01</td>
<td align="center">K7</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
@ -782,11 +782,11 @@
</tr>
</tbody>
</table>
<p>Instead of 1, now 6 isolates are flagged. In total, of all isolates are marked first weighted - more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>Instead of 2, now 7 isolates are flagged. In total, of all isolates are marked first weighted - more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.</p>
<p>As with <code><a href="../reference/first_isolate.html">filter_first_isolate()</a></code>, theres a shortcut for this new algorithm too:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb21-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb21-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="../reference/first_isolate.html">filter_first_weighted_isolate</a></span>()</a></code></pre></div>
<p>So we end up with 15,004 isolates for analysis.</p>
<p>So we end up with 15,107 isolates for analysis.</p>
<p>We can remove unneeded columns:</p>
<div class="sourceCode" id="cb22"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb22-1" data-line-number="1">data_1st &lt;-<span class="st"> </span>data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb22-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(<span class="op">-</span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(first, keyab))</a></code></pre></div>
@ -811,26 +811,10 @@
</tr></thead>
<tbody>
<tr class="odd">
<td>2</td>
<td align="center">2014-02-14</td>
<td align="center">E4</td>
<td align="center">Hospital D</td>
<td align="center">B_STPHY_AUR</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>4</td>
<td align="center">2011-11-19</td>
<td align="center">S8</td>
<td align="center">Hospital B</td>
<td>1</td>
<td align="center">2014-06-23</td>
<td align="center">O4</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
@ -842,68 +826,84 @@
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>2</td>
<td align="center">2016-10-05</td>
<td align="center">W5</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>5</td>
<td align="center">2016-07-28</td>
<td align="center">X9</td>
<td align="center">Hospital D</td>
<td align="center">B_STRPT_PNE</td>
<td>3</td>
<td align="center">2017-12-26</td>
<td align="center">S8</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>6</td>
<td align="center">2010-03-04</td>
<td align="center">T4</td>
<td align="center">Hospital A</td>
<td align="center">B_STRPT_PNE</td>
<td>5</td>
<td align="center">2014-04-03</td>
<td align="center">Y7</td>
<td align="center">Hospital B</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">F</td>
<td align="center">Gram-positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="odd">
<td>7</td>
<td align="center">2012-10-22</td>
<td align="center">Q6</td>
<td align="center">Hospital A</td>
<td align="center">B_ESCHR_COL</td>
<td align="center">2011-05-16</td>
<td align="center">I8</td>
<td align="center">Hospital D</td>
<td align="center">B_KLBSL_PNE</td>
<td align="center">R</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">M</td>
<td align="center">Gram-negative</td>
<td align="center">Klebsiella</td>
<td align="center">pneumoniae</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>8</td>
<td align="center">2014-12-28</td>
<td align="center">Z2</td>
<td align="center">Hospital B</td>
<td align="center">B_STPHY_AUR</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">F</td>
<td align="center">Gram-negative</td>
<td align="center">Escherichia</td>
<td align="center">coli</td>
<td align="center">TRUE</td>
</tr>
<tr class="even">
<td>8</td>
<td align="center">2016-12-06</td>
<td align="center">B2</td>
<td align="center">Hospital B</td>
<td align="center">B_STRPT_PNE</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">S</td>
<td align="center">R</td>
<td align="center">M</td>
<td align="center">Gram-positive</td>
<td align="center">Streptococcus</td>
<td align="center">pneumoniae</td>
<td align="center">Staphylococcus</td>
<td align="center">aureus</td>
<td align="center">TRUE</td>
</tr>
</tbody>
@ -925,7 +925,7 @@
<div class="sourceCode" id="cb25"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb25-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/clean/topics/freq">freq</a></span>(genus, species)</a></code></pre></div>
<p><strong>Frequency table</strong></p>
<p>Class: character<br>
Length: 15,004 (of which NA: 0 = 0.00%)<br>
Length: 15,107 (of which NA: 0 = 0.00%)<br>
Unique: 4</p>
<p>Shortest: 16<br>
Longest: 24</p>
@ -942,33 +942,33 @@ Longest: 24</p>
<tr class="odd">
<td align="left">1</td>
<td align="left">Escherichia coli</td>
<td align="right">7,359</td>
<td align="right">49.0%</td>
<td align="right">7,359</td>
<td align="right">49.0%</td>
<td align="right">7,471</td>
<td align="right">49.5%</td>
<td align="right">7,471</td>
<td align="right">49.5%</td>
</tr>
<tr class="even">
<td align="left">2</td>
<td align="left">Staphylococcus aureus</td>
<td align="right">3,800</td>
<td align="right">25.3%</td>
<td align="right">11,159</td>
<td align="right">74.4%</td>
<td align="right">3,789</td>
<td align="right">25.1%</td>
<td align="right">11,260</td>
<td align="right">74.5%</td>
</tr>
<tr class="odd">
<td align="left">3</td>
<td align="left">Streptococcus pneumoniae</td>
<td align="right">2,272</td>
<td align="right">15.1%</td>
<td align="right">13,431</td>
<td align="right">89.5%</td>
<td align="right">2,296</td>
<td align="right">15.2%</td>
<td align="right">13,556</td>
<td align="right">89.7%</td>
</tr>
<tr class="even">
<td align="left">4</td>
<td align="left">Klebsiella pneumoniae</td>
<td align="right">1,573</td>
<td align="right">10.5%</td>
<td align="right">15,004</td>
<td align="right">1,551</td>
<td align="right">10.3%</td>
<td align="right">15,107</td>
<td align="right">100.0%</td>
</tr>
</tbody>
@ -979,7 +979,7 @@ Longest: 24</p>
<a href="#resistance-percentages" class="anchor"></a>Resistance percentages</h2>
<p>The functions <code><a href="../reference/portion.html">portion_S()</a></code>, <code><a href="../reference/portion.html">portion_SI()</a></code>, <code><a href="../reference/portion.html">portion_I()</a></code>, <code><a href="../reference/portion.html">portion_IR()</a></code> and <code><a href="../reference/portion.html">portion_R()</a></code> can be used to determine the portion of a specific antimicrobial outcome. As per the EUCAST guideline of 2019, we calculate resistance as the portion of R (<code><a href="../reference/portion.html">portion_R()</a></code>) and susceptibility as the portion of S and I (<code><a href="../reference/portion.html">portion_SI()</a></code>). These functions can be used on their own:</p>
<div class="sourceCode" id="cb26"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb26-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span><span class="kw"><a href="../reference/portion.html">portion_R</a></span>(AMX)</a>
<a class="sourceLine" id="cb26-2" data-line-number="2"><span class="co"># [1] 0.4674753</span></a></code></pre></div>
<a class="sourceLine" id="cb26-2" data-line-number="2"><span class="co"># [1] 0.4685245</span></a></code></pre></div>
<p>Or can be used in conjuction with <code><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by()</a></code> and <code><a href="https://dplyr.tidyverse.org/reference/summarise.html">summarise()</a></code>, both from the <code>dplyr</code> package:</p>
<div class="sourceCode" id="cb27"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb27-1" data-line-number="1">data_1st <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb27-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital) <span class="op">%&gt;%</span><span class="st"> </span></a>
@ -992,19 +992,19 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4635820</td>
<td align="center">0.4686054</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4720092</td>
<td align="center">0.4644004</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4717477</td>
<td align="center">0.4821269</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4621821</td>
<td align="center">0.4655684</td>
</tr>
</tbody>
</table>
@ -1022,23 +1022,23 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Hospital A</td>
<td align="center">0.4635820</td>
<td align="center">4517</td>
<td align="center">0.4686054</td>
<td align="center">4539</td>
</tr>
<tr class="even">
<td align="center">Hospital B</td>
<td align="center">0.4720092</td>
<td align="center">5216</td>
<td align="center">0.4644004</td>
<td align="center">5295</td>
</tr>
<tr class="odd">
<td align="center">Hospital C</td>
<td align="center">0.4717477</td>
<td align="center">2283</td>
<td align="center">0.4821269</td>
<td align="center">2238</td>
</tr>
<tr class="even">
<td align="center">Hospital D</td>
<td align="center">0.4621821</td>
<td align="center">2988</td>
<td align="center">0.4655684</td>
<td align="center">3035</td>
</tr>
</tbody>
</table>
@ -1058,27 +1058,27 @@ Longest: 24</p>
<tbody>
<tr class="odd">
<td align="center">Escherichia</td>
<td align="center">0.9244463</td>
<td align="center">0.8884359</td>
<td align="center">0.9930697</td>
<td align="center">0.9243742</td>
<td align="center">0.8933208</td>
<td align="center">0.9950475</td>
</tr>
<tr class="even">
<td align="center">Klebsiella</td>
<td align="center">0.8207247</td>
<td align="center">0.9052765</td>
<td align="center">0.9860140</td>
<td align="center">0.8149581</td>
<td align="center">0.8884591</td>
<td align="center">0.9787234</td>
</tr>
<tr class="odd">
<td align="center">Staphylococcus</td>
<td align="center">0.9189474</td>
<td align="center">0.9250000</td>
<td align="center">0.9934211</td>
<td align="center">0.9192399</td>
<td align="center">0.9160728</td>
<td align="center">0.9912906</td>
</tr>
<tr class="even">
<td align="center">Streptococcus</td>
<td align="center">0.6126761</td>
<td align="center">0.5997387</td>
<td align="center">0.0000000</td>
<td align="center">0.6126761</td>
<td align="center">0.5997387</td>
</tr>
</tbody>
</table>
@ -1151,9 +1151,9 @@ Longest: 24</p>
<div id="independence-test" class="section level2">
<h2 class="hasAnchor">
<a href="#independence-test" class="anchor"></a>Independence test</h2>
<p>The next example uses the included <code>septic_patients</code>, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This <code>data.frame</code> can be used to practice AMR analysis.</p>
<p>The next example uses the included <code>example_isolates</code>, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This <code>data.frame</code> can be used to practice AMR analysis.</p>
<p>We will compare the resistance to fosfomycin (column <code>FOS</code>) in hospital A and D. The input for the <code><a href="https://www.rdocumentation.org/packages/stats/topics/fisher.test">fisher.test()</a></code> can be retrieved with a transformation like this:</p>
<div class="sourceCode" id="cb35"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb35-1" data-line-number="1">check_FOS &lt;-<span class="st"> </span>septic_patients <span class="op">%&gt;%</span></a>
<div class="sourceCode" id="cb35"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb35-1" data-line-number="1">check_FOS &lt;-<span class="st"> </span>example_isolates <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb35-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(hospital_id <span class="op">%in%</span><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="st">"A"</span>, <span class="st">"D"</span>)) <span class="op">%&gt;%</span><span class="st"> </span><span class="co"># filter on only hospitals A and D</span></a>
<a class="sourceLine" id="cb35-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/select.html">select</a></span>(hospital_id, FOS) <span class="op">%&gt;%</span><span class="st"> </span><span class="co"># select the hospitals and fosfomycin</span></a>
<a class="sourceLine" id="cb35-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/group_by.html">group_by</a></span>(hospital_id) <span class="op">%&gt;%</span><span class="st"> </span><span class="co"># group on the hospitals</span></a>
@ -1226,7 +1226,7 @@ Longest: 24</p>
<footer><div class="copyright">
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

After

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -185,7 +185,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">13 August 2019</h4>
<h4 class="date">27 August 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -211,13 +211,13 @@
<a class="sourceLine" id="cb2-9" data-line-number="9"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb2-10" data-line-number="10"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb2-11" data-line-number="11"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb2-12" data-line-number="12"><span class="co"># as.mo("sau") 8.6 8.9 11.0 9.4 9.7 26.0 10</span></a>
<a class="sourceLine" id="cb2-13" data-line-number="13"><span class="co"># as.mo("stau") 32.0 33.0 43.0 42.0 52.0 56.0 10</span></a>
<a class="sourceLine" id="cb2-14" data-line-number="14"><span class="co"># as.mo("staaur") 8.5 8.8 11.0 9.3 11.0 26.0 10</span></a>
<a class="sourceLine" id="cb2-15" data-line-number="15"><span class="co"># as.mo("STAAUR") 8.7 8.8 9.3 9.3 9.7 10.0 10</span></a>
<a class="sourceLine" id="cb2-16" data-line-number="16"><span class="co"># as.mo("S. aureus") 23.0 24.0 28.0 25.0 26.0 45.0 10</span></a>
<a class="sourceLine" id="cb2-17" data-line-number="17"><span class="co"># as.mo("S. aureus") 23.0 24.0 34.0 25.0 25.0 120.0 10</span></a>
<a class="sourceLine" id="cb2-18" data-line-number="18"><span class="co"># as.mo("Staphylococcus aureus") 4.1 4.2 4.3 4.3 4.5 4.7 10</span></a></code></pre></div>
<a class="sourceLine" id="cb2-12" data-line-number="12"><span class="co"># as.mo("sau") 8.1 8.1 8.3 8.3 8.4 8.6 10</span></a>
<a class="sourceLine" id="cb2-13" data-line-number="13"><span class="co"># as.mo("stau") 31.0 31.0 48.0 40.0 48.0 130.0 10</span></a>
<a class="sourceLine" id="cb2-14" data-line-number="14"><span class="co"># as.mo("staaur") 8.1 8.3 10.0 8.4 8.6 24.0 10</span></a>
<a class="sourceLine" id="cb2-15" data-line-number="15"><span class="co"># as.mo("STAAUR") 8.1 8.1 12.0 8.4 9.2 28.0 10</span></a>
<a class="sourceLine" id="cb2-16" data-line-number="16"><span class="co"># as.mo("S. aureus") 22.0 23.0 26.0 23.0 24.0 40.0 10</span></a>
<a class="sourceLine" id="cb2-17" data-line-number="17"><span class="co"># as.mo("S. aureus") 22.0 23.0 23.0 23.0 23.0 24.0 10</span></a>
<a class="sourceLine" id="cb2-18" data-line-number="18"><span class="co"># as.mo("Staphylococcus aureus") 3.6 3.8 4.0 3.9 4.0 5.2 10</span></a></code></pre></div>
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.</p>
<p>To achieve this speed, the <code>as.mo</code> function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of <em>Thermus islandicus</em> (<code>B_THERMS_ISL</code>), a bug probably never found before in humans:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb3-1" data-line-number="1">T.islandicus &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="kw"><a href="../reference/as.mo.html">as.mo</a></span>(<span class="st">"theisl"</span>),</a>
@ -229,12 +229,12 @@
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(T.islandicus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb3-9" data-line-number="9"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># as.mo("theisl") 280 290 300 310 310 320 10</span></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># as.mo("THEISL") 280 300 310 310 320 330 10</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># as.mo("T. islandicus") 140 150 160 160 170 180 10</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># as.mo("T. islandicus") 140 150 160 160 160 170 10</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># as.mo("Thermus islandicus") 50 53 69 57 74 140 10</span></a></code></pre></div>
<p>That takes 9.8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<a class="sourceLine" id="cb3-10" data-line-number="10"><span class="co"># as.mo("theisl") 260 270 280 280 290 300 10</span></a>
<a class="sourceLine" id="cb3-11" data-line-number="11"><span class="co"># as.mo("THEISL") 260 280 300 290 300 370 10</span></a>
<a class="sourceLine" id="cb3-12" data-line-number="12"><span class="co"># as.mo("T. islandicus") 130 140 140 140 150 150 10</span></a>
<a class="sourceLine" id="cb3-13" data-line-number="13"><span class="co"># as.mo("T. islandicus") 130 130 130 130 140 150 10</span></a>
<a class="sourceLine" id="cb3-14" data-line-number="14"><span class="co"># as.mo("Thermus islandicus") 47 48 53 50 52 71 10</span></a></code></pre></div>
<p>That takes 9.6 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Thermus islandicus</em>) are almost fast - these are the most probable input from most data sets.</p>
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Thermus islandicus</em> (which is very uncommon):</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/graphics/topics/par">par</a></span>(<span class="dt">mar =</span> <span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/c">c</a></span>(<span class="dv">5</span>, <span class="dv">16</span>, <span class="dv">4</span>, <span class="dv">2</span>)) <span class="co"># set more space for left margin text (16)</span></a>
<a class="sourceLine" id="cb4-2" data-line-number="2"></a>
@ -255,8 +255,8 @@
<a href="#repetitive-results" class="anchor"></a>Repetitive results</h3>
<p>Repetitive results are unique values that are present more than once. Unique values will only be calculated once by <code><a href="../reference/as.mo.html">as.mo()</a></code>. We will use <code><a href="../reference/mo_property.html">mo_name()</a></code> for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses <code><a href="../reference/as.mo.html">as.mo()</a></code> internally.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb5-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/library">library</a></span>(dplyr)</a>
<a class="sourceLine" id="cb5-2" data-line-number="2"><span class="co"># take all MO codes from the septic_patients data set</span></a>
<a class="sourceLine" id="cb5-3" data-line-number="3">x &lt;-<span class="st"> </span>septic_patients<span class="op">$</span>mo <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb5-2" data-line-number="2"><span class="co"># take all MO codes from the example_isolates data set</span></a>
<a class="sourceLine" id="cb5-3" data-line-number="3">x &lt;-<span class="st"> </span>example_isolates<span class="op">$</span>mo <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb5-4" data-line-number="4"><span class="st"> </span><span class="co"># keep only the unique ones</span></a>
<a class="sourceLine" id="cb5-5" data-line-number="5"><span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/unique">unique</a></span>() <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb5-6" data-line-number="6"><span class="st"> </span><span class="co"># pick 50 of them at random</span></a>
@ -280,8 +280,8 @@
<a class="sourceLine" id="cb5-24" data-line-number="24"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb5-25" data-line-number="25"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb5-26" data-line-number="26"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb5-27" data-line-number="27"><span class="co"># mo_name(x) 641 673 690 684 701 775 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.68 seconds (684 ms). You only lose time on your unique input values.</p>
<a class="sourceLine" id="cb5-27" data-line-number="27"><span class="co"># mo_name(x) 611 618 646 642 656 720 10</span></a></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.64 seconds (641 ms). You only lose time on your unique input values.</p>
</div>
<div id="precalculated-results" class="section level3">
<h3 class="hasAnchor">
@ -294,10 +294,10 @@
<a class="sourceLine" id="cb6-5" data-line-number="5"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb6-6" data-line-number="6"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb6-7" data-line-number="7"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb6-8" data-line-number="8"><span class="co"># A 6.760 7.320 7.630 7.54 8.070 8.500 10</span></a>
<a class="sourceLine" id="cb6-9" data-line-number="9"><span class="co"># B 23.800 25.300 28.500 25.50 26.100 50.100 10</span></a>
<a class="sourceLine" id="cb6-10" data-line-number="10"><span class="co"># C 0.906 0.911 0.941 0.93 0.969 0.991 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0009 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<a class="sourceLine" id="cb6-8" data-line-number="8"><span class="co"># A 6.440 6.690 9.070 7.040 7.500 27.800 10</span></a>
<a class="sourceLine" id="cb6-9" data-line-number="9"><span class="co"># B 21.800 22.200 23.600 23.400 23.800 30.200 10</span></a>
<a class="sourceLine" id="cb6-10" data-line-number="10"><span class="co"># C 0.661 0.826 0.844 0.836 0.928 0.936 10</span></a></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0008 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb7-1" data-line-number="1">run_it &lt;-<span class="st"> </span><span class="kw"><a href="https://www.rdocumentation.org/packages/microbenchmark/topics/microbenchmark">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</a>
<a class="sourceLine" id="cb7-2" data-line-number="2"> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</a>
<a class="sourceLine" id="cb7-3" data-line-number="3"> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),</a>
@ -310,14 +310,14 @@
<a class="sourceLine" id="cb7-10" data-line-number="10"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</a>
<a class="sourceLine" id="cb7-11" data-line-number="11"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb7-12" data-line-number="12"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb7-13" data-line-number="13"><span class="co"># A 0.464 0.465 0.484 0.482 0.485 0.528 10</span></a>
<a class="sourceLine" id="cb7-14" data-line-number="14"><span class="co"># B 0.621 0.632 0.659 0.636 0.650 0.784 10</span></a>
<a class="sourceLine" id="cb7-15" data-line-number="15"><span class="co"># C 0.673 0.749 0.785 0.788 0.826 0.918 10</span></a>
<a class="sourceLine" id="cb7-16" data-line-number="16"><span class="co"># D 0.446 0.451 0.477 0.467 0.474 0.586 10</span></a>
<a class="sourceLine" id="cb7-17" data-line-number="17"><span class="co"># E 0.442 0.456 0.481 0.464 0.469 0.648 10</span></a>
<a class="sourceLine" id="cb7-18" data-line-number="18"><span class="co"># F 0.442 0.459 0.470 0.466 0.490 0.494 10</span></a>
<a class="sourceLine" id="cb7-19" data-line-number="19"><span class="co"># G 0.446 0.449 0.469 0.471 0.481 0.499 10</span></a>
<a class="sourceLine" id="cb7-20" data-line-number="20"><span class="co"># H 0.445 0.452 0.466 0.458 0.463 0.522 10</span></a></code></pre></div>
<a class="sourceLine" id="cb7-13" data-line-number="13"><span class="co"># A 0.468 0.472 0.483 0.483 0.487 0.520 10</span></a>
<a class="sourceLine" id="cb7-14" data-line-number="14"><span class="co"># B 0.619 0.621 0.649 0.648 0.656 0.698 10</span></a>
<a class="sourceLine" id="cb7-15" data-line-number="15"><span class="co"># C 0.702 0.732 0.770 0.788 0.799 0.809 10</span></a>
<a class="sourceLine" id="cb7-16" data-line-number="16"><span class="co"># D 0.456 0.457 0.487 0.466 0.475 0.684 10</span></a>
<a class="sourceLine" id="cb7-17" data-line-number="17"><span class="co"># E 0.451 0.463 0.466 0.466 0.471 0.479 10</span></a>
<a class="sourceLine" id="cb7-18" data-line-number="18"><span class="co"># F 0.437 0.457 0.464 0.463 0.469 0.497 10</span></a>
<a class="sourceLine" id="cb7-19" data-line-number="19"><span class="co"># G 0.450 0.454 0.468 0.466 0.477 0.495 10</span></a>
<a class="sourceLine" id="cb7-20" data-line-number="20"><span class="co"># H 0.454 0.458 0.471 0.464 0.471 0.510 10</span></a></code></pre></div>
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> too, there is no point in calculating the result. And because this package knows all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.</p>
</div>
<div id="results-in-other-languages" class="section level3">
@ -344,13 +344,13 @@
<a class="sourceLine" id="cb8-18" data-line-number="18"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/print">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</a>
<a class="sourceLine" id="cb8-19" data-line-number="19"><span class="co"># Unit: milliseconds</span></a>
<a class="sourceLine" id="cb8-20" data-line-number="20"><span class="co"># expr min lq mean median uq max neval</span></a>
<a class="sourceLine" id="cb8-21" data-line-number="21"><span class="co"># en 18.92 19.31 19.46 19.45 19.65 20.00 10</span></a>
<a class="sourceLine" id="cb8-22" data-line-number="22"><span class="co"># de 20.65 20.85 21.77 21.28 22.33 25.34 10</span></a>
<a class="sourceLine" id="cb8-23" data-line-number="23"><span class="co"># nl 26.17 26.78 32.00 28.27 31.87 49.90 10</span></a>
<a class="sourceLine" id="cb8-24" data-line-number="24"><span class="co"># es 19.94 20.45 23.13 20.95 22.09 40.02 10</span></a>
<a class="sourceLine" id="cb8-25" data-line-number="25"><span class="co"># it 20.43 20.65 23.48 21.71 22.62 40.72 10</span></a>
<a class="sourceLine" id="cb8-26" data-line-number="26"><span class="co"># fr 20.28 20.69 22.35 21.09 21.32 31.54 10</span></a>
<a class="sourceLine" id="cb8-27" data-line-number="27"><span class="co"># pt 19.92 20.28 23.24 21.67 22.46 41.19 10</span></a></code></pre></div>
<a class="sourceLine" id="cb8-21" data-line-number="21"><span class="co"># en 17.37 18.13 21.04 18.34 20.65 35.24 10</span></a>
<a class="sourceLine" id="cb8-22" data-line-number="22"><span class="co"># de 18.69 19.32 19.49 19.44 19.77 20.06 10</span></a>
<a class="sourceLine" id="cb8-23" data-line-number="23"><span class="co"># nl 24.85 25.07 27.07 25.37 25.58 42.68 10</span></a>
<a class="sourceLine" id="cb8-24" data-line-number="24"><span class="co"># es 18.96 19.55 23.91 19.88 21.02 41.15 10</span></a>
<a class="sourceLine" id="cb8-25" data-line-number="25"><span class="co"># it 18.85 19.34 21.08 19.52 20.22 35.18 10</span></a>
<a class="sourceLine" id="cb8-26" data-line-number="26"><span class="co"># fr 18.80 19.32 21.40 19.56 20.29 37.00 10</span></a>
<a class="sourceLine" id="cb8-27" data-line-number="27"><span class="co"># pt 18.81 19.45 19.57 19.59 19.64 20.20 10</span></a></code></pre></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div>
</div>
@ -362,7 +362,7 @@
<footer><div class="copyright">
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 82 KiB

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -185,7 +185,7 @@
<h1>How to predict antimicrobial resistance</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">13 August 2019</h4>
<h4 class="date">27 August 2019</h4>
<div class="hidden name"><code>resistance_predict.Rmd</code></div>
@ -212,15 +212,15 @@
<p>Our package contains a function <code><a href="../reference/resistance_predict.html">resistance_predict()</a></code>, which takes the same input as functions for <a href="./AMR.html">other AMR analysis</a>. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.</p>
<p>It is basically as easy as:</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb2-1" data-line-number="1"><span class="co"># resistance prediction of piperacillin/tazobactam (TZP):</span></a>
<a class="sourceLine" id="cb2-2" data-line-number="2"><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">tbl =</span> septic_patients, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"TZP"</span>, <span class="dt">model =</span> <span class="st">"binomial"</span>)</a>
<a class="sourceLine" id="cb2-2" data-line-number="2"><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">tbl =</span> example_isolates, <span class="dt">col_date =</span> <span class="st">"date"</span>, <span class="dt">col_ab =</span> <span class="st">"TZP"</span>, <span class="dt">model =</span> <span class="st">"binomial"</span>)</a>
<a class="sourceLine" id="cb2-3" data-line-number="3"></a>
<a class="sourceLine" id="cb2-4" data-line-number="4"><span class="co"># or:</span></a>
<a class="sourceLine" id="cb2-5" data-line-number="5">septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-5" data-line-number="5">example_isolates <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-6" data-line-number="6"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>,</a>
<a class="sourceLine" id="cb2-7" data-line-number="7"> model <span class="st">"binomial"</span>)</a>
<a class="sourceLine" id="cb2-8" data-line-number="8"></a>
<a class="sourceLine" id="cb2-9" data-line-number="9"><span class="co"># to bind it to object 'predict_TZP' for example:</span></a>
<a class="sourceLine" id="cb2-10" data-line-number="10">predict_TZP &lt;-<span class="st"> </span>septic_patients <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-10" data-line-number="10">predict_TZP &lt;-<span class="st"> </span>example_isolates <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb2-11" data-line-number="11"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"TZP"</span>,</a>
<a class="sourceLine" id="cb2-12" data-line-number="12"> <span class="dt">model =</span> <span class="st">"binomial"</span>)</a></code></pre></div>
<p>The function will look for a date column itself if <code>col_date</code> is not set.</p>
@ -296,7 +296,7 @@
<h3 class="hasAnchor">
<a href="#choosing-the-right-model" class="anchor"></a>Choosing the right model</h3>
<p>Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span></a>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb8-1" data-line-number="1">example_isolates <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo, <span class="dt">language =</span> <span class="ot">NULL</span>) <span class="op">==</span><span class="st"> "Gram-positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb8-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"VAN"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"binomial"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb8-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
@ -341,7 +341,7 @@
</tbody>
</table>
<p>For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1">septic_patients <span class="op">%&gt;%</span></a>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb9-1" data-line-number="1">example_isolates <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-2" data-line-number="2"><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/filter.html">filter</a></span>(<span class="kw"><a href="../reference/mo_property.html">mo_gramstain</a></span>(mo, <span class="dt">language =</span> <span class="ot">NULL</span>) <span class="op">==</span><span class="st"> "Gram-positive"</span>) <span class="op">%&gt;%</span></a>
<a class="sourceLine" id="cb9-3" data-line-number="3"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">resistance_predict</a></span>(<span class="dt">col_ab =</span> <span class="st">"VAN"</span>, <span class="dt">year_min =</span> <span class="dv">2010</span>, <span class="dt">info =</span> <span class="ot">FALSE</span>, <span class="dt">model =</span> <span class="st">"linear"</span>) <span class="op">%&gt;%</span><span class="st"> </span></a>
<a class="sourceLine" id="cb9-4" data-line-number="4"><span class="st"> </span><span class="kw"><a href="../reference/resistance_predict.html">ggplot_rsi_predict</a></span>()</a>
@ -379,7 +379,7 @@
<footer><div class="copyright">
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>
<p>Developed by <a href="https://www.rug.nl/staff/m.s.berends/">Matthijs S. Berends</a>, <a href="https://www.rug.nl/staff/c.f.luz/">Christian F. Luz</a>, <a href="https://www.rug.nl/staff/a.w.friedrich/">Alex W. Friedrich</a>, <a href="https://www.rug.nl/staff/b.sinha/">Bhanu N. M. Sinha</a>, <a href="https://www.rug.nl/staff/c.j.albers/">Casper J. Albers</a>, <a href="https://www.rug.nl/staff/c.glasner/">Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>

View File

@ -42,7 +42,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -341,7 +341,7 @@
<li>Aside from this website with many tutorials, the package itself contains extensive help pages with many examples for all functions.</li>
<li>The package also contains example data sets:
<ul>
<li>The <a href="./reference/septic_patients.html"><code>septic_patients</code> data set</a>. This data set contains:
<li>The <a href="./reference/example_isolates.html"><code>example_isolates</code> data set</a>. This data set contains:
<ul>
<li>2,000 blood culture isolates from anonymised septic patients between 2001 and 2017 in the Northern Netherlands</li>
<li>Results of 40 antibiotics (each antibiotic in its own column) with a total ~40,000 antimicrobial results</li>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -225,9 +225,9 @@
</div>
<div id="amr-0-7-1-9062" class="section level1">
<div id="amr-0-7-1-9063" class="section level1">
<h1 class="page-header">
<a href="#amr-0-7-1-9062" class="anchor"></a>AMR 0.7.1.9062<small> Unreleased </small>
<a href="#amr-0-7-1-9063" class="anchor"></a>AMR 0.7.1.9063<small> Unreleased </small>
</h1>
<div id="breaking" class="section level3">
<h3 class="hasAnchor">
@ -269,7 +269,7 @@ This is important, because a value like <code>"testvalue"</code> could never be
<a class="sourceLine" id="cb3-7" data-line-number="7"><span class="co">#&gt; 4 AMC B_PSDMN_AER 0 0 30 30</span></a>
<a class="sourceLine" id="cb3-8" data-line-number="8"><span class="co">#&gt; 5 AMC B_STPHY_AUR 234 0 1 235</span></a></code></pre></div>
<p>You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R <code><a href="https://www.rdocumentation.org/packages/base/topics/format">format()</a></code> function:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/format">format</a></span>(x)</a></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb4-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/base/topics/format">format</a></span>(x, <span class="dt">combine_SI =</span> <span class="ot">TRUE</span>)</a></code></pre></div>
</li>
<li>
<p>Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for <code>portion_*</code> functions or <code>count_*</code> functions. This can be used to determine the empiric susceptibily of a combination therapy. A new parameter <code>only_all_tested</code> (<strong>which defaults to <code>FALSE</code></strong>) replaces the old <code>also_single_tested</code> and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the <code>portion</code> and <code>count</code> help pages), where the %SI is being determined:</p>
@ -304,7 +304,9 @@ Since this is a major change, usage of the old <code>also_single_tested</code> w
<h3 class="hasAnchor">
<a href="#changed" class="anchor"></a>Changed</h3>
<ul>
<li>Function: <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>
<li>Renamed data set <code>septic_patients</code> to <code>example_isolates</code>
</li>
<li>Function <code><a href="../reference/eucast_rules.html">eucast_rules()</a></code>:
<ul>
<li>Fixed a bug for <em>Yersinia pseudotuberculosis</em>
</li>
@ -1256,7 +1258,7 @@ Using <code><a href="../reference/as.mo.html">as.mo(..., allow_uncertain = 3)</a
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#amr-0-7-1-9062">0.7.1.9062</a></li>
<li><a href="#amr-0-7-1-9063">0.7.1.9063</a></li>
<li><a href="#amr-0-7-1">0.7.1</a></li>
<li><a href="#amr-0-7-0">0.7.0</a></li>
<li><a href="#amr-0-6-1">0.6.1</a></li>

View File

@ -47,7 +47,7 @@
<script src="../extra.js"></script>
<meta property="og:title" content="Data set with 500 isolates - WHONET example — WHONET" />
<meta property="og:description" content="This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our septic_patients data set." />
<meta property="og:description" content="This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our example_isolates data set." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
<meta name="twitter:card" content="summary" />
@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -230,7 +230,7 @@
<div class="ref-description">
<p>This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our <code><a href='septic_patients.html'>septic_patients</a></code> data set.</p>
<p>This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our <code><a href='example_isolates.html'>example_isolates</a></code> data set.</p>
</div>
@ -288,7 +288,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -301,7 +301,7 @@
<span class='co'># resistance of ciprofloxacine per age group</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='first_isolate.html'>filter_first_isolate</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='kw'>age_group</span> <span class='kw'>=</span> <span class='fu'>age_groups</span>(<span class='no'>age</span>)) <span class='kw'>%&gt;%</span>
@ -330,7 +330,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -342,12 +342,12 @@
<span class='co'># using dplyr's mutate</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_at</a></span>(<span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='no'>PEN</span>:<span class='no'>RIF</span>), <span class='no'>as.rsi</span>)
<span class='co'># fastest way to transform all columns with already valid AB results to class `rsi`:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate_all.html'>mutate_if</a></span>(<span class='no'>is.rsi.eligible</span>,
<span class='no'>as.rsi</span>)
@ -379,7 +379,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9061</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -265,16 +265,16 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='fu'>availability</span>(<span class='no'>septic_patients</span>)
<span class='fu'>availability</span>(<span class='no'>example_isolates</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>availability</span>()
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>availability</span>()
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select_all.html'>select_if</a></span>(<span class='no'>is.rsi</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>availability</span>()
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select_all.html'>select_if</a></span>(<span class='no'>is.rsi</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>availability</span>()

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9061</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -251,12 +251,20 @@
<th>minimum</th>
<td><p>the minimum allowed number of available (tested) isolates. Any isolate count lower than <code>minimum</code> will return <code>NA</code> with a warning. The default number of <code>30</code> isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.</p></td>
</tr>
<tr>
<th>combine_RI</th>
<td><p>logical to indicate whether values R and I should be summed</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p><strong>M39 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition</strong>, 2014, <em>Clinical and Laboratory Standards Institute (CLSI)</em>. <a href='https://clsi.org/standards/products/microbiology/documents/m39/'>https://clsi.org/standards/products/microbiology/documents/m39/</a>.</p>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>The function <code>format</code> calculated the resistance per bug-drug combination. Use <code>combine_RI = FALSE</code> (default) to test R vs. S+I and <code>combine_RI = TRUE</code> to test R+I vs. S.</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
@ -265,7 +273,7 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='fu'>bug_drug_combinations</span>(<span class='no'>septic_patients</span>)
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='fu'>bug_drug_combinations</span>(<span class='no'>example_isolates</span>)
<span class='no'>x</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/format'>format</a></span>(<span class='no'>x</span>)
<span class='co'># }</span></pre>
@ -277,6 +285,8 @@
<li><a href="#source">Source</a></li>
<li><a href="#details">Details</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
<li><a href="#examples">Examples</a></li>

View File

@ -81,7 +81,7 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -356,29 +356,29 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='co'># septic_patients is a data set available in the AMR package. It is true, genuine data.</span>
?<span class='no'>septic_patients</span>
<span class='co'># example_isolates is a data set available in the AMR package.</span>
?<span class='no'>example_isolates</span>
<span class='co'># Count resistant isolates</span>
<span class='fu'>count_R</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>count_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>count_R</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'>count_IR</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='co'># Or susceptible isolates</span>
<span class='fu'>count_S</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>count_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>count_S</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='co'># Count all available isolates</span>
<span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>n_rsi</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'>n_rsi</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='co'># Since n_rsi counts available isolates, you can</span>
<span class='co'># calculate back to count e.g. non-susceptible isolates.</span>
<span class='co'># This results in the same:</span>
<span class='fu'>count_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'><a href='portion.html'>portion_SI</a></span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>) * <span class='fu'>n_rsi</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'><a href='portion.html'>portion_SI</a></span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>) * <span class='fu'>n_rsi</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>R</span> <span class='kw'>=</span> <span class='fu'>count_R</span>(<span class='no'>CIP</span>),
<span class='kw'>I</span> <span class='kw'>=</span> <span class='fu'>count_I</span>(<span class='no'>CIP</span>),
@ -390,24 +390,24 @@ count_R and count_IR can be used to count resistant isolates, count_S and count_
<span class='co'># Count co-resistance between amoxicillin/clav acid and gentamicin,</span>
<span class='co'># so we can see that combination therapy does a lot more than mono therapy.</span>
<span class='co'># Please mind that `portion_SI` calculates percentages right away instead.</span>
<span class='fu'>count_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>AMC</span>) <span class='co'># 1433</span>
<span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>AMC</span>) <span class='co'># 1879</span>
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMC</span>) <span class='co'># 1433</span>
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>AMC</span>) <span class='co'># 1879</span>
<span class='fu'>count_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>GEN</span>) <span class='co'># 1399</span>
<span class='fu'>count_all</span>(<span class='no'>septic_patients</span>$<span class='no'>GEN</span>) <span class='co'># 1855</span>
<span class='fu'>count_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>GEN</span>) <span class='co'># 1399</span>
<span class='fu'>count_all</span>(<span class='no'>example_isolates</span>$<span class='no'>GEN</span>) <span class='co'># 1855</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>septic_patients</span>,
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>example_isolates</span>,
<span class='fu'>count_SI</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>)) <span class='co'># 1764</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>septic_patients</span>,
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/with'>with</a></span>(<span class='no'>example_isolates</span>,
<span class='fu'>n_rsi</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>)) <span class='co'># 1936</span>
<span class='co'># Get portions S/I/R immediately of all rsi columns</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># It also supports grouping variables</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>count_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)

View File

@ -0,0 +1,305 @@
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Data set with 2,000 blood culture isolates from septic patients — example_isolates • AMR (for R)</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<!-- sticky kit -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>
<!-- docsearch -->
<script src="../docsearch.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.css" integrity="sha256-QOSRU/ra9ActyXkIBbiIB144aDBdtvXBcNc3OTNuX/Q=" crossorigin="anonymous" />
<link href="../docsearch.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity="sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin="anonymous"></script>
<link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script>
<meta property="og:title" content="Data set with 2,000 blood culture isolates from septic patients — example_isolates" />
<meta property="og:description" content="An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This data.frame can be used to practice AMR analysis. For examples, please read the tutorial on our website." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
<meta name="twitter:card" content="summary" />
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-reference-topic">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home"></span>
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fa fa-question-circle"></span>
How to
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/AMR.html">
<span class="fa fa-directions"></span>
Conduct AMR analysis
</a>
</li>
<li>
<a href="../articles/resistance_predict.html">
<span class="fa fa-dice"></span>
Predict antimicrobial resistance
</a>
</li>
<li>
<a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span>
Determine multi-drug resistance (MDR)
</a>
</li>
<li>
<a href="../articles/WHONET.html">
<span class="fa fa-globe-americas"></span>
Work with WHONET data
</a>
</li>
<li>
<a href="../articles/SPSS.html">
<span class="fa fa-file-upload"></span>
Import data from SPSS/SAS/Stata
</a>
</li>
<li>
<a href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
Apply EUCAST rules
</a>
</li>
<li>
<a href="../reference/mo_property.html">
<span class="fa fa-bug"></span>
Get properties of a microorganism
</a>
</li>
<li>
<a href="../reference/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>
<a href="../reference/">
<span class="fa fa-book-open"></span>
Manual
</a>
</li>
<li>
<a href="../authors.html">
<span class="fa fa-users"></span>
Authors
</a>
</li>
<li>
<a href="../news/">
<span class="far fa far fa-newspaper"></span>
Changelog
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://gitlab.com/msberends/AMR">
<span class="fab fa fab fa-gitlab"></span>
Source Code
</a>
</li>
<li>
<a href="../LICENSE-text.html">
<span class="fa fa-book"></span>
Licence
</a>
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
</div>
</form>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Data set with 2,000 blood culture isolates from septic patients</h1>
<div class="hidden name"><code>example_isolates.Rd</code></div>
</div>
<div class="ref-description">
<p>An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This <code>data.frame</code> can be used to practice AMR analysis. For examples, please read <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>the tutorial on our website</a>.</p>
</div>
<pre class="usage"><span class='no'>example_isolates</span></pre>
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 2,000 observations and 49 variables:</p><dl class='dl-horizontal'>
<dt><code>date</code></dt><dd><p>date of receipt at the laboratory</p></dd>
<dt><code>hospital_id</code></dt><dd><p>ID of the hospital, from A to D</p></dd>
<dt><code>ward_icu</code></dt><dd><p>logical to determine if ward is an intensive care unit</p></dd>
<dt><code>ward_clinical</code></dt><dd><p>logical to determine if ward is a regular clinical ward</p></dd>
<dt><code>ward_outpatient</code></dt><dd><p>logical to determine if ward is an outpatient clinic</p></dd>
<dt><code>age</code></dt><dd><p>age of the patient</p></dd>
<dt><code>gender</code></dt><dd><p>gender of the patient</p></dd>
<dt><code>patient_id</code></dt><dd><p>ID of the patient, first 10 characters of an SHA hash containing irretrievable information</p></dd>
<dt><code>mo</code></dt><dd><p>ID of microorganism created with <code><a href='as.mo.html'>as.mo</a></code>, see also <code><a href='microorganisms.html'>microorganisms</a></code></p></dd>
<dt><code>peni:rifa</code></dt><dd><p>40 different antibiotics with class <code>rsi</code> (see <code><a href='as.rsi.html'>as.rsi</a></code>); these column names occur in <code><a href='antibiotics.html'>antibiotics</a></code> data set and can be translated with <code><a href='ab_property.html'>ab_name</a></code></p></dd>
</dl>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
<p>On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a tutorial</a> about how to conduct AMR analysis, the <a href='https://msberends.gitlab.io/AMR/reference'>complete documentation of all functions</a> (which reads a lot easier than here in R) and <a href='https://msberends.gitlab.io/AMR/articles/WHONET.html'>an example analysis using WHONET data</a>.</p>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#format">Format</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
</ul>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.js" integrity="sha256-GKvGqXDznoRYHCwKXGnuchvKSwmx9SRMrZOTh2g4Sb0=" crossorigin="anonymous"></script>
<script>
docsearch({
apiKey: 'f737050abfd4d726c63938e18f8c496e',
indexName: 'amr',
inputSelector: 'input#search-input.form-control',
transformData: function(hits) {
return hits.map(function (hit) {
hit.url = updateHitURL(hit);
return hit;
});
}
});
</script>
</body>
</html>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -295,29 +295,29 @@
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='co'># filter on isolates that have any result for any aminoglycoside</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>()
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>()
<span class='co'># this is essentially the same as (but without determination of column names):</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter_all.html'>filter_at</a></span>(<span class='kw'>.vars</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/vars.html'>vars</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"GEN"</span>, <span class='st'>"TOB"</span>, <span class='st'>"AMK"</span>, <span class='st'>"KAN"</span>)),
<span class='kw'>.vars_predicate</span> <span class='kw'>=</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/all_vars.html'>any_vars</a></span>(<span class='no'>.</span> <span class='kw'>%in%</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"S"</span>, <span class='st'>"I"</span>, <span class='st'>"R"</span>)))
<span class='co'># filter on isolates that show resistance to ANY aminoglycoside</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>)
<span class='co'># filter on isolates that show resistance to ALL aminoglycosides</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='co'># filter on isolates that show resistance to</span>
<span class='co'># any aminoglycoside and any fluoroquinolone</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>filter_fluoroquinolones</span>(<span class='st'>"R"</span>)
<span class='co'># filter on isolates that show resistance to</span>
<span class='co'># all aminoglycosides and all fluoroquinolones</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'>filter_aminoglycosides</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>filter_fluoroquinolones</span>(<span class='st'>"R"</span>, <span class='st'>"all"</span>)
<span class='co'># }</span></pre>
@ -337,7 +337,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -373,12 +373,12 @@ To conduct an analysis of antimicrobial resistance, you should only include the
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='co'># `septic_patients` is a dataset available in the AMR package. It is true, genuine data.</span>
<span class='co'># See ?septic_patients.</span>
<span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
<span class='co'># See ?example_isolates.</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='co'># Filter on first isolates:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolate</span> <span class='kw'>=</span> <span class='fu'>first_isolate</span>(<span class='no'>.</span>,
<span class='kw'>col_date</span> <span class='kw'>=</span> <span class='st'>"date"</span>,
<span class='kw'>col_patient_id</span> <span class='kw'>=</span> <span class='st'>"patient_id"</span>,
@ -386,19 +386,19 @@ To conduct an analysis of antimicrobial resistance, you should only include the
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>)
<span class='co'># Which can be shortened to:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'>filter_first_isolate</span>()
<span class='co'># or for first weighted isolates:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'>filter_first_weighted_isolate</span>()
<span class='co'># Now let's see if first isolates matter:</span>
<span class='no'>A</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>A</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>count</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>GEN</span>), <span class='co'># gentamicin availability</span>
<span class='kw'>resistance</span> <span class='kw'>=</span> <span class='fu'><a href='portion.html'>portion_IR</a></span>(<span class='no'>GEN</span>)) <span class='co'># gentamicin resistance</span>
<span class='no'>B</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>B</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'>filter_first_weighted_isolate</span>() <span class='kw'>%&gt;%</span> <span class='co'># the 1st isolate filter</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>count</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>GEN</span>), <span class='co'># gentamicin availability</span>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -379,11 +379,11 @@
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>ggplot2</span>)
<span class='co'># get antimicrobial results for drugs against a UTI:</span>
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)) +
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)) +
<span class='fu'>geom_rsi</span>()
<span class='co'># prettify the plot using some additional functions:</span>
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>)
<span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>df</span>) +
<span class='fu'>geom_rsi</span>() +
<span class='fu'>scale_y_percent</span>() +
@ -392,17 +392,17 @@
<span class='fu'>theme_rsi</span>()
<span class='co'># or better yet, simplify this using the wrapper function - a single command:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>()
<span class='co'># get only portions and no counts:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># add other ggplot2 parameters as you like:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>width</span> <span class='kw'>=</span> <span class='fl'>0.5</span>,
<span class='kw'>colour</span> <span class='kw'>=</span> <span class='st'>"black"</span>,
@ -410,12 +410,12 @@
<span class='kw'>linetype</span> <span class='kw'>=</span> <span class='fl'>2</span>,
<span class='kw'>alpha</span> <span class='kw'>=</span> <span class='fl'>0.25</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>colours</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='kw'>SI</span> <span class='kw'>=</span> <span class='st'>"yellow"</span>))
<span class='co'># resistance of ciprofloxacine per age group</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>first_isolate</span> <span class='kw'>=</span> <span class='fu'><a href='first_isolate.html'>first_isolate</a></span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>first_isolate</span> <span class='kw'>==</span> <span class='fl'>TRUE</span>,
<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>
@ -426,17 +426,17 @@
<span class='fu'>ggplot_rsi</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"age_group"</span>)
<span class='co'># }</span><span class='co'># NOT RUN {</span>
<span class='co'># for colourblind mode, use divergent colours from the viridis package:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>() + <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/scale_viridis.html'>scale_fill_viridis_d</a></span>()
<span class='co'># a shorter version which also adjusts data label colours:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>colours</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># it also supports groups (don't forget to use the group var on `x` or `facet`):</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>AMX</span>, <span class='no'>NIT</span>, <span class='no'>FOS</span>, <span class='no'>TMP</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>ggplot_rsi</span>(<span class='kw'>x</span> <span class='kw'>=</span> <span class='st'>"hospital_id"</span>,
@ -447,11 +447,11 @@
<span class='kw'>datalabels</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># genuine analysis: check 3 most prevalent microorganisms</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='co'># create new bacterial ID's, with all CoNS under the same group (Becker et al.)</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>mo</span> <span class='kw'>=</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='no'>mo</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)) <span class='kw'>%&gt;%</span>
<span class='co'># filter on top three bacterial ID's</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>%in%</span> <span class='fu'>top_freq</span>(<span class='fu'>freq</span>(<span class='no'>.</span>$<span class='no'>mo</span>), <span class='fl'>3</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>%in%</span> <span class='fu'>top_freq</span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/clean/topics/freq'>freq</a></span>(<span class='no'>.</span>$<span class='no'>mo</span>), <span class='fl'>3</span>)) <span class='kw'>%&gt;%</span>
<span class='co'># filter on first isolates</span>
<span class='fu'><a href='first_isolate.html'>filter_first_isolate</a></span>() <span class='kw'>%&gt;%</span>
<span class='co'># get short MO names (like "E. coli")</span>
@ -488,7 +488,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -490,7 +490,7 @@
</tr><tr>
<td>
<p><code><a href="septic_patients.html">septic_patients</a></code> </p>
<p><code><a href="example_isolates.html">example_isolates</a></code> </p>
</td>
<td><p>Data set with 2,000 blood culture isolates from septic patients</p></td>
</tr><tr>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -283,7 +283,7 @@
<span class='fu'>left_join_microorganisms</span>(<span class='st'>"B_KLBSL_PNE"</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>left_join_microorganisms</span>()
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>left_join_microorganisms</span>()
<span class='no'>df</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></span>(<span class='kw'>date</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/seq'>seq</a></span>(<span class='kw'>from</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/as.Date'>as.Date</a></span>(<span class='st'>"2018-01-01"</span>),
<span class='kw'>to</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/as.Date'>as.Date</a></span>(<span class='st'>"2018-01-07"</span>),
@ -313,7 +313,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9057</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -337,12 +337,12 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='co'># `septic_patients` is a dataset available in the AMR package. It is true, genuine data.</span>
<span class='co'># See ?septic_patients.</span>
<span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
<span class='co'># See ?example_isolates.</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='co'># set key antibiotics to a new variable</span>
<span class='no'>my_patients</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>my_patients</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>keyab</span> <span class='kw'>=</span> <span class='fu'>key_antibiotics</span>(<span class='no'>.</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(
<span class='co'># now calculate first isolates</span>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -300,7 +300,7 @@
<span class='co'># get frequencies of bacteria whose name start with 'Ent' or 'ent'</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>clean</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='join.html'>left_join_microorganisms</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>genus</span> <span class='kw'>%like%</span> <span class='st'>'^ent'</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/clean/topics/freq'>freq</a></span>(<span class='no'>genus</span>, <span class='no'>species</span>)
@ -329,7 +329,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -383,7 +383,7 @@
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/mutate.html'>mutate</a></span>(<span class='kw'>EUCAST</span> <span class='kw'>=</span> <span class='fu'>mdro</span>(<span class='no'>.</span>),
<span class='kw'>BRMO</span> <span class='kw'>=</span> <span class='fu'>brmo</span>(<span class='no'>.</span>))
<span class='co'># }</span></pre>
@ -411,7 +411,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -81,7 +81,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9062</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -371,30 +371,30 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='co'># septic_patients is a data set available in the AMR package. It is true, genuine data.</span>
?<span class='no'>septic_patients</span>
<span class='co'># example_isolates is a data set available in the AMR package.</span>
?<span class='no'>example_isolates</span>
<span class='co'># Calculate resistance</span>
<span class='fu'>portion_R</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>portion_IR</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>portion_R</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'>portion_IR</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='co'># Or susceptibility</span>
<span class='fu'>portion_S</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>portion_SI</span>(<span class='no'>septic_patients</span>$<span class='no'>AMX</span>)
<span class='fu'>portion_S</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='fu'>portion_SI</span>(<span class='no'>example_isolates</span>$<span class='no'>AMX</span>)
<span class='co'># Do the above with pipes:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_R</span>(<span class='no'>AMX</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_IR</span>(<span class='no'>AMX</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>AMX</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>AMX</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_R</span>(<span class='no'>AMX</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_IR</span>(<span class='no'>AMX</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_S</span>(<span class='no'>AMX</span>)
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>AMX</span>)
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>p</span> <span class='kw'>=</span> <span class='fu'>portion_SI</span>(<span class='no'>CIP</span>),
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>n_rsi</a></span>(<span class='no'>CIP</span>)) <span class='co'># n_rsi works like n_distinct in dplyr</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>R</span> <span class='kw'>=</span> <span class='fu'>portion_R</span>(<span class='no'>CIP</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>I</span> <span class='kw'>=</span> <span class='fu'>portion_I</span>(<span class='no'>CIP</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
@ -405,24 +405,24 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='co'># Calculate co-resistance between amoxicillin/clav acid and gentamicin,</span>
<span class='co'># so we can see that combination therapy does a lot more than mono therapy:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>AMC</span>) <span class='co'># %SI = 76.3%</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>) <span class='co'># n = 1879</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>AMC</span>) <span class='co'># %SI = 76.3%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>) <span class='co'># n = 1879</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>GEN</span>) <span class='co'># %SI = 75.4%</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>GEN</span>) <span class='co'># n = 1855</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>GEN</span>) <span class='co'># %SI = 75.4%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>GEN</span>) <span class='co'># n = 1855</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># %SI = 94.1%</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># n = 1939</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'>portion_SI</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># %SI = 94.1%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>) <span class='co'># n = 1939</span>
<span class='co'># See Details on how `only_all_tested` works. Example:</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>numerator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_SI</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>),
<span class='kw'>denominator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>),
<span class='kw'>portion</span> <span class='kw'>=</span> <span class='fu'>portion_SI</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>))
<span class='co'># numerator denominator portion</span>
<span class='co'># 1764 1936 0.9408</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>numerator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_SI</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>denominator</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>portion</span> <span class='kw'>=</span> <span class='fu'>portion_SI</span>(<span class='no'>AMC</span>, <span class='no'>GEN</span>, <span class='kw'>only_all_tested</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>))
@ -430,7 +430,7 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='co'># 1687 1798 0.9383</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/summarise.html'>summarise</a></span>(<span class='kw'>cipro_p</span> <span class='kw'>=</span> <span class='fu'>portion_SI</span>(<span class='no'>CIP</span>, <span class='kw'>as_percent</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>cipro_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>CIP</span>),
@ -440,12 +440,12 @@ portion_R and portion_IR can be used to calculate resistance, portion_S and port
<span class='kw'>combination_n</span> <span class='kw'>=</span> <span class='fu'><a href='count.html'>count_all</a></span>(<span class='no'>CIP</span>, <span class='no'>GEN</span>))
<span class='co'># Get portions S/I/R immediately of all rsi columns</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)
<span class='co'># It also supports grouping variables</span>
<span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/select.html'>select</a></span>(<span class='no'>hospital_id</span>, <span class='no'>AMX</span>, <span class='no'>CIP</span>) <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/group_by.html'>group_by</a></span>(<span class='no'>hospital_id</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>portion_df</span>(<span class='kw'>translate</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9055</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">0.7.1.9063</span>
</span>
</div>
@ -342,13 +342,13 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># NOT RUN {</span>
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='fu'>resistance_predict</span>(<span class='no'>septic_patients</span>, <span class='kw'>col_ab</span> <span class='kw'>=</span> <span class='st'>"AMX"</span>, <span class='kw'>year_min</span> <span class='kw'>=</span> <span class='fl'>2010</span>, <span class='kw'>model</span> <span class='kw'>=</span> <span class='st'>"binomial"</span>)
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='fu'>resistance_predict</span>(<span class='no'>example_isolates</span>, <span class='kw'>col_ab</span> <span class='kw'>=</span> <span class='st'>"AMX"</span>, <span class='kw'>year_min</span> <span class='kw'>=</span> <span class='fl'>2010</span>, <span class='kw'>model</span> <span class='kw'>=</span> <span class='st'>"binomial"</span>)
<span class='fu'><a href='https://www.rdocumentation.org/packages/graphics/topics/plot'>plot</a></span>(<span class='no'>x</span>)
<span class='fu'>ggplot_rsi_predict</span>(<span class='no'>x</span>)
<span class='co'># use dplyr so you can actually read it:</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>library</a></span>(<span class='no'>dplyr</span>)
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>x</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='first_isolate.html'>filter_first_isolate</a></span>() <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='fu'><a href='mo_property.html'>mo_genus</a></span>(<span class='no'>mo</span>) <span class='kw'>==</span> <span class='st'>"Staphylococcus"</span>) <span class='kw'>%&gt;%</span>
<span class='fu'>resistance_predict</span>(<span class='st'>"PEN"</span>, <span class='kw'>model</span> <span class='kw'>=</span> <span class='st'>"binomial"</span>)
@ -363,7 +363,7 @@
<span class='co'># create nice plots with ggplot2 yourself</span>
<span class='kw'>if</span> (!<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/library'>require</a></span>(<span class='no'>ggplot2</span>)) {
<span class='no'>data</span> <span class='kw'>&lt;-</span> <span class='no'>septic_patients</span> <span class='kw'>%&gt;%</span>
<span class='no'>data</span> <span class='kw'>&lt;-</span> <span class='no'>example_isolates</span> <span class='kw'>%&gt;%</span>
<span class='fu'><a href='https://dplyr.tidyverse.org/reference/filter.html'>filter</a></span>(<span class='no'>mo</span> <span class='kw'>==</span> <span class='fu'><a href='as.mo.html'>as.mo</a></span>(<span class='st'>"E. coli"</span>)) <span class='kw'>%&gt;%</span>
<span class='fu'>resistance_predict</span>(<span class='kw'>col_ab</span> <span class='kw'>=</span> <span class='st'>"AMX"</span>,
<span class='kw'>col_date</span> <span class='kw'>=</span> <span class='st'>"date"</span>,
@ -410,7 +410,7 @@
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>, <a href='https://www.rug.nl/staff/c.j.albers/'>Casper J. Albers</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>.</p>
</div>
<div class="pkgdown">

View File

@ -63,6 +63,9 @@
<url>
<loc>https://msberends.gitlab.io/AMR/reference/eucast_rules.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/example_isolates.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/extended-functions.html</loc>
</url>
@ -129,9 +132,6 @@
<url>
<loc>https://msberends.gitlab.io/AMR/reference/rsi_translation.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/septic_patients.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/skewness.html</loc>
</url>

View File

@ -148,7 +148,7 @@ The `AMR` package basically does four important things:
* Aside from this website with many tutorials, the package itself contains extensive help pages with many examples for all functions.
* The package also contains example data sets:
* The [`septic_patients` data set](./reference/septic_patients.html). This data set contains:
* The [`example_isolates` data set](./reference/example_isolates.html). This data set contains:
* 2,000 blood culture isolates from anonymised septic patients between 2001 and 2017 in the Northern Netherlands
* Results of 40 antibiotics (each antibiotic in its own column) with a total ~40,000 antimicrobial results
* Real and genuine data

View File

@ -37,7 +37,7 @@
WHONET
}
\description{
This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our \code{\link{septic_patients}} data set.
This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The data itself was based on our \code{\link{example_isolates}} data set.
}
\section{Read more on our website!}{

View File

@ -60,7 +60,7 @@ age_groups(ages, c(1, 2, 4, 6, 13, 17))
# resistance of ciprofloxacine per age group
library(dplyr)
septic_patients \%>\%
example_isolates \%>\%
filter_first_isolate() \%>\%
filter(mo == as.mo("E. coli")) \%>\%
group_by(age_group = age_groups(age)) \%>\%

View File

@ -96,12 +96,12 @@ freq(rsi_data) # frequency table with informative header
# using dplyr's mutate
library(dplyr)
septic_patients \%>\%
example_isolates \%>\%
mutate_at(vars(PEN:RIF), as.rsi)
# fastest way to transform all columns with already valid AB results to class `rsi`:
septic_patients \%>\%
example_isolates \%>\%
mutate_if(is.rsi.eligible,
as.rsi)

View File

@ -26,16 +26,16 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
availability(septic_patients)
availability(example_isolates)
library(dplyr)
septic_patients \%>\% availability()
example_isolates \%>\% availability()
septic_patients \%>\%
example_isolates \%>\%
select_if(is.rsi) \%>\%
availability()
septic_patients \%>\%
example_isolates \%>\%
filter(mo == as.mo("E. coli")) \%>\%
select_if(is.rsi) \%>\%
availability()

View File

@ -15,10 +15,15 @@ bug_drug_combinations(x, col_mo = NULL, minimum = 30)
\item{col_mo}{column name of the unique IDs of the microorganisms (see \code{\link{mo}}), defaults to the first column of class \code{mo}. Values will be coerced using \code{\link{as.mo}}.}
\item{minimum}{the minimum allowed number of available (tested) isolates. Any isolate count lower than \code{minimum} will return \code{NA} with a warning. The default number of \code{30} isolates is advised by the Clinical and Laboratory Standards Institute (CLSI) as best practice, see Source.}
\item{combine_RI}{logical to indicate whether values R and I should be summed}
}
\description{
Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use \code{format} on the result to prettify it to a printable format, see Examples.
}
\details{
The function \code{format} calculated the resistance per bug-drug combination. Use \code{combine_RI = FALSE} (default) to test R vs. S+I and \code{combine_RI = TRUE} to test R+I vs. S.
}
\section{Read more on our website!}{
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a tutorial} about how to conduct AMR analysis, the \href{https://msberends.gitlab.io/AMR/reference}{complete documentation of all functions} (which reads a lot easier than here in R) and \href{https://msberends.gitlab.io/AMR/articles/WHONET.html}{an example analysis using WHONET data}.
@ -26,7 +31,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
\examples{
\donttest{
x <- bug_drug_combinations(septic_patients)
x <- bug_drug_combinations(example_isolates)
x
format(x)
}

View File

@ -122,29 +122,29 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
# septic_patients is a data set available in the AMR package. It is true, genuine data.
?septic_patients
# example_isolates is a data set available in the AMR package.
?example_isolates
# Count resistant isolates
count_R(septic_patients$AMX)
count_IR(septic_patients$AMX)
count_R(example_isolates$AMX)
count_IR(example_isolates$AMX)
# Or susceptible isolates
count_S(septic_patients$AMX)
count_SI(septic_patients$AMX)
count_S(example_isolates$AMX)
count_SI(example_isolates$AMX)
# Count all available isolates
count_all(septic_patients$AMX)
n_rsi(septic_patients$AMX)
count_all(example_isolates$AMX)
n_rsi(example_isolates$AMX)
# Since n_rsi counts available isolates, you can
# calculate back to count e.g. non-susceptible isolates.
# This results in the same:
count_SI(septic_patients$AMX)
portion_SI(septic_patients$AMX) * n_rsi(septic_patients$AMX)
count_SI(example_isolates$AMX)
portion_SI(example_isolates$AMX) * n_rsi(example_isolates$AMX)
library(dplyr)
septic_patients \%>\%
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(R = count_R(CIP),
I = count_I(CIP),
@ -156,24 +156,24 @@ 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_SI` calculates percentages right away instead.
count_SI(septic_patients$AMC) # 1433
count_all(septic_patients$AMC) # 1879
count_SI(example_isolates$AMC) # 1433
count_all(example_isolates$AMC) # 1879
count_SI(septic_patients$GEN) # 1399
count_all(septic_patients$GEN) # 1855
count_SI(example_isolates$GEN) # 1399
count_all(example_isolates$GEN) # 1855
with(septic_patients,
with(example_isolates,
count_SI(AMC, GEN)) # 1764
with(septic_patients,
with(example_isolates,
n_rsi(AMC, GEN)) # 1936
# Get portions S/I/R immediately of all rsi columns
septic_patients \%>\%
example_isolates \%>\%
select(AMX, CIP) \%>\%
count_df(translate = FALSE)
# It also supports grouping variables
septic_patients \%>\%
example_isolates \%>\%
select(hospital_id, AMX, CIP) \%>\%
group_by(hospital_id) \%>\%
count_df(translate = FALSE)

8
man/septic_patients.Rd → man/example_isolates.Rd Executable file → Normal file
View File

@ -1,8 +1,8 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{septic_patients}
\alias{septic_patients}
\name{example_isolates}
\alias{example_isolates}
\title{Data set with 2,000 blood culture isolates from septic patients}
\format{A \code{\link{data.frame}} with 2,000 observations and 49 variables:
\describe{
@ -18,10 +18,10 @@
\item{\code{peni:rifa}}{40 different antibiotics with class \code{rsi} (see \code{\link{as.rsi}}); these column names occur in \code{\link{antibiotics}} data set and can be translated with \code{\link{ab_name}}}
}}
\usage{
septic_patients
example_isolates
}
\description{
An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
An anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This \code{data.frame} can be used to practice AMR analysis. For examples, please read \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{the tutorial on our website}.
}
\section{Read more on our website!}{

View File

@ -63,29 +63,29 @@ The \code{group} column in \code{\link{antibiotics}} data set will be searched f
library(dplyr)
# filter on isolates that have any result for any aminoglycoside
septic_patients \%>\% filter_aminoglycosides()
example_isolates \%>\% filter_aminoglycosides()
# this is essentially the same as (but without determination of column names):
septic_patients \%>\%
example_isolates \%>\%
filter_at(.vars = vars(c("GEN", "TOB", "AMK", "KAN")),
.vars_predicate = any_vars(. \%in\% c("S", "I", "R")))
# filter on isolates that show resistance to ANY aminoglycoside
septic_patients \%>\% filter_aminoglycosides("R")
example_isolates \%>\% filter_aminoglycosides("R")
# filter on isolates that show resistance to ALL aminoglycosides
septic_patients \%>\% filter_aminoglycosides("R", "all")
example_isolates \%>\% filter_aminoglycosides("R", "all")
# filter on isolates that show resistance to
# any aminoglycoside and any fluoroquinolone
septic_patients \%>\%
example_isolates \%>\%
filter_aminoglycosides("R") \%>\%
filter_fluoroquinolones("R")
# filter on isolates that show resistance to
# all aminoglycosides and all fluoroquinolones
septic_patients \%>\%
example_isolates \%>\%
filter_aminoglycosides("R", "all") \%>\%
filter_fluoroquinolones("R", "all")
}

View File

@ -106,12 +106,12 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
# `septic_patients` is a dataset available in the AMR package. It is true, genuine data.
# See ?septic_patients.
# `example_isolates` is a dataset available in the AMR package.
# See ?example_isolates.
library(dplyr)
# Filter on first isolates:
septic_patients \%>\%
example_isolates \%>\%
mutate(first_isolate = first_isolate(.,
col_date = "date",
col_patient_id = "patient_id",
@ -119,19 +119,19 @@ septic_patients \%>\%
filter(first_isolate == TRUE)
# Which can be shortened to:
septic_patients \%>\%
example_isolates \%>\%
filter_first_isolate()
# or for first weighted isolates:
septic_patients \%>\%
example_isolates \%>\%
filter_first_weighted_isolate()
# Now let's see if first isolates matter:
A <- septic_patients \%>\%
A <- example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(count = n_rsi(GEN), # gentamicin availability
resistance = portion_IR(GEN)) # gentamicin resistance
B <- septic_patients \%>\%
B <- example_isolates \%>\%
filter_first_weighted_isolate() \%>\% # the 1st isolate filter
group_by(hospital_id) \%>\%
summarise(count = n_rsi(GEN), # gentamicin availability

View File

@ -114,11 +114,11 @@ library(dplyr)
library(ggplot2)
# get antimicrobial results for drugs against a UTI:
ggplot(septic_patients \%>\% select(AMX, NIT, FOS, TMP, CIP)) +
ggplot(example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)) +
geom_rsi()
# prettify the plot using some additional functions:
df <- septic_patients \%>\% select(AMX, NIT, FOS, TMP, CIP)
df <- example_isolates \%>\% select(AMX, NIT, FOS, TMP, CIP)
ggplot(df) +
geom_rsi() +
scale_y_percent() +
@ -127,17 +127,17 @@ ggplot(df) +
theme_rsi()
# or better yet, simplify this using the wrapper function - a single command:
septic_patients \%>\%
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi()
# get only portions and no counts:
septic_patients \%>\%
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(datalabels = FALSE)
# add other ggplot2 parameters as you like:
septic_patients \%>\%
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(width = 0.5,
colour = "black",
@ -145,12 +145,12 @@ septic_patients \%>\%
linetype = 2,
alpha = 0.25)
septic_patients \%>\%
example_isolates \%>\%
select(AMX) \%>\%
ggplot_rsi(colours = c(SI = "yellow"))
# resistance of ciprofloxacine per age group
septic_patients \%>\%
example_isolates \%>\%
mutate(first_isolate = first_isolate(.)) \%>\%
filter(first_isolate == TRUE,
mo == as.mo("E. coli")) \%>\%
@ -162,17 +162,17 @@ septic_patients \%>\%
\donttest{
# for colourblind mode, use divergent colours from the viridis package:
septic_patients \%>\%
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi() + scale_fill_viridis_d()
# a shorter version which also adjusts data label colours:
septic_patients \%>\%
example_isolates \%>\%
select(AMX, NIT, FOS, TMP, CIP) \%>\%
ggplot_rsi(colours = FALSE)
# it also supports groups (don't forget to use the group var on `x` or `facet`):
septic_patients \%>\%
example_isolates \%>\%
select(hospital_id, AMX, NIT, FOS, TMP, CIP) \%>\%
group_by(hospital_id) \%>\%
ggplot_rsi(x = "hospital_id",
@ -183,7 +183,7 @@ septic_patients \%>\%
datalabels = FALSE)
# genuine analysis: check 3 most prevalent microorganisms
septic_patients \%>\%
example_isolates \%>\%
# create new bacterial ID's, with all CoNS under the same group (Becker et al.)
mutate(mo = as.mo(mo, Becker = TRUE)) \%>\%
# filter on top three bacterial ID's

View File

@ -48,7 +48,7 @@ left_join_microorganisms(as.mo("K. pneumoniae"))
left_join_microorganisms("B_KLBSL_PNE")
library(dplyr)
septic_patients \%>\% left_join_microorganisms()
example_isolates \%>\% left_join_microorganisms()
df <- data.frame(date = seq(from = as.Date("2018-01-01"),
to = as.Date("2018-01-07"),

View File

@ -82,12 +82,12 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
# `septic_patients` is a dataset available in the AMR package. It is true, genuine data.
# See ?septic_patients.
# `example_isolates` is a dataset available in the AMR package.
# See ?example_isolates.
library(dplyr)
# set key antibiotics to a new variable
my_patients <- septic_patients \%>\%
my_patients <- example_isolates \%>\%
mutate(keyab = key_antibiotics(.)) \%>\%
mutate(
# now calculate first isolates

View File

@ -57,7 +57,7 @@ a \%like\% b
# get frequencies of bacteria whose name start with 'Ent' or 'ent'
library(dplyr)
library(clean)
septic_patients \%>\%
example_isolates \%>\%
left_join_microorganisms() \%>\%
filter(genus \%like\% '^ent') \%>\%
freq(genus, species)

View File

@ -146,7 +146,7 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
\examples{
library(dplyr)
septic_patients \%>\%
example_isolates \%>\%
mutate(EUCAST = mdro(.),
BRMO = brmo(.))
}

View File

@ -133,30 +133,30 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
# septic_patients is a data set available in the AMR package. It is true, genuine data.
?septic_patients
# example_isolates is a data set available in the AMR package.
?example_isolates
# Calculate resistance
portion_R(septic_patients$AMX)
portion_IR(septic_patients$AMX)
portion_R(example_isolates$AMX)
portion_IR(example_isolates$AMX)
# Or susceptibility
portion_S(septic_patients$AMX)
portion_SI(septic_patients$AMX)
portion_S(example_isolates$AMX)
portion_SI(example_isolates$AMX)
# Do the above with pipes:
library(dplyr)
septic_patients \%>\% portion_R(AMX)
septic_patients \%>\% portion_IR(AMX)
septic_patients \%>\% portion_S(AMX)
septic_patients \%>\% portion_SI(AMX)
example_isolates \%>\% portion_R(AMX)
example_isolates \%>\% portion_IR(AMX)
example_isolates \%>\% portion_S(AMX)
example_isolates \%>\% portion_SI(AMX)
septic_patients \%>\%
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(p = portion_SI(CIP),
n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr
septic_patients \%>\%
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(R = portion_R(CIP, as_percent = TRUE),
I = portion_I(CIP, as_percent = TRUE),
@ -167,24 +167,24 @@ 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_SI(AMC) # \%SI = 76.3\%
septic_patients \%>\% count_all(AMC) # n = 1879
example_isolates \%>\% portion_SI(AMC) # \%SI = 76.3\%
example_isolates \%>\% count_all(AMC) # n = 1879
septic_patients \%>\% portion_SI(GEN) # \%SI = 75.4\%
septic_patients \%>\% count_all(GEN) # n = 1855
example_isolates \%>\% portion_SI(GEN) # \%SI = 75.4\%
example_isolates \%>\% count_all(GEN) # n = 1855
septic_patients \%>\% portion_SI(AMC, GEN) # \%SI = 94.1\%
septic_patients \%>\% count_all(AMC, GEN) # n = 1939
example_isolates \%>\% portion_SI(AMC, GEN) # \%SI = 94.1\%
example_isolates \%>\% count_all(AMC, GEN) # n = 1939
# See Details on how `only_all_tested` works. Example:
septic_patients \%>\%
example_isolates \%>\%
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 \%>\%
example_isolates \%>\%
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))
@ -192,7 +192,7 @@ septic_patients \%>\%
# 1687 1798 0.9383
septic_patients \%>\%
example_isolates \%>\%
group_by(hospital_id) \%>\%
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
cipro_n = count_all(CIP),
@ -202,12 +202,12 @@ septic_patients \%>\%
combination_n = count_all(CIP, GEN))
# Get portions S/I/R immediately of all rsi columns
septic_patients \%>\%
example_isolates \%>\%
select(AMX, CIP) \%>\%
portion_df(translate = FALSE)
# It also supports grouping variables
septic_patients \%>\%
example_isolates \%>\%
select(hospital_id, AMX, CIP) \%>\%
group_by(hospital_id) \%>\%
portion_df(translate = FALSE)

View File

@ -80,13 +80,13 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\examples{
x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010, model = "binomial")
x <- resistance_predict(example_isolates, col_ab = "AMX", year_min = 2010, model = "binomial")
plot(x)
ggplot_rsi_predict(x)
# use dplyr so you can actually read it:
library(dplyr)
x <- septic_patients \%>\%
x <- example_isolates \%>\%
filter_first_isolate() \%>\%
filter(mo_genus(mo) == "Staphylococcus") \%>\%
resistance_predict("PEN", model = "binomial")
@ -101,7 +101,7 @@ summary(mymodel)
# create nice plots with ggplot2 yourself
if (!require(ggplot2)) {
data <- septic_patients \%>\%
data <- example_isolates \%>\%
filter(mo == as.mo("E. coli")) \%>\%
resistance_predict(col_ab = "AMX",
col_date = "date",

View File

@ -22,5 +22,5 @@
context("availability.R")
test_that("availability works", {
expect_equal(class(availability(septic_patients)), "data.frame")
expect_equal(class(availability(example_isolates)), "data.frame")
})

View File

@ -22,7 +22,7 @@
context("bug_drug_combinations.R")
test_that("bug_drug_combinations works", {
b <- suppressWarnings(bug_drug_combinations(septic_patients))
b <- suppressWarnings(bug_drug_combinations(example_isolates))
expect_s3_class(b, "bugdrug")
expect_message(print(b))
expect_true(is.data.frame(format(b)))

View File

@ -22,27 +22,27 @@
context("count.R")
test_that("counts work", {
# AMX resistance in `septic_patients`
expect_equal(count_R(septic_patients$AMX), 683)
expect_equal(count_I(septic_patients$AMX), 3)
expect_equal(count_S(septic_patients$AMX), 543)
expect_equal(count_R(septic_patients$AMX) + count_I(septic_patients$AMX),
count_IR(septic_patients$AMX))
expect_equal(count_S(septic_patients$AMX) + count_I(septic_patients$AMX),
count_SI(septic_patients$AMX))
# AMX resistance in `example_isolates`
expect_equal(count_R(example_isolates$AMX), 683)
expect_equal(count_I(example_isolates$AMX), 3)
expect_equal(count_S(example_isolates$AMX), 543)
expect_equal(count_R(example_isolates$AMX) + count_I(example_isolates$AMX),
count_IR(example_isolates$AMX))
expect_equal(count_S(example_isolates$AMX) + count_I(example_isolates$AMX),
count_SI(example_isolates$AMX))
library(dplyr)
expect_equal(septic_patients %>% count_S(AMC), 1342)
expect_equal(septic_patients %>% count_S(AMC, GEN, only_all_tested = TRUE), 1660)
expect_equal(septic_patients %>% count_S(AMC, GEN, only_all_tested = FALSE), 1728)
expect_equal(septic_patients %>% count_all(AMC, GEN, only_all_tested = TRUE), 1798)
expect_equal(septic_patients %>% count_all(AMC, GEN, only_all_tested = FALSE), 1936)
expect_identical(septic_patients %>% count_all(AMC, GEN, only_all_tested = TRUE),
septic_patients %>% count_S(AMC, GEN, only_all_tested = TRUE) +
septic_patients %>% count_IR(AMC, GEN, only_all_tested = TRUE))
expect_equal(example_isolates %>% count_S(AMC), 1342)
expect_equal(example_isolates %>% count_S(AMC, GEN, only_all_tested = TRUE), 1660)
expect_equal(example_isolates %>% count_S(AMC, GEN, only_all_tested = FALSE), 1728)
expect_equal(example_isolates %>% count_all(AMC, GEN, only_all_tested = TRUE), 1798)
expect_equal(example_isolates %>% count_all(AMC, GEN, only_all_tested = FALSE), 1936)
expect_identical(example_isolates %>% count_all(AMC, GEN, only_all_tested = TRUE),
example_isolates %>% count_S(AMC, GEN, only_all_tested = TRUE) +
example_isolates %>% count_IR(AMC, GEN, only_all_tested = TRUE))
# count of cases
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
group_by(hospital_id) %>%
summarise(cipro = count_SI(CIP),
genta = count_SI(GEN),
@ -52,29 +52,29 @@ test_that("counts work", {
# count_df
expect_equal(
septic_patients %>% select(AMX) %>% count_df() %>% pull(value),
c(septic_patients$AMX %>% count_SI(),
septic_patients$AMX %>% count_R())
example_isolates %>% select(AMX) %>% count_df() %>% pull(value),
c(example_isolates$AMX %>% count_SI(),
example_isolates$AMX %>% count_R())
)
expect_equal(
septic_patients %>% select(AMX) %>% count_df(combine_IR = TRUE) %>% pull(value),
c(septic_patients$AMX %>% count_S(),
septic_patients$AMX %>% count_IR())
example_isolates %>% select(AMX) %>% count_df(combine_IR = TRUE) %>% pull(value),
c(example_isolates$AMX %>% count_S(),
example_isolates$AMX %>% count_IR())
)
expect_equal(
septic_patients %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(value),
c(septic_patients$AMX %>% count_S(),
septic_patients$AMX %>% count_I(),
septic_patients$AMX %>% count_R())
example_isolates %>% select(AMX) %>% count_df(combine_SI = FALSE) %>% pull(value),
c(example_isolates$AMX %>% count_S(),
example_isolates$AMX %>% count_I(),
example_isolates$AMX %>% count_R())
)
# warning for speed loss
expect_warning(count_R(as.character(septic_patients$AMC)))
expect_warning(count_I(as.character(septic_patients$AMC)))
expect_warning(count_S(as.character(septic_patients$AMC,
septic_patients$GEN)))
expect_warning(count_S(septic_patients$AMC,
as.character(septic_patients$GEN)))
expect_warning(count_R(as.character(example_isolates$AMC)))
expect_warning(count_I(as.character(example_isolates$AMC)))
expect_warning(count_S(as.character(example_isolates$AMC,
example_isolates$GEN)))
expect_warning(count_S(example_isolates$AMC,
as.character(example_isolates$GEN)))
# check for errors
expect_error(count_IR("test", minimum = "test"))
@ -85,6 +85,6 @@ test_that("counts work", {
expect_error(count_S("test", as_percent = "test"))
expect_error(count_df(c("A", "B", "C")))
expect_error(count_df(septic_patients[,"date"]))
expect_error(count_df(example_isolates[,"date"]))
})

View File

@ -30,15 +30,15 @@ test_that("EUCAST rules work", {
"then_change_these_antibiotics", "to_value",
"reference.rule", "reference.rule_group"))
expect_error(suppressWarnings(eucast_rules(septic_patients, col_mo = "Non-existing")))
expect_error(suppressWarnings(eucast_rules(example_isolates, col_mo = "Non-existing")))
expect_error(eucast_rules(x = "text"))
expect_error(eucast_rules(data.frame(a = "test")))
expect_error(eucast_rules(data.frame(mo = "test"), rules = "invalid rules set"))
expect_warning(eucast_rules(data.frame(mo = "Escherichia coli", vancomycin = "S")))
expect_identical(colnames(septic_patients),
colnames(suppressWarnings(eucast_rules(septic_patients))))
expect_identical(colnames(example_isolates),
colnames(suppressWarnings(eucast_rules(example_isolates))))
a <- data.frame(mo = c("Klebsiella pneumoniae",
"Pseudomonas aeruginosa",
@ -66,7 +66,7 @@ test_that("EUCAST rules work", {
# piperacillin must be R in Enterobacteriaceae when tica is R
library(dplyr)
expect_equal(suppressWarnings(
septic_patients %>%
example_isolates %>%
mutate(TIC = as.rsi("R"),
PIP = as.rsi("S")) %>%
eucast_rules(col_mo = "mo") %>%
@ -79,7 +79,7 @@ test_that("EUCAST rules work", {
# Azithromicin and Clarythromycin must be equal to Erythromycin
a <- suppressWarnings(
septic_patients %>%
example_isolates %>%
transmute(mo,
ERY,
AZM = as.rsi("R"),
@ -87,7 +87,7 @@ test_that("EUCAST rules work", {
eucast_rules(col_mo = "mo") %>%
pull(CLR))
b <- suppressWarnings(
septic_patients %>%
example_isolates %>%
select(mo, ERY) %>%
eucast_rules(col_mo = "mo") %>%
pull(ERY))
@ -108,9 +108,9 @@ test_that("EUCAST rules work", {
"S")
# also test norf
expect_output(suppressWarnings(eucast_rules(septic_patients %>% mutate(NOR = "S", NAL = "S"))))
expect_output(suppressWarnings(eucast_rules(example_isolates %>% mutate(NOR = "S", NAL = "S"))))
# check verbose output
expect_output(suppressWarnings(eucast_rules(septic_patients, verbose = TRUE)))
expect_output(suppressWarnings(eucast_rules(example_isolates, verbose = TRUE)))
})

View File

@ -23,22 +23,22 @@ context("filter_ab_class.R")
test_that("ATC-group filtering works", {
library(dplyr)
expect_gt(septic_patients %>% filter_ab_class("carbapenem") %>% nrow(), 0)
expect_gt(septic_patients %>% filter_aminoglycosides() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_carbapenems() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_cephalosporins() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_1st_cephalosporins() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_2nd_cephalosporins() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_3rd_cephalosporins() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_4th_cephalosporins() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_fluoroquinolones() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_glycopeptides() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_macrolides() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_tetracyclines() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_ab_class("carbapenem") %>% nrow(), 0)
expect_gt(example_isolates %>% filter_aminoglycosides() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_carbapenems() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_cephalosporins() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_1st_cephalosporins() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_2nd_cephalosporins() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_3rd_cephalosporins() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_4th_cephalosporins() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_fluoroquinolones() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_glycopeptides() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_macrolides() %>% nrow(), 0)
expect_gt(example_isolates %>% filter_tetracyclines() %>% nrow(), 0)
expect_gt(septic_patients %>% filter_carbapenems("R", "all") %>% nrow(), 0)
expect_gt(example_isolates %>% filter_carbapenems("R", "all") %>% nrow(), 0)
expect_error(septic_patients %>% filter_carbapenems(result = "test"))
expect_error(septic_patients %>% filter_carbapenems(scope = "test"))
expect_warning(septic_patients %>% select(1:3) %>% filter_carbapenems())
expect_error(example_isolates %>% filter_carbapenems(result = "test"))
expect_error(example_isolates %>% filter_carbapenems(scope = "test"))
expect_warning(example_isolates %>% select(1:3) %>% filter_carbapenems())
})

View File

@ -25,7 +25,7 @@ test_that("first isolates work", {
# first isolates
expect_equal(
sum(
first_isolate(x = septic_patients,
first_isolate(x = example_isolates,
col_date = "date",
col_patient_id = "patient_id",
col_mo = "mo",
@ -37,7 +37,7 @@ test_that("first isolates work", {
expect_equal(
suppressWarnings(
sum(
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
# let syntax determine these automatically:
# col_date = "date",
# col_patient_id = "patient_id",
@ -51,7 +51,7 @@ test_that("first isolates work", {
expect_equal(
suppressWarnings(
sum(
first_isolate(x = septic_patients %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
first_isolate(x = example_isolates %>% dplyr::as_tibble() %>% mutate(keyab = key_antibiotics(.)),
# let syntax determine these automatically:
# col_date = "date",
# col_patient_id = "patient_id",
@ -65,7 +65,7 @@ test_that("first isolates work", {
expect_equal(
suppressWarnings(
sum(
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
col_date = "date",
col_patient_id = "patient_id",
col_mo = "mo",
@ -79,7 +79,7 @@ test_that("first isolates work", {
expect_equal(
suppressWarnings(
sum(
first_isolate(x = septic_patients %>% mutate(keyab = key_antibiotics(.)),
first_isolate(x = example_isolates %>% mutate(keyab = key_antibiotics(.)),
col_date = "date",
col_patient_id = "patient_id",
col_mo = "mo",
@ -92,7 +92,7 @@ test_that("first isolates work", {
# first non-ICU isolates
expect_equal(
sum(
first_isolate(septic_patients,
first_isolate(example_isolates,
col_mo = "mo",
col_date = "date",
col_patient_id = "patient_id",
@ -106,7 +106,7 @@ test_that("first isolates work", {
random_rows <- sample(x = 1:2000, size = 1500, replace = FALSE)
expect_lt(
sum(
first_isolate(x = mutate(septic_patients,
first_isolate(x = mutate(example_isolates,
specimen = if_else(row_number() %in% random_rows,
"Urine",
"Other")),
@ -121,7 +121,7 @@ test_that("first isolates work", {
# same, but now exclude ICU
expect_lt(
sum(
first_isolate(x = mutate(septic_patients,
first_isolate(x = mutate(example_isolates,
specimen = if_else(row_number() %in% random_rows,
"Urine",
"Other")),
@ -137,7 +137,7 @@ test_that("first isolates work", {
1501)
# "No isolates found"
expect_message(septic_patients %>%
expect_message(example_isolates %>%
mutate(specimen = "test") %>%
mutate(first = first_isolate(., "date", "patient_id",
col_mo = "mo",
@ -145,7 +145,7 @@ test_that("first isolates work", {
filter_specimen = "something_unexisting")))
# printing of exclusion message
expect_output(septic_patients %>%
expect_output(example_isolates %>%
first_isolate(col_date = "date",
col_mo = "mo",
col_patient_id = "patient_id",
@ -154,29 +154,29 @@ test_that("first isolates work", {
# errors
expect_error(first_isolate("date", "patient_id", col_mo = "mo"))
expect_error(first_isolate(septic_patients,
expect_error(first_isolate(example_isolates,
col_date = "non-existing col",
col_mo = "mo"))
# look for columns itself
expect_message(first_isolate(septic_patients))
expect_message(first_isolate(septic_patients %>%
expect_message(first_isolate(example_isolates))
expect_message(first_isolate(example_isolates %>%
mutate(mo = as.character(mo)) %>%
left_join_microorganisms()))
# if mo is not an mo class, result should be the same
expect_identical(septic_patients %>%
expect_identical(example_isolates %>%
mutate(mo = as.character(mo)) %>%
first_isolate(col_date = "date",
col_mo = "mo",
col_patient_id = "patient_id"),
septic_patients %>%
example_isolates %>%
first_isolate(col_date = "date",
col_mo = "mo",
col_patient_id = "patient_id"))
# missing dates should be no problem
df <- septic_patients
df <- example_isolates
df[1:100, "date"] <- NA
expect_equal(
sum(
@ -189,19 +189,19 @@ test_that("first isolates work", {
1322)
# unknown MOs
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
mutate(first = first_isolate(., include_unknown = FALSE)) %>%
.$first %>%
sum(),
1062)
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
mutate(mo = ifelse(mo == "B_ESCHR_COL", "UNKNOWN", mo)) %>%
mutate(first = first_isolate(., include_unknown = TRUE)) %>%
.$first %>%
sum(),
1529)
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
mutate(mo = ifelse(mo == "B_ESCHR_COL", NA, mo)) %>%
mutate(first = first_isolate(.)) %>%
.$first %>%

View File

@ -24,10 +24,10 @@ context("freq.R")
test_that("frequency table works", {
library(clean)
# mo
expect_true(is.freq(freq(septic_patients$mo)))
expect_true(is.freq(freq(example_isolates$mo)))
# rsi
expect_true(is.freq(freq(septic_patients$AMX)))
expect_true(is.freq(freq(example_isolates$AMX)))
library(dplyr)
expect_true(is.freq(septic_patients %>% freq(mo)))
expect_true(is.freq(example_isolates %>% freq(mo)))
})

View File

@ -30,34 +30,34 @@ test_that("ggplot_rsi works", {
# data should be equal
expect_equal(
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi())$data %>%
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi())$data %>%
summarise_all(portion_IR) %>% as.double(),
septic_patients %>% select(AMC, CIP) %>%
example_isolates %>% select(AMC, CIP) %>%
summarise_all(portion_IR) %>% as.double()
)
print(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))
print(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))
print(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))
print(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))
expect_equal(
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>%
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "interpretation", facet = "antibiotic"))$data %>%
summarise_all(portion_IR) %>% as.double(),
septic_patients %>% select(AMC, CIP) %>%
example_isolates %>% select(AMC, CIP) %>%
summarise_all(portion_IR) %>% as.double()
)
expect_equal(
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>%
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic", facet = "interpretation"))$data %>%
summarise_all(portion_IR) %>% as.double(),
septic_patients %>% select(AMC, CIP) %>%
example_isolates %>% select(AMC, CIP) %>%
summarise_all(portion_IR) %>% as.double()
)
expect_equal(
(septic_patients %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic",
(example_isolates %>% select(AMC, CIP) %>% ggplot_rsi(x = "antibiotic",
facet = "interpretation"))$data %>%
summarise_all(count_IR) %>% as.double(),
septic_patients %>% select(AMC, CIP) %>%
example_isolates %>% select(AMC, CIP) %>%
summarise_all(count_IR) %>% as.double()
)

View File

@ -23,15 +23,15 @@ context("guess_ab_col.R")
test_that("guess_ab_col works", {
expect_equal(guess_ab_col(septic_patients, "amox"),
expect_equal(guess_ab_col(example_isolates, "amox"),
"AMX")
expect_equal(guess_ab_col(septic_patients, "amoxicillin"),
expect_equal(guess_ab_col(example_isolates, "amoxicillin"),
"AMX")
expect_equal(guess_ab_col(septic_patients, "J01AA07"),
expect_equal(guess_ab_col(example_isolates, "J01AA07"),
"TCY")
expect_equal(guess_ab_col(septic_patients, "tetracycline"),
expect_equal(guess_ab_col(example_isolates, "tetracycline"),
"TCY")
expect_equal(guess_ab_col(septic_patients, "TETR"),
expect_equal(guess_ab_col(example_isolates, "TETR"),
"TCY")
df <- data.frame(AMP_ND10 = "R",

View File

@ -22,13 +22,13 @@
context("join_microorganisms.R")
test_that("joins work", {
unjoined <- septic_patients
inner <- septic_patients %>% inner_join_microorganisms()
left <- septic_patients %>% left_join_microorganisms()
semi <- septic_patients %>% semi_join_microorganisms()
anti <- septic_patients %>% anti_join_microorganisms()
suppressWarnings(right <- septic_patients %>% right_join_microorganisms())
suppressWarnings(full <- septic_patients %>% full_join_microorganisms())
unjoined <- example_isolates
inner <- example_isolates %>% inner_join_microorganisms()
left <- example_isolates %>% left_join_microorganisms()
semi <- example_isolates %>% semi_join_microorganisms()
anti <- example_isolates %>% anti_join_microorganisms()
suppressWarnings(right <- example_isolates %>% right_join_microorganisms())
suppressWarnings(full <- example_isolates %>% full_join_microorganisms())
expect_true(ncol(unjoined) < ncol(inner))
expect_true(nrow(unjoined) == nrow(inner))

View File

@ -22,8 +22,8 @@
context("key_antibiotics.R")
test_that("keyantibiotics work", {
expect_equal(length(key_antibiotics(septic_patients, warnings = FALSE)), nrow(septic_patients))
expect_false(all(is.na(key_antibiotics(septic_patients))))
expect_equal(length(key_antibiotics(example_isolates, warnings = FALSE)), nrow(example_isolates))
expect_false(all(is.na(key_antibiotics(example_isolates))))
expect_true(key_antibiotics_equal("SSS", "SSS"))
expect_false(key_antibiotics_equal("SSS", "SRS"))
expect_true(key_antibiotics_equal("SSS", "SIS", ignore_I = TRUE))

View File

@ -22,13 +22,13 @@
context("kurtosis.R")
test_that("kurtosis works", {
expect_equal(kurtosis(septic_patients$age),
expect_equal(kurtosis(example_isolates$age),
3.549319,
tolerance = 0.00001)
expect_equal(unname(kurtosis(data.frame(septic_patients$age))),
expect_equal(unname(kurtosis(data.frame(example_isolates$age))),
3.549319,
tolerance = 0.00001)
expect_equal(kurtosis(matrix(septic_patients$age)),
expect_equal(kurtosis(matrix(example_isolates$age)),
3.549319,
tolerance = 0.00001)
})

View File

@ -24,29 +24,29 @@ context("mdro.R")
test_that("mdro works", {
library(dplyr)
expect_error(suppressWarnings(mdro(septic_patients, country = "invalid", col_mo = "mo", info = TRUE)))
expect_error(suppressWarnings(mdro(septic_patients, country = "fr", info = TRUE)))
expect_error(mdro(septic_patients, guideline = c("BRMO", "MRGN"), info = TRUE))
expect_error(mdro(septic_patients, col_mo = "invalid", info = TRUE))
expect_error(suppressWarnings(mdro(example_isolates, country = "invalid", col_mo = "mo", info = TRUE)))
expect_error(suppressWarnings(mdro(example_isolates, country = "fr", info = TRUE)))
expect_error(mdro(example_isolates, guideline = c("BRMO", "MRGN"), info = TRUE))
expect_error(mdro(example_isolates, col_mo = "invalid", info = TRUE))
outcome <- mdro(septic_patients)
outcome <- eucast_exceptional_phenotypes(septic_patients, info = TRUE)
outcome <- mdro(example_isolates)
outcome <- eucast_exceptional_phenotypes(example_isolates, info = TRUE)
# check class
expect_equal(outcome %>% class(), c('ordered', 'factor'))
outcome <- mdro(septic_patients, "nl", info = TRUE)
outcome <- mdro(example_isolates, "nl", info = TRUE)
# check class
expect_equal(outcome %>% class(), c('ordered', 'factor'))
# septic_patients should have these finding using Dutch guidelines
# example_isolates should have these finding using Dutch guidelines
expect_equal(outcome %>% freq() %>% pull(count),
c(1969, 25, 6)) # 1969 neg, 25 unconfirmed, 6 pos
expect_equal(brmo(septic_patients, info = FALSE),
mdro(septic_patients, guideline = "BRMO", info = FALSE))
expect_equal(brmo(example_isolates, info = FALSE),
mdro(example_isolates, guideline = "BRMO", info = FALSE))
# still working on German guidelines
expect_error(suppressWarnings(mrgn(septic_patients, info = TRUE)))
expect_error(suppressWarnings(mrgn(example_isolates, info = TRUE)))
# test Dutch P. aeruginosa MDRO
expect_equal(
@ -80,8 +80,8 @@ test_that("mdro works", {
expect_equal(
# select only rifampicine, mo will be determined automatically (as M. tuberculosis),
# number of mono-resistant strains should be equal to number of rifampicine-resistant strains
septic_patients %>% select(RIF) %>% mdr_tb() %>% freq() %>% pull(count) %>% .[2],
count_R(septic_patients$RIF))
example_isolates %>% select(RIF) %>% mdr_tb() %>% freq() %>% pull(count) %>% .[2],
count_R(example_isolates$RIF))
sample_rsi <- function() {
sample(c("S", "I", "R"),

View File

@ -42,8 +42,8 @@ test_that("functions missing in older R versions work", {
test_that("looking up ab columns works", {
expect_warning(generate_warning_abs_missing(c("AMP", "AMX")))
expect_warning(generate_warning_abs_missing(c("AMP", "AMX"), any = TRUE))
expect_warning(get_column_abx(septic_patients, hard_dependencies = "FUS"))
expect_message(get_column_abx(septic_patients, soft_dependencies = "FUS"))
expect_message(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
expect_warning(get_column_abx(dplyr::rename(septic_patients, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
expect_warning(get_column_abx(example_isolates, hard_dependencies = "FUS"))
expect_message(get_column_abx(example_isolates, soft_dependencies = "FUS"))
expect_message(get_column_abx(dplyr::rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = TRUE))
expect_warning(get_column_abx(dplyr::rename(example_isolates, thisone = AMX), amox = "thisone", tmp = "thisone", verbose = FALSE))
})

View File

@ -147,7 +147,7 @@ test_that("as.mo works", {
# select with one column
expect_identical(
septic_patients[1:10,] %>%
example_isolates[1:10,] %>%
left_join_microorganisms() %>%
select(genus) %>%
as.mo() %>%
@ -157,9 +157,9 @@ test_that("as.mo works", {
# select with two columns
expect_identical(
septic_patients[1:10,] %>%
example_isolates[1:10,] %>%
pull(mo),
septic_patients[1:10,] %>%
example_isolates[1:10,] %>%
left_join_microorganisms() %>%
select(genus, species) %>%
as.mo())
@ -168,13 +168,13 @@ test_that("as.mo works", {
expect_warning(as.mo(c("INVALID", "Yeah, unknown")))
# too many columns
expect_error(septic_patients %>% select(1:3) %>% as.mo())
expect_error(example_isolates %>% select(1:3) %>% as.mo())
# print
expect_output(print(as.mo(c("B_ESCHR_COL", NA))))
# test pull
expect_equal(nrow(septic_patients %>% mutate(mo = as.mo(mo))),
expect_equal(nrow(example_isolates %>% mutate(mo = as.mo(mo))),
2000)
# test data.frame
@ -248,7 +248,7 @@ test_that("as.mo works", {
expect_warning(as.mo("Virus"))
# summary
expect_equal(length(summary(septic_patients$mo)), 6)
expect_equal(length(summary(example_isolates$mo)), 6)
# WHONET codes and NA/NaN
expect_equal(as.character(as.mo(c("xxx", "na", "nan"), debug = TRUE)),
@ -260,7 +260,7 @@ test_that("as.mo works", {
rep("UNKNOWN", 3))
expect_null(mo_failures())
expect_true(septic_patients %>% pull(mo) %>% is.mo())
expect_true(example_isolates %>% pull(mo) %>% is.mo())
# expect_equal(get_mo_code("test", "mo"), "test")
# expect_equal(length(get_mo_code("Escherichia", "genus")),
@ -286,7 +286,7 @@ test_that("as.mo works", {
expect_output(print(tibble(mo = as.mo("B_STRPT_PNE"))))
# assigning and subsetting
x <- septic_patients$mo
x <- example_isolates$mo
expect_s3_class(x[1], "mo")
expect_s3_class(x[[1]], "mo")
expect_s3_class(c(x[1], x[9]), "mo")

View File

@ -22,28 +22,28 @@
context("portion.R")
test_that("portions works", {
# AMX resistance in `septic_patients`
expect_equal(portion_R(septic_patients$AMX), 0.5557364, tolerance = 0.0001)
expect_equal(portion_I(septic_patients$AMX), 0.002441009, tolerance = 0.0001)
expect_equal(1 - portion_R(septic_patients$AMX) - portion_I(septic_patients$AMX),
portion_S(septic_patients$AMX))
expect_equal(portion_R(septic_patients$AMX) + portion_I(septic_patients$AMX),
portion_IR(septic_patients$AMX))
expect_equal(portion_S(septic_patients$AMX) + portion_I(septic_patients$AMX),
portion_SI(septic_patients$AMX))
# AMX resistance in `example_isolates`
expect_equal(portion_R(example_isolates$AMX), 0.5557364, tolerance = 0.0001)
expect_equal(portion_I(example_isolates$AMX), 0.002441009, tolerance = 0.0001)
expect_equal(1 - portion_R(example_isolates$AMX) - portion_I(example_isolates$AMX),
portion_S(example_isolates$AMX))
expect_equal(portion_R(example_isolates$AMX) + portion_I(example_isolates$AMX),
portion_IR(example_isolates$AMX))
expect_equal(portion_S(example_isolates$AMX) + portion_I(example_isolates$AMX),
portion_SI(example_isolates$AMX))
expect_equal(septic_patients %>% portion_SI(AMC),
expect_equal(example_isolates %>% portion_SI(AMC),
0.7626397,
tolerance = 0.0001)
expect_equal(septic_patients %>% portion_SI(AMC, GEN),
expect_equal(example_isolates %>% portion_SI(AMC, GEN),
0.9408,
tolerance = 0.0001)
expect_equal(septic_patients %>% portion_SI(AMC, GEN, only_all_tested = TRUE),
expect_equal(example_isolates %>% portion_SI(AMC, GEN, only_all_tested = TRUE),
0.9382647,
tolerance = 0.0001)
# percentages
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
group_by(hospital_id) %>%
summarise(R = portion_R(CIP, as_percent = TRUE),
I = portion_I(CIP, as_percent = TRUE),
@ -55,7 +55,7 @@ test_that("portions works", {
1409)
# count of cases
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
group_by(hospital_id) %>%
summarise(cipro_p = portion_SI(CIP, as_percent = TRUE),
cipro_n = n_rsi(CIP),
@ -66,14 +66,14 @@ test_that("portions works", {
pull(combination_n),
c(305, 617, 241, 711))
expect_warning(portion_R(as.character(septic_patients$AMC)))
expect_warning(portion_S(as.character(septic_patients$AMC)))
expect_warning(portion_S(as.character(septic_patients$AMC,
septic_patients$GEN)))
expect_warning(n_rsi(as.character(septic_patients$AMC,
septic_patients$GEN)))
expect_equal(suppressWarnings(n_rsi(as.character(septic_patients$AMC,
septic_patients$GEN))),
expect_warning(portion_R(as.character(example_isolates$AMC)))
expect_warning(portion_S(as.character(example_isolates$AMC)))
expect_warning(portion_S(as.character(example_isolates$AMC,
example_isolates$GEN)))
expect_warning(n_rsi(as.character(example_isolates$AMC,
example_isolates$GEN)))
expect_equal(suppressWarnings(n_rsi(as.character(example_isolates$AMC,
example_isolates$GEN))),
1879)
# check for errors
@ -86,36 +86,36 @@ test_that("portions works", {
expect_error(portion_S("test", also_single_tested = TRUE))
# check too low amount of isolates
expect_identical(suppressWarnings(portion_R(septic_patients$AMX, minimum = nrow(septic_patients) + 1)),
expect_identical(suppressWarnings(portion_R(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
NA)
expect_identical(suppressWarnings(portion_I(septic_patients$AMX, minimum = nrow(septic_patients) + 1)),
expect_identical(suppressWarnings(portion_I(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
NA)
expect_identical(suppressWarnings(portion_S(septic_patients$AMX, minimum = nrow(septic_patients) + 1)),
expect_identical(suppressWarnings(portion_S(example_isolates$AMX, minimum = nrow(example_isolates) + 1)),
NA)
# warning for speed loss
expect_warning(portion_R(as.character(septic_patients$GEN)))
expect_warning(portion_I(as.character(septic_patients$GEN)))
expect_warning(portion_S(septic_patients$AMC, as.character(septic_patients$GEN)))
expect_warning(portion_R(as.character(example_isolates$GEN)))
expect_warning(portion_I(as.character(example_isolates$GEN)))
expect_warning(portion_S(example_isolates$AMC, as.character(example_isolates$GEN)))
# portion_df
expect_equal(
septic_patients %>% select(AMX) %>% portion_df() %>% pull(value),
c(septic_patients$AMX %>% portion_SI(),
septic_patients$AMX %>% portion_R())
example_isolates %>% select(AMX) %>% portion_df() %>% pull(value),
c(example_isolates$AMX %>% portion_SI(),
example_isolates$AMX %>% portion_R())
)
expect_equal(
septic_patients %>% select(AMX) %>% portion_df(combine_IR = TRUE) %>% pull(value),
c(septic_patients$AMX %>% portion_S(),
septic_patients$AMX %>% portion_IR())
example_isolates %>% select(AMX) %>% portion_df(combine_IR = TRUE) %>% pull(value),
c(example_isolates$AMX %>% portion_S(),
example_isolates$AMX %>% portion_IR())
)
expect_equal(
septic_patients %>% select(AMX) %>% portion_df(combine_SI = FALSE) %>% pull(value),
c(septic_patients$AMX %>% portion_S(),
septic_patients$AMX %>% portion_I(),
septic_patients$AMX %>% portion_R())
example_isolates %>% select(AMX) %>% portion_df(combine_SI = FALSE) %>% pull(value),
c(example_isolates$AMX %>% portion_S(),
example_isolates$AMX %>% portion_I(),
example_isolates$AMX %>% portion_R())
)
expect_error(portion_df(c("A", "B", "C")))
expect_error(portion_df(septic_patients[,"date"]))
expect_error(portion_df(example_isolates[,"date"]))
})

View File

@ -22,7 +22,7 @@
context("resistance_predict.R")
test_that("prediction of rsi works", {
AMX_R <- septic_patients %>%
AMX_R <- example_isolates %>%
filter(mo == "B_ESCHR_COL") %>%
rsi_predict(col_ab = "AMX",
col_date = "date",
@ -30,57 +30,57 @@ test_that("prediction of rsi works", {
minimum = 10,
info = TRUE) %>%
pull("value")
# AMX resistance will increase according to data set `septic_patients`
# AMX resistance will increase according to data set `example_isolates`
expect_true(AMX_R[3] < AMX_R[20])
x <- resistance_predict(septic_patients, col_ab = "AMX", year_min = 2010, model = "binomial")
x <- resistance_predict(example_isolates, col_ab = "AMX", year_min = 2010, model = "binomial")
plot(x)
ggplot_rsi_predict(x)
expect_error(ggplot_rsi_predict(septic_patients))
expect_error(ggplot_rsi_predict(example_isolates))
library(dplyr)
expect_output(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "binomial",
col_ab = "AMX",
col_date = "date",
info = TRUE))
expect_output(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "loglin",
col_ab = "AMX",
col_date = "date",
info = TRUE))
expect_output(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_output(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "lin",
col_ab = "AMX",
col_date = "date",
info = TRUE))
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "INVALID MODEL",
col_ab = "AMX",
col_date = "date",
info = TRUE))
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "binomial",
col_ab = "NOT EXISTING COLUMN",
col_date = "date",
info = TRUE))
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "binomial",
col_ab = "AMX",
col_date = "NOT EXISTING COLUMN",
info = TRUE))
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
col_ab = "AMX",
col_date = "NOT EXISTING COLUMN",
info = TRUE))
expect_error(rsi_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_error(rsi_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
col_ab = "AMX",
col_date = "date",
info = TRUE))
# almost all E. coli are MEM S in the Netherlands :)
expect_error(resistance_predict(x = filter(septic_patients, mo == "B_ESCHR_COL"),
expect_error(resistance_predict(x = filter(example_isolates, mo == "B_ESCHR_COL"),
model = "binomial",
col_ab = "MEM",
col_date = "date",

View File

@ -41,12 +41,12 @@ test_that("rsi works", {
"-Sum R" = "1",
"-Sum I" = "0"))
expect_identical(as.logical(lapply(septic_patients, is.rsi.eligible)),
rep(FALSE, length(septic_patients)))
expect_identical(as.logical(lapply(example_isolates, is.rsi.eligible)),
rep(FALSE, length(example_isolates)))
library(dplyr)
# 40 rsi columns
expect_equal(septic_patients %>%
expect_equal(example_isolates %>%
mutate_at(vars(PEN:RIF), as.character) %>%
lapply(is.rsi.eligible) %>%
as.logical() %>%
@ -69,7 +69,7 @@ test_that("mic2rsi works", {
guideline = "EUCAST")),
"R")
expect_true(septic_patients %>%
expect_true(example_isolates %>%
mutate(amox_mic = as.mic(2)) %>%
select(mo, amox_mic) %>%
as.rsi() %>%
@ -97,7 +97,7 @@ test_that("disk2rsi works", {
guideline = "CLSI")),
"R")
expect_true(septic_patients %>%
expect_true(example_isolates %>%
mutate(amox_disk = as.disk(15)) %>%
select(mo, amox_disk) %>%
as.rsi(guideline = "CLSI") %>%

View File

@ -22,13 +22,13 @@
context("skewness.R")
test_that("skewness works", {
expect_equal(skewness(septic_patients$age),
expect_equal(skewness(example_isolates$age),
-0.8958019,
tolerance = 0.00001)
expect_equal(unname(skewness(data.frame(septic_patients$age))),
expect_equal(unname(skewness(data.frame(example_isolates$age))),
-0.8958019,
tolerance = 0.00001)
expect_equal(skewness(matrix(septic_patients$age)),
expect_equal(skewness(matrix(example_isolates$age)),
-0.8958019,
tolerance = 0.00001)
})

View File

@ -461,12 +461,12 @@ data_1st %>%
## Independence test
The next example uses the included `septic_patients`, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This `data.frame` can be used to practice AMR analysis.
The next example uses the included `example_isolates`, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. This `data.frame` can be used to practice AMR analysis.
We will compare the resistance to fosfomycin (column `FOS`) in hospital A and D. The input for the `fisher.test()` can be retrieved with a transformation like this:
```{r, results = 'markup'}
check_FOS <- septic_patients %>%
check_FOS <- example_isolates %>%
filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
select(hospital_id, FOS) %>% # select the hospitals and fosfomycin
group_by(hospital_id) %>% # group on the hospitals

View File

@ -114,8 +114,8 @@ Repetitive results are unique values that are present more than once. Unique val
```{r, message = FALSE}
library(dplyr)
# take all MO codes from the septic_patients data set
x <- septic_patients$mo %>%
# take all MO codes from the example_isolates data set
x <- example_isolates$mo %>%
# keep only the unique ones
unique() %>%
# pick 50 of them at random

View File

@ -42,15 +42,15 @@ Our package contains a function `resistance_predict()`, which takes the same inp
It is basically as easy as:
```{r, eval = FALSE}
# resistance prediction of piperacillin/tazobactam (TZP):
resistance_predict(tbl = septic_patients, col_date = "date", col_ab = "TZP", model = "binomial")
resistance_predict(tbl = example_isolates, col_date = "date", col_ab = "TZP", model = "binomial")
# or:
septic_patients %>%
example_isolates %>%
resistance_predict(col_ab = "TZP",
model "binomial")
# to bind it to object 'predict_TZP' for example:
predict_TZP <- septic_patients %>%
predict_TZP <- example_isolates %>%
resistance_predict(col_ab = "TZP",
model = "binomial")
```
@ -60,7 +60,7 @@ The function will look for a date column itself if `col_date` is not set.
When running any of these commands, a summary of the regression model will be printed unless using `resistance_predict(..., info = FALSE)`.
```{r, echo = FALSE}
predict_TZP <- septic_patients %>%
predict_TZP <- example_isolates %>%
resistance_predict(col_ab = "TZP", model = "binomial")
```
@ -92,7 +92,7 @@ ggplot_rsi_predict(predict_TZP, ribbon = FALSE)
Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:
```{r}
septic_patients %>%
example_isolates %>%
filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>%
ggplot_rsi_predict()
@ -113,7 +113,7 @@ Valid values are:
For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:
```{r}
septic_patients %>%
example_isolates %>%
filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "linear") %>%
ggplot_rsi_predict()