diff --git a/DESCRIPTION b/DESCRIPTION index dcb6027d..5a6953db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.5.0.9017 -Date: 2019-02-11 +Date: 2019-02-12 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/R/freq.R b/R/freq.R index 4158bdc9..109ddffe 100755 --- a/R/freq.R +++ b/R/freq.R @@ -564,8 +564,16 @@ format_header <- function(x, markdown = FALSE, decimal.mark = ".", big.mark = ", # FORMATTING # rsi if (has_length == TRUE & any(x_class == "rsi")) { + if (header$count_S < header$count_IR) { + ratio <- paste0(green(1), ":", red(format(header$count_IR / header$count_S, + digits = 1, nsmall = 1, decimal.mark = decimal.mark, big.mark = big.mark))) + } else { + ratio <- paste0(green(format(header$count_S / header$count_IR, + digits = 1, nsmall = 1, decimal.mark = decimal.mark, big.mark = big.mark)), + ":", red(1)) + } header$`%IR` <- paste((header$count_IR / header$length) %>% percent(force_zero = TRUE, round = digits, decimal.mark = decimal.mark), - paste0("(ratio S : IR = 1.0 : ", (header$count_IR / header$count_S) %>% format(digits = 1, nsmall = 1, decimal.mark = decimal.mark, big.mark = big.mark), ")")) + paste0("(ratio ", ratio, ")")) header <- header[!names(header) %in% c("count_S", "count_IR")] } # dates @@ -872,11 +880,20 @@ print.frequency_tbl <- function(x, if (opt$tbl_format == "pandoc") { title <- bold(title) } else if (opt$tbl_format == "markdown") { - title <- paste0("\n**", title, "** ") # two space for newline + title <- paste0("\n\n**", title, "** ") # two space for newline + } + + cat(title, "\n\n") + + if (NROW(x) == 0) { + cat("No observations.\n") + if (opt$tbl_format == "markdown") { + cat("\n") + } + return(invisible()) } if (opt$header == TRUE) { - cat(title, "\n") if (!is.null(opt$header_txt)) { if (is.null(opt$digits)) { opt$digits <- 2 @@ -884,14 +901,6 @@ print.frequency_tbl <- function(x, cat(format_header(x, digits = opt$digits, markdown = (opt$tbl_format == "markdown"), decimal.mark = decimal.mark, big.mark = big.mark)) } - } else if (opt$tbl_format == "markdown") { - # do print title as caption in markdown - cat("\n", title, sep = "") # two trailing spaces for markdown - } - - if (NROW(x) == 0) { - cat("\n\nNo observations.\n") - return(invisible()) } # save old NA setting for kable diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 0fcd39d7..29aa831d 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -185,7 +185,7 @@
AMR.Rmd
Note: values on this page will change with every website update since they are based on randomly created values and the page was written in RMarkdown. However, the methodology remains unchanged. This page was generated on 11 February 2019.
+Note: values on this page will change with every website update since they are based on randomly created values and the page was written in RMarkdown. However, the methodology remains unchanged. This page was generated on 12 February 2019.
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.
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,
+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,
+ bacteria = sample(bacteria, size = sample_size, replace = TRUE,
prob = c(0.50, 0.25, 0.15, 0.10)),
- amox = sample(ab_interpretations, size = sample_size, replace = TRUE,
+ amox = sample(ab_interpretations, size = sample_size, replace = TRUE,
prob = c(0.60, 0.05, 0.35)),
- amcl = sample(ab_interpretations, size = sample_size, replace = TRUE,
+ amcl = sample(ab_interpretations, size = sample_size, replace = TRUE,
prob = c(0.75, 0.10, 0.15)),
- cipr = sample(ab_interpretations, size = sample_size, replace = TRUE,
+ cipr = sample(ab_interpretations, size = sample_size, replace = TRUE,
prob = c(0.80, 0.00, 0.20)),
- gent = sample(ab_interpretations, size = sample_size, replace = TRUE,
+ gent = 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:
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:
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:
2013-12-28 | -M2 | -Hospital B | -Streptococcus pneumoniae | -R | -S | -S | -S | -M | -|||
2017-03-17 | -Z5 | +2012-04-28 | +X6 | Hospital B | Escherichia coli | R | S | -S | +R | S | F |
2011-05-13 | -G5 | -Hospital B | -Streptococcus pneumoniae | -S | -S | -S | -S | -M | -|||
2011-03-06 | -X3 | -Hospital D | -Escherichia coli | -S | -S | -S | -S | -F | -|||
2016-11-01 | -C9 | -Hospital D | -Escherichia coli | -R | -S | -R | -S | -M | -|||
2010-12-16 | -E2 | +2012-12-23 | +Z1 | Hospital A | +Escherichia coli | +I | +S | +R | +S | +F | +|
2011-05-27 | +G10 | +Hospital B | Streptococcus pneumoniae | S | S | @@ -385,6 +352,39 @@S | M | ||||
2012-08-19 | +Q1 | +Hospital D | +Escherichia coli | +S | +R | +S | +S | +F | +|||
2016-05-06 | +Y2 | +Hospital D | +Klebsiella pneumoniae | +S | +S | +S | +S | +F | +|||
2010-08-27 | +I8 | +Hospital A | +Escherichia coli | +R | +S | +S | +S | +M | +
Now, let’s start the cleaning and the analysis!
@@ -396,6 +396,7 @@Use the frequency table function freq()
to look specifically for unique values in any variable. For example, for the gender
variable:
#> Frequency table of `gender` from a data.frame (20,000 x 9)
+#>
#> Class: factor (numeric)
#> Levels: F, M
#> Length: 20,000 (of which NA: 0 = 0.00%)
@@ -403,15 +404,15 @@
#>
#> Item Count Percent Cum. Count Cum. Percent
#> --- ----- ------- -------- ----------- -------------
-#> 1 M 10,390 52.0% 10,390 52.0%
-#> 2 F 9,610 48.1% 20,000 100.0%
+#> 1 M 10,303 51.5% 10,303 51.5%
+#> 2 F 9,697 48.5% 20,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:
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:
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:
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:
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
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")
@@ -435,10 +436,10 @@
#> Kingella kingae (no changes)
#>
#> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-#> Table 1: Intrinsic resistance in Enterobacteriaceae (1288 changes)
+#> Table 1: Intrinsic resistance in Enterobacteriaceae (1278 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 (2832 changes)
+#> Table 4: Intrinsic resistance in Gram-positive bacteria (2750 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)
@@ -454,16 +455,16 @@
#> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
#> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
#>
-#> => EUCAST rules affected 7,405 out of 20,000 rows
+#> => EUCAST rules affected 7,442 out of 20,000 rows
#> -> added 0 test results
-#> -> changed 4,120 test results (0 to S; 0 to I; 4,120 to R)
Now that we have the microbial ID, we can add some taxonomic properties:
data <- data %>%
- mutate(gramstain = mo_gramstain(bacteria),
+ mutate(gramstain = mo_gramstain(bacteria),
genus = mo_genus(bacteria),
species = mo_species(bacteria))
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(.))
+ 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 5,647 first isolates (28.2% of total)
So only 28.2% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.3% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
For future use, the above two syntaxes can be shortened with the filter_first_isolate()
function:
Only 2 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics()
function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.
Only 1 isolates are marked as ‘first’ according to CLSI guideline. But when reviewing the antibiogram, it is obvious that some isolates are absolutely different strains and should be included too. This is why we weigh isolates, based on their antibiogram. The key_antibiotics()
function adds a vector with 18 key antibiotics: 6 broad spectrum ones, 6 small spectrum for Gram negatives and 6 small spectrum for Gram positives. These can be defined by the user.
If a column exists with a name like ‘key(…)ab’ the first_isolate()
function will automatically use it and determine the first weighted isolates. Mind the NOTEs in below output:
data <- data %>%
- mutate(keyab = key_antibiotics(.)) %>%
- mutate(first_weighted = first_isolate(.))
+ 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.
#> [Criterion] Inclusion based on key antibiotics, ignoring I.
-#> => Found 15,789 first weighted isolates (78.9% of total)
isolate | @@ -646,11 +647,11 @@||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-01-02 | -F5 | +2010-01-15 | +V8 | B_ESCHR_COL | -R | S | +R | S | S | TRUE | @@ -658,11 +659,11 @@|
2 | -2010-04-18 | -F5 | +2010-02-08 | +V8 | B_ESCHR_COL | S | -I | +S | R | S | FALSE | @@ -670,8 +671,8 @@|
3 | -2010-05-05 | -F5 | +2010-02-24 | +V8 | B_ESCHR_COL | R | S | @@ -682,8 +683,32 @@|||||
4 | -2010-11-03 | -F5 | +2010-04-28 | +V8 | +B_ESCHR_COL | +R | +S | +S | +S | +FALSE | +FALSE | +|
5 | +2010-05-13 | +V8 | +B_ESCHR_COL | +R | +S | +S | +S | +FALSE | +FALSE | +|||
6 | +2010-05-14 | +V8 | B_ESCHR_COL | S | S | @@ -693,9 +718,21 @@TRUE | ||||||
5 | -2010-12-16 | -F5 | +7 | +2010-08-04 | +V8 | +B_ESCHR_COL | +R | +S | +S | +S | +FALSE | +TRUE | +
8 | +2010-09-12 | +V8 | B_ESCHR_COL | S | S | @@ -704,34 +741,10 @@FALSE | TRUE | |||||
6 | -2011-02-23 | -F5 | -B_ESCHR_COL | -S | -S | -S | -S | -TRUE | -TRUE | -|||
7 | -2011-04-26 | -F5 | -B_ESCHR_COL | -S | -S | -S | -S | -FALSE | -FALSE | -|||
8 | -2011-08-01 | -F5 | +9 | +2010-10-03 | +V8 | B_ESCHR_COL | R | I | @@ -740,45 +753,32 @@FALSE | TRUE | ||
9 | -2011-09-09 | -F5 | -B_ESCHR_COL | -S | -S | -S | -S | -FALSE | -TRUE | -|||
10 | -2011-09-11 | -F5 | +2011-01-09 | +V8 | B_ESCHR_COL | -S | R | S | +R | S | FALSE | TRUE |
Instead of 2, now 9 isolates are flagged. In total, 78.9% of all isolates are marked ‘first weighted’ - 50.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.
+Instead of 1, now 8 isolates are flagged. In total, 78.9% of all isolates are marked ‘first weighted’ - 50.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 15,789 isolates for analysis.
+So we end up with 15,783 isolates for analysis.
We can remove unneeded columns:
+ select(-c(first, keyab))Now our data looks like:
date | patient_id | hospital | @@ -795,12 +795,41 @@|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2013-12-28 | -M2 | +2012-04-28 | +X6 | +Hospital B | +B_ESCHR_COL | +R | +S | +R | +S | +F | +Gram negative | +Escherichia | +coli | +TRUE | +||||||||
2012-12-23 | +Z1 | +Hospital A | +B_ESCHR_COL | +I | +S | +R | +S | +F | +Gram negative | +Escherichia | +coli | +TRUE | +|||||||||||
2011-05-27 | +G10 | Hospital B | B_STRPTC_PNE | -R | +S | S | S | R | @@ -811,13 +840,12 @@TRUE | ||||||||||||||
2 | -2017-03-17 | -Z5 | -Hospital B | +2012-08-19 | +Q1 | +Hospital D | B_ESCHR_COL | -R | S | +R | S | S | F | @@ -827,30 +855,28 @@TRUE | |||||||||
3 | -2011-05-13 | -G5 | -Hospital B | -B_STRPTC_PNE | -S | -S | -S | +2016-05-06 | +Y2 | +Hospital D | +B_KLBSL_PNE | R | -M | -Gram positive | -Streptococcus | +S | +S | +S | +F | +Gram negative | +Klebsiella | pneumoniae | TRUE |
5 | -2016-11-01 | -C9 | -Hospital D | +2010-08-27 | +I8 | +Hospital A | B_ESCHR_COL | R | S | -R | +S | S | M | Gram negative | @@ -858,38 +884,6 @@coli | TRUE | |||||||
6 | -2010-12-16 | -E2 | -Hospital A | -B_STRPTC_PNE | -S | -S | -S | -R | -M | -Gram positive | -Streptococcus | -pneumoniae | -TRUE | -||||||||||
7 | -2013-06-03 | -G1 | -Hospital A | -B_STRPTC_PNE | -R | -S | -S | -R | -M | -Gram positive | -Streptococcus | -pneumoniae | -TRUE | -
Time for the analysis!
@@ -907,9 +901,9 @@Or can be used like the dplyr
way, which is easier readable:
Frequency table of genus
and species
from a data.frame
(15,789 x 13)
-Columns: 2
-Length: 15,789 (of which NA: 0 = 0.00%)
+
Frequency table of genus
and species
from a data.frame
(15,783 x 13)
Columns: 2
+Length: 15,783 (of which NA: 0 = 0.00%)
Unique: 4
Shortest: 16
Longest: 24
The functions portion_R
, portion_RI
, portion_I
, portion_IS
and portion_S
can be used to determine the portion of a specific antimicrobial outcome. They can be used on their own:
Or can be used in conjuction with group_by()
and summarise()
, both from the dplyr
package:
Or can be used in conjuction with group_by()
and summarise()
, both from the dplyr
package:
hospital | @@ -976,26 +970,26 @@ Longest: 24||
---|---|---|
Hospital A | -0.4824505 | +0.4697326 |
Hospital B | -0.4689469 | +0.4770958 |
Hospital C | -0.4689858 | +0.4799670 |
Hospital D | -0.4772799 | +0.4785082 |
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):
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 = portion_IR(amox),
+ group_by(hospital) %>%
+ summarise(amoxicillin = portion_IR(amox),
available = n_rsi(amox))
Hospital A | -0.4824505 | -4701 | +0.4697326 | +4675 |
Hospital B | -0.4689469 | -5555 | +0.4770958 | +5523 |
Hospital C | -0.4689858 | -2386 | +0.4799670 | +2421 |
Hospital D | -0.4772799 | -3147 | +0.4785082 | +3164 |
These functions can also be used to get the portion of multiple antibiotics, to calculate co-resistance very easily:
data_1st %>%
- group_by(genus) %>%
- summarise(amoxicillin = portion_S(amcl),
+ group_by(genus) %>%
+ summarise(amoxicillin = portion_S(amcl),
gentamicin = portion_S(gent),
"amox + gent" = portion_S(amcl, gent))
Escherichia | -0.7303198 | -0.9056119 | -0.9745730 | +0.7345687 | +0.9051757 | +0.9773802 |
Klebsiella | -0.7343027 | -0.8955717 | -0.9643093 | +0.7307190 | +0.9071895 | +0.9771242 |
Staphylococcus | -0.7304946 | -0.9196838 | -0.9821520 | +0.7353606 | +0.9210857 | +0.9816537 |
Streptococcus | -0.7308142 | +0.7268273 | 0.0000000 | -0.7308142 | +0.7268273 |
To make a transition to the next part, let’s see how this difference could be plotted:
data_1st %>%
- group_by(genus) %>%
- summarise("1. Amoxicillin" = portion_S(amcl),
+ group_by(genus) %>%
+ summarise("1. Amoxicillin" = portion_S(amcl),
"2. Gentamicin" = portion_S(gent),
"3. Amox + gent" = portion_S(amcl, gent)) %>%
- tidyr::gather("Antibiotic", "S", -genus) %>%
- ggplot(aes(x = genus,
+ tidyr::gather("Antibiotic", "S", -genus) %>%
+ ggplot(aes(x = genus,
y = S,
fill = Antibiotic)) +
- geom_col(position = "dodge2")
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,
+ggplot(data = a_data_set,
+ mapping = aes(x = year,
y = value)) +
- geom_col() +
- labs(title = "A title",
+ geom_col() +
+ labs(title = "A title",
subtitle = "A subtitle",
x = "My X axis",
y = "My Y axis")
-ggplot(a_data_set,
- aes(year, value) +
- geom_bar()
+ggplot(a_data_set,
+ aes(year, value) +
+ geom_bar()
The AMR
package contains functions to extend this ggplot2
package, for example geom_rsi()
. It automatically transforms data with count_df()
or portion_df()
and show results in stacked bars. Its simplest and shortest example:
ggplot(data_1st) +
+
Omit the translate_ab = FALSE
to have the antibiotic codes (amox, amcl, cipr, gent) translated to official WHO names (amoxicillin, amoxicillin and betalactamase inhibitor, 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`)
@@ -1114,22 +1108,22 @@ Longest: 24
# show percentages on y axis
scale_y_percent(breaks = 0:4 * 25) +
# turn 90 degrees, make it bars instead of columns
- coord_flip() +
+ coord_flip() +
# add labels
- labs(title = "Resistance per genus and antibiotic",
+ 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) %>%
+ group_by(genus) %>%
ggplot_rsi(x = "genus",
facet = "Antibiotic",
breaks = 0:4 * 25,
datalabels = FALSE) +
- coord_flip()
We can transform the data and apply the test in only a couple of lines:
septic_patients %>%
- filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
- select(hospital_id, fosf) %>% # select the hospitals and fosfomycin
- group_by(hospital_id) %>% # group on the hospitals
+ filter(hospital_id %in% c("A", "D")) %>% # filter on only hospitals A and D
+ select(hospital_id, fosf) %>% # select the hospitals and fosfomycin
+ group_by(hospital_id) %>% # group on the hospitals
count_df(combine_IR = TRUE) %>% # count all isolates per group (hospital_id)
- tidyr::spread(hospital_id, Value) %>% # transform output so A and D are columns
- select(A, D) %>% # and select these only
+ tidyr::spread(hospital_id, Value) %>% # transform output so A and D are columns
+ select(A, D) %>% # and select these only
as.matrix() %>% # transform to good old matrix for fisher.test()
fisher.test() # do Fisher's Exact Test
#>
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 eef839e2..f78b6151 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 989e41bf..9b94b88c 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 4bda66c7..430bdd63 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 995be60a..13afa548 100644
Binary files a/docs/articles/AMR_files/figure-html/plot 5-1.png and b/docs/articles/AMR_files/figure-html/plot 5-1.png differ
diff --git a/docs/articles/EUCAST.html b/docs/articles/EUCAST.html
index 2187de6e..bc96c8ae 100644
--- a/docs/articles/EUCAST.html
+++ b/docs/articles/EUCAST.html
@@ -185,7 +185,7 @@
How to apply EUCAST rules
Matthijs S. Berends
- 11 February 2019
+ 12 February 2019
EUCAST.Rmd
diff --git a/docs/articles/atc_property.html b/docs/articles/atc_property.html
index 80e89e8f..4c63ca08 100644
--- a/docs/articles/atc_property.html
+++ b/docs/articles/atc_property.html
@@ -185,7 +185,7 @@
How to get properties of an antibiotic
Matthijs S. Berends
- 11 February 2019
+ 12 February 2019
atc_property.Rmd
diff --git a/docs/articles/mo_property.html b/docs/articles/mo_property.html
index b6d725b1..812e42df 100644
--- a/docs/articles/mo_property.html
+++ b/docs/articles/mo_property.html
@@ -185,7 +185,7 @@
How to get properties of a microorganism
Matthijs S. Berends
- 11 February 2019
+ 12 February 2019
mo_property.Rmd
diff --git a/docs/articles/resistance_predict.html b/docs/articles/resistance_predict.html
index 07ec214e..b547d194 100644
--- a/docs/articles/resistance_predict.html
+++ b/docs/articles/resistance_predict.html
@@ -185,7 +185,7 @@
How to predict antimicrobial resistance
Matthijs S. Berends
- 11 February 2019
+ 12 February 2019
resistance_predict.Rmd
@@ -295,7 +295,7 @@
Choosing the right model
Resistance is not easily predicted; if we look at vancomycin resistance in Gram positives, the spread (i.e. standard error) is enormous:
septic_patients %>%
- filter(mo_gramstain(mo) == "Gram positive") %>%
+ filter(mo_gramstain(mo) == "Gram positive") %>%
resistance_predict(col_ab = "vanc", year_min = 2010, info = FALSE) %>%
ggplot_rsi_predict()
#> NOTE: Using column `date` as input for `col_date`.
@@ -340,7 +340,7 @@
For the vancomycin resistance in Gram positive bacteria, a linear model might be more appropriate since no (left half of a) binomial distribution is to be expected based on the observed years:
septic_patients %>%
- filter(mo_gramstain(mo) == "Gram positive") %>%
+ filter(mo_gramstain(mo) == "Gram positive") %>%
resistance_predict(col_ab = "vanc", year_min = 2010, info = FALSE, model = "linear") %>%
ggplot_rsi_predict()
#> NOTE: Using column `date` as input for `col_date`.
diff --git a/docs/news/index.html b/docs/news/index.html
index 201f3864..e1dcf835 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -798,7 +798,7 @@ These functions use as.atc()
- Full support for Windows, Linux and macOS
- Full support for old R versions, only R-3.0.0 (April 2013) or later is needed (needed packages may have other dependencies)
-- Function
n_rsi
to count cases where antibiotic test results were available, to be used in conjunction with dplyr::summarise
, see ?rsi
+- Function
n_rsi
to count cases where antibiotic test results were available, to be used in conjunction with dplyr::summarise
, see ?rsi
- 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