AMR
1.8.1.9002AMR
1.8.1.9003as.integer()
for MIC values, since MIC are not integer values and running table()
on MIC values will consequently fail for not being able to retrieve the level position (as that’s how normally as.integer()
on factor
s work)as.integer()
for MIC values, since MIC are not integer values and running table()
on MIC values consequently failed for not being able to retrieve the level position (as that’s how normally as.integer()
on factor
s work)droplevels()
on MIC will now return a common factor
at default and will lose the <mic>
class. Use droplevels(..., as.mic = TRUE)
to keep the <mic>
class.ab_from_text()
set_mo_source()
, which now also allows the source file to contain valid taxonomic names instead of only valid microorganism ID of this packagelocation of your reference file, see Details. Can be ""
, NULL
or FALSE
to delete the reference file.
location of your reference file, this can be any text file (comma-, tab- or pipe-separated) or an Excel file (see Details). Can also be ""
, NULL
or FALSE
to delete the reference file.
destination of the compressed data file, default to the user's home directory.
The reference file can be a text file separated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an R object file (extension '.rds'). To use an Excel file, you will need to have the readxl
package installed.
set_mo_source()
will check the file for validity: it must be a data.frame, must have a column named "mo"
which contains values from microorganisms$mo
and must have a reference column with your own defined values. If all tests pass, set_mo_source()
will read the file into R and will ask to export it to "~/mo_source.rds"
. The CRAN policy disallows packages to write to the file system, although 'exceptions may be allowed in interactive sessions if the package obtains confirmation from the user'. For this reason, this function only works in interactive sessions so that the user can specifically confirm and allow that this file will be created. The destination of this file can be set with the destination
argument and defaults to the user's home directory. It can also be set as an R option, using options(AMR_mo_source = "my/location/file.rds")
.
The created compressed data file "mo_source.rds"
will be used at default for MO determination (function as.mo()
and consequently all mo_*
functions like mo_genus()
and mo_gramstain()
). The location and timestamp of the original file will be saved as an attribute to the compressed data file.
set_mo_source()
will check the file for validity: it must be a data.frame, must have a column named "mo"
which contains values from microorganisms$mo
or microorganisms$fullname
and must have a reference column with your own defined values. If all tests pass, set_mo_source()
will read the file into R and will ask to export it to "~/mo_source.rds"
. The CRAN policy disallows packages to write to the file system, although 'exceptions may be allowed in interactive sessions if the package obtains confirmation from the user'. For this reason, this function only works in interactive sessions so that the user can specifically confirm and allow that this file will be created. The destination of this file can be set with the destination
argument and defaults to the user's home directory. It can also be set as an R option, using options(AMR_mo_source = "my/location/file.rds")
.
The created compressed data file "mo_source.rds"
will be used at default for MO determination (function as.mo()
and consequently all mo_*
functions like mo_genus()
and mo_gramstain()
). The location and timestamp of the original file will be saved as an attribute to the compressed data file.
The function get_mo_source()
will return the data set by reading "mo_source.rds"
with readRDS()
. If the original file has changed (by checking the location and timestamp of the original file), it will call set_mo_source()
to update the data file automatically if used in an interactive session.
Reading an Excel file (.xlsx
) with only one row has a size of 8-9 kB. The compressed file created with set_mo_source()
will then have a size of 0.1 kB and can be read by get_mo_source()
in only a couple of microseconds (millionths of a second).
Imagine this data on a sheet of an Excel file (mo codes were looked up in the microorganisms data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:
| A | B |
---|--------------------|--------------|
-1 | Organisation XYZ | mo |
-2 | lab_mo_ecoli | B_ESCHR_COLI |
-3 | lab_mo_kpneumoniae | B_KLBSL_PNMN |
-4 | | |
+Imagine this data on a sheet of an Excel file. The first column contains the organisation specific codes, the second column contains valid taxonomic names:
| A | B |
+--|--------------------|-----------------------|
+1 | Organisation XYZ | mo |
+2 | lab_mo_ecoli | Escherichia coli |
+3 | lab_mo_kpneumoniae | Klebsiella pneumoniae |
+4 | | |
We save it as "home/me/ourcodes.xlsx"
. Now we have to set it as a source:
set_mo_source("home/me/ourcodes.xlsx")
@@ -220,13 +220,13 @@ This is the fastest way to have your organisation (or analysis) specific codes p
#> Class <mo>
#> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
-If we edit the Excel file by, let's say, adding row 4 like this:
| A | B |
---|--------------------|--------------|
-1 | Organisation XYZ | mo |
-2 | lab_mo_ecoli | B_ESCHR_COLI |
-3 | lab_mo_kpneumoniae | B_KLBSL_PNMN |
-4 | lab_Staph_aureus | B_STPHY_AURS |
-5 | | |
+If we edit the Excel file by, let's say, adding row 4 like this:
| A | B |
+--|--------------------|-----------------------|
+1 | Organisation XYZ | mo |
+2 | lab_mo_ecoli | Escherichia coli |
+3 | lab_mo_kpneumoniae | Klebsiella pneumoniae |
+4 | lab_Staph_aureus | Staphylococcus aureus |
+5 | | |
...any new usage of an MO function in this package will update your data file:
diff --git a/docs/survey.html b/docs/survey.html
index a686c33f..f0faa2df 100644
--- a/docs/survey.html
+++ b/docs/survey.html
@@ -17,7 +17,7 @@
diff --git a/inst/tinytest/test-mic.R b/inst/tinytest/test-mic.R
index 1e4b714b..a82a992d 100755
--- a/inst/tinytest/test-mic.R
+++ b/inst/tinytest/test-mic.R
@@ -42,7 +42,8 @@ expect_inherits(x[1], "mic")
expect_inherits(x[[1]], "mic")
expect_inherits(c(x[1], x[9]), "mic")
expect_inherits(unique(x[1], x[9]), "mic")
-expect_inherits(droplevels(c(x[1], x[9])), "mic")
+expect_inherits(droplevels(c(x[1], x[9]), as.mic = TRUE), "factor")
+expect_inherits(droplevels(c(x[1], x[9]), as.mic = TRUE), "mic")
x[2] <- 32
expect_inherits(x, "mic")
expect_warning(as.mic("INVALID VALUE"))
diff --git a/man/mo_source.Rd b/man/mo_source.Rd
index 1c37fb15..eb8e1794 100644
--- a/man/mo_source.Rd
+++ b/man/mo_source.Rd
@@ -14,7 +14,7 @@ set_mo_source(
get_mo_source(destination = getOption("AMR_mo_source", "~/mo_source.rds"))
}
\arguments{
-\item{path}{location of your reference file, see \emph{Details}. Can be \code{""}, \code{NULL} or \code{FALSE} to delete the reference file.}
+\item{path}{location of your reference file, this can be any text file (comma-, tab- or pipe-separated) or an Excel file (see \emph{Details}). Can also be \code{""}, \code{NULL} or \code{FALSE} to delete the reference file.}
\item{destination}{destination of the compressed data file, default to the user's home directory.}
}
@@ -26,9 +26,9 @@ This is \strong{the fastest way} to have your organisation (or analysis) specifi
\details{
The reference file can be a text file separated with commas (CSV) or tabs or pipes, an Excel file (either 'xls' or 'xlsx' format) or an \R object file (extension '.rds'). To use an Excel file, you will need to have the \code{readxl} package installed.
-\code{\link[=set_mo_source]{set_mo_source()}} will check the file for validity: it must be a \link{data.frame}, must have a column named \code{"mo"} which contains values from \code{\link[=microorganisms]{microorganisms$mo}} and must have a reference column with your own defined values. If all tests pass, \code{\link[=set_mo_source]{set_mo_source()}} will read the file into \R and will ask to export it to \code{"~/mo_source.rds"}. The CRAN policy disallows packages to write to the file system, although '\emph{exceptions may be allowed in interactive sessions if the package obtains confirmation from the user}'. For this reason, this function only works in interactive sessions so that the user can \strong{specifically confirm and allow} that this file will be created. The destination of this file can be set with the \code{destination} argument and defaults to the user's home directory. It can also be set as an \R option, using \code{options(AMR_mo_source = "my/location/file.rds")}.
+\code{\link[=set_mo_source]{set_mo_source()}} will check the file for validity: it must be a \link{data.frame}, must have a column named \code{"mo"} which contains values from \code{\link[=microorganisms]{microorganisms$mo}} or \code{\link[=microorganisms]{microorganisms$fullname}} and must have a reference column with your own defined values. If all tests pass, \code{\link[=set_mo_source]{set_mo_source()}} will read the file into \R and will ask to export it to \code{"~/mo_source.rds"}. The CRAN policy disallows packages to write to the file system, although '\emph{exceptions may be allowed in interactive sessions if the package obtains confirmation from the user}'. For this reason, this function only works in interactive sessions so that the user can \strong{specifically confirm and allow} that this file will be created. The destination of this file can be set with the \code{destination} argument and defaults to the user's home directory. It can also be set as an \R option, using \code{options(AMR_mo_source = "my/location/file.rds")}.
-The created compressed data file \code{"mo_source.rds"} will be used at default for MO determination (function \code{\link[=as.mo]{as.mo()}} and consequently all \verb{mo_*} functions like \code{\link[=mo_genus]{mo_genus()}} and \code{\link[=mo_gramstain]{mo_gramstain()}}). The location and timestamp of the original file will be saved as an attribute to the compressed data file.
+The created compressed data file \code{"mo_source.rds"} will be used at default for MO determination (function \code{\link[=as.mo]{as.mo()}} and consequently all \verb{mo_*} functions like \code{\link[=mo_genus]{mo_genus()}} and \code{\link[=mo_gramstain]{mo_gramstain()}}). The location and timestamp of the original file will be saved as an \link[base:attributes]{attribute} to the compressed data file.
The function \code{\link[=get_mo_source]{get_mo_source()}} will return the data set by reading \code{"mo_source.rds"} with \code{\link[=readRDS]{readRDS()}}. If the original file has changed (by checking the location and timestamp of the original file), it will call \code{\link[=set_mo_source]{set_mo_source()}} to update the data file automatically if used in an interactive session.
@@ -37,12 +37,12 @@ Reading an Excel file (\code{.xlsx}) with only one row has a size of 8-9 kB. The
\section{How to Setup}{
-Imagine this data on a sheet of an Excel file (mo codes were looked up in the \link{microorganisms} data set). The first column contains the organisation specific codes, the second column contains an MO code from this package:\preformatted{ | A | B |
---|--------------------|--------------|
-1 | Organisation XYZ | mo |
-2 | lab_mo_ecoli | B_ESCHR_COLI |
-3 | lab_mo_kpneumoniae | B_KLBSL_PNMN |
-4 | | |
+Imagine this data on a sheet of an Excel file. The first column contains the organisation specific codes, the second column contains valid taxonomic names:\preformatted{ | A | B |
+--|--------------------|-----------------------|
+1 | Organisation XYZ | mo |
+2 | lab_mo_ecoli | Escherichia coli |
+3 | lab_mo_kpneumoniae | Klebsiella pneumoniae |
+4 | | |
}
We save it as \code{"home/me/ourcodes.xlsx"}. Now we have to set it as a source:\preformatted{set_mo_source("home/me/ourcodes.xlsx")
@@ -68,13 +68,13 @@ as.mo(c("Escherichia coli", "E. coli", "lab_mo_ecoli"))
#> [1] B_ESCHR_COLI B_ESCHR_COLI B_ESCHR_COLI
}
-If we edit the Excel file by, let's say, adding row 4 like this:\preformatted{ | A | B |
---|--------------------|--------------|
-1 | Organisation XYZ | mo |
-2 | lab_mo_ecoli | B_ESCHR_COLI |
-3 | lab_mo_kpneumoniae | B_KLBSL_PNMN |
-4 | lab_Staph_aureus | B_STPHY_AURS |
-5 | | |
+If we edit the Excel file by, let's say, adding row 4 like this:\preformatted{ | A | B |
+--|--------------------|-----------------------|
+1 | Organisation XYZ | mo |
+2 | lab_mo_ecoli | Escherichia coli |
+3 | lab_mo_kpneumoniae | Klebsiella pneumoniae |
+4 | lab_Staph_aureus | Staphylococcus aureus |
+5 | | |
}
...any new usage of an MO function in this package will update your data file:\preformatted{as.mo("lab_mo_ecoli")