1
0
mirror of https://github.com/msberends/AMR.git synced 2024-12-24 19:26:12 +01:00

set_mo_source

This commit is contained in:
dr. M.S. (Matthijs) Berends 2019-01-21 15:53:01 +01:00
parent c6c3088e9f
commit 46dcc7e2e8
36 changed files with 1134 additions and 261 deletions

View File

@ -15,6 +15,7 @@
^docs$
^git_merge\.sh$
^git_premaster\.sh$
^git_siteonly\.sh$
^index\.md$
^installed_deps$
^Meta$

1
.gitignore vendored
View File

@ -20,5 +20,6 @@ vignettes/*.R
^CRAN-RELEASE$
git_premaster.sh
git_merge.sh
git_siteonly.sh
packrat/lib*/
packrat/src/

View File

@ -1,6 +1,6 @@
Package: AMR
Version: 0.5.0.9010
Date: 2019-01-17
Version: 0.5.0.9011
Date: 2019-01-21
Title: Antimicrobial Resistance Analysis
Authors@R: c(
person(
@ -58,6 +58,7 @@ Imports:
Suggests:
covr (>= 3.0.1),
ggplot2,
readxl,
rmarkdown,
rstudioapi,
testthat (>= 1.0.2)

View File

@ -77,6 +77,7 @@ export(full_join_microorganisms)
export(g.test)
export(geom_rsi)
export(get_locale)
export(get_mo_source)
export(ggplot_rsi)
export(ggplot_rsi_predict)
export(guess_ab_col)
@ -136,6 +137,7 @@ export(rsi_predict)
export(scale_rsi_colours)
export(scale_y_percent)
export(semi_join_microorganisms)
export(set_mo_source)
export(skewness)
export(theme_rsi)
export(top_freq)

View File

@ -6,6 +6,7 @@
* New website: https://msberends.gitlab.io/AMR (built with the great [`pkgdown`](https://pkgdown.r-lib.org/))
* Contains the complete manual of this package and all of its functions with an explanation of their parameters
* Contains a comprehensive tutorial about how to conduct antimicrobial resistance analysis
* New functions `set_mo_source()` and `get_mo_source()` to use your own predefined MO codes as input for `as.mo()` and consequently all `mo_*` functions
* Support for the upcoming [`dplyr`](https://dplyr.tidyverse.org) version 0.8.0
* New function `guess_ab_col()` to find an antibiotic column in a table
* New function `mo_failures()` to review values that could not be coerced to a valid MO code, using `as.mo()`. This latter function will now only show a maximum of 25 uncoerced values.
@ -55,6 +56,7 @@
* 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)
* Merged data sets `microorganisms.certe` and `microorganisms.umcg` into `microorganisms.codes`
* Function `mo_taxonomy()` now contains the kingdom too
* Reduce false positives for `is.rsi.eligible()`
* Summaries of class `mo` will now return the top 3 and the unique count, e.g. using `summary(mo)`

View File

@ -148,7 +148,7 @@
#' }
#' @source [3] Integrated Taxonomic Information System (ITIS) on-line database, \url{https://www.itis.gov}.
#' @inheritSection AMR Read more on our website!
#' @seealso \code{\link{as.mo}} \code{\link{mo_property}} \code{\link{microorganisms.umcg}}
#' @seealso \code{\link{as.mo}} \code{\link{mo_property}} \code{\link{microorganisms.codes}}
"microorganisms"
#' Data set with old taxonomic data from ITIS
@ -167,29 +167,17 @@
#' @seealso \code{\link{as.mo}} \code{\link{mo_property}} \code{\link{microorganisms}}
"microorganisms.old"
#' Translation table for UMCG
#' Translation table for microorganism codes
#'
#' A data set containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{MO}s with \code{\link{guess_mo}}.
#' @format A \code{\link{data.frame}} with 1,095 observations and 2 variables:
#' A data set containing commonly used codes for microorganisms. Define your own with \code{\link{set_mo_source}}.
#' @format A \code{\link{data.frame}} with 3,303 observations and 2 variables:
#' \describe{
#' \item{\code{umcg}}{Code of microorganism according to UMCG MMB}
#' \item{\code{certe}}{Code of microorganism according to Certe MMB}
#' }
#' @inheritSection AMR Read more on our website!
#' @seealso \code{\link{as.mo}} \code{\link{microorganisms.certe}} \code{\link{microorganisms}}
"microorganisms.umcg"
#' Translation table for Certe
#'
#' A data set containing all bacteria codes of Certe MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{MO}s with \code{\link{guess_mo}}.
#' @format A \code{\link{data.frame}} with 2,665 observations and 2 variables:
#' \describe{
#' \item{\code{certe}}{Code of microorganism according to Certe MMB}
#' \item{\code{certe}}{Commonly used code of a microorganism}
#' \item{\code{mo}}{Code of microorganism in \code{\link{microorganisms}}}
#' }
#' @inheritSection AMR Read more on our website!
#' @seealso \code{\link{as.mo}} \code{\link{microorganisms}}
"microorganisms.certe"
"microorganisms.codes"
#' Data set with 2000 blood culture isolates of septic patients
#'

View File

@ -54,11 +54,10 @@ globalVariables(c(".",
"median",
"mic",
"microorganisms",
"microorganisms.certe",
"microorganisms.codes",
"microorganisms.old",
"microorganisms.oldDT",
"microorganisms.prevDT",
"microorganisms.umcg",
"microorganisms.unprevDT",
"microorganismsDT",
"mo",

56
R/mo.R
View File

@ -30,7 +30,7 @@
#'
#' This excludes \emph{Enterococci} at default (who are in group D), use \code{Lancefield = "all"} to also categorise all \emph{Enterococci} as group D.
#' @param allow_uncertain a logical to indicate whether the input should be checked for less possible results, see Details
#' @param reference_df a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. The first column can be any microbial name, code or ID (used in your analysis or organisation), the second column must be a valid \code{mo} as found in the \code{\link{microorganisms}} data set.
#' @param reference_df a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. See \code{\link{set_mo_source}} and \code{\link{get_mo_source}} to automate the usage of your own codes (e.g. used in your analysis or organisation).
#' @rdname as.mo
#' @aliases mo
#' @keywords mo Becker becker Lancefield lancefield guess
@ -139,7 +139,7 @@
#' df <- df %>%
#' mutate(mo = as.mo(paste(genus, species)))
#' }
as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, reference_df = NULL) {
as.mo <- function(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE, reference_df = get_mo_source()) {
mo <- mo_validate(x = x, property = "mo",
Becker = Becker, Lancefield = Lancefield,
allow_uncertain = allow_uncertain, reference_df = reference_df)
@ -152,11 +152,11 @@ is.mo <- function(x) {
identical(class(x), "mo")
}
#' @importFrom dplyr %>% pull left_join n_distinct progress_estimated
#' @importFrom dplyr %>% pull left_join n_distinct progress_estimated filter
#' @importFrom data.table data.table as.data.table setkey
#' @importFrom crayon magenta red italic
exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
allow_uncertain = TRUE, reference_df = NULL,
allow_uncertain = TRUE, reference_df = get_mo_source(),
property = "mo", clear_options = TRUE) {
if (!"AMR" %in% base::.packages()) {
@ -206,11 +206,16 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
if (!is.data.frame(reference_df) | NCOL(reference_df) < 2) {
stop('`reference_df` must be a data.frame with at least two columns.', call. = FALSE)
}
# remove factors, just keep characters
if (!"mo" %in% colnames(reference_df)) {
stop("`reference_df` must contain a column `mo` with values from the 'microorganisms' data set.", call. = FALSE)
}
reference_df <- reference_df %>% filter(!is.na(mo))
# # remove factors, just keep characters
suppressWarnings(
reference_df[] <- lapply(reference_df, as.character)
)
}
if (all(identical(trimws(x_input), "") | is.na(x_input))) {
# all empty
if (property == "mo") {
@ -220,24 +225,25 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
} else {
return(rep(NA_character_, length(x_input)))
}
} else if (all(x %in% microorganismsDT[["mo"]])) {
# existing mo codes when not looking for property "mo", like mo_genus("B_ESCHR_COL")
x <- microorganismsDT[data.table(mo = x), on = "mo", ..property][[1]]
} else if (!is.null(reference_df)
& all(x %in% reference_df[, 1])
& all(reference_df[, 2] %in% microorganismsDT[["mo"]])) {
# manually defined reference
} else if (all(x %in% reference_df[, 1])
& all(reference_df[, "mo"] %in% microorganismsDT[["mo"]])) {
# all in reference df
colnames(reference_df)[1] <- "x"
colnames(reference_df)[2] <- "mo"
suppressWarnings(
x <- data.frame(x = x, stringsAsFactors = FALSE) %>%
left_join(reference_df, by = "x") %>%
left_join(microorganisms, by = "mo") %>%
pull(property)
)
} else if (all(toupper(x) %in% microorganisms.certe[, "certe"])) {
# old Certe codes
y <- as.data.table(microorganisms.certe)[data.table(certe = toupper(x)), on = "certe", ]
} else if (all(x %in% microorganismsDT[["mo"]])) {
# existing mo codes when not looking for property "mo", like mo_genus("B_ESCHR_COL")
x <- microorganismsDT[data.table(mo = x), on = "mo", ..property][[1]]
} else if (all(toupper(x) %in% microorganisms.codes[, "code"])) {
# commonly used MO codes
y <- as.data.table(microorganisms.codes)[data.table(code = toupper(x)), on = "code", ]
x <- microorganismsDT[data.table(mo = y[["mo"]]), on = "mo", ..property][[1]]
} else if (!all(x %in% microorganismsDT[[property]])) {
@ -419,28 +425,16 @@ exec_as.mo <- function(x, Becker = FALSE, Lancefield = FALSE,
}
# TRY OTHER SOURCES ----
if (toupper(x_backup[i]) %in% microorganisms.certe[, 1]) {
mo_found <- microorganisms.certe[toupper(x_backup[i]) == microorganisms.certe[, 1], 2][1L]
if (toupper(x_backup[i]) %in% microorganisms.codes[, 1]) {
mo_found <- microorganisms.codes[toupper(x_backup[i]) == microorganisms.codes[, 1], "mo"][1L]
if (length(mo_found) > 0) {
x[i] <- microorganismsDT[mo == mo_found, ..property][[1]][1L]
next
}
}
if (x_backup[i] %in% microorganisms.umcg[, 1]) {
mo_umcg <- microorganisms.umcg[microorganisms.umcg[, 1] == x_backup[i], 2]
mo_found <- microorganisms.certe[microorganisms.certe[, 1] == mo_umcg, 2][1L]
if (length(mo_found) == 0) {
# not found
x[i] <- NA_character_
failures <- c(failures, x_backup[i])
} else {
x[i] <- microorganismsDT[mo == mo_found, ..property][[1]][1L]
}
next
}
if (!is.null(reference_df)) {
if (x_backup[i] %in% reference_df[, 1]) {
ref_mo <- reference_df[reference_df[, 1] == x_backup[i], 2]
ref_mo <- reference_df[reference_df[, 1] == x_backup[i], "mo"]
if (ref_mo %in% microorganismsDT[, mo]) {
x[i] <- microorganismsDT[mo == ref_mo, ..property][[1]][1L]
next

174
R/mo_source.R Normal file
View File

@ -0,0 +1,174 @@
# ==================================================================== #
# TITLE #
# Antimicrobial Resistance (AMR) Analysis #
# #
# SOURCE #
# https://gitlab.com/msberends/AMR #
# #
# LICENCE #
# (c) 2019 Berends MS (m.s.berends@umcg.nl), Luz CF (c.f.luz@umcg.nl) #
# #
# This R package is free software; you can freely use and distribute #
# it for both personal and commercial purposes under the terms of the #
# GNU General Public License version 2.0 (GNU GPL-2), as published by #
# the Free Software Foundation. #
# #
# This R package was created for academic research and was publicly #
# released in the hope that it will be useful, but it comes WITHOUT #
# ANY WARRANTY OR LIABILITY. #
# Visit our website for more info: https://msberends.gitab.io/AMR. #
# ==================================================================== #
#' Use predefined reference data set
#'
#' These functions can be used to predefine your own reference to be used in \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}.
#' @param path location of your reference file, see Details
#' @rdname mo_source
#' @name mo_source
#' @aliases set_mo_source get_mo_source
#' @details The reference file can be a text file seperated with commas (CSV) or pipes, an Excel file (old 'xls' format or new 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you need to have the \code{readxl} package installed.
#'
#' \code{set_mo_source} will check the file for validity: it must be a \code{data.frame}, must have a column named \code{"mo"} which contains values from \code{microorganisms$mo} and must have a reference column with your own defined values. If all tests pass, \code{set_mo_source} will read the file into R and export it to \code{"~/.mo_source.rds"}. This compressed data file will then be used at default for MO determination (function \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}). The location of the original file will be saved as option with \code{\link{options}(mo_source = path)}. Its timestamp will be saved with \code{\link{options}(mo_source_datetime = ...)}.
#'
#' \code{get_mo_source} will return the data set by reading \code{"~/.mo_source.rds"} with \code{\link{readRDS}}. If the original file has changed (the file defined with \code{path}), it will call \code{set_mo_source} to update the data file automatically.
#'
#' Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file will have a size of 0.1 kB and can be read by \code{get_mo_source} in only a couple of microseconds (a millionth of a second).
#' @importFrom dplyr select everything
#' @export
#' @inheritSection AMR Read more on our website!
#' @examples
#' \dontrun{
#'
#' # imagine this Excel file (mo codes looked up in `microorganisms` data set):
#' # A B
#' # 1 our code mo
#' # 2 lab_mo_ecoli B_ESCHR_COL
#' # 3 lab_mo_kpneumoniae B_KLBSL_PNE
#'
#' # 1. We save it as 'home/me/ourcodes.xlsx'
#'
#' # 2. We use it for input:
#' set_mo_source("C:\path\ourcodes.xlsx")
#' #> Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#'
#' # 3. And use it in our functions:
#' as.mo("lab_mo_ecoli")
#' #> B_ESCHR_COL
#'
#' mo_genus("lab_mo_kpneumoniae")
#' #> "Klebsiella"
#'
#' # 4. It will look for changes itself:
#' # (add new row to the Excel file and save it)
#'
#' mo_genus("lab_mo_kpneumoniae")
#' #> Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#' #> "Klebsiella"
#' }
set_mo_source <- function(path) {
if (!is.character(path) | length(path) > 1) {
stop("`path` must be a character of length 1.")
}
if (path == "") {
options(mo_source = NULL)
options(mo_source_timestamp = NULL)
if (file.exists("~/.mo_source.rds")) {
unlink("~/.mo_source.rds")
message("Removed mo_source file '~/.mo_source.rds'.")
}
return(invisible())
}
if (!file.exists(path)) {
stop("File not found: ", path)
}
is_valid <- function(df) {
valid <- TRUE
if (!is.data.frame(df)) {
valid <- FALSE
} else if (!"mo" %in% colnames(df)) {
valid <- FALSE
} else if (!all(df$mo %in% AMR::microorganisms$mo)) {
valid <- FALSE
} else if (NCOL(df) < 2) {
valid <- FALSE
}
valid
}
if (path %like% '[.]rds$') {
df <- readRDS(path)
} else if (path %like% '[.]xlsx?$') {
# is Excel file (old or new)
if (!"readxl" %in% utils::installed.packages()) {
stop("Install the 'readxl' package first.")
}
if (path %like% '[.]xlsx$') {
df <- readxl::read_xlsx(path)
} else {
df <- readxl::read_xls(path)
}
} else {
# try comma first
try(
df <- utils::read.table(header = TRUE, sep = ",", stringsAsFactors = FALSE),
silent = TRUE)
if (!is_valid(df)) {
# try pipe
try(
df <- utils::read.table(header = TRUE, sep = "|", stringsAsFactors = FALSE),
silent = TRUE)
}
}
if (!is_valid(df)) {
stop("File must contain a column with self-defined values and a reference column `mo` with valid values from the `microorganisms` data set.")
}
if (colnames(df)[1] == "mo") {
# put mo to the end
df <- df %>% select(-"mo", everything(), "mo")
}
df <- as.data.frame(df, stringAsFactors = FALSE)
# success
if (file.exists("~/.mo_source.rds")) {
action <- "Updated"
} else {
action <- "Created"
}
saveRDS(df, "~/.mo_source.rds")
options(mo_source = path)
options(mo_source_timestamp = as.character(file.info(path)$mtime))
message(action, " mo_source file '~/.mo_source.rds' from '", path, "'.")
}
#' @rdname mo_source
#' @export
get_mo_source <- function() {
if (is.null(getOption("mo_source", NULL))) {
return(NULL)
} else {
old_time <- as.POSIXct(getOption("mo_source_timestamp"))
new_time <- as.POSIXct(as.character(file.info(getOption("mo_source", ""))$mtime))
if (is.na(new_time)) {
# source file was deleted, remove reference too
set_mo_source("")
return(NULL)
}
if (new_time != old_time) {
# set updated source
set_mo_source(getOption("mo_source"))
}
}
readRDS("~/.mo_source.rds")
}

View File

@ -19,7 +19,7 @@
# Visit our website for more info: https://msberends.gitab.io/AMR. #
# ==================================================================== #
url: https://msberends.gitlab.io/AMR
url: 'https://msberends.gitlab.io/AMR'
title: 'AMR (for R)'
@ -83,18 +83,21 @@ reference:
- '`ITIS`'
- title: 'Cleaning your data'
desc: >
Functions for cleaning and optimising your data, to be able
to add variables later on (like taxonomic properties) or to
fix and extend antibiotic interpretations by applying [EUCAST rules](http://www.eucast.org/expert_rules_and_intrinsic_resistance/).
Functions for cleaning and optimising your data, to be able to add
variables later on (like taxonomic properties) or to fix and extend
antibiotic interpretations by applying [EUCAST rules](http://www.eucast.org/expert_rules_and_intrinsic_resistance/).
contents:
- starts_with("as.")
- '`mo_source`'
- '`eucast_rules`'
- '`guess_ab_col`'
- '`read.4D`'
- title: 'Adding variables to your data'
desc: >
Functions to add new data to existing data, like the determination
of first isolates,
of first isolates, multi-drug resistant microorganisms (MDRO), getting
properties of microorganisms or antibiotics and determining the age of
patients or divide ages into age groups.
contents:
- '`first_isolate`'
- '`mdro`'
@ -109,7 +112,8 @@ reference:
- '`join`'
- title: 'Analysing your data'
desc: >
Functions for conducting AMR analysis
Functions for conducting AMR analysis, like counting isolates, calculating
resistance or susceptibility, creating frequency tables or make plots.
contents:
- '`count`'
- '`portion`'
@ -128,9 +132,8 @@ reference:
- '`antibiotics`'
- '`microorganisms`'
- '`septic_patients`'
- '`microorganisms.certe`'
- '`microorganisms.codes`'
- '`microorganisms.old`'
- '`microorganisms.umcg`'
- '`supplementary_data`'
- title: Other
desc: >

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>

View File

@ -40,7 +40,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
@ -178,7 +178,7 @@
<h1>Benchmarks</h1>
<h4 class="author">Matthijs S. Berends</h4>
<h4 class="date">17 January 2019</h4>
<h4 class="date">21 January 2019</h4>
<div class="hidden name"><code>benchmarks.Rmd</code></div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>

View File

@ -24,9 +24,9 @@
/* class for footer */
.university {
background-image: url(logo_rug.png);
height: 40px;
background-size: 160px;
background-size: 200px;
background-repeat: no-repeat;
background-position: center right;
}
/* Supports icons for brand using font-awesome */
@ -68,6 +68,18 @@ pre, code {
pre {
font-size: 90% !important;
}
kbd {
display: inline-block;
padding: 0 4px;
box-shadow: 1px 1px 1px #2c3e50;
margin: 2px;
font-size: small;
vertical-align: text-bottom;
color: #2c3e50;
background: #eee;
font-weight: bold;
}
li, p {
line-height: 1.5;
}
@ -137,7 +149,8 @@ thead {
border-top: 2px solid black;
border-bottom: 2px solid black;
}
tbody {
thead ~ tbody {
/* only when it has a header */
border-bottom: 2px solid black;
}
table a:not(.btn), .table a:not(.btn) {
@ -146,3 +159,8 @@ table a:not(.btn), .table a:not(.btn) {
table a:not(.btn):hover, .table a:not(.btn):hover {
text-decoration: underline;
}
.template-reference-index h2 ~ p {
font-size: 110%;
/* font-weight: bold; */
}

View File

@ -29,11 +29,19 @@ $('head').append('<!-- Updated Font Awesome library --><link rel="stylesheet" hr
// Edit footer
$( document ).ready(function() {
// redirect to GitLab
var url_old = window.location.href;
var url_new = url_old.replace("github", "gitlab");
if (url_old != url_new) {
window.location.replace(url);
}
$('footer').html('<p>' +
$('footer .copyright p').html().replace("Developed by",
"<code>AMR</code> (for R). Developed at the University of Groningen.<br>Authors:") +
'<code>AMR</code> (for R). Developed at the <a href="https://www.rug.nl" target="_blank">University of Groningen</a>.<br>Authors:') +
'</p>');
//$('footer').prepend("<div class='university'/>");
$('footer').addClass("university");
// Edit title of manual
$('.template-reference-index h1').text('Manual');

View File

@ -42,7 +42,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
@ -191,6 +191,7 @@
<li>Research Microbiologists</li>
<li>Biomedical Researchers</li>
<li>Research Pharmacologists</li>
<li>Data Scientists / Data Analysts</li>
</ul>
<p>Veterinary Microbiology:</p>
<ul>
@ -203,14 +204,6 @@
<li>Extremophile Researchers</li>
<li>Astrobiologists</li>
</ul>
<p>Other specialists in any of the above fields:</p>
<ul>
<li>Data Scientists/Data Analysts</li>
<li>Biotechnologists</li>
<li>Biochemists</li>
<li>Geneticists</li>
<li>Molecular Biologists/Microbiologists</li>
</ul>
<p>Developers:</p>
<ul>
<li>Package developers for R</li>
@ -222,7 +215,7 @@
<a href="#get-this-package" class="anchor"></a>Get this package</h3>
<p>This package is available on the official R network (CRAN), which has a peer-reviewed submission process. Install this package in R with:</p>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" data-line-number="1"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/install.packages">install.packages</a></span>(<span class="st">"AMR"</span>)</a></code></pre></div>
<p>It will be downloaded and installed automatically. For RStudio, click on menu <em>Tools</em> &gt; <em>Install Packages…</em>, then type in “AMR” and press <kbd>Install</kbd>.</p>
<p>It will be downloaded and installed automatically. For RStudio, click on the menu <em>Tools</em> &gt; <em>Install Packages…</em> and then type in “AMR” and press <kbd>Install</kbd>.</p>
</div>
<div id="get-started" class="section level3">
<h3 class="hasAnchor">

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
@ -235,6 +235,7 @@
<li>Contains a comprehensive tutorial about how to conduct antimicrobial resistance analysis</li>
</ul>
</li>
<li>New functions <code><a href="../reference/mo_source.html">set_mo_source()</a></code> and <code><a href="../reference/mo_source.html">get_mo_source()</a></code> to use your own predefined MO codes as input for <code><a href="../reference/as.mo.html">as.mo()</a></code> and consequently all <code>mo_*</code> functions</li>
<li>Support for the upcoming <a href="https://dplyr.tidyverse.org"><code>dplyr</code></a> version 0.8.0</li>
<li>New function <code><a href="../reference/guess_ab_col.html">guess_ab_col()</a></code> to find an antibiotic column in a table</li>
<li>New function <code><a href="../reference/mo_failures.html">mo_failures()</a></code> to review values that could not be coerced to a valid MO code, using <code><a href="../reference/as.mo.html">as.mo()</a></code>. This latter function will now only show a maximum of 25 uncoerced values.</li>
@ -297,6 +298,8 @@
</ul>
</li>
<li>A note to the manual pages of the <code>portion</code> functions, that low counts can influence the outcome and that the <code>portion</code> functions may camouflage this, since they only return the portion (albeit being dependent on the <code>minimum</code> parameter)</li>
<li>Merged data sets <code>microorganisms.certe</code> and <code>microorganisms.umcg</code> into <code>microorganisms.codes</code>
</li>
<li>Function <code><a href="../reference/mo_property.html">mo_taxonomy()</a></code> now contains the kingdom too</li>
<li>Reduce false positives for <code><a href="../reference/as.rsi.html">is.rsi.eligible()</a></code>
</li>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
@ -228,7 +228,7 @@
</div>
<pre class="usage"><span class='fu'>as.mo</span>(<span class='no'>x</span>, <span class='kw'>Becker</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>Lancefield</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>allow_uncertain</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>reference_df</span> <span class='kw'>=</span> <span class='kw'>NULL</span>)
<span class='kw'>reference_df</span> <span class='kw'>=</span> <span class='fu'><a href='mo_source.html'>get_mo_source</a></span>())
<span class='fu'>is.mo</span>(<span class='no'>x</span>)</pre>
@ -255,7 +255,7 @@
</tr>
<tr>
<th>reference_df</th>
<td><p>a <code>data.frame</code> to use for extra reference when translating <code>x</code> to a valid <code>mo</code>. The first column can be any microbial name, code or ID (used in your analysis or organisation), the second column must be a valid <code>mo</code> as found in the <code><a href='microorganisms.html'>microorganisms</a></code> data set.</p></td>
<td><p>a <code>data.frame</code> to use for extra reference when translating <code>x</code> to a valid <code>mo</code>. See <code><a href='mo_source.html'>set_mo_source</a></code> and <code><a href='mo_source.html'>get_mo_source</a></code> to automate the usage of your own codes (e.g. used in your analysis or organisation).</p></td>
</tr>
</table>

View File

@ -78,7 +78,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
@ -278,6 +278,12 @@
<td><p>Class 'rsi'</p></td>
</tr><tr>
<td>
<p><code><a href="mo_source.html">set_mo_source()</a></code> <code><a href="mo_source.html">get_mo_source()</a></code> </p>
</td>
<td><p>Use predefined reference data set</p></td>
</tr><tr>
<td>
<p><code><a href="eucast_rules.html">eucast_rules()</a></code> <code><a href="eucast_rules.html">EUCAST_rules()</a></code> <code><a href="eucast_rules.html">interpretive_reading()</a></code> </p>
</td>
@ -299,7 +305,7 @@
<tr>
<th colspan="2">
<h2 id="section-adding-variables-to-your-data" class="hasAnchor"><a href="#section-adding-variables-to-your-data" class="anchor"></a>Adding variables to your data</h2>
<p class="section-desc"><p>Functions to add new data to existing data, like the determination of first isolates,</p></p>
<p class="section-desc"><p>Functions to add new data to existing data, like the determination of first isolates, multi-drug resistant microorganisms (MDRO), getting properties of microorganisms or antibiotics and determining the age of patients or divide ages into age groups.</p></p>
</th>
</tr>
<tr>
@ -373,7 +379,7 @@
<tr>
<th colspan="2">
<h2 id="section-analysing-your-data" class="hasAnchor"><a href="#section-analysing-your-data" class="anchor"></a>Analysing your data</h2>
<p class="section-desc"><p>Functions for conducting AMR analysis</p></p>
<p class="section-desc"><p>Functions for conducting AMR analysis, like counting isolates, calculating resistance or susceptibility, creating frequency tables or make plots.</p></p>
</th>
</tr>
<tr>
@ -459,9 +465,9 @@
</tr><tr>
<td>
<p><code><a href="microorganisms.certe.html">microorganisms.certe</a></code> </p>
<p><code><a href="microorganisms.codes.html">microorganisms.codes</a></code> </p>
</td>
<td><p>Translation table for Certe</p></td>
<td><p>Translation table for microorganism codes</p></td>
</tr><tr>
<td>
@ -470,12 +476,6 @@
<td><p>Data set with old taxonomic data from ITIS</p></td>
</tr><tr>
<td>
<p><code><a href="microorganisms.umcg.html">microorganisms.umcg</a></code> </p>
</td>
<td><p>Translation table for UMCG</p></td>
</tr><tr>
<td>
<p><code><a href="supplementary_data.html">microorganismsDT</a></code> <code><a href="supplementary_data.html">microorganisms.prevDT</a></code> <code><a href="supplementary_data.html">microorganisms.unprevDT</a></code> <code><a href="supplementary_data.html">microorganisms.oldDT</a></code> </p>
</td>

View File

@ -0,0 +1,297 @@
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Translation table for microorganism codes — microorganisms.codes • AMR (for R)</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<!-- sticky kit -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>
<!-- docsearch -->
<script src="../docsearch.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.css" integrity="sha256-QOSRU/ra9ActyXkIBbiIB144aDBdtvXBcNc3OTNuX/Q=" crossorigin="anonymous" />
<link href="../docsearch.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity="sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin="anonymous"></script>
<link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script>
<meta property="og:title" content="Translation table for microorganism codes — microorganisms.codes" />
<meta property="og:description" content="A data set containing commonly used codes for microorganisms. Define your own with set_mo_source." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
<meta name="twitter:card" content="summary" />
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-reference-topic">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home"></span>
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fa fa-question-circle"></span>
How to
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/AMR.html">
<span class="fa fa-directions"></span>
Conduct AMR analysis
</a>
</li>
<li>
<a href="../articles/Predict.html">
<span class="fa fa-dice"></span>
Predict antimicrobial resistance
</a>
</li>
<li>
<a href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
Apply EUCAST rules
</a>
</li>
<li>
<a href="../articles/mo_property.html">
<span class="fa fa-bug"></span>
Get properties of a microorganism
</a>
</li>
<li>
<a href="../articles/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/G_test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>
<a href="../reference/">
<span class="fa fa-book-open"></span>
Manual
</a>
</li>
<li>
<a href="../authors.html">
<span class="fa fa-users"></span>
Authors
</a>
</li>
<li>
<a href="../news/">
<span class="far fa far fa-newspaper"></span>
Changelog
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://gitlab.com/msberends/AMR">
<span class="fab fa fab fa-gitlab"></span>
Source Code
</a>
</li>
<li>
<a href="../LICENSE-text.html">
<span class="fa fa-book"></span>
Licence
</a>
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
</div>
</form>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Translation table for microorganism codes</h1>
<div class="hidden name"><code>microorganisms.codes.Rd</code></div>
</div>
<div class="ref-description">
<p>A data set containing commonly used codes for microorganisms. Define your own with <code><a href='mo_source.html'>set_mo_source</a></code>.</p>
</div>
<pre class="usage"><span class='no'>microorganisms.codes</span></pre>
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
<p>A <code><a href='https://www.rdocumentation.org/packages/base/topics/data.frame'>data.frame</a></code> with 3,303 observations and 2 variables:</p><dl class='dl-horizontal'>
<dt><code>certe</code></dt><dd><p>Commonly used code of a microorganism</p></dd>
<dt><code>mo</code></dt><dd><p>Code of microorganism in <code><a href='microorganisms.html'>microorganisms</a></code></p></dd>
</dl>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
<p><img src='figures/logo.png' height=40px style=margin-bottom:5px /> <br />
On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a omprehensive tutorial</a> about how to conduct AMR analysis and find <a href='https://msberends.gitlab.io/AMR/reference'>the complete documentation of all functions</a>, which reads a lot easier than in R.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p><code><a href='as.mo.html'>as.mo</a></code> <code><a href='microorganisms.html'>microorganisms</a></code></p></div>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#format">Format</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
<li><a href="#see-also">See also</a></li>
</ul>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.js" integrity="sha256-GKvGqXDznoRYHCwKXGnuchvKSwmx9SRMrZOTh2g4Sb0=" crossorigin="anonymous"></script>
<script>
docsearch({
apiKey: 'f737050abfd4d726c63938e18f8c496e',
indexName: 'amr',
inputSelector: 'input#search-input.form-control',
transformData: function(hits) {
return hits.map(function (hit) {
hit.url = updateHitURL(hit);
return hit;
});
}
});
</script>
</body>
</html>

View File

@ -80,7 +80,7 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9010</span>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
@ -269,7 +269,7 @@ On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitla
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p><code><a href='as.mo.html'>as.mo</a></code> <code><a href='mo_property.html'>mo_property</a></code> <code><a href='microorganisms.umcg.html'>microorganisms.umcg</a></code></p></div>
<div class='dont-index'><p><code><a href='as.mo.html'>as.mo</a></code> <code><a href='mo_property.html'>mo_property</a></code> <code><a href='microorganisms.codes.html'>microorganisms.codes</a></code></p></div>
</div>

View File

@ -0,0 +1,334 @@
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Use predefined reference data set — mo_source • AMR (for R)</title>
<!-- favicons -->
<link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png" />
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png" />
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png" />
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png" />
<!-- jquery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<!-- sticky kit -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" crossorigin="anonymous"></script>
<!-- pkgdown -->
<link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script>
<!-- docsearch -->
<script src="../docsearch.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.css" integrity="sha256-QOSRU/ra9ActyXkIBbiIB144aDBdtvXBcNc3OTNuX/Q=" crossorigin="anonymous" />
<link href="../docsearch.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/jquery.mark.min.js" integrity="sha256-4HLtjeVgH0eIB3aZ9mLYF6E8oU5chNdjU6p6rrXpl9U=" crossorigin="anonymous"></script>
<link href="../extra.css" rel="stylesheet">
<script src="../extra.js"></script>
<meta property="og:title" content="Use predefined reference data set — mo_source" />
<meta property="og:description" content="These functions can be used to predefine your own reference to be used in as.mo and consequently all mo_* functions like mo_genus and mo_gramstain." />
<meta property="og:image" content="https://msberends.gitlab.io/AMR/logo.png" />
<meta name="twitter:card" content="summary" />
<!-- mathjax -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="container template-reference-topic">
<header>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">AMR (for R)</a>
<span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.5.0.9011</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../index.html">
<span class="fa fa-home"></span>
Home
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<span class="fa fa-question-circle"></span>
How to
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/AMR.html">
<span class="fa fa-directions"></span>
Conduct AMR analysis
</a>
</li>
<li>
<a href="../articles/Predict.html">
<span class="fa fa-dice"></span>
Predict antimicrobial resistance
</a>
</li>
<li>
<a href="../articles/EUCAST.html">
<span class="fa fa-exchange-alt"></span>
Apply EUCAST rules
</a>
</li>
<li>
<a href="../articles/mo_property.html">
<span class="fa fa-bug"></span>
Get properties of a microorganism
</a>
</li>
<li>
<a href="../articles/ab_property.html">
<span class="fa fa-capsules"></span>
Get properties of an antibiotic
</a>
</li>
<li>
<a href="../articles/freq.html">
<span class="fa fa-sort-amount-down"></span>
Create frequency tables
</a>
</li>
<li>
<a href="../articles/G_test.html">
<span class="fa fa-clipboard-check"></span>
Use the G-test
</a>
</li>
<li>
<a href="../articles/benchmarks.html">
<span class="fa fa-shipping-fast"></span>
Other: benchmarks
</a>
</li>
</ul>
</li>
<li>
<a href="../reference/">
<span class="fa fa-book-open"></span>
Manual
</a>
</li>
<li>
<a href="../authors.html">
<span class="fa fa-users"></span>
Authors
</a>
</li>
<li>
<a href="../news/">
<span class="far fa far fa-newspaper"></span>
Changelog
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://gitlab.com/msberends/AMR">
<span class="fab fa fab fa-gitlab"></span>
Source Code
</a>
</li>
<li>
<a href="../LICENSE-text.html">
<span class="fa fa-book"></span>
Licence
</a>
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="form-group">
<input type="search" class="form-control" name="search-input" id="search-input" placeholder="Search..." aria-label="Search for..." autocomplete="off">
</div>
</form>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
</header>
<div class="row">
<div class="col-md-9 contents">
<div class="page-header">
<h1>Use predefined reference data set</h1>
<div class="hidden name"><code>mo_source.Rd</code></div>
</div>
<div class="ref-description">
<p>These functions can be used to predefine your own reference to be used in <code><a href='as.mo.html'>as.mo</a></code> and consequently all <code>mo_*</code> functions like <code><a href='mo_property.html'>mo_genus</a></code> and <code><a href='mo_property.html'>mo_gramstain</a></code>.</p>
</div>
<pre class="usage"><span class='fu'>set_mo_source</span>(<span class='no'>path</span>)
<span class='fu'>get_mo_source</span>()</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>path</th>
<td><p>location of your reference file, see Details</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
<p>The reference file can be a text file seperated with commas (CSV) or pipes, an Excel file (old 'xls' format or new 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you need to have the <code>readxl</code> package installed.</p>
<p><code>set_mo_source</code> will check the file for validity: it must be a <code>data.frame</code>, must have a column named <code>"mo"</code> which contains values from <code>microorganisms$mo</code> and must have a reference column with your own defined values. If all tests pass, <code>set_mo_source</code> will read the file into R and export it to <code>"~/.mo_source.rds"</code>. This compressed data file will then be used at default for MO determination (function <code><a href='as.mo.html'>as.mo</a></code> and consequently all <code>mo_*</code> functions like <code><a href='mo_property.html'>mo_genus</a></code> and <code><a href='mo_property.html'>mo_gramstain</a></code>). The location of the original file will be saved as option with <code><a href='https://www.rdocumentation.org/packages/base/topics/options'>options</a>(mo_source = path)</code>. Its timestamp will be saved with <code><a href='https://www.rdocumentation.org/packages/base/topics/options'>options</a>(mo_source_datetime = ...)</code>.</p>
<p><code>get_mo_source</code> will return the data set by reading <code>"~/.mo_source.rds"</code> with <code><a href='https://www.rdocumentation.org/packages/base/topics/readRDS'>readRDS</a></code>. If the original file has changed (the file defined with <code>path</code>), it will call <code>set_mo_source</code> to update the data file automatically.</p>
<p>Reading an Excel file (<code>.xlsx</code>) with only one row has a size of 8-9 kB. The compressed file will have a size of 0.1 kB and can be read by <code>get_mo_source</code> in only a couple of microseconds (a millionth of a second).</p>
<h2 class="hasAnchor" id="read-more-on-our-website-"><a class="anchor" href="#read-more-on-our-website-"></a>Read more on our website!</h2>
<p><img src='figures/logo.png' height=40px style=margin-bottom:5px /> <br />
On our website <a href='https://msberends.gitlab.io/AMR'>https://msberends.gitlab.io/AMR</a> you can find <a href='https://msberends.gitlab.io/AMR/articles/AMR.html'>a omprehensive tutorial</a> about how to conduct AMR analysis and find <a href='https://msberends.gitlab.io/AMR/reference'>the complete documentation of all functions</a>, which reads a lot easier than in R.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"># NOT RUN {
# imagine this Excel file (mo codes looked up in `microorganisms` data set):
# A B
# 1 our code mo
# 2 lab_mo_ecoli B_ESCHR_COL
# 3 lab_mo_kpneumoniae B_KLBSL_PNE
# 1. We save it as 'home/me/ourcodes.xlsx'
# 2. We use it for input:
set_mo_source("C:\path\ourcodes.xlsx")
#> Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
# 3. And use it in our functions:
as.mo("lab_mo_ecoli")
#> B_ESCHR_COL
mo_genus("lab_mo_kpneumoniae")
#> "Klebsiella"
# 4. It will look for changes itself:
# (add new row to the Excel file and save it)
mo_genus("lab_mo_kpneumoniae")
#> Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#> "Klebsiella"
# }
</pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#arguments">Arguments</a></li>
<li><a href="#details">Details</a></li>
<li><a href="#read-more-on-our-website-">Read more on our website!</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by <a href='https://www.rug.nl/staff/m.s.berends/'>Matthijs S. Berends</a>, <a href='https://www.rug.nl/staff/c.f.luz/'>Christian F. Luz</a>, <a href='https://www.rug.nl/staff/c.glasner/'>Corinna Glasner</a>, <a href='https://www.rug.nl/staff/a.w.friedrich/'>Alex W. Friedrich</a>, <a href='https://www.rug.nl/staff/b.sinha/'>Bhanu N. M. Sinha</a>.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/docsearch.js/2.6.1/docsearch.min.js" integrity="sha256-GKvGqXDznoRYHCwKXGnuchvKSwmx9SRMrZOTh2g4Sb0=" crossorigin="anonymous"></script>
<script>
docsearch({
apiKey: 'f737050abfd4d726c63938e18f8c496e',
indexName: 'amr',
inputSelector: 'input#search-input.form-control',
transformData: function(hits) {
return hits.map(function (hit) {
hit.url = updateHitURL(hit);
return hit;
});
}
});
</script>
</body>
</html>

View File

@ -85,14 +85,11 @@
<loc>https://msberends.gitlab.io/AMR/reference/microorganisms.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/microorganisms.certe.html</loc>
<loc>https://msberends.gitlab.io/AMR/reference/microorganisms.codes.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/microorganisms.old.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/microorganisms.umcg.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/mo_failures.html</loc>
</url>
@ -102,6 +99,9 @@
<url>
<loc>https://msberends.gitlab.io/AMR/reference/mo_renamed.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/mo_source.html</loc>
</url>
<url>
<loc>https://msberends.gitlab.io/AMR/reference/p.symbol.html</loc>
</url>

View File

@ -17,6 +17,7 @@ Medical Microbiology:
* Research Microbiologists
* Biomedical Researchers
* Research Pharmacologists
* Data Scientists / Data Analysts
Veterinary Microbiology:
@ -29,14 +30,6 @@ Microbial Ecology:
* Extremophile Researchers
* Astrobiologists
Other specialists in any of the above fields:
* Data Scientists/Data Analysts
* Biotechnologists
* Biochemists
* Geneticists
* Molecular Biologists/Microbiologists
Developers:
* Package developers for R
@ -51,7 +44,7 @@ This package is available on the official R network (CRAN), which has a peer-rev
install.packages("AMR")
```
It will be downloaded and installed automatically. For RStudio, click on menu *Tools* > *Install Packages...*, then type in "AMR" and press <kbd>Install</kbd>.
It will be downloaded and installed automatically. For RStudio, click on the menu *Tools* > *Install Packages...* and then type in "AMR" and press <kbd>Install</kbd>.
### Get started

View File

@ -7,7 +7,7 @@
\title{Transform to microorganism ID}
\usage{
as.mo(x, Becker = FALSE, Lancefield = FALSE, allow_uncertain = TRUE,
reference_df = NULL)
reference_df = get_mo_source())
is.mo(x)
}
@ -24,7 +24,7 @@ is.mo(x)
\item{allow_uncertain}{a logical to indicate whether the input should be checked for less possible results, see Details}
\item{reference_df}{a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. The first column can be any microbial name, code or ID (used in your analysis or organisation), the second column must be a valid \code{mo} as found in the \code{\link{microorganisms}} data set.}
\item{reference_df}{a \code{data.frame} to use for extra reference when translating \code{x} to a valid \code{mo}. See \code{\link{set_mo_source}} and \code{\link{get_mo_source}} to automate the usage of your own codes (e.g. used in your analysis or organisation).}
}
\value{
Character (vector) with class \code{"mo"}. Unknown values will return \code{NA}.

View File

@ -48,6 +48,6 @@ On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://
}
\seealso{
\code{\link{as.mo}} \code{\link{mo_property}} \code{\link{microorganisms.umcg}}
\code{\link{as.mo}} \code{\link{mo_property}} \code{\link{microorganisms.codes}}
}
\keyword{datasets}

View File

@ -1,19 +1,19 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{microorganisms.certe}
\alias{microorganisms.certe}
\title{Translation table for Certe}
\format{A \code{\link{data.frame}} with 2,665 observations and 2 variables:
\name{microorganisms.codes}
\alias{microorganisms.codes}
\title{Translation table for microorganism codes}
\format{A \code{\link{data.frame}} with 3,303 observations and 2 variables:
\describe{
\item{\code{certe}}{Code of microorganism according to Certe MMB}
\item{\code{certe}}{Commonly used code of a microorganism}
\item{\code{mo}}{Code of microorganism in \code{\link{microorganisms}}}
}}
\usage{
microorganisms.certe
microorganisms.codes
}
\description{
A data set containing all bacteria codes of Certe MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{MO}s with \code{\link{guess_mo}}.
A data set containing commonly used codes for microorganisms. Define your own with \code{\link{set_mo_source}}.
}
\section{Read more on our website!}{

View File

@ -1,27 +0,0 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/data.R
\docType{data}
\name{microorganisms.umcg}
\alias{microorganisms.umcg}
\title{Translation table for UMCG}
\format{A \code{\link{data.frame}} with 1,095 observations and 2 variables:
\describe{
\item{\code{umcg}}{Code of microorganism according to UMCG MMB}
\item{\code{certe}}{Code of microorganism according to Certe MMB}
}}
\usage{
microorganisms.umcg
}
\description{
A data set containing all bacteria codes of UMCG MMB. These codes can be joined to data with an ID from \code{\link{microorganisms}$mo} (using \code{\link{left_join_microorganisms}}). GLIMS codes can also be translated to valid \code{MO}s with \code{\link{guess_mo}}.
}
\section{Read more on our website!}{
\if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr}
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a omprehensive tutorial} about how to conduct AMR analysis and find \href{https://msberends.gitlab.io/AMR/reference}{the complete documentation of all functions}, which reads a lot easier than in R.
}
\seealso{
\code{\link{as.mo}} \code{\link{microorganisms.certe}} \code{\link{microorganisms}}
}
\keyword{datasets}

63
man/mo_source.Rd Normal file
View File

@ -0,0 +1,63 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/mo_source.R
\name{mo_source}
\alias{mo_source}
\alias{set_mo_source}
\alias{get_mo_source}
\title{Use predefined reference data set}
\usage{
set_mo_source(path)
get_mo_source()
}
\arguments{
\item{path}{location of your reference file, see Details}
}
\description{
These functions can be used to predefine your own reference to be used in \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}.
}
\details{
The reference file can be a text file seperated with commas (CSV) or pipes, an Excel file (old 'xls' format or new 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you need to have the \code{readxl} package installed.
\code{set_mo_source} will check the file for validity: it must be a \code{data.frame}, must have a column named \code{"mo"} which contains values from \code{microorganisms$mo} and must have a reference column with your own defined values. If all tests pass, \code{set_mo_source} will read the file into R and export it to \code{"~/.mo_source.rds"}. This compressed data file will then be used at default for MO determination (function \code{\link{as.mo}} and consequently all \code{mo_*} functions like \code{\link{mo_genus}} and \code{\link{mo_gramstain}}). The location of the original file will be saved as option with \code{\link{options}(mo_source = path)}. Its timestamp will be saved with \code{\link{options}(mo_source_datetime = ...)}.
\code{get_mo_source} will return the data set by reading \code{"~/.mo_source.rds"} with \code{\link{readRDS}}. If the original file has changed (the file defined with \code{path}), it will call \code{set_mo_source} to update the data file automatically.
Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The compressed file will have a size of 0.1 kB and can be read by \code{get_mo_source} in only a couple of microseconds (a millionth of a second).
}
\section{Read more on our website!}{
\if{html}{\figure{logo.png}{options: height=40px style=margin-bottom:5px} \cr}
On our website \url{https://msberends.gitlab.io/AMR} you can find \href{https://msberends.gitlab.io/AMR/articles/AMR.html}{a omprehensive tutorial} about how to conduct AMR analysis and find \href{https://msberends.gitlab.io/AMR/reference}{the complete documentation of all functions}, which reads a lot easier than in R.
}
\examples{
\dontrun{
# imagine this Excel file (mo codes looked up in `microorganisms` data set):
# A B
# 1 our code mo
# 2 lab_mo_ecoli B_ESCHR_COL
# 3 lab_mo_kpneumoniae B_KLBSL_PNE
# 1. We save it as 'home/me/ourcodes.xlsx'
# 2. We use it for input:
set_mo_source("C:\\path\\ourcodes.xlsx")
#> Created mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
# 3. And use it in our functions:
as.mo("lab_mo_ecoli")
#> B_ESCHR_COL
mo_genus("lab_mo_kpneumoniae")
#> "Klebsiella"
# 4. It will look for changes itself:
# (add new row to the Excel file and save it)
mo_genus("lab_mo_kpneumoniae")
#> Updated mo_source file '~/.mo_source.rds' from 'home/me/ourcodes.xlsx'.
#> "Klebsiella"
}
}

View File

@ -24,9 +24,9 @@
/* class for footer */
.university {
background-image: url(logo_rug.png);
height: 40px;
background-size: 160px;
background-size: 200px;
background-repeat: no-repeat;
background-position: center right;
}
/* Supports icons for brand using font-awesome */
@ -68,6 +68,18 @@ pre, code {
pre {
font-size: 90% !important;
}
kbd {
display: inline-block;
padding: 0 4px;
box-shadow: 1px 1px 1px #2c3e50;
margin: 2px;
font-size: small;
vertical-align: text-bottom;
color: #2c3e50;
background: #eee;
font-weight: bold;
}
li, p {
line-height: 1.5;
}
@ -137,7 +149,8 @@ thead {
border-top: 2px solid black;
border-bottom: 2px solid black;
}
tbody {
thead ~ tbody {
/* only when it has a header */
border-bottom: 2px solid black;
}
table a:not(.btn), .table a:not(.btn) {
@ -146,3 +159,8 @@ table a:not(.btn), .table a:not(.btn) {
table a:not(.btn):hover, .table a:not(.btn):hover {
text-decoration: underline;
}
.template-reference-index h2 ~ p {
font-size: 110%;
/* font-weight: bold; */
}

View File

@ -29,11 +29,19 @@ $('head').append('<!-- Updated Font Awesome library --><link rel="stylesheet" hr
// Edit footer
$( document ).ready(function() {
// redirect to GitLab
var url_old = window.location.href;
var url_new = url_old.replace("github", "gitlab");
if (url_old != url_new) {
window.location.replace(url);
}
$('footer').html('<p>' +
$('footer .copyright p').html().replace("Developed by",
"<code>AMR</code> (for R). Developed at the University of Groningen.<br>Authors:") +
'<code>AMR</code> (for R). Developed at the <a href="https://www.rug.nl" target="_blank">University of Groningen</a>.<br>Authors:') +
'</p>');
//$('footer').prepend("<div class='university'/>");
$('footer').addClass("university");
// Edit title of manual
$('.template-reference-index h1').text('Manual');

View File

@ -194,7 +194,7 @@ test_that("as.mo works", {
expect_equal(suppressMessages(as.character(as.mo("Escherichia blattae"))), "B_SHMWL_BLA")
# - Didymosphaeria spartinae (unprevalent)
expect_warning(suppressMessages(as.mo("D spartin", allow_uncertain = TRUE)))
# - was renames to Leptosphaeria obiones
# - was renamed to Leptosphaeria obiones
expect_equal(suppressWarnings(suppressMessages(as.character(as.mo("D spartin", allow_uncertain = TRUE)))),
"F_LPTSP_OBI")
@ -205,15 +205,15 @@ test_that("as.mo works", {
# predefined reference_df
expect_equal(as.character(as.mo("TestingOwnID",
reference_df = data.frame(a = "TestingOwnID", b = "B_ESCHR_COL"))),
reference_df = data.frame(mycol = "TestingOwnID", mo = "B_ESCHR_COL"))),
"B_ESCHR_COL")
expect_equal(as.character(as.mo(c("TestingOwnID", "E. coli"),
reference_df = data.frame(a = "TestingOwnID", b = "B_ESCHR_COL"))),
reference_df = data.frame(mycol = "TestingOwnID", mo = "B_ESCHR_COL"))),
c("B_ESCHR_COL", "B_ESCHR_COL"))
expect_warning(as.mo("TestingOwnID", reference_df = NULL))
expect_error(as.mo("E. coli", reference_df = data.frame(a = "TestingOwnID")))
expect_error(as.mo("E. coli", reference_df = data.frame(mycol = "TestingOwnID")))
# combination of existing mo and certe
# combination of existing mo and other code
expect_identical(as.character(as.mo(c("B_ESCHR_COL", "ESCCOL"))),
c("B_ESCHR_COL", "B_ESCHR_COL"))