diff --git a/articles/AMR_with_tidymodels.html b/articles/AMR_with_tidymodels.html index 636b16286..b7fc76811 100644 --- a/articles/AMR_with_tidymodels.html +++ b/articles/AMR_with_tidymodels.html @@ -142,7 +142,7 @@ package.

#> dplyr::filter() masks stats::filter() #> dplyr::lag() masks stats::lag() #> recipes::step() masks stats::step() -#> Use tidymodels_prefer() to resolve common conflicts. +#> Dig deeper into tidy modeling with R at https://www.tmwr.org library(AMR) # For AMR data analysis # Load the example_isolates dataset diff --git a/pkgdown.yml b/pkgdown.yml index f4307ed83..55fa3dc04 100644 --- a/pkgdown.yml +++ b/pkgdown.yml @@ -12,7 +12,7 @@ articles: resistance_predict: resistance_predict.html welcome_to_AMR: welcome_to_AMR.html WHONET: WHONET.html -last_built: 2025-02-11T07:53Z +last_built: 2025-02-11T16:27Z urls: reference: https://msberends.github.io/AMR/reference article: https://msberends.github.io/AMR/articles diff --git a/reference/as.sir.html b/reference/as.sir.html index 775d2c72c..918387f21 100644 --- a/reference/as.sir.html +++ b/reference/as.sir.html @@ -782,16 +782,16 @@ A microorganism is categorised as "Resistant" when there is a high likelihood of #> # A tibble: 57 × 16 #> datetime index ab_given mo_given host_given ab mo #> * <dttm> <int> <chr> <chr> <chr> <ab> <mo> -#> 1 2025-02-11 07:53:48 4 AMX B_STRPT… human AMX B_STRPT_PNMN -#> 2 2025-02-11 07:53:55 4 genta Escheri… human GEN B_[ORD]_ENTRBCTR -#> 3 2025-02-11 07:53:55 4 genta Escheri… human GEN B_[ORD]_ENTRBCTR -#> 4 2025-02-11 07:53:56 4 genta Escheri… cattle GEN B_ESCHR_COLI -#> 5 2025-02-11 07:53:56 4 genta Escheri… cattle GEN B_ESCHR_COLI -#> 6 2025-02-11 07:53:48 3 AMX B_STRPT… human AMX B_STRPT_PNMN -#> 7 2025-02-11 07:53:55 3 tobra Escheri… human TOB B_[ORD]_ENTRBCTR -#> 8 2025-02-11 07:53:55 3 tobra Escheri… human TOB B_[ORD]_ENTRBCTR -#> 9 2025-02-11 07:53:56 3 tobra Escheri… horses TOB B_ESCHR_COLI -#> 10 2025-02-11 07:53:56 3 tobra Escheri… horses TOB B_ESCHR_COLI +#> 1 2025-02-11 16:28:00 4 AMX B_STRPT… human AMX B_STRPT_PNMN +#> 2 2025-02-11 16:28:07 4 genta Escheri… human GEN B_[ORD]_ENTRBCTR +#> 3 2025-02-11 16:28:07 4 genta Escheri… human GEN B_[ORD]_ENTRBCTR +#> 4 2025-02-11 16:28:08 4 genta Escheri… cattle GEN B_ESCHR_COLI +#> 5 2025-02-11 16:28:08 4 genta Escheri… cattle GEN B_ESCHR_COLI +#> 6 2025-02-11 16:28:00 3 AMX B_STRPT… human AMX B_STRPT_PNMN +#> 7 2025-02-11 16:28:07 3 tobra Escheri… human TOB B_[ORD]_ENTRBCTR +#> 8 2025-02-11 16:28:07 3 tobra Escheri… human TOB B_[ORD]_ENTRBCTR +#> 9 2025-02-11 16:28:08 3 tobra Escheri… horses TOB B_ESCHR_COLI +#> 10 2025-02-11 16:28:08 3 tobra Escheri… horses TOB B_ESCHR_COLI #> # ℹ 47 more rows #> # ℹ 9 more variables: host <chr>, method <chr>, input <dbl>, outcome <sir>, #> # notes <chr>, guideline <chr>, ref_table <chr>, uti <lgl>, diff --git a/reference/plot-1.png b/reference/plot-1.png new file mode 100644 index 000000000..a230853be Binary files /dev/null and b/reference/plot-1.png differ diff --git a/reference/plot-10.png b/reference/plot-10.png new file mode 100644 index 000000000..8dec4586d Binary files /dev/null and b/reference/plot-10.png differ diff --git a/reference/plot-11.png b/reference/plot-11.png new file mode 100644 index 000000000..ed646966b Binary files /dev/null and b/reference/plot-11.png differ diff --git a/reference/plot-12.png b/reference/plot-12.png new file mode 100644 index 000000000..db924cdb7 Binary files /dev/null and b/reference/plot-12.png differ diff --git a/reference/plot-13.png b/reference/plot-13.png new file mode 100644 index 000000000..76ba6a5f3 Binary files /dev/null and b/reference/plot-13.png differ diff --git a/reference/plot-14.png b/reference/plot-14.png new file mode 100644 index 000000000..6ff1bad75 Binary files /dev/null and b/reference/plot-14.png differ diff --git a/reference/plot-15.png b/reference/plot-15.png new file mode 100644 index 000000000..4da34f2ca Binary files /dev/null and b/reference/plot-15.png differ diff --git a/reference/plot-16.png b/reference/plot-16.png new file mode 100644 index 000000000..4b437815c Binary files /dev/null and b/reference/plot-16.png differ diff --git a/reference/plot-17.png b/reference/plot-17.png new file mode 100644 index 000000000..879422043 Binary files /dev/null and b/reference/plot-17.png differ diff --git a/reference/plot-18.png b/reference/plot-18.png new file mode 100644 index 000000000..757b104c2 Binary files /dev/null and b/reference/plot-18.png differ diff --git a/reference/plot-19.png b/reference/plot-19.png new file mode 100644 index 000000000..231b81794 Binary files /dev/null and b/reference/plot-19.png differ diff --git a/reference/plot-2.png b/reference/plot-2.png new file mode 100644 index 000000000..babfa7890 Binary files /dev/null and b/reference/plot-2.png differ diff --git a/reference/plot-20.png b/reference/plot-20.png new file mode 100644 index 000000000..8c67ffa28 Binary files /dev/null and b/reference/plot-20.png differ diff --git a/reference/plot-3.png b/reference/plot-3.png new file mode 100644 index 000000000..c1d59d47d Binary files /dev/null and b/reference/plot-3.png differ diff --git a/reference/plot-4.png b/reference/plot-4.png new file mode 100644 index 000000000..88cbc6652 Binary files /dev/null and b/reference/plot-4.png differ diff --git a/reference/plot-5.png b/reference/plot-5.png new file mode 100644 index 000000000..f0d9422b3 Binary files /dev/null and b/reference/plot-5.png differ diff --git a/reference/plot-6.png b/reference/plot-6.png new file mode 100644 index 000000000..161e1fc1f Binary files /dev/null and b/reference/plot-6.png differ diff --git a/reference/plot-7.png b/reference/plot-7.png new file mode 100644 index 000000000..1611fd3e5 Binary files /dev/null and b/reference/plot-7.png differ diff --git a/reference/plot-8.png b/reference/plot-8.png new file mode 100644 index 000000000..17e45a612 Binary files /dev/null and b/reference/plot-8.png differ diff --git a/reference/plot-9.png b/reference/plot-9.png new file mode 100644 index 000000000..ef462b42e Binary files /dev/null and b/reference/plot-9.png differ diff --git a/reference/plot.html b/reference/plot.html index 6ef3a7f65..2efd83de7 100644 --- a/reference/plot.html +++ b/reference/plot.html @@ -271,7 +271,132 @@ Especially the scale_*_mic() functions are relevant wrappers to plot MIC values

Examples

- +
some_mic_values <- random_mic(size = 100)
+some_disk_values <- random_disk(size = 100, mo = "Escherichia coli", ab = "cipro")
+some_sir_values <- random_sir(50, prob_SIR = c(0.55, 0.05, 0.30))
+
+plot(some_mic_values)
+
+plot(some_disk_values)
+
+plot(some_sir_values)
+
+
+# when providing the microorganism and antibiotic, colours will show interpretations:
+plot(some_mic_values, mo = "S. aureus", ab = "ampicillin")
+
+plot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
+
+plot(some_disk_values, mo = "Escherichia coli", ab = "cipro", language = "nl")
+
+
+
+# Plotting using scale_x_mic() -----------------------------------------
+# \donttest{
+if (require("ggplot2")) {
+  mic_plot <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
+                                counts = c(1, 1, 2, 2, 3, 3)),
+                     aes(mics, counts)) +
+    geom_col()
+  mic_plot +
+    labs(title = "without scale_x_mic()")
+}
+
+if (require("ggplot2")) {
+  mic_plot +
+    scale_x_mic() +
+    labs(title = "with scale_x_mic()")
+}
+
+if (require("ggplot2")) {
+  mic_plot +
+    scale_x_mic(keep_operators = "all") +
+    labs(title = "with scale_x_mic() keeping all operators")
+}
+
+if (require("ggplot2")) {
+  mic_plot +
+    scale_x_mic(mic_range = c(1, 16)) +
+    labs(title = "with scale_x_mic() using a manual 'within' range")
+}
+
+if (require("ggplot2")) {
+  mic_plot +
+    scale_x_mic(mic_range = c(0.032, 256)) +
+    labs(title = "with scale_x_mic() using a manual 'outside' range")
+}
+
+
+# Plotting using scale_y_mic() -----------------------------------------
+some_groups <- sample(LETTERS[1:5], 20, replace = TRUE)
+if (require("ggplot2")) {
+  ggplot(data.frame(mic = some_mic_values,
+                    group = some_groups),
+         aes(group, mic)) +
+    geom_boxplot() +
+    geom_violin(linetype = 2, colour = "grey", fill = NA) +
+    scale_y_mic()
+}
+
+if (require("ggplot2")) {
+  ggplot(data.frame(mic = some_mic_values,
+                    group = some_groups),
+         aes(group, mic)) +
+    geom_boxplot() +
+    geom_violin(linetype = 2, colour = "grey", fill = NA) +
+    scale_y_mic(mic_range = c(NA, 2))
+}
+
+
+# Plotting using scale_fill_mic() -----------------------------------------
+some_counts <- as.integer(runif(20, 5, 50))
+if (require("ggplot2")) {
+  ggplot(data.frame(mic = some_mic_values,
+                   group = some_groups,
+                   counts = some_counts),
+         aes(group, counts, fill = mic)) +
+    geom_col() +
+    scale_fill_mic(mic_range = c(0.5, 16))
+}
+
+
+# Auto plotting --------------------------------------------------------
+if (require("ggplot2")) {
+  autoplot(some_mic_values)
+}
+
+if (require("ggplot2")) {
+  autoplot(some_disk_values, mo = "Escherichia coli", ab = "cipro")
+}
+
+if (require("ggplot2")) {
+  autoplot(some_sir_values)
+}
+
+
+# Plotting using scale_y_percent() -------------------------------------
+if (require("ggplot2")) {
+  p <- ggplot(data.frame(mics = as.mic(c(0.25, "<=4", 4, 8, 32, ">=32")),
+                               counts = c(1, 1, 2, 2, 3, 3)),
+                         aes(mics, counts / sum(counts))) +
+    geom_col()
+  print(p)
+  
+  p2 <- p +
+    scale_y_percent() +
+    theme_sir()
+  print(p2)
+  
+  p +
+    scale_y_percent(breaks = seq(from = 0, to = 1, by = 0.1),
+                    limits = c(0, 1)) +
+    theme_sir()
+}
+
+
+
+# }
+
diff --git a/reference/random.html b/reference/random.html index da5e9cd2d..34692929f 100644 --- a/reference/random.html +++ b/reference/random.html @@ -99,43 +99,43 @@

Examples

random_mic(25)
 #> Class 'mic'
-#>  [1] 64    0.001 >=256 0.001 0.005 8     8     1     16    0.002 >=256 16   
-#> [13] 4     64    0.002 0.001 0.25  64    0.025 64    0.025 1     0.001 16   
-#> [25] 0.5  
+#>  [1] 32     2      0.002  128    128    0.0625 32     4      128    0.0625
+#> [11] 0.5    0.025  256    4      16     0.025  0.025  4      256    0.5   
+#> [21] 8      4      0.005  4      0.01  
 random_disk(25)
 #> Class 'disk'
-#>  [1] 10 42 50 49 46 44 48 49 32 49 20 30 44 13 10 34 26 26 26 47 19 38 23 41 41
+#>  [1] 11 10 21 42 49 34 17 35 45 37 36 16 17 25 47 47 41 47 10  6 31 33 37 29 14
 random_sir(25)
 #> Class 'sir'
-#>  [1] R S S I I I I S S I S S R S S R S S R S R R R I I
+#>  [1] R S S I I S S S I R S R S I S I S S I S I S R S R
 
 # \donttest{
 # make the random generation more realistic by setting a bug and/or drug:
 random_mic(25, "Klebsiella pneumoniae") # range 0.0625-64
 #> Class 'mic'
-#>  [1] 0.125  0.5    128    64     8      0.0625 0.125  >=256  4      8     
-#> [11] 0.125  2      32     2      0.0625 0.125  64     0.025  64     8     
-#> [21] 0.002  8      0.025  1      4     
+#>  [1] 0.25   0.5    2      32     0.005  0.025  0.5    >=128  0.0625 0.25  
+#> [11] 0.0625 4      4      8      0.001  16     >=128  0.25   0.025  0.025 
+#> [21] 16     0.0625 0.0625 >=128  0.125 
 random_mic(25, "Klebsiella pneumoniae", "meropenem") # range 0.0625-16
 #> Class 'mic'
-#>  [1] 8    16   4    8    2    16   16   2    0.5  1    8    8    16   1    1   
-#> [16] 4    2    8    8    2    8    0.25 2    0.5  0.5 
+#>  [1] 1      1      16     4      32     0.5    8      8      8      8     
+#> [11] 0.5    <=0.25 2      32     0.5    4      32     0.5    <=0.25 16    
+#> [21] 2      8      <=0.25 8      8     
 random_mic(25, "Streptococcus pneumoniae", "meropenem") # range 0.0625-4
 #> Class 'mic'
-#>  [1] <=0.0625 0.25     8        2        0.25     1        4        2       
-#>  [9] 0.25     <=0.0625 0.5      8        0.25     0.5      4        0.125   
-#> [17] 2        0.25     4        4        0.25     <=0.0625 8        <=0.0625
-#> [25] <=0.0625
+#>  [1] 2     2     0.125 8     4     2     0.125 2     0.5   0.5   16    1    
+#> [13] 1     0.25  0.25  0.25  2     8     0.125 0.125 2     8     4     16   
+#> [25] 2    
 
 random_disk(25, "Klebsiella pneumoniae") # range 8-50
 #> Class 'disk'
-#>  [1] 40 43 38 39 15 49 39 10 47 43 30 38 15 26 16 24 32 16 36 47 35 11 45 42 41
+#>  [1] 25 17 40 14 34 35 40 45 18 35 24 42 48 45 19 31 45  9 35 26 30 26 48 10 15
 random_disk(25, "Klebsiella pneumoniae", "ampicillin") # range 11-17
 #> Class 'disk'
-#>  [1] 11 16 14 13 11 11 16 17 14 11 15 16 17 12 17 16 11 11 12 13 14 12 13 11 11
+#>  [1] 13 17 14 11 14 14 14 17 17 17 14 17 15 12 12 12 15 16 17 14 16 14 13 12 16
 random_disk(25, "Streptococcus pneumoniae", "ampicillin") # range 12-27
 #> Class 'disk'
-#>  [1] 19 25 18 20 25 16 15 25 19 25 27 19 25 20 23 21 17 19 25 25 22 24 17 22 21
+#>  [1] 26 20 18 27 18 15 18 17 16 20 24 21 25 21 25 18 23 25 17 24 17 16 20 18 25
 # }
 
diff --git a/reference/skewness.html b/reference/skewness.html index 5d6af1c90..490fc8c1b 100644 --- a/reference/skewness.html +++ b/reference/skewness.html @@ -89,7 +89,7 @@ When negative ('left-skewed'): the left tail is longer; the mass of the distribu

Examples

skewness(runif(1000))
-#> [1] 0.03714722
+#> [1] 0.01209417