Perform data transformations, or set up chains of transformations and
operations to be applied to matrix type data. processData()
is a generic
for which methods can be defined off both x
(the data to transform),
and param
(the transform operation).
# S4 method for class 'exprObj,list'
processData(x, param, name = "scaled", ...)
# S4 method for class 'exprObj,normParam'
processData(x, param, name = "normalized", ...)
# S4 method for class 'exprObj,scaleParam'
processData(x, param, name = "scaled", ...)
# S4 method for class 'exprObj,adjustParam'
processData(x, param, name = "custom", ...)
# S4 method for class 'allMatrix,list'
processData(x, param, ...)
data to transform
S4 parameter class defining the transform operation and params affecting it. Can also be a list of several of these objects, acting as a pipeline.
character (optional). Object name
to assign to the output. Default name
changes based on param
input:
when param
is list
or scaleParam
: name = "scaled"
when param
is normParam
: name = "normalized"
when param
is adjustParam
: name = "custom"
when param
is osmFISHNormParam
: name = "custom"
when param
is pearsonResidNormParam
: name = "scaled"
additional params to pass
The same class as x
process_param for processing operations that can be performed
through processData()
processExpression()
for the way to use this framework with the
giotto
object
m <- matrix(c(0, 0, 3, 2, 0, 5, 4, 0, 0, 1, 12, 0), nrow = 3)
# single operation
lib_norm <- normParam("library")
lib_norm$scalefactor <- 5000 # alter a default param of library norm
processData(m, lib_norm)
#> [,1] [,2] [,3] [,4]
#> [1,] 0 1428.571 5000 384.6154
#> [2,] 0 0.000 0 4615.3846
#> [3,] 5000 3571.429 0 0.0000
# chained operations
log_norm <- normParam("log")
zscore_rows <- scaleParam("zscore", MARGIN = 1)
zscore_cols <- scaleParam("zscore")
# this is essentially the same as the default giotto normalization
# only difference is the library norm scalefactor change.
processData(m, list(lib_norm, log_norm, zscore_rows, zscore_cols))
#> [,1] [,2] [,3] [,4]
#> [1,] -0.9286596 0.3090142 1.1298095 -0.1005791
#> [2,] -0.1299711 -1.1180333 -0.3583914 1.0464888
#> [3,] 1.0586307 0.8090191 -0.7714182 -0.9459097