csv_data {opm} | R Documentation |
Information about the plate as originally read from the
input CSV file (see read_opm
and
read_single_opm
for reading such files).
## S4 method for signature 'MOPMX' csv_data(object, ...) ## S4 method for signature 'OPM' csv_data(object, keys = character(), strict = TRUE, what = c("select", "filename", "setup_time", "position", "other"), normalize = FALSE) ## S4 method for signature 'OPMS' csv_data(object, ...)
object |
|
keys |
Character vector (or other objects usable as
vector index). An optional sub-selection. If empty (the
default), all CSV data are returned. By default
it is an error to select non-existing items. Ignored
unless |
strict |
Logical scalar indicating whether or not it
is an error if |
what |
Character scalar specifying a subset of the
data. If ‘select’, use |
normalize |
Logical or integer scalar indicating
whether plate position and setup time entries (if
selected) should be normalised. This should always work
for the plate positions, but for the setup times it
depends on the values for the For |
... |
Optional arguments passed between the methods. |
It is easy to copy the CSV data to the
metadata
; see the examples section. Editing
of the CSV data has deliberately not been
implemented into opm, but the
metadata
can be modified using a plethora
of methods, even manually with edit
.
For the OPM
method, a named character
vector (unnamed character scalar in the case of
filename
, setup_time
and filename
and if what
is not ‘select’). For the other
methods either a named character vector (if the selection
yields a single entry) or a character matrix with one row
per plate. Missing entries in one of the plates yield
NA
in the output.
base::strptime
Other getter-functions: aggr_settings
,
aggregated
, anyDuplicated
,
anyNA
, contains
,
dim
, disc_settings
,
discretized
, duplicated
,
has_aggr
, has_disc
,
hours
, max
,
measurements
, minmax
,
seq
, subset
,
thin_out
, well
## 'OPM' method
(x <- csv_data(vaas_1, "Setup Time"))
## Setup Time
## "8/30/2010 1:53:08 PM"
stopifnot(identical(x, c(`Setup Time` = "8/30/2010 1:53:08 PM")))
# compare this to 'what = "setup_time"'; here, names are kept
(y <- csv_data(vaas_1, "Setup Time", normalize = TRUE))
## Setup Time
## "2010-08-30 13:53:08"
stopifnot(!is.na(y), y != x, names(y) == names(x))
(x <- csv_data(vaas_1, what = "filename")) # one file name (of course)
## [1] "./E. coli DSM 30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_ 7B_5.csv"
stopifnot(is.character(x), length(x) == 1L)
(x <- csv_data(vaas_1, what = "position")) # single position (of course)
## [1] " 7-B"
(y <- csv_data(vaas_1, what = "position", normalize = TRUE))
## [1] "07-B"
stopifnot(x == " 7-B", y == "07-B") # four characters when normalised
(x <- csv_data(vaas_1, what = "setup_time")) # single setup time (of course)
## [1] "8/30/2010 1:53:08 PM"
(y <- csv_data(vaas_1, what = "setup_time", normalize = TRUE))
## [1] "2010-08-30 13:53:08"
stopifnot(length(x) == 1, x != y) # converted to canonical data/time format
# WARNING: It is unlikely that all OmniLog output has the setup-time format
# defined by default in opm_opt("time.fmt")
## 'OPMS' method
(x <- csv_data(vaas_4, "Setup Time")) # one setup time per plate
## Setup Time Setup Time Setup Time
## "8/30/2010 1:19:11 PM" "8/30/2010 1:53:08 PM" "8/30/2010 12:31:46 PM"
## Setup Time
## "8/30/2010 11:28:54 AM"
stopifnot(is.character(x), length(x) == 4)
(x <- csv_data(vaas_4, what = "filename")) # one file name per plate
## [1] "./E. coli DSM 18039_vim10_12B__1_28_PMX_0_8#30#2010_E_12B_5.csv"
## [2] "./E. coli DSM 30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_ 7B_5.csv"
## [3] "./P. aeruginosa DSM 1707_vim10_17B__1_28_PMX_0_8#30#2010_D_17B_5.csv"
## [4] "./P. aeruginosa St. 429_vim10_22B__1_28_PMX_0_8#30#2010_C_22B_5.csv"
stopifnot(is.character(x), length(x) == 4L)
(x <- csv_data(vaas_4, what = "position")) # one position per plate
## [1] "12-B" " 7-B" "17-B" "22-B"
stopifnot(is.character(x), length(x) == length(vaas_4))
(x <- csv_data(vaas_4, what = "setup_time")) # one setup time per plate
## [1] "8/30/2010 1:19:11 PM" "8/30/2010 1:53:08 PM" "8/30/2010 12:31:46 PM"
## [4] "8/30/2010 11:28:54 AM"
(y <- csv_data(vaas_4, what = "setup_time", normalize = TRUE))
## [1] "2010-08-30 13:19:11" "2010-08-30 13:53:08" "2010-08-30 12:31:46"
## [4] "2010-08-30 11:28:54"
stopifnot(length(x) == 4, x != y) # converted to canonical data/time format
# see the warning above
## Useful application: copying selected CSV data to the metadata
x <- vaas_4
# this appends the CSV data after conversion to a suitable data frame
metadata(x, -1) <- to_metadata(csv_data(x, what = "other"))
to_metadata(x)
## Experiment Species Strain Slot Plate number
## 1 First replicate Escherichia coli DSM18039 B 6
## 2 First replicate Escherichia coli DSM30083T B 6
## 3 First replicate Pseudomonas aeruginosa DSM1707 B 6
## 4 First replicate Pseudomonas aeruginosa 429SC1 B 6
## Data File
## 1 C:\\Dokumente und Einstellungen\\Johannes\\Eigene Dateien\\Korrespondenz\\Lea\\R-Paket paper\\d5e-files\\1st tech replicate\\E. coli DSM 18039_vim10_12B__1_28_PMX_0_8#30#2010_E_12B_5.oka
## 2 C:\\Dokumente und Einstellungen\\Johannes\\Eigene Dateien\\Korrespondenz\\Lea\\R-Paket paper\\d5e-files\\1st tech replicate\\E. coli DSM 30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_ 7B_5.oka
## 3 C:\\Dokumente und Einstellungen\\Johannes\\Eigene Dateien\\Korrespondenz\\Lea\\R-Paket paper\\d5e-files\\1st tech replicate\\P. aeruginosa DSM 1707_vim10_17B__1_28_PMX_0_8#30#2010_D_17B_5.oka
## 4 C:\\Dokumente und Einstellungen\\Johannes\\Eigene Dateien\\Korrespondenz\\Lea\\R-Paket paper\\d5e-files\\1st tech replicate\\P. aeruginosa St. 429_vim10_22B__1_28_PMX_0_8#30#2010_C_22B_5.oka
## Strain Type Sample Number Strain Name Strain Number Other
## 1 E. coli DSM 18039 12B vim10
## 2 E. coli DSM 30083T 7B vim10
## 3 P. aeruginosa DSM 1707 17B vim10
## 4 P. aeruginosa St. 429 22B vim10
stopifnot(sapply(metadata(x), length) > sapply(metadata(vaas_4), length))