diff --git a/DESCRIPTION b/DESCRIPTION index c5a7b19d..38aea241 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.7.1.9046 -Date: 2021-10-03 +Version: 1.7.1.9048 +Date: 2021-10-04 Title: Antimicrobial Resistance Data Analysis Description: Functions to simplify and standardise antimicrobial resistance (AMR) data analysis and to work with microbial and antimicrobial properties by diff --git a/NEWS.md b/NEWS.md index 61e9d4d8..1166ed5b 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# `AMR` 1.7.1.9046 -## Last updated: 3 October 2021 +# `AMR` 1.7.1.9048 +## Last updated: 4 October 2021 ### Breaking changes * Removed `p_symbol()` and all `filter_*()` functions (except for `filter_first_isolate()`), which were all deprecated in a previous package version diff --git a/data-raw/AMR_latest.tar.gz b/data-raw/AMR_latest.tar.gz index 41eb9178..847e34bc 100644 Binary files a/data-raw/AMR_latest.tar.gz and b/data-raw/AMR_latest.tar.gz differ diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 17e963e0..2f9c29b4 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -44,7 +44,7 @@ AMR (for R) - 1.7.1.9040 + 1.7.1.9048 @@ -191,7 +191,7 @@

How to conduct AMR data analysis

Matthijs S. Berends

-

29 September 2021

+

04 October 2021

Source: vignettes/AMR.Rmd @@ -200,7 +200,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 29 September 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 04 October 2021.

Introduction

@@ -231,21 +231,21 @@ -2021-09-29 +2021-10-04 abcd Escherichia coli S S -2021-09-29 +2021-10-04 abcd Escherichia coli S R -2021-09-29 +2021-10-04 efgh Escherichia coli R @@ -342,52 +342,52 @@ -2017-08-27 -L5 -Hospital B -Escherichia coli -S -S -S -S -M - - -2017-02-15 -L4 -Hospital C -Escherichia coli -S -S -R -S -M - - -2010-01-01 -H4 +2017-09-21 +T1 Hospital A Escherichia coli R S S S -M +F -2014-12-09 -C5 -Hospital B +2016-12-13 +P9 +Hospital D Escherichia coli S S S S -M +F -2010-02-19 -W1 +2013-09-17 +S3 +Hospital A +Streptococcus pneumoniae +S +S +R +S +F + + +2017-10-22 +R4 +Hospital C +Staphylococcus aureus +S +S +S +S +F + + +2012-01-06 +P6 Hospital D Escherichia coli S @@ -397,15 +397,15 @@ F -2010-11-16 -X9 -Hospital A -Escherichia coli +2014-06-30 +D3 +Hospital C +Staphylococcus aureus +S +S R S -S -S -F +M @@ -439,16 +439,16 @@ Longest: 1

1 M -10,412 -52.06% -10,412 -52.06% +10,351 +51.76% +10,351 +51.76% 2 F -9,588 -47.94% +9,649 +48.25% 20,000 100.00% @@ -501,9 +501,9 @@ Longest: 1

# ℹ Using column 'patient_id' as input for `col_patient_id`. # Basing inclusion on all antimicrobial results, using a points threshold of # 2 -# => Found 10,617 'phenotype-based' first isolates (53.1% of total where a +# => Found 10,567 'phenotype-based' first isolates (52.8% of total where a # microbial ID was available)
-

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

+

So only 52.8% 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)
@@ -511,10 +511,10 @@ Longest: 1

 data_1st <- data %>% 
   filter_first_isolate()
-

So we end up with 10,617 isolates for analysis. Now our data looks like:

+

So we end up with 10,567 isolates for analysis. Now our data looks like:

 head(data_1st)
- +
@@ -528,7 +528,7 @@ Longest: 1

-+ @@ -549,94 +549,94 @@ Longest: 1

+ + + + + + + + + + + + + + + + - - + + - + + + - - - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + - - - - + + + + - - - - + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -665,8 +665,8 @@ Longest: 1

data_1st %>% freq(genus, species)

Frequency table

Class: character
-Length: 10,617
-Available: 10,617 (100.0%, NA: 0 = 0.0%)
+Length: 10,567
+Available: 10,567 (100.0%, NA: 0 = 0.0%)
Unique: 4

Shortest: 16
Longest: 24

@@ -683,33 +683,33 @@ Longest: 24

- - - - + + + + - - - - + + + + - - - - + + + + - - - + + + @@ -728,14 +728,14 @@ Longest: 24

-+-+ @@ -756,13 +756,28 @@ Longest: 24

- - - + + + + + + + + + + + + + + + + + + - + @@ -770,28 +785,13 @@ Longest: 24

- - - - - - - - - - - - - - - - - - + + + - - + + @@ -801,42 +801,12 @@ Longest: 24

- - - - - - - - - - - - - - - - - - + + + - - - - - - - - - - - - - - - @@ -845,6 +815,36 @@ Longest: 24

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
22016-12-13P9Hospital DB_ESCHR_COLISSSSFGram-negativeEscherichiacoliTRUE
32010-01-01H42013-09-17S3 Hospital AB_ESCHR_COLIB_STRPT_PNMNSS RSSSMGram-negativeEscherichiacoliRFGram-positiveStreptococcuspneumoniae TRUE
42014-12-09C5Hospital BB_ESCHR_COLISSSSMGram-negativeEscherichiacoliTRUE
62010-11-16X9Hospital AB_ESCHR_COLIRSSSFGram-negativeEscherichiacoliTRUE
82011-07-04T1Hospital DB_ESCHR_COLISSRSFGram-negativeEscherichiacoliTRUE
102012-05-19M7Hospital D2017-10-22R4Hospital C B_STPHY_AURSRRR SMSSSF Gram-positive Staphylococcus aureus TRUE
142016-05-14C2Hospital D92014-05-28Y8Hospital B B_ESCHR_COLI RIS RSFGram-negativeEscherichiacoliTRUE
112010-02-13Y5Hospital AB_ESCHR_COLIRSSSFGram-negativeEscherichiacoliTRUE
122010-01-30F3Hospital CB_ESCHR_COLIRRS R M Gram-negative
1 Escherichia coli4,56943.03%4,56943.03%4,62343.75%4,62343.75%
2 Staphylococcus aureus2,71825.60%7,28768.64%2,76526.17%7,38869.92%
3 Streptococcus pneumoniae2,15820.33%9,44588.96%2,01719.09%9,40589.00%
4 Klebsiella pneumoniae1,17211.04%10,6171,16211.00%10,567 100.00%
2016-05-14C2Hospital D2013-09-17S3Hospital AB_STRPT_PNMNSSRRFGram-positiveStreptococcuspneumoniaeTRUE
2010-01-30F3Hospital C B_ESCHR_COLI RI RS R M Gram-negative coli TRUE
2013-08-08C10Hospital CB_STRPT_PNMNSSSRMGram-positiveStreptococcuspneumoniaeTRUE
2017-08-12H8Hospital D2011-10-02B9Hospital C B_STRPT_PNMNSSII S R M TRUE
2012-09-19S7Hospital CB_STPHY_AURSRSSRFGram-positiveStaphylococcusaureusTRUE
2016-07-27I10Hospital C2017-09-14Y3Hospital A B_STRPT_PNMNSS R RMGram-positiveStreptococcuspneumoniaeTRUE
2013-11-25P4Hospital DB_STRPT_PNMNSS S R F pneumoniae TRUE
2013-01-07L2Hospital CB_STRPT_PNMNRRSRMGram-positiveStreptococcuspneumoniaeTRUE
2015-06-10O6Hospital DB_ESCHR_COLIRRSRFGram-negativeEscherichiacoliTRUE

If you want to get a quick glance of the number of isolates in different bug/drug combinations, you can use the bug_drug_combinations() function:

@@ -866,50 +866,50 @@ Longest: 24

E. coli AMX -2159 -142 -2268 -4569 +2182 +119 +2322 +4623 E. coli AMC -3349 -169 -1051 -4569 +3388 +143 +1092 +4623 E. coli CIP -3375 +3434 0 -1194 -4569 +1189 +4623 E. coli GEN -3985 +4002 0 -584 -4569 +621 +4623 K. pneumoniae AMX 0 0 -1172 -1172 +1162 +1162 K. pneumoniae AMC -930 -35 -207 -1172 +928 +43 +191 +1162 @@ -932,34 +932,34 @@ Longest: 24

E. coli GEN -3985 +4002 0 -584 -4569 +621 +4623 K. pneumoniae GEN -1073 +1043 0 -99 -1172 +119 +1162 S. aureus GEN -2409 +2461 0 -309 -2718 +304 +2765 S. pneumoniae GEN 0 0 -2158 -2158 +2017 +2017 @@ -973,7 +973,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.5429029
+# [1] 0.5489732

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

 data_1st %>% 
@@ -987,19 +987,19 @@ Longest: 24

Hospital A -0.5478773 +0.5483971 Hospital B -0.5516767 +0.5501101 Hospital C -0.5306768 +0.5632754 Hospital D -0.5297098 +0.5369668 @@ -1018,23 +1018,23 @@ Longest: 24

Hospital A -0.5478773 -3227 +0.5483971 +3213 Hospital B -0.5516767 -3638 +0.5501101 +3632 Hospital C -0.5306768 -1581 +0.5632754 +1612 Hospital D -0.5297098 -2171 +0.5369668 +2110 @@ -1055,27 +1055,27 @@ Longest: 24

Escherichia -0.7699715 -0.8721821 -0.9748304 +0.7637897 +0.8656716 +0.9781527 Klebsiella -0.8233788 -0.9155290 -0.9872014 +0.8356282 +0.8975904 +0.9845095 Staphylococcus -0.7969095 -0.8863135 -0.9790287 +0.7949367 +0.8900542 +0.9804702 Streptococcus -0.5338276 +0.5389192 0.0000000 -0.5338276 +0.5389192 @@ -1090,33 +1090,33 @@ Longest: 24

summarise(across(penicillins(), resistance, as_percent = TRUE)) %>% # format the antibiotic column names, using so-called snake case, # so 'Amoxicillin/clavulanic acid' becomes 'amoxicillin_clavulanic_acid' - rename_with(.fn = ab_name, .cols = penicillins(), snake_case = TRUE)
+ rename_with(set_ab_names, penicillins()) - - + + - + - - + + - + - - + +
hospitalAmoxicillinAmoxicillin/clavulanic acidamoxicillinamoxicillin_clavulanic_acid
Hospital A 54.8%26.7%27.0%
Hospital B55.2%26.9%55.0%26.1%
Hospital C53.1%56.3% 26.9%
Hospital D53.0%25.4%53.7%25.3%
@@ -1200,18 +1200,18 @@ Longest: 24

mic_values <- random_mic(size = 100) mic_values # Class <mic> -# [1] 0.005 0.125 32 0.0625 0.5 0.125 16 0.25 0.025 -# [10] <=0.001 <=0.001 0.0625 0.01 1 2 32 0.01 8 -# [19] 0.005 32 0.005 32 128 0.125 0.125 2 <=0.001 -# [28] 4 8 0.005 0.002 0.5 0.002 0.5 64 0.125 -# [37] 0.01 0.002 0.0625 128 0.5 1 0.125 0.0625 0.002 -# [46] 32 0.025 0.005 8 0.002 <=0.001 8 1 16 -# [55] <=0.001 0.25 0.125 0.025 4 8 0.0625 16 4 -# [64] 64 <=0.001 128 0.125 0.5 4 32 <=0.001 128 -# [73] 16 64 16 0.125 4 2 0.002 0.025 8 -# [82] 4 2 0.01 4 0.125 <=0.001 0.002 0.01 0.5 -# [91] 32 128 0.01 1 0.125 4 0.002 0.25 0.25 -# [100] 16 +# [1] 0.5 0.125 0.002 2 0.0625 128 64 0.002 0.002 +# [10] 8 0.025 256 0.0625 0.25 128 256 0.0625 4 +# [19] 0.025 256 64 256 4 <=0.001 128 0.0625 0.025 +# [28] 256 0.25 0.25 0.01 0.002 0.125 16 0.002 2 +# [37] 0.01 2 8 8 0.125 64 4 128 32 +# [46] 0.25 32 1 1 256 128 128 64 4 +# [55] 128 128 128 0.025 1 4 16 0.01 0.005 +# [64] 0.025 2 0.002 0.25 0.0625 0.005 0.005 16 8 +# [73] 32 0.002 0.01 256 256 1 8 32 8 +# [82] 0.125 0.002 0.005 32 16 8 256 32 0.5 +# [91] 4 0.25 1 0.25 2 2 0.125 0.25 16 +# [100] 4
 # base R:
 plot(mic_values)
@@ -1240,10 +1240,10 @@ Longest: 24

# to review it. disk_values # Class <disk> -# [1] 26 27 19 22 20 17 23 26 26 17 21 21 22 18 19 25 18 20 17 20 20 22 17 31 24 -# [26] 28 22 20 31 18 19 26 25 19 22 19 26 26 24 18 18 19 31 25 31 21 28 23 22 21 -# [51] 22 18 22 18 29 25 29 29 29 24 22 19 23 23 23 22 17 24 17 26 23 25 30 26 17 -# [76] 17 20 31 17 30 25 18 18 22 29 25 24 29 27 26 30 29 18 21 18 24 25 26 31 25 +# [1] 20 29 17 26 24 21 24 26 23 31 21 20 29 20 23 20 20 31 21 22 24 19 28 29 24 +# [26] 31 31 25 30 24 30 30 30 25 22 30 25 22 27 28 19 18 19 31 20 18 18 23 25 23 +# [51] 27 21 24 25 25 21 22 23 25 29 22 21 22 28 30 27 25 21 18 27 30 21 29 25 31 +# [76] 18 19 17 18 23 24 26 30 29 24 24 20 29 28 27 18 31 23 26 30 23 17 23 28 31
 # base R:
 plot(disk_values, mo = "E. coli", ab = "cipro")
diff --git a/docs/articles/AMR_files/figure-html/disk_plots-1.png b/docs/articles/AMR_files/figure-html/disk_plots-1.png index 4db6f29b..2cacec49 100644 Binary files a/docs/articles/AMR_files/figure-html/disk_plots-1.png and b/docs/articles/AMR_files/figure-html/disk_plots-1.png differ diff --git a/docs/articles/AMR_files/figure-html/disk_plots_mo_ab-1.png b/docs/articles/AMR_files/figure-html/disk_plots_mo_ab-1.png index 22b4bfe9..aeaa94f0 100644 Binary files a/docs/articles/AMR_files/figure-html/disk_plots_mo_ab-1.png and b/docs/articles/AMR_files/figure-html/disk_plots_mo_ab-1.png differ diff --git a/docs/articles/AMR_files/figure-html/mic_plots-1.png b/docs/articles/AMR_files/figure-html/mic_plots-1.png index 385ff912..f8521ad8 100644 Binary files a/docs/articles/AMR_files/figure-html/mic_plots-1.png and b/docs/articles/AMR_files/figure-html/mic_plots-1.png differ diff --git a/docs/articles/AMR_files/figure-html/mic_plots-2.png b/docs/articles/AMR_files/figure-html/mic_plots-2.png index 9ed1b6f1..9524a1b0 100644 Binary files a/docs/articles/AMR_files/figure-html/mic_plots-2.png and b/docs/articles/AMR_files/figure-html/mic_plots-2.png differ diff --git a/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-1.png b/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-1.png index 00a88b1c..d3ebf6ad 100644 Binary files a/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-1.png and b/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-1.png differ diff --git a/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-2.png b/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-2.png index 36bbf549..6f72ad56 100644 Binary files a/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-2.png and b/docs/articles/AMR_files/figure-html/mic_plots_mo_ab-2.png differ 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 595798be..b3e72b98 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 18d61b26..196a7abc 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 52dce181..357b9e93 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 c4168fd2..772970b2 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/datasets.html b/docs/articles/datasets.html index b87b0c55..19a1c762 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -44,7 +44,7 @@ AMR (for R) - 1.7.1.9046 + 1.7.1.9048 @@ -190,7 +190,7 @@ diff --git a/docs/articles/welcome_to_AMR.html b/docs/articles/welcome_to_AMR.html index 36886bcb..dbc69193 100644 --- a/docs/articles/welcome_to_AMR.html +++ b/docs/articles/welcome_to_AMR.html @@ -44,7 +44,7 @@ AMR (for R) - 1.7.1.9040 + 1.7.1.9048 diff --git a/docs/news/index.html b/docs/news/index.html index 9a94dbb4..72ef8220 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -92,7 +92,7 @@ AMR (for R) - 1.7.1.9046 + 1.7.1.9048 @@ -240,12 +240,12 @@ Source: NEWS.md -
-

- Unreleased AMR 1.7.1.9046

-
+
+

+ Unreleased AMR 1.7.1.9048

+

-Last updated: 3 October 2021 +Last updated: 4 October 2021

diff --git a/inst/tinytest/test-ab_property.R b/inst/tinytest/test-ab_property.R index 2fdb4b8a..006c4c53 100644 --- a/inst/tinytest/test-ab_property.R +++ b/inst/tinytest/test-ab_property.R @@ -69,7 +69,7 @@ expect_identical(colnames(set_ab_names(example_isolates[, 20:25], language = "nl c("Cefoxitine", "Cefotaxim", "Ceftazidim", "Ceftriaxon", "Gentamicine", "Tobramycine")) expect_identical(colnames(set_ab_names(example_isolates[, 20:25], "atc")), c("J01DC01", "J01DD01", "J01DD02", "J01DD04", "J01GB03", "J01GB01")) -if (AMR:::pkg_is_available("dplyr")) { +if (AMR:::pkg_is_available("dplyr") && packageVersion("dplyr") >= "1.0.0") { expect_identical(example_isolates %>% set_ab_names(), example_isolates %>% rename_with(set_ab_names)) } diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index 2703f578..f74ec274 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -385,13 +385,13 @@ data_1st %>% summarise(across(penicillins(), resistance, as_percent = TRUE)) %>% # format the antibiotic column names, using so-called snake case, # so 'Amoxicillin/clavulanic acid' becomes 'amoxicillin_clavulanic_acid' - rename_with(.fn = ab_name, .cols = penicillins(), snake_case = TRUE) + rename_with(set_ab_names, penicillins()) ``` ```{r, echo = FALSE, message = FALSE} data_1st %>% group_by(hospital) %>% summarise(across(penicillins(), resistance, as_percent = TRUE)) %>% - rename_with(.fn = ab_name, .cols = penicillins(), snake_case = TRUE) %>% + rename_with(set_ab_names, penicillins()) %>% knitr::kable(align = "lrr") ```