From 13120f465f84a21af85ec60ed3071f8e617f6665 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Wed, 20 Feb 2019 13:57:23 +0100 Subject: [PATCH] website update --- DESCRIPTION | 4 +- R/catalogue_of_life.R | 4 +- README.md | 3 +- docs/articles/AMR.html | 1014 ++++++++--------- .../AMR_files/figure-html/plot 1-1.png | Bin 33724 -> 33736 bytes .../AMR_files/figure-html/plot 3-1.png | Bin 21109 -> 21123 bytes .../AMR_files/figure-html/plot 4-1.png | Bin 69620 -> 69624 bytes .../AMR_files/figure-html/plot 5-1.png | Bin 51370 -> 51370 bytes docs/articles/benchmarks.html | 175 +-- .../figure-html/unnamed-chunk-4-1.png | Bin 31454 -> 31518 bytes .../figure-html/unnamed-chunk-4-2.png | Bin 33495 -> 33318 bytes docs/index.html | 19 +- docs/reference/as.mo.html | 4 +- docs/reference/catalogue_of_life.html | 4 +- docs/reference/catalogue_of_life_version.html | 4 +- docs/reference/microorganisms.codes.html | 4 +- docs/reference/microorganisms.html | 4 +- docs/reference/microorganisms.old.html | 4 +- docs/reference/mo_property.html | 4 +- index.md | 18 +- man/as.mo.Rd | 4 +- man/catalogue_of_life.Rd | 4 +- man/catalogue_of_life_version.Rd | 4 +- man/microorganisms.Rd | 4 +- man/microorganisms.codes.Rd | 4 +- man/microorganisms.old.Rd | 4 +- man/mo_property.Rd | 4 +- vignettes/benchmarks.Rmd | 52 +- 28 files changed, 661 insertions(+), 684 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f7d59cd2..d82496bb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -48,15 +48,15 @@ Imports: crayon (>= 1.3.0), data.table (>= 1.9.0), dplyr (>= 0.7.0), + ggplot2, hms, knitr (>= 1.0.0), + microbenchmark, rlang (>= 0.2.0), tidyr (>= 0.7.0) Suggests: covr (>= 3.0.1), curl, - ggplot2, - microbenchmark, readxl, rmarkdown, rstudioapi, diff --git a/R/catalogue_of_life.R b/R/catalogue_of_life.R index 30e9f626..480ab496 100755 --- a/R/catalogue_of_life.R +++ b/R/catalogue_of_life.R @@ -29,8 +29,8 @@ #' Included are: #' \itemize{ #' \item{All ~55,000 (sub)species from the kingdoms of Archaea, Bacteria, Protozoa and Viruses} -#' \item{All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different species, of which most are not microbial. Including everything tremendously slows down our algortihms, and not all fungi fit the scope of this package. By only including the aforementioned taxonomic orders, the most relevant species are covered (like genera \emph{Aspergillus}, \emph{Candida}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} -#' \item{All ~15,000 previously accepted names of inckuded (sub)species that have been taxonomically renamed} +#' \item{All ~3,000 (sub)species from these orders of the kingdom of Fungi: Eurotiales, Onygenales, Pneumocystales, Saccharomycetales and Schizosaccharomycetales. The kingdom of Fungi is a very large taxon with almost 300,000 different (sub)species, of which most are not microbial (but rather macroscopic, like mushrooms). Because of this, not all fungi fit the scope of this package and including everything would tremendously slow down our algorithms too. By only including the aforementioned taxonomic orders, the most relevant (sub)species are covered (like all species of \emph{Aspergillus}, \emph{Candida}, \emph{Pneumocystis}, \emph{Saccharomyces} and \emph{Trichophyton}).} +#' \item{All ~15,000 previously accepted names of included (sub)species that have been taxonomically renamed} #' \item{The complete taxonomic tree of all included (sub)species: from kingdom to subspecies} #' \item{The responsible author(s) and year of scientific publication} #' } diff --git a/README.md b/README.md index 8c69270c..ad6a632e 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# AMR (for R) +% AMR (for R) + ### Not a developer? Then please visit our website [https://msberends.gitlab.io/AMR](https://msberends.gitlab.io/AMR) to read about this package. diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 1e382202..839a1db4 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -1,75 +1,35 @@ - - - - + + + + - How to conduct AMR analysis • AMR (for R) - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - + +
-
- + +
+ + + - - - -
+
-

Resistance percentages

+

+Resistance percentages

The functions portion_R, portion_RI, portion_I, portion_IS and portion_S can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:

- -

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

+ +

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

- - - + group_by(hospital) %>% + summarise(amoxicillin =portion_IR(amox)) +
+ - - + - + - + - + - +
hospital amoxicillin
Hospital A0.47356080.4792724
Hospital B0.47085040.4777657
Hospital C0.47797650.4674139
Hospital D0.47622010.4796148
-

Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the n_rsi() can be used, which works exactly like n_distinct() from the dplyr package. It counts all isolates available for every group (i.e. values S, I or R):

+

Of course it would be very convenient to know the number of isolates responsible for the percentages. For that purpose the n_rsi() can be used, which works exactly like n_distinct() from the dplyr package. It counts all isolates available for every group (i.e. values S, I or R):

- - - + group_by(hospital) %>% + summarise(amoxicillin =portion_IR(amox), + available = n_rsi(amox)) +
+ - - + - - + + - - + + - - + + - - + +
hospital amoxicillin available
Hospital A0.473560846900.47927244728
Hospital B0.470850456090.47776575532
Hospital C0.477976522930.46741392409
Hospital D0.476220132170.47961483115

These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily:

- - - + group_by(genus) %>% + summarise(amoxicillin =portion_S(amcl), + gentamicin = portion_S(gent), + "amox + gent" = portion_S(amcl, gent)) +
+ - - + - - - + + + - - - + + + - - - + + + - + - +
genus amoxicillin gentamicin amox + gent
Escherichia0.73228550.90074790.97515530.73210610.90139030.9751545
Klebsiella0.73523690.89941600.97598960.73680780.90162870.9687296
Staphylococcus0.72408460.91877260.97447140.73785430.91649800.9792510
Streptococcus0.74170330.7406089 0.00000000.74170330.7406089

To make a transition to the next part, let’s see how this difference could be plotted:

-

+ geom_col(position = "dodge2")
+

-

Plots

+

+Plots

To show results in plots, most R users would nowadays use the ggplot2 package. This package lets you create plots in layers. You can read more about it on their website. A quick example would look like these syntaxes:

-
ggplot(data = a_data_set,
-       mapping = aes(x = year,
+
-

The AMR package contains functions to extend this ggplot2 package, for example geom_rsi(). It automatically transforms data with count_df() or portion_df() and show results in stacked bars. Its simplest and shortest example:

- -

+ggplot(a_data_set, + aes(year, value) + + geom_bar()
+

The AMR package contains functions to extend this ggplot2 package, for example geom_rsi(). It automatically transforms data with count_df() or portion_df() and show results in stacked bars. Its simplest and shortest example:

+
ggplot(data_1st) +
+  geom_rsi(translate_ab = FALSE)
+

Omit the translate_ab = FALSE to have the antibiotic codes (amox, amcl, cipr, gent) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, ciprofloxacin, gentamicin).

If we group on e.g. the genus column and add some additional functions from our package, we can create this:

-

-

To simplify this, we also created the ggplot_rsi() function, which combines almost all above functions:

+ theme(axis.text.y = element_text(face = "italic"))
+

+

To simplify this, we also created the ggplot_rsi() function, which combines almost all above functions:

-

+ coord_flip()
+

-

Independence test

+

+Independence test

The next example uses the included septic_patients, which is an anonymised data set containing 2,000 microbial blood culture isolates with their full antibiograms found in septic patients in 4 different hospitals in the Netherlands, between 2001 and 2017. It is true, genuine data. This data.frame can be used to practice AMR analysis.

-

We will compare the resistance to fosfomycin (column fosf) in hospital A and D. The input for the final fisher.test() will be this:

- - - +

We will compare the resistance to fosfomycin (column fosf) in hospital A and D. The input for the final fisher.test() will be this:

+
+ - - + @@ -1211,16 +1166,16 @@ Longest: 24

A D
IR

We can transform the data and apply the test in only a couple of lines:

septic_patients %>%
-  filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
-  select(hospital_id, fosf) %>%            # select the hospitals and fosfomycin
-  group_by(hospital_id) %>%                # group on the hospitals
-  count_df(combine_IR = TRUE) %>%          # count all isolates per group (hospital_id)
-  tidyr::spread(hospital_id, Value) %>%    # transform output so A and D are columns
-  select(A, D) %>%                         # and select these only
-  as.matrix() %>%                          # transform to good old matrix for fisher.test()
-  fisher.test()                            # do Fisher's Exact Test
+  filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
+  select(hospital_id, fosf) %>%            # select the hospitals and fosfomycin
+  group_by(hospital_id) %>%                # group on the hospitals
+  count_df(combine_IR = TRUE) %>%          # count all isolates per group (hospital_id)
+  tidyr::spread(hospital_id, Value) %>%    # transform output so A and D are columns
+  select(A, D) %>%                         # and select these only
+  as.matrix() %>%                          # transform to good old matrix for fisher.test()
+  fisher.test()                            # do Fisher's Exact Test
 #> 
-#>  Fisher's Exact Test for Count Data
+#>  Fisher's Exact Test for Count Data
 #> 
 #> data:  .
 #> p-value = 0.03104
@@ -1237,49 +1192,56 @@ Longest: 24

-