[ {opm} | R Documentation |
Select a subset of the measurements
(and,
if present, of the aggregated
data and the
discretized
data) or plates. Return this
subset (or these subsets) together with the other slots
(which are unchanged).
## S4 method for signature 'MOPMX,ANY,missing,ANY' x[i, j, drop] ## S4 method for signature 'MOPMX,ANY,missing,missing' x[i, j, drop] ## S4 method for signature 'MOPMX,character,missing,ANY' x[i, j, drop] ## S4 method for signature 'MOPMX,character,missing,missing' x[i, j, drop] ## S4 method for signature 'MOPMX,expression,missing,ANY' x[i, j, drop] ## S4 method for signature 'MOPMX,expression,missing,missing' x[i, j, drop] ## S4 method for signature 'MOPMX,formula,missing,ANY' x[i, j, drop] ## S4 method for signature 'MOPMX,formula,missing,missing' x[i, j, drop] ## S4 method for signature 'MOPMX,list,missing,ANY' x[i, j, drop] ## S4 method for signature 'MOPMX,list,missing,missing' x[i, j, drop] ## S4 method for signature 'MOPMX,missing,missing,ANY' x[i, j, drop] ## S4 method for signature 'MOPMX,missing,missing,missing' x[i, j, drop] ## S4 method for signature 'OPM,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'OPMA,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'OPMD,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'OPMS,ANY,ANY,ANY' x[i, j, k, ..., drop = FALSE]
x |
|
i |
Vector or missing. For the For the For the |
j |
Vector or missing.
|
k |
Vector or missing. The |
... |
This should not be set. It is an error to specify additional dimensions. |
drop |
Logical scalar. Remove the aggregated data
(and the discretised data, if any) and turn an
|
The OPMA
method works like the
OPM
one, but the function applies the
subset creation to the original and the aggregated data
in parallel. The OPMD
method applies the
selection also to the discretised data.
The aggregated and discretised data may also be dropped entirely; this might be appropriate if a subset of the time points is selected, potentially yielding aggregated values that do not fit to the measurements anymore.
In contrast to the usual '[' methods, with respect to the
measurements this always return a matrix (as a component
of the returned object), even if it could be simplified
to a vector. The time column is not counted and always
copied. It is an error to delete the entire matrix. In
all other respects, the OPM
method behaves
like the '[' methods from the base package.
The OPMS
method selects a subset of the
plates and/or the measurements of the individual plates.
It simplifies the outcome to a OPM
or
OPMA
object if only a single plate remains
and to NULL
if no plate remains. This is different
from creating subsets of a list in R. OPMS
subset creation rather behaves like subset creation a
three-dimensional array with plates as first dimension,
time points as second, and wells as third.
OPM
, OPMA
or
OPMS
object, or NULL
.
base::'[' base::'[['
## OPM(A) method # complete dataset, full 96-well plates (x <- dim(vaas_1)) stopifnot(x == c(384, 96)) # selecting specific wells copy <- vaas_1[, 11:22] (x <- dim(copy)) stopifnot(x == c(384, 12)) # indexing with formulae allows for sequences of well coordinates copy <- vaas_1[, ~ A11:B10] # "A11" is 11th, "B10" is 22th well name stopifnot(dim(copy) == c(384, 12)) # same result as above # can also be combined copy <- vaas_1[, ~ A11:22] stopifnot(dim(copy) == c(384, 12)) # same result as above # dropping aggregated data copy <- vaas_1[] # normal selection stopifnot(has_aggr(copy), identical(copy, vaas_1)) copy <- vaas_1[drop = TRUE] # selection with dropping stopifnot(!has_aggr(copy), !identical(copy, vaas_1)) ## OPMS method # Create OPMS object with fewer plates (the first two ones) (x <- vaas_4[1:2]) stopifnot(is(x, "OPMS"), dim(x) == c(2, 384, 96)) # we can select the same objects with a formula (which is passed through # the infix-q operator) stopifnot(identical(vaas_4[~ Species == "Escherichia coli"], x)) # we can select another infix operator with the left side of the formula stopifnot(identical(vaas_4[k ~ Species], vaas_4)) # If only a single plate is selected, this is reduced to OPM(A) x <- vaas_4[3] stopifnot(!is(x, "OPMS"), dim(x) == c(384, 96)) # Create OPMS object with fewer time points (the first 100 in that case; # usually this would correspond to the first 25 hours) x <- vaas_4[, 1:100] stopifnot(dim(x) == c(4, 100, 96)) # Create OPMS object with fewer wells (x <- vaas_4[, , 1:12]) stopifnot(dim(x) == c(4, 384, 12)) # The same with well names x <- vaas_4[, , ~ A01:A12] # within x, these are well names 1 to 12 stopifnot(dim(x) == c(4, 384, 12)) # to do this with a vector, one would need sprintf("A%02i", 1:12) # Select all plates that have aggregated values x <- vaas_4[has_aggr(vaas_4)] stopifnot(identical(x, vaas_4)) # all have such values! # Traverse all contained OPM objects for (i in seq(vaas_4)) { # OR: for (i in 1:length(vaas_4)) x <- vaas_4[i] # now do something with 'x'... stopifnot(dim(x) == c(384, 96)) } # see also oapply() for a more elegant approach ## MOPMX method (x <- new("MOPMX", list(vaas_1, vaas_4))) # create MOPMX object stopifnot(is(x, "MOPMX"), length(x) == 2) (y <- x[~ Species != "Escherichia coli"]) stopifnot(is(y, "MOPMX"), length(y) == 1) (y <- x[list(1, 3:4)]) # only 2nd element reduced stopifnot(is(y, "MOPMX"), length(y) == 2, !identical(x, y))