diff --git a/DESCRIPTION b/DESCRIPTION index 76a7bc83..a9dd97d9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.1.0.9018 -Date: 2020-05-22 +Version: 1.1.0.9019 +Date: 2020-05-25 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index be5d3b54..c1eb90b1 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.1.0.9018 -## Last updated: 22-May-2020 +# AMR 1.1.0.9019 +## Last updated: 25-May-2020 ### Breaking * Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users. @@ -20,7 +20,8 @@ * Improvements for algorithm in `as.ab()`, so that e.g. `as.ab("ampi sul")` and `ab_name("ampi sul")` work * Functions `ab_atc()` and `ab_group()` now return `NA` if no antimicrobial agent could be found * Small fix for some text input that could not be coerced as valid MIC values -* Fixed interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood) +* Fix for interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood) +* Fix for `set_mo_source()` to make sure that column `mo` will always be the second column ### Other * Removed previously deprecated function `p.symbol()` - it was replaced with `p_symbol()` diff --git a/R/ab_property.R b/R/ab_property.R index a51fa8be..3a021818 100644 --- a/R/ab_property.R +++ b/R/ab_property.R @@ -22,7 +22,7 @@ #' Property of an antibiotic #' #' Use these functions to return a specific property of an antibiotic from the [antibiotics] data set. All input values will be evaluated internally with [as.ab()]. -#' @inheritSection lifecycle Maturing lifecycle +#' @inheritSection lifecycle Stable lifecycle #' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.ab()] #' @param tolower logical to indicate whether the first character of every output should be transformed to a lower case character. This will lead to e.g. "polymyxin B" and not "polymyxin b". #' @param property one of the column names of one of the [antibiotics] data set @@ -33,7 +33,7 @@ #' @param ... other parameters passed on to [as.ab()] #' @details All output will be [translate]d where possible. #' -#' The function [ab_url()] will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available. +#' The function [ab_url()] will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available. #' @inheritSection as.ab Source #' @rdname ab_property #' @name ab_property diff --git a/R/mo_property.R b/R/mo_property.R index c6409fdf..40a08dca 100755 --- a/R/mo_property.R +++ b/R/mo_property.R @@ -22,6 +22,7 @@ #' Property of a microorganism #' #' Use these functions to return a specific property of a microorganism. All input values will be evaluated internally with [as.mo()], which makes it possible to use microbial abbreviations, codes and names as input. Please see *Examples*. +#' @inheritSection lifecycle Stable lifecycle #' @param x any (vector of) text that can be coerced to a valid microorganism code with [as.mo()] #' @param property one of the column names of the [microorganisms] data set or `"shortname"` #' @param language language of the returned text, defaults to system language (see [get_locale()]) and can also be set with `getOption("AMR_locale")`. Use `language = NULL` or `language = ""` to prevent translation. diff --git a/R/mo_source.R b/R/mo_source.R index b44b79d4..611b7524 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -19,13 +19,13 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -#' Use predefined reference data set +#' User-defined reference data set for microorganisms #' #' @description These functions can be used to predefine your own reference to be used in [as.mo()] and consequently all `mo_*` functions like [mo_genus()] and [mo_gramstain()]. #' #' This is **the fastest way** to have your organisation (or analysis) specific codes picked up and translated by this package. #' @inheritSection lifecycle Stable lifecycle -#' @param path location of your reference file, see Details +#' @param path location of your reference file, see Details. Can be `""`, `NULL` or `FALSE` to delete the reference file. #' @rdname mo_source #' @name mo_source #' @aliases set_mo_source get_mo_source @@ -35,11 +35,12 @@ #' #' [get_mo_source()] will return the data set by reading `"~/.mo_source.rds"` with [readRDS()]. If the original file has changed (the file defined with `path`), it will call [set_mo_source()] to update the data file automatically. #' -#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (a millionth of a second). +#' Reading an Excel file (`.xlsx`) with only one row has a size of 8-9 kB. The compressed file created with [set_mo_source()] will then have a size of 0.1 kB and can be read by [get_mo_source()] in only a couple of microseconds (millionths of a second). #' -#' ## How it works +#' @section How to setup: +#' +#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the [microorganisms] data set). The first column contains the organisation specific codes, the second column contains an MO code from this package: #' -#' Imagine this data on a sheet of an Excel file (mo codes were looked up in the `microorganisms` data set). The first column contains the organisation specific codes, the second column contains an MO code from this package: #' ``` #' | A | B | #' --|--------------------|--------------| @@ -50,27 +51,31 @@ #' ``` #' #' We save it as `"home/me/ourcodes.xlsx"`. Now we have to set it as a source: +#' #' ``` #' set_mo_source("home/me/ourcodes.xlsx") -#' # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +#' #> NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx' +#' #> (columns "Organisation XYZ" and "mo") #' ``` #' -#' It has now created a file `"~/.mo_source.rds"` with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept. +#' It has now created a file `"~/.mo_source.rds"` with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file. #' #' And now we can use it in our functions: +#' #' ``` #' as.mo("lab_mo_ecoli") -#' [1] B_ESCHR_COLI +#' #> [1] B_ESCHR_COLI #' #' mo_genus("lab_mo_kpneumoniae") -#' [1] "Klebsiella" +#' #> [1] "Klebsiella" #' #' # other input values still work too #' as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli")) -#' [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI +#' #> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI #' ``` #' -#' If we edit the Excel file to, let's say, by adding row 4 like this: +#' If we edit the Excel file by, let's say, adding row 4 like this: +#' #' ``` #' | A | B | #' --|--------------------|--------------| @@ -82,36 +87,41 @@ #' ``` #' #' ...any new usage of an MO function in this package will update your data file: +#' #' ``` #' as.mo("lab_mo_ecoli") -#' # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -#' [1] B_ESCHR_COLI +#' #> NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx' +#' #> (columns "Organisation XYZ" and "mo") +#' #> [1] B_ESCHR_COLI #' #' mo_genus("lab_Staph_aureus") -#' [1] "Staphylococcus" +#' #> [1] "Staphylococcus" #' ``` #' -#' To remove the reference data file completely, just use `""` or `NULL` as input for `[set_mo_source()]`: +#' To delete the reference data file, just use `""`, `NULL` or `FALSE` as input for [set_mo_source()]: +#' #' ``` #' set_mo_source(NULL) #' # Removed mo_source file '~/.mo_source.rds'. #' ``` +#' +#' If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of [as.mo()]. If the mo_source file is manually deleted (i.e. without using [set_mo_source()]), the references to the mo_source file will be removed upon the next use of [as.mo()]. #' @export #' @inheritSection AMR Read more on our website! set_mo_source <- function(path) { file_location <- path.expand("~/mo_source.rds") - if (!is.character(path) | length(path) > 1) { - stop("`path` must be a character of length 1.") + if (length(path) > 1) { + stop("`path` must be of length 1.") } - if (path %in% c(NULL, "")) { + if (is.null(path) || path %in% c(FALSE, "")) { options(mo_source = NULL) options(mo_source_timestamp = NULL) if (file.exists(file_location)) { unlink(file_location) - message("Removed mo_source file '", file_location, "'.") + message(font_red(paste0("Removed mo_source file '", font_bold(file_location), "'"))) } return(invisible()) } @@ -154,13 +164,13 @@ set_mo_source <- function(path) { # check integrity mo_source_isvalid(df) - df <- df %>% filter(!is.na(mo)) + df <- subset(df, !is.na(mo)) # keep only first two columns, second must be mo if (colnames(df)[1] == "mo") { - df <- df[, c(2, 1)] + df <- df[, c(colnames(df)[2], "mo")] } else { - df <- df[, c(1, 2)] + df <- df[, c(colnames(df)[1], "mo")] } df <- as.data.frame(df, stringAsFactors = FALSE) @@ -174,30 +184,40 @@ set_mo_source <- function(path) { saveRDS(df, file_location) options(mo_source = path) options(mo_source_timestamp = as.character(file.info(path)$mtime)) - message(action, " mo_source file '", file_location, "' from '", path, "'.") + message(font_blue(paste0("NOTE: ", + action, " mo_source file '", font_bold(file_location), "'", + " from '", font_bold(path), "'", + '\n (columns "', colnames(df)[1], '" and "', colnames(df)[2], '")'))) } #' @rdname mo_source #' @export get_mo_source <- function() { if (is.null(getOption("mo_source", NULL))) { - NULL - } else { - old_time <- as.POSIXct(getOption("mo_source_timestamp")) - new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime)) - - if (is.na(new_time)) { - # source file was deleted, remove reference too - set_mo_source("") - return(NULL) - } - if (new_time != old_time) { - # set updated source - set_mo_source(getOption("mo_source")) - } - file_location <- path.expand("~/mo_source.rds") - readRDS(file_location) + return(NULL) } + + if (!file.exists(path.expand("~/mo_source.rds"))) { + options(mo_source = NULL) + options(mo_source_timestamp = NULL) + message(font_blue("NOTE: Removed references to deleted mo_source file (see ?mo_source)")) + return(NULL) + } + + old_time <- as.POSIXct(getOption("mo_source_timestamp")) + new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime)) + + if (is.na(new_time)) { + # source file was deleted, remove reference too + set_mo_source("") + return(NULL) + } + if (new_time != old_time) { + # set updated source + set_mo_source(getOption("mo_source")) + } + file_location <- path.expand("~/mo_source.rds") + readRDS(file_location) } mo_source_isvalid <- function(x, refer_to_name = "`reference_df`", stop_on_error = TRUE) { diff --git a/docs/404.html b/docs/404.html index 9a2803fa..322b2c22 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 2c558f42..4ceeb702 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index fd2e26e5..1d459a7a 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.1.0.9015 + 1.1.0.9019 @@ -186,7 +186,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

20 May 2020

+

25 May 2020

Source: vignettes/AMR.Rmd @@ -195,7 +195,7 @@ -

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 20 May 2020.

+

Note: values on this page will change with every website update since they are based on randomly created values and the page was written in R Markdown. However, the methodology remains unchanged. This page was generated on 25 May 2020.

Introduction

@@ -226,21 +226,21 @@ -2020-05-20 +2020-05-25 abcd Escherichia coli S S -2020-05-20 +2020-05-25 abcd Escherichia coli S R -2020-05-20 +2020-05-25 efgh Escherichia coli R @@ -336,41 +336,63 @@ -2013-03-27 -L8 +2015-03-17 +U1 +Hospital D +Escherichia coli +S +S +S +S +F + + +2017-08-02 +P6 Hospital B Streptococcus pneumoniae R S S S +F + + +2017-06-24 +E4 +Hospital C +Escherichia coli +S +S +S +S M -2015-12-30 -K1 -Hospital B -Staphylococcus aureus +2011-02-12 +I10 +Hospital D +Streptococcus pneumoniae +R S S R -S M -2016-06-06 -D3 -Hospital B +2010-03-17 +Q3 +Hospital C Staphylococcus aureus -S -S R S -M +S +S +F -2011-07-04 -H10 +2010-08-19 +A7 Hospital D Escherichia coli S @@ -379,28 +401,6 @@ S M - -2012-04-12 -M3 -Hospital B -Staphylococcus aureus -R -S -S -S -M - - -2017-03-06 -S4 -Hospital C -Escherichia coli -S -S -S -S -F -

Now, let’s start the cleaning and the analysis!

@@ -432,16 +432,16 @@ Longest: 1

1 M -10,319 -51.60% -10,319 -51.60% +10,403 +52.02% +10,403 +52.02% 2 F -9,681 -48.41% +9,597 +47.99% 20,000 100.00% @@ -456,11 +456,7 @@ Longest: 1

mutate_at(vars(AMX:GEN), as.rsi)

Finally, we will apply EUCAST rules on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the eucast_rules() function can also apply additional rules, like forcing ampicillin = R when amoxicillin/clavulanic acid = R.

Because the amoxicillin (column AMX) and amoxicillin/clavulanic acid (column AMC) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The eucast_rules() fixes this:

-
data <- eucast_rules(data, col_mo = "bacteria")
-# [31m
-# Skipping inheritance rules defined by this package, such as setting trimethoprim (TMP) = R where trimethoprim/sulfamethoxazole (SXT) = R.
-# Use eucast_rules(..., rules = "all") to also apply those rules.
-# [39m
+
data <- eucast_rules(data, col_mo = "bacteria")

@@ -482,10 +478,10 @@ Longest: 1

This AMR package includes this methodology with the first_isolate() function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:

data <- data %>%
   mutate(first = first_isolate(.))
-# [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m
-# [34mNOTE: Using column `[1mdate[22m` as input for `col_date`.[39m
-# [34mNOTE: Using column `[1mpatient_id[22m` as input for `col_patient_id`.[39m
-

So only 28.5% is suitable for resistance analysis! We can now filter on it with the filter() function, also from the dplyr package:

+# NOTE: Using column `bacteria` as input for `col_mo`. +# NOTE: Using column `date` as input for `col_date`. +# NOTE: Using column `patient_id` as input for `col_patient_id`.

+

So only 28.2% is suitable for resistance analysis! We can now filter on it with the filter() function, also from the dplyr package:

data_1st <- data %>%
   filter(first == TRUE)

For future use, the above two syntaxes can be shortened with the filter_first_isolate() function:

@@ -495,7 +491,7 @@ Longest: 1

First weighted isolates

-

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 S1, sorted on date:

+

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 K4, sorted on date:

@@ -511,32 +507,32 @@ Longest: 1

- - + + - - - + + + - - + + + + - - - - + + - + @@ -544,8 +540,8 @@ Longest: 1

- - + + @@ -555,19 +551,19 @@ Longest: 1

- - + + - - - + + + - - + + @@ -577,10 +573,10 @@ Longest: 1

- - + + - + @@ -588,30 +584,30 @@ Longest: 1

- - + + - - + + - - + + - - + + - - + + @@ -621,16 +617,16 @@ Longest: 1

isolate
12010-02-10S12010-01-01K4 B_ESCHR_COLISSS RRSS TRUE
22010-02-27S12010-02-09K4 B_ESCHR_COLISI R SSS FALSE
32010-03-05S12010-03-03K4 B_ESCHR_COLISI S R S
42010-04-03S12010-04-25K4 B_ESCHR_COLI S S
52010-05-22S12010-07-04K4 B_ESCHR_COLIRRRSSS S FALSE
62010-07-19S12010-09-04K4 B_ESCHR_COLI S I
72010-07-19S12010-10-01K4 B_ESCHR_COLISI S R S
82010-08-28S12011-03-20K4 B_ESCHR_COLII S S SFALSESTRUE
92010-09-09S12011-06-26K4 B_ESCHR_COLIRR SRR S FALSE
102010-09-20S12011-10-22K4 B_ESCHR_COLI S S
-

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 key_antibiotics() 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.

+

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 key_antibiotics() 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.

If a column exists with a name like ‘key(…)ab’ the first_isolate() function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:

data <- data %>%
   mutate(keyab = key_antibiotics(.)) %>%
   mutate(first_weighted = first_isolate(.))
-# [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m
-# [34mNOTE: Using column `[1mbacteria[22m` as input for `col_mo`.[39m
-# [34mNOTE: Using column `[1mdate[22m` as input for `col_date`.[39m
-# [34mNOTE: Using column `[1mpatient_id[22m` as input for `col_patient_id`.[39m
-# [34mNOTE: Using column `[1mkeyab[22m` as input for `col_keyantibiotics`. Use [1mcol_keyantibiotics = FALSE[22m to prevent this.[39m
+# NOTE: Using column `bacteria` as input for `col_mo`. +# NOTE: Using column `bacteria` as input for `col_mo`. +# NOTE: Using column `date` as input for `col_date`. +# NOTE: Using column `patient_id` as input for `col_patient_id`. +# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
@@ -647,44 +643,44 @@ Longest: 1

- - + + - - - + + + - - + + + + - - - - + + - + - + - - + + @@ -695,34 +691,34 @@ Longest: 1

- - + + - - - + + + - + - - + + - + - - + + - + @@ -731,32 +727,32 @@ Longest: 1

- - + + - - + + - - + + - - + + - - + + @@ -767,11 +763,11 @@ Longest: 1

isolate
12010-02-10S12010-01-01K4 B_ESCHR_COLISSS RRSS TRUE TRUE
22010-02-27S12010-02-09K4 B_ESCHR_COLISI R SSS FALSE TRUE
32010-03-05S12010-03-03K4 B_ESCHR_COLISI S R S FALSETRUEFALSE
42010-04-03S12010-04-25K4 B_ESCHR_COLI S S
52010-05-22S12010-07-04K4 B_ESCHR_COLIRRRSSS S FALSETRUEFALSE
62010-07-19S12010-09-04K4 B_ESCHR_COLI S I S S FALSETRUEFALSE
72010-07-19S12010-10-01K4 B_ESCHR_COLISI S R S
82010-08-28S12011-03-20K4 B_ESCHR_COLII S S SFALSESTRUE TRUE
92010-09-09S12011-06-26K4 B_ESCHR_COLIRR SRR S FALSE TRUE
102010-09-20S12011-10-22K4 B_ESCHR_COLI S S
-

Instead of 1, now 10 isolates are flagged. In total, 78.4% of all isolates are marked ‘first weighted’ - 49.9% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

+

Instead of 2, now 7 isolates are flagged. In total, 78.4% of all isolates are marked ‘first weighted’ - 50.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

As with filter_first_isolate(), there’s a shortcut for this new algorithm too:

data_1st <- data %>%
   filter_first_weighted_isolate()
-

So we end up with 15,684 isolates for analysis.

+

So we end up with 15,673 isolates for analysis.

We can remove unneeded columns:

data_1st <- data_1st %>%
   select(-c(first, keyab))
@@ -797,14 +793,46 @@ Longest: 1

1 -2013-03-27 -L8 +2015-03-17 +U1 +Hospital D +B_ESCHR_COLI +S +S +S +S +F +Gram-negative +Escherichia +coli +TRUE + + +2 +2017-08-02 +P6 Hospital B B_STRPT_PNMN R R S R +F +Gram-positive +Streptococcus +pneumoniae +TRUE + + +4 +2011-02-12 +I10 +Hospital D +B_STRPT_PNMN +R +R +S +R M Gram-positive Streptococcus @@ -812,41 +840,9 @@ Longest: 1

TRUE -2 -2015-12-30 -K1 -Hospital B -B_STPHY_AURS -S -S -R -S -M -Gram-positive -Staphylococcus -aureus -TRUE - - -3 -2016-06-06 -D3 -Hospital B -B_STPHY_AURS -S -S -R -S -M -Gram-positive -Staphylococcus -aureus -TRUE - - -4 -2011-07-04 -H10 +6 +2010-08-19 +A7 Hospital D B_ESCHR_COLI S @@ -860,35 +856,35 @@ Longest: 1

TRUE -6 -2017-03-06 -S4 -Hospital C -B_ESCHR_COLI +7 +2013-04-06 +H5 +Hospital A +B_STPHY_AURS +R S S S -S -F -Gram-negative -Escherichia -coli +M +Gram-positive +Staphylococcus +aureus TRUE -7 -2014-08-08 -C5 +8 +2013-12-11 +J8 Hospital C -B_ESCHR_COLI +B_KLBSL_PNMN R +I S -R S M Gram-negative -Escherichia -coli +Klebsiella +pneumoniae TRUE @@ -910,8 +906,8 @@ Longest: 1

data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 15,684
-Available: 15,684 (100%, NA: 0 = 0%)
+Length: 15,673
+Available: 15,673 (100%, NA: 0 = 0%)
Unique: 4

Shortest: 16
Longest: 24

@@ -928,33 +924,33 @@ Longest: 24

1 Escherichia coli -7,819 -49.85% -7,819 -49.85% +7,843 +50.04% +7,843 +50.04% 2 Staphylococcus aureus -3,992 -25.45% -11,811 -75.31% +3,949 +25.20% +11,792 +75.24% 3 Streptococcus pneumoniae -2,332 -14.87% -14,143 -90.17% +2,320 +14.80% +14,112 +90.04% 4 Klebsiella pneumoniae -1,541 -9.83% -15,684 +1,561 +9.96% +15,673 100.00% @@ -966,7 +962,7 @@ Longest: 24

The functions resistance() and susceptibility() can be used to calculate antimicrobial resistance or susceptibility. For more specific analyses, the functions proportion_S(), proportion_SI(), proportion_I(), proportion_IR() and proportion_R() can be used to determine the proportion of a specific antimicrobial outcome.

As per the EUCAST guideline of 2019, we calculate resistance as the proportion of R (proportion_R(), equal to resistance()) and susceptibility as the proportion of S and I (proportion_SI(), equal to susceptibility()). These functions can be used on their own:

data_1st %>% resistance(AMX)
-# [1] 0.4410227
+# [1] 0.441396

Or can be used in conjuction with group_by() and summarise(), both from the dplyr package:

data_1st %>%
   group_by(hospital) %>%
@@ -979,19 +975,19 @@ Longest: 24

Hospital A -0.4448217 +0.4339461 Hospital B -0.4476345 +0.4463033 Hospital C -0.4299828 +0.4511013 Hospital D -0.4317450 +0.4368288 @@ -1009,23 +1005,23 @@ Longest: 24

Hospital A -0.4448217 -4712 +0.4339461 +4678 Hospital B -0.4476345 -5538 +0.4463033 +5559 Hospital C -0.4299828 -2328 +0.4511013 +2270 Hospital D -0.4317450 -3106 +0.4368288 +3166 @@ -1045,27 +1041,27 @@ Longest: 24

Escherichia -0.8199258 -0.8988362 -0.9842691 +0.8236644 +0.8999107 +0.9832972 Klebsiella -0.8189487 -0.8916288 -0.9857236 +0.8315183 +0.8923767 +0.9820628 Staphylococcus -0.8166333 -0.9170842 -0.9857214 +0.8219802 +0.9161813 +0.9853127 Streptococcus -0.6170669 +0.6224138 0.0000000 -0.6170669 +0.6224138 @@ -1141,8 +1137,7 @@ Longest: 24

Independence test

The next example uses the example_isolates data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and 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:

-
# use package 'tidyr' to pivot data; 
-# it gets installed with this 'AMR' package
+
# use package 'tidyr' to pivot data:
 library(tidyr)
 
 check_FOS <- example_isolates %>%
@@ -1173,7 +1168,7 @@ Longest: 24

# sample estimates: # odds ratio # 0.4488318
-

As can be seen, the p value is 0.031, which means that the fosfomycin resistance found in hospital A and D are really different.

+

As can be seen, the p value is 0.031, which means that the fosfomycin resistance found in isolates from patients in hospital A and D are really different.

diff --git a/docs/articles/AMR_files/figure-html/plot 1-1.png b/docs/articles/AMR_files/figure-html/plot 1-1.png index 19550a37..c99032eb 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 1-1.png and b/docs/articles/AMR_files/figure-html/plot 1-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 3-1.png b/docs/articles/AMR_files/figure-html/plot 3-1.png index 1d621764..f0a36370 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 3-1.png and b/docs/articles/AMR_files/figure-html/plot 3-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 4-1.png b/docs/articles/AMR_files/figure-html/plot 4-1.png index ac2e0534..bc55a496 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 4-1.png and b/docs/articles/AMR_files/figure-html/plot 4-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 5-1.png b/docs/articles/AMR_files/figure-html/plot 5-1.png index 9d2bb5cb..50ac57dd 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ diff --git a/docs/articles/MDR.html b/docs/articles/MDR.html index b596ed6a..b0e346dc 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.1.0.9015 + 1.1.0.9019 @@ -186,7 +186,7 @@

How to determine multi-drug resistance (MDR)

Matthijs S. Berends

-

20 May 2020

+

25 May 2020

Source: vignettes/MDR.Rmd @@ -235,9 +235,9 @@ The German national guideline - Mueller et al. (2015) Antimicrobial Resistance a
example_isolates %>%
   mdro() %>%
   freq() # show frequency table of the result
-# [34mNOTE: Using column `[1mmo[22m` as input for `col_mo`.[39m
-# [34mNOTE: Auto-guessing columns suitable for analysis...[39m[34mOK.[39m
-# [34mNOTE: Reliability would be improved if these antimicrobial results would be available too: ceftaroline ([1mCPT[22m), fusidic acid ([1mFUS[22m), telavancin ([1mTLV[22m), daptomycin ([1mDAP[22m), quinupristin/dalfopristin ([1mQDA[22m), minocycline ([1mMNO[22m), gentamicin-high ([1mGEH[22m), streptomycin-high ([1mSTH[22m), doripenem ([1mDOR[22m), levofloxacin ([1mLVX[22m), netilmicin ([1mNET[22m), ticarcillin/clavulanic acid ([1mTCC[22m), ertapenem ([1mETP[22m), cefotetan ([1mCTT[22m), aztreonam ([1mATM[22m), ampicillin/sulbactam ([1mSAM[22m), polymyxin B ([1mPLB[22m)[39m
+# NOTE: Using column `mo` as input for `col_mo`.
+# NOTE: Auto-guessing columns suitable for analysis...OK.
+# NOTE: Reliability would be improved if these antimicrobial results would be available too: ceftaroline (CPT), fusidic acid (FUS), telavancin (TLV), daptomycin (DAP), quinupristin/dalfopristin (QDA), minocycline (MNO), gentamicin-high (GEH), streptomycin-high (STH), doripenem (DOR), levofloxacin (LVX), netilmicin (NET), ticarcillin/clavulanic acid (TCC), ertapenem (ETP), cefotetan (CTT), aztreonam (ATM), ampicillin/sulbactam (SAM), polymyxin B (PLB)
 # Warning in mdro(.): NA introduced for isolates where the available percentage of
 # antimicrobial classes was below 50% (set with `pct_required_classes`)

Frequency table

@@ -302,26 +302,26 @@ Unique: 2

The data set now looks like this:

head(my_TB_data)
 #   rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
-# 1          R         R            R          R            S            S
-# 2          S         S            S          I            R            S
-# 3          S         R            S          I            S            I
-# 4          S         R            S          S            S            R
-# 5          R         S            R          S            S            R
-# 6          I         S            R          R            R            R
+# 1          S         S            R          R            S            S
+# 2          R         R            S          R            S            R
+# 3          R         S            S          R            S            S
+# 4          R         S            S          S            S            R
+# 5          S         R            R          S            R            R
+# 6          R         R            R          R            R            R
 #   kanamycin
-# 1         I
+# 1         R
 # 2         S
-# 3         R
-# 4         I
-# 5         I
-# 6         S
+# 3 S +# 4 S +# 5 R +# 6 R

We can now add the interpretation of MDR-TB to our data set. You can use:

mdro(my_TB_data, guideline = "TB")

or its shortcut mdr_tb():

my_TB_data$mdr <- mdr_tb(my_TB_data)
-# [34mNOTE: No column found as input for `col_mo`, [1massuming all records contain [3mMycobacterium tuberculosis.[23m[22m[39m
-# [34mNOTE: Auto-guessing columns suitable for analysis...[39m[34mOK.[39m
-# [34mNOTE: Reliability would be improved if these antimicrobial results would be available too: capreomycin ([1mCAP[22m), rifabutin ([1mRIB[22m), rifapentine ([1mRFP[22m)[39m
+# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis. +# NOTE: Auto-guessing columns suitable for analysis...OK. +# NOTE: Reliability would be improved if these antimicrobial results would be available too: capreomycin (CAP), rifabutin (RIB), rifapentine (RFP)

Create a frequency table of the results:

freq(my_TB_data$mdr)

Frequency table

@@ -343,40 +343,40 @@ Unique: 5

1 Mono-resistant -3288 -65.76% -3288 -65.76% +3239 +64.78% +3239 +64.78% 2 Negative -631 -12.62% -3919 -78.38% +655 +13.10% +3894 +77.88% 3 Multi-drug-resistant -582 -11.64% -4501 -90.02% +593 +11.86% +4487 +89.74% 4 Poly-resistant -298 -5.96% -4799 -95.98% +304 +6.08% +4791 +95.82% 5 Extensively drug-resistant -201 -4.02% +209 +4.18% 5000 100.00% diff --git a/docs/articles/PCA.html b/docs/articles/PCA.html index 86d60ae8..0eb49c22 100644 --- a/docs/articles/PCA.html +++ b/docs/articles/PCA.html @@ -39,7 +39,7 @@ AMR (for R) - 1.1.0 + 1.1.0.9019 @@ -186,7 +186,7 @@

How to conduct principal component analysis (PCA) for AMR

Matthijs S. Berends

-

15 April 2020

+

25 May 2020

Source: vignettes/PCA.Rmd @@ -217,47 +217,47 @@ # $ age <dbl> 65, 65, 45, 45, 45, 45, 78, 78, 45, 79, 67, 67, 71, 7… # $ gender <chr> "F", "F", "F", "F", "F", "F", "M", "M", "F", "F", "M"… # $ patient_id <chr> "A77334", "A77334", "067927", "067927", "067927", "06… -# $ mo <mo> B_ESCHR_COLI, B_ESCHR_COLI, B_STPHY_EPDR, B_STPHY_EPDR… -# $ PEN <rsi> R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R,… -# $ OXA <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ FLC <rsi> NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA,… -# $ AMX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ AMC <rsi> I, I, NA, NA, NA, NA, S, S, NA, NA, S, S, I, I, R, I,… -# $ AMP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ TZP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ CZO <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ FEP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ CXM <rsi> I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R… -# $ FOX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ CTX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,… -# $ CAZ <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, … -# $ CRO <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,… -# $ GEN <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ TOB <rsi> NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, N… -# $ AMK <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ KAN <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ TMP <rsi> R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, … -# $ SXT <rsi> R, R, S, S, NA, NA, NA, NA, S, S, NA, NA, S, S, S, S,… -# $ NIT <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ FOS <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ LNZ <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R… -# $ CIP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA,… -# $ MFX <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ VAN <rsi> R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, … -# $ TEC <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R… -# $ TCY <rsi> R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, … -# $ TGC <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ DOX <rsi> NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R,… -# $ ERY <rsi> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,… -# $ CLI <rsi> NA, NA, NA, NA, NA, R, NA, NA, NA, NA, NA, NA, NA, NA… -# $ AZM <rsi> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,… -# $ IPM <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,… -# $ MEM <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ MTR <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ CHL <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ COL <rsi> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, … -# $ MUP <rsi> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… -# $ RIF <rsi> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R… +# $ mo <mo> "B_ESCHR_COLI", "B_ESCHR_COLI", "B_STPHY_EPDR", "B_STP… +# $ PEN <ord> R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R, R,… +# $ OXA <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ FLC <ord> NA, NA, R, R, R, R, S, S, R, S, S, S, NA, NA, NA, NA,… +# $ AMX <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ AMC <ord> I, I, NA, NA, NA, NA, S, S, NA, NA, S, S, I, I, R, I,… +# $ AMP <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ TZP <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ CZO <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ FEP <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ CXM <ord> I, I, R, R, R, R, S, S, R, S, S, S, S, S, NA, S, S, R… +# $ FOX <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ CTX <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,… +# $ CAZ <ord> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, S, … +# $ CRO <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,… +# $ GEN <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ TOB <ord> NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA, S, S, N… +# $ AMK <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ KAN <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ TMP <ord> R, R, S, S, R, R, R, R, S, S, NA, NA, S, S, S, S, S, … +# $ SXT <ord> R, R, S, S, NA, NA, NA, NA, S, S, NA, NA, S, S, S, S,… +# $ NIT <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ FOS <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ LNZ <ord> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R… +# $ CIP <ord> NA, NA, NA, NA, NA, NA, NA, NA, S, S, NA, NA, NA, NA,… +# $ MFX <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ VAN <ord> R, R, S, S, S, S, S, S, S, S, NA, NA, R, R, R, R, R, … +# $ TEC <ord> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R… +# $ TCY <ord> R, R, S, S, S, S, S, S, S, I, S, S, NA, NA, I, R, R, … +# $ TGC <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ DOX <ord> NA, NA, S, S, S, S, S, S, S, NA, S, S, NA, NA, NA, R,… +# $ ERY <ord> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,… +# $ CLI <ord> NA, NA, NA, NA, NA, R, NA, NA, NA, NA, NA, NA, NA, NA… +# $ AZM <ord> R, R, R, R, R, R, S, S, R, S, S, S, R, R, R, R, R, R,… +# $ IPM <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, S, S,… +# $ MEM <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ MTR <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ CHL <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ COL <ord> NA, NA, R, R, R, R, R, R, R, R, R, R, NA, NA, NA, R, … +# $ MUP <ord> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N… +# $ RIF <ord> R, R, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, R, R, R…

Now to transform this to a data set with only resistance percentages per taxonomic order and genus:

resistance_data <- example_isolates %>%
   group_by(order = mo_order(mo),       # group on anything, like order
@@ -283,7 +283,7 @@
 Perform principal component analysis
 

The new pca() function will automatically filter on rows that contain numeric values in all selected variables, so we now only need to do:

pca_result <- pca(resistance_data)
-# NOTE: Columns selected for PCA: AMC/CXM/CTX/CAZ/GEN/TOB/TMP/SXT.
+# NOTE: Columns selected for PCA: AMC CXM CTX CAZ GEN TOB TMP SXT.
 #       Total observations available: 7.

The result can be reviewed with the good old summary() function:

summary(pca_result)
@@ -303,8 +303,7 @@
 
ggplot_pca(pca_result)

You can also print an ellipse per group, and edit the appearance:

-
-ggplot_pca(pca_result, ellipse = TRUE) +
+
ggplot_pca(pca_result, ellipse = TRUE) +
   ggplot2::labs(title = "An AMR/PCA biplot!")

@@ -325,7 +324,7 @@
-

Site built with pkgdown 1.5.0.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/articles/PCA_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/PCA_files/figure-html/unnamed-chunk-5-1.png index 760b3b65..eaaafe4d 100644 Binary files a/docs/articles/PCA_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/PCA_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 054cf9b4..7cf15ca7 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -39,7 +39,7 @@ AMR (for R) - 1.1.0.9015 + 1.1.0.9019
@@ -186,7 +186,7 @@

Benchmarks

Matthijs S. Berends

-

20 May 2020

+

25 May 2020

Source: vignettes/benchmarks.Rmd @@ -221,21 +221,21 @@ times = 10) print(S.aureus, unit = "ms", signif = 2) # Unit: milliseconds -# expr min lq mean median uq max neval -# as.mo("sau") 8.7 9.4 13.0 9.5 11 39.0 10 -# as.mo("stau") 140.0 150.0 160.0 170.0 180 180.0 10 -# as.mo("STAU") 140.0 140.0 160.0 150.0 170 180.0 10 -# as.mo("staaur") 8.7 9.6 16.0 11.0 11 41.0 10 -# as.mo("STAAUR") 8.7 9.2 13.0 10.0 11 37.0 10 -# as.mo("S. aureus") 10.0 12.0 23.0 13.0 39 41.0 10 -# as.mo("S aureus") 9.4 10.0 11.0 11.0 12 12.0 10 -# as.mo("Staphylococcus aureus") 7.5 7.5 8.3 8.4 9 9.3 10 -# as.mo("Staphylococcus aureus (MRSA)") 890.0 930.0 940.0 940.0 950 980.0 10 -# as.mo("Sthafilokkockus aaureuz") 370.0 390.0 420.0 400.0 440 510.0 10 -# as.mo("MRSA") 8.0 8.9 15.0 10.0 11 39.0 10 -# as.mo("VISA") 20.0 21.0 36.0 25.0 53 60.0 10 -# as.mo("VRSA") 19.0 22.0 29.0 24.0 26 53.0 10 -# as.mo(22242419) 150.0 150.0 170.0 150.0 160 290.0 10 +# expr min lq mean median uq max neval +# as.mo("sau") 9.7 11.0 15 11.0 12.0 49 10 +# as.mo("stau") 130.0 150.0 180 170.0 190.0 270 10 +# as.mo("STAU") 130.0 130.0 140 140.0 150.0 170 10 +# as.mo("staaur") 7.9 9.6 15 11.0 12.0 40 10 +# as.mo("STAAUR") 9.1 9.4 16 11.0 12.0 41 10 +# as.mo("S. aureus") 8.5 11.0 12 12.0 13.0 16 10 +# as.mo("S aureus") 8.4 11.0 17 12.0 14.0 47 10 +# as.mo("Staphylococcus aureus") 6.4 8.6 12 8.8 9.8 40 10 +# as.mo("Staphylococcus aureus (MRSA)") 830.0 860.0 910 900.0 930.0 1100 10 +# as.mo("Sthafilokkockus aaureuz") 370.0 390.0 410 400.0 430.0 440 10 +# as.mo("MRSA") 9.2 9.5 16 11.0 11.0 63 10 +# as.mo("VISA") 22.0 22.0 36 26.0 54.0 59 10 +# as.mo("VRSA") 21.0 23.0 48 27.0 55.0 180 10 +# as.mo(22242419) 150.0 160.0 160 160.0 170.0 190 10

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.

To achieve this speed, the as.mo function also takes into account the prevalence of human pathogenic microorganisms. The downside of this is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of Methanosarcina semesiae (B_MTHNSR_SEMS), a bug probably never found before in humans:

@@ -247,18 +247,18 @@ times = 10) print(M.semesiae, unit = "ms", signif = 4) # Unit: milliseconds -# expr min lq mean median uq -# as.mo("metsem") 163.900 165.300 180.600 176.600 192.600 -# as.mo("METSEM") 153.500 156.100 177.300 176.000 200.400 -# as.mo("M. semesiae") 9.155 10.250 15.980 10.800 12.790 -# as.mo("M. semesiae") 9.498 10.160 16.700 10.560 11.050 -# as.mo("Methanosarcina semesiae") 7.006 7.345 7.993 7.814 8.413 -# max neval -# 206.600 10 -# 206.800 10 -# 38.630 10 -# 46.810 10 -# 9.659 10 +# expr min lq mean median uq max +# as.mo("metsem") 152.700 163.100 172.10 171.40 176.20 213.80 +# as.mo("METSEM") 148.300 167.900 181.50 185.30 196.70 204.60 +# as.mo("M. semesiae") 8.610 9.468 13.88 10.05 15.28 35.20 +# as.mo("M. semesiae") 9.164 9.530 21.29 11.58 42.98 50.57 +# as.mo("Methanosarcina semesiae") 6.625 7.229 14.25 7.98 11.32 42.18 +# neval +# 10 +# 10 +# 10 +# 10 +# 10

Looking up arbitrary codes of less prevalent microorganisms costs the most time. Full names (like Methanosarcina semesiae) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.

In the figure below, we compare Escherichia coli (which is very common) with Prevotella brevis (which is moderately common) and with Methanosarcina semesiae (which is uncommon):

@@ -267,8 +267,7 @@

Repetitive results

Repetitive results are unique values that are present more than once. Unique values will only be calculated once by as.mo(). We will use mo_name() for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses as.mo() internally.

-
library(dplyr)
-
# take all MO codes from the example_isolates data set
+
# take all MO codes from the example_isolates data set
 x <- example_isolates$mo %>%
   # keep only the unique ones
   unique() %>%
@@ -293,25 +292,25 @@
 print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
 #        expr  min   lq mean median   uq  max neval
-#  mo_name(x) 1690 1710 1770   1760 1810 1870    10
-

So transforming 500,000 values (!!) of 50 unique values only takes 1.76 seconds. You only lose time on your unique input values.

+# mo_name(x) 1700 1760 1780 1770 1800 1880 10
+

So transforming 500,000 values (!!) of 50 unique values only takes 1.77 seconds. You only lose time on your unique input values.

Precalculated results

What about precalculated results? If the input is an already precalculated result of a helper function like mo_name(), it almost doesn’t take any time at all (see ‘C’ below):

-
run_it <- microbenchmark(A = mo_name("B_STPHY_AURS"),
+
run_it <- microbenchmark(A = mo_name("B_STPHY_AURS"),
                          B = mo_name("S. aureus"),
                          C = mo_name("Staphylococcus aureus"),
                          times = 10)
 print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
-#  expr    min     lq   mean median    uq    max neval
-#     A  6.240  6.490  6.860  6.910  7.15  7.510    10
-#     B 10.500 10.600 15.300 12.000 12.10 49.300    10
-#     C  0.198  0.243  0.266  0.278  0.29  0.322    10
+# expr min lq mean median uq max neval +# A 5.640 5.890 10.300 6.580 6.850 44.400 10 +# B 11.000 11.300 11.500 11.400 11.500 12.400 10 +# C 0.217 0.238 0.271 0.267 0.298 0.383 10

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0003 seconds - it doesn’t even start calculating if the result would be the same as the expected resulting value. That goes for all helper functions:

-
run_it <- microbenchmark(A = mo_species("aureus"),
+
run_it <- microbenchmark(A = mo_species("aureus"),
                          B = mo_genus("Staphylococcus"),
                          C = mo_name("Staphylococcus aureus"),
                          D = mo_family("Staphylococcaceae"),
@@ -323,21 +322,21 @@
 print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
 #  expr   min    lq  mean median    uq   max neval
-#     A 0.248 0.253 0.266  0.256 0.271 0.323    10
-#     B 0.248 0.254 0.272  0.255 0.257 0.420    10
-#     C 0.245 0.259 0.265  0.268 0.271 0.286    10
-#     D 0.248 0.252 0.268  0.261 0.278 0.323    10
-#     E 0.250 0.256 0.265  0.261 0.268 0.312    10
-#     F 0.237 0.238 0.249  0.243 0.246 0.317    10
-#     G 0.239 0.242 0.252  0.245 0.245 0.319    10
-#     H 0.233 0.241 0.262  0.256 0.272 0.347    10
+# A 0.205 0.208 0.230 0.219 0.240 0.307 10 +# B 0.201 0.216 0.227 0.223 0.229 0.293 10 +# C 0.209 0.210 0.224 0.218 0.241 0.255 10 +# D 0.200 0.211 0.222 0.217 0.224 0.279 10 +# E 0.199 0.209 0.220 0.211 0.219 0.280 10 +# F 0.201 0.205 0.228 0.212 0.217 0.346 10 +# G 0.193 0.208 0.218 0.217 0.220 0.272 10 +# H 0.190 0.195 0.206 0.200 0.203 0.263 10

Of course, when running mo_phylum("Firmicutes") the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes" anyway, 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.

Results in other languages

When the system language is non-English and supported by this AMR package, some functions will have a translated result. This almost does’t take extra time:

-
mo_name("CoNS", language = "en") # or just mo_name("CoNS") on an English system
+
mo_name("CoNS", language = "en") # or just mo_name("CoNS") on an English system
 # [1] "Coagulase-negative Staphylococcus (CoNS)"
 
 mo_name("CoNS", language = "es") # or just mo_name("CoNS") on a Spanish system
@@ -357,13 +356,13 @@
 print(run_it, unit = "ms", signif = 4)
 # Unit: milliseconds
 #  expr   min    lq  mean median    uq    max neval
-#    en 20.99 21.59 26.64  22.35 22.94  69.49   100
-#    de 22.02 22.54 26.83  22.98 23.87  63.13   100
-#    nl 25.78 26.55 34.69  27.25 28.22 182.90   100
-#    es 21.92 22.67 26.97  23.26 24.01  62.68   100
-#    it 21.96 22.58 25.11  22.90 23.50  66.81   100
-#    fr 21.82 22.76 27.53  23.26 23.84  66.75   100
-#    pt 21.76 22.56 25.84  23.13 23.90  63.63   100
+# en 20.45 21.03 25.78 21.63 27.29 71.19 100 +# de 21.48 22.06 28.50 22.81 28.56 73.54 100 +# nl 25.11 26.21 33.48 27.31 35.01 81.28 100 +# es 21.59 22.20 29.02 23.05 30.33 73.83 100 +# it 21.46 22.05 28.45 22.79 29.45 64.36 100 +# fr 21.47 22.12 31.87 22.83 31.24 174.10 100 +# pt 21.53 22.22 27.19 22.91 25.67 71.87 100

Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.

diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png index 156b91b3..3548c4a0 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png index 3448c009..3bb56f1d 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index d63f798f..0db68063 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019 diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index d6c981a7..35e84e5d 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -39,7 +39,7 @@ AMR (for R) - 1.1.0 + 1.1.0.9019 @@ -186,7 +186,7 @@

How to predict antimicrobial resistance

Matthijs S. Berends

-

15 April 2020

+

25 May 2020

Source: vignettes/resistance_predict.Rmd @@ -221,7 +221,7 @@ example_isolates %>% model "binomial") # to bind it to object 'predict_TZP' for example: -predict_TZP % +predict_TZP <- example_isolates %>% resistance_predict(col_ab = "TZP", model = "binomial")

The function will look for a date column itself if col_date is not set.

@@ -230,36 +230,37 @@ predict_TZP %

This text is only a printed summary - the actual result (output) of the function is a data.frame containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation:

predict_TZP
 #    year      value    se_min    se_max observations   observed  estimated
-# 1  2003 0.06250000        NA        NA           32 0.06250000 0.05486389
-# 2  2004 0.08536585        NA        NA           82 0.08536585 0.06089002
-# 3  2005 0.05000000        NA        NA           60 0.05000000 0.06753075
-# 4  2006 0.05084746        NA        NA           59 0.05084746 0.07483801
-# 5  2007 0.12121212        NA        NA           66 0.12121212 0.08286570
-# 6  2008 0.04166667        NA        NA           72 0.04166667 0.09166918
-# 7  2009 0.01639344        NA        NA           61 0.01639344 0.10130461
-# 8  2010 0.05660377        NA        NA           53 0.05660377 0.11182814
-# 9  2011 0.18279570        NA        NA           93 0.18279570 0.12329488
-# 10 2012 0.30769231        NA        NA           65 0.30769231 0.13575768
-# 11 2013 0.06896552        NA        NA           58 0.06896552 0.14926576
-# 12 2014 0.10000000        NA        NA           60 0.10000000 0.16386307
-# 13 2015 0.23636364        NA        NA           55 0.23636364 0.17958657
-# 14 2016 0.22619048        NA        NA           84 0.22619048 0.19646431
-# 15 2017 0.16279070        NA        NA           86 0.16279070 0.21451350
-# 16 2018 0.23373852 0.2021578 0.2653193           NA         NA 0.23373852
-# 17 2019 0.25412909 0.2168525 0.2914057           NA         NA 0.25412909
-# 18 2020 0.27565854 0.2321869 0.3191302           NA         NA 0.27565854
-# 19 2021 0.29828252 0.2481942 0.3483709           NA         NA 0.29828252
-# 20 2022 0.32193804 0.2649008 0.3789753           NA         NA 0.32193804
-# 21 2023 0.34654311 0.2823269 0.4107593           NA         NA 0.34654311
-# 22 2024 0.37199700 0.3004860 0.4435080           NA         NA 0.37199700
-# 23 2025 0.39818127 0.3193839 0.4769787           NA         NA 0.39818127
-# 24 2026 0.42496142 0.3390173 0.5109056           NA         NA 0.42496142
-# 25 2027 0.45218939 0.3593720 0.5450068           NA         NA 0.45218939
-# 26 2028 0.47970658 0.3804212 0.5789920           NA         NA 0.47970658
-# 27 2029 0.50734745 0.4021241 0.6125708           NA         NA 0.50734745
-# 28 2030 0.53494347 0.4244247 0.6454622           NA         NA 0.53494347
+# 1 2002 0.20000000 NA NA 15 0.20000000 0.05616378 +# 2 2003 0.06250000 NA NA 32 0.06250000 0.06163839 +# 3 2004 0.08536585 NA NA 82 0.08536585 0.06760841 +# 4 2005 0.05000000 NA NA 60 0.05000000 0.07411100 +# 5 2006 0.05084746 NA NA 59 0.05084746 0.08118454 +# 6 2007 0.12121212 NA NA 66 0.12121212 0.08886843 +# 7 2008 0.04166667 NA NA 72 0.04166667 0.09720264 +# 8 2009 0.01639344 NA NA 61 0.01639344 0.10622731 +# 9 2010 0.05660377 NA NA 53 0.05660377 0.11598223 +# 10 2011 0.18279570 NA NA 93 0.18279570 0.12650615 +# 11 2012 0.30769231 NA NA 65 0.30769231 0.13783610 +# 12 2013 0.06896552 NA NA 58 0.06896552 0.15000651 +# 13 2014 0.10000000 NA NA 60 0.10000000 0.16304829 +# 14 2015 0.23636364 NA NA 55 0.23636364 0.17698785 +# 15 2016 0.22619048 NA NA 84 0.22619048 0.19184597 +# 16 2017 0.16279070 NA NA 86 0.16279070 0.20763675 +# 17 2018 0.22436641 0.1938710 0.2548618 NA NA 0.22436641 +# 18 2019 0.24203228 0.2062911 0.2777735 NA NA 0.24203228 +# 19 2020 0.26062172 0.2191758 0.3020676 NA NA 0.26062172 +# 20 2021 0.28011130 0.2325557 0.3276669 NA NA 0.28011130 +# 21 2022 0.30046606 0.2464567 0.3544755 NA NA 0.30046606 +# 22 2023 0.32163907 0.2609011 0.3823771 NA NA 0.32163907 +# 23 2024 0.34357130 0.2759081 0.4112345 NA NA 0.34357130 +# 24 2025 0.36619175 0.2914934 0.4408901 NA NA 0.36619175 +# 25 2026 0.38941799 0.3076686 0.4711674 NA NA 0.38941799 +# 26 2027 0.41315710 0.3244399 0.5018743 NA NA 0.41315710 +# 27 2028 0.43730688 0.3418075 0.5328063 NA NA 0.43730688 +# 28 2029 0.46175755 0.3597639 0.5637512 NA NA 0.46175755 +# 29 2030 0.48639359 0.3782932 0.5944939 NA NA 0.48639359

The function plot is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:

-
plot(predict_TZP)
+
plot(predict_TZP)

This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model.

We also support the ggplot2 package with our custom function ggplot_rsi_predict() to create more appealing plots:

@@ -272,7 +273,7 @@ predict_TZP %

Choosing the right model

-

Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:

+

Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous:

example_isolates %>%
   filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
   resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>%
@@ -317,7 +318,7 @@ predict_TZP %
 
 
 
-

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:

+

For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years:

example_isolates %>%
   filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
   resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "linear") %>%
@@ -334,9 +335,9 @@ predict_TZP %
 # Link function: logit
 
 summary(model)$coefficients
-#                 Estimate Std. Error   z value     Pr(>|z|)
-# (Intercept) -224.3987194 48.0335384 -4.671709 2.987038e-06
-# year           0.1106102  0.0238753  4.632831 3.606990e-06
+# Estimate Std. Error z value Pr(>|z|) +# (Intercept) -200.67944891 46.17315349 -4.346237 1.384932e-05 +# year 0.09883005 0.02295317 4.305725 1.664395e-05
@@ -356,7 +357,7 @@ predict_TZP %
-

Site built with pkgdown 1.5.0.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-4-1.png index 0f81459b..13ac2399 100644 Binary files a/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-1.png index 22cbccfb..270ddba5 100644 Binary files a/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-2.png b/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-2.png index 4a86a8ae..b0bad4ed 100644 Binary files a/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-2.png and b/docs/articles/resistance_predict_files/figure-html/unnamed-chunk-5-2.png differ diff --git a/docs/authors.html b/docs/authors.html index 2d23c15d..c99bf627 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019 diff --git a/docs/extra.css b/docs/extra.css index a141e993..4d4be351 100644 --- a/docs/extra.css +++ b/docs/extra.css @@ -215,6 +215,11 @@ table a:not(.btn):hover, .table a:not(.btn):hover { font-size: 15px; } +.template-home h4 { + padding-top: 40px !important; + font-weight: bold !important; +} + /* logos on index page */ .logo_img { display: inline-block; diff --git a/docs/index.html b/docs/index.html index 1ad28cc4..a1758b2b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019 @@ -197,10 +197,10 @@ A methods paper about this package has been preprinted at bioRxiv (DOI: 10.1101/

What is AMR (for R)?

-

(To find out how to conduct AMR analysis, please continue reading here to get started.

+

(To find out how to conduct AMR analysis, please continue reading here to get started.)

AMR is a free, open-source and independent R package to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. Our aim is to provide a standard for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting.

After installing this package, R knows ~70,000 distinct microbial species and all ~550 antibiotic, antimycotic and antiviral drugs by name and code (including ATC, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data.

-

This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is actively maintained and is free software (see Copyright). It is fully independent of any other R package and can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.

+

This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is actively maintained and is free software (see Copyright). It is fully independent of any other R package, can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.

Used in more than 100 countries
Since its first public release in early 2018, this package has been downloaded from more than 100 countries (source: CRAN logs). Click the map to enlarge, to see the names of the countries. diff --git a/docs/news/index.html b/docs/news/index.html index 32f206ef..e838eec3 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019

@@ -229,13 +229,13 @@ Source: NEWS.md
-
-

-AMR 1.1.0.9018 Unreleased +
+

+AMR 1.1.0.9019 Unreleased

-
+

-Last updated: 22-May-2020 +Last updated: 25-May-2020

@@ -269,7 +269,8 @@ Negative effects of this change are:
  • Improvements for algorithm in as.ab(), so that e.g. as.ab("ampi sul") and ab_name("ampi sul") work
  • Functions ab_atc() and ab_group() now return NA if no antimicrobial agent could be found
  • Small fix for some text input that could not be coerced as valid MIC values
  • -
  • Fixed interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
  • +
  • Fix for interpretation of generic CLSI interpretation rules (thanks to Anthony Underwood)
  • +
  • Fix for set_mo_source() to make sure that column mo will always be the second column
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 635cd45b..0023e3de 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: WHONET: WHONET.html benchmarks: benchmarks.html resistance_predict: resistance_predict.html -last_built: 2020-05-22T18:29Z +last_built: 2020-05-24T22:55Z urls: reference: https://msberends.gitlab.io/AMR/reference article: https://msberends.gitlab.io/AMR/articles diff --git a/docs/reference/AMR-deprecated.html b/docs/reference/AMR-deprecated.html index 26d0dba8..52cf1a2c 100644 --- a/docs/reference/AMR-deprecated.html +++ b/docs/reference/AMR-deprecated.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019
    diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html index 840b2a40..d2d79529 100644 --- a/docs/reference/ab_property.html +++ b/docs/reference/ab_property.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019
    @@ -311,13 +311,14 @@

    Details

    All output will be translated where possible.

    -

    The function ab_url() will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available.

    -

    Maturing lifecycle

    +

    The function ab_url() will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available.

    +

    Stable lifecycle

    -


    -The lifecycle of this function is maturing. The unlying code of a maturing function has been roughed out, but finer details might still change. This function needs wider usage and more extensive testing in order to optimise the unlying code.

    +


    +The lifecycle of this function is stable. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.

    +

    If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.

    Source

    diff --git a/docs/reference/age.html b/docs/reference/age.html index 9bf08767..77680ac6 100644 --- a/docs/reference/age.html +++ b/docs/reference/age.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019
    diff --git a/docs/reference/age_groups.html b/docs/reference/age_groups.html index d0bf90a8..9c7b920a 100644 --- a/docs/reference/age_groups.html +++ b/docs/reference/age_groups.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019
    diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index 393363e3..4f7f03c7 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019

    diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index fdcbe1aa..dbc10ee0 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index 9962855a..6f00064d 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 0e37c2c9..e0ec2b89 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index 575568fd..ecba2c83 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index b1399033..198a5f7b 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -83,7 +83,7 @@ This function requires an internet connection." /> AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/availability.html b/docs/reference/availability.html index 375a974e..ffbde8be 100644 --- a/docs/reference/availability.html +++ b/docs/reference/availability.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/bug_drug_combinations.html b/docs/reference/bug_drug_combinations.html index 54802d0d..d9f68518 100644 --- a/docs/reference/bug_drug_combinations.html +++ b/docs/reference/bug_drug_combinations.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/count.html b/docs/reference/count.html index 4d4353a6..c986cf79 100644 --- a/docs/reference/count.html +++ b/docs/reference/count.html @@ -83,7 +83,7 @@ count_resistant() should be used to count resistant isolates, count_susceptible( AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index b328576e..a4fe41a3 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/filter_ab_class.html b/docs/reference/filter_ab_class.html index 997aee93..f9437000 100644 --- a/docs/reference/filter_ab_class.html +++ b/docs/reference/filter_ab_class.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 443b91d4..5989e3c9 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/g.test.html b/docs/reference/g.test.html index d0e70a55..54a54887 100644 --- a/docs/reference/g.test.html +++ b/docs/reference/g.test.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/ggplot_pca.html b/docs/reference/ggplot_pca.html index 4439fb36..2dc3a8d2 100644 --- a/docs/reference/ggplot_pca.html +++ b/docs/reference/ggplot_pca.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index f97ff905..e90bc0ce 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index 2c6b0584..9ed3ecd5 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/index.html b/docs/reference/index.html index abcda4af..6d9245c5 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.1.0.9018 + 1.1.0.9019 @@ -295,7 +295,7 @@

    set_mo_source() get_mo_source()

    -

    Use predefined reference data set

    +

    User-defined reference data set for microorganisms

    diff --git a/docs/reference/join.html b/docs/reference/join.html index a33a04fa..fcc9912f 100644 --- a/docs/reference/join.html +++ b/docs/reference/join.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 0e16d6fe..f528d663 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/kurtosis.html b/docs/reference/kurtosis.html index b8354257..da3c30fd 100644 --- a/docs/reference/kurtosis.html +++ b/docs/reference/kurtosis.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/lifecycle.html b/docs/reference/lifecycle.html index bbc15045..170248bc 100644 --- a/docs/reference/lifecycle.html +++ b/docs/reference/lifecycle.html @@ -84,7 +84,7 @@ This page contains a section for every lifecycle (with text borrowed from the af AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/like.html b/docs/reference/like.html index d364b0bb..bd040406 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index c41bb82e..6f4a74d6 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 3aff8b4d..792af6e9 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9004 + 1.1.0.9019 @@ -329,6 +329,13 @@

    The Gram stain - mo_gramstain() - will be determined on the taxonomic kingdom and phylum. According to Cavalier-Smith (2002) who defined subkingdoms Negibacteria and Posibacteria, only these phyla are Posibacteria: Actinobacteria, Chloroflexi, Firmicutes and Tenericutes. These bacteria are considered Gram-positive - all other bacteria are considered Gram-negative. Species outside the kingdom of Bacteria will return a value NA.

    All output will be translated where possible.

    The function mo_url() will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species.

    +

    Stable lifecycle

    + + + +


    +The lifecycle of this function is stable. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided.

    +

    If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error.

    Catalogue of Life

    diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index 4f08deb1..075dfc5d 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -6,7 +6,7 @@ -Use predefined reference data set — mo_source • AMR (for R) +User-defined reference data set for microorganisms — mo_source • AMR (for R) @@ -48,7 +48,7 @@ - + @@ -83,7 +83,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p AMR (for R) - 1.1.0.9017 + 1.1.0.9019 @@ -227,7 +227,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
    @@ -246,7 +246,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p path -

    location of your reference file, see Details

    +

    location of your reference file, see Details. Can be "", NULL or FALSE to delete the reference file.

    @@ -255,10 +255,13 @@ This is the fastest way to have your organisation (or analysis) specific codes p

    The reference file can be a text file seperated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you need to have the readxl package installed.

    set_mo_source() will check the file for validity: it must be a data.frame, must have a column named "mo" which contains values from microorganisms$mo and must have a reference column with your own defined values. If all tests pass, set_mo_source() will read the file into R and export it to "~/.mo_source.rds". This compressed data file will then be used at default for MO determination (function as.mo() and consequently all mo_* functions like mo_genus() and mo_gramstain()). The location of the original file will be saved as option with options(mo_source = path). Its timestamp will be saved with options(mo_source_datetime = ...).

    get_mo_source() will return the data set by reading "~/.mo_source.rds" with readRDS(). If the original file has changed (the file defined with path), it will call set_mo_source() to update the data file automatically.

    -

    Reading an Excel file (.xlsx) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by get_mo_source() in only a couple of microseconds (a millionth of a second).

    How it works

    +

    Reading an Excel file (.xlsx) with only one row has a size of 8-9 kB. The compressed file created with set_mo_source() will then have a size of 0.1 kB and can be read by get_mo_source() in only a couple of microseconds (millionths of a second).

    +

    How to setup

    + + -

    Imagine this data on a sheet of an Excel file (mo codes were looked up in the microorganisms data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:

      |         A          |       B      |
    +

    Imagine this data on a sheet of an Excel file (mo codes were looked up in the microorganisms data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:

      |         A          |       B      |
     --|--------------------|--------------|
     1 | Organisation XYZ   | mo           |
     2 | lab_mo_ecoli       | B_ESCHR_COLI |
    @@ -267,21 +270,21 @@ This is the fastest way to have your organisation (or analysis) specific codes p
     

    We save it as "home/me/ourcodes.xlsx". Now we have to set it as a source:

    set_mo_source("home/me/ourcodes.xlsx")
    -# Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
    +#&gt; NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx' +#&gt; (columns "Organisation XYZ" and "mo")
    -

    It has now created a file "~/.mo_source.rds" with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.

    -

    And now we can use it in our functions:

    as.mo("lab_mo_ecoli")
    -[1] B_ESCHR_COLI
    +

    It has now created a file "~/.mo_source.rds" with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.

    +

    And now we can use it in our functions:

    as.mo("lab_mo_ecoli")
    +#&gt; [1] B_ESCHR_COLI
     
    -mo_genus("lab_mo_kpneumoniae")
    -[1] "Klebsiella"
    +mo_genus("lab_mo_kpneumoniae")
    +#&gt; [1] "Klebsiella"
     
    -# other input values still work too
    -as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
    -[1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
    -
    +# other input values still work too +as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli")) +#&gt; [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
    -

    If we edit the Excel file to, let's say, by adding row 4 like this:

      |         A          |       B      |
    +

    If we edit the Excel file by, let's say, adding row 4 like this:

      |         A          |       B      |
     --|--------------------|--------------|
     1 | Organisation XYZ   | mo           |
     2 | lab_mo_ecoli       | B_ESCHR_COLI |
    @@ -290,18 +293,18 @@ as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
     5 |                    |              |
     
    -

    ...any new usage of an MO function in this package will update your data file:

    as.mo("lab_mo_ecoli")
    -# Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
    -[1] B_ESCHR_COLI
    +

    ...any new usage of an MO function in this package will update your data file:

    as.mo("lab_mo_ecoli")
    +#&gt; NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
    +#&gt;       (columns "Organisation XYZ" and "mo")
    +#&gt; [1] B_ESCHR_COLI
     
    -mo_genus("lab_Staph_aureus")
    -[1] "Staphylococcus"
    -
    +mo_genus("lab_Staph_aureus") +#&gt; [1] "Staphylococcus"
    -

    To remove the reference data file completely, just use "" or NULL as input for [set_mo_source()]:

    set_mo_source(NULL)
    +

    To delete the reference data file, just use "", NULL or FALSE as input for set_mo_source():

    set_mo_source(NULL)
     # Removed mo_source file '~/.mo_source.rds'.
    - +

    If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of as.mo(). If the mo_source file is manually deleted (i.e. without using set_mo_source()), the references to the mo_source file will be removed upon the next use of as.mo().

    Stable lifecycle

    diff --git a/docs/reference/p_symbol.html b/docs/reference/p_symbol.html index d1dbae16..600dd4fb 100644 --- a/docs/reference/p_symbol.html +++ b/docs/reference/p_symbol.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019
    diff --git a/docs/reference/pca.html b/docs/reference/pca.html index 2d64955d..21185ca3 100644 --- a/docs/reference/pca.html +++ b/docs/reference/pca.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019
    diff --git a/docs/reference/proportion.html b/docs/reference/proportion.html index 715b0a9d..73be35c8 100644 --- a/docs/reference/proportion.html +++ b/docs/reference/proportion.html @@ -83,7 +83,7 @@ resistance() should be used to calculate resistance, susceptibility() should be AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 7bbf5d93..f8b4fa0b 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/skewness.html b/docs/reference/skewness.html index 2cd7fac3..314dab68 100644 --- a/docs/reference/skewness.html +++ b/docs/reference/skewness.html @@ -83,7 +83,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/docs/reference/translate.html b/docs/reference/translate.html index d4f887ba..64921852 100644 --- a/docs/reference/translate.html +++ b/docs/reference/translate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.1.0.9017 + 1.1.0.9019 diff --git a/index.md b/index.md index 6a915997..ea20c3e7 100644 --- a/index.md +++ b/index.md @@ -5,13 +5,13 @@ ### What is `AMR` (for R)? -*(To find out how to conduct AMR analysis, please [continue reading here to get started](./articles/AMR.html).* +*(To find out how to conduct AMR analysis, please [continue reading here to get started](./articles/AMR.html).)* `AMR` is a free, open-source and independent [R package](https://www.r-project.org) to simplify the analysis and prediction of Antimicrobial Resistance (AMR) and to work with microbial and antimicrobial data and properties, by using evidence-based methods. **Our aim is to provide a standard** for clean and reproducible antimicrobial resistance data analysis, that can therefore empower epidemiological analyses to continuously enable surveillance and treatment evaluation in any setting. After installing this package, R knows [**~70,000 distinct microbial species**](./reference/microorganisms.html) and all [**~550 antibiotic, antimycotic and antiviral drugs**](./reference/antibiotics.html) by name and code (including ATC, LOINC and SNOMED CT), and knows all about valid R/SI and MIC values. It supports any data format, including WHONET/EARS-Net data. -This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is [actively maintained](./news) and is free software (see [Copyright](#copyright)). It is fully independent of any other R package and can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources. +This package was created for both routine data analysis and academic research, at the Faculty of Medical Sciences of the University of Groningen, the Netherlands, and the Medical Microbiology & Infection Prevention (MMBI) department of the University Medical Center Groningen (UMCG). This R package is [actively maintained](./news) and is free software (see [Copyright](#copyright)). It is fully independent of any other R package, can be used with all versions of R since R-3.0.0 (April 2013) and has a total file size of only 5 MB. It was designed to work in any setting, including those with very limited resources.

    diff --git a/man/ab_property.Rd b/man/ab_property.Rd index 7f848646..e1fea2b4 100644 --- a/man/ab_property.Rd +++ b/man/ab_property.Rd @@ -74,12 +74,14 @@ Use these functions to return a specific property of an antibiotic from the \lin \details{ All output will be \link{translate}d where possible. -The function \code{\link[=ab_url]{ab_url()}} will return the direct URL to the official WHO website. A warning will be returned if the reauired ATC code is not available. +The function \code{\link[=ab_url]{ab_url()}} will return the direct URL to the official WHO website. A warning will be returned if the required ATC code is not available. } -\section{Maturing lifecycle}{ +\section{Stable lifecycle}{ -\if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr} -The \link[AMR:lifecycle]{lifecycle} of this function is \strong{maturing}. The unlying code of a maturing function has been roughed out, but finer details might still change. This function needs wider usage and more extensive testing in order to optimise the unlying code. +\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr} +The \link[AMR:lifecycle]{lifecycle} of this function is \strong{stable}. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided. + +If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error. } \section{Source}{ diff --git a/man/mo_property.Rd b/man/mo_property.Rd index 4af6ad6f..eee9640b 100644 --- a/man/mo_property.Rd +++ b/man/mo_property.Rd @@ -111,6 +111,14 @@ All output will be \link{translate}d where possible. The function \code{\link[=mo_url]{mo_url()}} will return the direct URL to the online database entry, which also shows the scientific reference of the concerned species. } +\section{Stable lifecycle}{ + +\if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr} +The \link[AMR:lifecycle]{lifecycle} of this function is \strong{stable}. In a stable function, major changes are unlikely. This means that the unlying code will generally evolve by adding new arguments; removing arguments or changing the meaning of existing arguments will be avoided. + +If the unlying code needs breaking changes, they will occur gradually. For example, a parameter will be deprecated and first continue to work, but will emit an message informing you of the change. Next, typically after at least one newly released version on CRAN, the message will be transformed to an error. +} + \section{Catalogue of Life}{ \if{html}{\figure{logo_col.png}{options: height=40px style=margin-bottom:5px} \cr} diff --git a/man/mo_source.Rd b/man/mo_source.Rd index dd7b59d8..0dd376a6 100644 --- a/man/mo_source.Rd +++ b/man/mo_source.Rd @@ -4,14 +4,14 @@ \alias{mo_source} \alias{set_mo_source} \alias{get_mo_source} -\title{Use predefined reference data set} +\title{User-defined reference data set for microorganisms} \usage{ set_mo_source(path) get_mo_source() } \arguments{ -\item{path}{location of your reference file, see Details} +\item{path}{location of your reference file, see Details. Can be \code{""}, \code{NULL} or \code{FALSE} to delete the reference file.} } \description{ These functions can be used to predefine your own reference to be used in \code{\link[=as.mo]{as.mo()}} and consequently all \verb{mo_*} functions like \code{\link[=mo_genus]{mo_genus()}} and \code{\link[=mo_gramstain]{mo_gramstain()}}. @@ -25,10 +25,12 @@ The reference file can be a text file seperated with commas (CSV) or tabs or pip \code{\link[=get_mo_source]{get_mo_source()}} will return the data set by reading \code{"~/.mo_source.rds"} with \code{\link[=readRDS]{readRDS()}}. If the original file has changed (the file defined with \code{path}), it will call \code{\link[=set_mo_source]{set_mo_source()}} to update the data file automatically. -Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file used by this package will have a size of 0.1 kB and can be read by \code{\link[=get_mo_source]{get_mo_source()}} in only a couple of microseconds (a millionth of a second). -\subsection{How it works}{ +Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file created with \code{\link[=set_mo_source]{set_mo_source()}} will then have a size of 0.1 kB and can be read by \code{\link[=get_mo_source]{get_mo_source()}} in only a couple of microseconds (millionths of a second). +} +\section{How to setup}{ -Imagine this data on a sheet of an Excel file (mo codes were looked up in the \code{microorganisms} data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:\preformatted{ | A | B | + +Imagine this data on a sheet of an Excel file (mo codes were looked up in the \link{microorganisms} data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:\preformatted{ | A | B | --|--------------------|--------------| 1 | Organisation XYZ | mo | 2 | lab_mo_ecoli | B_ESCHR_COLI | @@ -37,23 +39,24 @@ Imagine this data on a sheet of an Excel file (mo codes were looked up in the \c } We save it as \code{"home/me/ourcodes.xlsx"}. Now we have to set it as a source:\preformatted{set_mo_source("home/me/ourcodes.xlsx") -# Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. +#> NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx' +#> (columns "Organisation XYZ" and "mo") } -It has now created a file \code{"~/.mo_source.rds"} with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept. +It has now created a file \code{"~/.mo_source.rds"} with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file. And now we can use it in our functions:\preformatted{as.mo("lab_mo_ecoli") -[1] B_ESCHR_COLI +#> [1] B_ESCHR_COLI mo_genus("lab_mo_kpneumoniae") -[1] "Klebsiella" +#> [1] "Klebsiella" # other input values still work too as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli")) -[1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI +#> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI } -If we edit the Excel file to, let's say, by adding row 4 like this:\preformatted{ | A | B | +If we edit the Excel file by, let's say, adding row 4 like this:\preformatted{ | A | B | --|--------------------|--------------| 1 | Organisation XYZ | mo | 2 | lab_mo_ecoli | B_ESCHR_COLI | @@ -63,18 +66,21 @@ If we edit the Excel file to, let's say, by adding row 4 like this:\preformatted } ...any new usage of an MO function in this package will update your data file:\preformatted{as.mo("lab_mo_ecoli") -# Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -[1] B_ESCHR_COLI +#> NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx' +#> (columns "Organisation XYZ" and "mo") +#> [1] B_ESCHR_COLI mo_genus("lab_Staph_aureus") -[1] "Staphylococcus" +#> [1] "Staphylococcus" } -To remove the reference data file completely, just use \code{""} or \code{NULL} as input for \verb{[set_mo_source()]}:\preformatted{set_mo_source(NULL) +To delete the reference data file, just use \code{""}, \code{NULL} or \code{FALSE} as input for \code{\link[=set_mo_source]{set_mo_source()}}:\preformatted{set_mo_source(NULL) # Removed mo_source file '~/.mo_source.rds'. } + +If the original Excel file is moved or deleted, the mo_source file will be removed upon the next use of \code{\link[=as.mo]{as.mo()}}. If the mo_source file is manually deleted (i.e. without using \code{\link[=set_mo_source]{set_mo_source()}}), the references to the mo_source file will be removed upon the next use of \code{\link[=as.mo]{as.mo()}}. } -} + \section{Stable lifecycle}{ \if{html}{\figure{lifecycle_stable.svg}{options: style=margin-bottom:5px} \cr} diff --git a/pkgdown/extra.css b/pkgdown/extra.css index a141e993..4d4be351 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -215,6 +215,11 @@ table a:not(.btn):hover, .table a:not(.btn):hover { font-size: 15px; } +.template-home h4 { + padding-top: 40px !important; + font-weight: bold !important; +} + /* logos on index page */ .logo_img { display: inline-block; diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index 39997955..989d02c6 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -477,8 +477,7 @@ The next example uses the `example_isolates` data set. This is a data set includ 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'} -# use package 'tidyr' to pivot data; -# it gets installed with this 'AMR' package +# use package 'tidyr' to pivot data: library(tidyr) check_FOS <- example_isolates %>% @@ -501,4 +500,4 @@ We can apply the test now with: fisher.test(check_FOS) ``` -As can be seen, the p value is `r round(fisher.test(check_FOS)$p.value, 3)`, which means that the fosfomycin resistance found in hospital A and D are really different. +As can be seen, the p value is `r round(fisher.test(check_FOS)$p.value, 3)`, which means that the fosfomycin resistance found in isolates from patients in hospital A and D are really different. diff --git a/vignettes/MDR.Rmd b/vignettes/MDR.Rmd index 933bbd91..5008fafa 100644 --- a/vignettes/MDR.Rmd +++ b/vignettes/MDR.Rmd @@ -65,7 +65,6 @@ example_isolates %>% freq() # show frequency table of the result ``` ```{r, echo = FALSE, results = 'asis', message = FALSE, warning = FALSE} -library(dplyr) example_isolates %>% mdro(info = FALSE) %>% freq() # show frequency table of the result diff --git a/vignettes/PCA.Rmd b/vignettes/PCA.Rmd index 9abce198..dfa512f7 100755 --- a/vignettes/PCA.Rmd +++ b/vignettes/PCA.Rmd @@ -86,7 +86,6 @@ ggplot_pca(pca_result) You can also print an ellipse per group, and edit the appearance: ```{r} - ggplot_pca(pca_result, ellipse = TRUE) + ggplot2::labs(title = "An AMR/PCA biplot!") ``` diff --git a/vignettes/benchmarks.Rmd b/vignettes/benchmarks.Rmd index 3c157085..1004c63c 100755 --- a/vignettes/benchmarks.Rmd +++ b/vignettes/benchmarks.Rmd @@ -122,9 +122,6 @@ Uncommon microorganisms take some more time than common microorganisms. To furth Repetitive results are unique values that are present more than once. Unique values will only be calculated once by `as.mo()`. We will use `mo_name()` for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses `as.mo()` internally. -```{r, message = FALSE, eval = FALSE} -library(dplyr) -``` ```{r, message = FALSE} # take all MO codes from the example_isolates data set x <- example_isolates$mo %>% diff --git a/vignettes/resistance_predict.Rmd b/vignettes/resistance_predict.Rmd index 24a50567..636ef58e 100755 --- a/vignettes/resistance_predict.Rmd +++ b/vignettes/resistance_predict.Rmd @@ -89,7 +89,7 @@ ggplot_rsi_predict(predict_TZP, ribbon = FALSE) ### Choosing the right model -Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous: +Resistance is not easily predicted; if we look at vancomycin resistance in Gram-positive bacteria, the spread (i.e. standard error) is enormous: ```{r} example_isolates %>% @@ -110,7 +110,7 @@ Valid values are: | `"loglin"` or `"poisson"` | `glm(..., family = poisson)` | Generalised linear model with poisson distribution | | `"lin"` or `"linear"` | `lm()` | Linear model | -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: +For the vancomycin resistance in Gram-positive bacteria, a linear model might be more appropriate since no binomial distribution is to be expected based on the observed years: ```{r} example_isolates %>%