(v1.0.1.9004) Support dplyr 1.0.0

This commit is contained in:
dr. M.S. (Matthijs) Berends 2020-03-14 14:05:43 +01:00
parent 3760bcb11e
commit 219cff403f
62 changed files with 616 additions and 213 deletions

1
.gitignore vendored
View File

@ -20,6 +20,7 @@ vignettes/*.R
^CRAN-RELEASE$ ^CRAN-RELEASE$
packrat/lib*/ packrat/lib*/
packrat/src/ packrat/src/
data-raw/taxa.txt
data-raw/taxon.tab data-raw/taxon.tab
data-raw/DSMZ_bactnames.xlsx data-raw/DSMZ_bactnames.xlsx
data-raw/country_analysis_url_token.R data-raw/country_analysis_url_token.R

View File

@ -1,6 +1,6 @@
Package: AMR Package: AMR
Version: 1.0.1.9003 Version: 1.0.1.9004
Date: 2020-03-08 Date: 2020-03-14
Title: Antimicrobial Resistance Analysis Title: Antimicrobial Resistance Analysis
Authors@R: c( Authors@R: c(
person(role = c("aut", "cre"), person(role = c("aut", "cre"),
@ -46,8 +46,10 @@ Imports:
knitr (>= 1.0.0), knitr (>= 1.0.0),
microbenchmark, microbenchmark,
pillar, pillar,
R6,
rlang (>= 0.3.1), rlang (>= 0.3.1),
tidyr (>= 1.0.0) tidyr (>= 1.0.0),
vctrs (>= 0.2.4)
Suggests: Suggests:
covr (>= 3.0.1), covr (>= 3.0.1),
curl, curl,
@ -63,5 +65,5 @@ BugReports: https://gitlab.com/msberends/AMR/issues
License: GPL-2 | file LICENSE License: GPL-2 | file LICENSE
Encoding: UTF-8 Encoding: UTF-8
LazyData: true LazyData: true
RoxygenNote: 7.0.2 RoxygenNote: 7.1.0
Roxygen: list(markdown = TRUE) Roxygen: list(markdown = TRUE)

View File

@ -1,14 +1,19 @@
# Generated by roxygen2: do not edit by hand # Generated by roxygen2: do not edit by hand
S3method("[",ab) S3method("[",ab)
S3method("[",disk)
S3method("[",mo) S3method("[",mo)
S3method("[<-",ab) S3method("[<-",ab)
S3method("[<-",disk)
S3method("[<-",mo) S3method("[<-",mo)
S3method("[[",ab) S3method("[[",ab)
S3method("[[",disk)
S3method("[[",mo) S3method("[[",mo)
S3method("[[<-",ab) S3method("[[<-",ab)
S3method("[[<-",disk)
S3method("[[<-",mo) S3method("[[<-",mo)
S3method(as.data.frame,ab) S3method(as.data.frame,ab)
S3method(as.data.frame,disk)
S3method(as.data.frame,mo) S3method(as.data.frame,mo)
S3method(as.double,mic) S3method(as.double,mic)
S3method(as.integer,mic) S3method(as.integer,mic)
@ -20,6 +25,7 @@ S3method(as.rsi,mic)
S3method(barplot,mic) S3method(barplot,mic)
S3method(barplot,rsi) S3method(barplot,rsi)
S3method(c,ab) S3method(c,ab)
S3method(c,disk)
S3method(c,mo) S3method(c,mo)
S3method(droplevels,mic) S3method(droplevels,mic)
S3method(droplevels,rsi) S3method(droplevels,rsi)
@ -52,11 +58,21 @@ S3method(skewness,matrix)
S3method(summary,mic) S3method(summary,mic)
S3method(summary,mo) S3method(summary,mo)
S3method(summary,rsi) S3method(summary,rsi)
S3method(type_sum,ab) S3method(vec_cast,character.mo)
S3method(type_sum,disk) S3method(vec_cast,mo)
S3method(type_sum,mic) S3method(vec_cast,mo.character)
S3method(type_sum,mo) S3method(vec_cast,mo.mo)
S3method(type_sum,rsi) S3method(vec_ptype2,mo)
S3method(vec_ptype_abbr,ab)
S3method(vec_ptype_abbr,disk)
S3method(vec_ptype_abbr,mic)
S3method(vec_ptype_abbr,mo)
S3method(vec_ptype_abbr,rsi)
S3method(vec_ptype_full,ab)
S3method(vec_ptype_full,disk)
S3method(vec_ptype_full,mic)
S3method(vec_ptype_full,mo)
S3method(vec_ptype_full,rsi)
export("%like%") export("%like%")
export("%like_case%") export("%like_case%")
export(ab_atc) export(ab_atc)
@ -199,14 +215,19 @@ export(skewness)
export(susceptibility) export(susceptibility)
export(theme_rsi) export(theme_rsi)
exportMethods("[.ab") exportMethods("[.ab")
exportMethods("[.disk")
exportMethods("[.mo") exportMethods("[.mo")
exportMethods("[<-.ab") exportMethods("[<-.ab")
exportMethods("[<-.disk")
exportMethods("[<-.mo") exportMethods("[<-.mo")
exportMethods("[[.ab") exportMethods("[[.ab")
exportMethods("[[.disk")
exportMethods("[[.mo") exportMethods("[[.mo")
exportMethods("[[<-.ab") exportMethods("[[<-.ab")
exportMethods("[[<-.disk")
exportMethods("[[<-.mo") exportMethods("[[<-.mo")
exportMethods(as.data.frame.ab) exportMethods(as.data.frame.ab)
exportMethods(as.data.frame.disk)
exportMethods(as.data.frame.mo) exportMethods(as.data.frame.mo)
exportMethods(as.double.mic) exportMethods(as.double.mic)
exportMethods(as.integer.mic) exportMethods(as.integer.mic)
@ -214,6 +235,7 @@ exportMethods(as.numeric.mic)
exportMethods(barplot.mic) exportMethods(barplot.mic)
exportMethods(barplot.rsi) exportMethods(barplot.rsi)
exportMethods(c.ab) exportMethods(c.ab)
exportMethods(c.disk)
exportMethods(c.mo) exportMethods(c.mo)
exportMethods(droplevels.mic) exportMethods(droplevels.mic)
exportMethods(droplevels.rsi) exportMethods(droplevels.rsi)
@ -244,6 +266,7 @@ exportMethods(skewness.matrix)
exportMethods(summary.mic) exportMethods(summary.mic)
exportMethods(summary.mo) exportMethods(summary.mo)
exportMethods(summary.rsi) exportMethods(summary.rsi)
importFrom(R6,R6Class)
importFrom(cleaner,freq) importFrom(cleaner,freq)
importFrom(cleaner,freq.default) importFrom(cleaner,freq.default)
importFrom(cleaner,percentage) importFrom(cleaner,percentage)
@ -294,7 +317,6 @@ importFrom(dplyr,mutate_at)
importFrom(dplyr,n) importFrom(dplyr,n)
importFrom(dplyr,n_distinct) importFrom(dplyr,n_distinct)
importFrom(dplyr,n_groups) importFrom(dplyr,n_groups)
importFrom(dplyr,progress_estimated)
importFrom(dplyr,pull) importFrom(dplyr,pull)
importFrom(dplyr,rename) importFrom(dplyr,rename)
importFrom(dplyr,row_number) importFrom(dplyr,row_number)
@ -317,7 +339,6 @@ importFrom(graphics,text)
importFrom(knitr,kable) importFrom(knitr,kable)
importFrom(microbenchmark,microbenchmark) importFrom(microbenchmark,microbenchmark)
importFrom(pillar,pillar_shaft) importFrom(pillar,pillar_shaft)
importFrom(pillar,type_sum)
importFrom(rlang,as_label) importFrom(rlang,as_label)
importFrom(rlang,enquos) importFrom(rlang,enquos)
importFrom(rlang,eval_tidy) importFrom(rlang,eval_tidy)
@ -334,3 +355,7 @@ importFrom(tidyr,pivot_wider)
importFrom(utils,adist) importFrom(utils,adist)
importFrom(utils,browseURL) importFrom(utils,browseURL)
importFrom(utils,menu) importFrom(utils,menu)
importFrom(vctrs,vec_cast)
importFrom(vctrs,vec_ptype2)
importFrom(vctrs,vec_ptype_abbr)
importFrom(vctrs,vec_ptype_full)

View File

@ -1,10 +1,13 @@
# AMR 1.0.1.9003 # AMR 1.0.1.9004
## <small>Last updated: 08-Mar-2020</small> ## <small>Last updated: 14-Mar-2020</small>
### New ### New
* Support for easy principal component analysis for AMR, using the new `pca()` function * Support for easy principal component analysis for AMR, using the new `pca()` function
* Plotting biplots for principal component analysis using the new `ggplot_pca()` function * Plotting biplots for principal component analysis using the new `ggplot_pca()` function
### Other
* Support for the upcoming `dplyr` version 1.0.0
# AMR 1.0.1 # AMR 1.0.1
### Changed ### Changed

10
R/ab.R
View File

@ -396,9 +396,15 @@ c.ab <- function(x, ...) {
class_integrity_check(y, "antimicrobial code", antibiotics$ab) class_integrity_check(y, "antimicrobial code", antibiotics$ab)
} }
#' @importFrom pillar type_sum #' @importFrom vctrs vec_ptype_abbr
#' @export #' @export
type_sum.ab <- function(x) { vec_ptype_abbr.ab <- function(x, ...) {
"ab"
}
#' @importFrom vctrs vec_ptype_full
#' @export
vec_ptype_full.ab <- function(x, ...) {
"ab" "ab"
} }

View File

@ -41,6 +41,7 @@
#' - Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code #' - Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code
#' - Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code #' - Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code
#' - Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI #' - Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI
#' - Principal component analysis for AMR
#' @section Read more on our website!: #' @section Read more on our website!:
#' On our website <https://msberends.gitlab.io/AMR> you can find [a comprehensive tutorial](https://msberends.gitlab.io/AMR/articles/AMR.html) about how to conduct AMR analysis, the [complete documentation of all functions](https://msberends.gitlab.io/AMR/reference) (which reads a lot easier than here in R) and [an example analysis using WHONET data](https://msberends.gitlab.io/AMR/articles/WHONET.html). #' On our website <https://msberends.gitlab.io/AMR> you can find [a comprehensive tutorial](https://msberends.gitlab.io/AMR/articles/AMR.html) about how to conduct AMR analysis, the [complete documentation of all functions](https://msberends.gitlab.io/AMR/reference) (which reads a lot easier than here in R) and [an example analysis using WHONET data](https://msberends.gitlab.io/AMR/articles/WHONET.html).

View File

@ -56,7 +56,7 @@
#' - `"ml"` = milliliter (e.g. eyedrops) #' - `"ml"` = milliliter (e.g. eyedrops)
#' @export #' @export
#' @rdname atc_online #' @rdname atc_online
#' @importFrom dplyr %>% progress_estimated #' @importFrom dplyr %>%
#' @inheritSection AMR Read more on our website! #' @inheritSection AMR Read more on our website!
#' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/> #' @source <https://www.whocc.no/atc_ddd_alterations__cumulative/ddd_alterations/abbrevations/>
#' @examples #' @examples

View File

@ -80,7 +80,7 @@ as.disk <- function(x, na.rm = FALSE) {
list_missing, call. = FALSE) list_missing, call. = FALSE)
} }
class(x) <- c("disk", "integer") class(x) <- "disk"
x x
} }
} }
@ -97,6 +97,20 @@ is.disk <- function(x) {
inherits(x, "disk") inherits(x, "disk")
} }
#' @exportMethod as.data.frame.disk
#' @export
#' @noRd
as.data.frame.disk <- function(x, ...) {
# same as as.data.frame.integer but with removed stringsAsFactors, since it will be class "disk"
nm <- paste(deparse(substitute(x), width.cutoff = 500L),
collapse = " ")
if (!"nm" %in% names(list(...))) {
as.data.frame.vector(x, ..., nm = nm)
} else {
as.data.frame.vector(x, ...)
}
}
#' @exportMethod print.disk #' @exportMethod print.disk
#' @export #' @export
#' @noRd #' @noRd
@ -105,12 +119,6 @@ print.disk <- function(x, ...) {
print(as.integer(x), quote = FALSE) print(as.integer(x), quote = FALSE)
} }
#' @importFrom pillar type_sum
#' @export
type_sum.disk <- function(x) {
"disk"
}
#' @importFrom pillar pillar_shaft #' @importFrom pillar pillar_shaft
#' @export #' @export
pillar_shaft.disk <- function(x, ...) { pillar_shaft.disk <- function(x, ...) {
@ -118,3 +126,56 @@ pillar_shaft.disk <- function(x, ...) {
out[is.na(x)] <- pillar::style_na(NA) out[is.na(x)] <- pillar::style_na(NA)
pillar::new_pillar_shaft_simple(out, align = "right", min_width = 3) pillar::new_pillar_shaft_simple(out, align = "right", min_width = 3)
} }
#' @importFrom vctrs vec_ptype_abbr
#' @export
vec_ptype_abbr.disk <- function(x, ...) {
"disk"
}
#' @importFrom vctrs vec_ptype_full
#' @export
vec_ptype_full.disk <- function(x, ...) {
"disk"
}
#' @exportMethod [.disk
#' @export
#' @noRd
"[.disk" <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
}
#' @exportMethod [[.disk
#' @export
#' @noRd
"[[.disk" <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
}
#' @exportMethod [<-.disk
#' @export
#' @noRd
"[<-.disk" <- function(i, j, ..., value) {
y <- NextMethod()
attributes(y) <- attributes(i)
y
}
#' @exportMethod [[<-.disk
#' @export
#' @noRd
"[[<-.disk" <- function(i, j, ..., value) {
y <- NextMethod()
attributes(y) <- attributes(i)
y
}
#' @exportMethod c.disk
#' @export
#' @noRd
c.disk <- function(x, ...) {
y <- NextMethod()
attributes(y) <- attributes(x)
y
}

View File

@ -50,13 +50,14 @@
#' df_joined <- left_join_microorganisms(df, "bacteria") #' df_joined <- left_join_microorganisms(df, "bacteria")
#' colnames(df_joined) #' colnames(df_joined)
inner_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) { inner_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
check_dataset_integrity()
checked <- joins_check_df(x, by) checked <- joins_check_df(x, by)
x <- checked$x x <- checked$x
by <- checked$by by <- checked$by
join <- suppressWarnings( join <- suppressWarnings(
dplyr::inner_join(x = x, y = microorganisms, by = by, suffix = suffix, ...) dplyr::inner_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
) )
if (nrow(join) > nrow(x)) { if (NROW(join) > NROW(x)) {
warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.") warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
} }
join join
@ -65,13 +66,14 @@ inner_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
#' @rdname join #' @rdname join
#' @export #' @export
left_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) { left_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
check_dataset_integrity()
checked <- joins_check_df(x, by) checked <- joins_check_df(x, by)
x <- checked$x x <- checked$x
by <- checked$by by <- checked$by
join <- suppressWarnings( join <- suppressWarnings(
dplyr::left_join(x = x, y = microorganisms, by = by, suffix = suffix, ...) dplyr::left_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
) )
if (nrow(join) > nrow(x)) { if (NROW(join) > NROW(x)) {
warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.") warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
} }
join join
@ -80,13 +82,14 @@ left_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
#' @rdname join #' @rdname join
#' @export #' @export
right_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) { right_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
check_dataset_integrity()
checked <- joins_check_df(x, by) checked <- joins_check_df(x, by)
x <- checked$x x <- checked$x
by <- checked$by by <- checked$by
join <- suppressWarnings( join <- suppressWarnings(
dplyr::right_join(x = x, y = microorganisms, by = by, suffix = suffix, ...) dplyr::right_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
) )
if (nrow(join) > nrow(x)) { if (NROW(join) > NROW(x)) {
warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.") warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
} }
join join
@ -95,13 +98,14 @@ right_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
#' @rdname join #' @rdname join
#' @export #' @export
full_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) { full_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
check_dataset_integrity()
checked <- joins_check_df(x, by) checked <- joins_check_df(x, by)
x <- checked$x x <- checked$x
by <- checked$by by <- checked$by
join <- suppressWarnings( join <- suppressWarnings(
dplyr::full_join(x = x, y = microorganisms, by = by, suffix = suffix, ...) dplyr::full_join(x = x, y = microorganisms, by = by, suffix = suffix, ...)
) )
if (nrow(join) > nrow(x)) { if (NROW(join) > NROW(x)) {
warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.") warning("The newly joined tbl contains ", nrow(join) - nrow(x), " rows more that its original.")
} }
join join
@ -110,6 +114,7 @@ full_join_microorganisms <- function(x, by = NULL, suffix = c("2", ""), ...) {
#' @rdname join #' @rdname join
#' @export #' @export
semi_join_microorganisms <- function(x, by = NULL, ...) { semi_join_microorganisms <- function(x, by = NULL, ...) {
check_dataset_integrity()
checked <- joins_check_df(x, by) checked <- joins_check_df(x, by)
x <- checked$x x <- checked$x
by <- checked$by by <- checked$by
@ -121,6 +126,7 @@ semi_join_microorganisms <- function(x, by = NULL, ...) {
#' @rdname join #' @rdname join
#' @export #' @export
anti_join_microorganisms <- function(x, by = NULL, ...) { anti_join_microorganisms <- function(x, by = NULL, ...) {
check_dataset_integrity()
checked <- joins_check_df(x, by) checked <- joins_check_df(x, by)
x <- checked$x x <- checked$x
by <- checked$by by <- checked$by
@ -131,7 +137,7 @@ anti_join_microorganisms <- function(x, by = NULL, ...) {
joins_check_df <- function(x, by) { joins_check_df <- function(x, by) {
if (!any(class(x) %in% c("data.frame", "matrix"))) { if (!any(class(x) %in% c("data.frame", "matrix"))) {
x <- data.frame(mo = as.character(x), stringsAsFactors = FALSE) x <- data.frame(mo = as.mo(x), stringsAsFactors = FALSE)
if (is.null(by)) { if (is.null(by)) {
by <- "mo" by <- "mo"
} }
@ -142,6 +148,7 @@ joins_check_df <- function(x, by) {
if (is.na(by)) { if (is.na(by)) {
if ("mo" %in% colnames(x)) { if ("mo" %in% colnames(x)) {
by <- "mo" by <- "mo"
x[, "mo"] <- as.mo(x[, "mo"])
} else { } else {
stop("Cannot join - no column found with name or class `mo`.", call. = FALSE) stop("Cannot join - no column found with name or class `mo`.", call. = FALSE)
} }

View File

@ -245,7 +245,7 @@ key_antibiotics <- function(x,
} }
#' @importFrom dplyr progress_estimated %>% #' @importFrom dplyr %>%
#' @rdname key_antibiotics #' @rdname key_antibiotics
#' @export #' @export
key_antibiotics_equal <- function(y, key_antibiotics_equal <- function(y,
@ -270,7 +270,7 @@ key_antibiotics_equal <- function(y,
result <- logical(length(x)) result <- logical(length(x))
if (info_needed == TRUE) { if (info_needed == TRUE) {
p <- dplyr::progress_estimated(length(x)) p <- progress_estimated(length(x))
} }
for (i in seq_len(length(x))) { for (i in seq_len(length(x))) {

10
R/mic.R
View File

@ -235,9 +235,15 @@ barplot.mic <- function(height,
axis(2, seq(0, max(table(droplevels.factor(height))))) axis(2, seq(0, max(table(droplevels.factor(height)))))
} }
#' @importFrom pillar type_sum #' @importFrom vctrs vec_ptype_abbr
#' @export #' @export
type_sum.mic <- function(x) { vec_ptype_abbr.mic <- function(x, ...) {
"mic"
}
#' @importFrom vctrs vec_ptype_full
#' @export
vec_ptype_full.mic <- function(x, ...) {
"mic" "mic"
} }

48
R/mo.R
View File

@ -78,9 +78,9 @@
#' - Uncertainty level 3: allow all of level 1 and 2, strip off text elements from the end, allow any part of a taxonomic name. #' - Uncertainty level 3: allow all of level 1 and 2, strip off text elements from the end, allow any part of a taxonomic name.
#' #'
#' This leads to e.g.: #' This leads to e.g.:
#' - `"Streptococcus group B (known as S. agalactiae)"`. The text between brackets will be removed and a warning will be thrown that the result *Streptococcus group B* (`B_STRPT_GRPB`) needs review. #' - `"Streptococcus group B (known as S. agalactiae)"`. The text between brackets will be removed and a warning will be thrown that the result *Streptococcus group B* (``r as.mo("Streptococcus group B")``) needs review.
#' - `"S. aureus - please mind: MRSA"`. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result *Staphylococcus aureus* (`B_STPHY_AURS`) needs review. #' - `"S. aureus - please mind: MRSA"`. The last word will be stripped, after which the function will try to find a match. If it does not, the second last word will be stripped, etc. Again, a warning will be thrown that the result *Staphylococcus aureus* (``r as.mo("Staphylococcus aureus")``) needs review.
#' - `"Fluoroquinolone-resistant Neisseria gonorrhoeae"`. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result *Neisseria gonorrhoeae* (`B_NESSR_GNRR`) needs review. #' - `"Fluoroquinolone-resistant Neisseria gonorrhoeae"`. The first word will be stripped, after which the function will try to find a match. A warning will be thrown that the result *Neisseria gonorrhoeae* (``r as.mo("Neisseria gonorrhoeae")``) needs review.
#' #'
#' The level of uncertainty can be set using the argument `allow_uncertain`. The default is `allow_uncertain = TRUE`, which is equal to uncertainty level 2. Using `allow_uncertain = FALSE` is equal to uncertainty level 0 and will skip all rules. You can also use e.g. `as.mo(..., allow_uncertain = 1)` to only allow up to level 1 uncertainty. #' The level of uncertainty can be set using the argument `allow_uncertain`. The default is `allow_uncertain = TRUE`, which is equal to uncertainty level 2. Using `allow_uncertain = FALSE` is equal to uncertainty level 0 and will skip all rules. You can also use e.g. `as.mo(..., allow_uncertain = 1)` to only allow up to level 1 uncertainty.
#' #'
@ -234,7 +234,7 @@ is.mo <- function(x) {
inherits(x, "mo") inherits(x, "mo")
} }
#' @importFrom dplyr %>% pull left_join n_distinct progress_estimated filter distinct #' @importFrom dplyr %>% pull left_join n_distinct filter distinct
#' @importFrom data.table data.table as.data.table setkey #' @importFrom data.table data.table as.data.table setkey
#' @importFrom crayon magenta red blue silver italic #' @importFrom crayon magenta red blue silver italic
#' @importFrom cleaner percentage #' @importFrom cleaner percentage
@ -1675,12 +1675,48 @@ print.mo <- function(x, ...) {
print.default(x, quote = FALSE) print.default(x, quote = FALSE)
} }
#' @importFrom pillar type_sum #' @importFrom vctrs vec_ptype_abbr
#' @export #' @export
type_sum.mo <- function(x) { vec_ptype_abbr.mo <- function(x, ...) {
"mo" "mo"
} }
#' @importFrom vctrs vec_ptype_full
#' @export
vec_ptype_full.mo <- function(x, ...) {
"mo"
}
#' @importFrom vctrs vec_ptype2
#' @export
vec_ptype2.mo <- function(x, y, ...) {
vctrs::vec_ptype2(x = as.character(x), y = as.character(y), ...)
}
#' @importFrom vctrs vec_cast
#' @export
vec_cast.mo <- function(x, to, ...) {
as.mo(vctrs::vec_cast(x = as.character(x), to = as.character(to), ...))
}
#' @importFrom vctrs vec_cast
#' @export
vec_cast.mo.mo <- function(x, to, ...) {
as.mo(vctrs::vec_cast(x = as.character(x), to = as.character(to), ...))
}
#' @importFrom vctrs vec_cast
#' @export
vec_cast.mo.character <- function(x, to, ...) {
vctrs::vec_cast(x = as.character(x), to = as.character(to), ...)
}
#' @importFrom vctrs vec_cast
#' @export
vec_cast.character.mo <- function(x, to, ...) {
as.mo(vctrs::vec_cast(x = as.character(x), to = as.character(to), ...))
}
#' @importFrom pillar pillar_shaft #' @importFrom pillar pillar_shaft
#' @export #' @export
pillar_shaft.mo <- function(x, ...) { pillar_shaft.mo <- function(x, ...) {

View File

@ -22,7 +22,7 @@
#' Principal Component Analysis (for AMR) #' Principal Component Analysis (for AMR)
#' #'
#' Performs a principal component analysis (PCA) based on a data set with automatic determination for afterwards plotting the groups and labels, and automatic filtering on only suitable (i.e. non-empty and numeric) variables. #' Performs a principal component analysis (PCA) based on a data set with automatic determination for afterwards plotting the groups and labels, and automatic filtering on only suitable (i.e. non-empty and numeric) variables.
#' @inheritSection lifecycle Experimental lifecycle #' @inheritSection lifecycle Maturing lifecycle
#' @param x a [data.frame] containing numeric columns #' @param x a [data.frame] containing numeric columns
#' @param ... columns of `x` to be selected for PCA #' @param ... columns of `x` to be selected for PCA
#' @inheritParams stats::prcomp #' @inheritParams stats::prcomp

142
R/progress_estimated.R Normal file
View File

@ -0,0 +1,142 @@
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis #
# #
# SOURCE #
# https://gitlab.com/msberends/AMR #
# #
# LICENCE #
# (c) 2018-2020 Berends MS, Luz CF et al. #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# #
# We created this package for both routine data analysis and academic #
# research and it was publicly released in the hope that it will be #
# useful, but it comes WITHOUT ANY WARRANTY OR LIABILITY. #
# Visit our website for more info: https://msberends.gitlab.io/AMR. #
# ==================================================================== #
# taken from https://github.com/tidyverse/dplyr/blob/f306d8da8f27c2e6abbd3c70f219fef7ca61fbb5/R/progress.R
# when it was still in the dplyr package
progress_estimated <- function(n, min_time = 0) {
Progress$new(n, min_time = min_time)
}
#' @importFrom R6 R6Class
Progress <- R6::R6Class("Progress",
public = list(
n = NULL,
i = 0,
init_time = NULL,
stopped = FALSE,
stop_time = NULL,
min_time = NULL,
last_update = NULL,
initialize = function(n, min_time = 0, ...) {
self$n <- n
self$min_time <- min_time
self$begin()
},
begin = function() {
"Initialise timer. Call this before beginning timing."
self$i <- 0
self$last_update <- self$init_time <- now()
self$stopped <- FALSE
self
},
pause = function(x) {
"Sleep for x seconds. Useful for testing."
Sys.sleep(x)
self
},
width = function() {
getOption("width") - nchar("|100% ~ 99.9 h remaining") - 2
},
tick = function() {
"Process one element"
if (self$stopped) return(self)
if (self$i == self$n) stop("No more ticks")
self$i <- self$i + 1
self
},
stop = function() {
if (self$stopped) return(self)
self$stopped <- TRUE
self$stop_time <- now()
self
},
print = function(...) {
if (!isTRUE(getOption("dplyr.show_progress")) || # user sepecifies no progress
!interactive() || # not an interactive session
!is.null(getOption("knitr.in.progress"))) { # dplyr used within knitr document
return(invisible(self))
}
now_ <- now()
if (now_ - self$init_time < self$min_time || now_ - self$last_update < 0.05) {
return(invisible(self))
}
self$last_update <- now_
if (self$stopped) {
overall <- show_time(self$stop_time - self$init_time)
if (self$i == self$n) {
cat_line("Completed after ", overall)
cat("\n")
} else {
cat_line("Killed after ", overall)
cat("\n")
}
return(invisible(self))
}
avg <- (now() - self$init_time) / self$i
time_left <- (self$n - self$i) * avg
nbars <- trunc(self$i / self$n * self$width())
cat_line(
"|", str_rep("=", nbars), str_rep(" ", self$width() - nbars), "|",
format(round(self$i / self$n * 100), width = 3), "% ",
"~", show_time(time_left), " remaining"
)
invisible(self)
}
)
)
cat_line <- function(...) {
msg <- paste(..., sep = "", collapse = "")
gap <- max(c(0, getOption("width") - nchar(msg, "width")))
cat("\r", msg, rep.int(" ", gap), sep = "")
utils::flush.console()
}
str_rep <- function(x, i) {
paste(rep.int(x, i), collapse = "")
}
show_time <- function(x) {
if (x < 60) {
paste(round(x), "s")
} else if (x < 60 * 60) {
paste(round(x / 60), "m")
} else {
paste(round(x / (60 * 60)), "h")
}
}
now <- function() proc.time()[[3]]

10
R/rsi.R
View File

@ -659,9 +659,15 @@ barplot.rsi <- function(height,
} }
} }
#' @importFrom pillar type_sum #' @importFrom vctrs vec_ptype_abbr
#' @export #' @export
type_sum.rsi <- function(x) { vec_ptype_abbr.rsi <- function(x, ...) {
"rsi"
}
#' @importFrom vctrs vec_ptype_full
#' @export
vec_ptype_full.rsi <- function(x, ...) {
"rsi" "rsi"
} }

Binary file not shown.

View File

@ -50,7 +50,7 @@ rm(data_json)
# add country data based on IP address and ipinfo.io API # add country data based on IP address and ipinfo.io API
unique_ip <- unique(data$ipaddress) unique_ip <- unique(data$ipaddress)
ip_tbl <- GET_df(unique_ip[1]) ip_tbl <- GET_df(unique_ip[1])
p <- progress_estimated(n = length(unique_ip) - 1, min_time = 0) p <- AMR:::progress_estimated(n = length(unique_ip) - 1, min_time = 0)
for (i in 2:length(unique_ip)) { for (i in 2:length(unique_ip)) {
p$tick()$print() p$tick()$print()
ip_tbl <- ip_tbl %>% ip_tbl <- ip_tbl %>%

View File

@ -23,6 +23,7 @@
# Data retrieved from the Catalogue of Life (CoL) through the Encyclopaedia of Life: # Data retrieved from the Catalogue of Life (CoL) through the Encyclopaedia of Life:
# https://opendata.eol.org/dataset/catalogue-of-life/ # https://opendata.eol.org/dataset/catalogue-of-life/
# https://doi.org/10.15468/rffz4x
# (download the resource file with a name like "Catalogue of Life yyyy-mm-dd") # (download the resource file with a name like "Catalogue of Life yyyy-mm-dd")
# and from the Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures # and from the Leibniz Institute DSMZ-German Collection of Microorganisms and Cell Cultures
# https://www.dsmz.de/support/bacterial-nomenclature-up-to-date-downloads.html # https://www.dsmz.de/support/bacterial-nomenclature-up-to-date-downloads.html
@ -32,7 +33,8 @@ library(dplyr)
library(AMR) library(AMR)
# unzip and extract taxon.tab (around 1.5 GB) from the CoL archive, then: # unzip and extract taxon.tab (around 1.5 GB) from the CoL archive, then:
data_col <- data.table::fread("data-raw/taxon.tab") # data_col <- data.table::fread("data-raw/taxon.tab")
data_col <- data.table::fread("data-raw/taxa.txt", quote = "")
# read the xlsx file from DSMZ (only around 2.5 MB): # read the xlsx file from DSMZ (only around 2.5 MB):
data_dsmz <- readxl::read_xlsx("data-raw/DSMZ_bactnames.xlsx") data_dsmz <- readxl::read_xlsx("data-raw/DSMZ_bactnames.xlsx")
@ -66,7 +68,7 @@ data_col <- data_col %>%
subspecies = infraspecificEpithet, subspecies = infraspecificEpithet,
rank = taxonRank, rank = taxonRank,
ref = scientificNameAuthorship, ref = scientificNameAuthorship,
species_id = furtherInformationURL) species_id = references)
data_col$source <- "CoL" data_col$source <- "CoL"
# clean data_dsmz # clean data_dsmz
@ -761,6 +763,7 @@ new_families <- MOs %>%
class(MOs$mo) <- "character" class(MOs$mo) <- "character"
MOs <- rbind(MOs %>% filter(!(rank == "family" & fullname %in% new_families)), MOs <- rbind(MOs %>% filter(!(rank == "family" & fullname %in% new_families)),
AMR::microorganisms %>% AMR::microorganisms %>%
select(-snomed) %>%
filter(family == "Enterobacteriaceae" & rank == "family") %>% filter(family == "Enterobacteriaceae" & rank == "family") %>%
rbind(., ., ., ., ., ., .) %>% rbind(., ., ., ., ., ., .) %>%
mutate(fullname = new_families, mutate(fullname = new_families,
@ -794,7 +797,9 @@ colnames(MOs)
MOs %>% arrange(fullname) %>% filter(!fullname %in% AMR::microorganisms$fullname) %>% View() MOs %>% arrange(fullname) %>% filter(!fullname %in% AMR::microorganisms$fullname) %>% View()
MOs.old %>% arrange(fullname) %>% filter(!fullname %in% AMR::microorganisms.old$fullname) %>% View() MOs.old %>% arrange(fullname) %>% filter(!fullname %in% AMR::microorganisms.old$fullname) %>% View()
# and the ones we lost: # and the ones we lost:
AMR::microorganisms %>% filter(!fullname %in% MOs$fullname) %>% View() AMR::microorganisms %>% filter(!fullname %in% MOs$fullname) %>% View() # based on fullname
AMR::microorganisms %>% filter(!mo %in% MOs$mo) %>% View() # based on mo
AMR::microorganisms %>% filter(!mo %in% MOs$mo & !fullname %in% MOs$fullname) %>% View()
# and these IDs have changed: # and these IDs have changed:
old_new <- MOs %>% old_new <- MOs %>%
mutate(kingdom_fullname = paste(kingdom, fullname)) %>% mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
@ -815,14 +820,31 @@ View(old_new)
# and these codes are now missing (which will throw a unit test error): # and these codes are now missing (which will throw a unit test error):
AMR::microorganisms.codes %>% filter(!mo %in% MOs$mo) AMR::microorganisms.codes %>% filter(!mo %in% MOs$mo)
AMR::rsi_translation %>% filter(!mo %in% MOs$mo) AMR::rsi_translation %>% filter(!mo %in% MOs$mo)
AMR::microorganisms.translation %>% filter(!mo_new %in% MOs$mo) AMR:::microorganisms.translation %>% filter(!mo_new %in% MOs$mo) %>% View()
# this is how to fix it # this is how to fix it
microorganisms.codes <- AMR::microorganisms.codes %>% microorganisms.codes <- AMR::microorganisms.codes %>%
left_join(MOs %>% left_join(MOs %>%
mutate(kingdom_fullname = paste(kingdom, fullname)) %>% mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
left_join(AMR::microorganisms %>% left_join(AMR::microorganisms %>%
transmute(mo, kingdom_fullname = paste(kingdom, fullname)),
by = "kingdom_fullname", suffix = c("_new", "_old")) %>%
select(mo_old, mo_new),
by = c("mo" = "mo_old")) %>%
select(code, mo = mo_new) %>%
filter(!is.na(mo))
microorganisms.codes %>% filter(!mo %in% MOs$mo)
# and for microorganisms.translation:
microorganisms.translation <- AMR:::microorganisms.translation %>%
select(mo = mo_new) %>%
left_join(AMR::microorganisms %>%
transmute(mo, kingdom_fullname = paste(kingdom, fullname)),
by = "kingdom_fullname", suffix = c("_new", "_old")) %>%
select(mo_old, mo_new)
left_join(MOs %>%
mutate(kingdom_fullname = paste(kingdom, fullname)) %>% mutate(kingdom_fullname = paste(kingdom, fullname)) %>%
select(mo, kingdom_fullname), by = "kingdom_fullname", suffix = c("_new", "_old")) %>% left_join(AMR::microorganisms %>%
transmute(mo, kingdom_fullname = paste(kingdom, fullname)),
by = "kingdom_fullname", suffix = c("_new", "_old")) %>%
select(mo_old, mo_new), select(mo_old, mo_new),
by = c("mo" = "mo_old")) %>% by = c("mo" = "mo_old")) %>%
select(code, mo = mo_new) %>% select(code, mo = mo_new) %>%

View File

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

View File

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

View File

@ -39,7 +39,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9000</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -77,9 +77,9 @@
</li> </li>
<li> <li>
<a href="../articles/PCA.html"> <a href="../articles/PCA.html">
<span class="fa fa-compress-alt"></span> <span class="fa fa-compress"></span>
Conduct Principal Component Analysis for AMR Conduct principal component analysis for AMR
</a> </a>
</li> </li>
<li> <li>
@ -186,7 +186,7 @@
<h1>How to apply EUCAST rules</h1> <h1>How to apply EUCAST rules</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 March 2020</h4> <h4 class="date">14 March 2020</h4>
<div class="hidden name"><code>EUCAST.Rmd</code></div> <div class="hidden name"><code>EUCAST.Rmd</code></div>

View File

@ -39,7 +39,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9000</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -186,7 +186,7 @@
<h1>How to conduct principal component analysis (PCA) for AMR</h1> <h1>How to conduct principal component analysis (PCA) for AMR</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 March 2020</h4> <h4 class="date">14 March 2020</h4>
<div class="hidden name"><code>PCA.Rmd</code></div> <div class="hidden name"><code>PCA.Rmd</code></div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

@ -39,7 +39,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9000</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -186,7 +186,7 @@
<h1>Benchmarks</h1> <h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4> <h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">07 March 2020</h4> <h4 class="date">14 March 2020</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div> <div class="hidden name"><code>benchmarks.Rmd</code></div>
@ -220,36 +220,21 @@
<span id="cb2-16"><a href="#cb2-16"></a> <span class="dt">times =</span> <span class="dv">10</span>)</span> <span id="cb2-16"><a href="#cb2-16"></a> <span class="dt">times =</span> <span class="dv">10</span>)</span>
<span id="cb2-17"><a href="#cb2-17"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</span> <span id="cb2-17"><a href="#cb2-17"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(S.aureus, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">2</span>)</span>
<span id="cb2-18"><a href="#cb2-18"></a><span class="co"># Unit: milliseconds</span></span> <span id="cb2-18"><a href="#cb2-18"></a><span class="co"># Unit: milliseconds</span></span>
<span id="cb2-19"><a href="#cb2-19"></a><span class="co"># expr min lq mean median uq max</span></span> <span id="cb2-19"><a href="#cb2-19"></a><span class="co"># expr min lq mean median uq max neval</span></span>
<span id="cb2-20"><a href="#cb2-20"></a><span class="co"># as.mo("sau") 8.0 8.2 9.1 8.4 8.5 16</span></span> <span id="cb2-20"><a href="#cb2-20"></a><span class="co"># as.mo("sau") 8.9 9.3 9.6 9.6 9.9 10 10</span></span>
<span id="cb2-21"><a href="#cb2-21"></a><span class="co"># as.mo("stau") 37.0 40.0 51.0 52.0 60.0 76</span></span> <span id="cb2-21"><a href="#cb2-21"></a><span class="co"># as.mo("stau") 41.0 41.0 51.0 43.0 67.0 74 10</span></span>
<span id="cb2-22"><a href="#cb2-22"></a><span class="co"># as.mo("STAU") 36.0 38.0 58.0 60.0 68.0 100</span></span> <span id="cb2-22"><a href="#cb2-22"></a><span class="co"># as.mo("STAU") 39.0 41.0 49.0 42.0 56.0 72 10</span></span>
<span id="cb2-23"><a href="#cb2-23"></a><span class="co"># as.mo("staaur") 8.2 8.4 9.5 8.6 8.9 14</span></span> <span id="cb2-23"><a href="#cb2-23"></a><span class="co"># as.mo("staaur") 9.0 9.2 9.7 9.5 9.9 11 10</span></span>
<span id="cb2-24"><a href="#cb2-24"></a><span class="co"># as.mo("STAAUR") 8.2 8.3 15.0 9.2 14.0 53</span></span> <span id="cb2-24"><a href="#cb2-24"></a><span class="co"># as.mo("STAAUR") 9.5 9.8 24.0 21.0 38.0 45 10</span></span>
<span id="cb2-25"><a href="#cb2-25"></a><span class="co"># as.mo("S. aureus") 13.0 21.0 64.0 21.0 45.0 260</span></span> <span id="cb2-25"><a href="#cb2-25"></a><span class="co"># as.mo("S. aureus") 15.0 16.0 26.0 18.0 38.0 61 10</span></span>
<span id="cb2-26"><a href="#cb2-26"></a><span class="co"># as.mo("S aureus") 13.0 14.0 33.0 24.0 44.0 76</span></span> <span id="cb2-26"><a href="#cb2-26"></a><span class="co"># as.mo("S aureus") 15.0 15.0 17.0 16.0 17.0 21 10</span></span>
<span id="cb2-27"><a href="#cb2-27"></a><span class="co"># as.mo("Staphylococcus aureus") 4.7 4.8 9.9 6.8 7.9 42</span></span> <span id="cb2-27"><a href="#cb2-27"></a><span class="co"># as.mo("Staphylococcus aureus") 5.2 5.6 8.4 6.0 6.5 30 10</span></span>
<span id="cb2-28"><a href="#cb2-28"></a><span class="co"># as.mo("Staphylococcus aureus (MRSA)") 620.0 640.0 770.0 700.0 860.0 1100</span></span> <span id="cb2-28"><a href="#cb2-28"></a><span class="co"># as.mo("Staphylococcus aureus (MRSA)") 640.0 690.0 710.0 710.0 720.0 760 10</span></span>
<span id="cb2-29"><a href="#cb2-29"></a><span class="co"># as.mo("Sthafilokkockus aaureuz") 330.0 350.0 460.0 490.0 560.0 570</span></span> <span id="cb2-29"><a href="#cb2-29"></a><span class="co"># as.mo("Sthafilokkockus aaureuz") 350.0 360.0 420.0 400.0 490.0 510 10</span></span>
<span id="cb2-30"><a href="#cb2-30"></a><span class="co"># as.mo("MRSA") 8.1 8.3 14.0 12.0 13.0 48</span></span> <span id="cb2-30"><a href="#cb2-30"></a><span class="co"># as.mo("MRSA") 9.2 9.3 16.0 10.0 10.0 49 10</span></span>
<span id="cb2-31"><a href="#cb2-31"></a><span class="co"># as.mo("VISA") 24.0 25.0 34.0 26.0 38.0 59</span></span> <span id="cb2-31"><a href="#cb2-31"></a><span class="co"># as.mo("VISA") 25.0 27.0 46.0 56.0 57.0 60 10</span></span>
<span id="cb2-32"><a href="#cb2-32"></a><span class="co"># as.mo("VRSA") 23.0 24.0 37.0 27.0 39.0 78</span></span> <span id="cb2-32"><a href="#cb2-32"></a><span class="co"># as.mo("VRSA") 26.0 27.0 39.0 28.0 32.0 120 10</span></span>
<span id="cb2-33"><a href="#cb2-33"></a><span class="co"># as.mo(22242419) 120.0 130.0 150.0 140.0 160.0 240</span></span> <span id="cb2-33"><a href="#cb2-33"></a><span class="co"># as.mo(22242419) 120.0 140.0 170.0 140.0 150.0 410 10</span></span></code></pre></div>
<span id="cb2-34"><a href="#cb2-34"></a><span class="co"># neval</span></span>
<span id="cb2-35"><a href="#cb2-35"></a><span class="co"># 10</span></span>
<span id="cb2-36"><a href="#cb2-36"></a><span class="co"># 10</span></span>
<span id="cb2-37"><a href="#cb2-37"></a><span class="co"># 10</span></span>
<span id="cb2-38"><a href="#cb2-38"></a><span class="co"># 10</span></span>
<span id="cb2-39"><a href="#cb2-39"></a><span class="co"># 10</span></span>
<span id="cb2-40"><a href="#cb2-40"></a><span class="co"># 10</span></span>
<span id="cb2-41"><a href="#cb2-41"></a><span class="co"># 10</span></span>
<span id="cb2-42"><a href="#cb2-42"></a><span class="co"># 10</span></span>
<span id="cb2-43"><a href="#cb2-43"></a><span class="co"># 10</span></span>
<span id="cb2-44"><a href="#cb2-44"></a><span class="co"># 10</span></span>
<span id="cb2-45"><a href="#cb2-45"></a><span class="co"># 10</span></span>
<span id="cb2-46"><a href="#cb2-46"></a><span class="co"># 10</span></span>
<span id="cb2-47"><a href="#cb2-47"></a><span class="co"># 10</span></span>
<span id="cb2-48"><a href="#cb2-48"></a><span class="co"># 10</span></span></code></pre></div>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="562.5"></p> <p><img src="benchmarks_files/figure-html/unnamed-chunk-4-1.png" width="562.5"></p>
<p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second.</p> <p>In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second.</p>
<p>To achieve this speed, the <code>as.mo</code> 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 <em>Methanosarcina semesiae</em> (<code>B_MTHNSR_SEMS</code>), a bug probably never found before in humans:</p> <p>To achieve this speed, the <code>as.mo</code> 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 <em>Methanosarcina semesiae</em> (<code>B_MTHNSR_SEMS</code>), a bug probably never found before in humans:</p>
@ -262,18 +247,18 @@
<span id="cb3-7"><a href="#cb3-7"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(M.semesiae, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</span> <span id="cb3-7"><a href="#cb3-7"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(M.semesiae, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</span>
<span id="cb3-8"><a href="#cb3-8"></a><span class="co"># Unit: milliseconds</span></span> <span id="cb3-8"><a href="#cb3-8"></a><span class="co"># Unit: milliseconds</span></span>
<span id="cb3-9"><a href="#cb3-9"></a><span class="co"># expr min lq mean median uq</span></span> <span id="cb3-9"><a href="#cb3-9"></a><span class="co"># expr min lq mean median uq</span></span>
<span id="cb3-10"><a href="#cb3-10"></a><span class="co"># as.mo("metsem") 1349.000 1352.000 1597.000 1411.000 1983.000</span></span> <span id="cb3-10"><a href="#cb3-10"></a><span class="co"># as.mo("metsem") 1485.000 1507.000 1524.00 1519.000 1538.000</span></span>
<span id="cb3-11"><a href="#cb3-11"></a><span class="co"># as.mo("METSEM") 1316.000 2146.000 2069.000 2226.000 2245.000</span></span> <span id="cb3-11"><a href="#cb3-11"></a><span class="co"># as.mo("METSEM") 1371.000 1495.000 1557.00 1567.000 1633.000</span></span>
<span id="cb3-12"><a href="#cb3-12"></a><span class="co"># as.mo("M. semesiae") 13.330 14.110 32.960 21.840 53.090</span></span> <span id="cb3-12"><a href="#cb3-12"></a><span class="co"># as.mo("M. semesiae") 16.010 16.310 25.38 16.480 42.840</span></span>
<span id="cb3-13"><a href="#cb3-13"></a><span class="co"># as.mo("M. semesiae") 13.730 20.960 29.720 21.430 40.000</span></span> <span id="cb3-13"><a href="#cb3-13"></a><span class="co"># as.mo("M. semesiae") 15.700 15.900 16.74 16.370 17.480</span></span>
<span id="cb3-14"><a href="#cb3-14"></a><span class="co"># as.mo("Methanosarcina semesiae") 4.802 5.171 6.667 6.551 8.036</span></span> <span id="cb3-14"><a href="#cb3-14"></a><span class="co"># as.mo("Methanosarcina semesiae") 5.885 6.116 11.79 6.347 8.155</span></span>
<span id="cb3-15"><a href="#cb3-15"></a><span class="co"># max neval</span></span> <span id="cb3-15"><a href="#cb3-15"></a><span class="co"># max neval</span></span>
<span id="cb3-16"><a href="#cb3-16"></a><span class="co"># 2184.000 10</span></span> <span id="cb3-16"><a href="#cb3-16"></a><span class="co"># 1577.00 10</span></span>
<span id="cb3-17"><a href="#cb3-17"></a><span class="co"># 2337.000 10</span></span> <span id="cb3-17"><a href="#cb3-17"></a><span class="co"># 1663.00 10</span></span>
<span id="cb3-18"><a href="#cb3-18"></a><span class="co"># 62.780 10</span></span> <span id="cb3-18"><a href="#cb3-18"></a><span class="co"># 48.53 10</span></span>
<span id="cb3-19"><a href="#cb3-19"></a><span class="co"># 64.510 10</span></span> <span id="cb3-19"><a href="#cb3-19"></a><span class="co"># 18.55 10</span></span>
<span id="cb3-20"><a href="#cb3-20"></a><span class="co"># 8.735 10</span></span></code></pre></div> <span id="cb3-20"><a href="#cb3-20"></a><span class="co"># 32.92 10</span></span></code></pre></div>
<p>That takes 6.1 times as much time on average. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Methanosarcina semesiae</em>) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.</p> <p>That takes 5.5 times as much time on average. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like <em>Methanosarcina semesiae</em>) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.</p>
<p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Methanosarcina semesiae</em> (which is uncommon):</p> <p>In the figure below, we compare <em>Escherichia coli</em> (which is very common) with <em>Prevotella brevis</em> (which is moderately common) and with <em>Methanosarcina semesiae</em> (which is uncommon):</p>
<p><img src="benchmarks_files/figure-html/unnamed-chunk-6-1.png" width="900"></p> <p><img src="benchmarks_files/figure-html/unnamed-chunk-6-1.png" width="900"></p>
<p>Uncommon microorganisms take a lot more time than common microorganisms. To relieve this pitfall and further improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p> <p>Uncommon microorganisms take a lot more time than common microorganisms. To relieve this pitfall and further improve performance, two important calculations take almost no time at all: <strong>repetitive results</strong> and <strong>already precalculated results</strong>.</p>
@ -287,11 +272,11 @@
<span id="cb4-4"><a href="#cb4-4"></a><span class="st"> </span><span class="co"># keep only the unique ones</span></span> <span id="cb4-4"><a href="#cb4-4"></a><span class="st"> </span><span class="co"># keep only the unique ones</span></span>
<span id="cb4-5"><a href="#cb4-5"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/unique.html">unique</a></span>() <span class="op">%&gt;%</span></span> <span id="cb4-5"><a href="#cb4-5"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/unique.html">unique</a></span>() <span class="op">%&gt;%</span></span>
<span id="cb4-6"><a href="#cb4-6"></a><span class="st"> </span><span class="co"># pick 50 of them at random</span></span> <span id="cb4-6"><a href="#cb4-6"></a><span class="st"> </span><span class="co"># pick 50 of them at random</span></span>
<span id="cb4-7"><a href="#cb4-7"></a><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>(<span class="dv">50</span>) <span class="op">%&gt;%</span></span> <span id="cb4-7"><a href="#cb4-7"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>(<span class="dv">50</span>) <span class="op">%&gt;%</span></span>
<span id="cb4-8"><a href="#cb4-8"></a><span class="st"> </span><span class="co"># paste that 10,000 times</span></span> <span id="cb4-8"><a href="#cb4-8"></a><span class="st"> </span><span class="co"># paste that 10,000 times</span></span>
<span id="cb4-9"><a href="#cb4-9"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/rep.html">rep</a></span>(<span class="dv">10000</span>) <span class="op">%&gt;%</span></span> <span id="cb4-9"><a href="#cb4-9"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/rep.html">rep</a></span>(<span class="dv">10000</span>) <span class="op">%&gt;%</span></span>
<span id="cb4-10"><a href="#cb4-10"></a><span class="st"> </span><span class="co"># scramble it</span></span> <span id="cb4-10"><a href="#cb4-10"></a><span class="st"> </span><span class="co"># scramble it</span></span>
<span id="cb4-11"><a href="#cb4-11"></a><span class="st"> </span><span class="kw"><a href="https://dplyr.tidyverse.org/reference/sample.html">sample</a></span>()</span> <span id="cb4-11"><a href="#cb4-11"></a><span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/sample.html">sample</a></span>()</span>
<span id="cb4-12"><a href="#cb4-12"></a> </span> <span id="cb4-12"><a href="#cb4-12"></a> </span>
<span id="cb4-13"><a href="#cb4-13"></a><span class="co"># got indeed 50 times 10,000 = half a million?</span></span> <span id="cb4-13"><a href="#cb4-13"></a><span class="co"># got indeed 50 times 10,000 = half a million?</span></span>
<span id="cb4-14"><a href="#cb4-14"></a><span class="kw"><a href="https://rdrr.io/r/base/length.html">length</a></span>(x)</span> <span id="cb4-14"><a href="#cb4-14"></a><span class="kw"><a href="https://rdrr.io/r/base/length.html">length</a></span>(x)</span>
@ -307,8 +292,8 @@
<span id="cb4-24"><a href="#cb4-24"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span> <span id="cb4-24"><a href="#cb4-24"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span>
<span id="cb4-25"><a href="#cb4-25"></a><span class="co"># Unit: milliseconds</span></span> <span id="cb4-25"><a href="#cb4-25"></a><span class="co"># Unit: milliseconds</span></span>
<span id="cb4-26"><a href="#cb4-26"></a><span class="co"># expr min lq mean median uq max neval</span></span> <span id="cb4-26"><a href="#cb4-26"></a><span class="co"># expr min lq mean median uq max neval</span></span>
<span id="cb4-27"><a href="#cb4-27"></a><span class="co"># mo_name(x) 564 605 673 630 657 1100 100</span></span></code></pre></div> <span id="cb4-27"><a href="#cb4-27"></a><span class="co"># mo_name(x) 542 585 605 601 614 738 100</span></span></code></pre></div>
<p>So transforming 500,000 values (!!) of 50 unique values only takes 0.63 seconds (630 ms). You only lose time on your unique input values.</p> <p>So transforming 500,000 values (!!) of 50 unique values only takes 0.6 seconds (600 ms). You only lose time on your unique input values.</p>
</div> </div>
<div id="precalculated-results" class="section level3"> <div id="precalculated-results" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
@ -321,10 +306,10 @@
<span id="cb5-5"><a href="#cb5-5"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span> <span id="cb5-5"><a href="#cb5-5"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span>
<span id="cb5-6"><a href="#cb5-6"></a><span class="co"># Unit: milliseconds</span></span> <span id="cb5-6"><a href="#cb5-6"></a><span class="co"># Unit: milliseconds</span></span>
<span id="cb5-7"><a href="#cb5-7"></a><span class="co"># expr min lq mean median uq max neval</span></span> <span id="cb5-7"><a href="#cb5-7"></a><span class="co"># expr min lq mean median uq max neval</span></span>
<span id="cb5-8"><a href="#cb5-8"></a><span class="co"># A 6.58 6.590 7.340 6.630 6.780 13.00 10</span></span> <span id="cb5-8"><a href="#cb5-8"></a><span class="co"># A 6.760 6.900 7.43 7.070 7.540 9.290 10</span></span>
<span id="cb5-9"><a href="#cb5-9"></a><span class="co"># B 13.50 13.700 18.700 13.900 14.600 60.80 10</span></span> <span id="cb5-9"><a href="#cb5-9"></a><span class="co"># B 14.200 14.400 18.80 14.900 16.000 51.500 10</span></span>
<span id="cb5-10"><a href="#cb5-10"></a><span class="co"># C 0.72 0.863 0.917 0.898 0.935 1.26 10</span></span></code></pre></div> <span id="cb5-10"><a href="#cb5-10"></a><span class="co"># C 0.586 0.726 0.74 0.757 0.763 0.804 10</span></span></code></pre></div>
<p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0009 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p> <p>So going from <code><a href="../reference/mo_property.html">mo_name("Staphylococcus aureus")</a></code> to <code>"Staphylococcus aureus"</code> takes 0.0008 seconds - it doesnt even start calculating <em>if the result would be the same as the expected resulting value</em>. That goes for all helper functions:</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1"></a>run_it &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</span> <div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1"></a>run_it &lt;-<span class="st"> </span><span class="kw"><a href="https://rdrr.io/pkg/microbenchmark/man/microbenchmark.html">microbenchmark</a></span>(<span class="dt">A =</span> <span class="kw"><a href="../reference/mo_property.html">mo_species</a></span>(<span class="st">"aureus"</span>),</span>
<span id="cb6-2"><a href="#cb6-2"></a> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</span> <span id="cb6-2"><a href="#cb6-2"></a> <span class="dt">B =</span> <span class="kw"><a href="../reference/mo_property.html">mo_genus</a></span>(<span class="st">"Staphylococcus"</span>),</span>
<span id="cb6-3"><a href="#cb6-3"></a> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),</span> <span id="cb6-3"><a href="#cb6-3"></a> <span class="dt">C =</span> <span class="kw"><a href="../reference/mo_property.html">mo_name</a></span>(<span class="st">"Staphylococcus aureus"</span>),</span>
@ -337,14 +322,14 @@
<span id="cb6-10"><a href="#cb6-10"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span> <span id="cb6-10"><a href="#cb6-10"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">3</span>)</span>
<span id="cb6-11"><a href="#cb6-11"></a><span class="co"># Unit: milliseconds</span></span> <span id="cb6-11"><a href="#cb6-11"></a><span class="co"># Unit: milliseconds</span></span>
<span id="cb6-12"><a href="#cb6-12"></a><span class="co"># expr min lq mean median uq max neval</span></span> <span id="cb6-12"><a href="#cb6-12"></a><span class="co"># expr min lq mean median uq max neval</span></span>
<span id="cb6-13"><a href="#cb6-13"></a><span class="co"># A 0.499 0.511 0.516 0.517 0.522 0.544 10</span></span> <span id="cb6-13"><a href="#cb6-13"></a><span class="co"># A 0.374 0.381 0.389 0.389 0.395 0.416 10</span></span>
<span id="cb6-14"><a href="#cb6-14"></a><span class="co"># B 0.532 0.539 0.550 0.542 0.563 0.592 10</span></span> <span id="cb6-14"><a href="#cb6-14"></a><span class="co"># B 0.404 0.411 0.422 0.421 0.425 0.452 10</span></span>
<span id="cb6-15"><a href="#cb6-15"></a><span class="co"># C 0.718 0.787 0.832 0.843 0.889 0.904 10</span></span> <span id="cb6-15"><a href="#cb6-15"></a><span class="co"># C 0.615 0.711 0.726 0.730 0.751 0.861 10</span></span>
<span id="cb6-16"><a href="#cb6-16"></a><span class="co"># D 0.538 0.548 0.566 0.567 0.571 0.607 10</span></span> <span id="cb6-16"><a href="#cb6-16"></a><span class="co"># D 0.405 0.409 0.429 0.428 0.435 0.485 10</span></span>
<span id="cb6-17"><a href="#cb6-17"></a><span class="co"># E 0.503 0.509 0.515 0.513 0.516 0.549 10</span></span> <span id="cb6-17"><a href="#cb6-17"></a><span class="co"># E 0.381 0.384 0.392 0.390 0.394 0.429 10</span></span>
<span id="cb6-18"><a href="#cb6-18"></a><span class="co"># F 0.502 0.504 0.514 0.511 0.519 0.539 10</span></span> <span id="cb6-18"><a href="#cb6-18"></a><span class="co"># F 0.365 0.366 0.379 0.375 0.383 0.419 10</span></span>
<span id="cb6-19"><a href="#cb6-19"></a><span class="co"># G 0.493 0.513 0.538 0.514 0.536 0.684 10</span></span> <span id="cb6-19"><a href="#cb6-19"></a><span class="co"># G 0.362 0.372 0.378 0.380 0.388 0.391 10</span></span>
<span id="cb6-20"><a href="#cb6-20"></a><span class="co"># H 0.499 0.501 0.509 0.505 0.516 0.531 10</span></span></code></pre></div> <span id="cb6-20"><a href="#cb6-20"></a><span class="co"># H 0.378 0.381 0.403 0.387 0.393 0.556 10</span></span></code></pre></div>
<p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> 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.</p> <p>Of course, when running <code><a href="../reference/mo_property.html">mo_phylum("Firmicutes")</a></code> the function has zero knowledge about the actual microorganism, namely <em>S. aureus</em>. But since the result would be <code>"Firmicutes"</code> 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.</p>
</div> </div>
<div id="results-in-other-languages" class="section level3"> <div id="results-in-other-languages" class="section level3">
@ -371,13 +356,13 @@
<span id="cb7-18"><a href="#cb7-18"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</span> <span id="cb7-18"><a href="#cb7-18"></a><span class="kw"><a href="https://rdrr.io/r/base/print.html">print</a></span>(run_it, <span class="dt">unit =</span> <span class="st">"ms"</span>, <span class="dt">signif =</span> <span class="dv">4</span>)</span>
<span id="cb7-19"><a href="#cb7-19"></a><span class="co"># Unit: milliseconds</span></span> <span id="cb7-19"><a href="#cb7-19"></a><span class="co"># Unit: milliseconds</span></span>
<span id="cb7-20"><a href="#cb7-20"></a><span class="co"># expr min lq mean median uq max neval</span></span> <span id="cb7-20"><a href="#cb7-20"></a><span class="co"># expr min lq mean median uq max neval</span></span>
<span id="cb7-21"><a href="#cb7-21"></a><span class="co"># en 23.72 25.30 30.59 25.77 26.99 76.03 100</span></span> <span id="cb7-21"><a href="#cb7-21"></a><span class="co"># en 24.76 26.92 35.44 27.70 31.93 143.10 100</span></span>
<span id="cb7-22"><a href="#cb7-22"></a><span class="co"># de 24.88 26.81 31.11 27.47 28.93 69.86 100</span></span> <span id="cb7-22"><a href="#cb7-22"></a><span class="co"># de 26.46 28.18 33.90 29.51 30.51 64.85 100</span></span>
<span id="cb7-23"><a href="#cb7-23"></a><span class="co"># nl 30.65 32.77 38.07 33.70 35.23 74.79 100</span></span> <span id="cb7-23"><a href="#cb7-23"></a><span class="co"># nl 32.40 34.89 39.79 35.94 37.28 75.95 100</span></span>
<span id="cb7-24"><a href="#cb7-24"></a><span class="co"># es 24.89 26.33 32.10 27.13 28.87 68.79 100</span></span> <span id="cb7-24"><a href="#cb7-24"></a><span class="co"># es 26.41 28.80 34.46 29.56 31.58 67.56 100</span></span>
<span id="cb7-25"><a href="#cb7-25"></a><span class="co"># it 24.78 26.72 33.51 27.53 28.91 166.60 100</span></span> <span id="cb7-25"><a href="#cb7-25"></a><span class="co"># it 26.44 28.52 35.22 29.30 30.37 156.00 100</span></span>
<span id="cb7-26"><a href="#cb7-26"></a><span class="co"># fr 24.84 26.58 31.50 27.13 28.29 67.38 100</span></span> <span id="cb7-26"><a href="#cb7-26"></a><span class="co"># fr 26.24 28.09 34.78 29.52 31.23 65.88 100</span></span>
<span id="cb7-27"><a href="#cb7-27"></a><span class="co"># pt 24.88 26.58 32.38 27.50 29.20 79.30 100</span></span></code></pre></div> <span id="cb7-27"><a href="#cb7-27"></a><span class="co"># pt 26.28 28.32 36.00 29.49 32.22 66.76 100</span></span></code></pre></div>
<p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p> <p>Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.</p>
</div> </div>
</div> </div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -43,7 +43,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a> <a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9002</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -204,8 +204,8 @@ A methods paper about this package has been preprinted at bioRxiv (DOI: 10.1101/
<div class="main-content"> <div class="main-content">
<p> <p>
<a href="./countries_large.png" target="_blank"><img src="./countries.png" class="countries_map"></a> <a href="./countries_large.png" target="_blank"><img src="./countries.png" class="countries_map"></a>
<strong>Used in almost 100 countries</strong><br> <strong>Used in more than 100 countries</strong><br>
Since its first public release in early 2018, this package has been downloaded over 25,000 times from 99 countries <small>(as of February 2020, <a href="https://cran-logs.rstudio.com" target="_blank">CRAN logs</a>)</small>. Click the map to enlarge.</p> Since its first public release in early 2018, this package has been downloaded from more than 100 countries <small>(as of March 2020, <a href="https://cran-logs.rstudio.com" target="_blank">CRAN logs</a>)</small>. Click the map to enlarge, to see the names of the countries.</p>
<br><br> <br><br>
</div> </div>
<div id="partners" class="section level4"> <div id="partners" class="section level4">
@ -240,6 +240,7 @@ A methods paper about this package has been preprinted at bioRxiv (DOI: 10.1101/
<li>Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code (<a href="./reference/mo_property.html">manual</a>)</li> <li>Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code (<a href="./reference/mo_property.html">manual</a>)</li>
<li>Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code (<a href="./reference/ab_property.html">manual</a>)</li> <li>Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code (<a href="./reference/ab_property.html">manual</a>)</li>
<li>Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI (<a href="https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt">link</a>)</li> <li>Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI (<a href="https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt">link</a>)</li>
<li>Principal component analysis for AMR (<a href="./articles/PCA.html">tutorial</a>)</li>
</ul> </ul>
<p>This package is ready-to-use for specialists in many fields:</p> <p>This package is ready-to-use for specialists in many fields:</p>
<ul> <ul>
@ -272,8 +273,8 @@ A methods paper about this package has been preprinted at bioRxiv (DOI: 10.1101/
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#latest-development-version" class="anchor"></a>Latest development version</h4> <a href="#latest-development-version" class="anchor"></a>Latest development version</h4>
<p>The latest and unpublished development version can be installed with (<strong>precaution: may be unstable</strong>):</p> <p>The latest and unpublished development version can be installed with (<strong>precaution: may be unstable</strong>):</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a><span class="kw"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"devtools"</span>)</span> <div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1"></a><span class="kw"><a href="https://rdrr.io/r/utils/install.packages.html">install.packages</a></span>(<span class="st">"remotes"</span>)</span>
<span id="cb2-2"><a href="#cb2-2"></a>devtools<span class="op">::</span><span class="kw"><a href="https://devtools.r-lib.org//reference/remote-reexports.html">install_gitlab</a></span>(<span class="st">"msberends/AMR"</span>)</span></code></pre></div> <span id="cb2-2"><a href="#cb2-2"></a>remotes<span class="op">::</span><span class="kw"><a href="https://remotes.r-lib.org/reference/install_gitlab.html">install_gitlab</a></span>(<span class="st">"msberends/AMR"</span>)</span></code></pre></div>
</div> </div>
</div> </div>
<div id="get-started" class="section level3"> <div id="get-started" class="section level3">

View File

@ -78,7 +78,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9002</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -226,13 +226,13 @@
</div> </div>
<div id="amr-1019002" class="section level1"> <div id="amr-1019004" class="section level1">
<h1 class="page-header"> <h1 class="page-header">
<a href="#amr-1019002" class="anchor"></a>AMR 1.0.1.9002<small> Unreleased </small> <a href="#amr-1019004" class="anchor"></a>AMR 1.0.1.9004<small> Unreleased </small>
</h1> </h1>
<div id="last-updated-08-mar-2020" class="section level2"> <div id="last-updated-14-mar-2020" class="section level2">
<h2 class="hasAnchor"> <h2 class="hasAnchor">
<a href="#last-updated-08-mar-2020" class="anchor"></a><small>Last updated: 08-Mar-2020</small> <a href="#last-updated-14-mar-2020" class="anchor"></a><small>Last updated: 14-Mar-2020</small>
</h2> </h2>
<div id="new" class="section level3"> <div id="new" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
@ -242,6 +242,13 @@
<li>Plotting biplots for principal component analysis using the new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function</li> <li>Plotting biplots for principal component analysis using the new <code><a href="../reference/ggplot_pca.html">ggplot_pca()</a></code> function</li>
</ul> </ul>
</div> </div>
<div id="other" class="section level3">
<h3 class="hasAnchor">
<a href="#other" class="anchor"></a>Other</h3>
<ul>
<li>Support for the upcoming <code>dplyr</code> version 1.0.0</li>
</ul>
</div>
</div> </div>
</div> </div>
<div id="amr-101" class="section level1"> <div id="amr-101" class="section level1">
@ -332,9 +339,9 @@
</li> </li>
</ul> </ul>
</div> </div>
<div id="other" class="section level3"> <div id="other-1" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
<a href="#other" class="anchor"></a>Other</h3> <a href="#other-1" class="anchor"></a>Other</h3>
<ul> <ul>
<li>Add a <code>CITATION</code> file</li> <li>Add a <code>CITATION</code> file</li>
<li>Full support for the upcoming R 4.0</li> <li>Full support for the upcoming R 4.0</li>
@ -432,9 +439,9 @@
</li> </li>
</ul> </ul>
</div> </div>
<div id="other-1" class="section level3"> <div id="other-2" class="section level3">
<h3 class="hasAnchor"> <h3 class="hasAnchor">
<a href="#other-1" class="anchor"></a>Other</h3> <a href="#other-2" class="anchor"></a>Other</h3>
<ul> <ul>
<li>Rewrote the complete documentation to markdown format, to be able to use the very latest version of the great <a href="https://roxygen2.r-lib.org/index.html">Roxygen2</a>, released in November 2019. This tremously improved the documentation quality, since the rewrite forced us to go over all texts again and make changes where needed.</li> <li>Rewrote the complete documentation to markdown format, to be able to use the very latest version of the great <a href="https://roxygen2.r-lib.org/index.html">Roxygen2</a>, released in November 2019. This tremously improved the documentation quality, since the rewrite forced us to go over all texts again and make changes where needed.</li>
<li>Change dependency on <code>clean</code> to <code>cleaner</code>, as this package was renamed accordingly upon CRAN request</li> <li>Change dependency on <code>clean</code> to <code>cleaner</code>, as this package was renamed accordingly upon CRAN request</li>
@ -586,9 +593,9 @@
</li> </li>
<li>Added more MIC factor levels (<code><a href="../reference/as.mic.html">as.mic()</a></code>)</li> <li>Added more MIC factor levels (<code><a href="../reference/as.mic.html">as.mic()</a></code>)</li>
</ul> </ul>
<div id="other-2" class="section level4"> <div id="other-3" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-2" class="anchor"></a>Other</h4> <a href="#other-3" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors</li> <li>Added Prof. Dr. Casper Albers as doctoral advisor and added Dr. Judith Fonville, Eric Hazenberg, Dr. Bart Meijer, Dr. Dennis Souverein and Annick Lenglet as contributors</li>
<li>Cleaned the coding style of every single syntax line in this package with the help of the <code>lintr</code> package</li> <li>Cleaned the coding style of every single syntax line in this package with the help of the <code>lintr</code> package</li>
@ -669,9 +676,9 @@
</li> </li>
</ul> </ul>
</div> </div>
<div id="other-3" class="section level4"> <div id="other-4" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-3" class="anchor"></a>Other</h4> <a href="#other-4" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Fixed a note thrown by CRAN tests</li> <li>Fixed a note thrown by CRAN tests</li>
</ul> </ul>
@ -765,9 +772,9 @@
<li><p>Fix for <code><a href="../reference/mo_property.html">mo_shortname()</a></code> where species would not be determined correctly</p></li> <li><p>Fix for <code><a href="../reference/mo_property.html">mo_shortname()</a></code> where species would not be determined correctly</p></li>
</ul> </ul>
</div> </div>
<div id="other-4" class="section level4"> <div id="other-5" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-4" class="anchor"></a>Other</h4> <a href="#other-5" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Support for R 3.6.0 and later by providing support for <a href="https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html">staged install</a> <li>Support for R 3.6.0 and later by providing support for <a href="https://developer.r-project.org/Blog/public/2019/02/14/staged-install/index.html">staged install</a>
</li> </li>
@ -1012,9 +1019,9 @@
<li>if using different lengths of pattern and x in <code><a href="../reference/like.html">%like%</a></code>, it will now return the call</li> <li>if using different lengths of pattern and x in <code><a href="../reference/like.html">%like%</a></code>, it will now return the call</li>
</ul> </ul>
</div> </div>
<div id="other-5" class="section level4"> <div id="other-6" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-5" class="anchor"></a>Other</h4> <a href="#other-6" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Updated licence text to emphasise GPL 2.0 and that this is an R package.</li> <li>Updated licence text to emphasise GPL 2.0 and that this is an R package.</li>
</ul> </ul>
@ -1129,9 +1136,9 @@
<li><p>Percentages will now will rounded more logically (e.g. in <code>freq</code> function)</p></li> <li><p>Percentages will now will rounded more logically (e.g. in <code>freq</code> function)</p></li>
</ul> </ul>
</div> </div>
<div id="other-6" class="section level4"> <div id="other-7" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-6" class="anchor"></a>Other</h4> <a href="#other-7" class="anchor"></a>Other</h4>
<ul> <ul>
<li>New dependency on package <code>crayon</code>, to support formatted text in the console</li> <li>New dependency on package <code>crayon</code>, to support formatted text in the console</li>
<li>Dependency <code>tidyr</code> is now mandatory (went to <code>Import</code> field) since <code>portion_df</code> and <code>count_df</code> rely on it</li> <li>Dependency <code>tidyr</code> is now mandatory (went to <code>Import</code> field) since <code>portion_df</code> and <code>count_df</code> rely on it</li>
@ -1264,9 +1271,9 @@
</li> </li>
</ul> </ul>
</div> </div>
<div id="other-7" class="section level4"> <div id="other-8" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-7" class="anchor"></a>Other</h4> <a href="#other-8" class="anchor"></a>Other</h4>
<ul> <ul>
<li>More unit tests to ensure better integrity of functions</li> <li>More unit tests to ensure better integrity of functions</li>
</ul> </ul>
@ -1393,9 +1400,9 @@
<li>Other small fixes</li> <li>Other small fixes</li>
</ul> </ul>
</div> </div>
<div id="other-8" class="section level4"> <div id="other-9" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-8" class="anchor"></a>Other</h4> <a href="#other-9" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher <li>Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher
<ul> <ul>
@ -1455,9 +1462,9 @@
<li>Functions <code>as.rsi</code> and <code>as.mic</code> now add the package name and version as attributes</li> <li>Functions <code>as.rsi</code> and <code>as.mic</code> now add the package name and version as attributes</li>
</ul> </ul>
</div> </div>
<div id="other-9" class="section level4"> <div id="other-10" class="section level4">
<h4 class="hasAnchor"> <h4 class="hasAnchor">
<a href="#other-9" class="anchor"></a>Other</h4> <a href="#other-10" class="anchor"></a>Other</h4>
<ul> <ul>
<li>Expanded <code>README.md</code> with more examples</li> <li>Expanded <code>README.md</code> with more examples</li>
<li>Added <a href="https://orcid.org">ORCID</a> of authors to DESCRIPTION file</li> <li>Added <a href="https://orcid.org">ORCID</a> of authors to DESCRIPTION file</li>
@ -1494,7 +1501,7 @@
<div id="tocnav"> <div id="tocnav">
<h2>Contents</h2> <h2>Contents</h2>
<ul class="nav nav-pills nav-stacked"> <ul class="nav nav-pills nav-stacked">
<li><a href="#amr-1019002">1.0.1.9002</a></li> <li><a href="#amr-1019004">1.0.1.9004</a></li>
<li><a href="#amr-101">1.0.1</a></li> <li><a href="#amr-101">1.0.1</a></li>
<li><a href="#amr-100">1.0.0</a></li> <li><a href="#amr-100">1.0.0</a></li>
<li><a href="#amr-090">0.9.0</a></li> <li><a href="#amr-090">0.9.0</a></li>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -245,6 +252,7 @@
<li><p>Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code</p></li> <li><p>Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code</p></li>
<li><p>Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code</p></li> <li><p>Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code</p></li>
<li><p>Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI</p></li> <li><p>Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI</p></li>
<li><p>Principal component analysis for AMR</p></li>
</ul> </ul>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2> <h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -258,6 +265,7 @@
<li><p><code>Date of data entry</code><br /> Date this data was entered in WHONET</p></li> <li><p><code>Date of data entry</code><br /> Date this data was entered in WHONET</p></li>
<li><p><code>AMP_ND10:CIP_EE</code><br /> 27 different antibiotics. You can lookup the abbreviatons in the <a href='antibiotics.html'>antibiotics</a> data set, or use e.g. <code><a href='ab_property.html'>ab_name("AMP")</a></code> to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using <code><a href='as.rsi.html'>as.rsi()</a></code>.</p></li> <li><p><code>AMP_ND10:CIP_EE</code><br /> 27 different antibiotics. You can lookup the abbreviatons in the <a href='antibiotics.html'>antibiotics</a> data set, or use e.g. <code><a href='ab_property.html'>ab_name("AMP")</a></code> to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using <code><a href='as.rsi.html'>as.rsi()</a></code>.</p></li>
</ul> </ul>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2> <h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9000</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -117,9 +117,9 @@
</li> </li>
<li> <li>
<a href="../articles/PCA.html"> <a href="../articles/PCA.html">
<span class="fa fa-compress-alt"></span> <span class="fa fa-compress"></span>
Conduct Principal Component Analysis for AMR Conduct principal component analysis for AMR
</a> </a>
</li> </li>
<li> <li>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9000</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -117,9 +117,9 @@
</li> </li>
<li> <li>
<a href="../articles/PCA.html"> <a href="../articles/PCA.html">
<span class="fa fa-compress-alt"></span> <span class="fa fa-compress"></span>
Conduct Principal Component Analysis for AMR Conduct principal component analysis for AMR
</a> </a>
</li> </li>
<li> <li>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -232,6 +239,7 @@
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2> <h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
<h3>For the antibiotics data set: a <code><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></code> with 452 observations and 14 variables:</h3> <h3>For the antibiotics data set: a <code><a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a></code> with 452 observations and 14 variables:</h3>
<ul> <ul>
@ -266,6 +274,8 @@
<li><p><code>iv_units</code><br /> Units of <code>iv_ddd</code></p></li> <li><p><code>iv_units</code><br /> Units of <code>iv_ddd</code></p></li>
</ul> </ul>
<p>An object of class <code>data.frame</code> with 102 rows and 9 columns.</p>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2> <h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p>World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): <a href='https://www.whocc.no/atc_ddd_index/'>https://www.whocc.no/atc_ddd_index/</a></p> <p>World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): <a href='https://www.whocc.no/atc_ddd_index/'>https://www.whocc.no/atc_ddd_index/</a></p>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -242,6 +249,7 @@
<li><p><code>mo</code><br /> ID of microorganism created with <code><a href='as.mo.html'>as.mo()</a></code>, see also <a href='microorganisms.html'>microorganisms</a></p></li> <li><p><code>mo</code><br /> ID of microorganism created with <code><a href='as.mo.html'>as.mo()</a></code>, see also <a href='microorganisms.html'>microorganisms</a></p></li>
<li><p><code>PEN:RIF</code><br /> 40 different antibiotics with class <code><a href='as.rsi.html'>rsi</a></code> (see <code><a href='as.rsi.html'>as.rsi()</a></code>); these column names occur in the <a href='antibiotics.html'>antibiotics</a> data set and can be translated with <code><a href='ab_property.html'>ab_name()</a></code></p></li> <li><p><code>PEN:RIF</code><br /> 40 different antibiotics with class <code><a href='as.rsi.html'>rsi</a></code> (see <code><a href='as.rsi.html'>as.rsi()</a></code>); these column names occur in the <a href='antibiotics.html'>antibiotics</a> data set and can be translated with <code><a href='ab_property.html'>ab_name()</a></code></p></li>
</ul> </ul>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2> <h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -237,6 +244,7 @@
<li><p><code>bacteria</code><br /> info about microorganism that can be transformed with <code><a href='as.mo.html'>as.mo()</a></code>, see also <a href='microorganisms.html'>microorganisms</a></p></li> <li><p><code>bacteria</code><br /> info about microorganism that can be transformed with <code><a href='as.mo.html'>as.mo()</a></code>, see also <a href='microorganisms.html'>microorganisms</a></p></li>
<li><p><code>AMX:GEN</code><br /> 4 different antibiotics that have to be transformed with <code><a href='as.rsi.html'>as.rsi()</a></code></p></li> <li><p><code>AMX:GEN</code><br /> 4 different antibiotics that have to be transformed with <code><a href='as.rsi.html'>as.rsi()</a></code></p></li>
</ul> </ul>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2> <h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>

View File

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

View File

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

View File

@ -81,7 +81,7 @@ This page contains a section for every lifecycle (with text borrowed from the af
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9000</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -119,9 +119,9 @@ This page contains a section for every lifecycle (with text borrowed from the af
</li> </li>
<li> <li>
<a href="../articles/PCA.html"> <a href="../articles/PCA.html">
<span class="fa fa-compress-alt"></span> <span class="fa fa-compress"></span>
Conduct Principal Component Analysis for AMR Conduct principal component analysis for AMR
</a> </a>
</li> </li>
<li> <li>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -234,6 +241,7 @@
<li><p><code>code</code><br /> Commonly used code of a microorganism</p></li> <li><p><code>code</code><br /> Commonly used code of a microorganism</p></li>
<li><p><code>mo</code><br /> ID of the microorganism in the <a href='microorganisms.html'>microorganisms</a> data set</p></li> <li><p><code>mo</code><br /> ID of the microorganism in the <a href='microorganisms.html'>microorganisms</a> data set</p></li>
</ul> </ul>
<h2 class="hasAnchor" id="catalogue-of-life"><a class="anchor" href="#catalogue-of-life"></a>Catalogue of Life</h2> <h2 class="hasAnchor" id="catalogue-of-life"><a class="anchor" href="#catalogue-of-life"></a>Catalogue of Life</h2>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -242,6 +249,7 @@
<li><p><code>prevalence</code><br /> Prevalence of the microorganism, see <code><a href='as.mo.html'>as.mo()</a></code></p></li> <li><p><code>prevalence</code><br /> Prevalence of the microorganism, see <code><a href='as.mo.html'>as.mo()</a></code></p></li>
<li><p><code>snomed</code><br /> SNOMED code of the microorganism. Use <code><a href='mo_property.html'>mo_snomed()</a></code> to retrieve it quickly, see <code><a href='mo_property.html'>mo_property()</a></code>.</p></li> <li><p><code>snomed</code><br /> SNOMED code of the microorganism. Use <code><a href='mo_property.html'>mo_snomed()</a></code> to retrieve it quickly, see <code><a href='mo_property.html'>mo_property()</a></code>.</p></li>
</ul> </ul>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2> <h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p>Catalogue of Life: Annual Checklist (public online taxonomic database), <a href='http://www.catalogueoflife.org'>http://www.catalogueoflife.org</a> (check included annual version with <code><a href='catalogue_of_life_version.html'>catalogue_of_life_version()</a></code>).</p> <p>Catalogue of Life: Annual Checklist (public online taxonomic database), <a href='http://www.catalogueoflife.org'>http://www.catalogueoflife.org</a> (check included annual version with <code><a href='catalogue_of_life_version.html'>catalogue_of_life_version()</a></code>).</p>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -237,6 +244,7 @@
<li><p><code>ref</code><br /> Author(s) and year of concerning scientific publication</p></li> <li><p><code>ref</code><br /> Author(s) and year of concerning scientific publication</p></li>
<li><p><code>prevalence</code><br /> Prevalence of the microorganism, see <code><a href='as.mo.html'>as.mo()</a></code></p></li> <li><p><code>prevalence</code><br /> Prevalence of the microorganism, see <code><a href='as.mo.html'>as.mo()</a></code></p></li>
</ul> </ul>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2> <h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p>Catalogue of Life: Annual Checklist (public online taxonomic database), <a href='http://www.catalogueoflife.org'>http://www.catalogueoflife.org</a> (check included annual version with <code><a href='catalogue_of_life_version.html'>catalogue_of_life_version()</a></code>).</p> <p>Catalogue of Life: Annual Checklist (public online taxonomic database), <a href='http://www.catalogueoflife.org'>http://www.catalogueoflife.org</a> (check included annual version with <code><a href='catalogue_of_life_version.html'>catalogue_of_life_version()</a></code>).</p>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9002</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -301,12 +301,12 @@
<p>The <code>pca()</code> function takes a <a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a> as input and performs the actual PCA with the <span style="R">R</span> function <code><a href='https://rdrr.io/r/stats/prcomp.html'>prcomp()</a></code>.</p> <p>The <code>pca()</code> function takes a <a href='https://rdrr.io/r/base/data.frame.html'>data.frame</a> as input and performs the actual PCA with the <span style="R">R</span> function <code><a href='https://rdrr.io/r/stats/prcomp.html'>prcomp()</a></code>.</p>
<p>The result of the <code>pca()</code> function is a <a href='https://rdrr.io/r/stats/prcomp.html'>prcomp</a> object, with an additional attribute <code>non_numeric_cols</code> which is a vector with the column names of all columns that do not contain numeric values. These are probably the groups and labels, and will be used by <code><a href='ggplot_pca.html'>ggplot_pca()</a></code>.</p> <p>The result of the <code>pca()</code> function is a <a href='https://rdrr.io/r/stats/prcomp.html'>prcomp</a> object, with an additional attribute <code>non_numeric_cols</code> which is a vector with the column names of all columns that do not contain numeric values. These are probably the groups and labels, and will be used by <code><a href='ggplot_pca.html'>ggplot_pca()</a></code>.</p>
<h2 class="hasAnchor" id="experimental-lifecycle"><a class="anchor" href="#experimental-lifecycle"></a>Experimental lifecycle</h2> <h2 class="hasAnchor" id="maturing-lifecycle"><a class="anchor" href="#maturing-lifecycle"></a>Maturing lifecycle</h2>
<p><img src='figures/lifecycle_experimental.svg' style=margin-bottom:5px /> <br /> <p><img src='figures/lifecycle_maturing.svg' style=margin-bottom:5px /> <br />
The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>experimental</strong>. An experimental function is in the very early stages of development. The unlying code might be changing frequently as we rapidly iterate and explore variations in search of the best fit. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions will not be included in releases we submit to CRAN, since they have not yet matured enough.</p> The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>maturing</strong>. The unlying code of a maturing function has been roughed out, but finer details might still change. We will strive to maintain backward compatibility, but the function needs wider usage and more extensive testing in order to optimise the unlying code.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span> <pre class="examples"><span class='co'># `example_isolates` is a dataset available in the AMR package.</span>
@ -334,7 +334,7 @@ The <a href='lifecycle.html'>lifecycle</a> of this function is <strong>experimen
<li><a href="#arguments">Arguments</a></li> <li><a href="#arguments">Arguments</a></li>
<li><a href="#value">Value</a></li> <li><a href="#value">Value</a></li>
<li><a href="#details">Details</a></li> <li><a href="#details">Details</a></li>
<li><a href="#experimental-lifecycle">Experimental lifecycle</a></li> <li><a href="#maturing-lifecycle">Maturing lifecycle</a></li>
<li><a href="#examples">Examples</a></li> <li><a href="#examples">Examples</a></li>
</ul> </ul>

View File

@ -79,7 +79,7 @@
</button> </button>
<span class="navbar-brand"> <span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a> <a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1</span> <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Latest development version">1.0.1.9004</span>
</span> </span>
</div> </div>
@ -115,6 +115,13 @@
Predict antimicrobial resistance Predict antimicrobial resistance
</a> </a>
</li> </li>
<li>
<a href="../articles/PCA.html">
<span class="fa fa-compress"></span>
Conduct principal component analysis for AMR
</a>
</li>
<li> <li>
<a href="../articles/MDR.html"> <a href="../articles/MDR.html">
<span class="fa fa-skull-crossbones"></span> <span class="fa fa-skull-crossbones"></span>
@ -241,6 +248,7 @@
<li><p><code>breakpoint_S</code><br /> Lowest MIC value or highest number of millimetres that leads to "S"</p></li> <li><p><code>breakpoint_S</code><br /> Lowest MIC value or highest number of millimetres that leads to "S"</p></li>
<li><p><code>breakpoint_R</code><br /> Highest MIC value or lowest number of millimetres that leads to "R"</p></li> <li><p><code>breakpoint_R</code><br /> Highest MIC value or lowest number of millimetres that leads to "R"</p></li>
</ul> </ul>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2> <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>The repository of this <code>AMR</code> package contains a file comprising this exact data set: <a href='https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt'>https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt</a>. This file <strong>allows for machine reading EUCAST and CLSI guidelines</strong>, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file is updated automatically.</p> <p>The repository of this <code>AMR</code> package contains a file comprising this exact data set: <a href='https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt'>https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt</a>. This file <strong>allows for machine reading EUCAST and CLSI guidelines</strong>, which is almost impossible with the Excel and PDF files distributed by EUCAST and CLSI. This file is updated automatically.</p>

View File

@ -17,8 +17,8 @@ We created this package for both routine data analysis and academic research (as
<div class="main-content"> <div class="main-content">
<p> <p>
<a href="./countries_large.png" target="_blank"><img src="./countries.png" class="countries_map"></a> <a href="./countries_large.png" target="_blank"><img src="./countries.png" class="countries_map"></a>
<strong>Used in almost 100 countries</strong><br> <strong>Used in more than 100 countries</strong><br>
Since its first public release in early 2018, this package has been downloaded over 25,000 times from 99 countries <small>(as of February 2020, <a href="https://cran-logs.rstudio.com" target="_blank">CRAN logs</a>)</small>. Click the map to enlarge.</p><br><br> Since its first public release in early 2018, this package has been downloaded from more than 100 countries <small>(as of March 2020, <a href="https://cran-logs.rstudio.com" target="_blank">CRAN logs</a>)</small>. Click the map to enlarge, to see the names of the countries.</p><br><br>
</div> </div>
#### Partners #### Partners
@ -51,6 +51,7 @@ This package can be used for:
* Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code ([manual](./reference/mo_property.html)) * Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code ([manual](./reference/mo_property.html))
* Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code ([manual](./reference/ab_property.html)) * Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code ([manual](./reference/ab_property.html))
* Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI ([link](https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt)) * Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI ([link](https://gitlab.com/msberends/AMR/blob/master/data-raw/rsi_translation.txt))
* Principal component analysis for AMR ([tutorial](./articles/PCA.html))
This package is ready-to-use for specialists in many fields: This package is ready-to-use for specialists in many fields:
@ -85,8 +86,8 @@ It will be downloaded and installed automatically. For RStudio, click on the men
The latest and unpublished development version can be installed with (**precaution: may be unstable**): The latest and unpublished development version can be installed with (**precaution: may be unstable**):
```r ```r
install.packages("devtools") install.packages("remotes")
devtools::install_gitlab("msberends/AMR") remotes::install_gitlab("msberends/AMR")
``` ```
### Get started ### Get started

View File

@ -26,6 +26,7 @@ This package can be used for:
\item Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code \item Getting SNOMED codes of a microorganism, or get its name associated with a SNOMED code
\item Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code \item Getting LOINC codes of an antibiotic, or get its name associated with a LOINC code
\item Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI \item Machine reading the EUCAST and CLSI guidelines from 2011-2020 to translate MIC values and disk diffusion diameters to R/SI
\item Principal component analysis for AMR
} }
} }
\section{Read more on our website!}{ \section{Read more on our website!}{

View File

@ -4,7 +4,8 @@
\name{WHONET} \name{WHONET}
\alias{WHONET} \alias{WHONET}
\title{Data set with 500 isolates - WHONET example} \title{Data set with 500 isolates - WHONET example}
\format{A \code{\link{data.frame}} with 500 observations and 53 variables: \format{
A \code{\link{data.frame}} with 500 observations and 53 variables:
\itemize{ \itemize{
\item \verb{Identification number}\cr ID of the sample \item \verb{Identification number}\cr ID of the sample
\item \verb{Specimen number}\cr ID of the specimen \item \verb{Specimen number}\cr ID of the specimen
@ -32,7 +33,8 @@
\item \code{Comment}\cr Other comments \item \code{Comment}\cr Other comments
\item \verb{Date of data entry}\cr Date this data was entered in WHONET \item \verb{Date of data entry}\cr Date this data was entered in WHONET
\item \code{AMP_ND10:CIP_EE}\cr 27 different antibiotics. You can lookup the abbreviatons in the \link{antibiotics} data set, or use e.g. \code{\link[=ab_name]{ab_name("AMP")}} to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using \code{\link[=as.rsi]{as.rsi()}}. \item \code{AMP_ND10:CIP_EE}\cr 27 different antibiotics. You can lookup the abbreviatons in the \link{antibiotics} data set, or use e.g. \code{\link[=ab_name]{ab_name("AMP")}} to get the official name immediately. Before analysis, you should transform this to a valid antibiotic class, using \code{\link[=as.rsi]{as.rsi()}}.
}} }
}
\usage{ \usage{
WHONET WHONET
} }

View File

@ -5,7 +5,8 @@
\alias{antibiotics} \alias{antibiotics}
\alias{antivirals} \alias{antivirals}
\title{Data sets with ~550 antimicrobials} \title{Data sets with ~550 antimicrobials}
\format{\subsection{For the \link{antibiotics} data set: a \code{\link{data.frame}} with 452 observations and 14 variables:}{ \format{
\subsection{For the \link{antibiotics} data set: a \code{\link{data.frame}} with 452 observations and 14 variables:}{
\itemize{ \itemize{
\item \code{ab}\cr Antibiotic ID as used in this package (like \code{AMC}), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available \item \code{ab}\cr Antibiotic ID as used in this package (like \code{AMC}), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available
\item \code{atc}\cr ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC, like \code{J01CR02} \item \code{atc}\cr ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC, like \code{J01CR02}
@ -36,7 +37,10 @@
\item \code{iv_ddd}\cr Defined Daily Dose (DDD), parenteral treatment \item \code{iv_ddd}\cr Defined Daily Dose (DDD), parenteral treatment
\item \code{iv_units}\cr Units of \code{iv_ddd} \item \code{iv_units}\cr Units of \code{iv_ddd}
} }
}} }
An object of class \code{data.frame} with 102 rows and 9 columns.
}
\source{ \source{
World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): \url{https://www.whocc.no/atc_ddd_index/} World Health Organization (WHO) Collaborating Centre for Drug Statistics Methodology (WHOCC): \url{https://www.whocc.no/atc_ddd_index/}

View File

@ -4,7 +4,8 @@
\name{example_isolates} \name{example_isolates}
\alias{example_isolates} \alias{example_isolates}
\title{Data set with 2,000 example isolates} \title{Data set with 2,000 example isolates}
\format{A \code{\link{data.frame}} with 2,000 observations and 49 variables: \format{
A \code{\link{data.frame}} with 2,000 observations and 49 variables:
\itemize{ \itemize{
\item \code{date}\cr date of receipt at the laboratory \item \code{date}\cr date of receipt at the laboratory
\item \code{hospital_id}\cr ID of the hospital, from A to D \item \code{hospital_id}\cr ID of the hospital, from A to D
@ -16,7 +17,8 @@
\item \code{patient_id}\cr ID of the patient \item \code{patient_id}\cr ID of the patient
\item \code{mo}\cr ID of microorganism created with \code{\link[=as.mo]{as.mo()}}, see also \link{microorganisms} \item \code{mo}\cr ID of microorganism created with \code{\link[=as.mo]{as.mo()}}, see also \link{microorganisms}
\item \code{PEN:RIF}\cr 40 different antibiotics with class \code{\link{rsi}} (see \code{\link[=as.rsi]{as.rsi()}}); these column names occur in the \link{antibiotics} data set and can be translated with \code{\link[=ab_name]{ab_name()}} \item \code{PEN:RIF}\cr 40 different antibiotics with class \code{\link{rsi}} (see \code{\link[=as.rsi]{as.rsi()}}); these column names occur in the \link{antibiotics} data set and can be translated with \code{\link[=ab_name]{ab_name()}}
}} }
}
\usage{ \usage{
example_isolates example_isolates
} }

View File

@ -4,14 +4,16 @@
\name{example_isolates_unclean} \name{example_isolates_unclean}
\alias{example_isolates_unclean} \alias{example_isolates_unclean}
\title{Data set with unclean data} \title{Data set with unclean data}
\format{A \code{\link{data.frame}} with 3,000 observations and 8 variables: \format{
A \code{\link{data.frame}} with 3,000 observations and 8 variables:
\itemize{ \itemize{
\item \code{patient_id}\cr ID of the patient \item \code{patient_id}\cr ID of the patient
\item \code{date}\cr date of receipt at the laboratory \item \code{date}\cr date of receipt at the laboratory
\item \code{hospital}\cr ID of the hospital, from A to C \item \code{hospital}\cr ID of the hospital, from A to C
\item \code{bacteria}\cr info about microorganism that can be transformed with \code{\link[=as.mo]{as.mo()}}, see also \link{microorganisms} \item \code{bacteria}\cr info about microorganism that can be transformed with \code{\link[=as.mo]{as.mo()}}, see also \link{microorganisms}
\item \code{AMX:GEN}\cr 4 different antibiotics that have to be transformed with \code{\link[=as.rsi]{as.rsi()}} \item \code{AMX:GEN}\cr 4 different antibiotics that have to be transformed with \code{\link[=as.rsi]{as.rsi()}}
}} }
}
\usage{ \usage{
example_isolates_unclean example_isolates_unclean
} }

View File

@ -4,7 +4,8 @@
\name{microorganisms} \name{microorganisms}
\alias{microorganisms} \alias{microorganisms}
\title{Data set with ~70,000 microorganisms} \title{Data set with ~70,000 microorganisms}
\format{A \code{\link{data.frame}} with 69,447 observations and 17 variables: \format{
A \code{\link{data.frame}} with 69,447 observations and 17 variables:
\itemize{ \itemize{
\item \code{mo}\cr ID of microorganism as used by this package \item \code{mo}\cr ID of microorganism as used by this package
\item \code{col_id}\cr Catalogue of Life ID \item \code{col_id}\cr Catalogue of Life ID
@ -16,7 +17,8 @@
\item \code{source}\cr Either "CoL", "DSMZ" (see Source) or "manually added" \item \code{source}\cr Either "CoL", "DSMZ" (see Source) or "manually added"
\item \code{prevalence}\cr Prevalence of the microorganism, see \code{\link[=as.mo]{as.mo()}} \item \code{prevalence}\cr Prevalence of the microorganism, see \code{\link[=as.mo]{as.mo()}}
\item \code{snomed}\cr SNOMED code of the microorganism. Use \code{\link[=mo_snomed]{mo_snomed()}} to retrieve it quickly, see \code{\link[=mo_property]{mo_property()}}. \item \code{snomed}\cr SNOMED code of the microorganism. Use \code{\link[=mo_snomed]{mo_snomed()}} to retrieve it quickly, see \code{\link[=mo_property]{mo_property()}}.
}} }
}
\source{ \source{
Catalogue of Life: Annual Checklist (public online taxonomic database), \url{http://www.catalogueoflife.org} (check included annual version with \code{\link[=catalogue_of_life_version]{catalogue_of_life_version()}}). Catalogue of Life: Annual Checklist (public online taxonomic database), \url{http://www.catalogueoflife.org} (check included annual version with \code{\link[=catalogue_of_life_version]{catalogue_of_life_version()}}).

View File

@ -4,11 +4,13 @@
\name{microorganisms.codes} \name{microorganisms.codes}
\alias{microorganisms.codes} \alias{microorganisms.codes}
\title{Translation table for common microorganism codes} \title{Translation table for common microorganism codes}
\format{A \code{\link{data.frame}} with 5,450 observations and 2 variables: \format{
A \code{\link{data.frame}} with 5,450 observations and 2 variables:
\itemize{ \itemize{
\item \code{code}\cr Commonly used code of a microorganism \item \code{code}\cr Commonly used code of a microorganism
\item \code{mo}\cr ID of the microorganism in the \link{microorganisms} data set \item \code{mo}\cr ID of the microorganism in the \link{microorganisms} data set
}} }
}
\usage{ \usage{
microorganisms.codes microorganisms.codes
} }

View File

@ -4,14 +4,16 @@
\name{microorganisms.old} \name{microorganisms.old}
\alias{microorganisms.old} \alias{microorganisms.old}
\title{Data set with previously accepted taxonomic names} \title{Data set with previously accepted taxonomic names}
\format{A \code{\link{data.frame}} with 24,246 observations and 5 variables: \format{
A \code{\link{data.frame}} with 24,246 observations and 5 variables:
\itemize{ \itemize{
\item \code{col_id}\cr Catalogue of Life ID that was originally given \item \code{col_id}\cr Catalogue of Life ID that was originally given
\item \code{col_id_new}\cr New Catalogue of Life ID that responds to an entry in the \link{microorganisms} data set \item \code{col_id_new}\cr New Catalogue of Life ID that responds to an entry in the \link{microorganisms} data set
\item \code{fullname}\cr Old full taxonomic name of the microorganism \item \code{fullname}\cr Old full taxonomic name of the microorganism
\item \code{ref}\cr Author(s) and year of concerning scientific publication \item \code{ref}\cr Author(s) and year of concerning scientific publication
\item \code{prevalence}\cr Prevalence of the microorganism, see \code{\link[=as.mo]{as.mo()}} \item \code{prevalence}\cr Prevalence of the microorganism, see \code{\link[=as.mo]{as.mo()}}
}} }
}
\source{ \source{
Catalogue of Life: Annual Checklist (public online taxonomic database), \url{http://www.catalogueoflife.org} (check included annual version with \code{\link[=catalogue_of_life_version]{catalogue_of_life_version()}}). Catalogue of Life: Annual Checklist (public online taxonomic database), \url{http://www.catalogueoflife.org} (check included annual version with \code{\link[=catalogue_of_life_version]{catalogue_of_life_version()}}).
} }

View File

@ -59,10 +59,10 @@ The \code{\link[=pca]{pca()}} function takes a \link{data.frame} as input and pe
The result of the \code{\link[=pca]{pca()}} function is a \link{prcomp} object, with an additional attribute \code{non_numeric_cols} which is a vector with the column names of all columns that do not contain numeric values. These are probably the groups and labels, and will be used by \code{\link[=ggplot_pca]{ggplot_pca()}}. The result of the \code{\link[=pca]{pca()}} function is a \link{prcomp} object, with an additional attribute \code{non_numeric_cols} which is a vector with the column names of all columns that do not contain numeric values. These are probably the groups and labels, and will be used by \code{\link[=ggplot_pca]{ggplot_pca()}}.
} }
\section{Experimental lifecycle}{ \section{Maturing lifecycle}{
\if{html}{\figure{lifecycle_experimental.svg}{options: style=margin-bottom:5px} \cr} \if{html}{\figure{lifecycle_maturing.svg}{options: style=margin-bottom:5px} \cr}
The \link[AMR:lifecycle]{lifecycle} of this function is \strong{experimental}. An experimental function is in the very early stages of development. The unlying code might be changing frequently as we rapidly iterate and explore variations in search of the best fit. Experimental functions might be removed without deprecation, so you are generally best off waiting until a function is more mature before you use it in production code. Experimental functions will not be included in releases we submit to CRAN, since they have not yet matured enough. 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. We will strive to maintain backward compatibility, but the function needs wider usage and more extensive testing in order to optimise the unlying code.
} }
\examples{ \examples{

View File

@ -4,7 +4,8 @@
\name{rsi_translation} \name{rsi_translation}
\alias{rsi_translation} \alias{rsi_translation}
\title{Data set for R/SI interpretation} \title{Data set for R/SI interpretation}
\format{A \code{\link{data.frame}} with 13,975 observations and 9 variables: \format{
A \code{\link{data.frame}} with 13,975 observations and 9 variables:
\itemize{ \itemize{
\item \code{guideline}\cr Name of the guideline \item \code{guideline}\cr Name of the guideline
\item \code{method}\cr Either "MIC" or "DISK" \item \code{method}\cr Either "MIC" or "DISK"
@ -15,7 +16,8 @@
\item \code{disk_dose}\cr Dose of the used disk diffusion method \item \code{disk_dose}\cr Dose of the used disk diffusion method
\item \code{breakpoint_S}\cr Lowest MIC value or highest number of millimetres that leads to "S" \item \code{breakpoint_S}\cr Lowest MIC value or highest number of millimetres that leads to "S"
\item \code{breakpoint_R}\cr Highest MIC value or lowest number of millimetres that leads to "R" \item \code{breakpoint_R}\cr Highest MIC value or lowest number of millimetres that leads to "R"
}} }
}
\usage{ \usage{
rsi_translation rsi_translation
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -47,10 +47,8 @@ test_that("joins work", {
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI")), 1) expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI")), 1)
expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI", by = c("mo" = "mo"))), 1) expect_equal(nrow(inner_join_microorganisms("B_ESCHR_COLI", by = c("mo" = "mo"))), 1)
expect_warning(inner_join_microorganisms("Escherichia", by = c("mo" = "genus")))
expect_equal(nrow(left_join_microorganisms("B_ESCHR_COLI")), 1) expect_equal(nrow(left_join_microorganisms("B_ESCHR_COLI")), 1)
expect_warning(left_join_microorganisms("Escherichia", by = c("mo" = "genus")))
expect_equal(nrow(semi_join_microorganisms("B_ESCHR_COLI")), 1) expect_equal(nrow(semi_join_microorganisms("B_ESCHR_COLI")), 1)
expect_equal(nrow(anti_join_microorganisms("B_ESCHR_COLI")), 0) expect_equal(nrow(anti_join_microorganisms("B_ESCHR_COLI")), 0)