diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0cb9ad16..f57d3bae 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,6 +64,7 @@ R: variables: WARNINGS_ARE_ERRORS: 1 script: + - export WARNINGS_ARE_ERRORS=1 # remove vignettes folder and get VignetteBuilder field out of DESCRIPTION file - rm -rf vignettes - Rscript -e 'd <- read.dcf("DESCRIPTION"); d[, colnames(d) == "VignetteBuilder"] <- NA; write.dcf(d, "DESCRIPTION")' @@ -81,6 +82,7 @@ coverage: allow_failure: true when: on_success only: + - premaster - master script: - apt-get install --yes git diff --git a/DESCRIPTION b/DESCRIPTION index 5c62f9b3..ca95dab4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: AMR Version: 0.5.0.9020 -Date: 2019-02-28 +Date: 2019-03-01 Title: Antimicrobial Resistance Analysis Authors@R: c( person( diff --git a/R/mo.R b/R/mo.R index a1b38299..f3418b14 100755 --- a/R/mo.R +++ b/R/mo.R @@ -117,6 +117,7 @@ #' @seealso \code{\link{microorganisms}} for the \code{data.frame} that is being used to determine ID's. \cr #' The \code{\link{mo_property}} functions (like \code{\link{mo_genus}}, \code{\link{mo_gramstain}}) to get properties based on the returned code. #' @inheritSection AMR Read more on our website! +#' @importFrom dplyr %>% pull left_join #' @examples #' # These examples all return "B_STPHY_AUR", the ID of S. aureus: #' as.mo("stau") @@ -171,16 +172,28 @@ as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, # check onLoad() in R/zzz.R: data tables are created there. } - if (all(x %in% AMR::microorganisms$mo) + if (deparse(substitute(reference_df)) == "get_mo_source()" & isFALSE(Becker) & isFALSE(Lancefield) - & is.null(reference_df)) { + & !is.null(reference_df) + & all(x %in% reference_df[,1])) { + # has valid own reference_df + # (data.table not faster here) + colnames(reference_df)[1] <- "x" + suppressWarnings( + y <- data.frame(x = x, stringsAsFactors = FALSE) %>% + left_join(reference_df, by = "x") %>% + pull("mo") + ) + + } else if (all(x %in% AMR::microorganisms$mo) + & isFALSE(Becker) + & isFALSE(Lancefield)) { y <- x } else if (all(tolower(x) %in% microorganismsDT$fullname_lower) & isFALSE(Becker) - & isFALSE(Lancefield) - & is.null(reference_df)) { + & isFALSE(Lancefield)) { # we need special treatment for very prevalent full names, they are likely! (case insensitive) # e.g. as.mo("Staphylococcus aureus") y <- microorganismsDT[prevalence == 1][data.table(fullname_lower = tolower(x)), diff --git a/R/mo_source.R b/R/mo_source.R index 43a4fd29..4a3ae099 100644 --- a/R/mo_source.R +++ b/R/mo_source.R @@ -52,15 +52,19 @@ #' # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. #' } #' -#' It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression. +#' It has now created a file "~/.mo_source.rds" with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept. #' #' And now we can use it in our functions: #' \preformatted{ #' as.mo("lab_mo_ecoli") -#' # B_ESCHR_COL +#' [1] B_ESCHR_COL #' #' mo_genus("lab_mo_kpneumoniae") -#' # "Klebsiella" +#' [1] "Klebsiella" +#' +#' # other input values still work too +#' as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli")) +#' [1] B_ESCHR_COL B_ESCHR_COL B_ESCHR_COL #' } #' #' If we edit the Excel file to, let's say, this: @@ -78,10 +82,10 @@ #' \preformatted{ #' as.mo("lab_mo_ecoli") #' # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -#' # B_ESCHR_COL +#' [1] B_ESCHR_COL #' #' mo_genus("lab_Staph_aureus") -#' # "Staphylococcus" +#' [1] "Staphylococcus" #' } #' #' To remove the reference completely, just use any of these: @@ -119,7 +123,9 @@ set_mo_source <- function(path) { valid <- FALSE } else if (!"mo" %in% colnames(df)) { valid <- FALSE - } else if (!all(df$mo %in% AMR::microorganisms$mo)) { + } else if (all(as.data.frame(df)[, 1] == "")) { + valid <- FALSE + } else if (!all(df$mo %in% c("", AMR::microorganisms$mo))) { valid <- FALSE } else if (NCOL(df) < 2) { valid <- FALSE @@ -163,9 +169,11 @@ set_mo_source <- function(path) { stop("File must contain a column with self-defined values and a reference column `mo` with valid values from the `microorganisms` data set.") } + # keep only first two columns, second must be mo if (colnames(df)[1] == "mo") { - # put mo to the end - df <- df %>% select(-"mo", everything(), "mo") + df <- df[, c(2, 1)] + } else { + df <- df[, c(1, 2)] } df <- as.data.frame(df, stringAsFactors = FALSE) diff --git a/appveyor.yml b/appveyor.yml index 2ee5ffa3..6d0eeea6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,8 +55,8 @@ on_failure: - 7z a failure.zip *.Rcheck\* - appveyor PushArtifact failure.zip -on_success: - - Rscript -e "library(covr); cc <- package_coverage(); codecov(coverage = cc, token = '50ffa0aa-fee0-4f8b-a11d-8c7edc6d32ca'); cat('Code coverage:', percent_coverage(cc))" +#on_success: +# - Rscript -e "library(covr); cc <- package_coverage(); codecov(coverage = cc, token = '50ffa0aa-fee0-4f8b-a11d-8c7edc6d32ca'); cat('Code coverage:', percent_coverage(cc))" artifacts: - path: '*.Rcheck\**\*.log' diff --git a/docs/articles/AMR.html b/docs/articles/AMR.html index 31d7506c..ba2b021f 100644 --- a/docs/articles/AMR.html +++ b/docs/articles/AMR.html @@ -192,7 +192,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 28 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 01 March 2019.
Now, let’s start the cleaning and the analysis!
@@ -411,8 +411,8 @@ #> #> Item Count Percent Cum. Count Cum. Percent #> --- ----- ------- -------- ----------- ------------- -#> 1 M 10,244 51.2% 10,244 51.2% -#> 2 F 9,756 48.8% 20,000 100.0% +#> 1 M 10,311 51.6% 10,311 51.6% +#> 2 F 9,689 48.4% 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:
data <- data %>%
@@ -443,10 +443,10 @@
#> Kingella kingae (no changes)
#>
#> EUCAST Expert Rules, Intrinsic Resistance and Exceptional Phenotypes (v3.1, 2016)
-#> Table 1: Intrinsic resistance in Enterobacteriaceae (1275 changes)
+#> Table 1: Intrinsic resistance in Enterobacteriaceae (1364 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 (2727 changes)
+#> Table 4: Intrinsic resistance in Gram-positive bacteria (2659 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)
@@ -462,9 +462,9 @@
#> Non-EUCAST: piperacillin/tazobactam = S where piperacillin = S (no changes)
#> Non-EUCAST: trimethoprim/sulfa = S where trimethoprim = S (no changes)
#>
-#> => EUCAST rules affected 7,427 out of 20,000 rows
+#> => EUCAST rules affected 7,366 out of 20,000 rows
#> -> added 0 test results
-#> -> changed 4,002 test results (0 to S; 0 to I; 4,002 to R)
So only 28.3% is suitable for resistance analysis! We can now filter on it with the filter()
function, also from the dplyr
package:
So only 28.2% 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:
isolate | @@ -654,8 +654,8 @@|||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | -2010-04-26 | -H9 | +2010-01-14 | +K8 | B_ESCHR_COL | R | S | @@ -666,10 +666,10 @@||||||||
2 | -2010-05-27 | -H9 | +2010-02-17 | +K8 | B_ESCHR_COL | -S | +R | S | R | S | @@ -678,20 +678,20 @@|||||
3 | -2010-07-20 | -H9 | +2010-03-01 | +K8 | B_ESCHR_COL | -R | -I | S | S | +R | +S | FALSE | TRUE | ||
4 | -2010-11-25 | -H9 | +2010-03-11 | +K8 | B_ESCHR_COL | S | S | @@ -702,83 +702,83 @@||||||||
5 | -2011-01-19 | -H9 | +2010-04-13 | +K8 | B_ESCHR_COL | +R | S | -S | -S | -S | -FALSE | +R | +R | FALSE | +TRUE |
6 | -2011-01-24 | -H9 | +2010-08-30 | +K8 | B_ESCHR_COL | S | S | -S | +R | S | FALSE | -FALSE | +TRUE | ||
7 | -2011-03-09 | -H9 | +2010-11-05 | +K8 | B_ESCHR_COL | -R | S | -R | +S | +S | S | FALSE | TRUE | ||
8 | -2011-06-07 | -H9 | +2010-12-21 | +K8 | B_ESCHR_COL | S | S | S | S | -TRUE | -TRUE | +FALSE | +FALSE | ||
9 | -2011-07-30 | -H9 | +2010-12-21 | +K8 | B_ESCHR_COL | -S | +R | S | S | S | FALSE | -FALSE | +TRUE | ||
10 | -2011-08-01 | -H9 | +2011-03-20 | +K8 | B_ESCHR_COL | S | S | +R | S | -S | -FALSE | -FALSE | +TRUE | +TRUE |
Instead of 2, now 6 isolates are flagged. In total, 79.1% of all isolates are marked ‘first weighted’ - 50.8% more than when using the CLSI guideline. In real life, this novel algorithm will yield 5-10% more isolates than the classic CLSI guideline.
+Instead of 2, now 9 isolates are flagged. In total, 78.7% of all isolates are marked ‘first weighted’ - 50.5% 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,814 isolates for analysis.
+So we end up with 15,738 isolates for analysis.
We can remove unneeded columns:
@@ -804,24 +804,72 @@Or can be used like the dplyr
way, which is easier readable:
Frequency table of genus
and species
from a data.frame
(15,814 x 13)
Frequency table of genus
and species
from a data.frame
(15,738 x 13)
Columns: 2
-Length: 15,814 (of which NA: 0 = 0.00%)
+Length: 15,738 (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:
data_1st %>%
group_by(hospital) %>%
@@ -984,19 +984,19 @@ Longest: 24
Hospital A
-0.4752371
+0.4800594
Hospital B
-0.4825898
+0.4737983
Hospital C
-0.4705631
+0.4763514
Hospital D
-0.4711928
+0.4724536
@@ -1014,23 +1014,23 @@ Longest: 24
Hospital A
-0.4752371
-4745
+0.4800594
+4714
Hospital B
-0.4825898
-5514
+0.4737983
+5534
Hospital C
-0.4705631
-2344
+0.4763514
+2368
Hospital D
-0.4711928
-3211
+0.4724536
+3122
@@ -1050,27 +1050,27 @@ Longest: 24
Escherichia
-0.7346552
-0.8993433
-0.9744885
+0.7283810
+0.9015873
+0.9751111
Klebsiella
-0.7406230
-0.9020979
-0.9726637
+0.7311622
+0.9157088
+0.9750958
Staphylococcus
-0.7322122
-0.9210867
-0.9785252
+0.7251732
+0.9230177
+0.9799846
Streptococcus
-0.7135883
+0.7345833
0.0000000
-0.7135883
+0.7345833
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 f5356f1b..e2bd8a99 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 87d6b07b..dc4fe583 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 28e02068..44face47 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 6e6cfd89..0390712c 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 7479f23d..296ccfa7 100644
--- a/docs/articles/EUCAST.html
+++ b/docs/articles/EUCAST.html
@@ -192,7 +192,7 @@
How to apply EUCAST rules
Matthijs S. Berends
- 28 February 2019
+ 01 March 2019
EUCAST.Rmd
diff --git a/docs/articles/G_test.html b/docs/articles/G_test.html
index 1f505187..7d2bafa2 100644
--- a/docs/articles/G_test.html
+++ b/docs/articles/G_test.html
@@ -192,7 +192,7 @@
How to use the G-test
Matthijs S. Berends
- 28 February 2019
+ 01 March 2019
G_test.Rmd
diff --git a/docs/articles/WHONET.html b/docs/articles/WHONET.html
index b249cb45..a5dbd596 100644
--- a/docs/articles/WHONET.html
+++ b/docs/articles/WHONET.html
@@ -192,7 +192,7 @@
How to work with WHONET data
Matthijs S. Berends
- 28 February 2019
+ 01 March 2019
WHONET.Rmd
diff --git a/docs/articles/atc_property.html b/docs/articles/atc_property.html
index b984a7a0..417e88ea 100644
--- a/docs/articles/atc_property.html
+++ b/docs/articles/atc_property.html
@@ -192,7 +192,7 @@
How to get properties of an antibiotic
Matthijs S. Berends
- 28 February 2019
+ 01 March 2019
atc_property.Rmd
diff --git a/docs/articles/benchmarks.html b/docs/articles/benchmarks.html
index a035fb11..151dfbe7 100644
--- a/docs/articles/benchmarks.html
+++ b/docs/articles/benchmarks.html
@@ -192,7 +192,7 @@
Benchmarks
Matthijs S. Berends
- 28 February 2019
+ 01 March 2019
benchmarks.Rmd
@@ -217,14 +217,14 @@
times = 10)
print(S.aureus, unit = "ms", signif = 3)
#> Unit: milliseconds
-#> expr min lq mean median uq max neval
-#> as.mo("sau") 16.70 16.80 17.10 16.90 17.20 18.4 10
-#> as.mo("stau") 31.70 31.80 48.90 31.90 73.00 117.0 10
-#> as.mo("staaur") 16.70 16.80 23.10 16.90 17.90 76.0 10
-#> as.mo("STAAUR") 16.80 17.00 33.20 18.20 56.00 58.6 10
-#> as.mo("S. aureus") 24.60 24.70 29.00 24.70 25.30 65.8 10
-#> as.mo("S. aureus") 24.60 24.70 29.20 24.80 25.10 67.4 10
-#> as.mo("Staphylococcus aureus") 7.02 7.11 7.73 7.26 7.33 11.9 10
In the table above, all measurements are shown in milliseconds (thousands of seconds). A value of 5 milliseconds means it can determine 200 input values per second. It case of 100 milliseconds, this is only 10 input values per second. The second input is the only one that has to be looked up thoroughly. All the others are known codes (the first one is a WHONET code) or common laboratory codes, or common full organism names like the last one. Full organism names are always preferred.
To achieve this speed, the as.mo
function also takes into account the prevalence of human pathogenic microorganisms. The downside is of course that less prevalent microorganisms will be determined less fast. See this example for the ID of Thermus islandicus (B_THERMS_ISL
), a bug probably never found before in humans:
T.islandicus <- microbenchmark(as.mo("theisl"),
@@ -236,12 +236,12 @@
print(T.islandicus, unit = "ms", signif = 3)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> as.mo("theisl") 262.0 292.0 296.0 304.0 310 312 10
-#> as.mo("THEISL") 261.0 263.0 286.0 288.0 307 311 10
-#> as.mo("T. islandicus") 142.0 143.0 164.0 165.0 184 187 10
-#> as.mo("T. islandicus") 142.0 143.0 170.0 163.0 192 229 10
-#> as.mo("Thermus islandicus") 67.7 68.1 94.3 89.4 117 132 10
That takes 7.5 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Thermus islandicus) are almost fast - these are the most probable input from most data sets.
+#> as.mo("theisl") 262.0 264.0 297.0 306 310 376 10 +#> as.mo("THEISL") 262.0 265.0 292.0 290 308 355 10 +#> as.mo("T. islandicus") 142.0 142.0 161.0 148 185 186 10 +#> as.mo("T. islandicus") 141.0 142.0 184.0 174 188 340 10 +#> as.mo("Thermus islandicus") 68.4 68.8 96.3 110 115 125 10 +That takes 8 times as much time on average. A value of 100 milliseconds means it can only determine ~10 different input values per second. We can conclude that looking up arbitrary codes of less prevalent microorganisms is the worst way to go, in terms of calculation performance. Full names (like Thermus islandicus) are almost fast - these are the most probable input from most data sets.
In the figure below, we compare Escherichia coli (which is very common) with Prevotella brevis (which is moderately common) and with Thermus islandicus (which is very uncommon):
par(mar = c(5, 16, 4, 2)) # set more space for left margin text (16)
@@ -287,8 +287,8 @@
print(run_it, unit = "ms", signif = 3)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> mo_fullname(x) 732 739 818 819 837 1040 10
So transforming 500,000 values (!!) of 50 unique values only takes 0.82 seconds (818 ms). You only lose time on your unique input values.
+#> mo_fullname(x) 723 731 797 785 807 1010 10 +So transforming 500,000 values (!!) of 50 unique values only takes 0.78 seconds (784 ms). You only lose time on your unique input values.
So going from mo_fullname("Staphylococcus aureus")
to "Staphylococcus aureus"
takes 0.0006 seconds - it doesn’t even start calculating if the result would be the same as the expected resulting value. That goes for all helper functions:
run_it <- microbenchmark(A = mo_species("aureus"),
B = mo_genus("Staphylococcus"),
@@ -317,14 +317,14 @@
print(run_it, unit = "ms", signif = 3)
#> Unit: milliseconds
#> expr min lq mean median uq max neval
-#> A 0.308 0.392 0.419 0.406 0.478 0.524 10
-#> B 0.377 0.406 0.424 0.418 0.442 0.486 10
-#> C 0.359 0.516 0.580 0.574 0.664 0.730 10
-#> D 0.266 0.326 0.337 0.342 0.350 0.383 10
-#> E 0.254 0.281 0.332 0.336 0.359 0.446 10
-#> F 0.237 0.315 0.329 0.340 0.360 0.374 10
-#> G 0.261 0.295 0.318 0.323 0.341 0.390 10
-#> H 0.271 0.290 0.321 0.317 0.343 0.403 10
Of course, when running mo_phylum("Firmicutes")
the function has zero knowledge about the actual microorganism, namely S. aureus. But since the result would be "Firmicutes"
too, there is no point in calculating the result. And because this package ‘knows’ all phyla of all known bacteria (according to the Catalogue of Life), it can just return the initial value immediately.
Currently supported are German, Dutch, Spanish, Italian, French and Portuguese.
diff --git a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png index b9b48285..009e4b61 100644 Binary files a/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/benchmarks_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/freq.html b/docs/articles/freq.html index c331ff99..244c9998 100644 --- a/docs/articles/freq.html +++ b/docs/articles/freq.html @@ -192,7 +192,7 @@freq.Rmd
mo_property.Rmd
resistance_predict.Rmd
It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression.
+It has now created a file "~/.mo_source.rds" with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept.
And now we can use it in our functions:
as.mo("lab_mo_ecoli") -# B_ESCHR_COL +[1] B_ESCHR_COL mo_genus("lab_mo_kpneumoniae") -# "Klebsiella" +[1] "Klebsiella" + # other input values still work too +as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli")) +[1] B_ESCHR_COL B_ESCHR_COL B_ESCHR_COL
If we edit the Excel file to, let's say, this:
| A | B | @@ -297,9 +300,9 @@ as.mo("lab_mo_ecoli")...any new usage of an MO function in this package will update your data:
as.mo("lab_mo_ecoli") # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -# B_ESCHR_COL +[1] B_ESCHR_COL mo_genus("lab_Staph_aureus") -# "Staphylococcus" +[1] "Staphylococcus"To remove the reference completely, just use any of these:
set_mo_source("") diff --git a/man/mo_source.Rd b/man/mo_source.Rd index e0fce598..05ca1b4d 100644 --- a/man/mo_source.Rd +++ b/man/mo_source.Rd @@ -45,15 +45,19 @@ set_mo_source("home/me/ourcodes.xlsx") # Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. } -It has now created a file "~/.mo_source.rds" with the contents of our Excel file. It it an R specific format with great compression. +It has now created a file "~/.mo_source.rds" with the contents of our Excel file, but only the first column with foreign values and the 'mo' column will be kept. And now we can use it in our functions: \preformatted{ as.mo("lab_mo_ecoli") -# B_ESCHR_COL +[1] B_ESCHR_COL mo_genus("lab_mo_kpneumoniae") -# "Klebsiella" +[1] "Klebsiella" + +# other input values still work too +as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli")) +[1] B_ESCHR_COL B_ESCHR_COL B_ESCHR_COL } If we edit the Excel file to, let's say, this: @@ -71,10 +75,10 @@ If we edit the Excel file to, let's say, this: \preformatted{ as.mo("lab_mo_ecoli") # Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'. -# B_ESCHR_COL +[1] B_ESCHR_COL mo_genus("lab_Staph_aureus") -# "Staphylococcus" +[1] "Staphylococcus" } To remove the reference completely, just use any of these: