diff --git a/.gitignore b/.gitignore index 81344b27..df09180e 100755 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ packrat/lib*/ packrat/src/ data-raw/taxon.tab data-raw/DSMZ_bactnames.xlsx +data-raw/country_analysis_url_token.R diff --git a/DESCRIPTION b/DESCRIPTION index 486001dc..970255f9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 0.9.0 -Date: 2019-11-30 +Version: 0.9.0.9002 +Date: 2019-12-16 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 40415ffa..379a0d5c 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,8 @@ +# AMR 0.9.0.9002 +## Last updated: 16-Dec-2019 + +Website updates + # AMR 0.9.0 ### Breaking diff --git a/data-raw/country_analysis.R b/data-raw/country_analysis.R new file mode 100644 index 00000000..c7dd8dfa --- /dev/null +++ b/data-raw/country_analysis.R @@ -0,0 +1,80 @@ + +# Read and format data ---------------------------------------------------- + +library(tidyverse) +library(maps) + +# get website analytics +source("data-raw/country_analysis_url_token.R") +url_json <- paste0(country_analysis_url, + "/index.php?&module=API&token_auth=", + country_analysis_token, + "&method=Live.getLastVisitsDetails&idSite=3&language=en&expanded=1&date=2018-01-01,2028-01-01&period=range&filter_limit=-1&format=JSON&segment=&translateColumnNames=1") + +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)) + + +# Plot world map ---------------------------------------------------------- + +countries_name <- sort(unique(data$country)) +countries_name <- countries_name[countries_name != "Unknown"] +countries_iso <- countrycode::countrycode(countries_name, 'country.name', 'iso3c') + +world1 <- sf::st_as_sf(map('world', plot = FALSE, fill = TRUE)) %>% + mutate(countries_code = countrycode::countrycode(ID, 'country.name', 'iso3c'), + included = as.integer(countries_code %in% countries_iso)) %>% + mutate(not_antarctica = as.integer(ID != "Antarctica")) + +(ggplot(world1) + + geom_sf(aes(fill = included, colour = not_antarctica), size = 0.25) + + theme_minimal() + + 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) + + +# Gibberish --------------------------------------------------------------- + +p1 <- data %>% + group_by(country) %>% + summarise(first = min(timestamp_server)) %>% + arrange(first) %>% + mutate(n = row_number()) %>% + ggplot(aes(x = first, y = n)) + + geom_line() + + geom_point(aes(x = max(first), y = max(n)), size = 3) + + scale_x_datetime(date_breaks = "2 months", date_labels = "%B %Y") + + labs(x = NULL, y = "Number of countries") + +package_releases <- read_html("https://cran.r-project.org/src/contrib/Archive/AMR/") %>% + rvest::html_table() %>% + .[[1]] %>% + as_tibble(.name_repair = "unique") %>% + filter(`Last modified` != "") %>% + transmute(version = gsub("[^0-9.]", "", + gsub(".tar.gz", "", Name)), + datetime = as.POSIXct(`Last modified`)) %>% + # add current + bind_rows(tibble(version = as.character(packageVersion("AMR")), + datetime = as.POSIXct(packageDate("AMR")))) %>% + # remove the ones not plottable + filter(datetime > min(p1$data$first)) + +p1 + geom_linerange(data = package_releases, aes(x = datetime, ymin = 0, ymax = 80), colour = "red", inherit.aes = FALSE) + diff --git a/docs/404.html b/docs/404.html index 1cc1b722..1fb3372a 100644 --- a/docs/404.html +++ b/docs/404.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0 + 0.9.0.9002 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index e9139bef..9d7220fa 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0 + 0.9.0.9002 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index c5379fd9..60651cc6 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -187,7 +187,7 @@

How to conduct AMR analysis

Matthijs S. Berends

-

30 November 2019

+

11 December 2019

@@ -196,7 +196,7 @@ -

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

+

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

Introduction

@@ -212,21 +212,21 @@ -2019-11-30 +2019-12-11 abcd Escherichia coli S S -2019-11-30 +2019-12-11 abcd Escherichia coli S R -2019-11-30 +2019-12-11 efgh Escherichia coli R @@ -321,70 +321,70 @@ -2017-05-01 -L9 -Hospital A -Staphylococcus aureus -S -S -S +2017-05-19 +J2 +Hospital D +Escherichia coli R +R +S +S M -2014-02-04 -U2 +2016-07-09 +K4 Hospital A -Escherichia coli +Streptococcus pneumoniae S +S +R +S +M + + +2014-05-10 +R6 +Hospital C +Escherichia coli +R +S +S +S +F + + +2011-06-29 +T4 +Hospital B +Escherichia coli +R +R +S +S +F + + +2012-02-11 +O10 +Hospital A +Streptococcus pneumoniae I -R -S -F - - -2016-12-08 -P9 -Hospital B -Escherichia coli -S S R S F -2014-11-30 -V1 -Hospital B -Klebsiella pneumoniae -R -S -S -R -F - - -2017-09-12 -T5 +2017-04-09 +D3 Hospital D -Staphylococcus aureus -S -S -S -R -F - - -2010-01-31 -W3 -Hospital A Escherichia coli R -S R S -F +S +M @@ -406,8 +406,8 @@ # # Item Count Percent Cum. Count Cum. Percent # --- ----- ------- -------- ----------- ------------- -# 1 M 10,321 51.61% 10,321 51.61% -# 2 F 9,679 48.40% 20,000 100.00% +# 1 M 10,408 52.04% 10,408 52.04% +# 2 F 9,592 47.96% 20,000 100.00%

So, we can draw at least two conclusions immediately. From a data scientists perspective, the data looks clean: only values M and F. From a researchers perspective: there are slightly more men. Nothing we didn’t already know.

The data is already quite clean, but we still need to transform some variables. The bacteria column now consists of text, and we want to add more variables based on microbial IDs later on. So, we will transform this column to valid IDs. The mutate() function of the dplyr package makes this really easy:

data <- data %>%
@@ -422,8 +422,8 @@
 # Other rules by this AMR package
 # Non-EUCAST: inherit amoxicillin results for unavailable ampicillin (no changes)
 # Non-EUCAST: inherit ampicillin results for unavailable amoxicillin (no changes)
-# Non-EUCAST: set amoxicillin/clav acid = S where ampicillin = S (2,960 values changed)
-# Non-EUCAST: set ampicillin = R where amoxicillin/clav acid = R (144 values changed)
+# Non-EUCAST: set amoxicillin/clav acid = S where ampicillin = S (2,997 values changed)
+# Non-EUCAST: set ampicillin = R where amoxicillin/clav acid = R (165 values changed)
 # Non-EUCAST: set piperacillin = R where piperacillin/tazobactam = R (no changes)
 # Non-EUCAST: set piperacillin/tazobactam = S where piperacillin = S (no changes)
 # Non-EUCAST: set trimethoprim = R where trimethoprim/sulfa = R (no changes)
@@ -448,14 +448,14 @@
 # Pasteurella multocida (no changes)
 # Staphylococcus (no changes)
 # Streptococcus groups A, B, C, G (no changes)
-# Streptococcus pneumoniae (997 values changed)
+# Streptococcus pneumoniae (1,063 values changed)
 # Viridans group streptococci (no changes)
 # 
 # EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-# Table 01: Intrinsic resistance in Enterobacteriaceae (1,331 values changed)
+# Table 01: Intrinsic resistance in Enterobacteriaceae (1,242 values changed)
 # Table 02: Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
 # Table 03: Intrinsic resistance in other Gram-negative bacteria (no changes)
-# Table 04: Intrinsic resistance in Gram-positive bacteria (2,705 values changed)
+# Table 04: Intrinsic resistance in Gram-positive bacteria (2,782 values changed)
 # Table 08: Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
 # Table 09: Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
 # Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)
@@ -463,15 +463,15 @@
 # Table 13: Interpretive rules for quinolones (no changes)
 # 
 # -------------------------------------------------------------------------------
-# EUCAST rules affected 6,481 out of 20,000 rows, making a total of 8,137 edits
+# EUCAST rules affected 6,564 out of 20,000 rows, making a total of 8,249 edits
 # => added 0 test results
 # 
-# => changed 8,137 test results
-#    - 115 test results changed from S to I
-#    - 4,732 test results changed from S to R
-#    - 1,228 test results changed from I to S
-#    - 330 test results changed from I to R
-#    - 1,732 test results changed from R to S
+# => changed 8,249 test results
+#    - 102 test results changed from S to I
+#    - 4,787 test results changed from S to R
+#    - 1,224 test results changed from I to S
+#    - 363 test results changed from I to R
+#    - 1,773 test results changed from R to S
 # -------------------------------------------------------------------------------
 # 
 # Use eucast_rules(..., verbose = TRUE) (on your original data) to get a data.frame with all specified edits instead.
@@ -499,7 +499,7 @@ # NOTE: Using column `bacteria` as input for `col_mo`. # NOTE: Using column `date` as input for `col_date`. # NOTE: Using column `patient_id` as input for `col_patient_id`. -# => Found 5,667 first isolates (28.3% of total)
+# => Found 5,656 first isolates (28.3% of total)

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

data_1st <- data %>% 
   filter(first == TRUE)
@@ -510,7 +510,7 @@

First weighted isolates

-

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient E9, sorted on date:

+

We made a slight twist to the CLSI algorithm, to take into account the antimicrobial susceptibility profile. Have a look at all isolates of patient D2, sorted on date:

@@ -526,52 +526,52 @@ - - + + - + - - + + - - + + - - + + - - + + - - + + - + - - + + @@ -581,10 +581,10 @@ - - + + - + @@ -592,8 +592,8 @@ - - + + @@ -603,40 +603,40 @@ - - + + - - + + - - + + - + - - + + + - - +
isolate
12010-07-16E92010-02-23D2 B_ESCHR_COLI S SSR S TRUE
22010-07-22E92010-03-20D2 B_ESCHR_COLISS RRS S FALSE
32010-08-26E92010-04-13D2 B_ESCHR_COLIR SRSS S FALSE
42010-10-17E92010-07-22D2 B_ESCHR_COLI S SSR S FALSE
52010-10-25E92010-07-22D2 B_ESCHR_COLI S S
62011-02-27E92010-08-04D2 B_ESCHR_COLISR S S S
72011-03-15E92010-08-19D2 B_ESCHR_COLI S S
82011-03-19E92010-09-02D2 B_ESCHR_COLIRRI SR S FALSE
92011-06-20E92010-09-04D2 B_ESCHR_COLI S SSR S FALSE
102011-12-03E92010-09-18D2 B_ESCHR_COLIR S S SSTRUEFALSE
-

Only 2 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

+

Only 1 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

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

data <- data %>% 
   mutate(keyab = key_antibiotics(.)) %>% 
@@ -647,7 +647,7 @@
 # NOTE: Using column `patient_id` as input for `col_patient_id`.
 # NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
 # [Criterion] Inclusion based on key antibiotics, ignoring I
-# => Found 15,044 first weighted isolates (75.2% of total)
+# => Found 15,026 first weighted isolates (75.1% of total)
@@ -664,131 +664,131 @@ - - + + - + - - + + - - + + - - + + - - + + - - + + - + - - + + - + - - + + - + - + - - + + - + - - + + - - + + - - + + + + + + + + + + + + + + - - - - - - - - - - - -
isolate
12010-07-16E92010-02-23D2 B_ESCHR_COLI S SSR S TRUE TRUE
22010-07-22E92010-03-20D2 B_ESCHR_COLISS RRS S FALSE TRUE
32010-08-26E92010-04-13D2 B_ESCHR_COLIR SRSS S FALSE TRUE
42010-10-17E92010-07-22D2 B_ESCHR_COLI S SSR S FALSE TRUE
52010-10-25E92010-07-22D2 B_ESCHR_COLI S S S S FALSEFALSETRUE
62011-02-27E92010-08-04D2 B_ESCHR_COLISR S S S FALSEFALSETRUE
72011-03-15E92010-08-19D2 B_ESCHR_COLI S S S S FALSEFALSETRUE
82011-03-19E92010-09-02D2 B_ESCHR_COLIRRI SR S FALSE TRUE
92011-06-20E92010-09-04D2 B_ESCHR_COLI S SRSFALSEFALSE
102010-09-18D2B_ESCHR_COLIRS S S FALSE TRUE
102011-12-03E9B_ESCHR_COLISSSSTRUETRUE
-

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

+

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

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

data_1st <- data %>% 
   filter_first_weighted_isolate()
-

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

+

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

We can remove unneeded columns:

data_1st <- data_1st %>% 
   select(-c(first, keyab))
@@ -796,7 +796,6 @@
head(data_1st)
- @@ -813,62 +812,58 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + - - - - + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -877,35 +872,33 @@ - - - - - + + + + + + - - - - - + + + - - - - - - - + + + + + + - - - + + + @@ -927,7 +920,7 @@
data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 15,044 (of which NA: 0 = 0%)
+Length: 15,026 (of which NA: 0 = 0%)
Unique: 4

Shortest: 16
Longest: 24

@@ -944,33 +937,33 @@ Longest: 24

- - - - + + + + - - - - + + + + - - - - + + + + - - - + + + @@ -982,7 +975,7 @@ Longest: 24

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

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

data_1st %>% resistance(AMX)
-# [1] 0.4660994
+# [1] 0.4631971

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

data_1st %>% 
   group_by(hospital) %>% 
@@ -995,19 +988,19 @@ Longest: 24

- + - + - + - +
date patient_id hospital
32016-12-08P9Hospital BB_ESCHR_COLISSRSFGram-negativeEscherichiacoliTRUE
42014-11-30V1Hospital BB_KLBSL_PNMNRSSRFGram-negativeKlebsiellapneumoniaeTRUE
52017-09-12T52017-05-19J2 Hospital DB_STPHY_AURSSSSB_ESCHR_COLI RFGram-positiveStaphylococcusaureusRSSMGram-negativeEscherichiacoli TRUE
62010-01-31W32016-07-09K4 Hospital AB_STRPT_PNMNSSRRMGram-positiveStreptococcuspneumoniaeTRUE
2014-05-10R6Hospital C B_ESCHR_COLI R SSSFGram-negativeEscherichiacoliTRUE
2011-06-29T4Hospital BB_ESCHR_COLI RRS S F Gram-negativeTRUE
72015-09-28K4Hospital BB_KLBSL_PNMN2012-02-11O10Hospital AB_STRPT_PNMNII RS RSMGram-negativeKlebsiellaFGram-positiveStreptococcus pneumoniae TRUE
82011-08-30B6Hospital AB_STPHY_AURSSS2017-04-09D3Hospital DB_ESCHR_COLIRR S S MGram-positiveStaphylococcusaureusGram-negativeEscherichiacoli TRUE
1 Escherichia coli7,49349.81%7,49349.81%7,42549.41%7,42549.41%
2 Staphylococcus aureus3,71824.71%11,21174.52%3,80625.33%11,23174.74%
3 Streptococcus pneumoniae2,29315.24%13,50489.76%2,31115.38%13,54290.12%
4 Klebsiella pneumoniae1,54010.24%15,0441,4849.88%15,026 100.00%
Hospital A0.46448330.4553786
Hospital B0.46262310.4653638
Hospital C0.46160600.4613043
Hospital D0.47768000.4729412
@@ -1025,23 +1018,23 @@ Longest: 24

Hospital A -0.4644833 -4519 +0.4553786 +4583 Hospital B -0.4626231 -5177 +0.4653638 +5168 Hospital C -0.4616060 -2279 +0.4613043 +2300 Hospital D -0.4776800 -3069 +0.4729412 +2975 @@ -1061,27 +1054,27 @@ Longest: 24

Escherichia -0.9253970 -0.8955025 -0.9929267 +0.9248485 +0.8921212 +0.9936700 Klebsiella -0.9298701 -0.9038961 -0.9967532 +0.9238544 +0.8928571 +0.9946092 Staphylococcus -0.9276493 -0.9133943 -0.9943518 +0.9224908 +0.9177614 +0.9923805 Streptococcus -0.6096816 +0.5962787 0.0000000 -0.6096816 +0.5962787 diff --git a/docs/articles/AMR_files/figure-html/plot 1-1.png b/docs/articles/AMR_files/figure-html/plot 1-1.png index d7bceec2..2e2aa561 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 1-1.png and b/docs/articles/AMR_files/figure-html/plot 1-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 3-1.png b/docs/articles/AMR_files/figure-html/plot 3-1.png index 1f51a21e..93c46df1 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 3-1.png and b/docs/articles/AMR_files/figure-html/plot 3-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 4-1.png b/docs/articles/AMR_files/figure-html/plot 4-1.png index 50a1c14d..dceb872e 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 4-1.png and b/docs/articles/AMR_files/figure-html/plot 4-1.png differ diff --git a/docs/articles/AMR_files/figure-html/plot 5-1.png b/docs/articles/AMR_files/figure-html/plot 5-1.png index e2aca4a6..d162c3fe 100644 Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html index 7dc377a0..4bcf3d08 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -187,7 +187,7 @@

How to apply EUCAST rules

Matthijs S. Berends

-

29 November 2019

+

11 December 2019

diff --git a/docs/articles/MDR.html b/docs/articles/MDR.html index 43a9fdb6..82d8068d 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -187,7 +187,7 @@

How to determine multi-drug resistance (MDR)

Matthijs S. Berends

-

29 November 2019

+

11 December 2019

@@ -306,19 +306,19 @@ Unique: 2

The data set now looks like this:

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

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

mdro(my_TB_data, guideline = "TB")

or its shortcut mdr_tb():

@@ -335,7 +335,7 @@ Unique: 2

# Author: WHO (World Health Organization) # Source: https://www.who.int/tb/publications/pmdt_companionhandbook/en/ # -# => Found 4377 MDROs out of 5000 tested isolates (87.5%) +# => Found 4374 MDROs out of 5000 tested isolates (87.5%)

Create a frequency table of the results:

freq(my_TB_data$mdr)

Frequency table

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

1 Mono-resistant -3240 -64.80% -3240 -64.80% +3299 +65.98% +3299 +65.98% 2 -Multi-drug-resistant -647 -12.94% -3887 -77.74% +Negative +626 +12.52% +3925 +78.50% 3 -Negative -623 -12.46% -4510 -90.20% +Multi-drug-resistant +572 +11.44% +4497 +89.94% 4 Poly-resistant -304 -6.08% -4814 -96.28% +265 +5.30% +4762 +95.24% 5 Extensively drug-resistant -186 -3.72% +238 +4.76% 5000 100.00% diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index 74b27fb3..5bfa4fd8 100644 --- a/docs/articles/SPSS.html +++ b/docs/articles/SPSS.html @@ -187,7 +187,7 @@

How to import data from SPSS / SAS / Stata

Matthijs S. Berends

-

29 November 2019

+

11 December 2019

diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index 16d6d3bf..3d45c612 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -187,7 +187,7 @@

How to work with WHONET data

Matthijs S. Berends

-

30 November 2019

+

11 December 2019

diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 7172e978..e5434395 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -187,7 +187,7 @@

Benchmarks

Matthijs S. Berends

-

29 November 2019

+

11 December 2019

@@ -222,20 +222,20 @@ print(S.aureus, unit = "ms", signif = 2) # Unit: milliseconds # expr min lq mean median uq max neval -# as.mo("sau") 11 11 15 12 14 39 10 -# as.mo("stau") 36 38 49 48 60 65 10 -# as.mo("STAU") 36 38 46 40 59 71 10 -# as.mo("staaur") 11 11 21 11 37 37 10 -# as.mo("STAAUR") 11 11 12 12 12 17 10 -# as.mo("S. aureus") 26 29 36 32 48 53 10 -# as.mo("S aureus") 25 27 37 29 52 64 10 -# as.mo("Staphylococcus aureus") 33 34 39 36 45 53 10 -# as.mo("Staphylococcus aureus (MRSA)") 660 720 740 740 760 800 10 -# as.mo("Sthafilokkockus aaureuz") 350 360 410 380 400 660 10 -# as.mo("MRSA") 11 11 14 12 12 36 10 -# as.mo("VISA") 21 23 27 26 28 47 10 -# as.mo("VRSA") 21 22 30 23 44 52 10 -# as.mo(22242419) 20 20 24 21 21 52 10 +# as.mo("sau") 11 11 15 11 14 33 10 +# as.mo("stau") 34 38 47 43 58 65 10 +# as.mo("STAU") 34 37 45 39 59 65 10 +# as.mo("staaur") 10 12 30 12 37 120 10 +# as.mo("STAAUR") 11 11 20 12 34 45 10 +# as.mo("S. aureus") 26 27 34 30 34 54 10 +# as.mo("S aureus") 26 27 44 28 28 160 10 +# as.mo("Staphylococcus aureus") 32 34 37 35 41 44 10 +# as.mo("Staphylococcus aureus (MRSA)") 640 690 710 700 720 810 10 +# as.mo("Sthafilokkockus aaureuz") 340 370 390 380 400 470 10 +# as.mo("MRSA") 11 11 14 12 12 35 10 +# as.mo("VISA") 22 23 33 26 46 51 10 +# as.mo("VRSA") 20 22 25 24 26 43 10 +# as.mo(22242419) 20 25 37 36 49 55 10

In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.

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

@@ -247,19 +247,19 @@ times = 10) print(M.semesiae, unit = "ms", signif = 4) # Unit: milliseconds -# expr min lq mean median uq max -# as.mo("metsem") 1501.0 1506.00 1665.0 1569.00 1788.00 2141.00 -# as.mo("METSEM") 1586.0 1610.00 1727.0 1675.00 1793.00 2002.00 -# as.mo("M. semesiae") 2266.0 2335.00 2587.0 2418.00 2524.00 3676.00 -# as.mo("M. semesiae") 2143.0 2252.00 2334.0 2331.00 2396.00 2540.00 -# as.mo("Methanosarcina semesiae") 34.8 35.74 46.3 39.64 62.28 65.83 +# expr min lq mean median uq max +# as.mo("metsem") 1455.00 1534.00 1589.00 1546.00 1642.0 1856.0 +# as.mo("METSEM") 1504.00 1560.00 1570.00 1568.00 1581.0 1668.0 +# as.mo("M. semesiae") 2262.00 2295.00 2338.00 2321.00 2361.0 2536.0 +# as.mo("M. semesiae") 2243.00 2261.00 2304.00 2302.00 2334.0 2397.0 +# as.mo("Methanosarcina semesiae") 33.36 35.01 43.82 39.71 47.8 68.4 # neval # 10 # 10 # 10 # 10 # 10 -

That takes 15.6 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Methanosarcina semesiae) are almost fast - these are the most probable input from most data sets.

+

That takes 14.9 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Methanosarcina semesiae) are almost fast - these are the most probable input from most data sets.

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

In reality, the as.mo() functions learns from its own output to speed up determinations for next times. In above figure, this effect was disabled to show the difference with the boxplot below - when you would use as.mo() yourself:

@@ -296,8 +296,8 @@ print(run_it, unit = "ms", signif = 3) # Unit: milliseconds # expr min lq mean median uq max neval -# mo_name(x) 655 668 715 717 751 797 10 -

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

+# mo_name(x) 647 669 689 685 701 770 10 +

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

@@ -309,11 +309,11 @@ times = 10) print(run_it, unit = "ms", signif = 3) # Unit: milliseconds -# expr min lq mean median uq max neval -# A 6.70 6.710 9.690 7.18 7.850 31.90 10 -# B 26.20 27.100 32.400 28.80 32.100 58.80 10 -# C 0.78 0.837 0.924 0.88 0.965 1.24 10

-

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

+# expr min lq mean median uq max neval +# A 6.440 6.560 11.00 7.210 8.75 44.10 10 +# B 25.400 25.700 31.40 27.900 34.90 53.80 10 +# C 0.816 0.878 1.05 0.991 1.24 1.37 10 +

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

run_it <- microbenchmark(A = mo_species("aureus"),
                          B = mo_genus("Staphylococcus"),
                          C = mo_name("Staphylococcus aureus"),
@@ -326,14 +326,14 @@
 print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
 #  expr   min    lq  mean median    uq   max neval
-#     A 0.444 0.449 0.473  0.460 0.466 0.630    10
-#     B 0.483 0.496 0.511  0.505 0.535 0.539    10
-#     C 0.709 0.839 0.850  0.846 0.886 0.921    10
-#     D 0.463 0.483 0.521  0.499 0.548 0.694    10
-#     E 0.433 0.451 0.493  0.484 0.513 0.611    10
-#     F 0.434 0.450 0.481  0.458 0.484 0.582    10
-#     G 0.434 0.443 0.471  0.455 0.489 0.577    10
-#     H 0.434 0.436 0.471  0.451 0.480 0.614    10
+# A 0.461 0.485 0.613 0.608 0.739 0.775 10 +# B 0.505 0.521 0.641 0.552 0.594 1.120 10 +# C 0.759 0.846 1.040 0.870 1.270 1.680 10 +# D 0.495 0.502 0.536 0.505 0.532 0.667 10 +# E 0.459 0.470 0.549 0.478 0.510 0.830 10 +# F 0.457 0.460 0.545 0.469 0.615 0.788 10 +# G 0.455 0.474 0.572 0.516 0.694 0.830 10 +# H 0.457 0.466 0.551 0.472 0.545 1.030 10

Of course, when running mo_phylum("Firmicutes") the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes" too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.

@@ -360,13 +360,13 @@ print(run_it, unit = "ms", signif = 4) # Unit: milliseconds # expr min lq mean median uq max neval -# en 22.05 22.65 29.93 25.35 27.03 53.36 10 -# de 22.86 23.16 30.45 27.22 28.33 62.68 10 -# nl 28.99 29.69 34.37 30.32 31.78 65.15 10 -# es 22.45 23.17 30.84 23.73 28.02 64.67 10 -# it 22.76 24.59 30.36 26.23 29.97 66.70 10 -# fr 23.00 24.20 30.70 27.00 29.22 51.23 10 -# pt 23.31 24.41 26.92 27.31 28.39 31.00 10
+# en 20.61 21.92 22.93 22.53 24.17 26.26 10 +# de 22.19 22.61 28.83 23.28 28.22 51.89 10 +# nl 27.45 28.26 29.07 29.34 29.78 30.03 10 +# es 22.05 23.69 30.82 28.10 30.51 51.22 10 +# it 23.00 24.39 31.27 27.07 33.34 49.78 10 +# fr 22.13 23.03 26.94 23.83 25.55 52.39 10 +# pt 22.43 24.94 33.02 28.38 45.69 49.11 10

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

diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-11-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-11-1.png index 5702abb8..ff9cd6be 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-11-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-11-1.png differ diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png index e0d2422f..75f2ee6a 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-9-1.png index 6ee94219..f0182e1d 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 7b5c5307..647d3904 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0 + 0.9.0.9002 diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index bf4224fb..bb494701 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -187,7 +187,7 @@

How to predict antimicrobial resistance

Matthijs S. Berends

-

29 November 2019

+

11 December 2019

diff --git a/docs/authors.html b/docs/authors.html index cb641dac..99a09cdb 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0 + 0.9.0.9002 diff --git a/docs/countries.png b/docs/countries.png index f0424ce4..441f09d7 100644 Binary files a/docs/countries.png and b/docs/countries.png differ diff --git a/docs/index.html b/docs/index.html index a16635e8..c56beaec 100644 --- a/docs/index.html +++ b/docs/index.html @@ -45,7 +45,7 @@ AMR (for R) - 0.9.0 + 0.9.0.9002 @@ -206,7 +206,7 @@ A methods paper about this package has been preprinted at bioRxiv. It was update

Used in over 70 countries
- Since its first public release in early 2018, this package has been downloaded over 25,000 times from 75 countries (as of November 2019, CRAN logs). Click the map to enlarge.

+ Since its first public release in early 2018, this package has been downloaded over 25,000 times from 78 countries (as of December 2019, CRAN logs). Click the map to enlarge.



@@ -272,7 +272,7 @@ A methods paper about this package has been preprinted at bioRxiv. It was update

Latest released version

-

This package is available on the official R network (CRAN), which has a peer-reviewed submission process. Install this package in R with:

+

This package is available here on the official R network (CRAN), which has a peer-reviewed submission process. Install this package in R from CRAN by using the command:

It will be downloaded and installed automatically. For RStudio, click on the menu Tools > Install Packages… and then type in “AMR” and press Install.

Note: Not all functions on this website may be available in this latest release. To use all functions and data sets mentioned on this website, install the latest development version.

diff --git a/docs/news/index.html b/docs/news/index.html index f806f7ac..4e024002 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -84,7 +84,7 @@ AMR (for R) - 0.9.0 + 0.9.0.9002
@@ -231,6 +231,17 @@
+
+

+AMR 0.9.0.9002 Unreleased +

+
+

+Last updated: 16-Dec-2019 +

+

Website updates

+
+

AMR 0.9.0 2019-11-29 @@ -1390,6 +1401,7 @@ Using as.mo(..., allow_uncertain = 3)

Contents

diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index 9c0f441d..3fc11df9 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -86,7 +86,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p AMR (for R) - 0.9.0 + 0.9.0.9002 diff --git a/docs/reference/resistance_predict-1.png b/docs/reference/resistance_predict-1.png new file mode 100644 index 00000000..b2a26365 Binary files /dev/null and b/docs/reference/resistance_predict-1.png differ diff --git a/docs/reference/resistance_predict-2.png b/docs/reference/resistance_predict-2.png new file mode 100644 index 00000000..480a216a Binary files /dev/null and b/docs/reference/resistance_predict-2.png differ diff --git a/docs/reference/resistance_predict-3.png b/docs/reference/resistance_predict-3.png new file mode 100644 index 00000000..9b805897 Binary files /dev/null and b/docs/reference/resistance_predict-3.png differ diff --git a/index.md b/index.md index 97db68e4..c2352576 100644 --- a/index.md +++ b/index.md @@ -18,7 +18,7 @@ We created this package for both routine analysis and academic research (as part

Used in over 70 countries
- Since its first public release in early 2018, this package has been downloaded over 25,000 times from 75 countries (as of November 2019, CRAN logs). Click the map to enlarge.



+ Since its first public release in early 2018, this package has been downloaded over 25,000 times from 78 countries (as of December 2019, CRAN logs). Click the map to enlarge.



#### Partners @@ -80,7 +80,7 @@ Developers #### Latest released version -This package is available [on the official R network (CRAN)](https://cran.r-project.org/package=AMR), which has a peer-reviewed submission process. Install this package in R with: +This package is available [here on the official R network (CRAN)](https://cran.r-project.org/package=AMR), which has a peer-reviewed submission process. Install this package in R from CRAN by using the command: ```r install.packages("AMR") diff --git a/pkgdown/logos/countries.png b/pkgdown/logos/countries.png index f0424ce4..441f09d7 100644 Binary files a/pkgdown/logos/countries.png and b/pkgdown/logos/countries.png differ