diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 75a1f682e..43c444781 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -48,24 +48,22 @@ jobs: fail-fast: false matrix: config: - - {os: windows-latest, r: 'release'} + - {os: macOS-latest, r: 'devel'} - {os: macOS-latest, r: 'release'} - - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: windows-latest, r: 'oldrel'} - # - {os: macOS-latest, r: 'oldrel'} - # - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: macOS-latest, r: 'oldrel'} - {os: windows-latest, r: 'devel'} - # - {os: macOS-latest, r: 'devel'} - # - {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: windows-latest, r: '3.6'} - # - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} - # - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: windows-latest, r: 'release'} + - {os: windows-latest, r: 'oldrel'} + - {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '4.0', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.6', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} + - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true RSPM: ${{ matrix.config.rspm }} - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 @@ -80,7 +78,6 @@ jobs: run: | install.packages('remotes') saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") shell: Rscript {0} - name: Cache R packages @@ -88,8 +85,8 @@ jobs: uses: actions/cache@v1 with: path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + key: ${{ runner.os }}-r-${{ matrix.config.r }}-3-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-3- - name: Install system dependencies if: runner.os == 'Linux' @@ -100,6 +97,11 @@ jobs: sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))") sudo -s eval "$sysreqs" + - name: Install macOS dependencies + if: matrix.config.os == 'macOS-latest' && matrix.config.r == 'devel' + run: | + brew install mariadb-connector-c + - name: Install dependencies run: | remotes::install_deps(dependencies = TRUE) @@ -126,7 +128,7 @@ jobs: - name: Upload check results if: failure() - uses: actions/upload-artifact@main + uses: actions/upload-artifact@master with: name: ${{ runner.os }}-r${{ matrix.config.r }}-results path: check diff --git a/DESCRIPTION b/DESCRIPTION index 26d41b0c1..181b065e7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR -Version: 1.4.0 -Date: 2020-10-08 +Version: 1.4.0.9000 +Date: 2020-10-15 Title: Antimicrobial Resistance Analysis Authors@R: c( person(role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index e7dca93f1..83f43ceaf 100755 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,10 @@ -# AMR 1.4.0 +# AMR 1.4.0.9000 +## Last updated: 15 October 2020 +### Other +* More extensive unit tests + +# AMR 1.4.0 Note: some changes in this version were suggested by anonymous reviewers from the journal we submitted our manuscipt about this package to. We are those reviewers very grateful for going through our code so thoroughly! diff --git a/docs/404.html b/docs/404.html index 0cd638ac9..8086240f4 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -255,7 +255,7 @@ Content not found. Please use links in the navbar.
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/LICENSE-text.html b/docs/LICENSE-text.html index 49932b372..5517d2cb0 100644 --- a/docs/LICENSE-text.html +++ b/docs/LICENSE-text.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -503,7 +503,7 @@ END OF TERMS AND CONDITIONS
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index e7a7ad6bc..64e99be5e 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -187,13 +187,13 @@ -
+
@@ -281,14 +280,12 @@ 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.

@@ -296,17 +293,15 @@ 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")
@@ -314,39 +309,35 @@ 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) @@ -361,71 +352,71 @@ - - - - - - - - - - - - - + + - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - + - - - - - - - - - - -
date
2014-02-15Y9Hospital AStreptococcus pneumoniaeRSSSF
2012-05-11J42011-04-04A3 Hospital CKlebsiella pneumoniaeRSSSM
2013-06-10J1Hospital B Staphylococcus aureus RSI S S M
2013-02-02U42011-10-13I4 Hospital B Escherichia coli SSSSM
2015-11-20J6Hospital AEscherichia coliIS R SM
2017-02-04X3Hospital BKlebsiella pneumoniaeSIS S F
2015-12-04S102010-10-17N9Hospital DStaphylococcus aureusIRSRF
2014-06-04X3 Hospital AStreptococcus pneumoniaeEscherichia coli S S S S F
2016-09-17G2Hospital BEscherichia coliRSSSM

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

@@ -437,8 +428,7 @@

We also created a package dedicated to data cleaning and checking, called the cleaner package. It freq() function can be used to create frequency tables.

For example, for the gender variable:

-data %>% freq(gender)
-
+data %>% freq(gender)

Frequency table

Class: character
Length: 20,000
@@ -459,16 +449,16 @@ Longest: 1

1 M -10,310 -51.55% -10,310 -51.55% +10,412 +52.06% +10,412 +52.06% 2 F -9,690 -48.45% +9,588 +47.94% 20,000 100.00% @@ -477,31 +467,27 @@ Longest: 1

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", rules = "all")
-# Set amoxicillin (AMX) = R where amoxicillin/clavulanic acid (AMC) = R
-
+data <- eucast_rules(data, col_mo = "bacteria", rules = "all") +# Set amoxicillin (AMX) = R where amoxicillin/clavulanic acid (AMC) = R

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

@@ -513,27 +499,24 @@ Longest: 1

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(.))
+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:

+# 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:

-data_1st <- data %>% 
-  filter(first == TRUE)
-
+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 T8, 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 Z7, sorted on date:

@@ -549,19 +532,19 @@ Longest: 1

- - + + + - - - + + @@ -571,10 +554,10 @@ Longest: 1

- - + + - + @@ -582,19 +565,19 @@ Longest: 1

- - + + - + - - + + @@ -604,52 +587,52 @@ Longest: 1

- - + + - - + + - - + + - + - - + + + + - - - + - - + + + - - + - - + + @@ -662,15 +645,14 @@ Longest: 1

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.

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(.))
+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.
-
+# NOTE: Using column `keyab` as input for `col_keyantibiotics`. Use col_keyantibiotics = FALSE to prevent this.
isolate
12010-04-04T82010-03-27Z7 B_ESCHR_COLIR S S RS TRUE
22010-10-03T82010-06-10Z7 B_ESCHR_COLI S S
32010-10-19T82010-06-25Z7 B_ESCHR_COLISI S S S
42011-01-12T82010-11-05Z7 B_ESCHR_COLI S SSR S FALSE
52011-02-03T82010-11-22Z7 B_ESCHR_COLI S S
62011-04-04T82011-02-06Z7 B_ESCHR_COLIR S S STRUESFALSE
72011-05-23T82011-03-19Z7 B_ESCHR_COLI R SSR S FALSE
82011-06-09T82011-07-19Z7 B_ESCHR_COLIRI S SSSFALSETRUE
92011-07-02T82011-08-15Z7 B_ESCHR_COLIR S SSSR FALSE
102011-12-05T82011-09-22Z7 B_ESCHR_COLI S S
@@ -687,20 +669,20 @@ Longest: 1

- - + + + - - - + + @@ -711,10 +693,10 @@ Longest: 1

- - + + - + @@ -723,106 +705,103 @@ Longest: 1

- - + + - + - + - - + + - + - - + + - - - + + + - - + + - + - + - - + + + + - - - + - - + + + - - - + + - - + + - +
isolate
12010-04-04T82010-03-27Z7 B_ESCHR_COLIR S S RS TRUE TRUE
22010-10-03T82010-06-10Z7 B_ESCHR_COLI S S
32010-10-19T82010-06-25Z7 B_ESCHR_COLISI S S S
42011-01-12T82010-11-05Z7 B_ESCHR_COLI S SSR S FALSEFALSETRUE
52011-02-03T82010-11-22Z7 B_ESCHR_COLI S S S S FALSEFALSETRUE
62011-04-04T82011-02-06Z7 B_ESCHR_COLIR S S STRUETRUESFALSEFALSE
72011-05-23T82011-03-19Z7 B_ESCHR_COLI R SSR S FALSEFALSETRUE
82011-06-09T82011-07-19Z7 B_ESCHR_COLIRI S SSSFALSETRUE TRUE
92011-07-02T82011-08-15Z7 B_ESCHR_COLIR S SSSFALSER FALSETRUE
102011-12-05T82011-09-22Z7 B_ESCHR_COLI S S S S FALSEFALSETRUE
-

Instead of 2, now 4 isolates are flagged. In total, 78.7% 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 2, now 8 isolates are flagged. In total, 78.6% 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.

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

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

So we end up with 15,713 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) @@ -836,7 +815,7 @@ Longest: 1

-+ @@ -859,60 +838,92 @@ Longest: 1

- - - - - + + + + + - - + + - - + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - + + + + + - + - - - + + + - - - - + + + + - - + + @@ -921,38 +932,6 @@ Longest: 1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
12014-02-15Y9Hospital AB_STRPT_PNMNR2011-04-04A3Hospital CB_STPHY_AURS RI SRFSM Gram-positiveStreptococcuspneumoniaeStaphylococcusaureus TRUE
22012-05-11J4Hospital C2011-10-13I4Hospital BB_ESCHR_COLISSSSMGram-negativeEscherichiacoliTRUE
32015-11-20J6Hospital AB_ESCHR_COLIISRSMGram-negativeEscherichiacoliTRUE
42017-02-04X3Hospital B B_KLBSL_PNMN R S S SMF Gram-negative Klebsiella pneumoniae TRUE
42013-02-02U4Hospital BB_ESCHR_COLI52010-10-17N9Hospital DB_STPHY_AURS R R SSR FGram-negativeEscherichiacoliGram-positiveStaphylococcusaureus TRUE
52015-12-04S10Hospital A72011-06-10P2Hospital B B_STRPT_PNMNSSII S R F pneumoniae TRUE
62016-09-17G2Hospital BB_ESCHR_COLIRSSSMGram-negativeEscherichiacoliTRUE
72012-06-30V5Hospital AB_ESCHR_COLIRRSSFGram-negativeEscherichiacoliTRUE

Time for the analysis!

@@ -968,16 +947,14 @@ Longest: 1

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,741
-Available: 15,741 (100%, NA: 0 = 0%)
+Length: 15,713
+Available: 15,713 (100%, NA: 0 = 0%)
Unique: 4

Shortest: 16
Longest: 24

@@ -994,33 +971,33 @@ Longest: 24

1 Escherichia coli -7,868 -49.98% -7,868 -49.98% +7,867 +50.07% +7,867 +50.07% 2 Staphylococcus aureus -3,927 -24.95% -11,795 -74.93% +3,842 +24.45% +11,709 +74.52% 3 Streptococcus pneumoniae -2,394 -15.21% -14,189 -90.14% +2,346 +14.93% +14,055 +89.45% 4 Klebsiella pneumoniae -1,552 -9.86% -15,741 +1,658 +10.55% +15,713 100.00% @@ -1031,10 +1008,9 @@ Longest: 24

Overview of different bug/drug combinations

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:

-data_1st %>% 
-  bug_drug_combinations() %>% 
-  head() # show first 6 rows
-
+data_1st %>% + bug_drug_combinations() %>% + head() # show first 6 rows
# NOTE: Using column `bacteria` as input for `col_mo`.
@@ -1049,59 +1025,58 @@ Longest: 24

- - - - + + + + - - - - + + + + - + - - + + - + - - + + - - + + - - - - + + + +
E. coli AMX382323738087868380626237997867
E. coli AMC621031513437868622332113237867
E. coli CIP59846006 01884786818617867
E. coli GEN70787072 079078687957867
K. pneumoniae AMX 0 01552155216581658
K. pneumoniae AMC11986329115521298563041658

Using Tidyverse selections, you can also select columns based on the antibiotic class they are in:

-data_1st %>% 
-  select(bacteria, fluoroquinolones()) %>% 
-  bug_drug_combinations()
-
+data_1st %>% + select(bacteria, fluoroquinolones()) %>% + bug_drug_combinations()
# Selecting fluoroquinolones: `CIP` (ciprofloxacin)
 # NOTE: Using column `bacteria` as input for `col_mo`.
@@ -1117,34 +1092,34 @@ Longest: 24

- + - - + + - + - - + + - + - - + + - + - - + +
E. coli CIP59846006 01884786818617867
K. pneumoniae CIP11761257 037615524011658
S. aureus CIP30372963 089039278793842
S. pneumoniae CIP18521785 054223945612346
@@ -1156,15 +1131,13 @@ Longest: 24

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

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))
# `summarise()` ungrouping output (override with `.groups` argument)
@@ -1174,29 +1147,28 @@ Longest: 24

- + - + - + - +
Hospital A0.52409890.5459117
Hospital B0.53266330.5280457
Hospital C0.55541610.5268007
Hospital D0.52480500.5537583

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))
# `summarise()` ungrouping output (override with `.groups` argument)
@@ -1207,34 +1179,33 @@ Longest: 24

- - + + - - + + - - + + - - + +
Hospital A0.524098947720.54591174574
Hospital B0.532663353730.52804575598
Hospital C0.555416123910.52680072388
Hospital D0.524805032050.55375833153

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))
# `summarise()` ungrouping output (override with `.groups` argument)
@@ -1246,45 +1217,44 @@ Longest: 24

- - - + + + - - - + + + - - - + + + - + - +
Escherichia0.82930860.89959330.98741740.83182920.89894500.9853820
Klebsiella0.81250000.90850520.98324740.81664660.89083230.9782871
Staphylococcus0.82454800.92386050.98701300.82326910.91905260.9880271
Streptococcus0.54594820.5264280 0.00000000.54594820.5264280

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)) %>% 
+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")
-# `summarise()` ungrouping output (override with `.groups` argument)
-
+ tidyr::pivot_longer(-genus, names_to = "antibiotic") %>% + ggplot(aes(x = genus, + y = value, + fill = antibiotic)) + + geom_col(position = "dodge2") +# `summarise()` ungrouping output (override with `.groups` argument)

@@ -1292,60 +1262,56 @@ Longest: 24

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")
+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(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)) + 
+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") + 
+  geom_rsi(x = "genus") + 
   # split plots on antibiotic
-  facet_rsi(facet = "antibiotic") +
+  facet_rsi(facet = "antibiotic") +
   # set colours to the R/SI interpretations
-  scale_rsi_colours() +
+  scale_rsi_colours() +
   # show percentages on y axis
-  scale_y_percent(breaks = 0:4 * 25) +
+  scale_y_percent(breaks = 0:4 * 25) +
   # turn 90 degrees, to make it bars instead of columns
-  coord_flip() +
+  coord_flip() +
   # add labels
-  labs(title = "Resistance per genus and antibiotic", 
-       subtitle = "(this is fake data)") +
+  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"))
-
+ 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()

@@ -1355,27 +1321,26 @@ Longest: 24

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:
-library(tidyr)
+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 <- 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
+check_FOS
 #       A  D
 # [1,] 25 77
-# [2,] 24 33
-
+# [2,] 24 33

We can apply the test now with:

 # do Fisher's Exact Test
-fisher.test(check_FOS)                            
+fisher.test(check_FOS)                            
 # 
 #   Fisher's Exact Test for Count Data
 # 
@@ -1386,8 +1351,7 @@ Longest: 24

# 0.2111489 0.9485124 # sample estimates: # odds ratio -# 0.4488318 -
+# 0.4488318

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

@@ -1408,7 +1372,7 @@ Longest: 24

-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

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 1aaf44b58..e78f6e21c 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 a98b90e64..a6f2f57a0 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 5ef8a6ec7..8878ab97b 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 c0919c0e8..dc78f9804 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/AMR_files/header-attrs-2.4/header-attrs.js b/docs/articles/AMR_files/header-attrs-2.4/header-attrs.js new file mode 100644 index 000000000..dd57d92e0 --- /dev/null +++ b/docs/articles/AMR_files/header-attrs-2.4/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html index 78e085256..d1c6cf950 100644 --- a/docs/articles/EUCAST.html +++ b/docs/articles/EUCAST.html @@ -39,7 +39,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -187,7 +187,7 @@ -
+

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",
+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",       # Benzylenicillin
-                   FOX = "S",       # Cefoxitin
-                   stringsAsFactors = FALSE)
-
+ "Pseudomonas aeruginosa"), + VAN = "-", # Vancomycin + AMX = "-", # Amoxicillin + COL = "-", # Colistin + CAZ = "-", # Ceftazidime + CXM = "-", # Cefuroxime + PEN = "S", # Benzylenicillin + FOX = "S", # Cefoxitin + stringsAsFactors = FALSE)
-data
-
+data
@@ -313,8 +310,7 @@
mo
-eucast_rules(data)
-
+eucast_rules(data)
@@ -397,7 +393,7 @@
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/EUCAST_files/header-attrs-2.4/header-attrs.js b/docs/articles/EUCAST_files/header-attrs-2.4/header-attrs.js new file mode 100644 index 000000000..dd57d92e0 --- /dev/null +++ b/docs/articles/EUCAST_files/header-attrs-2.4/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/MDR.html b/docs/articles/MDR.html index 07b19c454..1b5377b2d 100644 --- a/docs/articles/MDR.html +++ b/docs/articles/MDR.html @@ -39,7 +39,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -187,7 +187,7 @@ -
+
-example_isolates %>% 
-  mdro() %>% 
-  freq() # show frequency table of the result
+example_isolates %>% 
+  mdro() %>% 
+  freq() # show frequency table of the result
 # Warning in mdro(.): NA introduced for isolates where the available percentage of
-# antimicrobial classes was below 50% (set with `pct_required_classes`)
-
+# antimicrobial classes was below 50% (set with `pct_required_classes`)

Frequency table

Class: factor > ordered (numeric)
Length: 2,000
@@ -288,62 +286,56 @@ Unique: 2

 # 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)
-}
+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())
-
+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)
+head(my_TB_data)
 #   rifampicin isoniazid gatifloxacin ethambutol pyrazinamide moxifloxacin
-# 1          R         S            S          R            S            I
-# 2          I         S            S          S            I            R
-# 3          R         R            R          R            R            R
-# 4          R         I            S          R            S            S
-# 5          S         S            I          S            S            R
+# 1          R         S            S          R            R            S
+# 2          I         R            S          R            S            I
+# 3          R         R            S          S            S            S
+# 4          R         R            S          I            S            S
+# 5          S         I            R          S            R            S
 # 6          S         S            S          R            S            S
 #   kanamycin
-# 1         R
+# 1         S
 # 2         S
-# 3         R
-# 4         R
+# 3         S
+# 4         S
 # 5         S
-# 6         R
-
+# 6 R

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.
-
+my_TB_data$mdr<-mdr_tb(my_TB_data) +# NOTE: No column found as input for `col_mo`, assuming all records contain Mycobacterium tuberculosis.

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
@@ -363,40 +355,40 @@ Unique: 5

- - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - + + @@ -418,7 +410,7 @@ Unique: 5

-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/articles/MDR_files/header-attrs-2.4/header-attrs.js b/docs/articles/MDR_files/header-attrs-2.4/header-attrs.js new file mode 100644 index 000000000..dd57d92e0 --- /dev/null +++ b/docs/articles/MDR_files/header-attrs-2.4/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html index 7e2ab536b..9cd704c74 100644 --- a/docs/articles/benchmarks.html +++ b/docs/articles/benchmarks.html @@ -39,7 +39,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -187,7 +187,7 @@ -
+

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
-  times = 10)
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-print(S.aureus, unit = "ms", signif = 2)
+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
+  times = 10)
+print(S.aureus, unit = "ms", signif = 2)
 # Unit: milliseconds
 #                                   expr   min    lq  mean median    uq max neval
-#                           as.mo("sau")  11.0  12.0  25.0   13.0  14.0 130    10
-#                          as.mo("stau") 210.0 230.0 240.0  250.0 250.0 260    10
-#                          as.mo("STAU") 210.0 210.0 240.0  240.0 260.0 270    10
-#                        as.mo("staaur")  12.0  14.0  22.0   14.0  41.0  43    10
-#                        as.mo("STAAUR")  12.0  12.0  19.0   13.0  14.0  47    10
-#                     as.mo("S. aureus")  26.0  28.0  38.0   30.0  58.0  62    10
-#                      as.mo("S aureus")  28.0  29.0  45.0   52.0  56.0  60    10
-#         as.mo("Staphylococcus aureus")   2.1   2.2   7.9    2.4   2.6  32    10
-#  as.mo("Staphylococcus aureus (MRSA)") 840.0 880.0 890.0  890.0 890.0 930    10
-#       as.mo("Sthafilokkockus aaureuz") 340.0 370.0 390.0  390.0 410.0 490    10
-#                          as.mo("MRSA")  11.0  12.0  16.0   13.0  14.0  44    10
-#                          as.mo("VISA")  19.0  20.0  32.0   22.0  50.0  51    10
-#                          as.mo("VRSA")  18.0  22.0  24.0   22.0  23.0  46    10
-
+# as.mo("sau") 12.0 13.0 25.0 15.0 40.0 43 10 +# as.mo("stau") 210.0 220.0 230.0 230.0 250.0 260 10 +# as.mo("STAU") 210.0 210.0 230.0 250.0 250.0 260 10 +# as.mo("staaur") 12.0 13.0 24.0 14.0 41.0 42 10 +# as.mo("STAAUR") 13.0 13.0 22.0 14.0 39.0 42 10 +# as.mo("S. aureus") 27.0 30.0 42.0 41.0 54.0 61 10 +# as.mo("S aureus") 24.0 29.0 45.0 43.0 60.0 66 10 +# as.mo("Staphylococcus aureus") 2.1 2.5 4.9 2.5 2.9 26 10 +# as.mo("Staphylococcus aureus (MRSA)") 820.0 860.0 880.0 880.0 900.0 970 10 +# as.mo("Sthafilokkockus aaureuz") 330.0 340.0 370.0 370.0 390.0 420 10 +# as.mo("MRSA") 11.0 13.0 22.0 14.0 41.0 44 10 +# as.mo("VISA") 21.0 22.0 48.0 47.0 51.0 140 10 +# as.mo("VRSA") 19.0 20.0 23.0 21.0 22.0 47 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. It is clear that accepted taxonomic names are extremely fast, but some variations can take up to 500-1000 times as much time.

To improve performance, two important calculations take almost no time at all: repetitive results and already precalculated results.

@@ -312,79 +250,66 @@

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.

 # take all MO codes from the example_isolates data set
-x <- example_isolates$mo %>%
+x <- example_isolates$mo %>%
   # and copy them a thousand times
-  rep(1000) %>%
+  rep(1000) %>%
   # then scramble them
-  sample()
+  sample()
   
 # as the example_isolates has 2,000 rows, we should have 2 million items
-length(x)
+length(x)
 # [1] 2000000
 
 # and how many unique values do we have?
-n_distinct(x)
+n_distinct(x)
 # [1] 90
 
 # now let's see:
-run_it <- microbenchmark(mo_name(x),
-                         times = 10)
-print(run_it, unit = "ms", signif = 3)
+run_it <- microbenchmark(mo_name(x),
+                         times = 10)
+print(run_it, unit = "ms", signif = 3)
 # Unit: milliseconds
 #        expr min  lq mean median  uq max neval
-#  mo_name(x) 131 161  200    168 187 341    10
-
-

So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.168 seconds. You only lose time on your unique input values.

+# mo_name(x) 150 154 195 179 197 301 10
+

So getting official taxonomic names of 2,000,000 (!!) items consisting of 90 unique values only takes 0.179 seconds. 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("STAAUR"),
-                         B = mo_name("S. aureus"),
-                         C = mo_name("Staphylococcus aureus"),
-                         times = 10)
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-# Result of one value was guessed with uncertainty. Use mo_uncertainties() to review it.
-print(run_it, unit = "ms", signif = 3)
+run_it <- microbenchmark(A = mo_name("STAAUR"),
+                         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.85  7.05  7.57   7.51  8.05  8.52    10
-#     B 21.50 21.70 27.40  23.80 25.00 64.70    10
-#     C  1.75  1.86  1.99   1.93  2.08  2.27    10
-
-

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.0019 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:

+# A 7.11 7.23 7.79 7.74 8.46 8.54 10 +# B 21.40 21.90 30.40 24.00 25.50 60.00 10 +# C 1.97 1.98 2.12 2.05 2.34 2.43 10
+

So going from mo_name("Staphylococcus aureus") to "Staphylococcus aureus" takes 0.002 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)
+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 1.38 1.57 1.60   1.61 1.67 1.71    10
-#     B 1.55 1.60 1.73   1.63 1.92 2.05    10
-#     C 1.39 1.50 1.70   1.62 1.84 2.39    10
-#     D 1.32 1.51 1.59   1.57 1.61 2.04    10
-#     E 1.34 1.40 1.52   1.53 1.65 1.66    10
-#     F 1.28 1.53 1.56   1.60 1.66 1.72    10
-#     G 1.30 1.33 1.59   1.61 1.74 1.98    10
-#     H 1.31 1.45 1.62   1.55 1.70 2.46    10
-
+# expr min lq mean median uq max neval +# A 1.33 1.57 1.70 1.69 1.83 2.18 10 +# B 1.62 1.67 5.34 1.70 2.15 36.90 10 +# C 1.43 1.55 1.64 1.59 1.70 2.06 10 +# D 1.29 1.44 1.53 1.55 1.66 1.70 10 +# E 1.31 1.58 1.68 1.65 1.71 2.11 10 +# F 1.54 1.61 1.80 1.67 1.86 2.57 10 +# G 1.52 1.62 1.73 1.71 1.77 2.04 10 +# H 1.40 1.55 1.70 1.65 1.92 2.03 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.

@@ -392,34 +317,33 @@ 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
+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
+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
+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)
+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 14.00 14.36 18.52  14.64 15.18  57.58   100
-#    de 17.04 17.33 20.94  17.63 18.49  56.23   100
-#    nl 28.21 29.20 32.15  30.06 31.02  72.91   100
-#    es 16.85 17.26 19.83  17.44 17.95 152.20   100
-#    it 16.58 17.10 19.03  17.43 18.24  54.28   100
-#    fr 16.71 17.20 21.24  17.52 19.02  63.25   100
-#    pt 16.76 17.29 23.27  17.62 19.14  65.28   100
-
+# expr min lq mean median uq max neval +# en 14.20 14.66 20.04 15.14 16.90 58.67 100 +# de 17.15 17.85 24.30 18.27 20.00 59.17 100 +# nl 29.13 30.50 34.60 31.26 32.86 72.63 100 +# es 16.95 17.70 22.61 18.35 20.54 59.42 100 +# it 17.04 17.60 21.72 18.14 19.60 59.19 100 +# fr 16.82 17.52 21.71 18.05 19.63 61.06 100 +# pt 16.92 17.58 19.92 18.23 19.19 54.61 100

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

@@ -437,7 +361,7 @@
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

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 3c56ab46b..f3ac52fed 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/header-attrs-2.4/header-attrs.js b/docs/articles/benchmarks_files/header-attrs-2.4/header-attrs.js new file mode 100644 index 000000000..dd57d92e0 --- /dev/null +++ b/docs/articles/benchmarks_files/header-attrs-2.4/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/datasets.html b/docs/articles/datasets.html index 43f03b0cf..6fe0f7394 100644 --- a/docs/articles/datasets.html +++ b/docs/articles/datasets.html @@ -39,7 +39,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -187,7 +187,7 @@ -
+
diff --git a/docs/articles/datasets_files/header-attrs-2.4/header-attrs.js b/docs/articles/datasets_files/header-attrs-2.4/header-attrs.js new file mode 100644 index 000000000..dd57d92e0 --- /dev/null +++ b/docs/articles/datasets_files/header-attrs-2.4/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/docs/articles/index.html b/docs/articles/index.html index 94875c315..abc939193 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000
@@ -272,7 +272,7 @@
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/authors.html b/docs/authors.html index 7b9519ae7..4f70c17ef 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000
@@ -325,7 +325,7 @@
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/index.html b/docs/index.html index e3188ef14..b5376c2cb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -43,7 +43,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -282,8 +282,7 @@ Since you are one of our users, we would like to know how you use the package an

This package is available here on the official R network (CRAN), which has a peer-reviewed submission process. Install this package in R from CRAN by using the command:

-install.packages("AMR")
-
+install.packages("AMR")

It will be downloaded and installed automatically. For RStudio, click on the menu Tools > Install Packages… and then type in “AMR” and press Install.

Note: Not all functions on this website may be available in this latest release. To use all functions and data sets mentioned on this website, install the latest development version.

@@ -292,9 +291,8 @@ Since you are one of our users, we would like to know how you use the package an Latest development version

The latest and unpublished development version can be installed from GitHub using:

-install.packages("remotes") 
-remotes::install_github("msberends/AMR")
-
+install.packages("remotes") +remotes::install_github("msberends/AMR")
@@ -458,7 +456,7 @@ Since you are one of our users, we would like to know how you use the package an
-

Site built with pkgdown 1.5.1.9000.

+

Site built with pkgdown 1.6.1.

diff --git a/docs/news/index.html b/docs/news/index.html index bb09c9b6c..b9994ee53 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -236,6 +236,23 @@ Source: NEWS.md +
+

+AMR 1.4.0.9000 Unreleased +

+
+

+Last updated: 15 October 2020 +

+
+

+Other

+
    +
  • More extensive unit tests
  • +
+
+
+

AMR 1.4.0 2020-10-08 @@ -251,13 +268,12 @@

Data set intrinsic_resistant. This data set contains all bug-drug combinations where the ‘bug’ is intrinsic resistant to the ‘drug’ according to the latest EUCAST insights. It contains just two columns: microorganism and antibiotic.

Curious about which enterococci are actually intrinsic resistant to vancomycin?

-library(AMR)
-library(dplyr)
-intrinsic_resistant %>%
-  filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>% 
-  pull(microorganism)
-#> [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"   
-
+library(AMR) +library(dplyr) +intrinsic_resistant %>% + filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>% + pull(microorganism) +#> [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"

  • Support for veterinary ATC codes

  • Support for skimming classes <rsi>, <mic>, <disk> and <mo> with the skimr package

  • @@ -275,13 +291,12 @@

    Support for using dplyr’s across() to interpret MIC values or disk zone diameters, which also automatically determines the column with microorganism names or codes.

     # until dplyr 1.0.0
    -your_data %>% mutate_if(is.mic, as.rsi)
    -your_data %>% mutate_if(is.disk, as.rsi)
    +your_data %>% mutate_if(is.mic, as.rsi)
    +your_data %>% mutate_if(is.disk, as.rsi)
     
     # since dplyr 1.0.0
    -your_data %>% mutate(across(where(is.mic), as.rsi))
    -your_data %>% mutate(across(where(is.disk), as.rsi))
    -
    +your_data%>%mutate(across(where(is.mic), as.rsi)) +your_data%>%mutate(across(where(is.disk), as.rsi))
  • Cleaning columns in a data.frame now allows you to specify those columns with tidy selection, e.g. as.rsi(df, col1:col9)

  • Big speed improvement for interpreting MIC values and disk zone diameters. When interpreting 5,000 MIC values of two antibiotics (10,000 values in total), our benchmarks showed a total run time going from 80.7-85.1 seconds to 1.8-2.0 seconds.

  • @@ -292,10 +307,9 @@
  • Added intelligent data cleaning to as.disk(), so numbers can also be extracted from text and decimal numbers will always be rounded up:

    -as.disk(c("disk zone: 23.4 mm", 23.4))
    +as.disk(c("disk zone: 23.4 mm", 23.4))
     #> Class <disk>
    -#> [1] 24 24
    -
    +#> [1] 24 24
  • Improvements for as.mo():

    @@ -330,9 +344,9 @@
  • Added parameter excess to the kurtosis() function (defaults to FALSE), to return the excess kurtosis, defined as the kurtosis minus three.

  • -
    +

    -Other

    +Other
  • Added mo_domain() as an alias to mo_kingdom()

  • Added function filter_penicillins() to filter isolates on a specific result in any column with a name in the antimicrobial ‘penicillins’ class (more specific: ATC subgroup Beta-lactam antibacterials, penicillins)

  • @@ -416,9 +429,9 @@
  • Fixed a bug where as.mic() could not handle dots without a leading zero (like "<=.25)

  • -
    +

    -Other

    +Other @@ -478,9 +491,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added abbreviation “cfsc” for Cefoxitin and “cfav” for Ceftazidime/avibactam
  • -
    +

    -Other

    +Other
    • Removed previously deprecated function p.symbol() - it was replaced with p_symbol()
    • @@ -520,9 +533,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • Added generic CLSI rules for R/SI interpretation using as.rsi() for years 2010-2019 (thanks to Anthony Underwood)
    -
    +

    -Other

    +Other
    • Support for the upcoming dplyr version 1.0.0
    • More robust assigning for classes rsi and mic @@ -542,12 +555,11 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    • Interpretation from MIC values (and disk zones) to R/SI can now be used with mutate_at() of the dplyr package:

      -yourdata %>% 
      -  mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli")
      +yourdata %>% 
      +  mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = "E. coli")
       
      -yourdata %>% 
      -  mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = .$mybacteria)
      -
      +yourdata %>% + mutate_at(vars(antibiotic1:antibiotic25), as.rsi, mo = .$mybacteria)
  • Added antibiotic abbreviations for a laboratory manufacturer (GLIMS) for cefuroxime, cefotaxime, ceftazidime, cefepime, cefoxitin and trimethoprim/sulfamethoxazole

  • Added uti (as abbreviation of urinary tract infections) as parameter to as.rsi(), so interpretation of MIC values and disk zones can be made dependent on isolates specifically from UTIs

  • @@ -571,24 +583,22 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Support for LOINC codes in the antibiotics data set. Use ab_loinc() to retrieve LOINC codes, or use a LOINC code for input in any ab_* function:

    -ab_loinc("ampicillin")
    +ab_loinc("ampicillin")
     #> [1] "21066-6" "3355-5"  "33562-0" "33919-2" "43883-8" "43884-6" "87604-5"
    -ab_name("21066-6")
    +ab_name("21066-6")
     #> [1] "Ampicillin"
    -ab_atc("21066-6")
    -#> [1] "J01CA01"
    -
    +ab_atc("21066-6") +#> [1] "J01CA01"
  • Support for SNOMED CT codes in the microorganisms data set. Use mo_snomed() to retrieve SNOMED codes, or use a SNOMED code for input in any mo_* function:

    -mo_snomed("S. aureus")
    +mo_snomed("S. aureus")
     #> [1] 115329001   3092008 113961008
    -mo_name(115329001)
    +mo_name(115329001)
     #> [1] "Staphylococcus aureus"
    -mo_gramstain(115329001)
    -#> [1] "Gram-positive"
    -
    +mo_gramstain(115329001) +#> [1] "Gram-positive"
  • @@ -624,9 +634,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    -
    +

    -Other

    +Other

    then please adjust this to:

    -if (mo_order(somebugs) == "Enterobacterales") ...
    -
    +if (mo_order(somebugs) == "Enterobacterales") ...
    @@ -665,13 +673,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Functions susceptibility() and resistance() as aliases of proportion_SI() and proportion_R(), respectively. These functions were added to make it more clear that “I” should be considered susceptible and not resistant.

    -library(dplyr)
    -example_isolates %>%
    -  group_by(bug = mo_name(mo)) %>% 
    -  summarise(amoxicillin = resistance(AMX),
    -            amox_clav   = resistance(AMC)) %>%
    -  filter(!is.na(amoxicillin) | !is.na(amox_clav))
    -
    +library(dplyr) +example_isolates %>% + group_by(bug = mo_name(mo)) %>% + summarise(amoxicillin = resistance(AMX), + amox_clav = resistance(AMC)) %>% + filter(!is.na(amoxicillin) | !is.na(amox_clav))
  • Support for a new MDRO guideline: Magiorakos AP, Srinivasan A et al. “Multidrug-resistant, extensively drug-resistant and pandrug-resistant bacteria: an international expert proposal for interim standard definitions for acquired resistance.” Clinical Microbiology and Infection (2012).

    @@ -694,17 +701,16 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added a score (a certainty percentage) to mo_uncertainties(), that is calculated using the Levenshtein distance:

    -as.mo(c("Stafylococcus aureus",
    -        "staphylokok aureuz"))
    +as.mo(c("Stafylococcus aureus",
    +        "staphylokok aureuz"))
     #> Warning: 
     #> Results of two values were guessed with uncertainty. Use mo_uncertainties() to review them.
     #> Class 'mo'
     #> [1] B_STPHY_AURS B_STPHY_AURS
     
    -mo_uncertainties()
    +mo_uncertainties()
     #> "Stafylococcus aureus" -> Staphylococcus aureus (B_STPHY_AURS, score: 95.2%)
    -#> "staphylokok aureuz"   -> Staphylococcus aureus (B_STPHY_AURS, score: 85.7%)
    -
    +#> "staphylokok aureuz" -> Staphylococcus aureus (B_STPHY_AURS, score: 85.7%)
  • @@ -732,9 +738,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ -
    +

    -Other

    +Other

    For WHONET users, this means that all records/isolates with organism code "con" (contamination) will be excluded at default, since as.mo("con") = "UNKNOWN". The function always shows a note with the number of ‘unknown’ microorganisms that were included or excluded.

  • For code consistency, classes ab and mo will now be preserved in any subsetting or assignment. For the sake of data integrity, this means that invalid assignments will now result in NA:

     # how it works in base R:
    -x <- factor("A")
    -x[1] <- "B"
    +x <- factor("A")
    +x[1] <- "B"
     #> Warning message:
     #> invalid factor level, NA generated
     
     # how it now works similarly for classes 'mo' and 'ab':
    -x <- as.mo("E. coli")
    -x[1] <- "testvalue"
    +x <- as.mo("E. coli")
    +x[1] <- "testvalue"
     #> Warning message:
    -#> invalid microorganism code, NA generated
    -
    +#> 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).

  • @@ -785,9 +789,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Function bug_drug_combinations() to quickly get a data.frame with the results of all bug-drug combinations in a data set. The column containing microorganism codes is guessed automatically and its input is transformed with mo_shortname() at default:

    -x <- bug_drug_combinations(example_isolates)
    +x <- bug_drug_combinations(example_isolates)
     #> NOTE: Using column `mo` as input for `col_mo`.
    -x[1:4, ]
    +x[1:4, ]
     #>             mo  ab S I R total
     #> 1 A. baumannii AMC 0 0 3     3
     #> 2 A. baumannii AMK 0 0 0     0
    @@ -796,20 +800,18 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
     #> NOTE: Use 'format()' on this result to get a publicable/printable format.
     
     # change the transformation with the FUN argument to anything you like:
    -x <- bug_drug_combinations(example_isolates, FUN = mo_gramstain)
    +x <- bug_drug_combinations(example_isolates, FUN = mo_gramstain)
     #> NOTE: Using column `mo` as input for `col_mo`.
    -x[1:4, ]
    +x[1:4, ]
     #>              mo  ab   S  I   R total
     #> 1 Gram-negative AMC 469 89 174   732
     #> 2 Gram-negative AMK 251  0   2   253
     #> 3 Gram-negative AMP 227  0 405   632
     #> 4 Gram-negative AMX 227  0 405   632
    -#> NOTE: Use 'format()' on this result to get a publicable/printable format.
    -
    +#> NOTE: Use 'format()' on this result to get a publicable/printable format.

    You can format this to a printable format, ready for reporting or exporting to e.g. Excel with the base R format() function:

    -format(x, combine_IR = FALSE)
    -
    +format(x, combine_IR = FALSE)
  • Additional way to calculate co-resistance, i.e. when using multiple antimicrobials as input for portion_* functions or count_* functions. This can be used to determine the empiric susceptibility of a combination therapy. A new parameter only_all_tested (which defaults to FALSE) replaces the old also_single_tested and can be used to select one of the two methods to count isolates and calculate portions. The difference can be seen in this example table (which is also on the portion and count help pages), where the %SI is being determined:

    @@ -829,19 +831,17 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ # S or I <NA> X X - - # R <NA> - - - - # <NA> <NA> - - - - -# -------------------------------------------------------------------- - +# --------------------------------------------------------------------

    Since this is a major change, usage of the old also_single_tested will throw an informative error that it has been replaced by only_all_tested.

  • tibble printing support for classes rsi, mic, disk, ab mo. When using tibbles containing antimicrobial columns, values S will print in green, values I will print in yellow and values R will print in red. Microbial IDs (class mo) will emphasise on the genus and species, not on the kingdom.

     # (run this on your own console, as this page does not support colour printing)
    -library(dplyr)
    -example_isolates %>%
    -  select(mo:AMC) %>% 
    -  as_tibble()
    -
    +library(dplyr) +example_isolates %>% + select(mo:AMC) %>% + as_tibble()
  • @@ -898,9 +898,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added more MIC factor levels (as.mic())
  • -
    +

    -Other

    +Other
  • Support for all scientifically published pathotypes of E. coli to date (that we could find). Supported are:

    @@ -946,13 +945,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/

    All these lead to the microbial ID of E. coli:

    -as.mo("UPEC")
    +as.mo("UPEC")
     # B_ESCHR_COL
    -mo_name("UPEC")
    +mo_name("UPEC")
     # "Escherichia coli"
    -mo_gramstain("EHEC")
    -# "Gram-negative"
    -
    +mo_gramstain("EHEC") +# "Gram-negative"
  • Function mo_info() as an analogy to ab_info(). The mo_info() prints a list with the full taxonomy, authors, and the URL to the online database of a microorganism

  • Function mo_synonyms() to get all previously accepted taxonomic names of a microorganism

  • @@ -985,9 +983,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/ -
    +

    -Other

    +Other @@ -1051,15 +1049,14 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • support for boxplots:

    -septic_patients %>% 
    -  freq(age) %>% 
    -  boxplot()
    +septic_patients %>% 
    +  freq(age) %>% 
    +  boxplot()
     # grouped boxplots:
    -septic_patients %>% 
    -  group_by(hospital_id) %>% 
    -  freq(age) %>%
    -  boxplot()
    -
    +septic_patients %>% + group_by(hospital_id) %>% + freq(age) %>% + boxplot()
  • @@ -1081,9 +1078,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Fix for mo_shortname() where species would not be determined correctly
  • -
    +

    -Other

    +Other

    The antibiotics data set will be searched, after which the input data will be checked for column names with a value in any abbreviations, codes or official names found in the antibiotics data set. For example:

    -septic_patients %>% filter_glycopeptides(result = "R")
    +septic_patients %>% filter_glycopeptides(result = "R")
     # Filtering on glycopeptide antibacterials: any of `vanc` or `teic` is R
    -septic_patients %>% filter_glycopeptides(result = "R", scope = "all")
    -# Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R
    -
    +septic_patients %>% filter_glycopeptides(result = "R", scope = "all") +# Filtering on glycopeptide antibacterials: all of `vanc` and `teic` is R
  • All ab_* functions are deprecated and replaced by atc_* functions:

    -ab_property -> atc_property()
    -ab_name -> atc_name()
    -ab_official -> atc_official()
    -ab_trivial_nl -> atc_trivial_nl()
    -ab_certe -> atc_certe()
    -ab_umcg -> atc_umcg()
    -ab_tradenames -> atc_tradenames()
    -
    +ab_property -> atc_property() +ab_name -> atc_name() +ab_official -> atc_official() +ab_trivial_nl -> atc_trivial_nl() +ab_certe -> atc_certe() +ab_umcg -> atc_umcg() +ab_tradenames -> atc_tradenames()

    These functions use as.atc() internally. The old atc_property has been renamed atc_online_property(). This is done for two reasons: firstly, not all ATC codes are of antibiotics (ab) but can also be of antivirals or antifungals. Secondly, the input must have class atc or must be coerable to this class. Properties of these classes should start with the same class name, analogous to as.mo() and e.g. mo_genus.

  • New functions set_mo_source() and get_mo_source() to use your own predefined MO codes as input for as.mo() and consequently all mo_* functions

  • @@ -1190,25 +1184,22 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • New function ggplot_rsi_predict() as well as the base R plot() function can now be used for resistance prediction calculated with resistance_predict():

    -x <- resistance_predict(septic_patients, col_ab = "amox")
    -plot(x)
    -ggplot_rsi_predict(x)
    -
    +x <- resistance_predict(septic_patients, col_ab = "amox") +plot(x) +ggplot_rsi_predict(x)
  • Functions filter_first_isolate() and filter_first_weighted_isolate() to shorten and fasten filtering on data sets with antimicrobial results, e.g.:

    -septic_patients %>% filter_first_isolate(...)
    +septic_patients %>% filter_first_isolate(...)
     # or
    -filter_first_isolate(septic_patients, ...)
    -
    +filter_first_isolate(septic_patients, ...)

    is equal to:

    -septic_patients %>%
    -  mutate(only_firsts = first_isolate(septic_patients, ...)) %>%
    -  filter(only_firsts == TRUE) %>%
    -  select(-only_firsts)
    -
    +septic_patients %>% + mutate(only_firsts = first_isolate(septic_patients, ...)) %>% + filter(only_firsts == TRUE) %>% + select(-only_firsts)
  • New function availability() to check the number of available (non-empty) results in a data.frame

  • New vignettes about how to conduct AMR analysis, predict antimicrobial resistance, use the G-test and more. These are also available (and even easier readable) on our website: https://msberends.gitlab.io/AMR.

  • @@ -1239,24 +1230,22 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
     # mo_fullname() uses as.mo() internally
     
    -mo_fullname("Sthafilokockus aaureuz")
    +mo_fullname("Sthafilokockus aaureuz")
     #> [1] "Staphylococcus aureus"
     
    -mo_fullname("S. klossi")
    -#> [1] "Staphylococcus kloosii"
    -
    +mo_fullname("S. klossi") +#> [1] "Staphylococcus kloosii"
  • Uncertainty of the algorithm is now divided into four levels, 0 to 3, where the default allow_uncertain = TRUE is equal to uncertainty level 2. Run ?as.mo for more info about these levels.

     # equal:
    -as.mo(..., allow_uncertain = TRUE)
    -as.mo(..., allow_uncertain = 2)
    +as.mo(..., allow_uncertain = TRUE)
    +as.mo(..., allow_uncertain = 2)
     
     # also equal:
    -as.mo(..., allow_uncertain = FALSE)
    -as.mo(..., allow_uncertain = 0)
    -
    +as.mo(..., allow_uncertain = FALSE) +as.mo(..., allow_uncertain = 0)

    Using as.mo(..., allow_uncertain = 3) could lead to very unreliable results.

  • Implemented the latest publication of Becker et al. (2019), for categorising coagulase-negative Staphylococci

  • @@ -1264,11 +1253,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Incoercible results will now be considered ‘unknown’, MO code UNKNOWN. On foreign systems, properties of these will be translated to all languages already previously supported: German, Dutch, French, Italian, Spanish and Portuguese:

    -mo_genus("qwerty", language = "es")
    +mo_genus("qwerty", language = "es")
     # Warning: 
     # one unique value (^= 100.0%) could not be coerced and is considered 'unknown': "qwerty". Use mo_failures() to review it.
    -#> [1] "(género desconocido)"
    -
    +#> [1] "(género desconocido)"
  • Fix for vector containing only empty values

  • Finds better results when input is in other languages

  • @@ -1316,18 +1304,17 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
     # Determine genus of microorganisms (mo) in `septic_patients` data set:
     # OLD WAY
    -septic_patients %>%
    -  mutate(genus = mo_genus(mo)) %>%
    -  freq(genus)
    +septic_patients %>%
    +  mutate(genus = mo_genus(mo)) %>%
    +  freq(genus)
     # NEW WAY
    -septic_patients %>% 
    -  freq(mo_genus(mo))
    +septic_patients %>% 
    +  freq(mo_genus(mo))
     
     # Even supports grouping variables:
    -septic_patients %>%
    -  group_by(gender) %>% 
    -  freq(mo_genus(mo))
    -
    +septic_patients%>% + group_by(gender)%>% + freq(mo_genus(mo))
  • Header info is now available as a list, with the header function

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

  • @@ -1348,9 +1335,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • if using different lengths of pattern and x in %like%, it will now return the call
  • -
    +

    -Other

    +Other @@ -1398,11 +1385,10 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Function as.mo (and all mo_* wrappers) now supports genus abbreviations with “species” attached

    -as.mo("E. species")        # B_ESCHR
    -mo_fullname("E. spp.")     # "Escherichia species"
    -as.mo("S. spp")            # B_STPHY
    -mo_fullname("S. species")  # "Staphylococcus species"
    -
    +as.mo("E. species") # B_ESCHR +mo_fullname("E. spp.") # "Escherichia species" +as.mo("S. spp") # B_STPHY +mo_fullname("S. species") # "Staphylococcus species"
  • Added parameter combine_IR (TRUE/FALSE) to functions portion_df and count_df, to indicate that all values of I and R must be merged into one, so the output only consists of S vs. IR (susceptible vs. non-susceptible)

  • Fix for portion_*(..., as_percent = TRUE) when minimal number of isolates would not be met

  • @@ -1415,18 +1401,16 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Support for grouping variables, test with:

    -septic_patients %>% 
    -  group_by(hospital_id) %>% 
    -  freq(gender)
    -
    +septic_patients %>% + group_by(hospital_id) %>% + freq(gender)
  • Support for (un)selecting columns:

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

  • Now prints in markdown at default in non-interactive sessions

  • @@ -1470,9 +1454,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Percentages will now will rounded more logically (e.g. in freq function)

  • -
    +

    -Other

    +Other

    They also come with support for German, Dutch, French, Italian, Spanish and Portuguese:

    -mo_gramstain("E. coli")
    +mo_gramstain("E. coli")
     # [1] "Gram negative"
    -mo_gramstain("E. coli", language = "de") # German
    +mo_gramstain("E. coli", language = "de") # German
     # [1] "Gramnegativ"
    -mo_gramstain("E. coli", language = "es") # Spanish
    +mo_gramstain("E. coli", language = "es") # Spanish
     # [1] "Gram negativo"
    -mo_fullname("S. group A", language = "pt") # Portuguese
    -# [1] "Streptococcus grupo A"
    -
    +mo_fullname("S. group A", language = "pt") # Portuguese +# [1] "Streptococcus grupo A"

    Furthermore, former taxonomic names will give a note about the current taxonomic name:

    -mo_gramstain("Esc blattae")
    +mo_gramstain("Esc blattae")
     # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010)
    -# [1] "Gram negative"
    -
    +# [1] "Gram negative"
  • Functions count_R, count_IR, count_I, count_SI and count_S to selectively count resistant or susceptible isolates

    @@ -1529,21 +1511,19 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Functions as.mo and is.mo as replacements for as.bactid and is.bactid (since the microoganisms data set not only contains bacteria). These last two functions are deprecated and will be removed in a future release. The as.mo function determines microbial IDs using intelligent rules:

    -as.mo("E. coli")
    +as.mo("E. coli")
     # [1] B_ESCHR_COL
    -as.mo("MRSA")
    +as.mo("MRSA")
     # [1] B_STPHY_AUR
    -as.mo("S group A")
    -# [1] B_STRPTC_GRA
    -
    +as.mo("S group A") +# [1] B_STRPTC_GRA

    And with great speed too - on a quite regular Linux server from 2007 it takes us less than 0.02 seconds to transform 25,000 items:

    -thousands_of_E_colis <- rep("E. coli", 25000)
    -microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
    +thousands_of_E_colis <- rep("E. coli", 25000)
    +microbenchmark::microbenchmark(as.mo(thousands_of_E_colis), unit = "s")
     # Unit: seconds
     #         min       median         max  neval
    -#  0.01817717  0.01843957  0.03878077    100
    -
    +# 0.01817717 0.01843957 0.03878077 100
  • Added parameter reference_df for as.mo, so users can supply their own microbial IDs, name or codes as a reference table

  • @@ -1572,13 +1552,12 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Added 163 trade names to the antibiotics data set, it now contains 298 different trade names in total, e.g.:

    -ab_official("Bactroban")
    +ab_official("Bactroban")
     # [1] "Mupirocin"
    -ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
    +ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
     # [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"
    -ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
    -# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
    -
    +ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) +# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
  • For first_isolate, rows will be ignored when there’s no species available

  • Function ratio is now deprecated and will be removed in a future release, as it is not really the scope of this package

  • @@ -1589,14 +1568,13 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Support for quasiquotation in the functions series count_* and portions_*, and n_rsi. This allows to check for more than 2 vectors or columns.

    -septic_patients %>% select(amox, cipr) %>% count_IR()
    +septic_patients %>% select(amox, cipr) %>% count_IR()
     # which is the same as:
    -septic_patients %>% count_IR(amox, cipr)
    +septic_patients %>% count_IR(amox, cipr)
     
    -septic_patients %>% portion_S(amcl)
    -septic_patients %>% portion_S(amcl, gent)
    -septic_patients %>% portion_S(amcl, gent, pita)
    -
    +septic_patients %>% portion_S(amcl) +septic_patients %>% portion_S(amcl, gent) +septic_patients %>% portion_S(amcl, gent, pita)
  • Edited ggplot_rsi and geom_rsi so they can cope with count_df. The new fun parameter has value portion_df at default, but can be set to count_df.

  • Fix for ggplot_rsi when the ggplot2 package was not loaded

  • @@ -1609,21 +1587,19 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Support for types (classes) list and matrix for freq

    -my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2))
    -freq(my_matrix)
    -
    +my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2)) +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 = list(age = septic_patients$age, gender = septic_patients$gender) +my_list %>% freq(age) +my_list %>% freq(gender)
  • -
    +

    -Other

    +Other @@ -1750,9 +1726,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
  • Other small fixes
  • -
    +

    -Other

    +Other
    • Added integration tests (check if everything works as expected) for all releases of R 3.1 and higher
        @@ -1812,9 +1788,9 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
      • Functions as.rsi and as.mic now add the package name and version as attributes
    -
    +

    -Other

    +Other
    • Expanded README.md with more examples
    • Added ORCID of authors to DESCRIPTION file
    • @@ -1862,7 +1838,7 @@ This works for all drug combinations, such as ampicillin/sulbactam, ceftazidime/
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index f15f8936b..c488103bb 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,8 +1,18 @@ pandoc: 2.9.2.1 -pkgdown: 1.5.1.9000 -pkgdown_sha: eae56f08694abebf93cdfc0dd8e9ede06d8c815f -articles: [] -last_built: 2020-10-08T09:09Z +pkgdown: 1.6.1 +pkgdown_sha: ~ +articles: + AMR: AMR.html + EUCAST: EUCAST.html + MDR: MDR.html + PCA: PCA.html + SPSS: SPSS.html + WHONET: WHONET.html + benchmarks: benchmarks.html + datasets: datasets.html + resistance_predict: resistance_predict.html + welcome_to_AMR: welcome_to_AMR.html +last_built: 2020-10-15T07:41Z urls: reference: https://msberends.github.io/AMR//reference article: https://msberends.github.io/AMR//articles diff --git a/docs/reference/AMR.html b/docs/reference/AMR.html index d38253417..fec8077f9 100644 --- a/docs/reference/AMR.html +++ b/docs/reference/AMR.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000
    @@ -309,7 +309,7 @@ The Netherlands

    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/WHOCC.html b/docs/reference/WHOCC.html index eac07f2b8..8ef046c9e 100644 --- a/docs/reference/WHOCC.html +++ b/docs/reference/WHOCC.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000
    @@ -260,10 +260,10 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru

    On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    as.ab("meropenem")
    -ab_name("J01DH02")
    +    
    as.ab("meropenem")
    +ab_name("J01DH02")
     
    -ab_tradenames("flucloxacillin")
    +ab_tradenames("flucloxacillin")
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/WHONET.html b/docs/reference/WHONET.html index 428aa291e..9c2fbc65c 100644 --- a/docs/reference/WHONET.html +++ b/docs/reference/WHONET.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    This example data set has the exact same structure as an export file from WHONET. Such files can be used with this package, as this example data set shows. The antibiotic results are from our example_isolates data set. All patient names are created using online surname generators and are only in place for practice purposes.

    -
    WHONET
    +
    WHONET

    Format

    @@ -302,7 +302,7 @@
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/ab_from_text.html b/docs/reference/ab_from_text.html index 18d86365a..0950f4e02 100644 --- a/docs/reference/ab_from_text.html +++ b/docs/reference/ab_from_text.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,14 +242,14 @@

    Use this function on e.g. clinical texts from health care records. It returns a list with all antimicrobial drugs, doses and forms of administration found in the texts.

    -
    ab_from_text(
    -  text,
    -  type = c("drug", "dose", "administration"),
    -  collapse = NULL,
    -  translate_ab = FALSE,
    -  thorough_search = NULL,
    -  ...
    -)
    +
    ab_from_text(
    +  text,
    +  type = c("drug", "dose", "administration"),
    +  collapse = NULL,
    +  translate_ab = FALSE,
    +  thorough_search = NULL,
    +  ...
    +)

    Arguments

    mo
    1 Mono-resistant322564.50%322564.50%326265.24%326265.24%
    2 Negative69813.96%392378.46%66413.28%392678.52%
    3 Multi-drug-resistant58111.62%450490.08%60912.18%453590.70%
    4 Poly-resistant2985.96%480296.04%2835.66%481896.36%
    5 Extensively drug-resistant1983.96%1823.64% 5000 100.00%
    @@ -285,14 +285,14 @@

    A list, or a character if collapse is not NULL

    Details

    -

    This function is also internally used by as.ab(), although it then only searches for the first drug name and will throw a note if more drug names could have been returned.

    Parameter type

    +

    This function is also internally used by as.ab(), although it then only searches for the first drug name and will throw a note if more drug names could have been returned.

    Parameter type

    At default, the function will search for antimicrobial drug names. All text elements will be searched for official names, ATC codes and brand names. As it uses as.ab() internally, it will correct for misspelling.

    With type = "dose" (or similar, like "dosing", "doses"), all text elements will be searched for numeric values that are higher than 100 and do not resemble years. The output will be numeric. It supports any unit (g, mg, IE, etc.) and multiple values in one clinical text, see Examples.

    With type = "administration" (or abbreviations, like "admin", "adm"), all text elements will be searched for a form of drug administration. It supports the following forms (including common abbreviations): buccal, implant, inhalation, instillation, intravenous, nasal, oral, parenteral, rectal, sublingual, transdermal and vaginal. Abbreviations for oral (such as 'po', 'per os') will become "oral", all values for intravenous (such as 'iv', 'intraven') will become "iv". It supports multiple values in one clinical text, see Examples.

    -

    Parameter collapse

    +

    Parameter collapse

    Without using collapse, this function will return a list. This can be convenient to use e.g. inside a mutate()):
    @@ -316,36 +316,36 @@ The lifecycle of this function is maturing<

    Examples

    # mind the bad spelling of amoxicillin in this line, 
     # straight from a true health care record:
    -ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds")
    +ab_from_text("28/03/2020 regular amoxicilliin 500mg po tds")
     
    -ab_from_text("500 mg amoxi po and 400mg cipro iv")
    -ab_from_text("500 mg amoxi po and 400mg cipro iv", type = "dose")
    -ab_from_text("500 mg amoxi po and 400mg cipro iv", type = "admin")
    +ab_from_text("500 mg amoxi po and 400mg cipro iv")
    +ab_from_text("500 mg amoxi po and 400mg cipro iv", type = "dose")
    +ab_from_text("500 mg amoxi po and 400mg cipro iv", type = "admin")
     
    -ab_from_text("500 mg amoxi po and 400mg cipro iv", collapse = ", ")
    +ab_from_text("500 mg amoxi po and 400mg cipro iv", collapse = ", ")
     
     # if you want to know which antibiotic groups were administered, do e.g.:
    -abx <- ab_from_text("500 mg amoxi po and 400mg cipro iv")
    -ab_group(abx[[1]])
    +abx <- ab_from_text("500 mg amoxi po and 400mg cipro iv")
    +ab_group(abx[[1]])
     
    -if (require("dplyr")) {
    -  tibble(clinical_text = c("given 400mg cipro and 500 mg amox",
    -                           "started on doxy iv today")) %>% 
    -    mutate(abx_codes = ab_from_text(clinical_text),
    -           abx_doses = ab_from_text(clinical_text, type = "doses"),
    -           abx_admin = ab_from_text(clinical_text, type = "admin"),
    -           abx_coll = ab_from_text(clinical_text, collapse = "|"),
    -           abx_coll_names = ab_from_text(clinical_text,
    -                                         collapse = "|",
    -                                         translate_ab = "name"),
    -           abx_coll_doses = ab_from_text(clinical_text,
    -                                         type = "doses",
    -                                         collapse = "|"),
    -           abx_coll_admin = ab_from_text(clinical_text,
    -                                         type = "admin",
    -                                         collapse = "|"))
    +if (require("dplyr")) {
    +  tibble(clinical_text = c("given 400mg cipro and 500 mg amox",
    +                           "started on doxy iv today")) %>% 
    +    mutate(abx_codes = ab_from_text(clinical_text),
    +           abx_doses = ab_from_text(clinical_text, type = "doses"),
    +           abx_admin = ab_from_text(clinical_text, type = "admin"),
    +           abx_coll = ab_from_text(clinical_text, collapse = "|"),
    +           abx_coll_names = ab_from_text(clinical_text,
    +                                         collapse = "|",
    +                                         translate_ab = "name"),
    +           abx_coll_doses = ab_from_text(clinical_text,
    +                                         type = "doses",
    +                                         collapse = "|"),
    +           abx_coll_admin = ab_from_text(clinical_text,
    +                                         type = "admin",
    +                                         collapse = "|"))
     
    -}
    +}
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/ab_property.html b/docs/reference/ab_property.html index 129e6f299..3915f893f 100644 --- a/docs/reference/ab_property.html +++ b/docs/reference/ab_property.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,31 +242,31 @@

    Use these functions to return a specific property of an antibiotic from the antibiotics data set. All input values will be evaluated internally with as.ab().

    -
    ab_name(x, language = get_locale(), tolower = FALSE, ...)
    +    
    ab_name(x, language = get_locale(), tolower = FALSE, ...)
     
    -ab_atc(x, ...)
    +ab_atc(x, ...)
     
    -ab_cid(x, ...)
    +ab_cid(x, ...)
     
    -ab_synonyms(x, ...)
    +ab_synonyms(x, ...)
     
    -ab_tradenames(x, ...)
    +ab_tradenames(x, ...)
     
    -ab_group(x, language = get_locale(), ...)
    +ab_group(x, language = get_locale(), ...)
     
    -ab_atc_group1(x, language = get_locale(), ...)
    +ab_atc_group1(x, language = get_locale(), ...)
     
    -ab_atc_group2(x, language = get_locale(), ...)
    +ab_atc_group2(x, language = get_locale(), ...)
     
    -ab_loinc(x, ...)
    +ab_loinc(x, ...)
     
    -ab_ddd(x, administration = "oral", units = FALSE, ...)
    +ab_ddd(x, administration = "oral", units = FALSE, ...)
     
    -ab_info(x, language = get_locale(), ...)
    +ab_info(x, language = get_locale(), ...)
     
    -ab_url(x, open = FALSE, ...)
    +ab_url(x, open = FALSE, ...)
     
    -ab_property(x, property = "name", language = get_locale(), ...)
    +ab_property(x, property = "name", language = get_locale(), ...)

    Arguments

    @@ -349,42 +349,42 @@ The lifecycle of this function is stableExamples
    # all properties:
    -ab_name("AMX")       # "Amoxicillin"
    -ab_atc("AMX")        # J01CA04 (ATC code from the WHO)
    -ab_cid("AMX")        # 33613 (Compound ID from PubChem)
    -ab_synonyms("AMX")   # a list with brand names of amoxicillin
    -ab_tradenames("AMX") # same
    -ab_group("AMX")      # "Beta-lactams/penicillins"
    -ab_atc_group1("AMX") # "Beta-lactam antibacterials, penicillins"
    -ab_atc_group2("AMX") # "Penicillins with extended spectrum"
    -ab_url("AMX")        # link to the official WHO page
    +ab_name("AMX")       # "Amoxicillin"
    +ab_atc("AMX")        # J01CA04 (ATC code from the WHO)
    +ab_cid("AMX")        # 33613 (Compound ID from PubChem)
    +ab_synonyms("AMX")   # a list with brand names of amoxicillin
    +ab_tradenames("AMX") # same
    +ab_group("AMX")      # "Beta-lactams/penicillins"
    +ab_atc_group1("AMX") # "Beta-lactam antibacterials, penicillins"
    +ab_atc_group2("AMX") # "Penicillins with extended spectrum"
    +ab_url("AMX")        # link to the official WHO page
     
     # smart lowercase tranformation
    -ab_name(x = c("AMC", "PLB"))  # "Amoxicillin/clavulanic acid" "Polymyxin B"
    -ab_name(x = c("AMC", "PLB"),
    -        tolower = TRUE)       # "amoxicillin/clavulanic acid" "polymyxin B"
    +ab_name(x = c("AMC", "PLB"))  # "Amoxicillin/clavulanic acid" "Polymyxin B"
    +ab_name(x = c("AMC", "PLB"),
    +        tolower = TRUE)       # "amoxicillin/clavulanic acid" "polymyxin B"
     
     # defined daily doses (DDD)
    -ab_ddd("AMX", "oral")               #  1
    -ab_ddd("AMX", "oral", units = TRUE) # "g"
    -ab_ddd("AMX", "iv")                 #  1
    -ab_ddd("AMX", "iv", units = TRUE)   # "g"
    +ab_ddd("AMX", "oral")               #  1
    +ab_ddd("AMX", "oral", units = TRUE) # "g"
    +ab_ddd("AMX", "iv")                 #  1
    +ab_ddd("AMX", "iv", units = TRUE)   # "g"
     
    -ab_info("AMX")       # all properties as a list
    +ab_info("AMX")       # all properties as a list
     
     # all ab_* functions use as.ab() internally, so you can go from 'any' to 'any':
    -ab_atc("AMP")           # ATC code of AMP (ampicillin)
    -ab_group("J01CA01")     # Drug group of ampicillins ATC code
    -ab_loinc("ampicillin")  # LOINC codes of ampicillin
    -ab_name("21066-6")      # "Ampicillin" (using LOINC)
    -ab_name(6249)           # "Ampicillin" (using CID)
    -ab_name("J01CA01")      # "Ampicillin" (using ATC)
    +ab_atc("AMP")           # ATC code of AMP (ampicillin)
    +ab_group("J01CA01")     # Drug group of ampicillins ATC code
    +ab_loinc("ampicillin")  # LOINC codes of ampicillin
    +ab_name("21066-6")      # "Ampicillin" (using LOINC)
    +ab_name(6249)           # "Ampicillin" (using CID)
    +ab_name("J01CA01")      # "Ampicillin" (using ATC)
     
     # spelling from different languages and dyslexia are no problem
    -ab_atc("ceftriaxon")
    -ab_atc("cephtriaxone")
    -ab_atc("cephthriaxone")
    -ab_atc("seephthriaaksone")
    +ab_atc("ceftriaxon")
    +ab_atc("cephtriaxone")
    +ab_atc("cephthriaxone")
    +ab_atc("seephthriaaksone")
     
    @@ -242,7 +242,7 @@

    Calculates age in years based on a reference date, which is the sytem date at default.

    -
    age(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE)
    +
    age(x, reference = Sys.Date(), exact = FALSE, na.rm = FALSE)

    Arguments

    @@ -286,13 +286,13 @@ The lifecycle of this function is stableExamples
    # 10 random birth dates
    -df <- data.frame(birth_date = Sys.Date() - runif(10) * 25000)
    +df <- data.frame(birth_date = Sys.Date() - runif(10) * 25000)
     # add ages
    -df$age <- age(df$birth_date)
    +df$age <- age(df$birth_date)
     # add exact ages
    -df$age_exact <- age(df$birth_date, exact = TRUE)
    +df$age_exact <- age(df$birth_date, exact = TRUE)
     
    -df
    +df
     
    @@ -242,7 +242,7 @@

    Split ages into age groups defined by the split parameter. This allows for easier demographic (antimicrobial resistance) analysis.

    -
    age_groups(x, split_at = c(12, 25, 55, 75), na.rm = FALSE)
    +
    age_groups(x, split_at = c(12, 25, 55, 75), na.rm = FALSE)

    Arguments

    @@ -294,36 +294,36 @@ The lifecycle of this function is stable

    To determine ages, based on one or more reference dates, use the age() function.

    Examples

    -
    ages <- c(3, 8, 16, 54, 31, 76, 101, 43, 21)
    +    
    ages <- c(3, 8, 16, 54, 31, 76, 101, 43, 21)
     
     # split into 0-49 and 50+
    -age_groups(ages, 50)
    +age_groups(ages, 50)
     
     # split into 0-19, 20-49 and 50+
    -age_groups(ages, c(20, 50))
    +age_groups(ages, c(20, 50))
     
     # split into groups of ten years
    -age_groups(ages, 1:10 * 10)
    -age_groups(ages, split_at = "tens")
    +age_groups(ages, 1:10 * 10)
    +age_groups(ages, split_at = "tens")
     
     # split into groups of five years
    -age_groups(ages, 1:20 * 5)
    -age_groups(ages, split_at = "fives")
    +age_groups(ages, 1:20 * 5)
    +age_groups(ages, split_at = "fives")
     
     # split specifically for children
    -age_groups(ages, "children")
    +age_groups(ages, "children")
     # same:
    -age_groups(ages, c(1, 2, 4, 6, 13, 17))
    +age_groups(ages, c(1, 2, 4, 6, 13, 17))
     
     # \donttest{
     # resistance of ciprofloxacine per age group
    -library(dplyr)
    -example_isolates %>%
    -  filter_first_isolate() %>%
    -  filter(mo == as.mo("E. coli")) %>%
    -  group_by(age_group = age_groups(age)) %>%
    -  select(age_group, CIP) %>%
    -  ggplot_rsi(x = "age_group", minimum = 0)
    +library(dplyr)
    +example_isolates %>%
    +  filter_first_isolate() %>%
    +  filter(mo == as.mo("E. coli")) %>%
    +  group_by(age_group = age_groups(age)) %>%
    +  select(age_group, CIP) %>%
    +  ggplot_rsi(x = "age_group", minimum = 0)
     # }
     
    @@ -341,7 +341,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/antibiotic_class_selectors.html b/docs/reference/antibiotic_class_selectors.html index a6b1c94dd..50f8ada8b 100644 --- a/docs/reference/antibiotic_class_selectors.html +++ b/docs/reference/antibiotic_class_selectors.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,33 +242,33 @@

    Use these selection helpers inside any function that allows Tidyverse selection helpers, like dplyr::select() or tidyr::pivot_longer(). They help to select the columns of antibiotics that are of a specific antibiotic class, without the need to define the columns or antibiotic abbreviations.

    -
    ab_class(ab_class)
    +    
    ab_class(ab_class)
     
    -aminoglycosides()
    +aminoglycosides()
     
    -carbapenems()
    +carbapenems()
     
    -cephalosporins()
    +cephalosporins()
     
    -cephalosporins_1st()
    +cephalosporins_1st()
     
    -cephalosporins_2nd()
    +cephalosporins_2nd()
     
    -cephalosporins_3rd()
    +cephalosporins_3rd()
     
    -cephalosporins_4th()
    +cephalosporins_4th()
     
    -cephalosporins_5th()
    +cephalosporins_5th()
     
    -fluoroquinolones()
    +fluoroquinolones()
     
    -glycopeptides()
    +glycopeptides()
     
    -macrolides()
    +macrolides()
     
    -penicillins()
    +penicillins()
     
    -tetracyclines()
    +tetracyclines()

    Arguments

    @@ -298,34 +298,34 @@

    filter_ab_class() for the filter() equivalent.

    Examples

    -
    if (require("dplyr")) {
    +    
    if (require("dplyr")) {
     
       # this will select columns 'IPM' (imipenem) and 'MEM' (meropenem):
    -  example_isolates %>% 
    -    select(carbapenems())
    +  example_isolates %>% 
    +    select(carbapenems())
         
       # this will select columns 'mo', 'AMK', 'GEN', 'KAN' and 'TOB':
    -  example_isolates %>% 
    -    select(mo, aminoglycosides())
    +  example_isolates %>% 
    +    select(mo, aminoglycosides())
         
       # this will select columns 'mo' and all antimycobacterial drugs ('RIF'):
    -  example_isolates %>% 
    -    select(mo, ab_class("mycobact"))
    +  example_isolates %>% 
    +    select(mo, ab_class("mycobact"))
         
         
       # get bug/drug combinations for only macrolides in Gram-positives:
    -  example_isolates %>% 
    -    filter(mo_gramstain(mo) %like% "pos") %>% 
    -    select(mo, macrolides()) %>% 
    -    bug_drug_combinations() %>%
    -    format()
    +  example_isolates %>% 
    +    filter(mo_gramstain(mo) %like% "pos") %>% 
    +    select(mo, macrolides()) %>% 
    +    bug_drug_combinations() %>%
    +    format()
         
         
    -  data.frame(some_column = "some_value",
    -             J01CA01 = "S") %>%   # ATC code of ampicillin
    -    select(penicillins())         # only the 'J01CA01' column will be selected
    +  data.frame(some_column = "some_value",
    +             J01CA01 = "S") %>%   # ATC code of ampicillin
    +    select(penicillins())         # only the 'J01CA01' column will be selected
     
    -}
    +}
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/antibiotics.html b/docs/reference/antibiotics.html index 278b2ab33..0917e79b7 100644 --- a/docs/reference/antibiotics.html +++ b/docs/reference/antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,15 +242,15 @@

    Two data sets containing all antibiotics/antimycotics and antivirals. Use as.ab() or one of the ab_property() functions to retrieve values from the antibiotics data set. Three identifiers are included in this data set: an antibiotic ID (ab, primarily used in this package) as defined by WHONET/EARS-Net, an ATC code (atc) as defined by the WHO, and a Compound ID (cid) as found in PubChem. Other properties in this data set are derived from one or more of these codes.

    -
    antibiotics
    +    
    antibiotics
     
    -antivirals
    +antivirals

    Format

    -

    For the antibiotics data set: a data.frame with 455 observations and 14 variables:

    +

    For the antibiotics data set: a data.frame with 455 observations and 14 variables:

    • ab
      Antibiotic ID as used in this package (like AMC), using the official EARS-Net (European Antimicrobial Resistance Surveillance Network) codes where available

    • @@ -270,7 +270,7 @@
    -

    For the antivirals data set: a data.frame with 102 observations and 9 variables:

    +

    For the antivirals data set: a data.frame with 102 observations and 9 variables:

    • atc
      ATC code (Anatomical Therapeutic Chemical) as defined by the WHOCC

    • @@ -294,7 +294,7 @@

      Details

      Properties that are based on an ATC code are only available when an ATC is available. These properties are: atc_group1, atc_group2, oral_ddd, oral_units, iv_ddd and iv_units.

      -

      Synonyms (i.e. trade names) are derived from the Compound ID (cid) and consequently only available where a CID is available.

      Direct download

      +

      Synonyms (i.e. trade names) are derived from the Compound ID (cid) and consequently only available where a CID is available.

      Direct download

      These data sets are available as 'flat files' for use even without R - you can find the files here:

        @@ -346,7 +346,7 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru
        -

        Site built with pkgdown 1.5.1.9000.

        +

        Site built with pkgdown 1.6.1.

        diff --git a/docs/reference/as.ab.html b/docs/reference/as.ab.html index 2146f72f3..d5317e0cb 100644 --- a/docs/reference/as.ab.html +++ b/docs/reference/as.ab.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,9 +242,9 @@

        Use this function to determine the antibiotic code of one or more antibiotics. The data set antibiotics will be searched for abbreviations, official names and synonyms (brand names).

        -
        as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...)
        +    
        as.ab(x, flag_multiple_results = TRUE, info = TRUE, ...)
         
        -is.ab(x)
        +is.ab(x)

        Arguments

    @@ -325,27 +325,27 @@ This package contains all ~550 antibiotic, antimycotic and antiviral dru

    Examples

    # these examples all return "ERY", the ID of erythromycin:
    -as.ab("J01FA01")
    -as.ab("J 01 FA 01")
    -as.ab("Erythromycin")
    -as.ab("eryt")
    -as.ab("   eryt 123")
    -as.ab("ERYT")
    -as.ab("ERY")
    -as.ab("eritromicine") # spelled wrong, yet works
    -as.ab("Erythrocin")   # trade name
    -as.ab("Romycin")      # trade name
    +as.ab("J01FA01")
    +as.ab("J 01 FA 01")
    +as.ab("Erythromycin")
    +as.ab("eryt")
    +as.ab("   eryt 123")
    +as.ab("ERYT")
    +as.ab("ERY")
    +as.ab("eritromicine") # spelled wrong, yet works
    +as.ab("Erythrocin")   # trade name
    +as.ab("Romycin")      # trade name
     
     # spelling from different languages and dyslexia are no problem
    -ab_atc("ceftriaxon")
    -ab_atc("cephtriaxone")     # small spelling error
    -ab_atc("cephthriaxone")    # or a bit more severe
    -ab_atc("seephthriaaksone") # and even this works
    +ab_atc("ceftriaxon")
    +ab_atc("cephtriaxone")     # small spelling error
    +ab_atc("cephthriaxone")    # or a bit more severe
    +ab_atc("seephthriaaksone") # and even this works
     
     # use ab_* functions to get a specific properties (see ?ab_property);
     # they use as.ab() internally:
    -ab_name("J01FA01")    # "Erythromycin"
    -ab_name("eryt")       # "Erythromycin"
    +ab_name("J01FA01")    # "Erythromycin"
    +ab_name("eryt")       # "Erythromycin"
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/as.disk.html b/docs/reference/as.disk.html index 3c3c2da9c..5c8eb7085 100644 --- a/docs/reference/as.disk.html +++ b/docs/reference/as.disk.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,9 +242,9 @@

    This transforms a vector to a new class disk, which is a disk diffusion growth zone size (around an antibiotic disk) in millimetres between 6 and 50.

    -
    as.disk(x, na.rm = FALSE)
    +    
    as.disk(x, na.rm = FALSE)
     
    -is.disk(x)
    +is.disk(x)

    Arguments

    @@ -284,23 +284,23 @@ The lifecycle of this function is stableExamples
    # \donttest{
     # transform existing disk zones to the `disk` class
    -library(dplyr)
    -df <- data.frame(microorganism = "E. coli",
    -                 AMP = 20,
    -                 CIP = 14,
    -                 GEN = 18,
    -                 TOB = 16)
    -df[, 2:5] <- lapply(df[, 2:5], as.disk)
    +library(dplyr)
    +df <- data.frame(microorganism = "E. coli",
    +                 AMP = 20,
    +                 CIP = 14,
    +                 GEN = 18,
    +                 TOB = 16)
    +df[, 2:5] <- lapply(df[, 2:5], as.disk)
     # same with dplyr:
     # df %>% mutate(across(AMP:TOB, as.disk))
     
     # interpret disk values, see ?as.rsi
    -as.rsi(x = as.disk(18),
    -       mo = "Strep pneu",  # `mo` will be coerced with as.mo()
    -       ab = "ampicillin",  # and `ab` with as.ab()
    -       guideline = "EUCAST")
    +as.rsi(x = as.disk(18),
    +       mo = "Strep pneu",  # `mo` will be coerced with as.mo()
    +       ab = "ampicillin",  # and `ab` with as.ab()
    +       guideline = "EUCAST")
            
    -as.rsi(df)
    +as.rsi(df)
     # }
     
    @@ -318,7 +318,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/as.mic.html b/docs/reference/as.mic.html index 4467e4135..530811457 100644 --- a/docs/reference/as.mic.html +++ b/docs/reference/as.mic.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,9 +242,9 @@

    This transforms a vector to a new class mic, which is an ordered factor with valid minimum inhibitory concentrations (MIC) as levels. Invalid MIC values will be translated as NA with a warning.

    -
    as.mic(x, na.rm = FALSE)
    +    
    as.mic(x, na.rm = FALSE)
     
    -is.mic(x)
    +is.mic(x)

    Arguments

    @@ -282,24 +282,24 @@ The lifecycle of this function is stable

    as.rsi()

    Examples

    -
    mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
    -is.mic(mic_data)
    +    
    mic_data <- as.mic(c(">=32", "1.0", "1", "1.00", 8, "<=0.128", "8", "16", "16"))
    +is.mic(mic_data)
     
     # this can also coerce combined MIC/RSI values:
    -as.mic("<=0.002; S") # will return <=0.002
    +as.mic("<=0.002; S") # will return <=0.002
     
     # interpret MIC values
    -as.rsi(x = as.mic(2),
    -       mo = as.mo("S. pneumoniae"),
    -       ab = "AMX",
    -       guideline = "EUCAST")
    -as.rsi(x = as.mic(4),
    -       mo = as.mo("S. pneumoniae"),
    -       ab = "AMX",
    -       guideline = "EUCAST")
    +as.rsi(x = as.mic(2),
    +       mo = as.mo("S. pneumoniae"),
    +       ab = "AMX",
    +       guideline = "EUCAST")
    +as.rsi(x = as.mic(4),
    +       mo = as.mo("S. pneumoniae"),
    +       ab = "AMX",
    +       guideline = "EUCAST")
     
    -plot(mic_data)
    -barplot(mic_data)
    +plot(mic_data)
    +barplot(mic_data)
     
    @@ -242,24 +242,24 @@

    Use this function to determine a valid microorganism ID (mo). Determination is done using intelligent rules and the complete taxonomic kingdoms Bacteria, Chromista, Protozoa, Archaea and most microbial species from the kingdom Fungi (see Source). The input can be almost anything: a full name (like "Staphylococcus aureus"), an abbreviated name (like "S. aureus"), an abbreviation known in the field (like "MRSA"), or just a genus. Please see Examples.

    -
    as.mo(
    -  x,
    -  Becker = FALSE,
    -  Lancefield = FALSE,
    -  allow_uncertain = TRUE,
    -  reference_df = get_mo_source(),
    -  ignore_pattern = getOption("AMR_ignore_pattern"),
    -  language = get_locale(),
    -  ...
    -)
    +    
    as.mo(
    +  x,
    +  Becker = FALSE,
    +  Lancefield = FALSE,
    +  allow_uncertain = TRUE,
    +  reference_df = get_mo_source(),
    +  ignore_pattern = getOption("AMR_ignore_pattern"),
    +  language = get_locale(),
    +  ...
    +)
     
    -is.mo(x)
    +is.mo(x)
     
    -mo_failures()
    +mo_failures()
     
    -mo_uncertainties()
    +mo_uncertainties()
     
    -mo_renamed()
    +mo_renamed()

    Arguments

    @@ -306,7 +306,7 @@

    Details

    -

    General info

    +

    General info

    A microorganism ID from this package (class: mo) is human readable and typically looks like these examples:

      Code               Full name
    @@ -334,7 +334,7 @@
     
     

    This will lead to the effect that e.g. "E. coli" (a microorganism highly prevalent in humans) will return the microbial ID of Escherichia coli and not Entamoeba coli (a microorganism less prevalent in humans), although the latter would alphabetically come first.

    -

    Coping with uncertain results

    +

    Coping with uncertain results

    In addition, the as.mo() function can differentiate four levels of uncertainty to guess valid results:

      @@ -358,7 +358,7 @@
    -

    Microbial prevalence of pathogens in humans

    +

    Microbial prevalence of pathogens in humans

    The intelligent rules consider the prevalence of microorganisms in humans grouped into three groups, which is available as the prevalence columns in the microorganisms and microorganisms.old data sets. The grouping into human pathogenic prevalence is explained in the section Matching score for microorganisms below.

    @@ -423,39 +423,39 @@ This package contains the complete taxonomic tree of almost all microorganisms (

    Examples

    # \donttest{
     # These examples all return "B_STPHY_AURS", the ID of S. aureus:
    -as.mo("sau") # WHONET code
    -as.mo("stau")
    -as.mo("STAU")
    -as.mo("staaur")
    -as.mo("S. aureus")
    -as.mo("S aureus")
    -as.mo("Staphylococcus aureus")
    -as.mo("Staphylococcus aureus (MRSA)")
    -as.mo("Zthafilokkoockus oureuz") # handles 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(115329001) # SNOMED CT code
    +as.mo("sau") # WHONET code
    +as.mo("stau")
    +as.mo("STAU")
    +as.mo("staaur")
    +as.mo("S. aureus")
    +as.mo("S aureus")
    +as.mo("Staphylococcus aureus")
    +as.mo("Staphylococcus aureus (MRSA)")
    +as.mo("Zthafilokkoockus oureuz") # handles 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(115329001) # SNOMED CT code
     
     # Dyslexia is no problem - these all work:
    -as.mo("Ureaplasma urealyticum")
    -as.mo("Ureaplasma urealyticus")
    -as.mo("Ureaplasmium urealytica")
    -as.mo("Ureaplazma urealitycium")
    +as.mo("Ureaplasma urealyticum")
    +as.mo("Ureaplasma urealyticus")
    +as.mo("Ureaplasmium urealytica")
    +as.mo("Ureaplazma urealitycium")
     
    -as.mo("Streptococcus group A")
    -as.mo("GAS") # Group A Streptococci
    -as.mo("GBS") # Group B Streptococci
    +as.mo("Streptococcus group A")
    +as.mo("GAS") # Group A Streptococci
    +as.mo("GBS") # Group B Streptococci
     
    -as.mo("S. epidermidis")                 # will remain species: B_STPHY_EPDR
    -as.mo("S. epidermidis", Becker = TRUE)  # will not remain species: B_STPHY_CONS
    +as.mo("S. epidermidis")                 # will remain species: B_STPHY_EPDR
    +as.mo("S. epidermidis", Becker = TRUE)  # will not remain species: B_STPHY_CONS
     
    -as.mo("S. pyogenes")                    # will remain species: B_STRPT_PYGN
    -as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA
    +as.mo("S. pyogenes")                    # will remain species: B_STRPT_PYGN
    +as.mo("S. pyogenes", Lancefield = TRUE) # will not remain species: B_STRPT_GRPA
     
     # All mo_* functions use as.mo() internally too (see ?mo_property):
    -mo_genus("E. coli")           # returns "Escherichia"
    -mo_gramstain("E. coli")       # returns "Gram negative"
    +mo_genus("E. coli")           # returns "Escherichia"
    +mo_gramstain("E. coli")       # returns "Gram negative"
     # }
     
    @@ -473,7 +473,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/as.rsi.html b/docs/reference/as.rsi.html index eca6e93ab..eb7b2ba74 100644 --- a/docs/reference/as.rsi.html +++ b/docs/reference/as.rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,45 +242,45 @@

    Interpret minimum inhibitory concentration (MIC) values and disk diffusion diameters according to EUCAST or CLSI, or clean up existing R/SI values. This transforms the input to a new class rsi, which is an ordered factor with levels S < I < R. Values that cannot be interpreted will be returned as NA with a warning.

    -
    as.rsi(x, ...)
    +    
    as.rsi(x, ...)
     
    -is.rsi(x)
    +is.rsi(x)
     
    -is.rsi.eligible(x, threshold = 0.05)
    +is.rsi.eligible(x, threshold = 0.05)
     
     # S3 method for mic
    -as.rsi(
    -  x,
    -  mo = NULL,
    -  ab = deparse(substitute(x)),
    -  guideline = "EUCAST",
    -  uti = FALSE,
    -  conserve_capped_values = FALSE,
    -  add_intrinsic_resistance = FALSE,
    -  ...
    -)
    +as.rsi(
    +  x,
    +  mo = NULL,
    +  ab = deparse(substitute(x)),
    +  guideline = "EUCAST",
    +  uti = FALSE,
    +  conserve_capped_values = FALSE,
    +  add_intrinsic_resistance = FALSE,
    +  ...
    +)
     
     # S3 method for disk
    -as.rsi(
    -  x,
    -  mo = NULL,
    -  ab = deparse(substitute(x)),
    -  guideline = "EUCAST",
    -  uti = FALSE,
    -  add_intrinsic_resistance = FALSE,
    -  ...
    -)
    +as.rsi(
    +  x,
    +  mo = NULL,
    +  ab = deparse(substitute(x)),
    +  guideline = "EUCAST",
    +  uti = FALSE,
    +  add_intrinsic_resistance = FALSE,
    +  ...
    +)
     
     # S3 method for data.frame
    -as.rsi(
    -  x,
    -  ...,
    -  col_mo = NULL,
    -  guideline = "EUCAST",
    -  uti = NULL,
    -  conserve_capped_values = FALSE,
    -  add_intrinsic_resistance = FALSE
    -)
    +as.rsi( + x, + ..., + col_mo = NULL, + guideline = "EUCAST", + uti = NULL, + conserve_capped_values = FALSE, + add_intrinsic_resistance = FALSE +)

    Arguments

    @@ -334,43 +334,43 @@ list(version_txt = "v3.2", year = 2020, title = "EUCAST Expert Rules / EUCAST In

    Details

    -

    How it works

    +

    How it works

    The as.rsi() function works in four ways:

    1. For cleaning raw / untransformed data. The data will be cleaned to only contain values S, I and R and will try its best to determine this with some intelligence. For example, mixed values with R/SI interpretations and MIC values such as "<0.25; S" will be coerced to "S". Combined interpretations for multiple test methods (as seen in laboratory records) such as "S; S" will be coerced to "S", but a value like "S; I" will return NA with a warning that the input is unclear.

    2. For interpreting minimum inhibitory concentration (MIC) values according to EUCAST or CLSI. You must clean your MIC values first using as.mic(), that also gives your columns the new data class mic. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the mo parameter.

        -
      • Using dplyr, R/SI interpretation can be done very easily with either:

        your_data %>% mutate_if(is.mic, as.rsi)             # until dplyr 1.0.0
        -your_data %>% mutate(across(where(is.mic), as.rsi)) # since dplyr 1.0.0
        +
      • Using dplyr, R/SI interpretation can be done very easily with either:

        your_data %>% mutate_if(is.mic, as.rsi)             # until dplyr 1.0.0
        +your_data %>% mutate(across(where(is.mic), as.rsi)) # since dplyr 1.0.0
         
      • Operators like "<=" will be stripped before interpretation. When using conserve_capped_values = TRUE, an MIC value of e.g. ">2" will always return "R", even if the breakpoint according to the chosen guideline is ">=4". This is to prevent that capped values from raw laboratory data would not be treated conservatively. The default behaviour (conserve_capped_values = FALSE) considers ">2" to be lower than ">=4" and might in this case return "S" or "I".

    3. For interpreting disk diffusion diameters according to EUCAST or CLSI. You must clean your disk zones first using as.disk(), that also gives your columns the new data class disk. Also, be sure to have a column with microorganism names or codes. It will be found automatically, but can be set manually using the mo parameter.

        -
      • Using dplyr, R/SI interpretation can be done very easily with either:

        your_data %>% mutate_if(is.disk, as.rsi)             # until dplyr 1.0.0
        -your_data %>% mutate(across(where(is.disk), as.rsi)) # since dplyr 1.0.0
        +
      • Using dplyr, R/SI interpretation can be done very easily with either:

        your_data %>% mutate_if(is.disk, as.rsi)             # until dplyr 1.0.0
        +your_data %>% mutate(across(where(is.disk), as.rsi)) # since dplyr 1.0.0
         
    4. For interpreting a complete data set, with automatic determination of MIC values, disk diffusion diameters, microorganism names or codes, and antimicrobial test results. This is done very simply by running as.rsi(data).

    -

    Supported guidelines

    +

    Supported guidelines

    For interpreting MIC values as well as disk diffusion diameters, supported guidelines to be used as input for the guideline parameter are: "CLSI 2010", "CLSI 2011", "CLSI 2012", "CLSI 2013", "CLSI 2014", "CLSI 2015", "CLSI 2016", "CLSI 2017", "CLSI 2018", "CLSI 2019", "EUCAST 2011", "EUCAST 2012", "EUCAST 2013", "EUCAST 2014", "EUCAST 2015", "EUCAST 2016", "EUCAST 2017", "EUCAST 2018", "EUCAST 2019", "EUCAST 2020".

    Simply using "CLSI" or "EUCAST" as input will automatically select the latest version of that guideline.

    -

    After interpretation

    +

    After interpretation

    After using as.rsi(), you can use the eucast_rules() defined by EUCAST to (1) apply inferred susceptibility and resistance based on results of other antimicrobials and (2) apply intrinsic resistance based on taxonomic properties of a microorganism.

    -

    Machine readable interpretation guidelines

    +

    Machine readable interpretation guidelines

    The repository of this package contains a machine readable version of all guidelines. This is a CSV file consisting of 18,650 rows and 10 columns. This file is machine readable, since it contains one row for every unique combination of the test method (MIC or disk diffusion), the antimicrobial agent and the microorganism. This allows for easy implementation of these rules in laboratory information systems (LIS). Note that it only contains interpretation guidelines for humans - interpretation guidelines from CLSI for animals were removed.

    -

    Other

    +

    Other

    The function is.rsi.eligible() returns TRUE when a columns contains at most 5% invalid antimicrobial interpretations (not S and/or I and/or R), and FALSE otherwise. The threshold of 5% can be set with the threshold parameter.

    @@ -411,87 +411,87 @@ The lifecycle of this function is stable

    as.mic(), as.disk(), as.mo()

    Examples

    -
    summary(example_isolates) # see all R/SI results at a glance
    +    
    summary(example_isolates) # see all R/SI results at a glance
     
    -if (require("skimr")) {
    +if (require("skimr")) {
       # support for skim() too:
    -  skim(example_isolates)
    -}
    +  skim(example_isolates)
    +}
     
     # For INTERPRETING disk diffusion and MIC values -----------------------
            
     # a whole data set, even with combined MIC values and disk zones
    -df <- data.frame(microorganism = "E. coli",
    -                 AMP = as.mic(8),
    -                 CIP = as.mic(0.256),
    -                 GEN = as.disk(18),
    -                 TOB = as.disk(16),
    -                 NIT = as.mic(32))
    -as.rsi(df)
    +df <- data.frame(microorganism = "E. coli",
    +                 AMP = as.mic(8),
    +                 CIP = as.mic(0.256),
    +                 GEN = as.disk(18),
    +                 TOB = as.disk(16),
    +                 NIT = as.mic(32))
    +as.rsi(df)
     
     # for single values
    -as.rsi(x = as.mic(2),
    -       mo = as.mo("S. pneumoniae"),
    -       ab = "AMP",
    -       guideline = "EUCAST")
    +as.rsi(x = as.mic(2),
    +       mo = as.mo("S. pneumoniae"),
    +       ab = "AMP",
    +       guideline = "EUCAST")
     
    -as.rsi(x = as.disk(18),
    -       mo = "Strep pneu",  # `mo` will be coerced with as.mo()
    -       ab = "ampicillin",  # and `ab` with as.ab()
    -       guideline = "EUCAST")
    +as.rsi(x = as.disk(18),
    +       mo = "Strep pneu",  # `mo` will be coerced with as.mo()
    +       ab = "ampicillin",  # and `ab` with as.ab()
    +       guideline = "EUCAST")
     
     # \donttest{
     # the dplyr way
    -if (require("dplyr")) {
    -  df %>% mutate_if(is.mic, as.rsi)
    -  df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
    -  df %>% mutate(across(where(is.mic), as.rsi))
    -  df %>% mutate_at(vars(AMP:TOB), as.rsi)
    -  df %>% mutate(across(AMP:TOB, as.rsi))
    +if (require("dplyr")) {
    +  df %>% mutate_if(is.mic, as.rsi)
    +  df %>% mutate_if(function(x) is.mic(x) | is.disk(x), as.rsi)
    +  df %>% mutate(across(where(is.mic), as.rsi))
    +  df %>% mutate_at(vars(AMP:TOB), as.rsi)
    +  df %>% mutate(across(AMP:TOB, as.rsi))
      
    -  df %>%
    -    mutate_at(vars(AMP:TOB), as.rsi, mo = "E. coli")
    +  df %>%
    +    mutate_at(vars(AMP:TOB), as.rsi, mo = "E. coli")
         
       # to include information about urinary tract infections (UTI)
    -  data.frame(mo = "E. coli",
    -             NIT = c("<= 2", 32),
    -             from_the_bladder = c(TRUE, FALSE)) %>%
    -    as.rsi(uti = "from_the_bladder")
    +  data.frame(mo = "E. coli",
    +             NIT = c("<= 2", 32),
    +             from_the_bladder = c(TRUE, FALSE)) %>%
    +    as.rsi(uti = "from_the_bladder")
         
    -  data.frame(mo = "E. coli",
    -             NIT = c("<= 2", 32),
    -             specimen = c("urine", "blood")) %>%
    -    as.rsi() # automatically determines urine isolates
    +  data.frame(mo = "E. coli",
    +             NIT = c("<= 2", 32),
    +             specimen = c("urine", "blood")) %>%
    +    as.rsi() # automatically determines urine isolates
       
    -  df %>%
    -    mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)  
    -}
    +  df %>%
    +    mutate_at(vars(AMP:NIT), as.rsi, mo = "E. coli", uti = TRUE)  
    +}
     
     # For CLEANING existing R/SI values ------------------------------------
     
    -as.rsi(c("S", "I", "R", "A", "B", "C"))
    -as.rsi("<= 0.002; S") # will return "S"
    -rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
    -is.rsi(rsi_data)
    -plot(rsi_data)    # for percentages
    -barplot(rsi_data) # for frequencies
    +as.rsi(c("S", "I", "R", "A", "B", "C"))
    +as.rsi("<= 0.002; S") # will return "S"
    +rsi_data <- as.rsi(c(rep("S", 474), rep("I", 36), rep("R", 370)))
    +is.rsi(rsi_data)
    +plot(rsi_data)    # for percentages
    +barplot(rsi_data) # for frequencies
     
     # the dplyr way
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    mutate_at(vars(PEN:RIF), as.rsi)
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    mutate_at(vars(PEN:RIF), as.rsi)
       # same:   
    -  example_isolates %>%
    -    as.rsi(PEN:RIF)
    +  example_isolates %>%
    +    as.rsi(PEN:RIF)
      
       # fastest way to transform all columns with already valid AMR results to class `rsi`:
    -  example_isolates %>%
    -    mutate_if(is.rsi.eligible, as.rsi)
    +  example_isolates %>%
    +    mutate_if(is.rsi.eligible, as.rsi)
         
       # note: from dplyr 1.0.0 on, this will be: 
       # example_isolates %>%
       #   mutate(across(where(is.rsi.eligible), as.rsi))
    -}
    +}
     # }
     
    @@ -509,7 +509,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/atc_online.html b/docs/reference/atc_online.html index 22879c502..742cb29c2 100644 --- a/docs/reference/atc_online.html +++ b/docs/reference/atc_online.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,17 +242,17 @@

    Gets data from the WHO to determine properties of an ATC (e.g. an antibiotic), such as the name, defined daily dose (DDD) or standard unit.

    -
    atc_online_property(
    -  atc_code,
    -  property,
    -  administration = "O",
    -  url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no",
    -  url_vet = "https://www.whocc.no/atcvet/atcvet_index/?code=%s&showdescription=no"
    -)
    +    
    atc_online_property(
    +  atc_code,
    +  property,
    +  administration = "O",
    +  url = "https://www.whocc.no/atc_ddd_index/?code=%s&showdescription=no",
    +  url_vet = "https://www.whocc.no/atcvet/atcvet_index/?code=%s&showdescription=no"
    +)
     
    -atc_online_groups(atc_code, ...)
    +atc_online_groups(atc_code, ...)
     
    -atc_online_ddd(atc_code, ...)
    +atc_online_ddd(atc_code, ...)

    Arguments

    @@ -329,12 +329,12 @@ The lifecycle of this function is stableExamples
    # \donttest{
     # oral DDD (Defined Daily Dose) of amoxicillin
    -atc_online_property("J01CA04", "DDD", "O")
    +atc_online_property("J01CA04", "DDD", "O")
     
     # parenteral DDD (Defined Daily Dose) of amoxicillin
    -atc_online_property("J01CA04", "DDD", "P")
    +atc_online_property("J01CA04", "DDD", "P")
     
    -atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
    +atc_online_property("J01CA04", property = "groups") # search hierarchical groups of amoxicillin
     # }
     
    @@ -352,7 +352,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/availability.html b/docs/reference/availability.html index 5c4d6c123..708c0eca3 100644 --- a/docs/reference/availability.html +++ b/docs/reference/availability.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    Easy check for data availability of all columns in a data set. This makes it easy to get an idea of which antimicrobial combinations can be used for calculation with e.g. susceptibility() and resistance().

    -
    availability(tbl, width = NULL)
    +
    availability(tbl, width = NULL)

    Arguments

    @@ -277,14 +277,14 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    availability(example_isolates)
    +    
    availability(example_isolates)
     
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    filter(mo == as.mo("E. coli")) %>%
    -    select_if(is.rsi) %>%
    -    availability()
    -}
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    filter(mo == as.mo("E. coli")) %>%
    +    select_if(is.rsi) %>%
    +    availability()
    +}
     
    @@ -242,22 +242,22 @@

    Determine antimicrobial resistance (AMR) of all bug-drug combinations in your data set where at least 30 (default) isolates are available per species. Use format() on the result to prettify it to a publicable/printable format, see Examples.

    -
    bug_drug_combinations(x, col_mo = NULL, FUN = mo_shortname, ...)
    +    
    bug_drug_combinations(x, col_mo = NULL, FUN = mo_shortname, ...)
     
     # S3 method for bug_drug_combinations
    -format(
    -  x,
    -  translate_ab = "name (ab, atc)",
    -  language = get_locale(),
    -  minimum = 30,
    -  combine_SI = TRUE,
    -  combine_IR = FALSE,
    -  add_ab_group = TRUE,
    -  remove_intrinsic_resistant = FALSE,
    -  decimal.mark = getOption("OutDec"),
    -  big.mark = ifelse(decimal.mark == ",", ".", ","),
    -  ...
    -)
    +format( + x, + translate_ab = "name (ab, atc)", + language = get_locale(), + minimum = 30, + combine_SI = TRUE, + combine_IR = FALSE, + add_ab_group = TRUE, + remove_intrinsic_resistant = FALSE, + decimal.mark = getOption("OutDec"), + big.mark = ifelse(decimal.mark == ",", ".", ","), + ... +)

    Arguments

    @@ -343,18 +343,18 @@ The lifecycle of this function is stableExamples
    # \donttest{
    -x <- bug_drug_combinations(example_isolates)
    -x
    -format(x, translate_ab = "name (atc)")
    +x <- bug_drug_combinations(example_isolates)
    +x
    +format(x, translate_ab = "name (atc)")
     
     # Use FUN to change to transformation of microorganism codes
    -bug_drug_combinations(example_isolates, 
    -                      FUN = mo_gramstain)
    +bug_drug_combinations(example_isolates, 
    +                      FUN = mo_gramstain)
                                
    -bug_drug_combinations(example_isolates,
    -                      FUN = function(x) ifelse(x == as.mo("E. coli"),
    +bug_drug_combinations(example_isolates,
    +                      FUN = function(x) ifelse(x == as.mo("E. coli"),
                                                    "E. coli",
    -                                               "Others"))
    +                                               "Others"))
     # }
     
    @@ -372,7 +372,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/catalogue_of_life.html b/docs/reference/catalogue_of_life.html index 2b6769560..73c0a3e39 100644 --- a/docs/reference/catalogue_of_life.html +++ b/docs/reference/catalogue_of_life.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -278,32 +278,32 @@ Function as.mo() to use the data for intel

    Examples

    # Get version info of included data set
    -catalogue_of_life_version()
    +catalogue_of_life_version()
     
     
     # Get a note when a species was renamed
    -mo_shortname("Chlamydophila psittaci")
    +mo_shortname("Chlamydophila psittaci")
     # Note: 'Chlamydophila psittaci' (Everett et al., 1999) was renamed back to
     #       'Chlamydia psittaci' (Page, 1968)
     # [1] "C. psittaci"
     
     # Get any property from the entire taxonomic tree for all included species
    -mo_class("E. coli")
    +mo_class("E. coli")
     # [1] "Gammaproteobacteria"
     
    -mo_family("E. coli")
    +mo_family("E. coli")
     # [1] "Enterobacteriaceae"
     
    -mo_gramstain("E. coli") # based on kingdom and phylum, see ?mo_gramstain
    +mo_gramstain("E. coli") # based on kingdom and phylum, see ?mo_gramstain
     # [1] "Gram negative"
     
    -mo_ref("E. coli")
    +mo_ref("E. coli")
     # [1] "Castellani et al., 1919"
     
     # Do not get mistaken - this package is about microorganisms
    -mo_kingdom("C. elegans")
    +mo_kingdom("C. elegans")
     # [1] "Fungi"                 # Fungi?!
    -mo_name("C. elegans")
    +mo_name("C. elegans")
     # [1] "Cladosporium elegans"  # Because a microorganism was found
     
    @@ -321,7 +321,7 @@ Function as.mo() to use the data for intel
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/catalogue_of_life_version.html b/docs/reference/catalogue_of_life_version.html index f4b2f1ae3..b30a58f4d 100644 --- a/docs/reference/catalogue_of_life_version.html +++ b/docs/reference/catalogue_of_life_version.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    This function returns information about the included data from the Catalogue of Life.

    -
    catalogue_of_life_version()
    +
    catalogue_of_life_version()

    Value

    @@ -282,7 +282,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/count.html b/docs/reference/count.html index d16407397..bfa2e1d5d 100644 --- a/docs/reference/count.html +++ b/docs/reference/count.html @@ -83,7 +83,7 @@ count_resistant() should be used to count resistant isolates, count_susceptible( AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -244,31 +244,31 @@ count_resistant() should be used to count resistant isolates, count_susceptible(

    count_resistant() should be used to count resistant isolates, count_susceptible() should be used to count susceptible isolates.

    -
    count_resistant(..., only_all_tested = FALSE)
    +    
    count_resistant(..., only_all_tested = FALSE)
     
    -count_susceptible(..., only_all_tested = FALSE)
    +count_susceptible(..., only_all_tested = FALSE)
     
    -count_R(..., only_all_tested = FALSE)
    +count_R(..., only_all_tested = FALSE)
     
    -count_IR(..., only_all_tested = FALSE)
    +count_IR(..., only_all_tested = FALSE)
     
    -count_I(..., only_all_tested = FALSE)
    +count_I(..., only_all_tested = FALSE)
     
    -count_SI(..., only_all_tested = FALSE)
    +count_SI(..., only_all_tested = FALSE)
     
    -count_S(..., only_all_tested = FALSE)
    +count_S(..., only_all_tested = FALSE)
     
    -count_all(..., only_all_tested = FALSE)
    +count_all(..., only_all_tested = FALSE)
     
    -n_rsi(..., only_all_tested = FALSE)
    +n_rsi(..., only_all_tested = FALSE)
     
    -count_df(
    -  data,
    -  translate_ab = "name",
    -  language = get_locale(),
    -  combine_SI = TRUE,
    -  combine_IR = FALSE
    -)
    +count_df( + data, + translate_ab = "name", + language = get_locale(), + combine_SI = TRUE, + combine_IR = FALSE +)

    Arguments

    @@ -355,12 +355,12 @@ A microorganism is categorised as Susceptible, Increased exposure when -------------------------------------------------------------------- -

    Please note that, in combination therapies, for only_all_tested = TRUE applies that:

        count_S()    +   count_I()    +   count_R()    = count_all()
    -  proportion_S() + proportion_I() + proportion_R() = 1
    +

    Please note that, in combination therapies, for only_all_tested = TRUE applies that:

        count_S()    +   count_I()    +   count_R()    = count_all()
    +  proportion_S() + proportion_I() + proportion_R() = 1
     
    -

    and that, in combination therapies, for only_all_tested = FALSE applies that:

        count_S()    +   count_I()    +   count_R()    >= count_all()
    -  proportion_S() + proportion_I() + proportion_R() >= 1
    +

    and that, in combination therapies, for only_all_tested = FALSE applies that:

        count_S()    +   count_I()    +   count_R()    >= count_all()
    +  proportion_S() + proportion_I() + proportion_R() >= 1
     

    Using only_all_tested has no impact when only using one antibiotic as input.

    @@ -375,64 +375,64 @@ A microorganism is categorised as Susceptible, Increased exposure when

    Examples

    # example_isolates is a data set available in the AMR package.
    -?example_isolates
    +?example_isolates
     
    -count_resistant(example_isolates$AMX)   # counts "R"
    -count_susceptible(example_isolates$AMX) # counts "S" and "I"
    -count_all(example_isolates$AMX)         # counts "S", "I" and "R"
    +count_resistant(example_isolates$AMX)   # counts "R"
    +count_susceptible(example_isolates$AMX) # counts "S" and "I"
    +count_all(example_isolates$AMX)         # counts "S", "I" and "R"
     
     # be more specific
    -count_S(example_isolates$AMX)
    -count_SI(example_isolates$AMX)
    -count_I(example_isolates$AMX)
    -count_IR(example_isolates$AMX)
    -count_R(example_isolates$AMX)
    +count_S(example_isolates$AMX)
    +count_SI(example_isolates$AMX)
    +count_I(example_isolates$AMX)
    +count_IR(example_isolates$AMX)
    +count_R(example_isolates$AMX)
     
     # Count all available isolates
    -count_all(example_isolates$AMX)
    -n_rsi(example_isolates$AMX)
    +count_all(example_isolates$AMX)
    +n_rsi(example_isolates$AMX)
     
     # n_rsi() is an alias of count_all().
     # Since it counts all available isolates, you can
     # calculate back to count e.g. susceptible isolates.
     # These results are the same:
    -count_susceptible(example_isolates$AMX)
    -susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
    +count_susceptible(example_isolates$AMX)
    +susceptibility(example_isolates$AMX) * n_rsi(example_isolates$AMX)
     
     
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    group_by(hospital_id) %>%
    -    summarise(R  = count_R(CIP),
    -              I  = count_I(CIP),
    -              S  = count_S(CIP),
    -              n1 = count_all(CIP),  # the actual total; sum of all three
    -              n2 = n_rsi(CIP),      # same - analogous to n_distinct
    -              total = n())          # NOT the number of tested isolates!
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    group_by(hospital_id) %>%
    +    summarise(R  = count_R(CIP),
    +              I  = count_I(CIP),
    +              S  = count_S(CIP),
    +              n1 = count_all(CIP),  # the actual total; sum of all three
    +              n2 = n_rsi(CIP),      # same - analogous to n_distinct
    +              total = n())          # NOT the number of tested isolates!
      
       # Count co-resistance between amoxicillin/clav acid and gentamicin,
       # so we can see that combination therapy does a lot more than mono therapy.
       # Please mind that `susceptibility()` calculates percentages right away instead.
    -  example_isolates %>% count_susceptible(AMC) # 1433
    -  example_isolates %>% count_all(AMC)         # 1879
    +  example_isolates %>% count_susceptible(AMC) # 1433
    +  example_isolates %>% count_all(AMC)         # 1879
      
    -  example_isolates %>% count_susceptible(GEN) # 1399
    -  example_isolates %>% count_all(GEN)         # 1855
    +  example_isolates %>% count_susceptible(GEN) # 1399
    +  example_isolates %>% count_all(GEN)         # 1855
      
    -  example_isolates %>% count_susceptible(AMC, GEN) # 1764
    -  example_isolates %>% count_all(AMC, GEN)         # 1936
    +  example_isolates %>% count_susceptible(AMC, GEN) # 1764
    +  example_isolates %>% count_all(AMC, GEN)         # 1936
      
       # Get number of S+I vs. R immediately of selected columns
    -  example_isolates %>%
    -    select(AMX, CIP) %>%
    -    count_df(translate = FALSE)
    +  example_isolates %>%
    +    select(AMX, CIP) %>%
    +    count_df(translate = FALSE)
      
       # It also supports grouping variables
    -  example_isolates %>%
    -    select(hospital_id, AMX, CIP) %>%
    -    group_by(hospital_id) %>%
    -    count_df(translate = FALSE)
    -}
    +  example_isolates %>%
    +    select(hospital_id, AMX, CIP) %>%
    +    group_by(hospital_id) %>%
    +    count_df(translate = FALSE)
    +}
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/eucast_rules.html b/docs/reference/eucast_rules.html index ce8dd74a4..b12b413a4 100644 --- a/docs/reference/eucast_rules.html +++ b/docs/reference/eucast_rules.html @@ -83,7 +83,7 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -244,16 +244,16 @@ To improve the interpretation of the antibiogram before EUCAST rules are applied

    To improve the interpretation of the antibiogram before EUCAST rules are applied, some non-EUCAST rules can applied at default, see Details.

    -
    eucast_rules(
    -  x,
    -  col_mo = NULL,
    -  info = interactive(),
    -  rules = getOption("AMR_eucastrules", default = c("breakpoints", "expert")),
    -  verbose = FALSE,
    -  version_breakpoints = 10,
    -  version_expertrules = 3.2,
    -  ...
    -)
    +
    eucast_rules(
    +  x,
    +  col_mo = NULL,
    +  info = interactive(),
    +  rules = getOption("AMR_eucastrules", default = c("breakpoints", "expert")),
    +  verbose = FALSE,
    +  version_breakpoints = 10,
    +  version_expertrules = 3.2,
    +  ...
    +)

    Arguments

    @@ -311,7 +311,7 @@ Leclercq et al. EUCAST expert rules in antimicrobial susceptibility test

    Note: This function does not translate MIC values to RSI values. Use as.rsi() for that.
    Note: When ampicillin (AMP, J01CA01) is not available but amoxicillin (AMX, J01CA04) is, the latter will be used for all rules where there is a dependency on ampicillin. These drugs are interchangeable when it comes to expression of antimicrobial resistance.

    -

    The file containing all EUCAST rules is located here: https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv.

    'Other' rules

    +

    The file containing all EUCAST rules is located here: https://github.com/msberends/AMR/blob/master/data-raw/eucast_rules.tsv.

    'Other' rules

    Before further processing, two non-EUCAST rules about drug combinations can be applied to improve the efficacy of the EUCAST rules, and the reliability of your data (analysis). These rules are:

      @@ -349,21 +349,21 @@ The lifecycle of this function is stableExamples
      # \donttest{
      -a <- data.frame(mo = c("Staphylococcus aureus",
      +a <- 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",       # Benzylpenicillin
      -                FOX = "S",       # Cefoxitin
      -                stringsAsFactors = FALSE)
      +                       "Pseudomonas aeruginosa"),
      +                VAN = "-",       # Vancomycin
      +                AMX = "-",       # Amoxicillin
      +                COL = "-",       # Colistin
      +                CAZ = "-",       # Ceftazidime
      +                CXM = "-",       # Cefuroxime
      +                PEN = "S",       # Benzylpenicillin
      +                FOX = "S",       # Cefoxitin
      +                stringsAsFactors = FALSE)
       
      -a
      +a
       #                       mo  VAN  AMX  COL  CAZ  CXM  PEN  FOX
       # 1  Staphylococcus aureus    -    -    -    -    -    S    S
       # 2  Enterococcus faecalis    -    -    -    -    -    S    S
      @@ -373,9 +373,9 @@ The lifecycle of this function is stable# apply EUCAST rules: some results wil be changed
      -b <- eucast_rules(a)
      +b <- eucast_rules(a)
       
      -b
      +b
       #                       mo  VAN  AMX  COL  CAZ  CXM  PEN  FOX
       # 1  Staphylococcus aureus    -    S    R    R    S    S    S
       # 2  Enterococcus faecalis    -    -    R    R    R    S    R
      @@ -386,7 +386,7 @@ The lifecycle of this function is stable# do not apply EUCAST rules, but rather get a data.frame
       # containing all details about the transformations:
      -c <- eucast_rules(a, verbose = TRUE)
      +c <- eucast_rules(a, verbose = TRUE)
       # }
       
      @@ -404,7 +404,7 @@ The lifecycle of this function is stable
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/docs/reference/example_isolates.html b/docs/reference/example_isolates.html index ec9390f16..6366add0c 100644 --- a/docs/reference/example_isolates.html +++ b/docs/reference/example_isolates.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

      A data set containing 2,000 microbial isolates with their full antibiograms. The data set reflects reality and can be used to practice AMR analysis. For examples, please read the tutorial on our website.

      -
      example_isolates
      +
      example_isolates

      Format

      @@ -286,7 +286,7 @@
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/docs/reference/example_isolates_unclean.html b/docs/reference/example_isolates_unclean.html index 62ac0c6aa..5f260e955 100644 --- a/docs/reference/example_isolates_unclean.html +++ b/docs/reference/example_isolates_unclean.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

      A data set containing 3,000 microbial isolates that are not cleaned up and consequently not ready for AMR analysis. This data set can be used for practice.

      -
      example_isolates_unclean
      +
      example_isolates_unclean

      Format

      @@ -281,7 +281,7 @@
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/docs/reference/first_isolate.html b/docs/reference/first_isolate.html index 7c41d9c8a..a8c060b95 100644 --- a/docs/reference/first_isolate.html +++ b/docs/reference/first_isolate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,43 +242,43 @@

      Determine first (weighted) isolates of all microorganisms of every patient per episode and (if needed) per specimen type.

      -
      first_isolate(
      -  x,
      -  col_date = NULL,
      -  col_patient_id = NULL,
      -  col_mo = NULL,
      -  col_testcode = NULL,
      -  col_specimen = NULL,
      -  col_icu = NULL,
      -  col_keyantibiotics = NULL,
      -  episode_days = 365,
      -  testcodes_exclude = NULL,
      -  icu_exclude = FALSE,
      -  specimen_group = NULL,
      -  type = "keyantibiotics",
      -  ignore_I = TRUE,
      -  points_threshold = 2,
      -  info = interactive(),
      -  include_unknown = FALSE,
      -  ...
      -)
      +    
      first_isolate(
      +  x,
      +  col_date = NULL,
      +  col_patient_id = NULL,
      +  col_mo = NULL,
      +  col_testcode = NULL,
      +  col_specimen = NULL,
      +  col_icu = NULL,
      +  col_keyantibiotics = NULL,
      +  episode_days = 365,
      +  testcodes_exclude = NULL,
      +  icu_exclude = FALSE,
      +  specimen_group = NULL,
      +  type = "keyantibiotics",
      +  ignore_I = TRUE,
      +  points_threshold = 2,
      +  info = interactive(),
      +  include_unknown = FALSE,
      +  ...
      +)
       
      -filter_first_isolate(
      -  x,
      -  col_date = NULL,
      -  col_patient_id = NULL,
      -  col_mo = NULL,
      -  ...
      -)
      +filter_first_isolate(
      +  x,
      +  col_date = NULL,
      +  col_patient_id = NULL,
      +  col_mo = NULL,
      +  ...
      +)
       
      -filter_first_weighted_isolate(
      -  x,
      -  col_date = NULL,
      -  col_patient_id = NULL,
      -  col_mo = NULL,
      -  col_keyantibiotics = NULL,
      -  ...
      -)
      +filter_first_weighted_isolate( + x, + col_date = NULL, + col_patient_id = NULL, + col_mo = NULL, + col_keyantibiotics = NULL, + ... +)

      Arguments

    @@ -369,16 +369,16 @@

    WHY THIS IS SO IMPORTANT
    To conduct an analysis of antimicrobial resistance, you should only include the first isolate of every patient per episode (ref). If you would not do this, you could easily get an overestimate or underestimate of the resistance of an antibiotic. Imagine that a patient was admitted with an MRSA and that it was found in 5 different blood cultures the following week. The resistance percentage of oxacillin of all S. aureus isolates would be overestimated, because you included this MRSA more than once. It would be selection bias.

    All isolates with a microbial ID of NA will be excluded as first isolate.

    -

    The functions filter_first_isolate() and filter_first_weighted_isolate() are helper functions to quickly filter on first isolates. The function filter_first_isolate() is essentially equal to either:

      x[first_isolate(x, ...), ]
    -  x %>% filter(first_isolate(x, ...))
    +

    The functions filter_first_isolate() and filter_first_weighted_isolate() are helper functions to quickly filter on first isolates. The function filter_first_isolate() is essentially equal to either:

      x[first_isolate(x, ...), ]
    +  x %>% filter(first_isolate(x, ...))
     
    -

    The function filter_first_weighted_isolate() is essentially equal to:

      x %>%
    -    mutate(keyab = key_antibiotics(.)) %>%
    -    mutate(only_weighted_firsts = first_isolate(x,
    -                                                col_keyantibiotics = "keyab", ...)) %>%
    -    filter(only_weighted_firsts == TRUE) %>%
    -    select(-only_weighted_firsts, -keyab)
    +

    The function filter_first_weighted_isolate() is essentially equal to:

      x %>%
    +    mutate(keyab = key_antibiotics(.)) %>%
    +    mutate(only_weighted_firsts = first_isolate(x,
    +                                                col_keyantibiotics = "keyab", ...)) %>%
    +    filter(only_weighted_firsts == TRUE) %>%
    +    select(-only_weighted_firsts, -keyab)
     

    Key antibiotics

    @@ -413,39 +413,39 @@ The lifecycle of this function is stable# See ?example_isolates. # basic filtering on first isolates -example_isolates[first_isolate(example_isolates), ] +example_isolates[first_isolate(example_isolates), ] # \donttest{ -if (require("dplyr")) { +if (require("dplyr")) { # Filter on first isolates: - example_isolates %>% - mutate(first_isolate = first_isolate(.)) %>% - filter(first_isolate == TRUE) + example_isolates %>% + mutate(first_isolate = first_isolate(.)) %>% + filter(first_isolate == TRUE) # Short-hand versions: - example_isolates %>% - filter_first_isolate() + example_isolates %>% + filter_first_isolate() - example_isolates %>% - filter_first_weighted_isolate() + example_isolates %>% + filter_first_weighted_isolate() # Now let's see if first isolates matter: - A <- example_isolates %>% - group_by(hospital_id) %>% - summarise(count = n_rsi(GEN), # gentamicin availability - resistance = resistance(GEN)) # gentamicin resistance + A <- example_isolates %>% + group_by(hospital_id) %>% + summarise(count = n_rsi(GEN), # gentamicin availability + resistance = resistance(GEN)) # gentamicin resistance - B <- example_isolates %>% - filter_first_weighted_isolate() %>% # the 1st isolate filter - group_by(hospital_id) %>% - summarise(count = n_rsi(GEN), # gentamicin availability - resistance = resistance(GEN)) # gentamicin resistance + B <- example_isolates %>% + filter_first_weighted_isolate() %>% # the 1st isolate filter + group_by(hospital_id) %>% + summarise(count = n_rsi(GEN), # gentamicin availability + resistance = resistance(GEN)) # gentamicin resistance # Have a look at A and B. # B is more reliable because every isolate is counted only once. # Gentamicin resistance in hospital D appears to be 3.7% higher than # when you (erroneously) would have used all isolates for analysis. -} +} # }
    @@ -463,7 +463,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/g.test.html b/docs/reference/g.test.html index e122148f2..c8a394737 100644 --- a/docs/reference/g.test.html +++ b/docs/reference/g.test.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    g.test() performs chi-squared contingency table tests and goodness-of-fit tests, just like chisq.test() but is more reliable (1). A G-test can be used to see whether the number of observations in each category fits a theoretical expectation (called a G-test of goodness-of-fit), or to see whether the proportions of one variable are different for different values of the other variable (called a G-test of independence).

    -
    g.test(x, y = NULL, p = rep(1/length(x), length(x)), rescale.p = FALSE)
    +
    g.test(x, y = NULL, p = rep(1/length(x), length(x)), rescale.p = FALSE)

    Arguments

    @@ -305,14 +305,14 @@

    If x is a matrix with at least two rows and columns, it is taken as a two-dimensional contingency table: the entries of x must be non-negative integers. Otherwise, x and y must be vectors or factors of the same length; cases with missing values are removed, the objects are coerced to factors, and the contingency table is computed from these. Then Pearson's chi-squared test is performed of the null hypothesis that the joint distribution of the cell counts in a 2-dimensional contingency table is the product of the row and column marginals.

    The p-value is computed from the asymptotic chi-squared distribution of the test statistic.

    In the contingency table case simulation is done by random sampling from the set of all contingency tables with given marginals, and works only if the marginals are strictly positive. Note that this is not the usual sampling situation assumed for a chi-squared test (like the G-test) but rather that for Fisher's exact test.

    -

    In the goodness-of-fit case simulation is done by random sampling from the discrete distribution specified by p, each sample being of size n = sum(x). This simulation is done in R and may be slow.

    G-test of goodness-of-fit (likelihood ratio test)

    +

    In the goodness-of-fit case simulation is done by random sampling from the discrete distribution specified by p, each sample being of size n = sum(x). This simulation is done in R and may be slow.

    G-test of goodness-of-fit (likelihood ratio test)

    Use the G-test of goodness-of-fit when you have one nominal variable with two or more values (such as male and female, or red, pink and white flowers). You compare the observed counts of numbers of observations in each category with the expected counts, which you calculate using some kind of theoretical expectation (such as a 1:1 sex ratio or a 1:2:1 ratio in a genetic cross).

    If the expected number of observations in any category is too small, the G-test may give inaccurate results, and you should use an exact test instead (fisher.test()).

    The G-test of goodness-of-fit is an alternative to the chi-square test of goodness-of-fit (chisq.test()); each of these tests has some advantages and some disadvantages, and the results of the two tests are usually very similar.

    -

    G-test of independence

    +

    G-test of independence

    Use the G-test of independence when you have two nominal variables, each with two or more possible values. You want to know whether the proportions for one variable are different among values of the other variable.

    @@ -320,13 +320,13 @@

    Fisher's exact test (fisher.test()) is an exact test, where the G-test is still only an approximation. For any 2x2 table, Fisher's Exact test may be slower but will still run in seconds, even if the sum of your observations is multiple millions.

    The G-test of independence is an alternative to the chi-square test of independence (chisq.test()), and they will give approximately the same results.

    -

    How the test works

    +

    How the test works

    Unlike the exact test of goodness-of-fit (fisher.test()), the G-test does not directly calculate the probability of obtaining the observed results or something more extreme. Instead, like almost all statistical tests, the G-test has an intermediate step; it uses the data to calculate a test statistic that measures how far the observed data are from the null expectation. You then use a mathematical relationship, in this case the chi-square distribution, to estimate the probability of obtaining that value of the test statistic.

    The G-test uses the log of the ratio of two likelihoods as the test statistic, which is why it is also called a likelihood ratio test or log-likelihood ratio test. The formula to calculate a G-statistic is:

    \(G = 2 * sum(x * log(x / E))\)

    -

    where E are the expected values. Since this is chi-square distributed, the p value can be calculated in R with:

    p <- stats::pchisq(G, df, lower.tail = FALSE)
    +

    where E are the expected values. Since this is chi-square distributed, the p value can be calculated in R with:

    p <- stats::pchisq(G, df, lower.tail = FALSE)
     

    where df are the degrees of freedom.

    @@ -364,8 +364,8 @@ The lifecycle of this function is questioni # by a single gene with two co-dominant alleles, you would expect a 1:2:1 # ratio. -x <- c(772, 1611, 737) -G <- g.test(x, p = c(1, 2, 1) / 4) +x <- c(772, 1611, 737) +G <- g.test(x, p = c(1, 2, 1) / 4) # G$p.value = 0.12574. # There is no significant difference from a 1:2:1 ratio. @@ -380,8 +380,8 @@ The lifecycle of this function is questioni # keep the number of right and left-billed birds at a 1:1 ratio. Groth (1992) # observed 1752 right-billed and 1895 left-billed crossbills. -x <- c(1752, 1895) -g.test(x) +x <- c(1752, 1895) +g.test(x) # p = 0.01787343 # There is a significant difference from a 1:1 ratio. @@ -403,7 +403,7 @@ The lifecycle of this function is questioni
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/ggplot_rsi.html b/docs/reference/ggplot_rsi.html index 35f797477..0c624dac3 100644 --- a/docs/reference/ggplot_rsi.html +++ b/docs/reference/ggplot_rsi.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,67 +242,67 @@

    Use these functions to create bar plots for antimicrobial resistance analysis. All functions rely on ggplot2 functions.

    -
    ggplot_rsi(
    -  data,
    -  position = NULL,
    -  x = "antibiotic",
    -  fill = "interpretation",
    -  facet = NULL,
    -  breaks = seq(0, 1, 0.1),
    -  limits = NULL,
    -  translate_ab = "name",
    -  combine_SI = TRUE,
    -  combine_IR = FALSE,
    -  minimum = 30,
    -  language = get_locale(),
    -  nrow = NULL,
    -  colours = c(S = "#61a8ff", SI = "#61a8ff", I = "#61f7ff", IR = "#ff6961", R =
    -    "#ff6961"),
    -  datalabels = TRUE,
    -  datalabels.size = 2.5,
    -  datalabels.colour = "gray15",
    -  title = NULL,
    -  subtitle = NULL,
    -  caption = NULL,
    -  x.title = "Antimicrobial",
    -  y.title = "Proportion",
    -  ...
    -)
    +    
    ggplot_rsi(
    +  data,
    +  position = NULL,
    +  x = "antibiotic",
    +  fill = "interpretation",
    +  facet = NULL,
    +  breaks = seq(0, 1, 0.1),
    +  limits = NULL,
    +  translate_ab = "name",
    +  combine_SI = TRUE,
    +  combine_IR = FALSE,
    +  minimum = 30,
    +  language = get_locale(),
    +  nrow = NULL,
    +  colours = c(S = "#61a8ff", SI = "#61a8ff", I = "#61f7ff", IR = "#ff6961", R =
    +    "#ff6961"),
    +  datalabels = TRUE,
    +  datalabels.size = 2.5,
    +  datalabels.colour = "gray15",
    +  title = NULL,
    +  subtitle = NULL,
    +  caption = NULL,
    +  x.title = "Antimicrobial",
    +  y.title = "Proportion",
    +  ...
    +)
     
    -geom_rsi(
    -  position = NULL,
    -  x = c("antibiotic", "interpretation"),
    -  fill = "interpretation",
    -  translate_ab = "name",
    -  minimum = 30,
    -  language = get_locale(),
    -  combine_SI = TRUE,
    -  combine_IR = FALSE,
    -  ...
    -)
    +geom_rsi(
    +  position = NULL,
    +  x = c("antibiotic", "interpretation"),
    +  fill = "interpretation",
    +  translate_ab = "name",
    +  minimum = 30,
    +  language = get_locale(),
    +  combine_SI = TRUE,
    +  combine_IR = FALSE,
    +  ...
    +)
     
    -facet_rsi(facet = c("interpretation", "antibiotic"), nrow = NULL)
    +facet_rsi(facet = c("interpretation", "antibiotic"), nrow = NULL)
     
    -scale_y_percent(breaks = seq(0, 1, 0.1), limits = NULL)
    +scale_y_percent(breaks = seq(0, 1, 0.1), limits = NULL)
     
    -scale_rsi_colours(
    -  colours = c(S = "#61a8ff", SI = "#61a8ff", I = "#61f7ff", IR = "#ff6961", R =
    -    "#ff6961")
    -)
    +scale_rsi_colours(
    +  colours = c(S = "#61a8ff", SI = "#61a8ff", I = "#61f7ff", IR = "#ff6961", R =
    +    "#ff6961")
    +)
     
    -theme_rsi()
    +theme_rsi()
     
    -labels_rsi_count(
    -  position = NULL,
    -  x = "antibiotic",
    -  translate_ab = "name",
    -  minimum = 30,
    -  language = get_locale(),
    -  combine_SI = TRUE,
    -  combine_IR = FALSE,
    -  datalabels.size = 3,
    -  datalabels.colour = "gray15"
    -)
    +labels_rsi_count( + position = NULL, + x = "antibiotic", + translate_ab = "name", + minimum = 30, + language = get_locale(), + combine_SI = TRUE, + combine_IR = FALSE, + datalabels.size = 3, + datalabels.colour = "gray15" +)

    Arguments

    @@ -403,7 +403,7 @@

    Details

    -

    At default, the names of antibiotics will be shown on the plots using ab_name(). This can be set with the translate_ab parameter. See count_df().

    The functions

    +

    At default, the names of antibiotics will be shown on the plots using ab_name(). This can be set with the translate_ab parameter. See count_df().

    The functions

    geom_rsi() will take any variable from the data that has an rsi class (created with as.rsi()) using rsi_df() and will plot bars with the percentage R, I and S. The default behaviour is to have the bars stacked and to have the different antibiotics on the x axis.

    @@ -427,80 +427,80 @@ The lifecycle of this function is maturing<

    On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    if (require("ggplot2") & require("dplyr")) {
    +    
    if (require("ggplot2") & require("dplyr")) {
      
       # get antimicrobial results for drugs against a UTI:
    -  ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) +
    -    geom_rsi()
    +  ggplot(example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)) +
    +    geom_rsi()
      
       # prettify the plot using some additional functions:
    -  df <- example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)
    -  ggplot(df) +
    -    geom_rsi() +
    -    scale_y_percent() +
    -    scale_rsi_colours() +
    -    labels_rsi_count() +
    -    theme_rsi()
    +  df <- example_isolates %>% select(AMX, NIT, FOS, TMP, CIP)
    +  ggplot(df) +
    +    geom_rsi() +
    +    scale_y_percent() +
    +    scale_rsi_colours() +
    +    labels_rsi_count() +
    +    theme_rsi()
      
       # or better yet, simplify this using the wrapper function - a single command:
    -  example_isolates %>%
    -    select(AMX, NIT, FOS, TMP, CIP) %>%
    -    ggplot_rsi()
    +  example_isolates %>%
    +    select(AMX, NIT, FOS, TMP, CIP) %>%
    +    ggplot_rsi()
      
       # get only proportions and no counts:
    -  example_isolates %>%
    -    select(AMX, NIT, FOS, TMP, CIP) %>%
    -    ggplot_rsi(datalabels = FALSE)
    +  example_isolates %>%
    +    select(AMX, NIT, FOS, TMP, CIP) %>%
    +    ggplot_rsi(datalabels = FALSE)
      
       # add other ggplot2 parameters as you like:
    -  example_isolates %>%
    -    select(AMX, NIT, FOS, TMP, CIP) %>%
    -    ggplot_rsi(width = 0.5,
    -               colour = "black",
    -               size = 1,
    -               linetype = 2,
    -               alpha = 0.25)
    +  example_isolates %>%
    +    select(AMX, NIT, FOS, TMP, CIP) %>%
    +    ggplot_rsi(width = 0.5,
    +               colour = "black",
    +               size = 1,
    +               linetype = 2,
    +               alpha = 0.25)
      
    -  example_isolates %>%
    -    select(AMX) %>%
    -    ggplot_rsi(colours = c(SI = "yellow"))
    +  example_isolates %>%
    +    select(AMX) %>%
    +    ggplot_rsi(colours = c(SI = "yellow"))
       
    -}
    +}
       
     # \donttest{
     
     # resistance of ciprofloxacine per age group
    -example_isolates %>%
    -  mutate(first_isolate = first_isolate(.)) %>%
    -  filter(first_isolate == TRUE,
    -         mo == as.mo("E. coli")) %>%
    +example_isolates %>%
    +  mutate(first_isolate = first_isolate(.)) %>%
    +  filter(first_isolate == TRUE,
    +         mo == as.mo("E. coli")) %>%
       # `age_groups` is also a function of this AMR package:
    -  group_by(age_group = age_groups(age)) %>%
    -  select(age_group,
    -         CIP) %>%
    -  ggplot_rsi(x = "age_group")
    +  group_by(age_group = age_groups(age)) %>%
    +  select(age_group,
    +         CIP) %>%
    +  ggplot_rsi(x = "age_group")
       
     # for colourblind mode, use divergent colours from the viridis package:
    -example_isolates %>%
    -  select(AMX, NIT, FOS, TMP, CIP) %>%
    -  ggplot_rsi() + 
    -  scale_fill_viridis_d()
    +example_isolates %>%
    +  select(AMX, NIT, FOS, TMP, CIP) %>%
    +  ggplot_rsi() + 
    +  scale_fill_viridis_d()
     # a shorter version which also adjusts data label colours:
    -example_isolates %>%
    -  select(AMX, NIT, FOS, TMP, CIP) %>%
    -  ggplot_rsi(colours = FALSE)
    +example_isolates %>%
    +  select(AMX, NIT, FOS, TMP, CIP) %>%
    +  ggplot_rsi(colours = FALSE)
     
     
     # it also supports groups (don't forget to use the group var on `x` or `facet`):
    -example_isolates %>%
    -  select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
    -  group_by(hospital_id) %>%
    -  ggplot_rsi(x = "hospital_id",
    -             facet = "antibiotic",
    -             nrow = 1,
    -             title = "AMR of Anti-UTI Drugs Per Hospital",
    -             x.title = "Hospital",
    -             datalabels = FALSE)
    +example_isolates %>%
    +  select(hospital_id, AMX, NIT, FOS, TMP, CIP) %>%
    +  group_by(hospital_id) %>%
    +  ggplot_rsi(x = "hospital_id",
    +             facet = "antibiotic",
    +             nrow = 1,
    +             title = "AMR of Anti-UTI Drugs Per Hospital",
    +             x.title = "Hospital",
    +             datalabels = FALSE)
     # }
     
    @@ -518,7 +518,7 @@ The lifecycle of this function is maturing<
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/guess_ab_col.html b/docs/reference/guess_ab_col.html index 139ccb8cb..5e494859f 100644 --- a/docs/reference/guess_ab_col.html +++ b/docs/reference/guess_ab_col.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    This tries to find a column name in a data set based on information from the antibiotics data set. Also supports WHONET abbreviations.

    -
    guess_ab_col(x = NULL, search_string = NULL, verbose = FALSE)
    +
    guess_ab_col(x = NULL, search_string = NULL, verbose = FALSE)

    Arguments

    @@ -281,32 +281,32 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    df <- data.frame(amox = "S",
    -                 tetr = "R")
    +    
    df <- data.frame(amox = "S",
    +                 tetr = "R")
     
    -guess_ab_col(df, "amoxicillin")
    +guess_ab_col(df, "amoxicillin")
     # [1] "amox"
    -guess_ab_col(df, "J01AA07") # ATC code of tetracycline
    +guess_ab_col(df, "J01AA07") # ATC code of tetracycline
     # [1] "tetr"
     
    -guess_ab_col(df, "J01AA07", verbose = TRUE)
    +guess_ab_col(df, "J01AA07", verbose = TRUE)
     # NOTE: Using column `tetr` as input for `J01AA07` (tetracycline).
     # [1] "tetr"
     
     # WHONET codes
    -df <- data.frame(AMP_ND10 = "R",
    -                 AMC_ED20 = "S")
    -guess_ab_col(df, "ampicillin")
    +df <- data.frame(AMP_ND10 = "R",
    +                 AMC_ED20 = "S")
    +guess_ab_col(df, "ampicillin")
     # [1] "AMP_ND10"
    -guess_ab_col(df, "J01CR02")
    +guess_ab_col(df, "J01CR02")
     # [1] "AMC_ED20"
    -guess_ab_col(df, as.ab("augmentin"))
    +guess_ab_col(df, as.ab("augmentin"))
     # [1] "AMC_ED20"
     
     # Longer names take precendence:
    -df <- data.frame(AMP_ED2 = "S",
    -                 AMP_ED20 = "S")
    -guess_ab_col(df, "ampicillin")
    +df <- data.frame(AMP_ED2 = "S",
    +                 AMP_ED20 = "S")
    +guess_ab_col(df, "ampicillin")
     # [1] "AMP_ED20"
     
    @@ -324,7 +324,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/index.html b/docs/reference/index.html index d92dea965..6a90f7cc7 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -652,7 +652,7 @@
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/intrinsic_resistant.html b/docs/reference/intrinsic_resistant.html index 5734769c1..cc1062c07 100644 --- a/docs/reference/intrinsic_resistant.html +++ b/docs/reference/intrinsic_resistant.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    Data set containing defined intrinsic resistance by EUCAST of all bug-drug combinations.

    -
    intrinsic_resistant
    +
    intrinsic_resistant

    Format

    @@ -268,12 +268,12 @@

    On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    if (require("dplyr")) {
    -  intrinsic_resistant %>%
    -    filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>% 
    -    pull(microorganism)
    +    
    if (require("dplyr")) {
    +  intrinsic_resistant %>%
    +    filter(antibiotic == "Vancomycin", microorganism %like% "Enterococcus") %>% 
    +    pull(microorganism)
       # [1] "Enterococcus casseliflavus" "Enterococcus gallinarum"
    -}
    +}
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/join.html b/docs/reference/join.html index c7e82e2cf..153730664 100644 --- a/docs/reference/join.html +++ b/docs/reference/join.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,17 +242,17 @@

    Join the data set microorganisms easily to an existing table or character vector.

    -
    inner_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
    +    
    inner_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
     
    -left_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
    +left_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
     
    -right_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
    +right_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
     
    -full_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
    +full_join_microorganisms(x, by = NULL, suffix = c("2", ""), ...)
     
    -semi_join_microorganisms(x, by = NULL, ...)
    +semi_join_microorganisms(x, by = NULL, ...)
     
    -anti_join_microorganisms(x, by = NULL, ...)
    +anti_join_microorganisms(x, by = NULL, ...)

    Arguments

    @@ -293,25 +293,25 @@ The lifecycle of this function is stableOn our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    left_join_microorganisms(as.mo("K. pneumoniae"))
    -left_join_microorganisms("B_KLBSL_PNE")
    +    
    left_join_microorganisms(as.mo("K. pneumoniae"))
    +left_join_microorganisms("B_KLBSL_PNE")
     
     # \donttest{
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    left_join_microorganisms() %>% 
    -    colnames()
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    left_join_microorganisms() %>% 
    +    colnames()
      
    -  df <- data.frame(date = seq(from = as.Date("2018-01-01"),
    -                              to = as.Date("2018-01-07"),
    -                              by = 1),
    -                   bacteria = as.mo(c("S. aureus", "MRSA", "MSSA", "STAAUR",
    -                                      "E. coli", "E. coli", "E. coli")),
    -                   stringsAsFactors = FALSE)
    -  colnames(df)
    -  df_joined <- left_join_microorganisms(df, "bacteria")
    -  colnames(df_joined)
    -}
    +  df <- data.frame(date = seq(from = as.Date("2018-01-01"),
    +                              to = as.Date("2018-01-07"),
    +                              by = 1),
    +                   bacteria = as.mo(c("S. aureus", "MRSA", "MSSA", "STAAUR",
    +                                      "E. coli", "E. coli", "E. coli")),
    +                   stringsAsFactors = FALSE)
    +  colnames(df)
    +  df_joined <- left_join_microorganisms(df, "bacteria")
    +  colnames(df_joined)
    +}
     # }
     
    @@ -329,7 +329,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/key_antibiotics.html b/docs/reference/key_antibiotics.html index 7f9497499..5223b3bf0 100644 --- a/docs/reference/key_antibiotics.html +++ b/docs/reference/key_antibiotics.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,39 +242,39 @@

    These function can be used to determine first isolates (see first_isolate()). Using key antibiotics to determine first isolates is more reliable than without key antibiotics. These selected isolates will then be called first weighted isolates.

    -
    key_antibiotics(
    -  x,
    -  col_mo = NULL,
    -  universal_1 = guess_ab_col(x, "amoxicillin"),
    -  universal_2 = guess_ab_col(x, "amoxicillin/clavulanic acid"),
    -  universal_3 = guess_ab_col(x, "cefuroxime"),
    -  universal_4 = guess_ab_col(x, "piperacillin/tazobactam"),
    -  universal_5 = guess_ab_col(x, "ciprofloxacin"),
    -  universal_6 = guess_ab_col(x, "trimethoprim/sulfamethoxazole"),
    -  GramPos_1 = guess_ab_col(x, "vancomycin"),
    -  GramPos_2 = guess_ab_col(x, "teicoplanin"),
    -  GramPos_3 = guess_ab_col(x, "tetracycline"),
    -  GramPos_4 = guess_ab_col(x, "erythromycin"),
    -  GramPos_5 = guess_ab_col(x, "oxacillin"),
    -  GramPos_6 = guess_ab_col(x, "rifampin"),
    -  GramNeg_1 = guess_ab_col(x, "gentamicin"),
    -  GramNeg_2 = guess_ab_col(x, "tobramycin"),
    -  GramNeg_3 = guess_ab_col(x, "colistin"),
    -  GramNeg_4 = guess_ab_col(x, "cefotaxime"),
    -  GramNeg_5 = guess_ab_col(x, "ceftazidime"),
    -  GramNeg_6 = guess_ab_col(x, "meropenem"),
    -  warnings = TRUE,
    -  ...
    -)
    +    
    key_antibiotics(
    +  x,
    +  col_mo = NULL,
    +  universal_1 = guess_ab_col(x, "amoxicillin"),
    +  universal_2 = guess_ab_col(x, "amoxicillin/clavulanic acid"),
    +  universal_3 = guess_ab_col(x, "cefuroxime"),
    +  universal_4 = guess_ab_col(x, "piperacillin/tazobactam"),
    +  universal_5 = guess_ab_col(x, "ciprofloxacin"),
    +  universal_6 = guess_ab_col(x, "trimethoprim/sulfamethoxazole"),
    +  GramPos_1 = guess_ab_col(x, "vancomycin"),
    +  GramPos_2 = guess_ab_col(x, "teicoplanin"),
    +  GramPos_3 = guess_ab_col(x, "tetracycline"),
    +  GramPos_4 = guess_ab_col(x, "erythromycin"),
    +  GramPos_5 = guess_ab_col(x, "oxacillin"),
    +  GramPos_6 = guess_ab_col(x, "rifampin"),
    +  GramNeg_1 = guess_ab_col(x, "gentamicin"),
    +  GramNeg_2 = guess_ab_col(x, "tobramycin"),
    +  GramNeg_3 = guess_ab_col(x, "colistin"),
    +  GramNeg_4 = guess_ab_col(x, "cefotaxime"),
    +  GramNeg_5 = guess_ab_col(x, "ceftazidime"),
    +  GramNeg_6 = guess_ab_col(x, "meropenem"),
    +  warnings = TRUE,
    +  ...
    +)
     
    -key_antibiotics_equal(
    -  y,
    -  z,
    -  type = c("keyantibiotics", "points"),
    -  ignore_I = TRUE,
    -  points_threshold = 2,
    -  info = FALSE
    -)
    +key_antibiotics_equal( + y, + z, + type = c("keyantibiotics", "points"), + ignore_I = TRUE, + points_threshold = 2, + info = FALSE +)

    Arguments

    @@ -396,32 +396,32 @@ The lifecycle of this function is stable# See ?example_isolates. # output of the `key_antibiotics` function could be like this: -strainA <- "SSSRR.S.R..S" -strainB <- "SSSIRSSSRSSS" +strainA <- "SSSRR.S.R..S" +strainB <- "SSSIRSSSRSSS" # can those strings can be compared with: -key_antibiotics_equal(strainA, strainB) +key_antibiotics_equal(strainA, strainB) # TRUE, because I is ignored (as well as missing values) -key_antibiotics_equal(strainA, strainB, ignore_I = FALSE) +key_antibiotics_equal(strainA, strainB, ignore_I = FALSE) # FALSE, because I is not ignored and so the 4th value differs # \donttest{ -if (require("dplyr")) { +if (require("dplyr")) { # set key antibiotics to a new variable - my_patients <- example_isolates %>% - mutate(keyab = key_antibiotics(.)) %>% - mutate( + my_patients <- example_isolates %>% + mutate(keyab = key_antibiotics(.)) %>% + mutate( # now calculate first isolates - first_regular = first_isolate(., col_keyantibiotics = FALSE), + first_regular = first_isolate(., col_keyantibiotics = FALSE), # and first WEIGHTED isolates - first_weighted = first_isolate(., col_keyantibiotics = "keyab") - ) + first_weighted = first_isolate(., col_keyantibiotics = "keyab") + ) # Check the difference, in this data set it results in 7% more isolates: - sum(my_patients$first_regular, na.rm = TRUE) - sum(my_patients$first_weighted, na.rm = TRUE) -} + sum(my_patients$first_regular, na.rm = TRUE) + sum(my_patients$first_weighted, na.rm = TRUE) +} # } @@ -439,7 +439,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/kurtosis.html b/docs/reference/kurtosis.html index c1bdc5a45..6bd993392 100644 --- a/docs/reference/kurtosis.html +++ b/docs/reference/kurtosis.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,16 +242,16 @@

    Kurtosis is a measure of the "tailedness" of the probability distribution of a real-valued random variable. A normal distribution has a kurtosis of 3 and a excess kurtosis of 0.

    -
    kurtosis(x, na.rm = FALSE, excess = FALSE)
    +    
    kurtosis(x, na.rm = FALSE, excess = FALSE)
     
     # S3 method for default
    -kurtosis(x, na.rm = FALSE, excess = FALSE)
    +kurtosis(x, na.rm = FALSE, excess = FALSE)
     
     # S3 method for matrix
    -kurtosis(x, na.rm = FALSE, excess = FALSE)
    +kurtosis(x, na.rm = FALSE, excess = FALSE)
     
     # S3 method for data.frame
    -kurtosis(x, na.rm = FALSE, excess = FALSE)
    +kurtosis(x, na.rm = FALSE, excess = FALSE)

    Arguments

    @@ -301,7 +301,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/like.html b/docs/reference/like.html index aa8ea3120..9459a30fb 100644 --- a/docs/reference/like.html +++ b/docs/reference/like.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,11 +242,11 @@

    Convenient wrapper around grep() to match a pattern: x %like% pattern. It always returns a logical vector and is always case-insensitive (use x %like_case% pattern for case-sensitive matching). Also, pattern can be as long as x to compare items of each index in both vectors, or they both can have the same length to iterate over all cases.

    -
    like(x, pattern, ignore.case = TRUE)
    +    
    like(x, pattern, ignore.case = TRUE)
     
    -x %like% pattern
    +x %like% pattern
     
    -x %like_case% pattern
    +x %like_case% pattern

    Arguments

    @@ -299,25 +299,25 @@ The lifecycle of this function is stableExamples
    # simple test
    -a <- "This is a test"
    -b <- "TEST"
    -a %like% b
    +a <- "This is a test"
    +b <- "TEST"
    +a %like% b
     #> TRUE
    -b %like% a
    +b %like% a
     #> FALSE
     
     # also supports multiple patterns, length must be equal to x
    -a <- c("Test case", "Something different", "Yet another thing")
    -b <- c(     "case",           "diff",      "yet")
    -a %like% b
    +a <- c("Test case", "Something different", "Yet another thing")
    +b <- c(     "case",           "diff",      "yet")
    +a %like% b
     #> TRUE TRUE TRUE
     
     # get isolates whose name start with 'Ent' or 'ent'
     # \donttest{
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    filter(mo_name(mo) %like% "^ent")
    -}
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    filter(mo_name(mo) %like% "^ent")
    +}
     # }
     
    @@ -335,7 +335,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/mdro.html b/docs/reference/mdro.html index 901915431..f9e9f15c7 100644 --- a/docs/reference/mdro.html +++ b/docs/reference/mdro.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,26 +242,26 @@

    Determine which isolates are multidrug-resistant organisms (MDRO) according to international and national guidelines.

    -
    mdro(
    -  x,
    -  guideline = "CMI2012",
    -  col_mo = NULL,
    -  info = interactive(),
    -  pct_required_classes = 0.5,
    -  combine_SI = TRUE,
    -  verbose = FALSE,
    -  ...
    -)
    +    
    mdro(
    +  x,
    +  guideline = "CMI2012",
    +  col_mo = NULL,
    +  info = interactive(),
    +  pct_required_classes = 0.5,
    +  combine_SI = TRUE,
    +  verbose = FALSE,
    +  ...
    +)
     
    -brmo(x, guideline = "BRMO", ...)
    +brmo(x, guideline = "BRMO", ...)
     
    -mrgn(x, guideline = "MRGN", ...)
    +mrgn(x, guideline = "MRGN", ...)
     
    -mdr_tb(x, guideline = "TB", ...)
    +mdr_tb(x, guideline = "TB", ...)
     
    -mdr_cmi2012(x, guideline = "CMI2012", ...)
    +mdr_cmi2012(x, guideline = "CMI2012", ...)
     
    -eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)
    +eucast_exceptional_phenotypes(x, guideline = "EUCAST", ...)

    Arguments

    @@ -372,19 +372,19 @@ A microorganism is categorised as Susceptible, Increased exposure when

    On our website https://msberends.github.io/AMR/ you can find a comprehensive tutorial about how to conduct AMR analysis, the complete documentation of all functions and an example analysis using WHONET data. As we would like to better understand the backgrounds and needs of our users, please participate in our survey!

    Examples

    -
    mdro(example_isolates, guideline = "EUCAST")
    +    
    mdro(example_isolates, guideline = "EUCAST")
     
     # \donttest{
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    mdro() %>%
    -    table()
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    mdro() %>%
    +    table()
       
    -  example_isolates %>%
    -    mutate(EUCAST = eucast_exceptional_phenotypes(.),
    -           BRMO = brmo(.),
    -           MRGN = mrgn(.))
    -}
    +  example_isolates %>%
    +    mutate(EUCAST = eucast_exceptional_phenotypes(.),
    +           BRMO = brmo(.),
    +           MRGN = mrgn(.))
    +}
     # }
     
    @@ -402,7 +402,7 @@ A microorganism is categorised as Susceptible, Increased exposure when
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/microorganisms.codes.html b/docs/reference/microorganisms.codes.html index c84f3a3cd..1a58e88d3 100644 --- a/docs/reference/microorganisms.codes.html +++ b/docs/reference/microorganisms.codes.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    A data set containing commonly used codes for microorganisms, from laboratory systems and WHONET. Define your own with set_mo_source(). They will all be searched when using as.mo() and consequently all the mo_* functions.

    -
    microorganisms.codes
    +
    microorganisms.codes

    Format

    @@ -288,7 +288,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/microorganisms.html b/docs/reference/microorganisms.html index 24e0f879f..9b38b0e9e 100644 --- a/docs/reference/microorganisms.html +++ b/docs/reference/microorganisms.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    A data set containing the microbial taxonomy of six kingdoms from the Catalogue of Life. MO codes can be looked up using as.mo().

    -
    microorganisms
    +
    microorganisms

    Format

    @@ -276,7 +276,7 @@
  • 6 families under the Enterobacterales order, according to Adeolu et al. (2016, PMID 27620848), that are not (yet) in the Catalogue of Life

  • 7,411 species from the DSMZ (Deutsche Sammlung von Mikroorganismen und Zellkulturen) since the DSMZ contain the latest taxonomic information based on recent publications

  • -

    Direct download

    +

    Direct download

    This data set is available as 'flat file' for use even without R - you can find the file here:

      @@ -331,7 +331,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/docs/reference/microorganisms.old.html b/docs/reference/microorganisms.old.html index 4204c57dd..ee8b01aa4 100644 --- a/docs/reference/microorganisms.old.html +++ b/docs/reference/microorganisms.old.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

      A data set containing old (previously valid or accepted) taxonomic names according to the Catalogue of Life. This data set is used internally by as.mo().

      -
      microorganisms.old
      +
      microorganisms.old

      Format

      @@ -294,7 +294,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/docs/reference/mo_matching_score.html b/docs/reference/mo_matching_score.html index afaf3a0dd..c42a9d6b9 100644 --- a/docs/reference/mo_matching_score.html +++ b/docs/reference/mo_matching_score.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

      This helper function is used by as.mo() to determine the most probable match of taxonomic records, based on user input.

      -
      mo_matching_score(x, n)
      +
      mo_matching_score(x, n)

      Arguments

    @@ -276,11 +276,11 @@

    All matches are sorted descending on their matching score and for all user input values, the top match will be returned. This will lead to the effect that e.g., "E. coli" will return the microbial ID of Escherichia coli (\(m = 0.688\), a highly prevalent microorganism found in humans) and not Entamoeba coli (\(m = 0.079\), a less prevalent microorganism in humans), although the latter would alphabetically come first.

    Examples

    -
    as.mo("E. coli")
    -mo_uncertainties()
    +    
    as.mo("E. coli")
    +mo_uncertainties()
     
    -mo_matching_score(x = "E. coli",
    -                  n = c("Escherichia coli", "Entamoeba coli"))
    +mo_matching_score(x = "E. coli",
    +                  n = c("Escherichia coli", "Entamoeba coli"))
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/mo_property.html b/docs/reference/mo_property.html index 1384b61ca..918f08c71 100644 --- a/docs/reference/mo_property.html +++ b/docs/reference/mo_property.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,53 +242,53 @@

    Use these functions to return a specific property of a microorganism based on the latest accepted taxonomy. All input values will be evaluated internally with as.mo(), which makes it possible to use microbial abbreviations, codes and names as input. Please see Examples.

    -
    mo_name(x, language = get_locale(), ...)
    +    
    mo_name(x, language = get_locale(), ...)
     
    -mo_fullname(x, language = get_locale(), ...)
    +mo_fullname(x, language = get_locale(), ...)
     
    -mo_shortname(x, language = get_locale(), ...)
    +mo_shortname(x, language = get_locale(), ...)
     
    -mo_subspecies(x, language = get_locale(), ...)
    +mo_subspecies(x, language = get_locale(), ...)
     
    -mo_species(x, language = get_locale(), ...)
    +mo_species(x, language = get_locale(), ...)
     
    -mo_genus(x, language = get_locale(), ...)
    +mo_genus(x, language = get_locale(), ...)
     
    -mo_family(x, language = get_locale(), ...)
    +mo_family(x, language = get_locale(), ...)
     
    -mo_order(x, language = get_locale(), ...)
    +mo_order(x, language = get_locale(), ...)
     
    -mo_class(x, language = get_locale(), ...)
    +mo_class(x, language = get_locale(), ...)
     
    -mo_phylum(x, language = get_locale(), ...)
    +mo_phylum(x, language = get_locale(), ...)
     
    -mo_kingdom(x, language = get_locale(), ...)
    +mo_kingdom(x, language = get_locale(), ...)
     
    -mo_domain(x, language = get_locale(), ...)
    +mo_domain(x, language = get_locale(), ...)
     
    -mo_type(x, language = get_locale(), ...)
    +mo_type(x, language = get_locale(), ...)
     
    -mo_gramstain(x, language = get_locale(), ...)
    +mo_gramstain(x, language = get_locale(), ...)
     
    -mo_snomed(x, language = get_locale(), ...)
    +mo_snomed(x, language = get_locale(), ...)
     
    -mo_ref(x, language = get_locale(), ...)
    +mo_ref(x, language = get_locale(), ...)
     
    -mo_authors(x, language = get_locale(), ...)
    +mo_authors(x, language = get_locale(), ...)
     
    -mo_year(x, language = get_locale(), ...)
    +mo_year(x, language = get_locale(), ...)
     
    -mo_rank(x, language = get_locale(), ...)
    +mo_rank(x, language = get_locale(), ...)
     
    -mo_taxonomy(x, language = get_locale(), ...)
    +mo_taxonomy(x, language = get_locale(), ...)
     
    -mo_synonyms(x, language = get_locale(), ...)
    +mo_synonyms(x, language = get_locale(), ...)
     
    -mo_info(x, language = get_locale(), ...)
    +mo_info(x, language = get_locale(), ...)
     
    -mo_url(x, open = FALSE, language = get_locale(), ...)
    +mo_url(x, open = FALSE, language = get_locale(), ...)
     
    -mo_property(x, property = "fullname", language = get_locale(), ...)
    +mo_property(x, property = "fullname", language = get_locale(), ...)

    Arguments

    @@ -397,87 +397,87 @@ This package contains the complete taxonomic tree of almost all microorganisms (

    Examples

    # taxonomic tree -----------------------------------------------------------
    -mo_kingdom("E. coli")         # "Bacteria"
    -mo_phylum("E. coli")          # "Proteobacteria"
    -mo_class("E. coli")           # "Gammaproteobacteria"
    -mo_order("E. coli")           # "Enterobacterales"
    -mo_family("E. coli")          # "Enterobacteriaceae"
    -mo_genus("E. coli")           # "Escherichia"
    -mo_species("E. coli")         # "coli"
    -mo_subspecies("E. coli")      # ""
    +mo_kingdom("E. coli")         # "Bacteria"
    +mo_phylum("E. coli")          # "Proteobacteria"
    +mo_class("E. coli")           # "Gammaproteobacteria"
    +mo_order("E. coli")           # "Enterobacterales"
    +mo_family("E. coli")          # "Enterobacteriaceae"
    +mo_genus("E. coli")           # "Escherichia"
    +mo_species("E. coli")         # "coli"
    +mo_subspecies("E. coli")      # ""
     
     # colloquial properties ----------------------------------------------------
    -mo_name("E. coli")            # "Escherichia coli"
    -mo_fullname("E. coli")        # "Escherichia coli" - same as mo_name()
    -mo_shortname("E. coli")       # "E. coli"
    +mo_name("E. coli")            # "Escherichia coli"
    +mo_fullname("E. coli")        # "Escherichia coli" - same as mo_name()
    +mo_shortname("E. coli")       # "E. coli"
     
     # other properties ---------------------------------------------------------
    -mo_gramstain("E. coli")       # "Gram-negative"
    -mo_snomed("E. coli")          # 112283007, 116395006, ... (SNOMED codes)
    -mo_type("E. coli")            # "Bacteria" (equal to kingdom, but may be translated)
    -mo_rank("E. coli")            # "species"
    -mo_url("E. coli")             # get the direct url to the online database entry
    -mo_synonyms("E. coli")        # get previously accepted taxonomic names
    +mo_gramstain("E. coli")       # "Gram-negative"
    +mo_snomed("E. coli")          # 112283007, 116395006, ... (SNOMED codes)
    +mo_type("E. coli")            # "Bacteria" (equal to kingdom, but may be translated)
    +mo_rank("E. coli")            # "species"
    +mo_url("E. coli")             # get the direct url to the online database entry
    +mo_synonyms("E. coli")        # get previously accepted taxonomic names
     
     # scientific reference -----------------------------------------------------
    -mo_ref("E. coli")             # "Castellani et al., 1919"
    -mo_authors("E. coli")         # "Castellani et al."
    -mo_year("E. coli")            # 1919
    +mo_ref("E. coli")             # "Castellani et al., 1919"
    +mo_authors("E. coli")         # "Castellani et al."
    +mo_year("E. coli")            # 1919
     
     # abbreviations known in the field -----------------------------------------
    -mo_genus("MRSA")              # "Staphylococcus"
    -mo_species("MRSA")            # "aureus"
    -mo_shortname("VISA")          # "S. aureus"
    -mo_gramstain("VISA")          # "Gram-positive"
    +mo_genus("MRSA")              # "Staphylococcus"
    +mo_species("MRSA")            # "aureus"
    +mo_shortname("VISA")          # "S. aureus"
    +mo_gramstain("VISA")          # "Gram-positive"
     
    -mo_genus("EHEC")              # "Escherichia"
    -mo_species("EHEC")            # "coli"
    +mo_genus("EHEC")              # "Escherichia"
    +mo_species("EHEC")            # "coli"
     
     # known subspecies ---------------------------------------------------------
    -mo_name("doylei")             # "Campylobacter jejuni doylei"
    -mo_genus("doylei")            # "Campylobacter"
    -mo_species("doylei")          # "jejuni"
    -mo_subspecies("doylei")       # "doylei"
    +mo_name("doylei")             # "Campylobacter jejuni doylei"
    +mo_genus("doylei")            # "Campylobacter"
    +mo_species("doylei")          # "jejuni"
    +mo_subspecies("doylei")       # "doylei"
     
    -mo_fullname("K. pneu rh")     # "Klebsiella pneumoniae rhinoscleromatis"
    -mo_shortname("K. pneu rh")    # "K. pneumoniae"
    +mo_fullname("K. pneu rh")     # "Klebsiella pneumoniae rhinoscleromatis"
    +mo_shortname("K. pneu rh")    # "K. pneumoniae"
     
     # \donttest{
     # Becker classification, see ?as.mo ----------------------------------------
    -mo_fullname("S. epi")                     # "Staphylococcus epidermidis"
    -mo_fullname("S. epi", Becker = TRUE)      # "Coagulase-negative Staphylococcus (CoNS)"
    -mo_shortname("S. epi")                    # "S. epidermidis"
    -mo_shortname("S. epi", Becker = TRUE)     # "CoNS"
    +mo_fullname("S. epi")                     # "Staphylococcus epidermidis"
    +mo_fullname("S. epi", Becker = TRUE)      # "Coagulase-negative Staphylococcus (CoNS)"
    +mo_shortname("S. epi")                    # "S. epidermidis"
    +mo_shortname("S. epi", Becker = TRUE)     # "CoNS"
     
     # Lancefield classification, see ?as.mo ------------------------------------
    -mo_fullname("S. pyo")                     # "Streptococcus pyogenes"
    -mo_fullname("S. pyo", Lancefield = TRUE)  # "Streptococcus group A"
    -mo_shortname("S. pyo")                    # "S. pyogenes"
    -mo_shortname("S. pyo", Lancefield = TRUE) # "GAS" (='Group A Streptococci')
    +mo_fullname("S. pyo")                     # "Streptococcus pyogenes"
    +mo_fullname("S. pyo", Lancefield = TRUE)  # "Streptococcus group A"
    +mo_shortname("S. pyo")                    # "S. pyogenes"
    +mo_shortname("S. pyo", Lancefield = TRUE) # "GAS" (='Group A Streptococci')
     
     
     # language support for German, Dutch, Spanish, Portuguese, Italian and French
    -mo_gramstain("E. coli", language = "de")  # "Gramnegativ"
    -mo_gramstain("E. coli", language = "nl")  # "Gram-negatief"
    -mo_gramstain("E. coli", language = "es")  # "Gram negativo"
    +mo_gramstain("E. coli", language = "de")  # "Gramnegativ"
    +mo_gramstain("E. coli", language = "nl")  # "Gram-negatief"
    +mo_gramstain("E. coli", language = "es")  # "Gram negativo"
     
     # mo_type is equal to mo_kingdom, but mo_kingdom will remain official
    -mo_kingdom("E. coli")                     # "Bacteria" on a German system
    -mo_type("E. coli")                        # "Bakterien" on a German system
    -mo_type("E. coli")                        # "Bacteria" on an English system
    +mo_kingdom("E. coli")                     # "Bacteria" on a German system
    +mo_type("E. coli")                        # "Bakterien" on a German system
    +mo_type("E. coli")                        # "Bacteria" on an English system
     
    -mo_fullname("S. pyogenes",
    -            Lancefield = TRUE,
    -            language = "de")              # "Streptococcus Gruppe A"
    -mo_fullname("S. pyogenes",
    -            Lancefield = TRUE,
    -            language = "nl")              # "Streptococcus groep A"
    +mo_fullname("S. pyogenes",
    +            Lancefield = TRUE,
    +            language = "de")              # "Streptococcus Gruppe A"
    +mo_fullname("S. pyogenes",
    +            Lancefield = TRUE,
    +            language = "nl")              # "Streptococcus groep A"
     
     
     # get a list with the complete taxonomy (from kingdom to subspecies)
    -mo_taxonomy("E. coli")
    +mo_taxonomy("E. coli")
     # get a list with the taxonomy, the authors, Gram-stain and URL to the online database
    -mo_info("E. coli")
    +mo_info("E. coli")
     # }
     
    @@ -495,7 +495,7 @@ This package contains the complete taxonomic tree of almost all microorganisms (
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/mo_source.html b/docs/reference/mo_source.html index e0fdc23d1..f4b07a62a 100644 --- a/docs/reference/mo_source.html +++ b/docs/reference/mo_source.html @@ -83,7 +83,7 @@ This is the fastest way to have your organisation (or analysis) specific codes p AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -244,9 +244,9 @@ This is the fastest way to have your organisation (or analysis) specific codes p

    This is the fastest way to have your organisation (or analysis) specific codes picked up and translated by this package.

    -
    set_mo_source(path)
    +    
    set_mo_source(path)
     
    -get_mo_source()
    +get_mo_source()

    Arguments

    @@ -277,20 +277,20 @@ This is the fastest way to have your organisation (or analysis) specific codes p 4 | | | -

    We save it as "home/me/ourcodes.xlsx". Now we have to set it as a source:

    set_mo_source("home/me/ourcodes.xlsx")
    +

    We save it as "home/me/ourcodes.xlsx". Now we have to set it as a source:

    set_mo_source("home/me/ourcodes.xlsx")
     #> NOTE: Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
     #>       (columns "Organisation XYZ" and "mo")
     

    It has now created a file "~/.mo_source.rds" with the contents of our Excel file. Only the first column with foreign values and the 'mo' column will be kept when creating the RDS file.

    -

    And now we can use it in our functions:

    as.mo("lab_mo_ecoli")
    +

    And now we can use it in our functions:

    as.mo("lab_mo_ecoli")
     #> [1] B_ESCHR_COLI
     
    -mo_genus("lab_mo_kpneumoniae")
    +mo_genus("lab_mo_kpneumoniae")
     #> [1] "Klebsiella"
     
     # other input values still work too
    -as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
    +as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
     #> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
     
    @@ -303,16 +303,16 @@ This is the fastest way to have your organisation (or analysis) specific codes p 5 | | |
    -

    ...any new usage of an MO function in this package will update your data file:

    as.mo("lab_mo_ecoli")
    +

    ...any new usage of an MO function in this package will update your data file:

    as.mo("lab_mo_ecoli")
     #> NOTE: Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'
     #>       (columns "Organisation XYZ" and "mo")
     #> [1] B_ESCHR_COLI
     
    -mo_genus("lab_Staph_aureus")
    +mo_genus("lab_Staph_aureus")
     #> [1] "Staphylococcus"
     
    -

    To delete the reference data file, just use "", NULL or FALSE as input for set_mo_source():

    set_mo_source(NULL)
    +

    To delete the reference data file, just use "", NULL or FALSE as input for set_mo_source():

    set_mo_source(NULL)
     # Removed mo_source file '~/.mo_source.rds'.
     
    @@ -345,7 +345,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/p_symbol.html b/docs/reference/p_symbol.html index 7e14a6774..095a5b854 100644 --- a/docs/reference/p_symbol.html +++ b/docs/reference/p_symbol.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    Return the symbol related to the p-value: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1. Values above p = 1 will return NA.

    -
    p_symbol(p, emptychar = " ")
    +
    p_symbol(p, emptychar = " ")

    Arguments

    @@ -290,7 +290,7 @@ The lifecycle of this function is questioni
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/plot.html b/docs/reference/plot.html index 3bb2ad782..22800a21a 100644 --- a/docs/reference/plot.html +++ b/docs/reference/plot.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -243,48 +243,48 @@
    # S3 method for mic
    -plot(
    -  x,
    -  main = paste("MIC values of", deparse(substitute(x))),
    -  ylab = "Frequency",
    -  xlab = "MIC value",
    -  axes = FALSE,
    -  ...
    -)
    +plot(
    +  x,
    +  main = paste("MIC values of", deparse(substitute(x))),
    +  ylab = "Frequency",
    +  xlab = "MIC value",
    +  axes = FALSE,
    +  ...
    +)
     
     # S3 method for mic
    -barplot(
    -  height,
    -  main = paste("MIC values of", deparse(substitute(height))),
    -  ylab = "Frequency",
    -  xlab = "MIC value",
    -  axes = FALSE,
    -  ...
    -)
    +barplot(
    +  height,
    +  main = paste("MIC values of", deparse(substitute(height))),
    +  ylab = "Frequency",
    +  xlab = "MIC value",
    +  axes = FALSE,
    +  ...
    +)
     
     # S3 method for rsi
    -plot(
    -  x,
    -  lwd = 2,
    -  ylim = NULL,
    -  ylab = "Percentage",
    -  xlab = "Antimicrobial Interpretation",
    -  main = paste("Resistance Overview of", deparse(substitute(x))),
    -  axes = FALSE,
    -  ...
    -)
    +plot(
    +  x,
    +  lwd = 2,
    +  ylim = NULL,
    +  ylab = "Percentage",
    +  xlab = "Antimicrobial Interpretation",
    +  main = paste("Resistance Overview of", deparse(substitute(x))),
    +  axes = FALSE,
    +  ...
    +)
     
     # S3 method for rsi
    -barplot(
    -  height,
    -  col = c("chartreuse4", "chartreuse3", "brown3"),
    -  xlab = ifelse(beside, "Antimicrobial Interpretation", ""),
    -  main = paste("Resistance Overview of", deparse(substitute(height))),
    -  ylab = "Frequency",
    -  beside = TRUE,
    -  axes = beside,
    -  ...
    -)
    +barplot( + height, + col = c("chartreuse4", "chartreuse3", "brown3"), + xlab = ifelse(beside, "Antimicrobial Interpretation", ""), + main = paste("Resistance Overview of", deparse(substitute(height))), + ylab = "Frequency", + beside = TRUE, + axes = beside, + ... +)

    Arguments

    @@ -375,7 +375,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/proportion.html b/docs/reference/proportion.html index 771ea604d..385a3b9f0 100644 --- a/docs/reference/proportion.html +++ b/docs/reference/proportion.html @@ -83,7 +83,7 @@ resistance() should be used to calculate resistance, susceptibility() should be AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -244,39 +244,39 @@ resistance() should be used to calculate resistance, susceptibility() should be

    resistance() should be used to calculate resistance, susceptibility() should be used to calculate susceptibility.

    -
    resistance(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +    
    resistance(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -susceptibility(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +susceptibility(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -proportion_R(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +proportion_R(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -proportion_IR(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +proportion_IR(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -proportion_I(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +proportion_I(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -proportion_SI(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +proportion_SI(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -proportion_S(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
    +proportion_S(..., minimum = 30, as_percent = FALSE, only_all_tested = FALSE)
     
    -proportion_df(
    -  data,
    -  translate_ab = "name",
    -  language = get_locale(),
    -  minimum = 30,
    -  as_percent = FALSE,
    -  combine_SI = TRUE,
    -  combine_IR = FALSE
    -)
    +proportion_df(
    +  data,
    +  translate_ab = "name",
    +  language = get_locale(),
    +  minimum = 30,
    +  as_percent = FALSE,
    +  combine_SI = TRUE,
    +  combine_IR = FALSE
    +)
     
    -rsi_df(
    -  data,
    -  translate_ab = "name",
    -  language = get_locale(),
    -  minimum = 30,
    -  as_percent = FALSE,
    -  combine_SI = TRUE,
    -  combine_IR = FALSE
    -)
    +rsi_df( + data, + translate_ab = "name", + language = get_locale(), + minimum = 30, + as_percent = FALSE, + combine_SI = TRUE, + combine_IR = FALSE +)

    Arguments

    @@ -353,12 +353,12 @@ resistance() should be used to calculate resistance, susceptibility() should be -------------------------------------------------------------------- -

    Please note that, in combination therapies, for only_all_tested = TRUE applies that:

        count_S()    +   count_I()    +   count_R()    = count_all()
    -  proportion_S() + proportion_I() + proportion_R() = 1
    +

    Please note that, in combination therapies, for only_all_tested = TRUE applies that:

        count_S()    +   count_I()    +   count_R()    = count_all()
    +  proportion_S() + proportion_I() + proportion_R() = 1
     
    -

    and that, in combination therapies, for only_all_tested = FALSE applies that:

        count_S()    +   count_I()    +   count_R()    >= count_all()
    -  proportion_S() + proportion_I() + proportion_R() >= 1
    +

    and that, in combination therapies, for only_all_tested = FALSE applies that:

        count_S()    +   count_I()    +   count_R()    >= count_all()
    +  proportion_S() + proportion_I() + proportion_R() >= 1
     

    Using only_all_tested has no impact when only using one antibiotic as input.

    @@ -394,76 +394,76 @@ A microorganism is categorised as Susceptible, Increased exposure when

    Examples

    # example_isolates is a data set available in the AMR package.
    -?example_isolates
    +?example_isolates
     
    -resistance(example_isolates$AMX)     # determines %R
    -susceptibility(example_isolates$AMX) # determines %S+I
    +resistance(example_isolates$AMX)     # determines %R
    +susceptibility(example_isolates$AMX) # determines %S+I
     
     # be more specific
    -proportion_S(example_isolates$AMX)
    -proportion_SI(example_isolates$AMX)
    -proportion_I(example_isolates$AMX)
    -proportion_IR(example_isolates$AMX)
    -proportion_R(example_isolates$AMX)
    +proportion_S(example_isolates$AMX)
    +proportion_SI(example_isolates$AMX)
    +proportion_I(example_isolates$AMX)
    +proportion_IR(example_isolates$AMX)
    +proportion_R(example_isolates$AMX)
     
    -if (require("dplyr")) {
    -  example_isolates %>%
    -    group_by(hospital_id) %>%
    -    summarise(r = resistance(CIP),
    -              n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr, see ?n_rsi
    +if (require("dplyr")) {
    +  example_isolates %>%
    +    group_by(hospital_id) %>%
    +    summarise(r = resistance(CIP),
    +              n = n_rsi(CIP)) # n_rsi works like n_distinct in dplyr, see ?n_rsi
      
    -  example_isolates %>%
    -    group_by(hospital_id) %>%
    -    summarise(R  = resistance(CIP, as_percent = TRUE),
    -              SI = susceptibility(CIP, as_percent = TRUE),
    -              n1 = count_all(CIP),  # the actual total; sum of all three
    -              n2 = n_rsi(CIP),      # same - analogous to n_distinct
    -              total = n())          # NOT the number of tested isolates!
    +  example_isolates %>%
    +    group_by(hospital_id) %>%
    +    summarise(R  = resistance(CIP, as_percent = TRUE),
    +              SI = susceptibility(CIP, as_percent = TRUE),
    +              n1 = count_all(CIP),  # the actual total; sum of all three
    +              n2 = n_rsi(CIP),      # same - analogous to n_distinct
    +              total = n())          # NOT the number of tested isolates!
      
       # Calculate co-resistance between amoxicillin/clav acid and gentamicin,
       # so we can see that combination therapy does a lot more than mono therapy:
    -  example_isolates %>% susceptibility(AMC)  # %SI = 76.3%
    -  example_isolates %>% count_all(AMC)       #   n = 1879
    +  example_isolates %>% susceptibility(AMC)  # %SI = 76.3%
    +  example_isolates %>% count_all(AMC)       #   n = 1879
      
    -  example_isolates %>% susceptibility(GEN)  # %SI = 75.4%
    -  example_isolates %>% count_all(GEN)       #   n = 1855
    +  example_isolates %>% susceptibility(GEN)  # %SI = 75.4%
    +  example_isolates %>% count_all(GEN)       #   n = 1855
      
    -  example_isolates %>% susceptibility(AMC, GEN) # %SI = 94.1%
    -  example_isolates %>% count_all(AMC, GEN)      #   n = 1939
    +  example_isolates %>% susceptibility(AMC, GEN) # %SI = 94.1%
    +  example_isolates %>% count_all(AMC, GEN)      #   n = 1939
      
      
       # See Details on how `only_all_tested` works. Example:
    -  example_isolates %>%
    -    summarise(numerator = count_susceptible(AMC, GEN),
    -              denominator = count_all(AMC, GEN),
    -              proportion = susceptibility(AMC, GEN))
    +  example_isolates %>%
    +    summarise(numerator = count_susceptible(AMC, GEN),
    +              denominator = count_all(AMC, GEN),
    +              proportion = susceptibility(AMC, GEN))
      
    -  example_isolates %>%
    -    summarise(numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
    -              denominator = count_all(AMC, GEN, only_all_tested = TRUE),
    -              proportion = susceptibility(AMC, GEN, only_all_tested = TRUE))
    +  example_isolates %>%
    +    summarise(numerator = count_susceptible(AMC, GEN, only_all_tested = TRUE),
    +              denominator = count_all(AMC, GEN, only_all_tested = TRUE),
    +              proportion = susceptibility(AMC, GEN, only_all_tested = TRUE))
      
      
    -  example_isolates %>%
    -    group_by(hospital_id) %>%
    -    summarise(cipro_p = susceptibility(CIP, as_percent = TRUE),
    -              cipro_n = count_all(CIP),
    -              genta_p = susceptibility(GEN, as_percent = TRUE),
    -              genta_n = count_all(GEN),
    -              combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
    -              combination_n = count_all(CIP, GEN))
    +  example_isolates %>%
    +    group_by(hospital_id) %>%
    +    summarise(cipro_p = susceptibility(CIP, as_percent = TRUE),
    +              cipro_n = count_all(CIP),
    +              genta_p = susceptibility(GEN, as_percent = TRUE),
    +              genta_n = count_all(GEN),
    +              combination_p = susceptibility(CIP, GEN, as_percent = TRUE),
    +              combination_n = count_all(CIP, GEN))
      
       # Get proportions S/I/R immediately of all rsi columns
    -  example_isolates %>%
    -    select(AMX, CIP) %>%
    -    proportion_df(translate = FALSE)
    +  example_isolates %>%
    +    select(AMX, CIP) %>%
    +    proportion_df(translate = FALSE)
      
       # It also supports grouping variables
    -  example_isolates %>%
    -    select(hospital_id, AMX, CIP) %>%
    -    group_by(hospital_id) %>%
    -    proportion_df(translate = FALSE)
    -}
    +  example_isolates %>%
    +    select(hospital_id, AMX, CIP) %>%
    +    group_by(hospital_id) %>%
    +    proportion_df(translate = FALSE)
    +}
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/resistance_predict.html b/docs/reference/resistance_predict.html index fadec1de4..a173fb048 100644 --- a/docs/reference/resistance_predict.html +++ b/docs/reference/resistance_predict.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,45 +242,45 @@

    Create a prediction model to predict antimicrobial resistance for the next years on statistical solid ground. Standard errors (SE) will be returned as columns se_min and se_max. See Examples for a real live example.

    -
    resistance_predict(
    -  x,
    -  col_ab,
    -  col_date = NULL,
    -  year_min = NULL,
    -  year_max = NULL,
    -  year_every = 1,
    -  minimum = 30,
    -  model = NULL,
    -  I_as_S = TRUE,
    -  preserve_measurements = TRUE,
    -  info = interactive(),
    -  ...
    -)
    +    
    resistance_predict(
    +  x,
    +  col_ab,
    +  col_date = NULL,
    +  year_min = NULL,
    +  year_max = NULL,
    +  year_every = 1,
    +  minimum = 30,
    +  model = NULL,
    +  I_as_S = TRUE,
    +  preserve_measurements = TRUE,
    +  info = interactive(),
    +  ...
    +)
     
    -rsi_predict(
    -  x,
    -  col_ab,
    -  col_date = NULL,
    -  year_min = NULL,
    -  year_max = NULL,
    -  year_every = 1,
    -  minimum = 30,
    -  model = NULL,
    -  I_as_S = TRUE,
    -  preserve_measurements = TRUE,
    -  info = interactive(),
    -  ...
    -)
    +rsi_predict(
    +  x,
    +  col_ab,
    +  col_date = NULL,
    +  year_min = NULL,
    +  year_max = NULL,
    +  year_every = 1,
    +  minimum = 30,
    +  model = NULL,
    +  I_as_S = TRUE,
    +  preserve_measurements = TRUE,
    +  info = interactive(),
    +  ...
    +)
     
     # S3 method for resistance_predict
    -plot(x, main = paste("Resistance Prediction of", x_name), ...)
    +plot(x, main = paste("Resistance Prediction of", x_name), ...)
     
    -ggplot_rsi_predict(
    -  x,
    -  main = paste("Resistance Prediction of", x_name),
    -  ribbon = TRUE,
    -  ...
    -)
    +ggplot_rsi_predict( + x, + main = paste("Resistance Prediction of", x_name), + ribbon = TRUE, + ... +)

    Arguments

    @@ -395,55 +395,55 @@ A microorganism is categorised as Susceptible, Increased exposure when

    Models: lm() glm()

    Examples

    -
    x <- resistance_predict(example_isolates, 
    -                        col_ab = "AMX",
    -                        year_min = 2010,
    -                        model = "binomial")
    -plot(x)
    -if (require("ggplot2")) {
    -  ggplot_rsi_predict(x)
    -}
    +    
    x <- resistance_predict(example_isolates, 
    +                        col_ab = "AMX",
    +                        year_min = 2010,
    +                        model = "binomial")
    +plot(x)
    +if (require("ggplot2")) {
    +  ggplot_rsi_predict(x)
    +}
     
     # using dplyr:
    -if (require("dplyr")) {
    -  x <- example_isolates %>%
    -    filter_first_isolate() %>%
    -    filter(mo_genus(mo) == "Staphylococcus") %>%
    -    resistance_predict("PEN", model = "binomial")
    -  plot(x)
    +if (require("dplyr")) {
    +  x <- example_isolates %>%
    +    filter_first_isolate() %>%
    +    filter(mo_genus(mo) == "Staphylococcus") %>%
    +    resistance_predict("PEN", model = "binomial")
    +  plot(x)
     
       # get the model from the object
    -  mymodel <- attributes(x)$model
    -  summary(mymodel)
    -}
    +  mymodel <- attributes(x)$model
    +  summary(mymodel)
    +}
     
     # create nice plots with ggplot2 yourself
    -if (require("dplyr") & require("ggplot2")) {
    +if (require("dplyr") & require("ggplot2")) {
     
    -  data <- example_isolates %>%
    -    filter(mo == as.mo("E. coli")) %>%
    -    resistance_predict(col_ab = "AMX",
    -                       col_date = "date",
    -                       model = "binomial",
    -                       info = FALSE,
    -                       minimum = 15)
    +  data <- example_isolates %>%
    +    filter(mo == as.mo("E. coli")) %>%
    +    resistance_predict(col_ab = "AMX",
    +                       col_date = "date",
    +                       model = "binomial",
    +                       info = FALSE,
    +                       minimum = 15)
     
    -  ggplot(data,
    -         aes(x = year)) +
    -    geom_col(aes(y = value),
    -             fill = "grey75") +
    -    geom_errorbar(aes(ymin = se_min,
    -                      ymax = se_max),
    -                  colour = "grey50") +
    -    scale_y_continuous(limits = c(0, 1),
    -                       breaks = seq(0, 1, 0.1),
    -                       labels = paste0(seq(0, 100, 10), "%")) +
    -    labs(title = expression(paste("Forecast of Amoxicillin Resistance in ",
    -                                  italic("E. coli"))),
    -         y = "%R",
    -         x = "Year") +
    -    theme_minimal(base_size = 13)
    -}
    +  ggplot(data,
    +         aes(x = year)) +
    +    geom_col(aes(y = value),
    +             fill = "grey75") +
    +    geom_errorbar(aes(ymin = se_min,
    +                      ymax = se_max),
    +                  colour = "grey50") +
    +    scale_y_continuous(limits = c(0, 1),
    +                       breaks = seq(0, 1, 0.1),
    +                       labels = paste0(seq(0, 100, 10), "%")) +
    +    labs(title = expression(paste("Forecast of Amoxicillin Resistance in ",
    +                                  italic("E. coli"))),
    +         y = "%R",
    +         x = "Year") +
    +    theme_minimal(base_size = 13)
    +}
     
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/rsi_translation.html b/docs/reference/rsi_translation.html index 9ce3311d0..072bf6101 100644 --- a/docs/reference/rsi_translation.html +++ b/docs/reference/rsi_translation.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,7 +242,7 @@

    Data set to interpret MIC and disk diffusion to R/SI values. Included guidelines are CLSI (2010-2019) and EUCAST (2011-2020). Use as.rsi() to transform MICs or disks measurements to R/SI values.

    -
    rsi_translation
    +
    rsi_translation

    Format

    @@ -292,7 +292,7 @@
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/skewness.html b/docs/reference/skewness.html index 696e4e491..be7a4359d 100644 --- a/docs/reference/skewness.html +++ b/docs/reference/skewness.html @@ -83,7 +83,7 @@ When negative ('left-skewed'): the left tail is longer; the mass of the distribu AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -244,16 +244,16 @@ When negative ('left-skewed'): the left tail is longer; the mass of the distribu

    When negative ('left-skewed'): the left tail is longer; the mass of the distribution is concentrated on the right of a histogram. When positive ('right-skewed'): the right tail is longer; the mass of the distribution is concentrated on the left of a histogram. A normal distribution has a skewness of 0.

    -
    skewness(x, na.rm = FALSE)
    +    
    skewness(x, na.rm = FALSE)
     
     # S3 method for default
    -skewness(x, na.rm = FALSE)
    +skewness(x, na.rm = FALSE)
     
     # S3 method for matrix
    -skewness(x, na.rm = FALSE)
    +skewness(x, na.rm = FALSE)
     
     # S3 method for data.frame
    -skewness(x, na.rm = FALSE)
    +skewness(x, na.rm = FALSE)

    Arguments

    @@ -299,7 +299,7 @@ The lifecycle of this function is stable
    -

    Site built with pkgdown 1.5.1.9000.

    +

    Site built with pkgdown 1.6.1.

    diff --git a/docs/reference/translate.html b/docs/reference/translate.html index fbb640f54..217784d1e 100644 --- a/docs/reference/translate.html +++ b/docs/reference/translate.html @@ -82,7 +82,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -242,14 +242,14 @@

    For language-dependent output of AMR functions, like mo_name(), mo_gramstain(), mo_type() and ab_name().

    -
    get_locale()
    +
    get_locale()

    Details

    Strings will be translated to foreign languages if they are defined in a local translation file. Additions to this file can be suggested at our repository. The file can be found here: https://github.com/msberends/AMR/blob/master/data-raw/translations.tsv. This file will be read by all functions where a translated output can be desired, like all mo_property() functions (mo_name(), mo_gramstain(), mo_type(), etc.) and ab_property() functions (ab_name(), ab_group() etc.).

    Currently supported languages are: Dutch, English, French, German, Italian, Portuguese, Spanish. Please note that currently not all these languages have translations available for all antimicrobial agents and colloquial microorganism names.

    -

    Please suggest your own translations by creating a new issue on our repository.

    Changing the default language

    +

    Please suggest your own translations by creating a new issue on our repository.

    Changing the default language

    The system language will be used at default (as returned by Sys.getenv("LANG") or, if LANG is not set, Sys.getlocale()), if that language is supported. But the language to be used can be overwritten in two ways and will be checked in this order:

      @@ -278,27 +278,27 @@ The lifecycle of this function is stable# with get_locale() # English -mo_name("CoNS", language = "en") +mo_name("CoNS", language = "en") #> "Coagulase-negative Staphylococcus (CoNS)" # German -mo_name("CoNS", language = "de") +mo_name("CoNS", language = "de") #> "Koagulase-negative Staphylococcus (KNS)" # Dutch -mo_name("CoNS", language = "nl") +mo_name("CoNS", language = "nl") #> "Coagulase-negatieve Staphylococcus (CNS)" # Spanish -mo_name("CoNS", language = "es") +mo_name("CoNS", language = "es") #> "Staphylococcus coagulasa negativo (SCN)" # Italian -mo_name("CoNS", language = "it") +mo_name("CoNS", language = "it") #> "Staphylococcus negativo coagulasi (CoNS)" # Portuguese -mo_name("CoNS", language = "pt") +mo_name("CoNS", language = "pt") #> "Staphylococcus coagulase negativo (CoNS)" @@ -316,7 +316,7 @@ The lifecycle of this function is stable
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/docs/survey.html b/docs/survey.html index f2fb2b77a..2613bece3 100644 --- a/docs/survey.html +++ b/docs/survey.html @@ -81,7 +81,7 @@ AMR (for R) - 1.4.0 + 1.4.0.9000 @@ -255,7 +255,7 @@
      -

      Site built with pkgdown 1.5.1.9000.

      +

      Site built with pkgdown 1.6.1.

      diff --git a/vignettes/benchmarks.Rmd b/vignettes/benchmarks.Rmd index de3797f39..1efb24b61 100755 --- a/vignettes/benchmarks.Rmd +++ b/vignettes/benchmarks.Rmd @@ -61,7 +61,7 @@ The actual result is the same every time: it returns its microorganism code ``r But the calculation time differs a lot: -```{r, warning=FALSE} +```{r, warning=FALSE, message=FALSE} S.aureus <- microbenchmark( as.mo("sau"), # WHONET code as.mo("stau"), @@ -117,7 +117,7 @@ So getting official taxonomic names of `r format(length(x), big.mark = ",")` (!! 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): -```{r} +```{r, warning=FALSE, message=FALSE} run_it <- microbenchmark(A = mo_name("STAAUR"), B = mo_name("S. aureus"), C = mo_name("Staphylococcus aureus"),