diff --git a/DESCRIPTION b/DESCRIPTION
index 970255f9..f6db0e34 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,30 +1,30 @@
Package: AMR
-Version: 0.9.0.9002
-Date: 2019-12-16
+Version: 0.9.0.9003
+Date: 2019-12-20
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(role = c("aut", "cre"),
- family = "Berends", given = c("Matthijs", "S."), email = "m.s.berends@umcg.nl", comment = c(ORCID = "0000-0001-7620-1800")),
+ family = "Berends", given = c("Matthijs", "S"), email = "m.s.berends@umcg.nl", comment = c(ORCID = "0000-0001-7620-1800")),
person(role = c("aut", "ctb"),
- family = "Luz", given = c("Christian", "F."), email = "c.f.luz@umcg.nl", comment = c(ORCID = "0000-0001-5809-5995")),
+ family = "Luz", given = c("Christian", "F"), email = "c.f.luz@umcg.nl", comment = c(ORCID = "0000-0001-5809-5995")),
person(role = c("aut", "ths"),
- family = "Friedrich", given = c("Alex", "W."), email = "alex.friedrich@umcg.nl", comment = c(ORCID = "0000-0003-4881-038X")),
+ family = "Friedrich", given = c("Alexander", "W"), email = "alex.friedrich@umcg.nl", comment = c(ORCID = "0000-0003-4881-038X")),
person(role = c("aut", "ths"),
- family = "Sinha", given = c("Bhanu", "N.", "M."), email = "b.sinha@umcg.nl", comment = c(ORCID = "0000-0003-1634-0010")),
+ family = "Sinha", given = c("Bhanu", "N", "M"), email = "b.sinha@umcg.nl", comment = c(ORCID = "0000-0003-1634-0010")),
person(role = c("aut", "ths"),
- family = "Albers", given = c("Casper", "J."), email = "c.j.albers@rug.nl", comment = c(ORCID = "0000-0002-9213-6743")),
+ family = "Albers", given = c("Casper", "J"), email = "c.j.albers@rug.nl", comment = c(ORCID = "0000-0002-9213-6743")),
person(role = c("aut", "ths"),
family = "Glasner", given = "Corinna", email = "c.glasner@umcg.nl", comment = c(ORCID = "0000-0003-1241-1328")),
person(role = "ctb",
- family = "Fonville", given = c("Judith", "M."), email = "j.fonville@pamm.nl"),
+ family = "Fonville", given = c("Judith", "M"), email = "j.fonville@pamm.nl"),
person(role = "ctb",
- family = "Hassing", given = c("Erwin", "E.", "A."), email = "e.hassing@certe.nl"),
+ family = "Hassing", given = c("Erwin", "E", "A"), email = "e.hassing@certe.nl"),
person(role = "ctb",
- family = "Hazenberg", given = c("Eric", "H.", "L.", "C.", "M."), email = "e.hazenberg@jbz.nl"),
+ family = "Hazenberg", given = c("Eric", "H", "L", "C", "M"), email = "e.hazenberg@jbz.nl"),
person(role = "ctb",
family = "Lenglet", given = "Annick", email = "annick.lenglet@amsterdam.msf.org"),
person(role = "ctb",
- family = "Meijer", given = c("Bart", "C."), email = "b.meijerg@certe.nl"),
+ family = "Meijer", given = c("Bart", "C"), email = "b.meijerg@certe.nl"),
person(role = "ctb",
family = "Ny", given = "Sofia", email = "sofia.ny@folkhalsomyndigheten.se"),
person(role = "ctb",
diff --git a/NEWS.md b/NEWS.md
index 379a0d5c..b60b1d81 100755
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,7 +1,8 @@
-# AMR 0.9.0.9002
-## Last updated: 16-Dec-2019
+# AMR 0.9.0.9003
+## Last updated: 20-Dec-2019
-Website updates
+### Changes
+* Speed improvement for `as.mo()` (and consequently all `mo_*` functions that use `as.mo()` internally)
# AMR 0.9.0
diff --git a/R/mo.R b/R/mo.R
index 28bd5abb..8962fcf0 100755
--- a/R/mo.R
+++ b/R/mo.R
@@ -25,10 +25,10 @@
#' @param x a character vector or a [`data.frame`] with one or two columns
#' @param Becker a logical to indicate whether *Staphylococci* should be categorised into coagulase-negative *Staphylococci* ("CoNS") and coagulase-positive *Staphylococci* ("CoPS") instead of their own species, according to Karsten Becker *et al.* (1,2). Note that this does not include species that were newly named after these publications, like *S. caeli*.
#'
-#' This excludes *Staphylococcus aureus* at default, use `Becker = "all"` to also categorise *S. aureus* as "CoPS".
+#' This excludes *Staphylococcus aureus* at default, use `Becker = "all"` to also categorise *S. aureus* as "CoPS".
#' @param Lancefield a logical to indicate whether beta-haemolytic *Streptococci* should be categorised into Lancefield groups instead of their own species, according to Rebecca C. Lancefield (3). These *Streptococci* will be categorised in their first group, e.g. *Streptococcus dysgalactiae* will be group C, although officially it was also categorised into groups G and L.
#'
-#' This excludes *Enterococci* at default (who are in group D), use `Lancefield = "all"` to also categorise all *Enterococci* as group D.
+#' This excludes *Enterococci* at default (who are in group D), use `Lancefield = "all"` to also categorise all *Enterococci* as group D.
#' @param allow_uncertain a number between `0` (or `"none"`) and `3` (or `"all"`), or `TRUE` (= `2`) or `FALSE` (= `0`) to indicate whether the input should be checked for less probable results, please see *Details*
#' @param reference_df a [`data.frame`] to use for extra reference when translating `x` to a valid [`mo`]. See [set_mo_source()] and [get_mo_source()] to automate the usage of your own codes (e.g. used in your analysis or organisation).
#' @param ... other parameters passed on to functions
@@ -228,19 +228,7 @@ as.mo <- function(x,
& isFALSE(Lancefield)) {
# check previously found results
y <- mo_hist
-
- } else if (all(tolower(x) %in% microorganismsDT$fullname_lower)
- & isFALSE(Becker)
- & isFALSE(Lancefield)) {
- # we need special treatment for very prevalent full names, they are likely! (case insensitive)
- # e.g. as.mo("Staphylococcus aureus")
- y <- data.frame(fullname_lower = tolower(x),
- stringsAsFactors = FALSE) %>%
- left_join(microorganismsDT, by = "fullname_lower") %>%
- pull(mo)
-
- # don't save valid fullnames to history (i.e. values that are in microorganisms$fullname)
-
+
} else {
# will be checked for mo class in validation and uses exec_as.mo internally if necessary
y <- mo_validate(x = x, property = "mo",
@@ -249,7 +237,6 @@ as.mo <- function(x,
...)
}
-
to_class_mo(y)
}
@@ -283,7 +270,7 @@ exec_as.mo <- function(x,
initial_search = TRUE,
dyslexia_mode = FALSE,
force_mo_history = FALSE,
- disable_mo_history = FALSE,
+ disable_mo_history = getOption("AMR_disable_mo_history", FALSE),
debug = FALSE,
reference_data_to_use = microorganismsDT) {
@@ -433,18 +420,7 @@ exec_as.mo <- function(x,
} else if (all(tolower(x) %in% reference_data_to_use$fullname_lower)) {
# we need special treatment for very prevalent full names, they are likely!
# e.g. as.mo("Staphylococcus aureus")
- y <- reference_data_to_use[prevalence == 1][data.table(fullname_lower = tolower(x)), on = "fullname_lower", ..property][[1]]
- if (any(is.na(y))) {
- y[is.na(y)] <- reference_data_to_use[prevalence == 2][data.table(fullname_lower = tolower(x[is.na(y)])),
- on = "fullname_lower",
- ..property][[1]]
- }
- if (any(is.na(y))) {
- y[is.na(y)] <- reference_data_to_use[prevalence == 3][data.table(fullname_lower = tolower(x[is.na(y)])),
- on = "fullname_lower",
- ..property][[1]]
- }
- x <- y
+ x <- reference_data_to_use[data.table(fullname_lower = tolower(x)), on = "fullname_lower", ..property][[1]]
} else if (all(toupper(x) %in% AMR::microorganisms.codes$code)) {
# commonly used MO codes
diff --git a/data-raw/country_analysis.R b/data-raw/country_analysis.R
index c7dd8dfa..52e328b7 100644
--- a/data-raw/country_analysis.R
+++ b/data-raw/country_analysis.R
@@ -15,6 +15,11 @@ data_json <- jsonlite::read_json(url_json)
data <- tibble(
timestamp_server = as.POSIXct(sapply(data_json, function(x) x$serverTimestamp), origin = "1970-01-01"),
country = sapply(data_json, function(x) x$country))
+rm(data_json)
+
+# how many?
+n_distinct(data$country[data$country != "Unknown"])
+
# Plot world map ----------------------------------------------------------
@@ -28,25 +33,46 @@ world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE)) %>%
included = as.integer(countries_code %in% countries_iso)) %>%
mutate(not_antarctica = as.integer(ID != "Antarctica"))
-(ggplot(world1) +
+countries_plot <- ggplot(world1) +
geom_sf(aes(fill = included, colour = not_antarctica), size = 0.25) +
theme_minimal() +
- theme(legend.position = "none",
+ theme(legend.position = "none",
panel.grid = element_blank(),
axis.title = element_blank(),
axis.text = element_blank()) +
scale_fill_gradient(low = "white", high = "#CAD6EA") +
# this makes the border Antarctica turn white (invisible):
- scale_colour_gradient(low = "white", high = "#81899B") +
- geom_text(aes(x = -170,
- y = -70,
- label = stringr::str_wrap(paste0("Accented countries (n = ",
- length(countries_name), "): ",
- paste(countries_name, collapse = ", ")),
- 225)),
- hjust = 0,
- size = 4)) %>%
- ggsave("pkgdown/logos/countries.png", dpi = 300, plot = ., scale = 1.5)
+ scale_colour_gradient(low = "white", high = "#81899B")
+
+# main website page
+ggsave("pkgdown/logos/countries.png",
+ width = 6,
+ height = 3,
+ units = "in",
+ dpi = 100,
+ plot = countries_plot,
+ scale = 1)
+# when clicked - a high res enlargement
+ggsave("pkgdown/logos/countries_large.png",
+ width = 11,
+ height = 6,
+ units = "in",
+ dpi = 300,
+ plot =
+ countries_plot +
+ labs(title = tools::toTitleCase("Countries where the AMR package for R was downloaded from"),
+ subtitle = paste0("Between March 2018 - ", format(Sys.Date(), "%B %Y"))) +
+ theme(plot.title = element_text(size = 16, hjust = 0.5),
+ plot.subtitle = element_text(size = 12, hjust = 0.5)) +
+ geom_text(aes(x = -170,
+ y = -70,
+ label = stringr::str_wrap(paste0("Countries (n = ",
+ length(countries_name), "): ",
+ paste(countries_name, collapse = ", ")),
+ 200)),
+ hjust = 0,
+ size = 4),
+ scale = 1.5)
# Gibberish ---------------------------------------------------------------
diff --git a/docs/404.html b/docs/404.html
index 1fb3372a..062c9b99 100644
--- a/docs/404.html
+++ b/docs/404.html
@@ -84,7 +84,7 @@
AMR (for R)
- 0.9.0.9002
+ 0.9.0.9003
@@ -240,7 +240,7 @@ Content not found. Please use links in the navbar.