From 154fec27dd3640b602811e167169a4e9d93bf5f0 Mon Sep 17 00:00:00 2001 From: "Matthijs S. Berends" Date: Mon, 31 Dec 2018 12:03:35 +0100 Subject: [PATCH] website update --- docs/articles/AMR.html | 647 ++++++++++++++++++++------------------- docs/index.html | 26 +- docs/news/index.html | 200 +++--------- docs/pkgdown.yml | 2 +- docs/reference/freq.html | 8 +- vignettes/AMR.Rmd | 4 +- 6 files changed, 380 insertions(+), 507 deletions(-) diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 3ae90fe5..fd7deb3a 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -174,139 +174,142 @@ Needed R packages

As with many uses in R, we need some additional packages for AMR analysis. The most important one is dplyr, which tremendously improves the way we work with data - it allows for a very natural way of writing syntaxes in R. Another important dependency is ggplot2. This package can be used to create beautiful plots in R.

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

-
library(dplyr)   # the data science package
-library(AMR)     # this package, to simplify and automate AMR analysis
-library(ggplot2) # for appealing plots
+
library(dplyr)   # the data science package
+library(AMR)     # this package, to simplify and automate AMR analysis
+library(ggplot2) # for appealing plots

Creation of data

-

We will create some fake example data to use for analysis. For antimicrobial resistance analysis, we need at least: a patients ID, name or code of a microorganism, a date and antimicrobial results (an antibiogram). It could also include a specimen type (e.g. to filter on blood or urine), the ward type (e.g. to filter on ICUs).

+

We will create some fake example data to use for analysis. For antimicrobial resistance analysis, we need at least: a patient ID, name or code of a microorganism, a date and antimicrobial results (an antibiogram). It could also include a specimen type (e.g. to filter on blood or urine), the ward type (e.g. to filter on ICUs).

With additional columns (like a hospital name, the patients gender of even [well-defined] clinical properties) you can do a comparative analysis, as this tutorial will demonstrate too.

Patients

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

-
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.

+
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(strrep("M", 135),
+                                        strrep("F", 125)))
+

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

Dates

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

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

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

Microorganisms

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

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

Other variables

-

For completeness, we can also add the patients gender, the hospital where the patients was admitted and all valid antibmicrobial results:

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

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

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.

-
data <- data.frame(date = sample(dates, 5000, replace = TRUE),
-                   patient_id = sample(patients, 5000, replace = TRUE),
-                   # gender - add slightly more men:
-                   gender = sample(genders, 5000, replace = TRUE, prob = c(0.55, 0.45)),
-                   hospital = sample(hospitals, 5000, replace = TRUE),
-                   bacteria = sample(bacteria, 5000, replace = TRUE, prob = c(0.50, 0.25, 0.15, 0.10)),
-                   amox = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.6, 0.05, 0.35)),
-                   amcl = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.75, 0.1, 0.15)),
-                   cipr = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.8, 0, 0.2)),
-                   gent = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.92, 0, 0.07))
-                   )
+
data <- data.frame(date = sample(dates, 5000, replace = TRUE),
+                   patient_id = sample(patients, 5000, replace = TRUE),
+                   hospital = sample(hospitals, 5000, replace = TRUE),
+                   bacteria = sample(bacteria, 5000, replace = TRUE, prob = c(0.50, 0.25, 0.15, 0.10)),
+                   amox = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.6, 0.05, 0.35)),
+                   amcl = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.75, 0.1, 0.15)),
+                   cipr = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.8, 0, 0.2)),
+                   gent = sample(ab_interpretations, 5000, replace = TRUE, prob = c(0.92, 0, 0.07))
+                   )
+

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)

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

-
head(data)
+
head(data)
- + - - - - + + + + - + - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + +
date patient_idgender hospital bacteria amox amcl cipr gentgender
2017-01-24M8FHospital D2011-11-05F8Hospital A Streptococcus pneumoniaeS IR S SFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2016-12-18J6MHospital AEscherichia coliSSSS
2015-06-29E1M2013-06-01L1 Hospital CEscherichia coliRRSS
2013-02-28B1MHospital CEscherichia coliRSSS
2013-05-19N8MHospital A Streptococcus pneumoniaeSSSSMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
2014-05-29X5Hospital DEscherichia coli R SR SSMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
2014-04-02M2MHospital DStaphylococcus aureus2013-06-29K6Hospital BEscherichia coli S S R SFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2015-02-02W2Hospital DEscherichia coliSSSSFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2011-10-28T5Hospital DEscherichia coliRISSMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
@@ -316,98 +319,98 @@

Cleaning the data

-

Use the frequency table function freq() to look specifically for unique values in every variables. For example, for the gender variable:

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

Use the frequency table function freq() to look specifically for unique values in any variable. For example, for the gender variable:

+
data %>% freq(gender) # this would be the same: freq(data$gender)
# Frequency table of `gender` 
 # Class:   factor (numeric)  
-# Levels:  F, M  
+# Levels:  FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM  
 # Length:  5,000 (of which NA: 0 = 0.00%)  
 # Unique:  2
 # 
-#      Item    Count   Percent   Cum. Count   Cum. Percent
-# ---  -----  ------  --------  -----------  -------------
-# 1    M       2,773     55.5%        2,773          55.5%
-# 2    F       2,227     44.5%        5,000         100.0%
+# Item Count Percent Cum. Count Cum. Percent +# --- ---------------------------------------------------------------------------------------------------------------------------------------- ------ -------- ----------- ------------- +# 1 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2,536 50.7% 2,536 50.7% +# 2 MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 2,464 49.3% 5,000 100.0%

So, we can draw at least two conclusions immediately. From a data scientist perspective, the data looks clean: only values M and F. From a researcher 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(amox:cipr), as.rsi)
+
data <- data %>%
+  mutate_at(vars(amox:cipr), 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 amox) and amoxicillin/clavulanic acid (column amcl) in our data were generated randomly, some rows will undoubtedly contain amox = S and amcl = R, which is technically impossible. The eucast_rules() fixes this:

-
data <- eucast_rules(data, col_mo = "bacteria")
-# 
-# Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
-# 
-# EUCAST Clinical Breakpoints (v8.1, 2018)
-# Enterobacteriales (Order) (no changes)
-# Staphylococcus (no changes)
-# Enterococcus (no changes)
-# Streptococcus groups A, B, C, G (no changes)
-# Streptococcus pneumoniae (386 changes)
-# Viridans group streptococci (no changes)
-# Haemophilus influenzae (no changes)
-# Moraxella catarrhalis (no changes)
-# Anaerobic Gram positives (no changes)
-# Anaerobic Gram negatives (no changes)
-# Pasteurella multocida (no changes)
-# Campylobacter jejuni and C. coli (no changes)
-# Aerococcus sanguinicola and A. urinae (no changes)
-# Kingella kingae (no changes)
-# 
-# EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-# Table 1:  Intrinsic resistance in Enterobacteriaceae (342 changes)
-# Table 2:  Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
-# Table 3:  Intrinsic resistance in other Gram-negative bacteria (no changes)
-# Table 4:  Intrinsic resistance in Gram-positive bacteria (705 changes)
-# Table 8:  Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
-# Table 9:  Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
-# Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)
-# Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)
-# Table 12: Interpretive rules for aminoglycosides (no changes)
-# Table 13: Interpretive rules for quinolones (no changes)
-# 
-# Other rules
-# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (364 changes)
-# Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)
-# Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)
-# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (211 changes)
-# Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
-# Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
-# 
-# => EUCAST rules affected 4,626 out of 5,000 rows -> changed 2,008 test results.
+
data <- eucast_rules(data, col_mo = "bacteria")
+# 
+# Rules by the European Committee on Antimicrobial Susceptibility Testing (EUCAST)
+# 
+# EUCAST Clinical Breakpoints (v8.1, 2018)
+# Enterobacteriales (Order) (no changes)
+# Staphylococcus (no changes)
+# Enterococcus (no changes)
+# Streptococcus groups A, B, C, G (no changes)
+# Streptococcus pneumoniae (366 changes)
+# Viridans group streptococci (no changes)
+# Haemophilus influenzae (no changes)
+# Moraxella catarrhalis (no changes)
+# Anaerobic Gram positives (no changes)
+# Anaerobic Gram negatives (no changes)
+# Pasteurella multocida (no changes)
+# Campylobacter jejuni and C. coli (no changes)
+# Aerococcus sanguinicola and A. urinae (no changes)
+# Kingella kingae (no changes)
+# 
+# EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
+# Table 1:  Intrinsic resistance in Enterobacteriaceae (332 changes)
+# Table 2:  Intrinsic resistance in non-fermentative Gram-negative bacteria (no changes)
+# Table 3:  Intrinsic resistance in other Gram-negative bacteria (no changes)
+# Table 4:  Intrinsic resistance in Gram-positive bacteria (699 changes)
+# Table 8:  Interpretive rules for B-lactam agents and Gram-positive cocci (no changes)
+# Table 9:  Interpretive rules for B-lactam agents and Gram-negative rods (no changes)
+# Table 10: Interpretive rules for B-lactam agents and other Gram-negative bacteria (no changes)
+# Table 11: Interpretive rules for macrolides, lincosamides, and streptogramins (no changes)
+# Table 12: Interpretive rules for aminoglycosides (no changes)
+# Table 13: Interpretive rules for quinolones (no changes)
+# 
+# Other rules
+# Non-EUCAST: ampicillin = R where amoxicillin/clav acid = R (351 changes)
+# Non-EUCAST: piperacillin = R where piperacillin/tazobactam = R (no changes)
+# Non-EUCAST: trimethoprim = R where trimethoprim/sulfa = R (no changes)
+# Non-EUCAST: amoxicillin/clav acid = S where ampicillin = S (242 changes)
+# Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
+# Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
+# 
+# => EUCAST rules affected 4,575 out of 5,000 rows -> changed 1,990 test results.

Adding new variables

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

-
data <- data %>% 
-  mutate(gramstain = mo_gramstain(bacteria),
-         family = mo_family(bacteria))
+
data <- data %>% 
+  mutate(gramstain = mo_gramstain(bacteria),
+         family = mo_family(bacteria))

First isolates

We also need to know which isolates we can actually use for analysis.

-

To conduct an analysis of antimicrobial resistance, you must only include the first isolate of every patient per episode. 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 weeks (yes, some countries like the Netherlands have these blood drawing policies). The resistance percentage of oxacillin of all isolates would be overestimated, because you included this MRSA more than once. It would clearly be .

+

To conduct an analysis of antimicrobial resistance, you must only include the first isolate of every patient per episode (Hindler et al., Clin Infect Dis. 2007). 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 weeks (yes, some countries like the Netherlands have these blood drawing policies). The resistance percentage of oxacillin of all isolates would be overestimated, because you included this MRSA more than once. It would clearly be selection bias.

The Clinical and Laboratory Standards Institute (CLSI) appoints this as follows:

-

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

+

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

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:

- -

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

- +
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`.
+# => Found 2,928 first isolates (58.6% of total)
+

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

+
data_1st <- data %>% 
+  filter(first == TRUE)

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

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

@@ -428,8 +431,41 @@ 1 -2010-07-19 -S6 +2010-04-08 +W2 +B_ESCHR_COL +S +S +R +S +TRUE + + +2 +2010-07-04 +W2 +B_ESCHR_COL +R +R +S +R +FALSE + + +3 +2010-07-25 +W2 +B_ESCHR_COL +S +S +R +S +FALSE + + +4 +2011-08-12 +W2 B_ESCHR_COL S S @@ -437,43 +473,10 @@ S TRUE - -2 -2010-10-13 -S6 -B_ESCHR_COL -S -S -S -S -FALSE - - -3 -2010-12-24 -S6 -B_ESCHR_COL -R -I -S -S -FALSE - - -4 -2011-01-02 -S6 -B_ESCHR_COL -R -I -S -R -FALSE - 5 -2011-01-23 -S6 +2012-03-16 +W2 B_ESCHR_COL S S @@ -483,54 +486,54 @@ 6 -2011-05-16 -S6 +2012-08-15 +W2 B_ESCHR_COL S S -S -S -FALSE +R +R +TRUE 7 -2011-10-13 -S6 +2013-01-15 +W2 B_ESCHR_COL R S +R S -S -TRUE +FALSE 8 -2012-03-25 -S6 +2013-06-15 +W2 B_ESCHR_COL R -I +R S S FALSE 9 -2012-09-01 -S6 +2013-09-18 +W2 B_ESCHR_COL -R S S S -FALSE +S +TRUE 10 -2012-10-04 -S6 +2014-01-13 +W2 B_ESCHR_COL -S +R S S S @@ -538,20 +541,20 @@ -

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 show be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

+

Only 4 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 show be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics() function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.

If a column exists with a name like ‘key(…)ab’ the first_isolate() function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:

- +
data <- data %>% 
+  mutate(keyab = key_antibiotics(.)) %>% 
+  mutate(first_weighted = first_isolate(.))
+# NOTE: Using column `bacteria` as input for `col_mo`.
+# Warning: These columns do not exist and will be ignored: cfur, pita, trsu, vanc, teic, tetr, eryt, oxac, rifa, tobr, coli, cfot, cfta, mero.
+# THIS MAY STRONGLY INFLUENCE THE OUTCOME.
+# 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.
+# [Criterion] Inclusion based on key antibiotics, ignoring I.
+# => Found 4,412 first weighted isolates (88.2% of total)
@@ -568,118 +571,118 @@ - - + + - + - - + + + + - - - - + + - - + + - - + + - - + + - - - - + + + + - - + + - + - - + + - - - - + + + + - - + + + - - + - - + + - + - + - - + + - - - + + + - - + + - + @@ -688,28 +691,28 @@
isolate
12010-07-19S62010-04-08W2 B_ESCHR_COL S SSR S TRUE TRUE
22010-10-13S62010-07-04W2 B_ESCHR_COLRR SSSSFALSER FALSETRUE
32010-12-24S62010-07-25W2 B_ESCHR_COLRI S SRS FALSE TRUE
42011-01-02S62011-08-12W2 B_ESCHR_COLRI SRFALSESSSTRUE TRUE
52011-01-23S62012-03-16W2 B_ESCHR_COL S S S S FALSETRUEFALSE
62011-05-16S62012-08-15W2 B_ESCHR_COL S SSSFALSEFALSERRTRUETRUE
72011-10-13S62013-01-15W2 B_ESCHR_COL R SR SSTRUEFALSE TRUE
82012-03-25S62013-06-15W2 B_ESCHR_COL RIR S S FALSEFALSETRUE
92012-09-01S62013-09-18W2 B_ESCHR_COLR S S SFALSEFALSESTRUETRUE
102012-10-04S62014-01-13W2 B_ESCHR_COLSR S S S
-

Instead of 2, now 6 isolates are flagged. In total, 86.4% of all isolates are marked ‘first weighted’ - 28.1% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.

+

Instead of 4, now 9 isolates are flagged. In total, 88.2% of all isolates are marked ‘first weighted’ - 29.7% 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:

- -

So we end up with 4,318 isolates for analysis.

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

So we end up with 4,412 isolates for analysis.

We can remove unneeded columns:

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

Now our data looks like:

-
head(data_1st)
+
head(data_1st)
- + @@ -717,90 +720,90 @@ - - - - + + + - - + + + - - - - - - - - - - - - - - - - - - + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + + + + + + + + + + + + + + + diff --git a/docs/index.html b/docs/index.html index 05bfb7a0..491b09f6 100644 --- a/docs/index.html +++ b/docs/index.html @@ -162,7 +162,7 @@

Get this package

This package is available on the official R network. Install this package in R with:

- +

It will be downloaded and installed automatically.

@@ -178,17 +178,17 @@

All (sub)species from the taxonomic kingdoms Bacteria, Fungi and Protozoa are included in this package, as well as all previously accepted names known to ITIS. Furthermore, the responsible authors and year of publication are available. This allows users to use authoritative taxonomic information for their data analysis on any microorganism, not only human pathogens. It also helps to quickly determine the Gram stain of bacteria, since all bacteria are classified into subkingdom Negibacteria or Posibacteria. ITIS is a partnership of U.S., Canadian, and Mexican agencies and taxonomic specialists.

The AMR package basically does four important things:

    -
  1. -

    It cleanses existing data, by transforming it to reproducible and profound classes, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:

    +
  2. It cleanses existing data, by transforming it to reproducible and profound classes, making the most efficient use of R. These functions all use artificial intelligence to guess results that you would expect:
  3. +
  • Use as.mo() to get an ID of a microorganism. The IDs are human readable for the trained eye - the ID of Klebsiella pneumoniae is “B_KLBSL_PNE” (B stands for Bacteria) and the ID of S. aureus is “B_STPHY_AUR”. The function takes almost any text as input that looks like the name or code of a microorganism like “E. coli”, “esco” and “esccol”. Even as.mo("MRSA") will return the ID of S. aureus. Moreover, it can group all coagulase negative and positive Staphylococci, and can transform Streptococci into Lancefield groups. To find bacteria based on your input, it uses Artificial Intelligence to look up values in the included ITIS data, consisting of more than 18,000 microorganisms.
  • Use as.rsi() to transform values to valid antimicrobial results. It produces just S, I or R based on your input and warns about invalid values. Even values like “<=0.002; S” (combined MIC/RSI) will result in “S”.
  • Use as.mic() to cleanse your MIC values. It produces a so-called factor (called ordinal in SPSS) with valid MIC values as levels. A value like “<=0.002; S” (combined MIC/RSI) will result in “<=0.002”.
  • Use as.atc() to get the ATC code of an antibiotic as defined by the WHO. This package contains a database with most LIS codes, official names, DDDs and even trade names of antibiotics. For example, the values “Furabid”, “Furadantin”, “nitro” all return the ATC code of Nitrofurantoine.
- -
  • -

    It enhances existing data and adds new data from data sets included in this package.

    +
      +
    1. It enhances existing data and adds new data from data sets included in this package.
    2. +
    • Use eucast_rules() to apply EUCAST expert rules to isolates.
    • Use first_isolate() to identify the first isolates of every patient using guidelines from the CLSI (Clinical and Laboratory Standards Institute). @@ -200,9 +200,9 @@
    • The data set microorganisms contains the complete taxonomic tree of more than 18,000 microorganisms (bacteria, fungi/yeasts and protozoa). Furthermore, the colloquial name and Gram stain are available, which enables resistance analysis of e.g. different antibiotics per Gram stain. The package also contains functions to look up values in this data set like mo_genus(), mo_family(), mo_gramstain() or even mo_phylum(). As they use as.mo() internally, they also use artificial intelligence. For example, mo_genus("MRSA") and mo_genus("S. aureus") will both return "Staphylococcus". They also come with support for German, Dutch, Spanish, Italian, French and Portuguese. These functions can be used to add new variables to your data.
    • The data set antibiotics contains the ATC code, LIS codes, official name, trivial name and DDD of both oral and parenteral administration. It also contains a total of 298 trade names. Use functions like ab_name() and ab_tradenames() to look up values. The ab_* functions use as.atc() internally so they support AI to guess your expected result. For example, ab_name("Fluclox"), ab_name("Floxapen") and ab_name("J01CF05") will all return "Flucloxacillin". These functions can again be used to add new variables to your data.
    -
  • -
  • -

    It analyses the data with convenient functions that use well-known methods.

    +
      +
    1. It analyses the data with convenient functions that use well-known methods.
    2. +
    -
  • -
  • -

    It teaches the user how to use all the above actions.

    +
      +
    1. It teaches the user how to use all the above actions.
    2. +
    • The package contains extensive help pages with many examples.
    • It also contains an example data set called septic_patients. This data set contains: @@ -223,8 +223,6 @@
  • - -

    diff --git a/docs/news/index.html b/docs/news/index.html index 954e4c2d..2db8da27 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -169,26 +169,14 @@ @@ -197,8 +185,7 @@ Changed
    • Fixed a critical bug in eucast_rules() where some rules that depend on previous applied rules would not be applied adequately
    • -
    • Improvements for as.mo(): -
        +
      • Improvements for as.mo():
      • Finds better results when input is in other languages
      • Better handling for subspecies
      • Better handling for Salmonellae @@ -207,17 +194,12 @@
      • Manual now contains more info about the algorithms
      • Progress bar will be shown when it takes more than 3 seconds to get results
      • Support for formatted console text
      • -
      -
    • -
    • Function first_isolate(): -
        -
      • Fixed a bug where distances between dates would not be calculated right - in the septic_patients data set this yielded a differences of 0.15% more isolates
      • +
      • Function first_isolate():
      • +
      • Fixed a bug where distances between dates would not be calculated right - in the septic_patients data set this yielded a difference of 0.15% more isolates
      • Will now use a column named like “patid” for the patient ID (parameter col_patientid), when this parameter was left blank
      • Will now use a column named like “key(…)ab” or “key(…)antibiotics” for the key antibiotics (parameter col_keyantibiotics()), when this parameter was left blank
      • Removed parameter output_logical, the function will now always return a logical value
      • Renamed parameter filter_specimen to specimen_group, although using filter_specimen will still work
      • -
      -
    • A note to the manual pages of the portion functions, that low counts can influence the outcome and that the portion functions may camouflage this, since they only return the portion (albeit being dependent on the minimum parameter)
    • Function mo_taxonomy() now contains the kingdom too
    • Reduce false positives for is.rsi.eligible() @@ -226,8 +208,7 @@
    • Small text updates to summaries of class rsi and mic
    • -
    • Frequency tables (freq() function): -
        +
      • Frequency tables (freq() function):
      • Header info is now available as a list, with the header function
      • Added header info for class mo to show unique count of families, genera and species
      • Now honours the decimal.mark setting, which just like format defaults to getOption("OutDec") @@ -237,8 +218,6 @@
      • New parameter droplevels to exclude empty factor levels when input is a factor
      • Factor levels will be in header when present in input data
      • -
      -
    • Function scale_y_percent() now contains the limits parameter
    • Automatic parameter filling for mdro(), key_antibiotics() and eucast_rules()
    • @@ -280,8 +259,7 @@
    • EUCAST_rules was renamed to eucast_rules, the old function still exists as a deprecated function
    • -
    • Big changes to the eucast_rules function: -
        +
      • Big changes to the eucast_rules function:
      • Now also applies rules from the EUCAST ‘Breakpoint tables for bacteria’, version 8.1, 2018, http://www.eucast.org/clinical_breakpoints/ (see Source of the function)
      • New parameter rules to specify which rules should be applied (expert rules, breakpoints, others or all)
      • New parameter verbose which can be set to TRUE to get very specific messages about which columns and rows were affected
      • @@ -290,18 +268,11 @@
      • Data set septic_patients now reflects these changes
      • Added parameter pipe for piperacillin (J01CA12), also to the mdro function
      • Small fixes to EUCAST clinical breakpoint rules
      • -
      -
    • Added column kingdom to the microorganisms data set, and function mo_kingdom to look up values
    • Tremendous speed improvement for as.mo (and subsequently all mo_* functions), as empty values wil be ignored a priori
    • Fewer than 3 characters as input for as.mo will return NA
    • -
    • -

      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"
      +
    • Function as.mo (and all mo_* wrappers) now supports genus abbreviations with “species” attached r 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
    • @@ -310,19 +281,18 @@
    • Using portion_* functions now throws a warning when total available isolate is below parameter minimum
    • Functions as.mo, as.rsi, as.mic, as.atc and freq will not set package name as attribute anymore
    • -
    • Frequency tables - freq(): - -
    • first_isolate now tries to find columns to use as input when parameters are left blank
    • Improvements for MDRO algorithm (function mdro)
    • @@ -346,8 +314,7 @@
    • ggplot_rsi and scale_y_percent have breaks parameter
    • -
    • AI improvements for as.mo: -
        +
      • AI improvements for as.mo:
      • "CRS" -> Stenotrophomonas maltophilia
      • @@ -360,8 +327,6 @@
      • "MSSE" -> Staphylococcus epidermidis
      • -
      -
    • Fix for join functions
    • Speed improvement for is.rsi.eligible, now 15-20 times faster
    • In g.test, when sum(x) is below 1000 or any of the expected values is below 5, Fisher’s Exact Test will be suggested
    • @@ -390,8 +355,7 @@ New
      • The data set microorganisms now contains all microbial taxonomic data from ITIS (kingdoms Bacteria, Fungi and Protozoa), the Integrated Taxonomy Information System, available via https://itis.gov. The data set now contains more than 18,000 microorganisms with all known bacteria, fungi and protozoa according ITIS with genus, species, subspecies, family, order, class, phylum and subkingdom. The new data set microorganisms.old contains all previously known taxonomic names from those kingdoms.
      • -
      • New functions based on the existing function mo_property: -
          +
        • New functions based on the existing function mo_property:
        • Taxonomic names: mo_phylum, mo_class, mo_order, mo_family, mo_genus, mo_species, mo_subspecies
        • Semantic names: mo_fullname, mo_shortname @@ -401,52 +365,22 @@
        • Author and year: mo_ref
        -

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

        -
        mo_gramstain("E. coli")
        -# [1] "Gram negative"
        -mo_gramstain("E. coli", language = "de") # German
        -# [1] "Gramnegativ"
        -mo_gramstain("E. coli", language = "es") # Spanish
        -# [1] "Gram negativo"
        -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:

        - -
      • -
      • Functions count_R, count_IR, count_I, count_SI and count_S to selectively count resistant or susceptible isolates +

        They also come with support for German, Dutch, French, Italian, Spanish and Portuguese: r mo_gramstain("E. coli") # [1] "Gram negative" mo_gramstain("E. coli", language = "de") # German # [1] "Gramnegativ" mo_gramstain("E. coli", language = "es") # Spanish # [1] "Gram negativo" 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: r mo_gramstain("Esc blattae") # Note: 'Escherichia blattae' (Burgess et al., 1973) was renamed 'Shimwellia blattae' (Priest and Barker, 2010) # [1] "Gram negative"

          +
        • Functions count_R, count_IR, count_I, count_SI and count_S to selectively count resistant or susceptible isolates
        • Extra function count_df (which works like portion_df) to get all counts of S, I and R of a data set with antibiotic columns, with support for grouped variables
        • -
        -
      • Function is.rsi.eligible to check for columns that have valid antimicrobial results, but do not have the rsi class yet. Transform the columns of your raw data with: data %>% mutate_if(is.rsi.eligible, as.rsi)
      • -
      • -

        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 Artificial Intelligence (AI):

        - -

        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:

        - +
      • 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 Artificial Intelligence (AI): r as.mo("E. coli") # [1] B_ESCHR_COL as.mo("MRSA") # [1] B_STPHY_AUR 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: r 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
      • Added parameter reference_df for as.mo, so users can supply their own microbial IDs, name or codes as a reference table
      • -
      • Renamed all previous references to bactid to mo, like: -
          +
        • Renamed all previous references to bactid to mo, like:
        • Column names inputs of EUCAST_rules, first_isolate and key_antibiotics
        • Column names of datasets microorganisms and septic_patients
        • All old syntaxes will still work with this version, but will throw warnings
        • -
        -
      • Function labels_rsi_count to print datalabels on a RSI ggplot2 model
      • Functions as.atc and is.atc to transform/look up antibiotic ATC codes as defined by the WHO. The existing function guess_atc is now an alias of as.atc.

      • Function ab_property and its aliases: ab_name, ab_tradenames, ab_certe, ab_umcg and ab_trivial_nl @@ -461,14 +395,7 @@ Changed
        • Added three antimicrobial agents to the antibiotics data set: Terbinafine (D01BA02), Rifaximin (A07AA11) and Isoconazole (D01AC05)
        • -
        • -

          Added 163 trade names to the antibiotics data set, it now contains 298 different trade names in total, e.g.:

          -
          ab_official("Bactroban")
          -# [1] "Mupirocin"
          -ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
          -# [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin"
          -ab_atc(c("Bactroban", "Amoxil", "Zithromax", "Floxapen"))
          -# [1] "R01AX06" "J01CA04" "J01FA10" "J01CF05"
          +
        • Added 163 trade names to the antibiotics data set, it now contains 298 different trade names in total, e.g.: r ab_official("Bactroban") # [1] "Mupirocin" ab_name(c("Bactroban", "Amoxil", "Zithromax", "Floxapen")) # [1] "Mupirocin" "Amoxicillin" "Azithromycin" "Flucloxacillin" 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
        • @@ -477,36 +404,9 @@
        • Added prevalence column to the microorganisms data set
        • Added parameters minimum and as_percent to portion_df
        • -
        • -

          Support for quasiquotation in the functions series count_* and portions_*, and n_rsi. This allows to check for more than 2 vectors or columns.

          - -
        • -
        • 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
        • -
        • Added datalabels function labels_rsi_count to ggplot_rsi -
        • -
        • Added possibility to set any parameter to geom_rsi (and ggplot_rsi) so you can set your own preferences
        • -
        • Fix for joins, where predefined suffices would not be honoured
        • -
        • Added parameter quote to the freq function
        • -
        • Added generic function diff for frequency tables
        • -
        • Added longest en shortest character length in the frequency table (freq) header of class character -
        • -
        • -

          Support for types (classes) list and matrix for freq

          -
          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)
          -
        • +
        • Support for quasiquotation in the functions series count_* and portions_*, and n_rsi. This allows to check for more than 2 vectors or columns. ```r septic_patients %>% select(amox, cipr) %>% count_IR() # which is the same as: septic_patients %>% count_IR(amox, cipr)
        +

        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 * Added datalabels function `labels_rsi_count` to `ggplot_rsi` * Added possibility to set any parameter to `geom_rsi` (and `ggplot_rsi`) so you can set your own preferences * Fix for joins, where predefined suffices would not be honoured * Added parameter `quote` to the `freq` function * Added generic function `diff` for frequency tables * Added longest en shortest character length in the frequency table (`freq`) header of class `character` * Support for types (classes) list and matrix for `freq`r my_matrix = with(septic_patients, matrix(c(age, gender), ncol = 2)) freq(my_matrix) For lists, subsetting is possible:r my_list = list(age = septic_patients$age, gender = septic_patients$gender) my_list %>% freq(age) my_list %>% freq(gender) ```

        @@ -525,21 +425,15 @@ New

        • -BREAKING: rsi_df was removed in favour of new functions portion_R, portion_IR, portion_I, portion_SI and portion_S to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old rsi function. The old function still works, but is deprecated. -
            +BREAKING: rsi_df was removed in favour of new functions portion_R, portion_IR, portion_I, portion_SI and portion_S to selectively calculate resistance or susceptibility. These functions are 20 to 30 times faster than the old rsi function. The old function still works, but is deprecated.
          • New function portion_df to get all portions of S, I and R of a data set with antibiotic columns, with support for grouped variables
          • -
          -
        • -BREAKING: the methodology for determining first weighted isolates was changed. The antibiotics that are compared between isolates (call key antibiotics) to include more first isolates (afterwards called first weighted isolates) are now as follows: -
            +BREAKING: the methodology for determining first weighted isolates was changed. The antibiotics that are compared between isolates (call key antibiotics) to include more first isolates (afterwards called first weighted isolates) are now as follows:
          • Universal: amoxicillin, amoxicillin/clavlanic acid, cefuroxime, piperacillin/tazobactam, ciprofloxacin, trimethoprim/sulfamethoxazole
          • Gram-positive: vancomycin, teicoplanin, tetracycline, erythromycin, oxacillin, rifampicin
          • Gram-negative: gentamicin, tobramycin, colistin, cefotaxime, ceftazidime, meropenem
          • -
          -
        • Support for ggplot2 -
            +
          • New functions geom_rsi, facet_rsi, scale_y_percent, scale_rsi_colours and theme_rsi
          • New wrapper function ggplot_rsi to apply all above functions on a data set: @@ -550,32 +444,22 @@
        • -
        -
      • -
      • Determining bacterial ID: -
          +
        • Determining bacterial ID:
        • New functions as.bactid and is.bactid to transform/ look up microbial ID’s.
        • The existing function guess_bactid is now an alias of as.bactid
        • New Becker classification for Staphylococcus to categorise them into Coagulase Negative Staphylococci (CoNS) and Coagulase Positve Staphylococci (CoPS)
        • New Lancefield classification for Streptococcus to categorise them into Lancefield groups
        • -
        -
      • For convience, new descriptive statistical functions kurtosis and skewness that are lacking in base R - they are generic functions and have support for vectors, data.frames and matrices
      • Function g.test to perform the Χ2 distributed G-test, which use is the same as chisq.test
      • -
      • -Function ratio to transform a vector of values to a preset ratio - -
      • Support for Addins menu in RStudio to quickly insert %in% or %like% (and give them keyboard shortcuts), or to view the datasets that come with this package
      • Function p.symbol to transform p values to their related symbols: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
      • Functions clipboard_import and clipboard_export as helper functions to quickly copy and paste from/to software like Excel and SPSS. These functions use the clipr package, but are a little altered to also support headless Linux servers (so you can use it in RStudio Server)
      • -
      • New for frequency tables (function freq): -
          +
        • New for frequency tables (function freq):
        • A vignette to explain its usage
        • Support for rsi (antimicrobial resistance) to use as input
        • Support for table to use as input: freq(table(x, y)) @@ -590,8 +474,6 @@
        • Header of frequency tables now also show Mean Absolute Deviaton (MAD) and Interquartile Range (IQR)
        • Possibility to globally set the default for the amount of items to print, with options(max.print.freq = n) where n is your preset value
        -
      • -

      @@ -613,27 +495,21 @@
    • Small improvements to the microorganisms dataset (especially for Salmonella) and the column bactid now has the new class "bactid"
    • -
    • Combined MIC/RSI values will now be coerced by the rsi and mic functions: - -
    • Now possible to coerce MIC values with a space between operator and value, i.e. as.mic("<= 0.002") now works
    • Classes rsi and mic do not add the attribute package.version anymore
    • Added "groups" option for atc_property(..., property). It will return a vector of the ATC hierarchy as defined by the WHO. The new function atc_groups is a convenient wrapper around this.
    • Build-in host check for atc_property as it requires the host set by url to be responsive
    • Improved first_isolate algorithm to exclude isolates where bacteria ID or genus is unavailable
    • Fix for warning hybrid evaluation forced for row_number (924b62) from the dplyr package v0.7.5 and above
    • -
    • Support for empty values and for 1 or 2 columns as input for guess_bactid (now called as.bactid) -
        +
      • Support for empty values and for 1 or 2 columns as input for guess_bactid (now called as.bactid)
      • So yourdata %>% select(genus, species) %>% as.bactid() now also works
      • -
      -
    • Other small fixes
    @@ -641,14 +517,11 @@

    Other

    @@ -667,15 +540,12 @@
  • Function guess_bactid to determine the ID of a microorganism based on genus/species or known abbreviations like MRSA
  • Function guess_atc to determine the ATC of an antibiotic based on name, trade name, or known abbreviations
  • Function freq to create frequency tables, with additional info in a header
  • -
  • Function MDRO to determine Multi Drug Resistant Organisms (MDRO) with support for country-specific guidelines. - -
  • New algorithm to determine weighted isolates, can now be "points" or "keyantibiotics", see ?first_isolate
  • New print format for tibbles and data.tables
  • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 4fecc46c..f8312a6a 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -1,4 +1,4 @@ -pandoc: 2.3.1 +pandoc: 1.17.2 pkgdown: 1.3.0 pkgdown_sha: ~ articles: diff --git a/docs/reference/freq.html b/docs/reference/freq.html index 5f6bed31..b64d7c6d 100644 --- a/docs/reference/freq.html +++ b/docs/reference/freq.html @@ -47,7 +47,8 @@ - + @@ -163,7 +164,8 @@
    -

    Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. top_freq can be used to get the top/bottom n items of a frequency table, with counts as names.

    +

    Create a frequency table of a vector with items or a data frame. Supports quasiquotation and markdown for reports. The best practice is: data %>% freq(var).
    +top_freq can be used to get the top/bottom n items of a frequency table, with counts as names.

    @@ -240,7 +242,7 @@ - + diff --git a/vignettes/AMR.Rmd b/vignettes/AMR.Rmd index ed5f19a7..bfd3b620 100755 --- a/vignettes/AMR.Rmd +++ b/vignettes/AMR.Rmd @@ -66,9 +66,9 @@ 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 `r length(patients)`, with values (patient IDs) varying from ``r patients[1]`` to ``r patients[length(patients)]``. Now we we also set the gender of our patients, by putting the ID and the gender in a table: ```{r create gender} -patients_table <- data.frame(patients, +patients_table <- data.frame(patient_id = patients, gender = c(strrep("M", 135), - strrep("F", 125)) + strrep("F", 125))) ``` The first 135 patient IDs are now male, the other 125 are female.
    date patient_idgender hospital bacteria amox amcl cipr gentgender gramstain family first_weighted
    12017-01-24M8FHospital D2011-11-05F8Hospital A B_STRPTC_PNEIISS S RFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF Gram positive Streptococcaceae TRUE
    22016-12-18J6MHospital AB_ESCHR_COLSSSSGram negativeEnterobacteriaceaeTRUE
    32015-06-29E1M2013-06-01L1 Hospital CB_ESCHR_COLRRB_STRPTC_PNE S SGram negativeEnterobacteriaceaeTRUE
    42013-02-28B1MHospital CB_ESCHR_COLRSSSGram negativeEnterobacteriaceaeTRUE
    62014-04-02M2MHospital DB_STPHY_AURS S RSMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM Gram positiveStaphylococcaceaeStreptococcaceaeTRUE
    42013-06-29K6Hospital BB_ESCHR_COLSSRSFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFGram negativeEnterobacteriaceae TRUE
    62011-10-28T5Hospital DB_ESCHR_COLRISSMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMGram negativeEnterobacteriaceaeTRUE
    72015-11-12E2MHospital B2017-03-11D5Hospital D B_KLBSL_PNE R S R SMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMGram negativeEnterobacteriaceaeTRUE
    82013-04-06F6Hospital AB_ESCHR_COLRSSSFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF Gram negative Enterobacteriaceae TRUE
    na

    a character string to should be used to show empty (NA) values (only useful when na.rm = FALSE)

    a character string that should be used to show empty (NA) values (only useful when na.rm = FALSE)

    droplevels