Description Usage Arguments Details Value References See Also Examples
Either collect a metadata template from
OmniLog(R)
CSV comments assisting in later on adding
metadata using include_metadata
, or create
a data frame containing potential OPM
or
OPMS
object metadata.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | ## S4 method for signature 'MOPMX'
collect_template(object,
outfile = NULL, sep = "\t", previous = outfile, md.args = list(),
selection = opm_opt("csv.selection"), add.cols = NULL,
normalize = -1L, instrument = NULL, ..., demo = FALSE)
## S4 method for signature 'OPM'
collect_template(object, outfile = NULL,
sep = "\t", previous = outfile, md.args = list(),
selection = opm_opt("csv.selection"), add.cols = NULL, normalize = -1L,
instrument = NULL, ..., demo = FALSE)
## S4 method for signature 'OPMS'
collect_template(object, outfile = NULL,
sep = "\t", previous = outfile, md.args = list(),
selection = opm_opt("csv.selection"), add.cols = NULL, normalize = -1L,
instrument = NULL, ..., demo = FALSE)
## S4 method for signature 'character'
collect_template(object, outfile = NULL,
sep = "\t", previous = outfile, md.args = list(),
selection = opm_opt("csv.selection"), add.cols = NULL, normalize = -1L,
instrument = NULL, include = list(), ..., demo = FALSE)
## S4 method for signature 'ANY'
to_metadata(object, stringsAsFactors = FALSE,
optional = TRUE, sep = "\t", strip.white = FALSE, ...)
## S4 method for signature 'MOPMX'
to_metadata(object, stringsAsFactors = FALSE,
optional = TRUE, sep = "\t", strip.white = FALSE, ...)
## S4 method for signature 'WMD'
to_metadata(object, stringsAsFactors = FALSE,
optional = TRUE, sep = "\t", strip.white = FALSE, ...)
## S4 method for signature 'WMDS'
to_metadata(object, stringsAsFactors = FALSE,
optional = TRUE, sep = "\t", strip.white = FALSE, ...)
## S4 method for signature 'character'
to_metadata(object, stringsAsFactors = FALSE,
optional = TRUE, sep = c("\t", ",", ";"), strip.white = NA, ...)
|
object |
Character vector or If a character vector is provided to
|
outfile |
Character scalar. Ignored if |
sep |
Character scalar used for output
(CSV field separator for |
previous |
Ignored if empty. Otherwise passed to
|
md.args |
List of other arguments passed to the ‘to_metadata’ methods. |
add.cols |
Optional character vector with the names
of columns to be added to the result, or |
selection |
Elements to be extracted from the
CSV comments contained in each file. Character
vector passed to |
normalize |
Logical scalar also passed to
|
instrument |
Logical scalar or scalar convertible to
integer, or empty. Ignored if empty. If logical and
|
include |
File inclusion pattern (or generator for a
pattern). Passed to |
... |
Other arguments passed to
|
demo |
Logical scalar. Run in ‘demo’ mode?
Also passed to |
stringsAsFactors |
Logical scalar passed to
|
optional |
Logical scalar passed to
|
strip.white |
Logical scalar. For the file-name
method, passed to |
The collect_template
character method
batch-collects templates for meta-information from files
and optionally adds these data as novel rows to
previously collected data. It writes the collected
template to a file for use with an external editor,
and/or creates a data frame for editing the data directly
in R with the edit
function.
The to_metadata
character method reads metadata
from an input file and is only a thin wrapper for
read.delim
but contains some useful adaptations
(such as not converting strings to factors, and
not modifying column names). The default method
reads metadata from an object convertible to a data frame
and is only a thin wrapper of as.data.frame
but
contains the same useful adaptations as the file-name
method.
The WMD
and OPMS
methods
create a data frame from the contained metadata, where
necessary converting nested metadata entries to
data-frame columns of mode ‘list’. The number of
rows of the resulting data frame corresponds to the
length of object
, the number of columns to the
size of the set created from all valid names at the top
level of the metadata entries.
to_metadata
yields a data frame. The output of
collect_template
, in the case of the character
method, is a data frame, returned invisibly if
outfile
is given; if demo
is TRUE
, a
character vector of file names instead, returned
invisibly. The OPM
method returns a data
frame with one row and the number of columns equal to the
sum of the lengths of selection
and
add.cols
. The OPM
method returns
such a data frame with one row per contained plate.
base::default.stringsAsFactors base::as.data.frame
utils::edit utils::read.delim
Other io-functions: batch_collect
,
batch_opm
, batch_process
,
explode_dir
, file_pattern
,
glob_to_regex
,
read_opm
, read_single_opm
,
split_files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | ## collect_template()
# Character method
test.files <- opm_files("omnilog")
if (length(test.files) > 0) { # if the files are found
# Without writing to a file
(x <- collect_template(test.files))
stopifnot(is.data.frame(x), identical(x[, "File"], test.files))
# now proceed with e.g.
# x <- edit(x)
# Write to file
outfile <- tempfile()
stopifnot(!file.exists(outfile))
# This results in a CSV outfile which could be used as a starting point
# for including the metadata of interest together with the plate
# identifiers in a single file. include_metadata() can then be used to
# integrate the metadata in OPMX objects.
x <- collect_template(test.files, outfile = outfile)
stopifnot(file.exists(outfile))
unlink(outfile)
} else {
warning("test files not found")
}
# OPM method
(x <- collect_template(vaas_1)) # => data frame, one row per plate
stopifnot(dim(x) == c(1, 3))
(x <- collect_template(vaas_1, instrument = TRUE))
stopifnot(dim(x) == c(1, 4))
(x <- collect_template(vaas_1, add.cols = c("A", "B")))
stopifnot(dim(x) == c(1, 5)) # => data frame with more columns
# see include_metadata() for how to use this to add metadata information
# OPMS method
(x <- collect_template(vaas_4)) # => data frame, one row per plate
stopifnot(identical(dim(x), c(4L, 3L)))
(x <- collect_template(vaas_4, add.cols = c("A", "B")))
stopifnot(identical(dim(x), c(4L, 5L))) # => data frame with more columns
# again see include_metadata() for how to use this to add metadata
# information
## to_metadata()
# Character method
(x <- to_metadata(list(a = 7:8, `b c` = letters[1:2])))
tmpfile <- tempfile()
write.table(x, tmpfile, row.names = FALSE, sep = "\t")
(x1 <- read.delim(tmpfile)) # comparison with base R function
(x2 <- to_metadata(tmpfile))
stopifnot(identical(names(x2), names(x)), !identical(names(x1), names(x)))
# Default method
x <- list(a = 7:8, `b c` = letters[1:2])
(x1 <- as.data.frame(x))
(x2 <- to_metadata(x))
stopifnot(!identical(names(x), names(x1)), identical(names(x), names(x2)))
# WMD method
(x <- to_metadata(vaas_1)) # one row per OPM object
stopifnot(is.data.frame(x), nrow(x) == length(vaas_1), ncol(x) > 0)
# OPMS method
(x <- to_metadata(vaas_4)) # one row per OPM object
stopifnot(is.data.frame(x), nrow(x) == length(vaas_4), ncol(x) > 0)
copy <- vaas_4
metadata(copy) <- x
stopifnot(identical(copy, vaas_4))
# ... this works only in the special case of non-nested metadata that
# have the same set of entries in all OPMS elements
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.