diff --git a/DESCRIPTION b/DESCRIPTION index fc14968e..d6127fe9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.5.0.9017 -Date: 2021-02-08 +Version: 1.5.0.9018 +Date: 2021-02-09 Title: Antimicrobial Resistance Data Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index f95332df..a1c220a0 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.5.0.9017 -## Last updated: 8 February 2021 +# AMR 1.5.0.9018 +## Last updated: 9 February 2021 ### New * Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the `eucast_rules()` function and in `as.rsi()` to interpret MIC and disk diffusion values. This is now the default guideline in this package. diff --git a/R/first_isolate.R b/R/first_isolate.R index 81d49977..afdeaa92 100755 --- a/R/first_isolate.R +++ b/R/first_isolate.R @@ -160,7 +160,12 @@ first_isolate <- function(x = NULL, info = interactive(), include_unknown = FALSE, ...) { - meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE) # also checks dimensions to be >0 + if (is_null_or_grouped_tbl(x)) { + # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) + # is also fix for using a grouped df as input (a dot as first argument) + x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) + } + meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0 meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) @@ -184,12 +189,6 @@ first_isolate <- function(x = NULL, meet_criteria(info, allow_class = "logical", has_length = 1) meet_criteria(include_unknown, allow_class = "logical", has_length = 1) - if (is_null_or_grouped_tbl(x)) { - # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) - # is also fix for using a grouped df as input (a dot as first argument) - x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) - meet_criteria(x, allow_class = "data.frame") - } # remove data.table, grouping from tibbles, etc. x <- as.data.frame(x, stringsAsFactors = FALSE) @@ -512,16 +511,16 @@ filter_first_isolate <- function(x = NULL, col_patient_id = NULL, col_mo = NULL, ...) { - meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE) - meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) - meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) - meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) if (is_null_or_grouped_tbl(x)) { # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) # is also fix for using a grouped df as input (a dot as first argument) x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) - meet_criteria(x, allow_class = "data.frame") } + meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0 + meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + subset(x, first_isolate(x = x, col_date = col_date, col_patient_id = col_patient_id, @@ -537,17 +536,17 @@ filter_first_weighted_isolate <- function(x = NULL, col_mo = NULL, col_keyantibiotics = NULL, ...) { - meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE) - meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) - meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) - meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) - meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) if (is_null_or_grouped_tbl(x)) { # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) # is also fix for using a grouped df as input (a dot as first argument) x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) - meet_criteria(x, allow_class = "data.frame") } + meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0 + meet_criteria(col_date, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + meet_criteria(col_patient_id, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + meet_criteria(col_keyantibiotics, allow_class = "character", has_length = 1, allow_NULL = TRUE, is_in = colnames(x)) + y <- x if (is.null(col_keyantibiotics)) { # first try to look for it diff --git a/R/key_antibiotics.R b/R/key_antibiotics.R index 11f4195e..b177f6e6 100755 --- a/R/key_antibiotics.R +++ b/R/key_antibiotics.R @@ -130,7 +130,12 @@ key_antibiotics <- function(x = NULL, GramNeg_6 = guess_ab_col(x, "meropenem"), warnings = TRUE, ...) { - meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE) + if (is_null_or_grouped_tbl(x)) { + # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) + # is also fix for using a grouped df as input (a dot as first argument) + x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) + } + meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0 meet_criteria(col_mo, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE) meet_criteria(universal_1, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE) meet_criteria(universal_2, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE) @@ -152,12 +157,6 @@ key_antibiotics <- function(x = NULL, meet_criteria(GramNeg_6, allow_class = "character", has_length = 1, allow_NULL = TRUE, allow_NA = TRUE) meet_criteria(warnings, allow_class = "logical", has_length = 1) - if (is_null_or_grouped_tbl(x)) { - # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) - # is also fix for using a grouped df as input (a dot as first argument) - x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) - meet_criteria(x, allow_class = "data.frame") - } # force regular data.frame, not a tibble or data.table x <- as.data.frame(x, stringsAsFactors = FALSE) diff --git a/R/mdro.R b/R/mdro.R index e14206f5..d2fa22f9 100755 --- a/R/mdro.R +++ b/R/mdro.R @@ -155,7 +155,12 @@ mdro <- function(x = NULL, verbose = FALSE, only_rsi_columns = FALSE, ...) { - meet_criteria(x, allow_class = "data.frame", allow_NULL = TRUE) + if (is_null_or_grouped_tbl(x)) { + # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) + # is also fix for using a grouped df as input (a dot as first argument) + x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) + } + meet_criteria(x, allow_class = "data.frame") # also checks dimensions to be >0 meet_criteria(guideline, allow_class = c("list", "character"), allow_NULL = TRUE) if (!is.list(guideline)) { meet_criteria(guideline, allow_class = "character", has_length = 1, allow_NULL = TRUE) @@ -214,14 +219,7 @@ mdro <- function(x = NULL, } } } - - if (is_null_or_grouped_tbl(x)) { - # when `x` is left blank, auto determine it (get_current_data() also contains dplyr::cur_data_all()) - # is also fix for using a grouped df as input (a dot as first argument) - x <- tryCatch(get_current_data(arg_name = "x", call = -2), error = function(e) x) - meet_criteria(x, allow_class = "data.frame") - } - + # force regular data.frame, not a tibble or data.table x <- as.data.frame(x, stringsAsFactors = FALSE) diff --git a/data-raw/AMR_1.5.0.9017.tar.gz b/data-raw/AMR_1.5.0.9018.tar.gz similarity index 88% rename from data-raw/AMR_1.5.0.9017.tar.gz rename to data-raw/AMR_1.5.0.9018.tar.gz index c3ea82bb..867e430b 100644 Binary files a/data-raw/AMR_1.5.0.9017.tar.gz and b/data-raw/AMR_1.5.0.9018.tar.gz differ diff --git a/docs/404.html b/docs/404.html index 90d7944f..48b6c031 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018 diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index bc5967d7..bf77346f 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018 diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index ab846bbf..3b22530a 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.5.0.9014 + 1.5.0.9018 @@ -193,7 +193,7 @@

How to conduct AMR data analysis

Matthijs S. Berends

-

02 February 2021

+

09 February 2021

Source: vignettes/AMR.Rmd @@ -202,7 +202,7 @@ -

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

+

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 09 February 2021.

Introduction

@@ -233,21 +233,21 @@ -2021-02-02 +2021-02-09 abcd Escherichia coli S S -2021-02-02 +2021-02-09 abcd Escherichia coli S R -2021-02-02 +2021-02-09 efgh Escherichia coli R @@ -352,71 +352,71 @@ -2012-05-30 -Q5 +2014-07-31 +F7 Hospital B -Staphylococcus aureus -R -I -S -S -F - - -2012-10-04 -R8 -Hospital A Escherichia coli R -I -S -S -F - - -2015-02-19 -T6 -Hospital A -Klebsiella pneumoniae -S -S -R -S -F - - -2015-07-17 -R4 -Hospital C -Streptococcus pneumoniae -R -S -S -S -F - - -2011-01-13 -Q4 -Hospital B -Staphylococcus aureus -R -S -S -S -F - - -2013-04-17 -A6 -Hospital C -Staphylococcus aureus -S S S S M + +2017-11-01 +W10 +Hospital B +Escherichia coli +S +S +S +S +F + + +2013-06-17 +T1 +Hospital D +Klebsiella pneumoniae +S +S +S +S +F + + +2012-12-13 +Q2 +Hospital C +Streptococcus pneumoniae +R +R +S +S +F + + +2010-01-01 +O10 +Hospital B +Staphylococcus aureus +R +S +S +S +F + + +2010-07-24 +V5 +Hospital A +Staphylococcus aureus +S +S +R +S +F +

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

@@ -449,16 +449,16 @@ Longest: 1

1 M -10,232 -51.16% -10,232 -51.16% +10,335 +51.68% +10,335 +51.68% 2 F -9,768 -48.84% +9,665 +48.33% 20,000 100.00% @@ -503,7 +503,7 @@ Longest: 1

# 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.4% is suitable for resistance analysis! We can now filter on it with the filter() function, also from the dplyr package:

+

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)
@@ -515,7 +515,7 @@ Longest: 1

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 E. coli isolates of patient J3, 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 E. coli isolates of patient N1, sorted on date:

@@ -531,30 +531,30 @@ Longest: 1

- - + + - - + + - - + + - - - + + + - - + + @@ -564,19 +564,19 @@ Longest: 1

- - + + - - + + - - + + @@ -586,52 +586,52 @@ Longest: 1

- - + + + + + - - - - - + + - + - - + + + + - - - - + + + - - + - - + + @@ -641,7 +641,7 @@ Longest: 1

isolate
12010-01-21J32010-02-03N1 B_ESCHR_COLIRRIS S S TRUE
22010-03-02J32010-04-02N1 B_ESCHR_COLIRRRSSS S FALSE
32010-08-02J32010-06-23N1 B_ESCHR_COLI S S
42010-10-11J32010-06-25N1 B_ESCHR_COLISS RRS S FALSE
52010-10-15J32010-10-04N1 B_ESCHR_COLI S S
62010-10-23J32010-10-11N1 B_ESCHR_COLISSS RSSS FALSE
72010-11-25J32010-10-29N1 B_ESCHR_COLI RRS S S FALSE
82010-12-31J32010-11-11N1 B_ESCHR_COLISS R SSS FALSE
92011-02-25J32010-12-06N1 B_ESCHR_COLI RS R SSTRUEFALSE
102011-03-01J32010-12-13N1 B_ESCHR_COLI R R
-

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 %>% 
@@ -665,11 +665,11 @@ Longest: 1

1 -2010-01-21 -J3 +2010-02-03 +N1 B_ESCHR_COLI -R -R +I +S S S TRUE @@ -677,44 +677,44 @@ Longest: 1

2 -2010-03-02 -J3 +2010-04-02 +N1 B_ESCHR_COLI -R -R -R +S +S +S S FALSE -TRUE +FALSE 3 -2010-08-02 -J3 +2010-06-23 +N1 B_ESCHR_COLI S S S S FALSE -TRUE +FALSE 4 -2010-10-11 -J3 +2010-06-25 +N1 B_ESCHR_COLI -S -S R +R +S S FALSE TRUE 5 -2010-10-15 -J3 +2010-10-04 +N1 B_ESCHR_COLI S S @@ -725,23 +725,23 @@ Longest: 1

6 -2010-10-23 -J3 +2010-10-11 +N1 B_ESCHR_COLI +S +S +S R -S -S -S FALSE TRUE 7 -2010-11-25 -J3 +2010-10-29 +N1 B_ESCHR_COLI R -R +S S S FALSE @@ -749,48 +749,48 @@ Longest: 1

8 -2010-12-31 -J3 +2010-11-11 +N1 B_ESCHR_COLI +S +S R S -S -S FALSE TRUE 9 -2011-02-25 -J3 +2010-12-06 +N1 B_ESCHR_COLI R +S R S -S -TRUE +FALSE TRUE 10 -2011-03-01 -J3 +2010-12-13 +N1 B_ESCHR_COLI R R S S FALSE -FALSE +TRUE -

Instead of 2, now 9 isolates are flagged. In total, 78.5% of all isolates are marked ‘first weighted’ - 50.2% 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 8 isolates are flagged. In total, 78.2% of all isolates are marked ‘first weighted’ - 50.0% 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,707 isolates for analysis.

+

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

We can remove unneeded columns:

 data_1st <- data_1st %>% 
@@ -800,6 +800,7 @@ Longest: 1

head(data_1st)
+@@ -815,6 +816,7 @@ Longest: 1

+ @@ -831,53 +833,9 @@ Longest: 1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + @@ -890,9 +848,10 @@ Longest: 1

- - - + + + + @@ -905,16 +864,65 @@ Longest: 1

- - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -941,8 +949,8 @@ Longest: 1

data_1st %>% freq(genus, species)

Frequency table

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

Shortest: 16
Longest: 24

@@ -959,33 +967,33 @@ Longest: 24

- - - - + + + + - - - - + + + + - - - - + + + + - - - + + + @@ -1012,50 +1020,50 @@ Longest: 24

- - - - + + + + - - - - + + + + - + - - + + - + - - + + - - + + - - - - + + + +
date patient_id hospital
2012-05-30Q5Hospital BB_STPHY_AURSRISSFGram-positiveStaphylococcusaureusTRUE
2012-10-04R8Hospital AB_ESCHR_COLIRISSFGram-negativeEscherichiacoliTRUE
2015-02-19T6Hospital AB_KLBSL_PNMNRSRSFGram-negativeKlebsiellapneumoniaeTRUE
2015-07-17R442012-12-13Q2 Hospital C B_STRPT_PNMN R pneumoniae TRUE
2011-01-13Q4
52010-01-01O10 Hospital B B_STPHY_AURS R aureus TRUE
2013-04-17A6Hospital C
62010-07-24V5Hospital A B_STPHY_AURS S SR SFGram-positiveStaphylococcusaureusTRUE
72014-07-13G3Hospital BB_ESCHR_COLIRSRRMGram-negativeEscherichiacoliTRUE
82013-07-06K1Hospital DB_ESCHR_COLISSR S MGram-negativeEscherichiacoliTRUE
92011-07-06X4Hospital CB_STPHY_AURSRRSSF Gram-positive Staphylococcus aureus
1 Escherichia coli7,92150.43%7,92150.43%7,84650.14%7,84650.14%
2 Staphylococcus aureus3,85324.53%11,77474.96%3,87124.74%11,71774.88%
3 Streptococcus pneumoniae2,34914.96%14,12389.92%2,33114.90%14,04889.78%
4 Klebsiella pneumoniae1,58410.08%15,7071,60010.22%15,648 100.00%
E. coli AMX377524339037921376426338197846
E. coli AMC622329814007921628625513057846
E. coli CIP59955931 01926792119157846
E. coli GEN71737043 074879218037846
K. pneumoniae AMX 0 01584158416001600
K. pneumoniae AMC12305729715841270642661600
@@ -1078,34 +1086,34 @@ Longest: 24

E. coli CIP -5995 +5931 0 -1926 -7921 +1915 +7846 K. pneumoniae CIP -1217 +1214 0 -367 -1584 +386 +1600 S. aureus CIP -2930 +2965 0 -923 -3853 +906 +3871 S. pneumoniae CIP -1814 +1801 0 -535 -2349 +530 +2331 @@ -1118,7 +1126,7 @@ Longest: 24

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.5358121
+# [1] 0.5357873

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

 data_1st %>% 
@@ -1133,19 +1141,19 @@ Longest: 24

Hospital A -0.5293870 +0.5376208 Hospital B -0.5388889 +0.5299270 Hospital C -0.5364048 +0.5439754 Hospital D -0.5397891 +0.5373087 @@ -1165,23 +1173,23 @@ Longest: 24

Hospital A -0.5293870 -4747 +0.5376208 +4758 Hospital B -0.5388889 -5400 +0.5299270 +5480 Hospital C -0.5364048 -2431 +0.5439754 +2274 Hospital D -0.5397891 -3129 +0.5373087 +3136 @@ -1203,27 +1211,27 @@ Longest: 24

Escherichia -0.8232546 -0.9055675 -0.9868703 +0.8336732 +0.8976549 +0.9850879 Klebsiella -0.8125000 -0.9084596 -0.9848485 +0.8337500 +0.9050000 +0.9812500 Staphylococcus -0.8219569 -0.9270698 -0.9890994 +0.8235598 +0.9227590 +0.9842418 Streptococcus -0.5598127 +0.5456885 0.0000000 -0.5598127 +0.5456885 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 ccee1219..fac59d74 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 8168b631..1078fd51 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 22edb04d..c096fea4 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 43b81a7c..8134a60a 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/MDR.html b/docs/articles/MDR.html index a7e2e8b2..0e86071e 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.5.0.9014 + 1.5.0.9018
@@ -285,7 +285,7 @@

Class: factor > ordered (numeric)
Length: 2,000
Levels: 4: Negative < Multi-drug-resistant (MDR) < Extensively drug-resistant …
-Available: 1,747 (87.35%, NA: 253 = 12.65%)
+Available: 1,745 (87.25%, NA: 255 = 12.75%)
Unique: 2

@@ -301,16 +301,16 @@ Unique: 2

- + - + - - - + + + @@ -339,18 +339,18 @@ Unique: 2

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

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

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

- - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - + + diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index c89747eb..29dfcd95 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.5.0.9015 + 1.5.0.9018 diff --git a/docs/articles/index.html b/docs/articles/index.html index be0ffa27..ad832dd2 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018 diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html index be7dc4d7..96a6dcb5 100644 --- a/docs/articles/resistance_predict.html +++ b/docs/articles/resistance_predict.html @@ -39,7 +39,7 @@ AMR (for R) - 1.5.0.9014 + 1.5.0.9018 diff --git a/docs/articles/welcome_to_AMR.html b/docs/articles/welcome_to_AMR.html index faecd4ca..24991a11 100644 --- a/docs/articles/welcome_to_AMR.html +++ b/docs/articles/welcome_to_AMR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.5.0.9014 + 1.5.0.9018 diff --git a/docs/authors.html b/docs/authors.html index ab0d3f3f..471ce3c5 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018 diff --git a/docs/index.html b/docs/index.html index 53683825..c442e626 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018 diff --git a/docs/news/index.html b/docs/news/index.html index 4e350e63..e771b466 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9015 + 1.5.0.9018 @@ -236,22 +236,28 @@ Source: NEWS.md -
-

-AMR 1.5.0.9015 Unreleased +
+

+AMR 1.5.0.9018 Unreleased

-
+

-Last updated: 4 February 2021 +Last updated: 9 February 2021

-
+

-Breaking

+New

  • -

    Functions that are applied to a data set containing antibiotic columns gained the argument only_rsi_columns, which defaults to TRUE if any of the columns are of class <rsi> (i.e., transformed with as.rsi()). This increases reliability of automatic determination of antibiotic columns (so only columns that are defined to be <rsi> will be affected).

    -

    This change might invalidate existing code. But since the new argument always returns FALSE when no <rsi> column can be found in the data, this chance is low.

    -

    Affected functions are:

    +

    Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the eucast_rules() function and in as.rsi() to interpret MIC and disk diffusion values. This is now the default guideline in this package.

    +
      +
    • Added function eucast_dosage() to get a data.frame with advised dosages of a certain bug-drug combination, which is based on the new dosage data set
    • +
    • Added data set dosage to fuel the new eucast_dosage() function and to make this data available in a structured way
    • +
    • Existing data set example_isolates now reflects the latest EUCAST rules
    • +
    +
  • +
  • +

    Added argument only_rsi_columns for some functions, which defaults to FALSE, to indicate if the functions must only be applied to columns that are of class <rsi> (i.e., transformed with as.rsi()). This increases speed since automatic determination of antibiotic columns is not needed anymore. Affected functions are:

    -

    You can quickly transform all your eligible columns using either:

    +
  • +
  • +

    Functions oxazolidinones() (an antibiotic selector function) and filter_oxazolidinones() (an antibiotic filter function) to select/filter on e.g. linezolid and tedizolid

     
     library(dplyr)
    -your_date %>% mutate_if(is.rsi.eligible, as.rsi)        # old dplyr
    -your_date %>% mutate(across((is.rsi.eligible), as.rsi)) # new dplyr
    +x <- example_isolates %>% select(date, hospital_id, oxazolidinones()) +#> Selecting oxazolidinones: column 'LNZ' (linezolid) + +x <- example_isolates %>% filter_oxazolidinones() +#> Filtering on oxazolidinones: value in column `LNZ` (linezolid) is either "R", "S" or "I"
- - -
-

-New

-
    -
  • Support for EUCAST Clinical Breakpoints v11.0 (2021), effective in the eucast_rules() function and in as.rsi() to interpret MIC and disk diffusion values. This is now the default guideline in this package.

  • -
  • Data set dosage to fuel the new eucast_dosage() function and to make this data available in a structured way

  • -
  • Function eucast_dosage() to get a data.frame with advised dosages of a certain bug-drug combination, which is based on the new dosage data set

  • Support for custom MDRO guidelines, using the new custom_mdro_guideline() function, please see mdro() for additional info

  • Function isolate_identifier(), which will paste a microorganism code with all antimicrobial results of a data set into one string for each row. This is useful to compare isolates, e.g. between institutions or regions, when there is no genotyping available.

  • @@ -320,10 +322,9 @@
  • Functions get_episode() and is_new_episode() now support less than a day as value for argument episode_days (e.g., to include one patient/test per hour)
  • Argument ampc_cephalosporin_resistance in eucast_rules() now also applies to value “I” (not only “S”)
  • Updated colours of values R, S and I in tibble printing
  • -
  • Functions print() and summary() on a Principal Components Analysis object (pca()) now print additional group info if the original data was grouped using dplyr::group_by() -
  • -
  • Improved speed of guess_ab_col() +
  • Functions print() and summary() on a Principal Components Analysis object (pca()) now print additional group info if the original data was grouped using dplyr::group_by()
  • +
  • Improved speed and reliability of guess_ab_col(). As this also internally improves the reliability of first_isolate() and mdro(), this might have a slight impact on the results of those functions.
@@ -641,16 +642,16 @@

AMR 1.2.0 2020-05-28

-
+

-Breaking

+Breaking
  • Removed code dependency on all other R packages, making this package fully independent of the development process of others. This is a major code change, but will probably not be noticeable by most users.

    Making this package independent of especially the tidyverse (e.g. packages dplyr and tidyr) tremendously increases sustainability on the long term, since tidyverse functions change quite often. Good for users, but hard for package maintainers. Most of our functions are replaced with versions that only rely on base R, which keeps this package fully functional for many years to come, without requiring a lot of maintenance to keep up with other packages anymore. Another upside it that this package can now be used with all versions of R since R-3.0.0 (April 2013). Our package is being used in settings where the resources are very limited. Fewer dependencies on newer software is helpful for such settings.

    Negative effects of this change are:

      -
    • Function freq() that was borrowed from the cleaner package was removed. Use cleaner::freq(), or run library("cleaner") before you use freq().
    • +
    • Function freq() that was borrowed from the cleaner package was removed. Use cleaner::freq(), or run library("cleaner") before you use freq().
    • Printing values of class mo or rsi in a tibble will no longer be in colour and printing rsi in a tibble will show the class <ord>, not <rsi> anymore. This is purely a visual effect.
    • All functions from the mo_* family (like mo_name() and mo_gramstain()) are noticeably slower when running on hundreds of thousands of rows.
    • For developers: classes mo and ab now both also inherit class character, to support any data transformation. This change invalidates code that checks for class length == 1.
    • @@ -851,9 +852,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/

      AMR 0.9.0 2019-11-29

      -
      +

      -Breaking

      +Breaking
      • Adopted Adeolu et al. (2016), PMID 27620848 for the microorganisms data set, which means that the new order Enterobacterales now consists of a part of the existing family Enterobacteriaceae, but that this family has been split into other families as well (like Morganellaceae and Yersiniaceae). Although published in 2016, this information is not yet in the Catalogue of Life version of 2019. All MDRO determinations with mdro() will now use the Enterobacterales order for all guidelines before 2016 that were dependent on the Enterobacteriaceae family.
          @@ -959,9 +960,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/

          AMR 0.8.0 2019-10-15

          -
          +

          -Breaking

          +Breaking
          • Determination of first isolates now excludes all ‘unknown’ microorganisms at default, i.e. microbial code "UNKNOWN". They can be included with the new argument include_unknown:

            @@ -987,7 +988,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ #> invalid microorganism code, NA generated

          This is important, because a value like "testvalue" could never be understood by e.g. mo_name(), although the class would suggest a valid microbial code.

          -
        • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

        • +
        • Function freq() has moved to a new package, clean (CRAN link), since creating frequency tables actually does not fit the scope of this package. The freq() function still works, since it is re-exported from the clean package (which will be installed automatically upon updating this AMR package).

        • Renamed data set septic_patients to example_isolates

      @@ -1256,7 +1257,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • The age() function gained a new argument exact to determine ages with decimals
    • Removed deprecated functions guess_mo(), guess_atc(), EUCAST_rules(), interpretive_reading(), rsi()
    • -
    • Frequency tables (freq()): +
    • Frequency tables (freq()):
      • speed improvement for microbial IDs

      • fixed factor level names for R Markdown

      • @@ -1266,12 +1267,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
         
         septic_patients %>% 
        -  freq(age) %>% 
        +  freq(age) %>% 
           boxplot()
         # grouped boxplots:
         septic_patients %>% 
           group_by(hospital_id) %>% 
        -  freq(age) %>%
        +  freq(age) %>%
           boxplot()
      @@ -1281,7 +1282,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • Added ceftazidim intrinsic resistance to Streptococci
    • Changed default settings for age_groups(), to let groups of fives and tens end with 100+ instead of 120+
    • -
    • Fix for freq() for when all values are NA +
    • Fix for freq() for when all values are NA
    • Fix for first_isolate() for when dates are missing
    • Improved speed of guess_ab_col() @@ -1522,7 +1523,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • -
  • Frequency tables (freq() function): +
  • Frequency tables (freq() function):
    • Support for tidyverse quasiquotation! Now you can create frequency tables of function outcomes:

      @@ -1532,15 +1533,15 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # OLD WAY septic_patients %>% mutate(genus = mo_genus(mo)) %>% - freq(genus) + freq(genus) # NEW WAY septic_patients %>% - freq(mo_genus(mo)) + freq(mo_genus(mo)) # Even supports grouping variables: septic_patients %>% group_by(gender) %>% - freq(mo_genus(mo))
+ freq(mo_genus(mo))
  • Header info is now available as a list, with the header function

  • The argument header is now set to TRUE at default, even for markdown

  • @@ -1623,7 +1624,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Using portion_* functions now throws a warning when total available isolate is below argument minimum

  • Functions as.mo, as.rsi, as.mic, as.atc and freq will not set package name as attribute anymore

  • -

    Frequency tables - freq():

    +

    Frequency tables - freq():

    • Support for grouping variables, test with:

      @@ -1631,14 +1632,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ septic_patients %>% group_by(hospital_id) %>% - freq(gender)
  • + freq(gender)
  • Support for (un)selecting columns:

     
     septic_patients %>% 
    -  freq(hospital_id) %>% 
    +  freq(hospital_id) %>% 
       select(-count, -cum_count) # only get item, percent, cum_percent
  • Check for hms::is.hms

  • @@ -1656,7 +1657,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Removed diacritics from all authors (columns microorganisms$ref and microorganisms.old$ref) to comply with CRAN policy to only allow ASCII characters

  • Fix for mo_property not working properly

  • Fix for eucast_rules where some Streptococci would become ceftazidime R in EUCAST rule 4.5

  • -
  • Support for named vectors of class mo, useful for top_freq()

  • +
  • Support for named vectors of class mo, useful for top_freq()

  • ggplot_rsi and scale_y_percent have breaks argument

  • AI improvements for as.mo:

    @@ -1824,13 +1825,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
     
     my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
    -freq(my_matrix)
    +freq(my_matrix)

    For lists, subsetting is possible:

     
     my_list = list(age = septic_patients$age, gender = septic_patients$gender)
    -my_list %>% freq(age)
    -my_list %>% freq(gender)
    +my_list %>% freq(age) +my_list %>% freq(gender)
  • @@ -1904,13 +1905,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • A vignette to explain its usage
    • Support for rsi (antimicrobial resistance) to use as input
    • -
    • Support for table to use as input: freq(table(x, y)) +
    • Support for table to use as input: freq(table(x, y))
    • Support for existing functions hist and plot to use a frequency table as input: hist(freq(df$age))
    • Support for as.vector, as.data.frame, as_tibble and format
    • -
    • Support for quasiquotation: freq(mydata, mycolumn) is the same as mydata %>% freq(mycolumn) +
    • Support for quasiquotation: freq(mydata, mycolumn) is the same as mydata %>% freq(mycolumn)
    • Function top_freq function to return the top/below n items as vector
    • Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)
    • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 21a36d32..fadcf937 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -12,7 +12,7 @@ articles: datasets: datasets.html resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html -last_built: 2021-02-08T19:58Z +last_built: 2021-02-09T11:26Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/index.html b/docs/reference/index.html index 5c6ae730..e6a0c8d6 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018 diff --git a/docs/survey.html b/docs/survey.html index 07e2bfb7..c30b89f2 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.5.0.9017 + 1.5.0.9018
    1 Negative 161792.56%92.66% 161792.56%92.66%
    2 Multi-drug-resistant (MDR)1307.44%17471287.34%1745 100.00%
    1 Mono-resistant321164.22%321164.22%324664.92%324664.92%
    2 Negative99019.80%420184.02%97619.52%422284.44%
    3 Multi-drug-resistant4358.70%463692.72%4679.34%468993.78%
    4 Poly-resistant2585.16%489497.88%2304.60%491998.38%
    5 Extensively drug-resistant1062.12%811.62% 5000 100.00%