Description Usage Arguments Details Value See Also Examples
Select a subset of the plates in an OPMS
object based on the content of the metadata.
Alternatively, select a common subset of time points from
all plates. thin_out
keeps only a regular subset
of the time points from OPM
measurements.
This is a mainly experimental function that might be of
use in testing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## S4 method for signature 'MOPMX'
subset(x, query, values = TRUE,
invert = FALSE, exact = FALSE, time = FALSE, positive = "ignore",
negative = "ignore", common = FALSE, use = "i", ...)
## S4 method for signature 'OPMX'
subset(x, query, values = TRUE,
invert = FALSE, exact = FALSE, time = FALSE,
positive = c("ignore", "any", "all"),
negative = c("ignore", "any", "all"),
common = FALSE,
use = c("i", "I", "k", "K", "n", "N", "p", "P", "q", "Q", "t", "T",
"c", "C"))
## S4 method for signature 'MOPMX'
thin_out(object, ...)
## S4 method for signature 'OPM'
thin_out(object, factor, drop = FALSE)
## S4 method for signature 'OPMS'
thin_out(object, ...)
|
x |
|
query |
Logical or numeric vector or object accepted
as query by the infix operators. If a logical or numeric
vector, |
values |
Logical scalar. If That is, choose either the plates for which certain
metadata entries contain certain values, or choose the
plates for which these metadata have been set at all (to
some arbitrary value). See the mentioned functions for
details, and note the special behaviour if |
invert |
Logical scalar. If |
exact |
Logical scalar. If the values of
|
time |
Logical scalar. If |
positive |
Character scalar. If ‘ignore’, not
used. Otherwise all previous arguments except
If |
negative |
Character scalar. Like |
common |
Logical scalar. If |
use |
Character scalar. An alternative way to specify the settings. If ‘i’ or ‘I’, ignored. If ‘t’ or
‘T’, Otherwise, |
object |
|
factor |
Numeric scalar >= 1 indicating how much the data set shall be thinned out. |
drop |
Logical scalar. See |
... |
Optional arguments passed between the methods. |
The MOPMX
method creates subsets of all
contained OPMX
objects (if any) in turn and
then removes those that yielded NULL
. Thus
subset
is not intended for directly creating
subsets of MOPMX
but of their elements to
yield, e.g., elements that have a common set of
metadata
entries, as required under most
circumstances by some other MOPMX
methods
such as extract
.
Thinning the plates out is experimental insofar as it has not been tested whether and how this could sensibly be applied before aggregating the data.
NULL
or OPM
or OPMS
object. This depends on how many plates are selected; see
[
for details. The MOPMX
method always returns a MOPMX
object.
base::'[' base::'[[' base::subset
Other getter-functions: aggr_settings
,
aggregated
, anyDuplicated
,
anyNA
, contains
,
csv_data
, dim
,
disc_settings
, discretized
,
duplicated
, has_aggr
,
has_disc
, hours
,
max
, measurements
,
minmax
, seq
,
well
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 | # simple object comparison function
mustbe <- function(a, b) stopifnot(identical(a, b))
# all plates have that entry: selection identical to original object
mustbe(vaas_4, vaas_4["Species" %k% vaas_4, ])
mustbe(vaas_4, subset(vaas_4, list(Species = "Escherichia coli"),
values = FALSE)) # equivalent
mustbe(vaas_4, subset(vaas_4, ~ Species == "Escherichia coli",
values = FALSE)) # also equivalent
# two plates also have that value: yielding OPMS object with only two plates
mustbe(vaas_4[1:2], vaas_4[list(Species = "Escherichia coli") %q% vaas_4, ])
mustbe(vaas_4[1:2], subset(vaas_4, list(Species = "Escherichia coli")))
mustbe(vaas_4[1:2], subset(vaas_4, ~ Species == "Escherichia coli"))
# these are also equivalent
mustbe(vaas_4[c(1, 3)],
vaas_4[list(Strain = c("DSM18039", "DSM1707")) %q% vaas_4])
mustbe(vaas_4[c(1, 3)],
subset(vaas_4, list(Strain = c("DSM18039", "DSM1707"))))
mustbe(vaas_4[c(1, 3)],
subset(vaas_4, ~ Strain %in% c("DSM18039", "DSM1707")))
mustbe(vaas_4[c(1, 3)],
subset(vaas_4, ~ Strain == "DSM18039" || Strain == "DSM1707"))
# note that particularly formulae can be used to set up very complex queries
# select all plates that have aggregated values
dim(x <- subset(vaas_4, has_aggr(vaas_4)))
mustbe(x, vaas_4) # all have such values
# select a common set of time points
dim(x <- subset(vaas_4, time = TRUE))
mustbe(x, vaas_4) # the time points had already been identical
# create unequal time points
dim(copy <- vaas_4[, list(1:10, 1:20, 1:15, 1:10)])
mustbe(hours(copy), c(2.25, 4.75, 3.50, 2.25))
# now restrict to common subset
dim(x <- subset(copy, time = TRUE))
mustbe(hours(x), rep(2.25, 4))
# see also the example with split() given under "["
# select all wells that have positive reactions
dim(x <- subset(vaas_4, use = "p")) # in at least one plate
stopifnot(dim(x)[3] < dim(vaas_4)[3])
dim(y <- subset(vaas_4, use = "P")) # in all plates
stopifnot(dim(y)[3] < dim(x)[3])
# select all wells that have non-negative reactions in at least one plate
dim(y <- subset(vaas_4, use = "N", invert = TRUE))
stopifnot(dim(y)[3] > dim(x)[3])
## thin_out()
# 'OPM' method
(x <- dim(vaas_1))
stopifnot(identical(x, c(384L, 96L)))
copy <- thin_out(vaas_1, 10) # keep every 10th time point and measurement
(x <- dim(copy))
stopifnot(identical(x, c(38L, 96L)), has_aggr(copy))
copy <- thin_out(vaas_1, 10, drop = TRUE) # also remove the parameters
(x <- dim(copy))
stopifnot(identical(x, c(38L, 96L)), !has_aggr(copy))
# 'OPMS' method
(x <- dim(vaas_4))
stopifnot(identical(x, c(4L, 384L, 96L)))
copy <- thin_out(vaas_4, 10)
(x <- dim(copy))
stopifnot(identical(x, c(4L, 38L, 96L)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.