[ {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))
## [1] 384 96
stopifnot(x == c(384, 96))
# selecting specific wells
copy <- vaas_1[, 11:22]
(x <- dim(copy))
## [1] 384 12
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])
## 1
## Class OPMD
## From file ./E. coli DSM
## 18039_vim10_12B__1_28_PMX_0_8#30#2010_E_12B_5.csv
## Hours measured 95.75
## Number of wells 96
## Plate type Gen III
## Position 12-B
## Setup time 8/30/2010 1:19:11 PM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
##
## 2
## Class OPMD
## From file ./E. coli DSM
## 30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
## 7B_5.csv
## Hours measured 95.75
## Number of wells 96
## Plate type Gen III
## Position 7-B
## Setup time 8/30/2010 1:53:08 PM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
##
## => OPMS object with 2 plates (2 aggregated, 2 discretized) of type 'Gen III', 96 well(s) and about 384 time point(s).
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])
## 1
## Class OPMD
## From file ./E. coli DSM
## 18039_vim10_12B__1_28_PMX_0_8#30#2010_E_12B_5.csv
## Hours measured 95.75
## Number of wells 12
## Plate type Gen III
## Position 12-B
## Setup time 8/30/2010 1:19:11 PM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
##
## 2
## Class OPMD
## From file ./E. coli DSM
## 30083T_vim10_7B__1_28_PMX_0_8#30#2010_F_
## 7B_5.csv
## Hours measured 95.75
## Number of wells 12
## Plate type Gen III
## Position 7-B
## Setup time 8/30/2010 1:53:08 PM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
##
## 3
## Class OPMD
## From file ./P. aeruginosa DSM
## 1707_vim10_17B__1_28_PMX_0_8#30#2010_D_17B_5.csv
## Hours measured 95.75
## Number of wells 12
## Plate type Gen III
## Position 17-B
## Setup time 8/30/2010 12:31:46 PM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
##
## 4
## Class OPMD
## From file ./P. aeruginosa St.
## 429_vim10_22B__1_28_PMX_0_8#30#2010_C_22B_5.csv
## Hours measured 95.75
## Number of wells 12
## Plate type Gen III
## Position 22-B
## Setup time 8/30/2010 11:28:54 AM
## Metadata 5
## Aggregated TRUE
## Discretized TRUE
##
## => OPMS object with 4 plates (4 aggregated, 4 discretized) of type 'Gen III', 12 well(s) and about 384 time point(s).
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
## Length Plate.type Aggregated Discretized
## NA. 1 Gen III 1 1
## NA..1 4 Gen III 4 4
##
## => MOPMX object with 2 element(s), details are shown above.
## Access the elements with [[ or $ to apply specific methods.
stopifnot(is(x, "MOPMX"), length(x) == 2)
(y <- x[~ Species != "Escherichia coli"])
## Warning: closing gaps in indexes
## Length Plate.type Aggregated Discretized
## NA. 2 Gen III 2 2
##
## => MOPMX object with 1 element(s), details are shown above.
## Access the elements with [[ or $ to apply specific methods.
stopifnot(is(y, "MOPMX"), length(y) == 1)
(y <- x[list(1, 3:4)]) # only 2nd element reduced
## Length Plate.type Aggregated Discretized
## NA. 1 Gen III 1 1
## NA..1 2 Gen III 2 2
##
## => MOPMX object with 2 element(s), details are shown above.
## Access the elements with [[ or $ to apply specific methods.
stopifnot(is(y, "MOPMX"), length(y) == 2, !identical(x, y))