mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 00:02:38 +02:00
set_mo_source
This commit is contained in:
@ -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}.
|
||||
|
@ -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}
|
||||
|
@ -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!}{
|
||||
|
@ -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
63
man/mo_source.Rd
Normal 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"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user