do_disc {opm} | R Documentation |
Discretise the aggregated kinetic data, i.e. infer
discrete values from the curve parameters stored in an
OPMA
or OPMS
object. Here,
only discretisation into positive, negative and ambiguous
reactions is supported, and by default based on the
‘maximum height’ curve parameter (which is
biologically reasonable though).
## S4 method for signature 'MOPMX' do_disc(object, ...) ## S4 method for signature 'OPMA' do_disc(object, cutoff, groups = FALSE, plain = FALSE, subset = opm_opt("disc.param"), unify = FALSE) ## S4 method for signature 'OPMS' do_disc(object, cutoff = TRUE, groups = FALSE, plain = FALSE, subset = opm_opt("disc.param"), unify = !length(cutoff), ...)
object |
|
cutoff |
Determines the discretisation approach. If
not |
groups |
List, Note that if The |
plain |
Logical scalar indicating whether or not an
|
subset |
Character scalar passed to
|
unify |
Logical or numeric scalar indicating whether
results should be unified per group. This works by
choosing the most frequent value (mode) if its frequency
is above a given threshold and If If See ‘Details’ below on the potential consequences
of unification. In the The |
... |
Optional arguments passed between the methods
or to |
If unify
is set to FALSE
, the
discretisation results are always consistent (in the
sense described for the OPMD
class) with
the discretised parameter. If unify
is set to
TRUE
this cannot be guaranteed any more. To
enforce consistency, use opm_opt(strict.OPMD =
TRUE)
.
The discretised values can be queried for using
has_disc
and received using
discretized
.
If plain
is FALSE
, an OPMD
or
OPMS
object. Otherwise a logical vector
whose length corresponds to the number of wells in
object
with an additional ‘settings’
attribute describing the run. The vector and its
attribute would correspond to the
discretized
and disc_settings
entries of a resulting OPMD
object,
respectively.
Other discretization-functions:
best_cutoff
, discrete
## OPMA method
# arbitrary threshold, no ambiguity
summary(x <- do_disc(vaas_1, cutoff = 100))
## 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
stopifnot(has_disc(x), dim(x) == dim(vaas_1), !is.na(discretized(x)))
(y <- disc_settings(x)) # stored discretisation settings
## $method
## [1] "direct"
##
## $options
## $options$cutoffs
## [1] 100
##
## $options$datasets
## [1] 1
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "direct"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# arbitrary thresholds, allowing intermediate ('weak') reactions
summary(x <- do_disc(vaas_1, cutoff = c(75, 125)))
## 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
# the intermediate reactions are coded as NA
stopifnot(has_disc(x), dim(x) == dim(vaas_1), anyNA(discretized(x)))
(y <- disc_settings(x)) # stored discretisation settings
## $method
## [1] "direct"
##
## $options
## $options$cutoffs
## [1] 75 125
##
## $options$datasets
## [1] 1
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "direct"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# using k-means, two categories, no intermediate ('weak') reactions
summary(x <- do_disc(vaas_1, cutoff = FALSE))
## 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
stopifnot(has_disc(x), dim(x) == dim(vaas_1), !is.na(discretized(x)))
(y <- disc_settings(x)) # stored discretisation settings
## $method
## [1] "kmeans"
##
## $options
## $options$cutoffs
## [1] 196.6758
##
## $options$datasets
## [1] 1
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "kmeans"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# using k-means, now allowing intermediate ('weak') reactions
summary(x <- do_disc(vaas_1, cutoff = TRUE))
## 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
stopifnot(has_disc(x), dim(x) == dim(vaas_1), any(discretized(x)))
(y <- disc_settings(x)) # stored discretisation settings
## $method
## [1] "kmeans"
##
## $options
## $options$cutoffs
## [1] 129.0670 241.2105
##
## $options$datasets
## [1] 1
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "kmeans"))
stopifnot(is.list(y), is.list(y$options)) # named lists
## OPMS method
# arbitrary threshold, no ambiguity, no groups
x <- do_disc(vaas_4, cutoff = 100)
stopifnot(has_disc(x), dim(x) == dim(vaas_4), !is.na(discretized(x)))
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "direct"
##
## $options
## $options$cutoffs
## [1] 100
##
## $options$datasets
## [1] 4
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "direct"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# arbitrary threshold, no ambiguity, no groups, with unification
x <- do_disc(vaas_4, cutoff = 100, unify = TRUE)
## Warning: discretized data inconsistent with 'A' parameter
## Warning: discretized data inconsistent with 'A' parameter
## Warning: discretized data inconsistent with 'A' parameter
stopifnot(has_disc(x), dim(x) == dim(vaas_4))
stopifnot(anyNA(discretized(x))) # NAs caused by unification
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "direct"
##
## $options
## $options$cutoffs
## [1] 100
##
## $options$datasets
## [1] 4
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] 0.5
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "direct"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# all plates made uniform (makes not much sense)
# arbitrary threshold, no ambiguity, with groups, 1 plate per group
x <- do_disc(vaas_4, cutoff = 100, groups = TRUE)
stopifnot(has_disc(x), dim(x) == dim(vaas_4), !is.na(discretized(x)))
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "direct"
##
## $options
## $options$cutoffs
## [1] 100
##
## $options$datasets
## [1] 1
##
## $options$group
## [1] "1"
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "direct"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# here, the plate numbers yield the group names
# arbitrary threshold, no ambiguity, with specified groups
x <- do_disc(vaas_4, cutoff = 100, groups = "Species")
stopifnot(has_disc(x), dim(x) == dim(vaas_4), !is.na(discretized(x)))
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "direct"
##
## $options
## $options$cutoffs
## [1] 100
##
## $options$datasets
## [1] 2
##
## $options$group
## [1] "Escherichia coli"
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "direct"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# now, groups are from the metadata (but played no role)
# using k-means, no ambiguity, with specified groups
x <- do_disc(vaas_4, cutoff = FALSE, groups = "Species")
stopifnot(has_disc(x), dim(x) == dim(vaas_4), !is.na(discretized(x)))
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "kmeans"
##
## $options
## $options$cutoffs
## [1] 172.6614
##
## $options$datasets
## [1] 2
##
## $options$group
## [1] "Escherichia coli"
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] -1
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "kmeans"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# grouping by species, discretised separately
# same, with unification
x <- do_disc(vaas_4, cutoff = FALSE, groups = "Species", unify = TRUE)
stopifnot(has_disc(x), dim(x) == dim(vaas_4))
stopifnot(anyNA(discretized(x))) # NAs caused by unification
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "kmeans"
##
## $options
## $options$cutoffs
## [1] 172.6614
##
## $options$datasets
## [1] 2
##
## $options$group
## [1] "Escherichia coli"
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] 0.5
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "kmeans"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# grouping by species, discretised separately, then made uniform
# using best_cutoff(), groups defined by species affiliation (makes not
# much sense and by default yields warnings with these data)
x <- do_disc(vaas_4, cutoff = NULL, groups = "Species")
stopifnot(has_disc(x), dim(x) == dim(vaas_4), anyNA(discretized(x)))
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "best-cutoff"
##
## $options
## $options$cutoffs
## [1] 239.5111
##
## $options$datasets
## [1] 2
##
## $options$score
## [1] 1.62
##
## $options$group
## [1] "Escherichia coli"
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] 0.5
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "best-cutoff"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# groups as above, 2 strains per species, but some additional entries
# using best_cutoff(), single group for all plates (makes even less sense
# and by default also yields warnings with these data)
x <- do_disc(vaas_4, cutoff = NULL, groups = FALSE)
## Warning: discretized data inconsistent with 'A' parameter
## Warning: discretized data inconsistent with 'A' parameter
## Warning: discretized data inconsistent with 'A' parameter
## Warning: discretized data inconsistent with 'A' parameter
stopifnot(has_disc(x), dim(x) == dim(vaas_4), anyNA(discretized(x)))
(y <- disc_settings(x)[[1]]) # stored discretisation settings
## $method
## [1] "best-cutoff"
##
## $options
## $options$cutoffs
## [1] 222.5776
##
## $options$datasets
## [1] 4
##
## $options$score
## [1] 1.604167
##
## $options$parameter
## [1] "A"
##
## $options$unified
## [1] 0.5
##
##
## $software
## [1] "opm"
##
## $version
## [1] "1.3.63"
stopifnot(identical(y$method, "best-cutoff"))
stopifnot(is.list(y), is.list(y$options)) # named lists
# no subgroups, all 4 data sets in one group, and some additional entries