you can find [a comprehensive tutorial](https://msberends.github.io/AMR/articles/AMR.html) about how to conduct AMR analysis, the [complete documentation of all functions](https://msberends.github.io/AMR/reference) (which reads a lot easier than here in R) and [an example analysis using WHONET data](https://msberends.github.io/AMR/articles/WHONET.html). As we would like to better understand the backgrounds and needs of our users, please [participate in our survey](https://msberends.github.io/AMR/survey.html)!
#' @section Contact Us:
#' For suggestions, comments or questions, please contact us at:
#'
diff --git a/R/filter_ab_class.R b/R/filter_ab_class.R
index de0130e0..165814b0 100644
--- a/R/filter_ab_class.R
+++ b/R/filter_ab_class.R
@@ -33,8 +33,7 @@
#' @seealso [antibiotic_class_selectors()] for the `select()` equivalent.
#' @export
#' @examples
-#' \dontrun{
-#' library(dplyr)
+#' if (require(dplyr)) {
#'
#' # filter on isolates that have any result for any aminoglycoside
#' example_isolates %>% filter_ab_class("aminoglycoside")
@@ -64,6 +63,12 @@
#' filter_aminoglycosides("R", "all") %>%
#' filter_fluoroquinolones("R", "all")
#' }
+#'
+#' \dontrun{
+#' # with dplyr 1.0.0 and higher (that adds 'across()'), this is equal:
+#' example_isolates %>% filter_carbapenems("R", "all")
+#' example_isolates %>% filter(across(carbapenems(), ~. == "R"))
+#' }
filter_ab_class <- function(x,
ab_class,
result = NULL,
diff --git a/R/ggplot_pca.R b/R/ggplot_pca.R
index 4f9e7c60..ad4a6f82 100755
--- a/R/ggplot_pca.R
+++ b/R/ggplot_pca.R
@@ -40,6 +40,7 @@
#' @param arrows_colour the colour of the arrow and their text
#' @param arrows_size the size (thickness) of the arrow lines
#' @param arrows_textsize the size of the text at the end of the arrows
+#' @param arrows_textangled a logical whether the text at the end of the arrows should be angled
#' @param arrows_alpha the alpha (transparency) of the arrows and their text
#' @param base_textsize the text size for all plot elements except the labels and arrows
#' @param ... Parameters passed on to functions
@@ -58,20 +59,25 @@
#' # `example_isolates` is a dataset available in the AMR package.
#' # See ?example_isolates.
#'
-#' \dontrun{
#' # See ?pca for more info about Principal Component Analysis (PCA).
-#' library(dplyr)
-#' pca_model <- example_isolates %>%
-#' filter(mo_genus(mo) == "Staphylococcus") %>%
-#' group_by(species = mo_shortname(mo)) %>%
-#' summarise_if (is.rsi, resistance) %>%
-#' pca(FLC, AMC, CXM, GEN, TOB, TMP, SXT, CIP, TEC, TCY, ERY)
+#' if (require("dplyr")) {
+#' pca_model <- example_isolates %>%
+#' filter(mo_genus(mo) == "Staphylococcus") %>%
+#' group_by(species = mo_shortname(mo)) %>%
+#' summarise_if (is.rsi, resistance) %>%
+#' pca(FLC, AMC, CXM, GEN, TOB, TMP, SXT, CIP, TEC, TCY, ERY)
+#'
+#' # old (base R)
+#' biplot(pca_model)
#'
-#' # old
-#' biplot(pca_model)
-#'
-#' # new
-#' ggplot_pca(pca_model)
+#' # new
+#' ggplot_pca(pca_model)
+#'
+#' if (require("ggplot2")) {
+#' ggplot_pca(pca_model) +
+#' scale_colour_viridis_d() +
+#' labs(title = "Title here")
+#' }
#' }
ggplot_pca <- function(x,
choices = 1:2,
@@ -91,26 +97,28 @@ ggplot_pca <- function(x,
arrows_colour = "darkblue",
arrows_size = 0.5,
arrows_textsize = 3,
+ arrows_textangled = TRUE,
arrows_alpha = 0.75,
base_textsize = 10,
...) {
stop_ifnot_installed("ggplot2")
stop_ifnot(length(choices) == 2, "`choices` must be of length 2")
- stop_ifnot(is.logical(scale), "`scale` must be TRUE or FALSE")
- stop_ifnot(is.logical(pc.biplot), "`pc.biplot` must be TRUE or FALSE")
- stop_ifnot(is.numeric(choices), "`choices` must be numeric")
- stop_ifnot(is.numeric(labels_textsize), "`labels_textsize` must be numeric")
- stop_ifnot(is.numeric(labels_text_placement), "`labels_text_placement` must be numeric")
- stop_ifnot(is.logical(ellipse), "`ellipse` must be TRUE or FALSE")
- stop_ifnot(is.numeric(ellipse_prob), "`ellipse_prob` must be numeric")
- stop_ifnot(is.numeric(ellipse_size), "`ellipse_size` must be numeric")
- stop_ifnot(is.numeric(ellipse_alpha), "`ellipse_alpha` must be numeric")
stop_ifnot(is.logical(arrows), "`arrows` must be TRUE or FALSE")
+ stop_ifnot(is.logical(arrows_textangled), "`arrows_textangled` must be TRUE or FALSE")
+ stop_ifnot(is.logical(ellipse), "`ellipse` must be TRUE or FALSE")
+ stop_ifnot(is.logical(pc.biplot), "`pc.biplot` must be TRUE or FALSE")
+ stop_ifnot(is.logical(scale), "`scale` must be TRUE or FALSE")
+ stop_ifnot(is.numeric(arrows_alpha), "`arrows_alpha` must be numeric")
stop_ifnot(is.numeric(arrows_size), "`arrows_size` must be numeric")
stop_ifnot(is.numeric(arrows_textsize), "`arrows_textsize` must be numeric")
- stop_ifnot(is.numeric(arrows_alpha), "`arrows_alpha` must be numeric")
stop_ifnot(is.numeric(base_textsize), "`base_textsize` must be numeric")
+ stop_ifnot(is.numeric(choices), "`choices` must be numeric")
+ stop_ifnot(is.numeric(ellipse_alpha), "`ellipse_alpha` must be numeric")
+ stop_ifnot(is.numeric(ellipse_prob), "`ellipse_prob` must be numeric")
+ stop_ifnot(is.numeric(ellipse_size), "`ellipse_size` must be numeric")
+ stop_ifnot(is.numeric(labels_text_placement), "`labels_text_placement` must be numeric")
+ stop_ifnot(is.numeric(labels_textsize), "`labels_textsize` must be numeric")
calculations <- pca_calculations(pca_model = x,
groups = groups,
@@ -206,12 +214,20 @@ ggplot_pca <- function(x,
type = "open"),
colour = arrows_colour,
size = arrows_size,
- alpha = arrows_alpha) +
- ggplot2::geom_text(data = df.v,
- ggplot2::aes(label = varname, x = xvar, y = yvar, angle = angle, hjust = hjust),
- colour = arrows_colour,
- size = arrows_textsize,
- alpha = arrows_alpha)
+ alpha = arrows_alpha)
+ if (arrows_textangled == TRUE) {
+ g <- g + ggplot2::geom_text(data = df.v,
+ ggplot2::aes(label = varname, x = xvar, y = yvar, angle = angle, hjust = hjust),
+ colour = arrows_colour,
+ size = arrows_textsize,
+ alpha = arrows_alpha)
+ } else {
+ g <- g + ggplot2::geom_text(data = df.v,
+ ggplot2::aes(label = varname, x = xvar, y = yvar, hjust = hjust),
+ colour = arrows_colour,
+ size = arrows_textsize,
+ alpha = arrows_alpha)
+ }
}
# Add caption label about total explained variance
diff --git a/R/rsi.R b/R/rsi.R
index fa8d8a86..5a566a63 100755
--- a/R/rsi.R
+++ b/R/rsi.R
@@ -37,7 +37,7 @@
#'
#' Supported guidelines to be used as input for the `guideline` parameter are: `r paste0('"', sort(unique(AMR::rsi_translation$guideline)), '"', collapse = ", ")`. Simply using `"CLSI"` or `"EUCAST"` for input will automatically select the latest version of that guideline.
#'
-#' The repository of this package [contains a machine readable version](https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt) of all guidelines. This is a CSV file consisting of `r format(nrow(AMR::rsi_translation), big.mark = ",")` rows and `r ncol(AMR::rsi_translation)` columns. This file is machine readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. This **allows for easy implementation of these rules in laboratory information systems (LIS)**.
+#' The repository of this package [contains a machine readable version](https://github.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt) of all guidelines. This is a CSV file consisting of `r format(nrow(AMR::rsi_translation), big.mark = ",")` rows and `r ncol(AMR::rsi_translation)` columns. This file is machine readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. **This allows for easy implementation of these rules in laboratory information systems (LIS)**.
#'
#' After using [as.rsi()], you can use [eucast_rules()] to (1) apply inferred susceptibility and resistance based on results of other antimicrobials and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.
#'
diff --git a/R/rsi_calc.R b/R/rsi_calc.R
index 7eb9fb0c..7136fd1a 100755
--- a/R/rsi_calc.R
+++ b/R/rsi_calc.R
@@ -214,7 +214,7 @@ rsi_calc_df <- function(type, # "proportion", "count" or "both"
out <- data.frame(antibiotic = character(0),
interpretation = character(0),
value = double(0),
- isolates <- integer(0),
+ isolates = integer(0),
stringsAsFactors = FALSE)
if (data_has_groups) {
group_values <- unique(.data[, which(colnames(.data) %in% groups), drop = FALSE])
diff --git a/R/sysdata.rda b/R/sysdata.rda
index 55f0a9e1..539ecb67 100644
Binary files a/R/sysdata.rda and b/R/sysdata.rda differ
diff --git a/README.md b/README.md
index 17155054..21d1b4b7 100755
--- a/README.md
+++ b/README.md
@@ -3,7 +3,13 @@
# `AMR` (for R)
-This is the development source of the `AMR` package for R. Not a developer? Then please visit our website [https://msberends.github.io/AMR](https://msberends.github.io/AMR) to read about this package.
+`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, EARS-NET, 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 is fully independent of any other R package and works on Windows, macOS and Linux with all versions of R since R-3.0.0 (April 2013). It was designed to work in any setting, including those with very limited resources. It was created for both routine data analysis and academic research at the Faculty of Medical Sciences of the University of Groningen, in collaboration with non-profit organisations Certe Medical Diagnostics and Advice and University Medical Center Groningen. This R package is actively maintained and free software; you can freely use and distribute it for both personal and commercial (but not patent) purposes under the terms of the GNU General Public License version 2.0 (GPL-2), as published by the Free Software Foundation.
+
+This is the development source of the `AMR` package for R. Not a developer? Then please visit our website [https://msberends.github.io/AMR](https://msberends.github.io/AMR) to read more about this package.
*NOTE: this source code is on GitHub (https://github.com/msberends/AMR), but also automatically mirrored to GitLab (https://gitlab.com/msberends/AMR).*
diff --git a/_pkgdown.yml b/_pkgdown.yml
index abde494b..81d368a5 100644
--- a/_pkgdown.yml
+++ b/_pkgdown.yml
@@ -70,20 +70,20 @@ navbar:
href: "articles/benchmarks.html"
- text: "Manual"
icon: "fa-book-open"
- href: "reference/"
+ href: "reference/index.html"
- text: "Authors"
icon: "fa-users"
href: "authors.html"
- text: "Changelog"
icon: "far fa-newspaper"
- href: "news/"
+ href: "news/index.html"
right:
- text: "Source Code"
icon: "fab fa-github"
href: "https://github.com/msberends/AMR"
- - text: "Licence"
- icon: "fa-book"
- href: "LICENSE-text.html"
+ - text: "Survey"
+ icon: "fa-clipboard-list"
+ href: "survey.html"
reference:
- title: "Cleaning your data"
@@ -156,7 +156,7 @@ reference:
- "`catalogue_of_life_version`"
- "`WHOCC`"
- "`lifecycle`"
- - title: Other functions
+ - title: "Other functions"
desc: >
These functions are mostly for internal use, but some of
them may also be suitable for your analysis. Especially the
@@ -164,7 +164,7 @@ reference:
contents:
- "`get_locale`"
- "`like`"
- - title: Deprecated functions
+ - title: "Deprecated functions"
desc: >
These functions are deprecated, meaning that they will still
work but show a warning with every use and will be removed
diff --git a/data-raw/create_survey_page.R b/data-raw/create_survey_page.R
new file mode 100644
index 00000000..c36f80a8
--- /dev/null
+++ b/data-raw/create_survey_page.R
@@ -0,0 +1,6 @@
+
+license_text <- readLines("docs/LICENSE-text.html")
+license_text <- paste(license_text, collapse = "|||")
+license_text <- gsub("licen(s|c)e", "Survey", license_text, ignore.case = TRUE)
+license_text <- gsub(".*
", 'If no form is showing below, please click here to open it.
', license_text)
+writeLines(unlist(strsplit(license_text, "|||", fixed = TRUE)), "docs/survey.html")
diff --git a/data-raw/eucast_rules.tsv b/data-raw/eucast_rules.tsv
index cea81413..cada2dbe 100644
--- a/data-raw/eucast_rules.tsv
+++ b/data-raw/eucast_rules.tsv
@@ -177,7 +177,7 @@ genus_species is Clostridium innocuum VAN R Table 04: Intrinsic resistance in
genus_species like ^Streptococcus (pyogenes|agalactiae|dysgalactiae|group A|group B|group C|group G) PEN S aminopenicillins, cephalosporins_except_CAZ, carbapenems S Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules
genus is Enterococcus AMP R ureidopenicillins, carbapenems R Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules
genus is Enterococcus AMX R ureidopenicillins, carbapenems R Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci Expert Rules
-family is Enterobacteriaceae TIC, PIP R, S PIP R Table 09: Interpretive rules for B-lactam agents and Gram-negative rods Expert Rules
+order is Enterobacterales TIC, PIP R, S PIP R Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (at the time: Enterobacteriaceae) Expert Rules
genus like .* ERY S AZM, CLR S Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules
genus like .* ERY I AZM, CLR I Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules
genus like .* ERY R AZM, CLR R Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins Expert Rules
diff --git a/docs/404.html b/docs/404.html
index 6b4c48e9..7d2df2ef 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.2.0.9036
+ 1.2.0.9037
@@ -176,7 +176,7 @@
-
+
Manual
@@ -190,7 +190,7 @@
-
+
Changelog
@@ -206,10 +206,10 @@
-
-
+
+
- Licence
+ Survey
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html
index 5a26c8f2..2d1d6b43 100644
--- a/docs/LICENSE-text.html
+++ b/docs/LICENSE-text.html
@@ -81,7 +81,7 @@
AMR (for R)
- 1.2.0.9036
+ 1.2.0.9037
@@ -176,7 +176,7 @@
-
+
Manual
@@ -190,7 +190,7 @@
-
+
Changelog
@@ -206,10 +206,10 @@
-
-
+
+
- Licence
+ Survey
diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html
index 3943c64d..f6101862 100644
--- a/docs/articles/AMR.html
+++ b/docs/articles/AMR.html
@@ -39,7 +39,7 @@
AMR (for R)
- 1.2.0.9030
+ 1.2.0.9037
@@ -134,7 +134,7 @@
-
+
Manual
@@ -148,7 +148,7 @@
-
+
Changelog
@@ -164,10 +164,10 @@
-
-
+
+
- Licence
+ Survey
@@ -186,7 +186,7 @@
How to conduct AMR analysis
Matthijs S. Berends
- 09 July 2020
+ 24 July 2020
Source: vignettes/AMR.Rmd
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 09 July 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 24 July 2020.
Introduction
@@ -226,21 +226,21 @@
-2020-07-09 |
+2020-07-24 |
abcd |
Escherichia coli |
S |
S |
-2020-07-09 |
+2020-07-24 |
abcd |
Escherichia coli |
S |
R |
-2020-07-09 |
+2020-07-24 |
efgh |
Escherichia coli |
R |
@@ -336,68 +336,68 @@
-2016-01-30 |
-Y5 |
+2014-06-04 |
+V5 |
+Hospital B |
+Escherichia coli |
+R |
+S |
+S |
+S |
+F |
+
+
+2015-09-20 |
+M6 |
Hospital A |
Escherichia coli |
-S |
-S |
-S |
-S |
-F |
-
-
-2010-11-13 |
-Y1 |
-Hospital D |
-Escherichia coli |
R |
S |
S |
S |
-F |
+M |
-2016-07-21 |
-U10 |
-Hospital B |
-Escherichia coli |
-I |
-S |
-S |
-S |
-F |
-
-
-2013-03-14 |
-Q1 |
-Hospital B |
-Staphylococcus aureus |
-R |
-R |
-S |
-S |
-F |
-
-
-2013-04-22 |
-O8 |
-Hospital B |
-Staphylococcus aureus |
-S |
-S |
-R |
-S |
-F |
-
-
-2017-11-14 |
-J4 |
-Hospital A |
+2017-05-14 |
+Q6 |
+Hospital C |
Streptococcus pneumoniae |
+R |
S |
S |
S |
+F |
+
+
+2017-03-12 |
+O3 |
+Hospital D |
+Klebsiella pneumoniae |
+S |
+R |
+S |
+S |
+F |
+
+
+2017-12-27 |
+P8 |
+Hospital B |
+Escherichia coli |
+S |
+S |
+S |
+S |
+F |
+
+
+2013-11-30 |
+B10 |
+Hospital B |
+Staphylococcus aureus |
+I |
+S |
+S |
S |
M |
@@ -432,18 +432,18 @@ Longest: 1
1 |
M |
-10,300 |
-51.5% |
-10,300 |
-51.5% |
+10,487 |
+52.44% |
+10,487 |
+52.44% |
2 |
F |
-9,700 |
-48.5% |
+9,513 |
+47.57% |
20,000 |
-100.0% |
+100.00% |
@@ -481,7 +481,7 @@ Longest: 1
# 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`.