diff --git a/DESCRIPTION b/DESCRIPTION index 8290e2587..4c40fb409 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: AMR -Version: 1.3.0.9014 +Version: 1.3.0.9015 Date: 2020-09-03 Title: Antimicrobial Resistance Analysis Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 1d1edb1d9..39234a84a 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,5 @@ -# AMR 1.3.0.9014 -## Last updated: 3 September 2020 +# AMR 1.3.0.9015 +## Last updated: 3 September 2020 Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt to. We are those reviewers very grateful for going through our code so thoroughly! diff --git a/R/globals.R b/R/globals.R index 74f68be9e..85d4f247e 100755 --- a/R/globals.R +++ b/R/globals.R @@ -40,6 +40,7 @@ globalVariables(c(".rowid", "intrinsic_resistant", "isolates", "lang", + "language", "lookup", "microorganism", "microorganisms", diff --git a/R/mo.R b/R/mo.R index 6ed7543dd..747a7f04d 100755 --- a/R/mo.R +++ b/R/mo.R @@ -178,6 +178,13 @@ as.mo <- function(x, ...) { check_dataset_integrity() + + if (tryCatch(all(tolower(x) %in% MO_lookup$fullname_lower, na.rm = TRUE) + & isFALSE(Becker) + & isFALSE(Lancefield), error = function(e) FALSE)) { + # to improve speed, special case for taxonomically correct full names (case-insensitive) + return(MO_lookup[match(tolower(x), MO_lookup$fullname_lower), "mo", drop = TRUE]) + } # start off with replaced language-specific non-ASCII characters with ASCII characters x <- parse_and_convert(x) diff --git a/R/zzz.R b/R/zzz.R index 3538a6ee9..d298ee5d2 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -29,7 +29,7 @@ envir = asNamespace("AMR")) assign(x = "LANGUAGES_SUPPORTED", - value = sort(c("en", unique(AMR:::translations_file$lang))), + value = sort(c("en", unique(translations_file$lang))), envir = asNamespace("AMR")) # support for tibble headers (type_sum) and tibble columns content (pillar_shaft) @@ -50,13 +50,13 @@ } .onAttach <- function(...) { - if (!interactive() || stats::runif(1) > 0.1 || isTRUE(as.logical(Sys.getenv("AMR_silentstart", FALSE)))) { + if (!interactive() || stats::runif(1) > 0.1 || isTRUE(as.logical(getOption("AMR_silentstart", FALSE)))) { return() } packageStartupMessage("Thank you for using the AMR package! ", "If you have a minute, please anonymously fill in this short questionnaire to improve the package and its functionalities:", "\nhttps://msberends.github.io/AMR/survey.html", - "\n[ prevent his notice with suppressPackageStartupMessages(library(AMR)) or use Sys.setenv(AMR_silentstart = TRUE) ]") + "\n[ prevent his notice with suppressPackageStartupMessages(library(AMR)) or use options(AMR_silentstart = TRUE) ]") } create_MO_lookup <- function() { diff --git a/data-raw/antibiotics.dta b/data-raw/antibiotics.dta index edfa549c9..e67a7a999 100644 Binary files a/data-raw/antibiotics.dta and b/data-raw/antibiotics.dta differ diff --git a/data-raw/antibiotics.sas b/data-raw/antibiotics.sas index a98869dab..5f4aeb0a4 100644 Binary files a/data-raw/antibiotics.sas and b/data-raw/antibiotics.sas differ diff --git a/data-raw/antibiotics.sav b/data-raw/antibiotics.sav index e29f56b7d..d797056ff 100644 Binary files a/data-raw/antibiotics.sav and b/data-raw/antibiotics.sav differ diff --git a/data-raw/antibiotics.xlsx b/data-raw/antibiotics.xlsx index b18c74b1f..ea96de58a 100644 Binary files a/data-raw/antibiotics.xlsx and b/data-raw/antibiotics.xlsx differ diff --git a/data-raw/antivirals.dta b/data-raw/antivirals.dta index 9f845af02..5a850d13b 100644 Binary files a/data-raw/antivirals.dta and b/data-raw/antivirals.dta differ diff --git a/data-raw/antivirals.sas b/data-raw/antivirals.sas index 3e24b2392..436a75ad8 100644 Binary files a/data-raw/antivirals.sas and b/data-raw/antivirals.sas differ diff --git a/data-raw/antivirals.sav b/data-raw/antivirals.sav index dd824013f..6a57eba75 100644 Binary files a/data-raw/antivirals.sav and b/data-raw/antivirals.sav differ diff --git a/data-raw/antivirals.xlsx b/data-raw/antivirals.xlsx index e5586625d..19478cf3c 100644 Binary files a/data-raw/antivirals.xlsx and b/data-raw/antivirals.xlsx differ diff --git a/data-raw/intrinsic_resistant.dta b/data-raw/intrinsic_resistant.dta index 1949b6596..2d9cec0a1 100644 Binary files a/data-raw/intrinsic_resistant.dta and b/data-raw/intrinsic_resistant.dta differ diff --git a/data-raw/intrinsic_resistant.sas b/data-raw/intrinsic_resistant.sas index c2c8bed20..b652469d8 100644 Binary files a/data-raw/intrinsic_resistant.sas and b/data-raw/intrinsic_resistant.sas differ diff --git a/data-raw/intrinsic_resistant.sav b/data-raw/intrinsic_resistant.sav index 82221c5ba..75b9e9d0f 100644 Binary files a/data-raw/intrinsic_resistant.sav and b/data-raw/intrinsic_resistant.sav differ diff --git a/data-raw/intrinsic_resistant.xlsx b/data-raw/intrinsic_resistant.xlsx index 8432e2220..39aba4d8c 100644 Binary files a/data-raw/intrinsic_resistant.xlsx and b/data-raw/intrinsic_resistant.xlsx differ diff --git a/data-raw/microorganisms.dta b/data-raw/microorganisms.dta index 7c9723b8a..72619ea9c 100644 Binary files a/data-raw/microorganisms.dta and b/data-raw/microorganisms.dta differ diff --git a/data-raw/microorganisms.old.dta b/data-raw/microorganisms.old.dta index 0b8658b63..519118cba 100644 Binary files a/data-raw/microorganisms.old.dta and b/data-raw/microorganisms.old.dta differ diff --git a/data-raw/microorganisms.old.sas b/data-raw/microorganisms.old.sas index c03417d5f..12d3927f1 100644 Binary files a/data-raw/microorganisms.old.sas and b/data-raw/microorganisms.old.sas differ diff --git a/data-raw/microorganisms.old.sav b/data-raw/microorganisms.old.sav index 4b40d83b6..8c66c83b8 100644 Binary files a/data-raw/microorganisms.old.sav and b/data-raw/microorganisms.old.sav differ diff --git a/data-raw/microorganisms.old.xlsx b/data-raw/microorganisms.old.xlsx index 211c56c2f..32065953f 100644 Binary files a/data-raw/microorganisms.old.xlsx and b/data-raw/microorganisms.old.xlsx differ diff --git a/data-raw/microorganisms.sas b/data-raw/microorganisms.sas index 10fdb0752..8877096e5 100644 Binary files a/data-raw/microorganisms.sas and b/data-raw/microorganisms.sas differ diff --git a/data-raw/microorganisms.sav b/data-raw/microorganisms.sav index c7ff63dd4..f70556132 100644 Binary files a/data-raw/microorganisms.sav and b/data-raw/microorganisms.sav differ diff --git a/data-raw/microorganisms.xlsx b/data-raw/microorganisms.xlsx index 05ffcdd7d..0ce89ed2c 100644 Binary files a/data-raw/microorganisms.xlsx and b/data-raw/microorganisms.xlsx differ diff --git a/data-raw/rsi_translation.dta b/data-raw/rsi_translation.dta index 7a25f8ae4..bb374afd7 100644 Binary files a/data-raw/rsi_translation.dta and b/data-raw/rsi_translation.dta differ diff --git a/data-raw/rsi_translation.sas b/data-raw/rsi_translation.sas index 9921ba93a..e8f3f3d23 100644 Binary files a/data-raw/rsi_translation.sas and b/data-raw/rsi_translation.sas differ diff --git a/data-raw/rsi_translation.sav b/data-raw/rsi_translation.sav index 2e48a4cf1..d4c4224d9 100644 Binary files a/data-raw/rsi_translation.sav and b/data-raw/rsi_translation.sav differ diff --git a/data-raw/rsi_translation.xlsx b/data-raw/rsi_translation.xlsx index 426c29ce8..1d502a811 100644 Binary files a/data-raw/rsi_translation.xlsx and b/data-raw/rsi_translation.xlsx differ diff --git a/docs/404.html b/docs/404.html index e84e4f016..afc17ed67 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ - Download our reference data sets for own use + Data sets for download / own use
diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index a3cde3adf..0bac0325d 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index ff9e9ef89..2bf32ee68 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ @@ -79,7 +79,7 @@vignettes/AMR.Rmd
AMR.Rmd
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 21 August 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 03 September 2020.
So only 28.3% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.6% 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) @@ -532,7 +532,7 @@ Longest: 1First 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 C8, 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 M8, sorted on date:
-
isolate @@ -548,21 +548,21 @@ Longest: 11 -2010-01-13 -C8 +2010-01-28 +M8 B_ESCHR_COLI S S -S +R S TRUE 2 -2010-02-19 -C8 +2010-05-23 +M8 B_ESCHR_COLI -S +R S S S @@ -570,10 +570,10 @@ Longest: 13 -2010-03-12 -C8 +2010-07-11 +M8 B_ESCHR_COLI -R +S S S S @@ -581,30 +581,30 @@ Longest: 14 -2010-03-25 -C8 +2010-10-01 +M8 B_ESCHR_COLI S S R -R +S FALSE 5 -2010-04-28 -C8 +2010-12-02 +M8 B_ESCHR_COLI R S -R +S S FALSE 6 -2010-07-22 -C8 +2010-12-23 +M8 B_ESCHR_COLI S S @@ -614,8 +614,8 @@ Longest: 17 -2010-12-05 -C8 +2011-01-16 +M8 B_ESCHR_COLI S S @@ -625,33 +625,33 @@ Longest: 18 -2011-01-18 -C8 +2011-03-14 +M8 B_ESCHR_COLI -R -R +S +S S S TRUE 9 -2011-05-24 -C8 +2011-04-02 +M8 B_ESCHR_COLI -R -I -R +S +S +S S FALSE 10 -2011-06-24 -C8 +2011-04-05 +M8 B_ESCHR_COLI -S -S +R +R S S FALSE @@ -686,34 +686,34 @@ Longest: 11 -2010-01-13 -C8 +2010-01-28 +M8 B_ESCHR_COLI S S -S +R S TRUE TRUE 2 -2010-02-19 -C8 +2010-05-23 +M8 B_ESCHR_COLI -S +R S S S FALSE -FALSE +TRUE 3 -2010-03-12 -C8 +2010-07-11 +M8 B_ESCHR_COLI -R +S S S S @@ -722,32 +722,32 @@ Longest: 14 -2010-03-25 -C8 +2010-10-01 +M8 B_ESCHR_COLI S S R -R +S FALSE TRUE 5 -2010-04-28 -C8 +2010-12-02 +M8 B_ESCHR_COLI R S -R +S S FALSE TRUE 6 -2010-07-22 -C8 +2010-12-23 +M8 B_ESCHR_COLI S S @@ -758,8 +758,8 @@ Longest: 17 -2010-12-05 -C8 +2011-01-16 +M8 B_ESCHR_COLI S S @@ -770,11 +770,11 @@ Longest: 18 -2011-01-18 -C8 +2011-03-14 +M8 B_ESCHR_COLI -R -R +S +S S S TRUE @@ -782,23 +782,23 @@ Longest: 19 -2011-05-24 -C8 +2011-04-02 +M8 B_ESCHR_COLI -R -I -R +S +S +S S FALSE -TRUE +FALSE 10 -2011-06-24 -C8 +2011-04-05 +M8 B_ESCHR_COLI -S -S +R +R S S FALSE @@ -806,13 +806,13 @@ Longest: 1Instead of 2, now 8 isolates are flagged. In total, 78.4% of all isolates are marked ‘first weighted’ - 50.1% 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 2, now 8 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.5% 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,686 isolates for analysis.
+So we end up with 15,813 isolates for analysis.
We can remove unneeded columns:
data_1st <- data_1st %>% @@ -857,13 +857,77 @@ Longest: 1- +1 -2011-03-20 -W2 +2 +2017-04-19 +S1 +Hospital C +B_STPHY_AURS +S +S +S +S +F +Gram-positive +Staphylococcus +aureus +TRUE ++ +3 +2017-04-21 +L3 +Hospital B +B_ESCHR_COLI +R +S +S +S +M +Gram-negative +Escherichia +coli +TRUE ++ +4 +2011-01-19 +A7 Hospital A +B_STPHY_AURS +S +S +S +S +M +Gram-positive +Staphylococcus +aureus +TRUE ++ +5 +2011-01-24 +H10 +Hospital B +B_ESCHR_COLI +R +S +S +S +M +Gram-negative +Escherichia +coli +TRUE ++ 6 +2011-01-31 +T9 +Hospital C B_STRPT_PNMN -S -S +R +R S R F @@ -873,85 +937,21 @@ Longest: 1TRUE - -3 -2012-11-11 -A5 -Hospital D -B_STPHY_AURS -R -R -S -S -M -Gram-positive -Staphylococcus -aureus -TRUE -- -4 -2012-09-03 -Y3 -Hospital C +7 +2012-12-27 +Q9 +Hospital A B_ESCHR_COLI R +R +R S -R -R F Gram-negative Escherichia coli TRUE - -5 -2012-11-19 -I3 -Hospital C -B_ESCHR_COLI -S -S -S -R -M -Gram-negative -Escherichia -coli -TRUE -- -8 -2013-11-06 -B1 -Hospital B -B_KLBSL_PNMN -R -S -S -S -M -Gram-negative -Klebsiella -pneumoniae -TRUE -- 9 -2017-01-21 -U3 -Hospital D -B_KLBSL_PNMN -R -S -S -S -F -Gram-negative -Klebsiella -pneumoniae -TRUE -Time for the analysis!
@@ -975,8 +975,8 @@ Longest: 1Frequency table
Class: character
-Length: 15,686
-Available: 15,686 (100%, NA: 0 = 0%)
+Length: 15,813
+Available: 15,813 (100%, NA: 0 = 0%)
Unique: 4Shortest: 16
@@ -993,33 +993,33 @@ Longest: 24
Longest: 241 Escherichia coli -7,774 -49.56% -7,774 -49.56% +7,901 +49.97% +7,901 +49.97% 2 Staphylococcus aureus -3,952 -25.19% -11,726 -74.75% +3,946 +24.95% +11,847 +74.92% 3 Streptococcus pneumoniae -2,367 -15.09% -14,093 -89.84% +2,394 +15.14% +14,241 +90.06% 4 Klebsiella pneumoniae -1,593 -10.16% -15,686 +1,572 +9.94% +15,813 100.00%
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.5350631 +# [1] 0.5330424
Or can be used in conjuction with group_by()
and summarise()
, both from the dplyr
package:
@@ -1173,19 +1173,19 @@ Longest: 24Hospital A -0.5338783 +0.5262478 Hospital B -0.5368875 +0.5401022 Hospital C -0.5367068 +0.5257556 @@ -1206,23 +1206,23 @@ Longest: 24 Hospital D -0.5322422 +0.5357938 Hospital A -0.5338783 -4649 +0.5262478 +4648 Hospital B -0.5368875 -5571 +0.5401022 +5673 Hospital C -0.5367068 -2411 +0.5257556 +2349 @@ -1245,27 +1245,27 @@ Longest: 24 Hospital D -0.5322422 -3055 +0.5357938 +3143 Escherichia -0.8205557 -0.8986365 -0.9855930 +0.8220478 +0.8978610 +0.9860777 Klebsiella -0.8323917 -0.8901444 -0.9855618 +0.8276081 +0.9001272 +0.9860051 Staphylococcus -0.8276822 -0.9210526 -0.9868421 +0.8335023 +0.9206792 +0.9878358 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 7fda4f19a..6fa701d79 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 ed7101612..cc86c264a 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 b5de9a4d2..81b411bb0 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 d2d6fe207..291e600e0 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 3ecd97a7a..4a599acc4 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -39,7 +39,7 @@ Streptococcus -0.5504858 +0.5396825 0.0000000 -0.5504858 +0.5396825
head(my_TB_data) # rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin -# 1 I S S S S R -# 2 S S S R R I -# 3 R S S R S I -# 4 R S S R S S -# 5 S R I R I R -# 6 R R S R R R +# 1 S R S S R S +# 2 S R R S R S +# 3 S R R S S R +# 4 R R S S S R +# 5 I S I S S S +# 6 S S R R S S # kanamycin -# 1 S -# 2 R -# 3 R -# 4 I -# 5 R -# 6 R +# 1 R +# 2 I +# 3 S +# 4 R +# 5 S +# 6 S
We can now add the interpretation of MDR-TB to our data set. You can use:
@@ -368,40 +368,40 @@ Unique: 51 Mono-resistant -3233 -64.66% -3233 -64.66% +3297 +65.94% +3297 +65.94% 2 -Negative -698 -13.96% -3931 -78.62% +Multi-drug-resistant +614 +12.28% +3911 +78.22% 3 -Multi-drug-resistant -556 -11.12% -4487 -89.74% +Negative +603 +12.06% +4514 +90.28% 4 Poly-resistant -300 -6.00% -4787 -95.74% +278 +5.56% +4792 +95.84% diff --git a/docs/articles/PCA.html b/docs/articles/PCA.html index dc573f075..0e768c516 100644 --- a/docs/articles/PCA.html +++ b/docs/articles/PCA.html @@ -39,7 +39,7 @@ 5 Extensively drug-resistant -213 -4.26% +208 +4.16% 5000 100.00%
Now to transform this to a data set with only resistance percentages per taxonomic order and genus:
diff --git a/docs/articles/SPSS.html b/docs/articles/SPSS.html
index a7fa1ef4f..d99fa2f2c 100644
--- a/docs/articles/SPSS.html
+++ b/docs/articles/SPSS.html
@@ -39,7 +39,7 @@
vignettes/SPSS.Rmd
SPSS.Rmd
%SI: 78.59%
diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 90c3a146a..3322982a6 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -39,7 +39,7 @@ @@ -79,7 +79,7 @@ - Download our reference data sets for own use + Data sets for download / own use |
---|