runs a Principal Component Analysis on a random subset + projection
runPCAprojection(
gobject,
spat_unit = NULL,
feat_type = NULL,
expression_values = c("normalized", "scaled", "custom"),
reduction = c("cells", "feats"),
random_subset = 500,
name = "pca.projection",
feats_to_use = "hvf",
return_gobject = TRUE,
center = TRUE,
scale_unit = TRUE,
ncp = 100,
method = c("irlba"),
method_params = BiocParallel::SerialParam(),
rev = FALSE,
set_seed = TRUE,
seed_number = 1234,
verbose = TRUE,
toplevel = 1L,
...
)
giotto object
spatial unit
feature type
expression values to use
cells or genes
numeric. random subset to perform PCA on
arbitrary name for PCA run
subset of features to use for PCA
boolean: return giotto object (default = TRUE)
center data first (default = TRUE)
scale features before PCA (default = TRUE)
number of principal components to calculate
which implementation to use
BiocParallelParam object
do a reverse PCA
use of seed
seed number to use
verbosity of the function
relative stackframe where call was made
additional parameters for PCA (see details)
giotto object with updated PCA dimension recuction
See runPCA
and
PCA
for more information about other parameters.
This PCA implementation is similar to runPCA
, except that it
performs PCA on a subset of the cells or features, and predict on the others.
This can significantly increase speed without sacrificing accuracy too much.
feats_to_use = NULL: will use all features from the selected matrix
feats_to_use = <hvg name>: can be used to select a column name of
highly variable features, created by (see calculateHVF
)
feats_to_use = c('geneA', 'geneB', ...): will use all manually provided features
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.10
#> checking default envname 'giotto_env'
#> a system default python environment was found
#> Using python path:
#> "/usr/bin/python3"
runPCAprojection(g)
#> "hvf" column was found in the feats metadata information and will be
#> used to select highly variable features
#> Warning: ncp >= minimum dimension of x, will be set to minimum
#> dimension of x - 1
#> pca random subset: start
#> Warning: You're computing too large a percentage of total singular values, use a standard svd instead.
#> Warning: did not converge--results might be invalid!; try increasing work or maxit
#> pca random subset: done
#> pca prediction: start
#> pca prediction: done
#> Setting dimension reduction [cell][rna] pca.projection
#> 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
#> 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 pca.projection 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