
Pipeline step: PCA
step_pca_sc.RdWraps calculate_pca_sc() as an ScStep.
Usage
step_pca_sc(
no_pcs = 30L,
pca_params = params_sc_pca(),
sparse_svd = NULL,
hvg = NULL,
seed = 42L,
residuals = FALSE,
.verbose = TRUE
)Arguments
- no_pcs
Integer. Number of PCs to calculate.
- pca_params
Named list. Controls the parameters to be used for the PCA calculation which is single cell-specific, see
params_sc_pca()- sparse_svd
Optional boolean. Solve on the sparse data with implicit centring and scaling instead of materialising the dense scaled matrix.
NULLpicks the sparse path, which is faster and lighter on memory for every solver, or the dense one forresiduals = TRUE.FALSEuses the dense path, but only below 500,000 cells. Not used forMetaCells.- hvg
Optional integer. If you want to provide your own HVG genes. Otherwise, the function will default to what is found in
get_hvg(). Please provide 1-indexed genes here! If you provide these, the internal HVG will be overwritten.- seed
Integer. Controls reproducibility. Only relevant for
svd_solver = "randomised"and the Lanczos start vector.- residuals
Boolean. Run the PCA on the Pearson residuals of a model fitted with
fit_residuals_sc()instead of the stored normalised layer. Needsparams_sc_pca(normalise_variance = FALSE, clr = FALSE), since the residuals already carry the signal as variance, and does not supportsparse_svd: a residual column is dense even where the counts are not. On this dense path the defaultsvd_solver = "auto"pays for a full gene x gene cross-product and is slower thansvd_solver = "randomised", so pick the latter inparams_sc_pca()when speed matters. Not supported forMetaCells.- .verbose
Boolean or integer. Controls verbosity and returns run times.
FALSE-> quiet,TRUEor1L-> normal verbosity,2L-> detailed verbosity.
Examples
# PCA restricted to whatever the HVG step selected
step_hvg_sc(hvg_no = 30L) %>>% step_pca_sc(no_pcs = 10L)
#> <ScPipeline> 2 steps
#> 1. hvg hvg_no = 30L, hvg_params = <list>, streaming = NULL, .verbose = TRUE
#> 2. pca no_pcs = 10L, pca_params = <list>, sparse_svd = NULL, hvg = NULL, seed = 42L, residuals = FALSE, .verbose = TRUE