Perform data transformations, or set up chains of transformations and
operations to be applied to expression type data in the giotto object.
processExpression(
gobject,
param,
name = NULL,
expression_values = "raw",
spat_unit = NULL,
feat_type = NULL,
return_gobject = TRUE,
...
)giotto object
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"
character. Name of matrix to use
character (optional). spatial unit to use
character (optional). feature type to use
logical (optional). Whether to return the gobject.
When FALSE, the exprObj is returned instead.
additional params to pass
A giotto object when return_gobject = TRUE. Otherwise, an
exprObj
process_param for processing operations that can be performed
processData() for the lower level generic handling these operations
g <- GiottoData::loadGiottoMini("visium")
#> 1. read Giotto object
#> 2. read Giotto feature information
#> 3. read Giotto spatial information
#> 3.1 read Giotto spatial shape information
#> 3.2 read Giotto spatial centroid information
#> 3.3 read Giotto spatial overlap information
#> 4. read Giotto image information
#> python already initialized in this session
#> active environment : '/usr/bin/python3'
#> python version : 3.12
# single operation
processExpression(g, normParam("library"), name = "library")
#> Setting expression [cell][rna] library
#> An object of class giotto
#> >Active spat_unit: cell
#> >Active feat_type: rna
#> dimensions : 634, 624 (features, cells)
#> [SUBCELLULAR INFO]
#> polygons : cell
#> [AGGREGATE INFO]
#> expression -----------------------
#> [cell][rna] raw normalized scaled library
#> spatial locations ----------------
#> [cell] raw
#> spatial networks -----------------
#> [cell] Delaunay_network spatial_network
#> spatial enrichments --------------
#> [cell][rna] cluster_metagene DWLS
#> dim reduction --------------------
#> [cell][rna] pca custom_pca umap custom_umap tsne
#> nearest neighbor networks --------
#> [cell][rna] sNN.pca custom_NN
#> attached images ------------------
#> images : alignment image
#>
#>
#> Use objHistory() to see steps and params used
# single operation with changed parameter
lib <- normParam("library")
lib$scalefactor = 1000
processExpression(g, lib, name = "library2")
#> Setting expression [cell][rna] library2
#> An object of class giotto
#> >Active spat_unit: cell
#> >Active feat_type: rna
#> dimensions : 634, 624 (features, cells)
#> [SUBCELLULAR INFO]
#> polygons : cell
#> [AGGREGATE INFO]
#> expression -----------------------
#> [cell][rna] raw normalized scaled library2
#> spatial locations ----------------
#> [cell] raw
#> spatial networks -----------------
#> [cell] Delaunay_network spatial_network
#> spatial enrichments --------------
#> [cell][rna] cluster_metagene DWLS
#> dim reduction --------------------
#> [cell][rna] pca custom_pca umap custom_umap tsne
#> nearest neighbor networks --------
#> [cell][rna] sNN.pca custom_NN
#> attached images ------------------
#> images : alignment image
#>
#>
#> Use objHistory() to see steps and params used
# return the exprObj instead
processExpression(g, lib, name = "library2", return_gobject = FALSE)
#> An object of class exprObj : "library2"
#> spat_unit : "cell"
#> feat_type : "rna"
#> provenance: cell
#>
#> contains:
#> 634 x 624 sparse Matrix of class "dgCMatrix"
#>
#> Gna12 2.12766 2.372479 1.37931 1.890359 8.797654 0.7127584 2.747253 4.1459370 6.396588 . .
#> Ccnd2 . 1.186240 1.37931 . . 0.7127584 . 0.8291874 2.132196 . .
#> Btbd17 . 1.186240 1.37931 1.890359 . . 1.831502 . . . .
#>
#> Gna12 8.396306 5.303030 ......
#> Ccnd2 . 2.272727 ......
#> Btbd17 . . ......
#>
#> ........suppressing 611 columns and 628 rows
#>
#> Gm19935 . 1.18624 . . . . . . . . 1.265823 . . ......
#> 9630013A20Rik . . . . . . . . . . 1.265823 . . ......
#> 2900040C04Rik 2.12766 . . . . . . . . 1.703578 . . . ......
#>
#> First four colnames:
#> AAAGGGATGTAGCAAG-1 AAATGGCATGTCTTGT-1
#> AAATGGTCAATGTGCC-1 AAATTAACGGGTAGCT-1
# chained operation (this is the Giotto standard normalization)
processExpression(g,
list(
normParam("library"),
normParam("log"),
scaleParam("zscore", MARGIN = 1),
scaleParam("zscore", MARGIN = 2)
),
name = "scaled2"
)
#> Setting expression [cell][rna] scaled2
#> An object of class giotto
#> >Active spat_unit: cell
#> >Active feat_type: rna
#> dimensions : 634, 624 (features, cells)
#> [SUBCELLULAR INFO]
#> polygons : cell
#> [AGGREGATE INFO]
#> expression -----------------------
#> [cell][rna] raw normalized scaled scaled2
#> spatial locations ----------------
#> [cell] raw
#> spatial networks -----------------
#> [cell] Delaunay_network spatial_network
#> spatial enrichments --------------
#> [cell][rna] cluster_metagene DWLS
#> dim reduction --------------------
#> [cell][rna] pca custom_pca umap custom_umap tsne
#> nearest neighbor networks --------
#> [cell][rna] sNN.pca custom_NN
#> attached images ------------------
#> images : alignment image
#>
#>
#> Use objHistory() to see steps and params used