diff --git a/DESCRIPTION b/DESCRIPTION index 1301addbc..d1a8740a8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.0.1.9009 +Version: 1.1.0 Date: 2020-04-15 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 17aa8447d..4a3a83cce 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.0.1.9009 -## Last updated: 15-Apr-2020 +# AMR 1.1.0 + ### New * Support for easy principal component analysis for AMR, using the new `pca()` function diff --git a/cran-comments.md b/cran-comments.md index e9a2b76f3..d5de3b057 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,5 +1,5 @@ -# Version 0.10.0 +* Although the previous release (1.0.1) is from 2020-02-23, this updates provides support for the upcoming dplyr 1.0.0 which is used (and relied upon) by probably all our users. -* For this specific version, nothing to mention. +* For this specific version, otherwise nothing to mention. * Since version 0.3.0, CHECK returns a NOTE for having a data directory over 3 MB. This is needed to offer users reference data for the complete taxonomy of microorganisms - one of the most important features of this package. diff --git a/docs/404.html b/docs/404.html index fa9c9687d..c4ecb7f2b 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index f5bcbc645..46baee58e 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 912a95ee3..48eb7097a 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
-

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 17 March 2020.

+

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

Introduction

@@ -225,21 +226,21 @@ -2020-03-17 +2020-04-15 abcd Escherichia coli S S -2020-03-17 +2020-04-15 abcd Escherichia coli S R -2020-03-17 +2020-04-15 efgh Escherichia coli R @@ -252,12 +253,12 @@ Needed R packages

As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the tidyverse packages dplyr and ggplot2 by Dr Hadley Wickham. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.

Our AMR package depends on these packages and even extends their use and functions.

-
library(dplyr)
-library(ggplot2)
-library(AMR)
-
-# (if not yet installed, install with:)
-# install.packages(c("tidyverse", "AMR"))
+
library(dplyr)
+library(ggplot2)
+library(AMR)
+
+# (if not yet installed, install with:)
+# install.packages(c("tidyverse", "AMR"))
@@ -269,57 +270,57 @@

Patients

To start with patients, we need a unique list of patients.

-
patients <- unlist(lapply(LETTERS, paste0, 1:10))
+
patients <- unlist(lapply(LETTERS, paste0, 1:10))

The LETTERS object is available in R - it’s a vector with 26 characters: A to Z. The patients object we just created is now a vector of length 260, with values (patient IDs) varying from A1 to Z10. Now we we also set the gender of our patients, by putting the ID and the gender in a table:

-
patients_table <- data.frame(patient_id = patients,
-                             gender = c(rep("M", 135),
-                                        rep("F", 125)))
+
patients_table <- data.frame(patient_id = patients,
+                             gender = c(rep("M", 135),
+                                        rep("F", 125)))

The first 135 patient IDs are now male, the other 125 are female.

Dates

Let’s pretend that our data consists of blood cultures isolates from between 1 January 2010 and 1 January 2018.

-
dates <- seq(as.Date("2010-01-01"), as.Date("2018-01-01"), by = "day")
+
dates <- seq(as.Date("2010-01-01"), as.Date("2018-01-01"), by = "day")

This dates object now contains all days in our date range.

Microorganisms

For this tutorial, we will uses four different microorganisms: Escherichia coli, Staphylococcus aureus, Streptococcus pneumoniae, and Klebsiella pneumoniae:

-
bacteria <- c("Escherichia coli", "Staphylococcus aureus",
-              "Streptococcus pneumoniae", "Klebsiella pneumoniae")
+
bacteria <- c("Escherichia coli", "Staphylococcus aureus",
+              "Streptococcus pneumoniae", "Klebsiella pneumoniae")

Other variables

For completeness, we can also add the hospital where the patients was admitted and we need to define valid antibmicrobial results for our randomisation:

-
hospitals <- c("Hospital A", "Hospital B", "Hospital C", "Hospital D")
-ab_interpretations <- c("S", "I", "R")
+
hospitals <- c("Hospital A", "Hospital B", "Hospital C", "Hospital D")
+ab_interpretations <- c("S", "I", "R")

Put everything together

Using the sample() function, we can randomly select items from all objects we defined earlier. To let our fake data reflect reality a bit, we will also approximately define the probabilities of bacteria and the antibiotic results with the prob parameter.

-
sample_size <- 20000
-data <- data.frame(date = sample(dates, size = sample_size, replace = TRUE),
-                   patient_id = sample(patients, size = sample_size, replace = TRUE),
-                   hospital = sample(hospitals, size = sample_size, replace = TRUE,
-                                     prob = c(0.30, 0.35, 0.15, 0.20)),
-                   bacteria = sample(bacteria, size = sample_size, replace = TRUE,
-                                     prob = c(0.50, 0.25, 0.15, 0.10)),
-                   AMX = sample(ab_interpretations, size = sample_size, replace = TRUE,
-                                 prob = c(0.60, 0.05, 0.35)),
-                   AMC = sample(ab_interpretations, size = sample_size, replace = TRUE,
-                                 prob = c(0.75, 0.10, 0.15)),
-                   CIP = sample(ab_interpretations, size = sample_size, replace = TRUE,
-                                 prob = c(0.80, 0.00, 0.20)),
-                   GEN = sample(ab_interpretations, size = sample_size, replace = TRUE,
-                                 prob = c(0.92, 0.00, 0.08)))
+
sample_size <- 20000
+data <- data.frame(date = sample(dates, size = sample_size, replace = TRUE),
+                   patient_id = sample(patients, size = sample_size, replace = TRUE),
+                   hospital = sample(hospitals, size = sample_size, replace = TRUE,
+                                     prob = c(0.30, 0.35, 0.15, 0.20)),
+                   bacteria = sample(bacteria, size = sample_size, replace = TRUE,
+                                     prob = c(0.50, 0.25, 0.15, 0.10)),
+                   AMX = sample(ab_interpretations, size = sample_size, replace = TRUE,
+                                 prob = c(0.60, 0.05, 0.35)),
+                   AMC = sample(ab_interpretations, size = sample_size, replace = TRUE,
+                                 prob = c(0.75, 0.10, 0.15)),
+                   CIP = sample(ab_interpretations, size = sample_size, replace = TRUE,
+                                 prob = c(0.80, 0.00, 0.20)),
+                   GEN = sample(ab_interpretations, size = sample_size, replace = TRUE,
+                                 prob = c(0.92, 0.00, 0.08)))

Using the left_join() function from the dplyr package, we can ‘map’ the gender to the patient ID using the patients_table object we created earlier:

-
data <- data %>% left_join(patients_table)
+
data <- data %>% left_join(patients_table)

The resulting data set contains 20,000 blood culture isolates. With the head() function we can preview the first 6 rows of this data set:

-
head(data)
+
head(data)
@@ -334,21 +335,43 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + @@ -356,49 +379,27 @@ - - - - - + + + + + - - - - - - - - - - - - - + + - + - - - - - - - - - - -
date
2013-12-05H6Hospital B2015-12-27Y9Hospital A Escherichia coliRRSSF
2014-01-17X10Hospital CStaphylococcus aureusR S RSF
2015-10-31I3Hospital BEscherichia coli R SSS M
2015-04-13I32014-10-30D9 Hospital AStaphylococcus aureusEscherichia coli S S SM
2011-10-12Z1Hospital CKlebsiella pneumoniaeR2011-02-15P6Hospital DEscherichia coliS S S S F
2011-11-05D1Hospital BEscherichia coliRSRSM
2017-12-28B72011-10-07G2 Hospital CEscherichia coliStaphylococcus aureus S S S S M
2012-07-25F8Hospital DEscherichia coliSRSRM

Now, let’s start the cleaning and the analysis!

@@ -409,7 +410,7 @@ Cleaning the data

We also created a package dedicated to data cleaning and checking, called the cleaner package. It gets automatically installed with the AMR package. For its freq() function to create frequency tables, you don’t even need to load it yourself as it is available through the AMR package as well.

For example, for the gender variable:

-
data %>% freq(gender) # this would be the same: freq(data$gender)
+
data %>% freq(gender) # this would be the same: freq(data$gender)

Frequency table

Class: factor (numeric)
Length: 20,000
@@ -429,16 +430,16 @@ Unique: 2

1 M -10,489 -52.45% -10,489 -52.45% +10,277 +51.39% +10,277 +51.39% 2 F -9,511 -47.56% +9,723 +48.62% 20,000 100.00% @@ -446,23 +447,23 @@ Unique: 2

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 %>%
-  mutate(bacteria = as.mo(bacteria))
+
data <- data %>%
+  mutate(bacteria = as.mo(bacteria))

We also want to transform the antibiotics, because in real life data we don’t know if they are really clean. The as.rsi() function ensures reliability and reproducibility in these kind of variables. The mutate_at() will run the as.rsi() function on defined variables:

-
data <- data %>%
-  mutate_at(vars(AMX:GEN), as.rsi)
+
data <- data %>%
+  mutate_at(vars(AMX:GEN), as.rsi)

Finally, we will apply EUCAST rules on our antimicrobial results. In Europe, most medical microbiological laboratories already apply these rules. Our package features their latest insights on intrinsic resistance and exceptional phenotypes. Moreover, the eucast_rules() function can also apply additional rules, like forcing ampicillin = R when amoxicillin/clavulanic acid = R.

Because the amoxicillin (column AMX) and amoxicillin/clavulanic acid (column AMC) in our data were generated randomly, some rows will undoubtedly contain AMX = S and AMC = R, which is technically impossible. The eucast_rules() fixes this:

-
data <- eucast_rules(data, col_mo = "bacteria")
+
data <- eucast_rules(data, col_mo = "bacteria")

Adding new variables

Now that we have the microbial ID, we can add some taxonomic properties:

-
data <- data %>% 
-  mutate(gramstain = mo_gramstain(bacteria),
-         genus = mo_genus(bacteria),
-         species = mo_species(bacteria))
+
data <- data %>%
+  mutate(gramstain = mo_gramstain(bacteria),
+         genus = mo_genus(bacteria),
+         species = mo_species(bacteria))

First isolates

@@ -473,22 +474,22 @@ Unique: 2

(…) When preparing a cumulative antibiogram to guide clinical decisions about empirical antimicrobial therapy of initial infections, only the first isolate of a given species per patient, per analysis period (eg, one year) should be included, irrespective of body site, antimicrobial susceptibility profile, or other phenotypical characteristics (eg, biotype). The first isolate is easily identified, and cumulative antimicrobial susceptibility test data prepared using the first isolate are generally comparable to cumulative antimicrobial susceptibility test data calculated by other methods, providing duplicate isolates are excluded.
M39-A4 Analysis and Presentation of Cumulative Antimicrobial Susceptibility Test Data, 4th Edition. CLSI, 2014. Chapter 6.4

This AMR package includes this methodology with the first_isolate() function. It adopts the episode of a year (can be changed by user) and it starts counting days after every selected isolate. This new variable can easily be added to our data:

-
data <- data %>% 
-  mutate(first = first_isolate(.))
-# 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`.
-

So only 28.5% 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)
+
data <- data %>%
+  mutate(first = first_isolate(.))
+# 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`.
+

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)

For future use, the above two syntaxes can be shortened with the filter_first_isolate() function:

-
data_1st <- data %>% 
-  filter_first_isolate()
+
data_1st <- data %>%
+  filter_first_isolate()

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 A2, 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 R8, sorted on date:

@@ -504,10 +505,10 @@ Unique: 2

- - + + - + @@ -515,8 +516,8 @@ Unique: 2

- - + + @@ -526,10 +527,10 @@ Unique: 2

- - + + - + @@ -537,10 +538,10 @@ Unique: 2

- - + + - + @@ -548,8 +549,8 @@ Unique: 2

- - + + @@ -559,71 +560,71 @@ Unique: 2

- - + + + - - + - - + + - - - + + + - - + + - + - - + + - + - - + + - - - - + + + +
isolate
12010-01-14A22010-03-01R8 B_ESCHR_COLISR S S S
22010-06-29A22010-04-16R8 B_ESCHR_COLI S S
32010-07-21A22010-04-18R8 B_ESCHR_COLIRS S S S
42010-08-18A22010-05-08R8 B_ESCHR_COLIIR S S S
52010-11-16A22010-06-06R8 B_ESCHR_COLI S S
62011-01-29A22010-06-14R8 B_ESCHR_COLI RR S SSTRUEFALSE
72011-03-30A22010-07-28R8 B_ESCHR_COLIRRRSSS S FALSE
82011-04-08A22010-07-31R8 B_ESCHR_COLI S SRS S FALSE
92011-05-09A22010-08-25R8 B_ESCHR_COLI S SRS S FALSE
102011-07-16A22010-09-30R8 B_ESCHR_COLISSSSRRRR FALSE
-

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(.)) %>% 
-  mutate(first_weighted = first_isolate(.))
-# NOTE: Using column `bacteria` as input for `col_mo`.
-# 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`.
-# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
+
data <- data %>%
+  mutate(keyab = key_antibiotics(.)) %>%
+  mutate(first_weighted = first_isolate(.))
+# NOTE: Using column `bacteria` as input for `col_mo`.
+# 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`.
+# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
@@ -640,10 +641,10 @@ Unique: 2

- - + + - + @@ -652,124 +653,124 @@ Unique: 2

- - + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - - + + + - - + + - + - + - - + + - + - - + + - - - - + + + +
isolate
12010-01-14A22010-03-01R8 B_ESCHR_COLISR S S S
22010-06-29A22010-04-16R8 B_ESCHR_COLI S S S S FALSEFALSETRUE
32010-07-21A22010-04-18R8 B_ESCHR_COLIRS S S S FALSETRUEFALSE
42010-08-18A2B_ESCHR_COLIISSSFALSEFALSE
52010-11-16A2B_ESCHR_COLISSSSFALSEFALSE
62011-01-29A22010-05-08R8 B_ESCHR_COLI R S S SFALSE TRUE
52010-06-06R8B_ESCHR_COLISSSSFALSETRUE
62010-06-14R8B_ESCHR_COLIRRSSFALSE TRUE
72011-03-30A22010-07-28R8 B_ESCHR_COLIRRRSSS S FALSE TRUE
82011-04-08A22010-07-31R8 B_ESCHR_COLI S SRS S FALSETRUEFALSE
92011-05-09A22010-08-25R8 B_ESCHR_COLI S SRS S FALSE FALSE
102011-07-16A22010-09-30R8 B_ESCHR_COLISSSSRRRR FALSE TRUE
-

Instead of 2, now 6 isolates are flagged. In total, 75.8% of all isolates are marked ‘first weighted’ - 47.3% 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 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.

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,159 isolates for analysis.

+
data_1st <- data %>%
+  filter_first_weighted_isolate()
+

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

We can remove unneeded columns:

-
data_1st <- data_1st %>% 
-  select(-c(first, keyab))
+
data_1st <- data_1st %>%
+  select(-c(first, keyab))

Now our data looks like:

-
head(data_1st)
+
head(data_1st)
@@ -788,14 +789,44 @@ Unique: 2

- - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -803,9 +834,39 @@ Unique: 2

- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -817,66 +878,6 @@ Unique: 2

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
date
2013-12-05H6Hospital B2015-12-27Y9Hospital A B_ESCHR_COLIRR S SFGram-negativeEscherichiacoliTRUE
2014-01-17X10Hospital CB_STPHY_AURSRS R SFGram-positiveStaphylococcusaureusTRUE
2015-10-31I3Hospital BB_ESCHR_COLIRSSS M Gram-negative Escherichia TRUE
2015-04-13I32014-10-30D9 Hospital AB_ESCHR_COLISSSSMGram-negativeEscherichiacoliTRUE
2011-02-15P6Hospital DB_ESCHR_COLISSSSFGram-negativeEscherichiacoliTRUE
2011-10-07G2Hospital C B_STPHY_AURS S S aureus TRUE
2011-10-12Z1Hospital CB_KLBSL_PNMNRSSSFGram-negativeKlebsiellapneumoniaeTRUE
2011-11-05D1Hospital BB_ESCHR_COLIRSRSMGram-negativeEscherichiacoliTRUE
2017-12-28B7Hospital CB_ESCHR_COLISSSSMGram-negativeEscherichiacoliTRUE
2012-07-25F8Hospital DB_ESCHR_COLISSSRMGram-negativeEscherichiacoliTRUE

Time for the analysis!

@@ -891,13 +892,13 @@ Unique: 2

Dispersion of species

To just get an idea how the species are distributed, create a frequency table with our freq() function. We created the genus and species column earlier based on the microbial ID. With paste(), we can concatenate them together.

The freq() function can be used like the base R language was intended:

-
freq(paste(data_1st$genus, data_1st$species))
+
freq(paste(data_1st$genus, data_1st$species))

Or can be used like the dplyr way, which is easier readable:

-
data_1st %>% freq(genus, species)
+
data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 15,159
-Available: 15,159 (100%, NA: 0 = 0%)
+Length: 15,034
+Available: 15,034 (100%, NA: 0 = 0%)
Unique: 4

Shortest: 16
Longest: 24

@@ -914,33 +915,33 @@ Longest: 24

1 Escherichia coli -7,543 -49.76% -7,543 -49.76% +7,486 +49.79% +7,486 +49.79% 2 Staphylococcus aureus -3,783 -24.96% -11,326 -74.71% +3,727 +24.79% +11,213 +74.58% 3 Streptococcus pneumoniae -2,316 -15.28% -13,642 -89.99% +2,273 +15.12% +13,486 +89.70% 4 Klebsiella pneumoniae -1,517 -10.01% -15,159 +1,548 +10.30% +15,034 100.00% @@ -951,12 +952,12 @@ Longest: 24

Resistance percentages

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.4593311
+
data_1st %>% resistance(AMX)
+# [1] 0.4703339

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

-
data_1st %>% 
-  group_by(hospital) %>% 
-  summarise(amoxicillin = resistance(AMX))
+
data_1st %>%
+  group_by(hospital) %>%
+  summarise(amoxicillin = resistance(AMX))
@@ -965,27 +966,27 @@ Longest: 24

- + - + - + - +
hospital
Hospital A0.45541260.4760956
Hospital B0.46195860.4711409
Hospital C0.45661700.4700967
Hospital D0.46256950.4605220

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):

-
data_1st %>% 
-  group_by(hospital) %>% 
-  summarise(amoxicillin = resistance(AMX),
-            available = n_rsi(AMX))
+
data_1st %>%
+  group_by(hospital) %>%
+  summarise(amoxicillin = resistance(AMX),
+            available = n_rsi(AMX))
@@ -995,32 +996,32 @@ Longest: 24

- - + + - - + + - - + + - - + +
hospital
Hospital A0.455412645080.47609564518
Hospital B0.461958653100.47114095215
Hospital C0.456617022820.47009672274
Hospital D0.462569530590.46052203027

These functions can also be used to get the proportion of multiple antibiotics, to calculate empiric susceptibility of combination therapies very easily:

-
data_1st %>% 
-  group_by(genus) %>% 
-  summarise(amoxiclav = susceptibility(AMC),
-            gentamicin = susceptibility(GEN),
-            amoxiclav_genta = susceptibility(AMC, GEN))
+
data_1st %>%
+  group_by(genus) %>%
+  summarise(amoxiclav = susceptibility(AMC),
+            gentamicin = susceptibility(GEN),
+            amoxiclav_genta = susceptibility(AMC, GEN))
@@ -1031,95 +1032,95 @@ Longest: 24

- - - + + + - - - + + + - - - + + + - + - +
genus
Escherichia0.92416810.89327850.99350390.91811380.89473680.9927865
Klebsiella0.92155570.90046140.99538560.91537470.89599480.9948320
Staphylococcus0.91884750.92545600.99392020.92460420.92031120.9946338
Streptococcus0.61787560.6159261 0.00000000.61787560.6159261

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

-
data_1st %>% 
-  group_by(genus) %>% 
-  summarise("1. Amoxi/clav" = susceptibility(AMC),
-            "2. Gentamicin" = susceptibility(GEN),
-            "3. Amoxi/clav + genta" = susceptibility(AMC, GEN)) %>% 
-  # pivot_longer() from the tidyr package "lengthens" data:
-  tidyr::pivot_longer(-genus, names_to = "antibiotic") %>% 
-  ggplot(aes(x = genus,
-             y = value,
-             fill = antibiotic)) +
-  geom_col(position = "dodge2")
+
data_1st %>%
+  group_by(genus) %>%
+  summarise("1. Amoxi/clav" = susceptibility(AMC),
+            "2. Gentamicin" = susceptibility(GEN),
+            "3. Amoxi/clav + genta" = susceptibility(AMC, GEN)) %>%
+  # pivot_longer() from the tidyr package "lengthens" data:
+  tidyr::pivot_longer(-genus, names_to = "antibiotic") %>%
+  ggplot(aes(x = genus,
+             y = value,
+             fill = antibiotic)) +
+  geom_col(position = "dodge2")

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,
-                     y = value)) +
-  geom_col() +
-  labs(title = "A title",
-       subtitle = "A subtitle",
-       x = "My X axis",
-       y = "My Y axis")
-
-# or as short as:
-ggplot(a_data_set) +
-  geom_bar(aes(year))
+
ggplot(data = a_data_set,
+       mapping = aes(x = year,
+                     y = value)) +
+  geom_col() +
+  labs(title = "A title",
+       subtitle = "A subtitle",
+       x = "My X axis",
+       y = "My Y axis")
+
+# or as short as:
+ggplot(a_data_set) +
+  geom_bar(aes(year))

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

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

Omit the translate_ab = FALSE to have the antibiotic codes (AMX, AMC, CIP, GEN) translated to official WHO names (amoxicillin, amoxicillin/clavulanic acid, ciprofloxacin, gentamicin).

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

-
# group the data on `genus`
-ggplot(data_1st %>% group_by(genus)) + 
-  # create bars with genus on x axis
-  # it looks for variables with class `rsi`,
-  # of which we have 4 (earlier created with `as.rsi`)
-  geom_rsi(x = "genus") + 
-  # split plots on antibiotic
-  facet_rsi(facet = "antibiotic") +
-  # set colours to the R/SI interpretations
-  scale_rsi_colours() +
-  # show percentages on y axis
-  scale_y_percent(breaks = 0:4 * 25) +
-  # turn 90 degrees, to make it bars instead of columns
-  coord_flip() +
-  # add labels
-  labs(title = "Resistance per genus and antibiotic", 
-       subtitle = "(this is fake data)") +
-  # and print genus in italic to follow our convention
-  # (is now y axis because we turned the plot)
-  theme(axis.text.y = element_text(face = "italic"))
+
# group the data on `genus`
+ggplot(data_1st %>% group_by(genus)) +
+  # create bars with genus on x axis
+  # it looks for variables with class `rsi`,
+  # of which we have 4 (earlier created with `as.rsi`)
+  geom_rsi(x = "genus") +
+  # split plots on antibiotic
+  facet_rsi(facet = "antibiotic") +
+  # set colours to the R/SI interpretations
+  scale_rsi_colours() +
+  # show percentages on y axis
+  scale_y_percent(breaks = 0:4 * 25) +
+  # turn 90 degrees, to make it bars instead of columns
+  coord_flip() +
+  # add labels
+  labs(title = "Resistance per genus and antibiotic",
+       subtitle = "(this is fake data)") +
+  # and print genus in italic to follow our convention
+  # (is now y axis because we turned the plot)
+  theme(axis.text.y = element_text(face = "italic"))

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

-
data_1st %>% 
-  group_by(genus) %>%
-  ggplot_rsi(x = "genus",
-             facet = "antibiotic",
-             breaks = 0:4 * 25,
-             datalabels = FALSE) +
-  coord_flip()
+
data_1st %>%
+  group_by(genus) %>%
+  ggplot_rsi(x = "genus",
+             facet = "antibiotic",
+             breaks = 0:4 * 25,
+             datalabels = FALSE) +
+  coord_flip()

@@ -1127,38 +1128,38 @@ Longest: 24

Independence test

The next example uses the example_isolates data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis.

We will compare the resistance to fosfomycin (column FOS) in hospital A and D. The input for the fisher.test() can be retrieved with a transformation like this:

-
# use package 'tidyr' to pivot data; 
-# it gets installed with this 'AMR' package
-library(tidyr)
-
-check_FOS <- example_isolates %>%
-  filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
-  select(hospital_id, FOS) %>%             # select the hospitals and fosfomycin
-  group_by(hospital_id) %>%                # group on the hospitals
-  count_df(combine_SI = TRUE) %>%          # count all isolates per group (hospital_id)
-  pivot_wider(names_from = hospital_id,    # transform output so A and D are columns
-              values_from = value) %>%     
-  select(A, D) %>%                         # and only select these columns
-  as.matrix()                              # transform to a good old matrix for fisher.test()
-
-check_FOS
-#       A  D
-# [1,] 25 77
-# [2,] 24 33
+
# use package 'tidyr' to pivot data; 
+# it gets installed with this 'AMR' package
+library(tidyr)
+
+check_FOS <- example_isolates %>%
+  filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
+  select(hospital_id, FOS) %>%             # select the hospitals and fosfomycin
+  group_by(hospital_id) %>%                # group on the hospitals
+  count_df(combine_SI = TRUE) %>%          # count all isolates per group (hospital_id)
+  pivot_wider(names_from = hospital_id,    # transform output so A and D are columns
+              values_from = value) %>%
+  select(A, D) %>%                         # and only select these columns
+  as.matrix()                              # transform to a good old matrix for fisher.test()
+
+check_FOS
+#       A  D
+# [1,] 25 77
+# [2,] 24 33

We can apply the test now with:

-
# do Fisher's Exact Test
-fisher.test(check_FOS)                            
-# 
-#   Fisher's Exact Test for Count Data
-# 
-# data:  check_FOS
-# p-value = 0.03104
-# alternative hypothesis: true odds ratio is not equal to 1
-# 95 percent confidence interval:
-#  0.2111489 0.9485124
-# sample estimates:
-# odds ratio 
-#  0.4488318
+
# do Fisher's Exact Test
+fisher.test(check_FOS)
+# 
+#   Fisher's Exact Test for Count Data
+# 
+# data:  check_FOS
+# p-value = 0.03104
+# alternative hypothesis: true odds ratio is not equal to 1
+# 95 percent confidence interval:
+#  0.2111489 0.9485124
+# sample estimates:
+# odds ratio 
+#  0.4488318

As can be seen, the p value is 0.031, which means that the fosfomycin resistance found in hospital A and D are really different.

@@ -1166,42 +1167,9 @@ Longest: 24

@@ -1212,7 +1180,7 @@ Longest: 24

-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

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 83f55f8a5..5298c6f7d 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 728e1e251..5ad3aab90 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 17839ce67..5bf6110d0 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 7b8f8accd..b8180a53f 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 2e2ef10ad..ff4e8d268 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
@@ -208,33 +209,33 @@ Examples

These rules can be used to discard impossible bug-drug combinations in your data. For example, Klebsiella produces beta-lactamase that prevents ampicillin (or amoxicillin) from working against it. In other words, practically every strain of Klebsiella is resistant to ampicillin.

Sometimes, laboratory data can still contain such strains with ampicillin being susceptible to ampicillin. This could be because an antibiogram is available before an identification is available, and the antibiogram is then not re-interpreted based on the identification (namely, Klebsiella). EUCAST expert rules solve this, that can be used with eucast_rules():

-
oops <- data.frame(mo = c("Klebsiella", 
-                          "Escherichia"),
-                   ampicillin = "S")
-oops
-#            mo ampicillin
-# 1  Klebsiella          S
-# 2 Escherichia          S
-
-eucast_rules(oops, info = FALSE)
-#            mo ampicillin
-# 1  Klebsiella          R
-# 2 Escherichia          S
+
oops <- data.frame(mo = c("Klebsiella",
+                          "Escherichia"),
+                   ampicillin = "S")
+oops
+#            mo ampicillin
+# 1  Klebsiella          S
+# 2 Escherichia          S
+
+eucast_rules(oops, info = FALSE)
+#            mo ampicillin
+# 1  Klebsiella          R
+# 2 Escherichia          S

EUCAST rules can not only be used for correction, they can also be used for filling in known resistance and susceptibility based on results of other antimicrobials drugs. This process is called interpretive reading and is part of the eucast_rules() function as well:

-
data <- data.frame(mo = c("Staphylococcus aureus",
-                          "Enterococcus faecalis",
-                          "Escherichia coli",
-                          "Klebsiella pneumoniae",
-                          "Pseudomonas aeruginosa"),
-                   VAN = "-",       # Vancomycin
-                   AMX = "-",       # Amoxicillin
-                   COL = "-",       # Colistin
-                   CAZ = "-",       # Ceftazidime
-                   CXM = "-",       # Cefuroxime
-                   PEN = "S",       # Penicillin G
-                   FOX = "S",       # Cefoxitin
-                   stringsAsFactors = FALSE)
-
data
+
data <- data.frame(mo = c("Staphylococcus aureus",
+                          "Enterococcus faecalis",
+                          "Escherichia coli",
+                          "Klebsiella pneumoniae",
+                          "Pseudomonas aeruginosa"),
+                   VAN = "-",       # Vancomycin
+                   AMX = "-",       # Amoxicillin
+                   COL = "-",       # Colistin
+                   CAZ = "-",       # Ceftazidime
+                   CXM = "-",       # Cefuroxime
+                   PEN = "S",       # Penicillin G
+                   FOX = "S",       # Cefoxitin
+                   stringsAsFactors = FALSE)
+
data
@@ -299,7 +300,7 @@
mo
- + @@ -369,15 +370,9 @@ @@ -388,7 +383,7 @@
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/MDR.html b/docs/articles/MDR.html index 884fd7420..e176e090f 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
@@ -233,15 +234,15 @@ Examples

The mdro() function always returns an ordered factor. For example, the output of the default guideline by Magiorakos et al. returns a factor with levels ‘Negative’, ‘MDR’, ‘XDR’ or ‘PDR’ in that order.

The next example uses the example_isolates data set. This is a data set included with this package and contains 2,000 microbial isolates with their full antibiograms. It reflects reality and can be used to practice AMR analysis. If we test the MDR/XDR/PDR guideline on this data set, we get:

-
library(dplyr) # to support pipes: %>%
-
example_isolates %>% 
-  mdro() %>% 
-  freq() # show frequency table of the result
-# NOTE: Using column `mo` as input for `col_mo`.
-# NOTE: Auto-guessing columns suitable for analysis...OK.
-# NOTE: Reliability will be improved if these antimicrobial results would be available too: SAM (ampicillin/sulbactam), ATM (aztreonam), CTT (cefotetan), CPT (ceftaroline), DAP (daptomycin), DOR (doripenem), ETP (ertapenem), FUS (fusidic acid), GEH (gentamicin-high), LVX (levofloxacin), MNO (minocycline), NET (netilmicin), PLB (polymyxin B), QDA (quinupristin/dalfopristin), STH (streptomycin-high), TLV (telavancin), TCC (ticarcillin/clavulanic acid)
-# Warning in mdro(.): NA introduced for isolates where the available percentage of
-# antimicrobial classes was below 50% (set with `pct_required_classes`)
+
library(dplyr) # to support pipes: %>%
+
example_isolates %>%
+  mdro() %>%
+  freq() # show frequency table of the result
+# NOTE: Using column `mo` as input for `col_mo`.
+# NOTE: Auto-guessing columns suitable for analysis...OK.
+# NOTE: Reliability will be improved if these antimicrobial results would be available too: SAM (ampicillin/sulbactam), ATM (aztreonam), CTT (cefotetan), CPT (ceftaroline), DAP (daptomycin), DOR (doripenem), ETP (ertapenem), FUS (fusidic acid), GEH (gentamicin-high), LVX (levofloxacin), MNO (minocycline), NET (netilmicin), PLB (polymyxin B), QDA (quinupristin/dalfopristin), STH (streptomycin-high), TLV (telavancin), TCC (ticarcillin/clavulanic acid)
+# Warning in mdro(.): NA introduced for isolates where the available percentage of
+# antimicrobial classes was below 50% (set with `pct_required_classes`)

Frequency table

Class: factor > ordered (numeric)
Length: 2,000
@@ -277,55 +278,55 @@ Unique: 2

mo

For another example, I will create a data set to determine multi-drug resistant TB:

-
# a helper function to get a random vector with values S, I and R
-# with the probabilities 50% - 10% - 40%
-sample_rsi <- function() {
-  sample(c("S", "I", "R"),
-         size = 5000,
-         prob = c(0.5, 0.1, 0.4),
-         replace = TRUE)
-}
-
-my_TB_data <- data.frame(rifampicin = sample_rsi(),
-                         isoniazid = sample_rsi(),
-                         gatifloxacin = sample_rsi(),
-                         ethambutol = sample_rsi(),
-                         pyrazinamide = sample_rsi(),
-                         moxifloxacin = sample_rsi(),
-                         kanamycin = sample_rsi())
+
# a helper function to get a random vector with values S, I and R
+# with the probabilities 50% - 10% - 40%
+sample_rsi <- function() {
+  sample(c("S", "I", "R"),
+         size = 5000,
+         prob = c(0.5, 0.1, 0.4),
+         replace = TRUE)
+}
+
+my_TB_data <- data.frame(rifampicin = sample_rsi(),
+                         isoniazid = sample_rsi(),
+                         gatifloxacin = sample_rsi(),
+                         ethambutol = sample_rsi(),
+                         pyrazinamide = sample_rsi(),
+                         moxifloxacin = sample_rsi(),
+                         kanamycin = sample_rsi())

Because all column names are automatically verified for valid drug names or codes, this would have worked exactly the same:

-
my_TB_data <- data.frame(RIF = sample_rsi(),
-                         INH = sample_rsi(),
-                         GAT = sample_rsi(),
-                         ETH = sample_rsi(),
-                         PZA = sample_rsi(),
-                         MFX = sample_rsi(),
-                         KAN = sample_rsi())
+
my_TB_data <- data.frame(RIF = sample_rsi(),
+                         INH = sample_rsi(),
+                         GAT = sample_rsi(),
+                         ETH = sample_rsi(),
+                         PZA = sample_rsi(),
+                         MFX = sample_rsi(),
+                         KAN = sample_rsi())

The data set now looks like this:

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

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

-
mdro(my_TB_data, guideline = "TB")
+
mdro(my_TB_data, guideline = "TB")

or its shortcut mdr_tb():

-
my_TB_data$mdr <- mdr_tb(my_TB_data)
-# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
-# NOTE: Auto-guessing columns suitable for analysis...OK.
-# NOTE: Reliability will be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)
+
my_TB_data$mdr <- mdr_tb(my_TB_data)
+# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.
+# NOTE: Auto-guessing columns suitable for analysis...OK.
+# NOTE: Reliability will be improved if these antimicrobial results would be available too: CAP (capreomycin), RIB (rifabutin), RFP (rifapentine)

Create a frequency table of the results:

-
freq(my_TB_data$mdr)
+
freq(my_TB_data$mdr)

Frequency table

Class: factor > ordered (numeric)
Length: 5,000
@@ -345,40 +346,40 @@ Unique: 5

1 Mono-resistant -3312 -66.24% -3312 -66.24% +3310 +66.20% +3310 +66.20% 2 Negative -634 -12.68% -3946 -78.92% +637 +12.74% +3947 +78.94% 3 Multi-drug-resistant -554 -11.08% -4500 -90.00% +569 +11.38% +4516 +90.32% 4 Poly-resistant -291 -5.82% -4791 -95.82% +283 +5.66% +4799 +95.98% 5 Extensively drug-resistant -209 -4.18% +201 +4.02% 5000 100.00% @@ -400,7 +401,7 @@ Unique: 5

-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/PCA.html b/docs/articles/PCA.html index 1e02fa61e..86d60ae85 100644 --- a/docs/articles/PCA.html +++ b/docs/articles/PCA.html @@ -39,7 +39,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0
diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html index 44d83ae3e..87da5d0ca 100644 --- a/docs/articles/SPSS.html +++ b/docs/articles/SPSS.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
@@ -239,39 +240,38 @@

To demonstrate the first point:

-
# not all values are valid MIC values:
-as.mic(0.125)
-# Class 'mic'
-# [1] 0.125
-as.mic("testvalue")
-# Class 'mic'
-# [1] <NA>
-
-# the Gram stain is avaiable for all bacteria:
-mo_gramstain("E. coli")
-# [1] "Gram-negative"
-
-# Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST:
-klebsiella_test <- data.frame(mo = "klebsiella", 
-                              amox = "S",
-                              stringsAsFactors = FALSE)
-klebsiella_test # (our original data)
-#           mo amox
-# 1 klebsiella    S
-eucast_rules(klebsiella_test, info = FALSE) # (the edited data by EUCAST rules)
-#           mo amox
-# 1 klebsiella    R
-
-# hundreds of trade names can be translated to a name, trade name or an ATC code:
-ab_name("floxapen")
-# [1] "Flucloxacillin"
-ab_tradenames("floxapen")
-#  [1] "Floxacillin"          "FLOXACILLIN"          "Floxapen"            
-#  [4] "Floxapen sodium salt" "Fluclox"              "Flucloxacilina"      
-#  [7] "Flucloxacillin"       "Flucloxacilline"      "Flucloxacillinum"    
-# [10] "Fluorochloroxacillin"
-ab_atc("floxapen")
-# [1] "J01CF05"
+
# not all values are valid MIC values:
+as.mic(0.125)
+# Class 'mic'
+# [1] 0.125
+as.mic("testvalue")
+# Class 'mic'
+# [1] <NA>
+
+# the Gram stain is avaiable for all bacteria:
+mo_gramstain("E. coli")
+# [1] "Gram-negative"
+
+# Klebsiella is intrinsic resistant to amoxicllin, according to EUCAST:
+klebsiella_test <- data.frame(mo = "klebsiella",
+                              amox = "S",
+                              stringsAsFactors = FALSE)
+klebsiella_test # (our original data)
+#           mo amox
+# 1 klebsiella    S
+eucast_rules(klebsiella_test, info = FALSE) # (the edited data by EUCAST rules)
+#           mo amox
+# 1 klebsiella    R
+
+# hundreds of trade names can be translated to a name, trade name or an ATC code:
+ab_name("floxapen")
+# [1] "Flucloxacillin"
+ab_tradenames("floxapen")
+# [1] "floxacillin"          "floxapen"             "floxapen sodium salt"
+# [4] "fluclox"              "flucloxacilina"       "flucloxacillin"      
+# [7] "flucloxacilline"      "flucloxacillinum"     "fluorochloroxacillin"
+ab_atc("floxapen")
+# [1] "J01CF05"

@@ -287,97 +287,97 @@

If you want named variables to be imported as factors so it resembles SPSS more, use as_factor().

The difference is this:

-
SPSS_data
-# # A tibble: 4,203 x 4
-#     v001 sex       status    statusage
-#    <dbl> <dbl+lbl> <dbl+lbl>     <dbl>
-#  1 10002 1         1              76.6
-#  2 10004 0         1              59.1
-#  3 10005 1         1              54.5
-#  4 10006 1         1              54.1
-#  5 10007 1         1              57.7
-#  6 10008 1         1              62.8
-#  7 10010 0         1              63.7
-#  8 10011 1         1              73.1
-#  9 10017 1         1              56.7
-# 10 10018 0         1              66.6
-# # … with 4,193 more rows
-
-as_factor(SPSS_data)
-# # A tibble: 4,203 x 4
-#     v001 sex    status statusage
-#    <dbl> <fct>  <fct>      <dbl>
-#  1 10002 Male   alive       76.6
-#  2 10004 Female alive       59.1
-#  3 10005 Male   alive       54.5
-#  4 10006 Male   alive       54.1
-#  5 10007 Male   alive       57.7
-#  6 10008 Male   alive       62.8
-#  7 10010 Female alive       63.7
-#  8 10011 Male   alive       73.1
-#  9 10017 Male   alive       56.7
-# 10 10018 Female alive       66.6
-# # … with 4,193 more rows
+
SPSS_data
+# # A tibble: 4,203 x 4
+#     v001 sex       status    statusage
+#    <dbl> <dbl+lbl> <dbl+lbl>     <dbl>
+#  1 10002 1         1              76.6
+#  2 10004 0         1              59.1
+#  3 10005 1         1              54.5
+#  4 10006 1         1              54.1
+#  5 10007 1         1              57.7
+#  6 10008 1         1              62.8
+#  7 10010 0         1              63.7
+#  8 10011 1         1              73.1
+#  9 10017 1         1              56.7
+# 10 10018 0         1              66.6
+# # … with 4,193 more rows
+
+as_factor(SPSS_data)
+# # A tibble: 4,203 x 4
+#     v001 sex    status statusage
+#    <dbl> <fct>  <fct>      <dbl>
+#  1 10002 Male   alive       76.6
+#  2 10004 Female alive       59.1
+#  3 10005 Male   alive       54.5
+#  4 10006 Male   alive       54.1
+#  5 10007 Male   alive       57.7
+#  6 10008 Male   alive       62.8
+#  7 10010 Female alive       63.7
+#  8 10011 Male   alive       73.1
+#  9 10017 Male   alive       56.7
+# 10 10018 Female alive       66.6
+# # … with 4,193 more rows

Base R

To import data from SPSS, SAS or Stata, you can use the great haven package yourself:

-
# download and install the latest version:
-install.packages("haven")
-# load the package you just installed:
-library(haven) 
+
# download and install the latest version:
+install.packages("haven")
+# load the package you just installed:
+library(haven)

You can now import files as follows:

SPSS

To read files from SPSS into R:

-
# read any SPSS file based on file extension (best way):
-read_spss(file = "path/to/file")
-
-# read .sav or .zsav file:
-read_sav(file = "path/to/file")
-
-# read .por file:
-read_por(file = "path/to/file")
+
# read any SPSS file based on file extension (best way):
+read_spss(file = "path/to/file")
+
+# read .sav or .zsav file:
+read_sav(file = "path/to/file")
+
+# read .por file:
+read_por(file = "path/to/file")

Do not forget about as_factor(), as mentioned above.

To export your R objects to the SPSS file format:

-
# save as .sav file:
-write_sav(data = yourdata, path = "path/to/file")
-
-# save as compressed .zsav file:
-write_sav(data = yourdata, path = "path/to/file", compress = TRUE)
+
# save as .sav file:
+write_sav(data = yourdata, path = "path/to/file")
+
+# save as compressed .zsav file:
+write_sav(data = yourdata, path = "path/to/file", compress = TRUE)

SAS

To read files from SAS into R:

-
# read .sas7bdat + .sas7bcat files:
-read_sas(data_file = "path/to/file", catalog_file = NULL)
-
-# read SAS transport files (version 5 and version 8):
-read_xpt(file = "path/to/file")
+
# read .sas7bdat + .sas7bcat files:
+read_sas(data_file = "path/to/file", catalog_file = NULL)
+
+# read SAS transport files (version 5 and version 8):
+read_xpt(file = "path/to/file")

To export your R objects to the SAS file format:

-
# save as regular SAS file:
-write_sas(data = yourdata, path = "path/to/file")
-
-# the SAS transport format is an open format 
-# (required for submission of the data to the FDA)
-write_xpt(data = yourdata, path = "path/to/file", version = 8)
+
# save as regular SAS file:
+write_sas(data = yourdata, path = "path/to/file")
+
+# the SAS transport format is an open format 
+# (required for submission of the data to the FDA)
+write_xpt(data = yourdata, path = "path/to/file", version = 8)

Stata

To read files from Stata into R:

-
# read .dta file:
-read_stata(file = "/path/to/file")
-
-# works exactly the same:
-read_dta(file = "/path/to/file")
+
# read .dta file:
+read_stata(file = "/path/to/file")
+
+# works exactly the same:
+read_dta(file = "/path/to/file")

To export your R objects to the Stata file format:

-
# save as .dta file, Stata version 14:
-# (supports Stata v8 until v15 at the time of writing)
-write_dta(data = yourdata, path = "/path/to/file", version = 14)
+
# save as .dta file, Stata version 14:
+# (supports Stata v8 until v15 at the time of writing)
+write_dta(data = yourdata, path = "/path/to/file", version = 14)
@@ -385,16 +385,9 @@
@@ -405,7 +398,7 @@
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html index 8766019a8..3fe01da62 100644 --- a/docs/articles/WHONET.html +++ b/docs/articles/WHONET.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
@@ -199,33 +200,33 @@ Import of data

This tutorial assumes you already imported the WHONET data with e.g. the readxl package. In RStudio, this can be done using the menu button ‘Import Dataset’ in the tab ‘Environment’. Choose the option ‘From Excel’ and select your exported file. Make sure date fields are imported correctly.

An example syntax could look like this:

-
library(readxl)
-data <- read_excel(path = "path/to/your/file.xlsx")
+
library(readxl)
+data <- read_excel(path = "path/to/your/file.xlsx")

This package comes with an example data set WHONET. We will use it for this analysis.

Preparation

First, load the relevant packages if you did not yet did this. I use the tidyverse for all of my analyses. All of them. If you don’t know it yet, I suggest you read about it on their website: https://www.tidyverse.org/.

-
library(dplyr)   # part of tidyverse
-library(ggplot2) # part of tidyverse
-library(AMR)     # this package
+
library(dplyr)   # part of tidyverse
+library(ggplot2) # part of tidyverse
+library(AMR)     # this package

We will have to transform some variables to simplify and automate the analysis:

  • Microorganisms should be transformed to our own microorganism IDs (called an mo) using our Catalogue of Life reference data set, which contains all ~70,000 microorganisms from the taxonomic kingdoms Bacteria, Fungi and Protozoa. We do the tranformation with as.mo(). This function also recognises almost all WHONET abbreviations of microorganisms.
  • Antimicrobial results or interpretations have to be clean and valid. In other words, they should only contain values "S", "I" or "R". That is exactly where the as.rsi() function is for.
-
# transform variables
-data <- WHONET %>%
-  # get microbial ID based on given organism
-  mutate(mo = as.mo(Organism)) %>% 
-  # transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class
-  mutate_at(vars(AMP_ND10:CIP_EE), as.rsi)
+
# transform variables
+data <- WHONET %>%
+  # get microbial ID based on given organism
+  mutate(mo = as.mo(Organism)) %>%
+  # transform everything from "AMP_ND10" to "CIP_EE" to the new `rsi` class
+  mutate_at(vars(AMP_ND10:CIP_EE), as.rsi)

No errors or warnings, so all values are transformed succesfully.

We also created a package dedicated to data cleaning and checking, called the cleaner package. It gets automatically installed with the AMR package. For its freq() function to create frequency tables, you don’t even need to load it yourself as it is available through the AMR package as well.

So let’s check our data, with a couple of frequency tables:

-
# our newly created `mo` variable, put in the mo_name() function
-data %>% freq(mo_name(mo), nmax = 10)
+
# our newly created `mo` variable, put in the mo_name() function
+data %>% freq(mo_name(mo), nmax = 10)

Frequency table

Class: character
Length: 500
@@ -326,9 +327,9 @@ Longest: 40

(omitted 29 entries, n = 57 [11.40%])

-
# our transformed antibiotic columns
-# amoxicillin/clavulanic acid (J01CR02) as an example
-data %>% freq(AMC_ND2)
+
# our transformed antibiotic columns
+# amoxicillin/clavulanic acid (J01CR02) as an example
+data %>% freq(AMC_ND2)

Frequency table

Class: factor > ordered > rsi (numeric)
Length: 500
@@ -377,10 +378,10 @@ Unique: 3

A first glimpse at results

An easy ggplot will already give a lot of information, using the included ggplot_rsi() function:

-
data %>%
-  group_by(Country) %>%
-  select(Country, AMP_ND2, AMC_ED20, CAZ_ED10, CIP_ED5) %>%
-  ggplot_rsi(translate_ab = 'ab', facet = "Country", datalabels = FALSE)
+
data %>%
+  group_by(Country) %>%
+  select(Country, AMP_ND2, AMC_ED20, CAZ_ED10, CIP_ED5) %>%
+  ggplot_rsi(translate_ab = 'ab', facet = "Country", datalabels = FALSE)

@@ -398,7 +399,7 @@ Unique: 3

-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index dbc4e07e0..4073a6e95 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
@@ -196,83 +197,68 @@

One of the most important features of this package is the complete microbial taxonomic database, supplied by the Catalogue of Life. We created a function as.mo() that transforms any user input value to a valid microbial ID by using intelligent rules combined with the taxonomic tree of Catalogue of Life.

Using the microbenchmark package, we can review the calculation performance of this function. Its function microbenchmark() runs different input expressions independently of each other and measures their time-to-result.

-
library(microbenchmark)
-library(AMR)
+
library(microbenchmark)
+library(AMR)

In the next test, we try to ‘coerce’ different input values into the microbial code of Staphylococcus aureus. Coercion is a computational process of forcing output based on an input. For microorganism names, coercing user input to taxonomically valid microorganism names is crucial to ensure correct interpretation and to enable grouping based on taxonomic properties.

The actual result is the same every time: it returns its microorganism code B_STPHY_AURS (B stands for Bacteria, the taxonomic kingdom).

But the calculation time differs a lot:

-
S.aureus <- microbenchmark(
-  as.mo("sau"), # WHONET code
-  as.mo("stau"),
-  as.mo("STAU"),
-  as.mo("staaur"),
-  as.mo("STAAUR"),
-  as.mo("S. aureus"),
-  as.mo("S aureus"),
-  as.mo("Staphylococcus aureus"), # official taxonomic name
-  as.mo("Staphylococcus aureus (MRSA)"), # additional text
-  as.mo("Sthafilokkockus aaureuz"), # incorrect spelling
-  as.mo("MRSA"), # Methicillin Resistant S. aureus
-  as.mo("VISA"), # Vancomycin Intermediate S. aureus
-  as.mo("VRSA"), # Vancomycin Resistant S. aureus
-  as.mo(22242419), # Catalogue of Life ID
-  times = 10)
-print(S.aureus, unit = "ms", signif = 2)
-# Unit: milliseconds
-#                                   expr   min    lq  mean median    uq   max
-#                           as.mo("sau")   9.1   9.5  12.0    9.8  10.0  34.0
-#                          as.mo("stau")  38.0  41.0  55.0   41.0  42.0 160.0
-#                          as.mo("STAU")  41.0  41.0  50.0   44.0  63.0  67.0
-#                        as.mo("staaur")   8.6   8.8   9.4    9.4   9.6  10.0
-#                        as.mo("STAAUR")   8.6   8.8  12.0    9.3   9.8  37.0
-#                     as.mo("S. aureus")  14.0  15.0  51.0   27.0  43.0 250.0
-#                      as.mo("S aureus")  14.0  15.0  16.0   15.0  16.0  18.0
-#         as.mo("Staphylococcus aureus")   5.1   5.3   5.7    5.5   6.0   6.6
-#  as.mo("Staphylococcus aureus (MRSA)") 640.0 670.0 700.0  690.0 730.0 760.0
-#       as.mo("Sthafilokkockus aaureuz") 370.0 380.0 420.0  400.0 440.0 510.0
-#                          as.mo("MRSA")   8.6   8.7  11.0    9.1   9.6  32.0
-#                          as.mo("VISA")  24.0  25.0  38.0   38.0  50.0  53.0
-#                          as.mo("VRSA")  24.0  25.0  49.0   37.0  52.0 150.0
-#                        as.mo(22242419) 130.0 140.0 150.0  140.0 160.0 160.0
-#  neval
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
-#     10
+
S.aureus <- microbenchmark(
+  as.mo("sau"), # WHONET code
+  as.mo("stau"),
+  as.mo("STAU"),
+  as.mo("staaur"),
+  as.mo("STAAUR"),
+  as.mo("S. aureus"),
+  as.mo("S aureus"),
+  as.mo("Staphylococcus aureus"), # official taxonomic name
+  as.mo("Staphylococcus aureus (MRSA)"), # additional text
+  as.mo("Sthafilokkockus aaureuz"), # incorrect spelling
+  as.mo("MRSA"), # Methicillin Resistant S. aureus
+  as.mo("VISA"), # Vancomycin Intermediate S. aureus
+  as.mo("VRSA"), # Vancomycin Resistant S. aureus
+  as.mo(22242419), # Catalogue of Life ID
+  times = 10)
+print(S.aureus, unit = "ms", signif = 2)
+# Unit: milliseconds
+#                                   expr   min    lq mean median    uq max neval
+#                           as.mo("sau")  10.0  11.0   11   11.0  11.0  11    10
+#                          as.mo("stau")  39.0  43.0   54   44.0  70.0  72    10
+#                          as.mo("STAU")  43.0  44.0   52   47.0  68.0  71    10
+#                        as.mo("staaur")   9.6   9.8   11   11.0  12.0  13    10
+#                        as.mo("STAAUR")   9.6  11.0   17   11.0  11.0  45    10
+#                     as.mo("S. aureus")  15.0  17.0   26   18.0  43.0  50    10
+#                      as.mo("S aureus")  16.0  17.0   23   18.0  21.0  44    10
+#         as.mo("Staphylococcus aureus")   6.0   6.0   12    6.9   7.2  40    10
+#  as.mo("Staphylococcus aureus (MRSA)") 660.0 740.0  780  780.0 810.0 870    10
+#       as.mo("Sthafilokkockus aaureuz") 370.0 430.0  470  450.0 460.0 760    10
+#                          as.mo("MRSA")   9.5   9.6   13   11.0  11.0  35    10
+#                          as.mo("VISA")  25.0  26.0   38   30.0  50.0  58    10
+#                          as.mo("VRSA")  25.0  29.0   55   55.0  56.0 150    10
+#                        as.mo(22242419) 130.0 150.0  160  160.0 170.0 170    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.

To achieve this speed, the as.mo 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 Methanosarcina semesiae (B_MTHNSR_SEMS), a bug probably never found before in humans:

-
M.semesiae <- microbenchmark(as.mo("metsem"),
-                             as.mo("METSEM"),
-                             as.mo("M. semesiae"),
-                             as.mo("M.  semesiae"),
-                             as.mo("Methanosarcina semesiae"),
-                             times = 10)
-print(M.semesiae, unit = "ms", signif = 4)
-# Unit: milliseconds
-#                              expr     min       lq    mean   median       uq
-#                   as.mo("metsem") 1530.00 1561.000 1618.00 1620.000 1665.000
-#                   as.mo("METSEM") 1482.00 1523.000 1544.00 1555.000 1567.000
-#              as.mo("M. semesiae")   15.01   16.140   27.85   17.080   43.620
-#             as.mo("M.  semesiae")   15.54   16.200   19.30   16.570   17.040
-#  as.mo("Methanosarcina semesiae")    6.05    6.307    9.35    6.437    7.649
-#      max neval
-#  1710.00    10
-#  1586.00    10
-#    50.39    10
-#    42.95    10
-#    33.42    10
-

That takes 5.7 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 Methanosarcina semesiae) are always very fast and only take some thousands of seconds to coerce - they are the most probable input from most data sets.

+
M.semesiae <- microbenchmark(as.mo("metsem"),
+                             as.mo("METSEM"),
+                             as.mo("M. semesiae"),
+                             as.mo("M.  semesiae"),
+                             as.mo("Methanosarcina semesiae"),
+                             times = 10)
+print(M.semesiae, unit = "ms", signif = 4)
+# Unit: milliseconds
+#                              expr      min       lq     mean   median       uq
+#                   as.mo("metsem") 1629.000 1648.000 1694.000 1681.000 1734.000
+#                   as.mo("METSEM") 1577.000 1604.000 1675.000 1685.000 1700.000
+#              as.mo("M. semesiae")   17.390   17.470   26.150   18.020   43.560
+#             as.mo("M.  semesiae")   17.390   17.880   27.570   18.310   45.910
+#  as.mo("Methanosarcina semesiae")    6.988    7.067    7.443    7.262    7.733
+#       max neval
+#  1825.000    10
+#  1793.000    10
+#    48.390    10
+#    50.960    10
+#     8.381    10
+

That takes 5.6 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 Methanosarcina semesiae) are always very fast and only take some thousands of seconds to coerce - they 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):

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: repetitive results and already precalculated results.

@@ -280,103 +266,103 @@

Repetitive results

Repetitive results are unique values that are present more than once. Unique values will only be calculated once by as.mo(). We will use mo_name() for this test - a helper function that returns the full microbial name (genus, species and possibly subspecies) which uses as.mo() internally.

-
library(dplyr)
-# take all MO codes from the example_isolates data set
-x <- example_isolates$mo %>%
-  # keep only the unique ones
-  unique() %>%
-  # pick 50 of them at random
-  sample(50) %>%
-  # paste that 10,000 times
-  rep(10000) %>%
-  # scramble it
-  sample()
-  
-# got indeed 50 times 10,000 = half a million?
-length(x)
-# [1] 500000
-
-# and how many unique values do we have?
-n_distinct(x)
-# [1] 50
-
-# now let's see:
-run_it <- microbenchmark(mo_name(x),
-                         times = 100)
-print(run_it, unit = "ms", signif = 3)
-# Unit: milliseconds
-#        expr min  lq mean median  uq max neval
-#  mo_name(x) 572 626  648    645 666 792   100
-

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

+
library(dplyr)
+# take all MO codes from the example_isolates data set
+x <- example_isolates$mo %>%
+  # keep only the unique ones
+  unique() %>%
+  # pick 50 of them at random
+  sample(50) %>%
+  # paste that 10,000 times
+  rep(10000) %>%
+  # scramble it
+  sample()
+
+# got indeed 50 times 10,000 = half a million?
+length(x)
+# [1] 500000
+
+# and how many unique values do we have?
+n_distinct(x)
+# [1] 50
+
+# now let's see:
+run_it <- microbenchmark(mo_name(x),
+                         times = 100)
+print(run_it, unit = "ms", signif = 3)
+# Unit: milliseconds
+#        expr  min   lq mean median   uq  max neval
+#  mo_name(x) 1730 1790 1830   1810 1860 2030   100
+

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

Precalculated results

What about precalculated results? If the input is an already precalculated result of a helper function like mo_name(), it almost doesn’t take any time at all (see ‘C’ below):

-
run_it <- microbenchmark(A = mo_name("B_STPHY_AURS"),
-                         B = mo_name("S. aureus"),
-                         C = mo_name("Staphylococcus aureus"),
-                         times = 10)
-print(run_it, unit = "ms", signif = 3)
-# Unit: milliseconds
-#  expr    min     lq   mean median     uq   max neval
-#     A  6.730  6.860  7.110  6.950  7.170  8.47    10
-#     B 14.500 14.800 18.100 15.500 15.900 43.10    10
-#     C  0.726  0.753  0.821  0.791  0.882  1.04    10
-

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0008 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"),
-                         D = mo_family("Staphylococcaceae"),
-                         E = mo_order("Bacillales"),
-                         F = mo_class("Bacilli"),
-                         G = mo_phylum("Firmicutes"),
-                         H = mo_kingdom("Bacteria"),
-                         times = 10)
-print(run_it, unit = "ms", signif = 3)
-# Unit: milliseconds
-#  expr   min    lq  mean median    uq   max neval
-#     A 0.348 0.398 0.405  0.404 0.419 0.438    10
-#     B 0.407 0.416 0.461  0.426 0.490 0.667    10
-#     C 0.701 0.745 0.757  0.754 0.769 0.814    10
-#     D 0.435 0.440 0.497  0.464 0.569 0.588    10
-#     E 0.351 0.397 0.435  0.419 0.489 0.520    10
-#     F 0.358 0.385 0.396  0.393 0.420 0.430    10
-#     G 0.322 0.363 0.409  0.401 0.450 0.508    10
-#     H 0.340 0.372 0.384  0.385 0.403 0.432    10
+
run_it <- microbenchmark(A = mo_name("B_STPHY_AURS"),
+                         B = mo_name("S. aureus"),
+                         C = mo_name("Staphylococcus aureus"),
+                         times = 10)
+print(run_it, unit = "ms", signif = 3)
+# Unit: milliseconds
+#  expr   min     lq   mean median     uq    max neval
+#     A  7.26  7.390  8.020  7.450  7.500 11.100    10
+#     B 15.30 15.700 20.500 15.800 17.000 56.300    10
+#     C  0.58  0.718  0.735  0.726  0.747  0.927    10
+

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0007 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"),
+                         D = mo_family("Staphylococcaceae"),
+                         E = mo_order("Bacillales"),
+                         F = mo_class("Bacilli"),
+                         G = mo_phylum("Firmicutes"),
+                         H = mo_kingdom("Bacteria"),
+                         times = 10)
+print(run_it, unit = "ms", signif = 3)
+# Unit: milliseconds
+#  expr   min    lq  mean median    uq   max neval
+#     A 0.380 0.386 0.397  0.394 0.397 0.434    10
+#     B 0.413 0.417 0.444  0.424 0.430 0.627    10
+#     C 0.574 0.680 0.707  0.730 0.735 0.776    10
+#     D 0.407 0.419 0.430  0.430 0.435 0.470    10
+#     E 0.374 0.381 0.401  0.397 0.424 0.438    10
+#     F 0.366 0.380 0.389  0.387 0.395 0.422    10
+#     G 0.367 0.377 0.388  0.383 0.392 0.420    10
+#     H 0.368 0.374 0.386  0.382 0.390 0.430    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" 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.

Results in other languages

When the system language is non-English and supported by this AMR package, some functions will have a translated result. This almost does’t take extra time:

-
mo_name("CoNS", language = "en") # or just mo_name("CoNS") on an English system
-# [1] "Coagulase-negative Staphylococcus (CoNS)"
-
-mo_name("CoNS", language = "es") # or just mo_name("CoNS") on a Spanish system
-# [1] "Staphylococcus coagulasa negativo (SCN)"
-
-mo_name("CoNS", language = "nl") # or just mo_name("CoNS") on a Dutch system
-# [1] "Coagulase-negatieve Staphylococcus (CNS)"
-
-run_it <- microbenchmark(en = mo_name("CoNS", language = "en"),
-                         de = mo_name("CoNS", language = "de"),
-                         nl = mo_name("CoNS", language = "nl"),
-                         es = mo_name("CoNS", language = "es"),
-                         it = mo_name("CoNS", language = "it"),
-                         fr = mo_name("CoNS", language = "fr"),
-                         pt = mo_name("CoNS", language = "pt"),
-                         times = 100)
-print(run_it, unit = "ms", signif = 4)
-# Unit: milliseconds
-#  expr   min    lq  mean median    uq    max neval
-#    en 25.28 26.99 33.53  27.88 29.51  61.96   100
-#    de 26.99 29.27 36.92  30.02 33.09 160.30   100
-#    nl 32.37 34.58 40.59  35.88 37.10  67.43   100
-#    es 27.54 29.14 34.40  29.88 31.45  61.89   100
-#    it 26.77 28.79 34.28  29.73 31.30  69.41   100
-#    fr 27.01 28.81 34.96  29.39 30.79 161.10   100
-#    pt 26.76 28.85 34.13  29.69 31.74  63.08   100
+
mo_name("CoNS", language = "en") # or just mo_name("CoNS") on an English system
+# [1] "Coagulase-negative Staphylococcus (CoNS)"
+
+mo_name("CoNS", language = "es") # or just mo_name("CoNS") on a Spanish system
+# [1] "Staphylococcus coagulasa negativo (SCN)"
+
+mo_name("CoNS", language = "nl") # or just mo_name("CoNS") on a Dutch system
+# [1] "Coagulase-negatieve Staphylococcus (CNS)"
+
+run_it <- microbenchmark(en = mo_name("CoNS", language = "en"),
+                         de = mo_name("CoNS", language = "de"),
+                         nl = mo_name("CoNS", language = "nl"),
+                         es = mo_name("CoNS", language = "es"),
+                         it = mo_name("CoNS", language = "it"),
+                         fr = mo_name("CoNS", language = "fr"),
+                         pt = mo_name("CoNS", language = "pt"),
+                         times = 100)
+print(run_it, unit = "ms", signif = 4)
+# Unit: milliseconds
+#  expr   min    lq  mean median    uq    max neval
+#    en 26.72 28.52 32.86  29.31 30.18  69.18   100
+#    de 27.86 30.67 40.23  31.44 46.42 170.40   100
+#    nl 34.45 36.94 44.89  37.95 40.54  76.41   100
+#    es 27.89 30.51 38.46  31.33 32.89 170.10   100
+#    it 29.15 30.37 35.85  31.04 32.39  65.33   100
+#    fr 28.18 30.37 35.80  31.11 32.25  78.14   100
+#    pt 28.23 30.55 36.89  31.32 32.77  67.79   100

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

@@ -394,7 +380,7 @@
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png index 0d0f1bc39..b5ad771d2 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png index e03ef3d29..79fffe0b3 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index dd8f86bda..698a91192 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index 7014637ba..d6c981a79 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -13,19 +13,20 @@ - - - + + + + - + - +
@@ -199,84 +200,84 @@ Needed R packages

As with many uses in R, we need some additional packages for AMR analysis. Our package works closely together with the tidyverse packages dplyr and ggplot2 by Dr Hadley Wickham. The tidyverse tremendously improves the way we conduct data science - it allows for a very natural way of writing syntaxes and creating beautiful plots in R.

Our AMR package depends on these packages and even extends their use and functions.

-
library(dplyr)
-library(ggplot2)
-library(AMR)
-
-# (if not yet installed, install with:)
-# install.packages(c("tidyverse", "AMR"))
+
library(dplyr)
+library(ggplot2)
+library(AMR)
+
+# (if not yet installed, install with:)
+# install.packages(c("tidyverse", "AMR"))

Prediction analysis

Our package contains a function resistance_predict(), which takes the same input as functions for other AMR analysis. Based on a date column, it calculates cases per year and uses a regression model to predict antimicrobial resistance.

It is basically as easy as:

-
# resistance prediction of piperacillin/tazobactam (TZP):
-resistance_predict(tbl = example_isolates, col_date = "date", col_ab = "TZP", model = "binomial")
-
-# or:
-example_isolates %>% 
-  resistance_predict(col_ab = "TZP",
-                     model  "binomial")
-
-# to bind it to object 'predict_TZP' for example:
-predict_TZP <- example_isolates %>% 
-  resistance_predict(col_ab = "TZP",
-                     model = "binomial")
+
# resistance prediction of piperacillin/tazobactam (TZP):
+resistance_predict(tbl = example_isolates, col_date = "date", col_ab = "TZP", model = "binomial")
+
+# or:
+example_isolates %>% 
+  resistance_predict(col_ab = "TZP",
+                     model  "binomial")
+
+# to bind it to object 'predict_TZP' for example:
+predict_TZP % 
+  resistance_predict(col_ab = "TZP",
+                     model = "binomial")

The function will look for a date column itself if col_date is not set.

When running any of these commands, a summary of the regression model will be printed unless using resistance_predict(..., info = FALSE).

# NOTE: Using column `date` as input for `col_date`.

This text is only a printed summary - the actual result (output) of the function is a data.frame containing for each year: the number of observations, the actual observed resistance, the estimated resistance and the standard error below and above the estimation:

-
predict_TZP
-#    year      value    se_min    se_max observations   observed  estimated
-# 1  2003 0.06250000        NA        NA           32 0.06250000 0.05486389
-# 2  2004 0.08536585        NA        NA           82 0.08536585 0.06089002
-# 3  2005 0.05000000        NA        NA           60 0.05000000 0.06753075
-# 4  2006 0.05084746        NA        NA           59 0.05084746 0.07483801
-# 5  2007 0.12121212        NA        NA           66 0.12121212 0.08286570
-# 6  2008 0.04166667        NA        NA           72 0.04166667 0.09166918
-# 7  2009 0.01639344        NA        NA           61 0.01639344 0.10130461
-# 8  2010 0.05660377        NA        NA           53 0.05660377 0.11182814
-# 9  2011 0.18279570        NA        NA           93 0.18279570 0.12329488
-# 10 2012 0.30769231        NA        NA           65 0.30769231 0.13575768
-# 11 2013 0.06896552        NA        NA           58 0.06896552 0.14926576
-# 12 2014 0.10000000        NA        NA           60 0.10000000 0.16386307
-# 13 2015 0.23636364        NA        NA           55 0.23636364 0.17958657
-# 14 2016 0.22619048        NA        NA           84 0.22619048 0.19646431
-# 15 2017 0.16279070        NA        NA           86 0.16279070 0.21451350
-# 16 2018 0.23373852 0.2021578 0.2653193           NA         NA 0.23373852
-# 17 2019 0.25412909 0.2168525 0.2914057           NA         NA 0.25412909
-# 18 2020 0.27565854 0.2321869 0.3191302           NA         NA 0.27565854
-# 19 2021 0.29828252 0.2481942 0.3483709           NA         NA 0.29828252
-# 20 2022 0.32193804 0.2649008 0.3789753           NA         NA 0.32193804
-# 21 2023 0.34654311 0.2823269 0.4107593           NA         NA 0.34654311
-# 22 2024 0.37199700 0.3004860 0.4435080           NA         NA 0.37199700
-# 23 2025 0.39818127 0.3193839 0.4769787           NA         NA 0.39818127
-# 24 2026 0.42496142 0.3390173 0.5109056           NA         NA 0.42496142
-# 25 2027 0.45218939 0.3593720 0.5450068           NA         NA 0.45218939
-# 26 2028 0.47970658 0.3804212 0.5789920           NA         NA 0.47970658
-# 27 2029 0.50734745 0.4021241 0.6125708           NA         NA 0.50734745
-# 28 2030 0.53494347 0.4244247 0.6454622           NA         NA 0.53494347
+
predict_TZP
+#    year      value    se_min    se_max observations   observed  estimated
+# 1  2003 0.06250000        NA        NA           32 0.06250000 0.05486389
+# 2  2004 0.08536585        NA        NA           82 0.08536585 0.06089002
+# 3  2005 0.05000000        NA        NA           60 0.05000000 0.06753075
+# 4  2006 0.05084746        NA        NA           59 0.05084746 0.07483801
+# 5  2007 0.12121212        NA        NA           66 0.12121212 0.08286570
+# 6  2008 0.04166667        NA        NA           72 0.04166667 0.09166918
+# 7  2009 0.01639344        NA        NA           61 0.01639344 0.10130461
+# 8  2010 0.05660377        NA        NA           53 0.05660377 0.11182814
+# 9  2011 0.18279570        NA        NA           93 0.18279570 0.12329488
+# 10 2012 0.30769231        NA        NA           65 0.30769231 0.13575768
+# 11 2013 0.06896552        NA        NA           58 0.06896552 0.14926576
+# 12 2014 0.10000000        NA        NA           60 0.10000000 0.16386307
+# 13 2015 0.23636364        NA        NA           55 0.23636364 0.17958657
+# 14 2016 0.22619048        NA        NA           84 0.22619048 0.19646431
+# 15 2017 0.16279070        NA        NA           86 0.16279070 0.21451350
+# 16 2018 0.23373852 0.2021578 0.2653193           NA         NA 0.23373852
+# 17 2019 0.25412909 0.2168525 0.2914057           NA         NA 0.25412909
+# 18 2020 0.27565854 0.2321869 0.3191302           NA         NA 0.27565854
+# 19 2021 0.29828252 0.2481942 0.3483709           NA         NA 0.29828252
+# 20 2022 0.32193804 0.2649008 0.3789753           NA         NA 0.32193804
+# 21 2023 0.34654311 0.2823269 0.4107593           NA         NA 0.34654311
+# 22 2024 0.37199700 0.3004860 0.4435080           NA         NA 0.37199700
+# 23 2025 0.39818127 0.3193839 0.4769787           NA         NA 0.39818127
+# 24 2026 0.42496142 0.3390173 0.5109056           NA         NA 0.42496142
+# 25 2027 0.45218939 0.3593720 0.5450068           NA         NA 0.45218939
+# 26 2028 0.47970658 0.3804212 0.5789920           NA         NA 0.47970658
+# 27 2029 0.50734745 0.4021241 0.6125708           NA         NA 0.50734745
+# 28 2030 0.53494347 0.4244247 0.6454622           NA         NA 0.53494347

The function plot is available in base R, and can be extended by other packages to depend the output based on the type of input. We extended its function to cope with resistance predictions:

-
plot(predict_TZP)
+
plot(predict_TZP)

This is the fastest way to plot the result. It automatically adds the right axes, error bars, titles, number of available observations and type of model.

We also support the ggplot2 package with our custom function ggplot_rsi_predict() to create more appealing plots:

-
ggplot_rsi_predict(predict_TZP)
+
ggplot_rsi_predict(predict_TZP)

-

-# choose for error bars instead of a ribbon
-ggplot_rsi_predict(predict_TZP, ribbon = FALSE)
+
+# choose for error bars instead of a ribbon
+ggplot_rsi_predict(predict_TZP, ribbon = FALSE)

Choosing the right model

Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:

-
example_isolates %>%
-  filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
-  resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>% 
-  ggplot_rsi_predict()
-# NOTE: Using column `date` as input for `col_date`.
+
example_isolates %>%
+  filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
+  resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "binomial") %>%
+  ggplot_rsi_predict()
+# NOTE: Using column `date` as input for `col_date`.

Vancomycin resistance could be 100% in ten years, but might also stay around 0%.

You can define the model with the model parameter. The model chosen above is a generalised linear regression model using a binomial distribution, assuming that a period of zero resistance was followed by a period of increasing resistance leading slowly to more and more resistance.

@@ -317,40 +318,34 @@

For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:

-
example_isolates %>%
-  filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
-  resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "linear") %>% 
-  ggplot_rsi_predict()
-# NOTE: Using column `date` as input for `col_date`.
+
example_isolates %>%
+  filter(mo_gramstain(mo, language = NULL) == "Gram-positive") %>%
+  resistance_predict(col_ab = "VAN", year_min = 2010, info = FALSE, model = "linear") %>%
+  ggplot_rsi_predict()
+# NOTE: Using column `date` as input for `col_date`.

This seems more likely, doesn’t it?

The model itself is also available from the object, as an attribute:

-
model <- attributes(predict_TZP)$model
-
-summary(model)$family
-# 
-# Family: binomial 
-# Link function: logit
-
-summary(model)$coefficients
-#                 Estimate Std. Error   z value     Pr(>|z|)
-# (Intercept) -224.3987194 48.0335384 -4.671709 2.987038e-06
-# year           0.1106102  0.0238753  4.632831 3.606990e-06
+
model <- attributes(predict_TZP)$model
+
+summary(model)$family
+# 
+# Family: binomial 
+# Link function: logit
+
+summary(model)$coefficients
+#                 Estimate Std. Error   z value     Pr(>|z|)
+# (Intercept) -224.3987194 48.0335384 -4.671709 2.987038e-06
+# year           0.1106102  0.0238753  4.632831 3.606990e-06
@@ -361,7 +356,7 @@
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/authors.html b/docs/authors.html index 3d54f2f37..c35a9d859 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/index.html b/docs/index.html index 9246dec87..8185d1057 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/news/index.html b/docs/news/index.html index 7fba063cd..1d7642512 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 @@ -229,14 +229,10 @@ Source: NEWS.md -
-

-AMR 1.0.1.9009 Unreleased +
+

+AMR 1.1.0 Unreleased

-
-

-Last updated: 15-Apr-2020 -

New

@@ -274,7 +270,6 @@
-

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 346ab5fdd..783a957c0 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: WHONET: WHONET.html benchmarks: benchmarks.html resistance_predict: resistance_predict.html -last_built: 2020-04-15T09:25Z +last_built: 2020-04-15T12:29Z urls: reference: https://msberends.gitlab.io/AMR/reference article: https://msberends.gitlab.io/AMR/articles diff --git a/docs/reference/AMR-deprecated.html b/docs/reference/AMR-deprecated.html index c044add3b..5fc2f1f38 100644 --- a/docs/reference/AMR-deprecated.html +++ b/docs/reference/AMR-deprecated.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -260,12 +264,9 @@ The lifecycle of this function is retired
@@ -276,7 +277,7 @@ The lifecycle of this function is retired
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/AMR.html b/docs/reference/AMR.html index edc4c7430..dd7cb8a37 100644 --- a/docs/reference/AMR.html +++ b/docs/reference/AMR.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -276,13 +280,9 @@ The Netherlands

@@ -293,7 +293,7 @@ The Netherlands

-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/WHOCC.html b/docs/reference/WHOCC.html index d0bfd362e..2812292f3 100644 --- a/docs/reference/WHOCC.html +++ b/docs/reference/WHOCC.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -255,13 +259,9 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru ab_tradenames("flucloxacillin")
@@ -272,7 +272,7 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru

-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/WHONET.html b/docs/reference/WHONET.html index d0af41d19..9ac0f8fd9 100644 --- a/docs/reference/WHONET.html +++ b/docs/reference/WHONET.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0

diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html index 40dd0ac65..748ee96e0 100644 --- a/docs/reference/ab_property.html +++ b/docs/reference/ab_property.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -362,18 +366,9 @@ The lifecycle of this function is maturing< ab_atc("seephthriaaksone")
@@ -384,7 +379,7 @@ The lifecycle of this function is maturing<
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/age.html b/docs/reference/age.html index ccb1ad286..7d2287aa6 100644 --- a/docs/reference/age.html +++ b/docs/reference/age.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -284,16 +288,9 @@ The lifecycle of this function is stabledf
@@ -304,7 +301,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/age_groups.html b/docs/reference/age_groups.html index d46e77b8b..8512f9b19 100644 --- a/docs/reference/age_groups.html +++ b/docs/reference/age_groups.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -316,17 +320,9 @@ The lifecycle of this function is stable
@@ -337,7 +333,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/antibiotics.html b/docs/reference/antibiotics.html index 7d6491e67..40027955f 100644 --- a/docs/reference/antibiotics.html +++ b/docs/reference/antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index b0596ffbb..0ddb60f77 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -311,19 +315,9 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru ab_name("eryt") # "Erythromycin"
@@ -334,7 +328,7 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index afdb3e12f..23a00948e 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -290,17 +294,9 @@ The lifecycle of this function is stableas.rsi(df)
@@ -311,7 +307,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index 537ae9b41..acecca177 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -292,17 +296,9 @@ The lifecycle of this function is stablefreq(mic_data)
@@ -313,7 +309,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/as.mo.html b/docs/reference/as.mo.html index 7497f9f83..28219a212 100644 --- a/docs/reference/as.mo.html +++ b/docs/reference/as.mo.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -438,19 +442,9 @@ This package contains the complete taxonomic tree of almost all microorganisms ( }
@@ -461,7 +455,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index 248e3a510..3a502a148 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -413,18 +417,9 @@ The lifecycle of this function is stableis.rsi.eligible(WHONET$`First name`, threshold = 0.99) # succeeds
@@ -435,7 +430,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index 4249fa164..f9c52a1b8 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -47,7 +51,7 @@ - + @@ -65,7 +69,7 @@ This function requires an internet connection." /> - +
@@ -224,7 +228,7 @@ This function requires an internet connection." />
@@ -325,16 +329,9 @@ The lifecycle of this function is questioni # }
@@ -345,7 +342,7 @@ The lifecycle of this function is questioni
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/availability.html b/docs/reference/availability.html index c5965233b..98bd0c47a 100644 --- a/docs/reference/availability.html +++ b/docs/reference/availability.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -281,16 +285,9 @@ The lifecycle of this function is stableavailability()
@@ -301,7 +298,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/bug_drug_combinations.html b/docs/reference/bug_drug_combinations.html index ae9c1c184..2876a87d9 100644 --- a/docs/reference/bug_drug_combinations.html +++ b/docs/reference/bug_drug_combinations.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -348,17 +352,9 @@ The lifecycle of this function is stable# }
@@ -369,7 +365,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/catalogue_of_life.html b/docs/reference/catalogue_of_life.html index b49d70d8a..8984ba4ff 100644 --- a/docs/reference/catalogue_of_life.html +++ b/docs/reference/catalogue_of_life.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -296,15 +300,9 @@ Function as.mo() to use the data for intel # [1] "Chroococcus limneticus elegans" # Because a microorganism was found
@@ -315,7 +313,7 @@ Function as.mo() to use the data for intel
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/catalogue_of_life_version.html b/docs/reference/catalogue_of_life_version.html index ef1705e97..6fdd0bf93 100644 --- a/docs/reference/catalogue_of_life_version.html +++ b/docs/reference/catalogue_of_life_version.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -262,16 +266,9 @@ This package contains the complete taxonomic tree of almost all microorganisms ( microorganisms %>% group_by(kingdom) %>% freq(phylum, nmax = NULL)
@@ -282,7 +279,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/count.html b/docs/reference/count.html index 19f566c06..74ec5cd96 100644 --- a/docs/reference/count.html +++ b/docs/reference/count.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -47,7 +51,7 @@ - + @@ -65,7 +69,7 @@ count_resistant() should be used to count resistant isolates, count_susceptible( - +
@@ -224,7 +228,7 @@ count_resistant() should be used to count resistant isolates, count_susceptible(
@@ -420,19 +424,9 @@ A microorganism is categorised as Susceptible, Increased exposure when count_df(translate = FALSE)
@@ -443,7 +437,7 @@ A microorganism is categorised as Susceptible, Increased exposure when
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index 87c89bdcd..780164b64 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -47,7 +51,7 @@ - + @@ -65,7 +69,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied - +
@@ -224,7 +228,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied
@@ -444,18 +448,9 @@ The lifecycle of this function is maturing< # }
@@ -466,7 +461,7 @@ The lifecycle of this function is maturing<
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/example_isolates.html b/docs/reference/example_isolates.html index b2f4308e6..c5727c45e 100644 --- a/docs/reference/example_isolates.html +++ b/docs/reference/example_isolates.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -257,12 +261,9 @@
@@ -273,7 +274,7 @@
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/example_isolates_unclean.html b/docs/reference/example_isolates_unclean.html index cbf3fca61..2c482a405 100644 --- a/docs/reference/example_isolates_unclean.html +++ b/docs/reference/example_isolates_unclean.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -252,12 +256,9 @@
@@ -268,7 +269,7 @@
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/extended-functions.html b/docs/reference/extended-functions.html index 2a8f92a6b..1fc3301fc 100644 --- a/docs/reference/extended-functions.html +++ b/docs/reference/extended-functions.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -251,12 +255,9 @@ The lifecycle of this function is stable
@@ -267,7 +268,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/filter_ab_class.html b/docs/reference/filter_ab_class.html index be46b119b..4825616e5 100644 --- a/docs/reference/filter_ab_class.html +++ b/docs/reference/filter_ab_class.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -324,14 +328,9 @@ The lifecycle of this function is stablefilter_fluoroquinolones("R", "all")
@@ -342,7 +341,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 06eb7bb93..09e5ef67f 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0
diff --git a/docs/reference/g.test.html b/docs/reference/g.test.html index b14acc850..2a3fa6859 100644 --- a/docs/reference/g.test.html +++ b/docs/reference/g.test.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -376,19 +380,9 @@ The lifecycle of this function is questioni # Meaning: there are significantly more left-billed birds.
@@ -399,7 +393,7 @@ The lifecycle of this function is questioni
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/ggplot_pca.html b/docs/reference/ggplot_pca.html index 01ee1ba08..1aac97824 100644 --- a/docs/reference/ggplot_pca.html +++ b/docs/reference/ggplot_pca.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index 325abcfe0..906294d3e 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -507,15 +511,9 @@ The lifecycle of this function is maturing< }
@@ -526,7 +524,7 @@ The lifecycle of this function is maturing<
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index 8e859ca7c..7c377ed36 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -298,16 +302,9 @@ The lifecycle of this function is maturing< # [1] "AMP_ED20"
@@ -318,7 +315,7 @@ The lifecycle of this function is maturing<
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/index.html b/docs/reference/index.html index 8b4bb3f7e..b10210bea 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/join.html b/docs/reference/join.html index 1e285cdcf..6aa3e6a95 100644 --- a/docs/reference/join.html +++ b/docs/reference/join.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -298,15 +302,9 @@ The lifecycle of this function is stablecolnames(df_joined)
@@ -317,7 +315,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index ffeaed1b4..0c706a91a 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -410,17 +414,9 @@ The lifecycle of this function is stable# FALSE, because I is not ignored and so the 4th value differs
@@ -431,7 +427,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/kurtosis.html b/docs/reference/kurtosis.html index 0bbbf46d7..73dc4485f 100644 --- a/docs/reference/kurtosis.html +++ b/docs/reference/kurtosis.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -272,14 +276,9 @@ The lifecycle of this function is questioni
@@ -290,7 +289,7 @@ The lifecycle of this function is questioni
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/lifecycle.html b/docs/reference/lifecycle.html index 89dc32fe1..f29aba064 100644 --- a/docs/reference/lifecycle.html +++ b/docs/reference/lifecycle.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -48,7 +52,7 @@ - + @@ -66,7 +70,7 @@ This page contains a section for every lifecycle (with text borrowed from the af - +
@@ -225,7 +229,7 @@ This page contains a section for every lifecycle (with text borrowed from the af
@@ -283,17 +287,9 @@ The lifecycle of this function is questioning. We are no longer
@@ -304,7 +300,7 @@ The lifecycle of this function is questioning. We are no longer
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/like.html b/docs/reference/like.html index 07f04987a..1088b1a90 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 768703654..f22c56c09 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -450,19 +454,9 @@ A microorganism is categorised as Susceptible, Increased exposure when # }
@@ -473,7 +467,7 @@ A microorganism is categorised as Susceptible, Increased exposure when
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/microorganisms.codes.html b/docs/reference/microorganisms.codes.html index e34402806..0abdb39a9 100644 --- a/docs/reference/microorganisms.codes.html +++ b/docs/reference/microorganisms.codes.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index dcb1c8239..1cadbf321 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/microorganisms.old.html b/docs/reference/microorganisms.old.html index 1eaf56245..1c4cb819a 100644 --- a/docs/reference/microorganisms.old.html +++ b/docs/reference/microorganisms.old.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index df4766098..3fb120fe7 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -437,18 +441,9 @@ This package contains the complete taxonomic tree of almost all microorganisms ( # }
@@ -459,7 +454,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index e22b89165..428e2b64e 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -47,7 +51,7 @@ - + @@ -65,7 +69,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p - +
@@ -224,7 +228,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p
@@ -313,14 +317,9 @@ The lifecycle of this function is stable
@@ -331,7 +330,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/p_symbol.html b/docs/reference/p_symbol.html index 9435ca551..03a78e9fd 100644 --- a/docs/reference/p_symbol.html +++ b/docs/reference/p_symbol.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -263,14 +267,9 @@ The lifecycle of this function is questioni
@@ -281,7 +280,7 @@ The lifecycle of this function is questioni
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/pca.html b/docs/reference/pca.html index 73c83b27c..cd304523d 100644 --- a/docs/reference/pca.html +++ b/docs/reference/pca.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -328,15 +332,9 @@ The lifecycle of this function is maturing< ggplot_pca(pca_result) # a new and convenient plot function
@@ -347,7 +345,7 @@ The lifecycle of this function is maturing<
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/proportion.html b/docs/reference/proportion.html index aafc78e13..cecfbc74b 100644 --- a/docs/reference/proportion.html +++ b/docs/reference/proportion.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -47,7 +51,7 @@ - + @@ -65,7 +69,7 @@ resistance() should be used to calculate resistance, susceptibility() should be - +
@@ -224,7 +228,7 @@ resistance() should be used to calculate resistance, susceptibility() should be
@@ -463,20 +467,9 @@ A microorganism is categorised as Susceptible, Increased exposure when }
@@ -487,7 +480,7 @@ A microorganism is categorised as Susceptible, Increased exposure when
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/read.4D.html b/docs/reference/read.4D.html index 483b4b1e7..b75170fdc 100644 --- a/docs/reference/read.4D.html +++ b/docs/reference/read.4D.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -401,14 +405,9 @@ The lifecycle of this function is dormant
@@ -419,7 +418,7 @@ The lifecycle of this function is dormant
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html index 8cbb83d98..5134f7e28 100644 --- a/docs/reference/reexports.html +++ b/docs/reference/reexports.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -51,7 +55,7 @@ below to see their documentation. cleanerfreq " /> - + @@ -69,7 +73,7 @@ below to see their documentation. - +
@@ -228,14 +232,14 @@ below to see their documentation.

These objects are imported from other packages. Follow the links below to see their documentation.

-
+
cleaner

freq

@@ -246,10 +250,9 @@ below to see their documentation.

@@ -260,7 +263,7 @@ below to see their documentation.

-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index 5cbaa223e..9d7a39b0d 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -434,18 +438,9 @@ A microorganism is categorised as Susceptible, Increased exposure when }
@@ -456,7 +451,7 @@ A microorganism is categorised as Susceptible, Increased exposure when
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html index bc95c3c49..0c5bf48bf 100644 --- a/docs/reference/rsi_translation.html +++ b/docs/reference/rsi_translation.html @@ -82,7 +82,7 @@ AMR (for R) - 1.0.1.9009 + 1.1.0 diff --git a/docs/reference/skewness.html b/docs/reference/skewness.html index 000fa8bed..d0741ab53 100644 --- a/docs/reference/skewness.html +++ b/docs/reference/skewness.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -47,7 +51,7 @@ - + @@ -65,7 +69,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr - +
@@ -224,7 +228,7 @@ When negative: the left tail is longer; the mass of the distribution is concentr
@@ -274,14 +278,9 @@ The lifecycle of this function is questioni
@@ -292,7 +291,7 @@ The lifecycle of this function is questioni
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/docs/reference/translate.html b/docs/reference/translate.html index 5671cd548..9bb47ad30 100644 --- a/docs/reference/translate.html +++ b/docs/reference/translate.html @@ -24,16 +24,20 @@ + + + + - - + + - + - - + + @@ -46,7 +50,7 @@ - + @@ -64,7 +68,7 @@ - +
@@ -223,7 +227,7 @@
@@ -284,14 +288,9 @@ The lifecycle of this function is stable#> "Staphylococcus coagulase negativo (CoNS)"
@@ -302,7 +301,7 @@ The lifecycle of this function is stable
-

Site built with pkgdown 1.4.1.9000.

+

Site built with pkgdown 1.5.0.

diff --git a/git_merge.sh b/git_merge.sh index e7e2af2b3..9f9404ccd 100755 --- a/git_merge.sh +++ b/git_merge.sh @@ -19,17 +19,28 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -####################################################################### -# To push new commits to the premaster branch, run: # -# bash git_premaster.sh "commit message" # -# This creates auto version numbering in DESCRIPTION and NEWS.md. # -# # -# After successful CRAN checks, merge it to the master branch with: # -# bash git_merge.sh # -# # -# To prerelease a new version number, run: # -# bash git_premaster.sh "v0.x.x" FALSE "0.x.x" # -####################################################################### +######################################################################## +# `git_premaster.sh` takes 3 parameters: # +# 1. Commit message (character) [mandatory] # +# 2. Lazy website generation (logical), with FALSE only changed # +# files will be processed [defaults to TRUE] # +# 3. Version number to be used in DESCRIPTION and NEWS.md # +# [defaults to current tag and last commit number + 9000] # +# # +# To push new commits to the premaster branch, run: # +# bash git_premaster.sh "commit message" # +# This creates auto version numbering in DESCRIPTION and NEWS.md. # +# # +# After successful test checks, merge it to the master branch with: # +# bash git_merge.sh # +# # +# To prerelease a new version number, run: # +# bash git_premaster.sh "v1.x.x" FALSE "1.x.x" # +# # +# To only update the website, run: # +# bash git_siteonly.sh # +# (which is short for 'bash git_premaster.sh "website update" FALSE') # +######################################################################## # stash current changes # git stash --quiet @@ -55,7 +66,7 @@ case "$choice" in y|Y|j|J ) ;; * ) exit 1;; esac -Rscript -e "rhub::check(devtools::build(), platform = c('debian-clang-devel', 'debian-gcc-devel', 'fedora-clang-devel', 'fedora-gcc-devel', 'windows-x86_64-devel', 'debian-gcc-patched', 'solaris-x86-patched', 'debian-gcc-release', 'windows-x86_64-release', 'macos-elcapitan-release', 'windows-x86_64-oldrel'))" +Rscript -e "rhub::check(devtools::build(), platform = rhub::platforms()[!is.na(rhub::platforms()$`cran-name`), 'name'])" echo # and get stashed changes back diff --git a/git_premaster.sh b/git_premaster.sh index 478179500..fbd3de3ab 100755 --- a/git_premaster.sh +++ b/git_premaster.sh @@ -19,17 +19,28 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -####################################################################### -# To push new commits to the premaster branch, run: # -# bash git_premaster.sh "commit message" # -# This creates auto version numbering in DESCRIPTION and NEWS.md. # -# # -# After successful CRAN checks, merge it to the master branch with: # -# bash git_merge.sh # -# # -# To prerelease a new version number, run: # -# bash git_premaster.sh "v0.x.x" FALSE "0.x.x" # -####################################################################### +######################################################################## +# `git_premaster.sh` takes 3 parameters: # +# 1. Commit message (character) [mandatory] # +# 2. Lazy website generation (logical), with FALSE only changed # +# files will be processed [defaults to TRUE] # +# 3. Version number to be used in DESCRIPTION and NEWS.md # +# [defaults to current tag and last commit number + 9000] # +# # +# To push new commits to the premaster branch, run: # +# bash git_premaster.sh "commit message" # +# This creates auto version numbering in DESCRIPTION and NEWS.md. # +# # +# After successful test checks, merge it to the master branch with: # +# bash git_merge.sh # +# # +# To prerelease a new version number, run: # +# bash git_premaster.sh "v1.x.x" FALSE "1.x.x" # +# # +# To only update the website, run: # +# bash git_siteonly.sh # +# (which is short for 'bash git_premaster.sh "website update" FALSE') # +######################################################################## if [ -z "$1" ]; then echo "FATAL - no commit message" @@ -41,6 +52,9 @@ else lazy=$2 fi +# be sure to be on premaster branch +git checkout premaster --quiet + echo "••••••••••••••••••••••••••••••••••••••••••••" echo "• Updating package date and version number •" echo "••••••••••••••••••••••••••••••••••••••••••••" @@ -70,6 +84,7 @@ if [ -z "$3" ]; then # add date to 2nd line of NEWS.md when no version number was set sed -i -- "2s/.*/## \Last updated: $(date '+%d-%b-%Y')\<\/small\>/" NEWS.md else + # version number set in command new_version=$3 # rmove 2nd line of NEWS.md (the last changed date) sed -i -- "2s/.*//" NEWS.md @@ -136,5 +151,5 @@ case "$choice" in y|Y|j|J ) ;; * ) exit 1;; esac -Rscript -e "rhub::check(devtools::build(), platform = c('debian-clang-devel', 'debian-gcc-devel', 'fedora-clang-devel', 'fedora-gcc-devel', 'windows-x86_64-devel', 'debian-gcc-patched', 'solaris-x86-patched', 'debian-gcc-release', 'windows-x86_64-release', 'macos-elcapitan-release', 'windows-x86_64-oldrel'))" +Rscript -e "rhub::check(devtools::build(), platform = rhub::platforms()[!is.na(rhub::platforms()$`cran-name`), 'name'])" echo diff --git a/git_siteonly.sh b/git_siteonly.sh index 361b940cb..0c7df013e 100755 --- a/git_siteonly.sh +++ b/git_siteonly.sh @@ -19,17 +19,28 @@ # Visit our website for more info: https://msberends.gitlab.io/AMR. # # ==================================================================== # -####################################################################### -# To push new commits to the premaster branch, run: # -# bash git_premaster.sh "commit message" # -# This creates auto version numbering in DESCRIPTION and NEWS.md. # -# # -# After successful CRAN checks, merge it to the master branch with: # -# bash git_merge.sh # -# # -# To prerelease a new version number, run: # -# bash git_premaster.sh "v0.x.x" FALSE "0.x.x" # -####################################################################### +######################################################################## +# `git_premaster.sh` takes 3 parameters: # +# 1. Commit message (character) [mandatory] # +# 2. Lazy website generation (logical), with FALSE only changed # +# files will be processed [defaults to TRUE] # +# 3. Version number to be used in DESCRIPTION and NEWS.md # +# [defaults to current tag and last commit number + 9000] # +# # +# To push new commits to the premaster branch, run: # +# bash git_premaster.sh "commit message" # +# This creates auto version numbering in DESCRIPTION and NEWS.md. # +# # +# After successful test checks, merge it to the master branch with: # +# bash git_merge.sh # +# # +# To prerelease a new version number, run: # +# bash git_premaster.sh "v1.x.x" FALSE "1.x.x" # +# # +# To only update the website, run: # +# bash git_siteonly.sh # +# (which is short for 'bash git_premaster.sh "website update" FALSE') # +######################################################################## bash git_premaster.sh "website update" FALSE