sir <- random_sir(10)
sir
#> Class <sir>
-#> [1] S I I I I I R R I R
+#> [1] R S I R R I S R I R
mean_amr_distance(sir)
-#> [1] -0.621059 -0.621059 -0.621059 -0.621059 -0.621059 -0.621059 1.449138
-#> [8] 1.449138 -0.621059 1.449138
+#> [1] 0.9486833 -0.9486833 -0.9486833 0.9486833 0.9486833 -0.9486833
+#> [7] -0.9486833 0.9486833 -0.9486833 0.9486833
mic <- random_mic(10)
mic
#> Class <mic>
-#> [1] 0.5 0.008 0.001 0.0001 0.064 0.0002 0.064 0.0001 0.032 1
+#> [1] 0.0002 0.032 0.002 8 <=0.0001 0.001 0.5 <=0.0001
+#> [9] 0.002 0.002
mean_amr_distance(mic)
-#> [1] 1.198191624 0.000686808 -0.601499640 -1.268306334 0.602873256
-#> [6] -1.067577518 0.602873256 -1.268306334 0.402144440 1.398920440
+#> [1] -0.8220689 0.5401854 -0.2040199 2.0222300 -1.0081203 -0.3900712
+#> [7] 1.2780248 -1.0081203 -0.2040199 -0.2040199
# equal to the Z-score of their log2:
(log2(mic) - mean(log2(mic))) / sd(log2(mic))
-#> [1] 1.198191624 0.000686808 -0.601499640 -1.268306334 0.602873256
-#> [6] -1.067577518 0.602873256 -1.268306334 0.402144440 1.398920440
+#> [1] -0.8220689 0.5401854 -0.2040199 2.0222300 -1.0081203 -0.3900712
+#> [7] 1.2780248 -1.0081203 -0.2040199 -0.2040199
disk <- random_disk(10)
disk
#> Class <disk>
-#> [1] 38 37 42 30 40 24 45 36 49 44
+#> [1] 49 26 48 42 31 50 13 43 50 35
mean_amr_distance(disk)
-#> [1] -0.06786705 -0.20360115 0.47506935 -1.15373986 0.20360115 -1.96814446
-#> [7] 0.88227166 -0.33933525 1.42520806 0.74653756
+#> [1] 0.8341912 -1.0285658 0.7532018 0.2672651 -0.6236187 0.9151806
+#> [7] -2.0814285 0.3482546 0.9151806 -0.2996609
y <- data.frame(
id = LETTERS[1:10],
@@ -144,35 +145,35 @@
)
y
#> id amox cipr gent tobr
-#> 1 A I 30 16 >=8
-#> 2 B R 30 <=8 4
-#> 3 C I 28 <=8 4
-#> 4 D I 24 <=8 >=8
-#> 5 E I 28 <=8 4
-#> 6 F S 30 <=8 4
-#> 7 G I 28 <=8 4
-#> 8 H S 31 <=8 >=8
-#> 9 I R 26 <=8 4
-#> 10 J I 28 <=8 >=8
+#> 1 A S 24 4 2
+#> 2 B I 27 4 2
+#> 3 C S 18 4 2
+#> 4 D S 30 4 <=1
+#> 5 E I 23 4 2
+#> 6 F I 19 4 2
+#> 7 G R 23 4 <=1
+#> 8 H I 28 4 <=1
+#> 9 I R 28 4 <=1
+#> 10 J I 26 4 <=1
mean_amr_distance(y)
#> ℹ Calculating mean AMR distance based on columns "amox", "cipr", "gent", and
#> "tobr"
-#> [1] 1.08474449 0.40297922 -0.42682276 -0.41644967 -0.42682276 -0.18994784
-#> [7] -0.42682276 0.41261253 -0.07077061 0.05730016
+#> [1] 0.10747691 0.36066176 -0.39889277 -0.01860893 0.02308197 -0.31449782
+#> [7] 0.18119585 -0.18739883 0.60317059 -0.35618872
y$amr_distance <- mean_amr_distance(y, is.mic(y))
#> ℹ Calculating mean AMR distance based on columns "gent" and "tobr"
y[order(y$amr_distance), ]
#> id amox cipr gent tobr amr_distance
-#> 2 B R 30 <=8 4 -0.5454122
-#> 3 C I 28 <=8 4 -0.5454122
-#> 5 E I 28 <=8 4 -0.5454122
-#> 6 F S 30 <=8 4 -0.5454122
-#> 7 G I 28 <=8 4 -0.5454122
-#> 9 I R 26 <=8 4 -0.5454122
-#> 4 D I 24 <=8 >=8 0.4228336
-#> 8 H S 31 <=8 >=8 0.4228336
-#> 10 J I 28 <=8 >=8 0.4228336
-#> 1 A I 30 16 >=8 2.0039724
+#> 4 D S 30 4 <=1 -0.9486833
+#> 7 G R 23 4 <=1 -0.9486833
+#> 8 H I 28 4 <=1 -0.9486833
+#> 9 I R 28 4 <=1 -0.9486833
+#> 10 J I 26 4 <=1 -0.9486833
+#> 1 A S 24 4 2 0.9486833
+#> 2 B I 27 4 2 0.9486833
+#> 3 C S 18 4 2 0.9486833
+#> 5 E I 23 4 2 0.9486833
+#> 6 F I 19 4 2 0.9486833
if (require("dplyr")) {
y %>%
@@ -185,16 +186,16 @@
#> ℹ Calculating mean AMR distance based on columns "amox", "cipr", "gent", and
#> "tobr"
#> id amox cipr gent tobr amr_distance check_id_C
-#> 1 C I 28 <=8 4 -0.42682276 0.00000000
-#> 2 E I 28 <=8 4 -0.42682276 0.00000000
-#> 3 G I 28 <=8 4 -0.42682276 0.00000000
-#> 4 D I 24 <=8 >=8 -0.41644967 0.01037309
-#> 5 F S 30 <=8 4 -0.18994784 0.23687492
-#> 6 I R 26 <=8 4 -0.07077061 0.35605215
-#> 7 J I 28 <=8 >=8 0.05730016 0.48412292
-#> 8 B R 30 <=8 4 0.40297922 0.82980198
-#> 9 H S 31 <=8 >=8 0.41261253 0.83943529
-#> 10 A I 30 16 >=8 1.08474449 1.51156725
+#> 1 C S 18 4 2 -0.39889277 0.00000000
+#> 2 J I 26 4 <=1 -0.35618872 0.04270405
+#> 3 F I 19 4 2 -0.31449782 0.08439495
+#> 4 H I 28 4 <=1 -0.18739883 0.21149394
+#> 5 D S 30 4 <=1 -0.01860893 0.38028384
+#> 6 E I 23 4 2 0.02308197 0.42197474
+#> 7 A S 24 4 2 0.10747691 0.50636968
+#> 8 G R 23 4 <=1 0.18119585 0.58008862
+#> 9 B I 27 4 2 0.36066176 0.75955453
+#> 10 I R 28 4 <=1 0.60317059 1.00206336
if (require("dplyr")) {
# support for groups
example_isolates %>%
diff --git a/reference/mean_amr_distance.md b/reference/mean_amr_distance.md
index af9696d08..d5027a8da 100644
--- a/reference/mean_amr_distance.md
+++ b/reference/mean_amr_distance.md
@@ -85,30 +85,31 @@ suspicious.
sir <- random_sir(10)
sir
#> Class
-#> [1] S I I I I I R R I R
+#> [1] R S I R R I S R I R
mean_amr_distance(sir)
-#> [1] -0.621059 -0.621059 -0.621059 -0.621059 -0.621059 -0.621059 1.449138
-#> [8] 1.449138 -0.621059 1.449138
+#> [1] 0.9486833 -0.9486833 -0.9486833 0.9486833 0.9486833 -0.9486833
+#> [7] -0.9486833 0.9486833 -0.9486833 0.9486833
mic <- random_mic(10)
mic
#> Class
-#> [1] 0.5 0.008 0.001 0.0001 0.064 0.0002 0.064 0.0001 0.032 1
+#> [1] 0.0002 0.032 0.002 8 <=0.0001 0.001 0.5 <=0.0001
+#> [9] 0.002 0.002
mean_amr_distance(mic)
-#> [1] 1.198191624 0.000686808 -0.601499640 -1.268306334 0.602873256
-#> [6] -1.067577518 0.602873256 -1.268306334 0.402144440 1.398920440
+#> [1] -0.8220689 0.5401854 -0.2040199 2.0222300 -1.0081203 -0.3900712
+#> [7] 1.2780248 -1.0081203 -0.2040199 -0.2040199
# equal to the Z-score of their log2:
(log2(mic) - mean(log2(mic))) / sd(log2(mic))
-#> [1] 1.198191624 0.000686808 -0.601499640 -1.268306334 0.602873256
-#> [6] -1.067577518 0.602873256 -1.268306334 0.402144440 1.398920440
+#> [1] -0.8220689 0.5401854 -0.2040199 2.0222300 -1.0081203 -0.3900712
+#> [7] 1.2780248 -1.0081203 -0.2040199 -0.2040199
disk <- random_disk(10)
disk
#> Class
-#> [1] 38 37 42 30 40 24 45 36 49 44
+#> [1] 49 26 48 42 31 50 13 43 50 35
mean_amr_distance(disk)
-#> [1] -0.06786705 -0.20360115 0.47506935 -1.15373986 0.20360115 -1.96814446
-#> [7] 0.88227166 -0.33933525 1.42520806 0.74653756
+#> [1] 0.8341912 -1.0285658 0.7532018 0.2672651 -0.6236187 0.9151806
+#> [7] -2.0814285 0.3482546 0.9151806 -0.2996609
y <- data.frame(
id = LETTERS[1:10],
@@ -119,35 +120,35 @@ y <- data.frame(
)
y
#> id amox cipr gent tobr
-#> 1 A I 30 16 >=8
-#> 2 B R 30 <=8 4
-#> 3 C I 28 <=8 4
-#> 4 D I 24 <=8 >=8
-#> 5 E I 28 <=8 4
-#> 6 F S 30 <=8 4
-#> 7 G I 28 <=8 4
-#> 8 H S 31 <=8 >=8
-#> 9 I R 26 <=8 4
-#> 10 J I 28 <=8 >=8
+#> 1 A S 24 4 2
+#> 2 B I 27 4 2
+#> 3 C S 18 4 2
+#> 4 D S 30 4 <=1
+#> 5 E I 23 4 2
+#> 6 F I 19 4 2
+#> 7 G R 23 4 <=1
+#> 8 H I 28 4 <=1
+#> 9 I R 28 4 <=1
+#> 10 J I 26 4 <=1
mean_amr_distance(y)
#> ℹ Calculating mean AMR distance based on columns "amox", "cipr", "gent", and
#> "tobr"
-#> [1] 1.08474449 0.40297922 -0.42682276 -0.41644967 -0.42682276 -0.18994784
-#> [7] -0.42682276 0.41261253 -0.07077061 0.05730016
+#> [1] 0.10747691 0.36066176 -0.39889277 -0.01860893 0.02308197 -0.31449782
+#> [7] 0.18119585 -0.18739883 0.60317059 -0.35618872
y$amr_distance <- mean_amr_distance(y, is.mic(y))
#> ℹ Calculating mean AMR distance based on columns "gent" and "tobr"
y[order(y$amr_distance), ]
#> id amox cipr gent tobr amr_distance
-#> 2 B R 30 <=8 4 -0.5454122
-#> 3 C I 28 <=8 4 -0.5454122
-#> 5 E I 28 <=8 4 -0.5454122
-#> 6 F S 30 <=8 4 -0.5454122
-#> 7 G I 28 <=8 4 -0.5454122
-#> 9 I R 26 <=8 4 -0.5454122
-#> 4 D I 24 <=8 >=8 0.4228336
-#> 8 H S 31 <=8 >=8 0.4228336
-#> 10 J I 28 <=8 >=8 0.4228336
-#> 1 A I 30 16 >=8 2.0039724
+#> 4 D S 30 4 <=1 -0.9486833
+#> 7 G R 23 4 <=1 -0.9486833
+#> 8 H I 28 4 <=1 -0.9486833
+#> 9 I R 28 4 <=1 -0.9486833
+#> 10 J I 26 4 <=1 -0.9486833
+#> 1 A S 24 4 2 0.9486833
+#> 2 B I 27 4 2 0.9486833
+#> 3 C S 18 4 2 0.9486833
+#> 5 E I 23 4 2 0.9486833
+#> 6 F I 19 4 2 0.9486833
if (require("dplyr")) {
y %>%
@@ -160,16 +161,16 @@ if (require("dplyr")) {
#> ℹ Calculating mean AMR distance based on columns "amox", "cipr", "gent", and
#> "tobr"
#> id amox cipr gent tobr amr_distance check_id_C
-#> 1 C I 28 <=8 4 -0.42682276 0.00000000
-#> 2 E I 28 <=8 4 -0.42682276 0.00000000
-#> 3 G I 28 <=8 4 -0.42682276 0.00000000
-#> 4 D I 24 <=8 >=8 -0.41644967 0.01037309
-#> 5 F S 30 <=8 4 -0.18994784 0.23687492
-#> 6 I R 26 <=8 4 -0.07077061 0.35605215
-#> 7 J I 28 <=8 >=8 0.05730016 0.48412292
-#> 8 B R 30 <=8 4 0.40297922 0.82980198
-#> 9 H S 31 <=8 >=8 0.41261253 0.83943529
-#> 10 A I 30 16 >=8 1.08474449 1.51156725
+#> 1 C S 18 4 2 -0.39889277 0.00000000
+#> 2 J I 26 4 <=1 -0.35618872 0.04270405
+#> 3 F I 19 4 2 -0.31449782 0.08439495
+#> 4 H I 28 4 <=1 -0.18739883 0.21149394
+#> 5 D S 30 4 <=1 -0.01860893 0.38028384
+#> 6 E I 23 4 2 0.02308197 0.42197474
+#> 7 A S 24 4 2 0.10747691 0.50636968
+#> 8 G R 23 4 <=1 0.18119585 0.58008862
+#> 9 B I 27 4 2 0.36066176 0.75955453
+#> 10 I R 28 4 <=1 0.60317059 1.00206336
if (require("dplyr")) {
# support for groups
example_isolates %>%
diff --git a/reference/microorganisms.codes.html b/reference/microorganisms.codes.html
index 7c261486f..ef8fa5b5f 100644
--- a/reference/microorganisms.codes.html
+++ b/reference/microorganisms.codes.html
@@ -7,7 +7,7 @@
AMR (for R)
- 3.0.1.9152
+ 3.0.1.9153
diff --git a/reference/random.md b/reference/random.md
index 84171994d..762a9163d 100644
--- a/reference/random.md
+++ b/reference/random.md
@@ -111,16 +111,16 @@ the `skew` and `severity` arguments:
``` r
random_mic(25)
#> Class