Run partial singular value decomposition using RSpectra::svds

RunSVD(object, ...)

# Default S3 method
RunSVD(
  object,
  assay = NULL,
  n = 50,
  scale.embeddings = !pca,
  pca = FALSE,
  reduction.key = ifelse(pca, "PCA_", "LSI_"),
  scale.max = NULL,
  verbose = TRUE,
  tol = 1e-05,
  ...
)

# S3 method for class 'Assay'
RunSVD(
  object,
  assay = NULL,
  features = NULL,
  pca = FALSE,
  n = 50,
  reduction.key = ifelse(pca, "PCA_", "LSI_"),
  scale.max = NULL,
  verbose = TRUE,
  ...
)

# S3 method for class 'StdAssay'
RunSVD(
  object,
  assay = NULL,
  features = NULL,
  pca = FALSE,
  n = 50,
  reduction.key = ifelse(pca, "PCA_", "LSI_"),
  scale.max = NULL,
  verbose = TRUE,
  ...
)

# S3 method for class 'Seurat'
RunSVD(
  object,
  assay = NULL,
  features = NULL,
  layer = "data",
  n = 50,
  pca = FALSE,
  reduction.key = ifelse(pca, "PCA_", "LSI_"),
  reduction.name = ifelse(pca, "pca", "lsi"),
  scale.max = NULL,
  verbose = TRUE,
  ...
)

Arguments

object

A Seurat object

...

Arguments passed to other methods

assay

Which assay to use. If NULL, use the default assay

n

Number of singular values to compute

scale.embeddings

Scale cell embeddings within each component to mean 0 and SD 1 (default TRUE).

pca

Run PCA. Setting this option to TRUE will perform implicit scaling and centering of the input matrix to enable memory-efficient computation of the principal components.

reduction.key

Key for dimension reduction object

scale.max

Clipping value for cell embeddings. Default (NULL) is no clipping.

verbose

Print messages

tol

Tolerance (tol) parameter for RSpectra::svds(). Larger values speed up convergence due to greater amount of allowed error.

features

Which features to use. If NULL, use variable features

layer

Name of layer to use.

reduction.name

Name for stored dimension reduction object.

Value

Returns a SeuratObject::Seurat() object

Examples

x <- matrix(data = rnorm(100), ncol = 10)
RunSVD(x)
#> Running SVD
#> Scaling cell embeddings
#> Warning: No assay specified, setting assay as RNA by default.
#> Warning: Requested number is larger than the number of available items (10). Setting to 10.
#> LSI_ 1 
#> Positive:  5, 10, 4, 3, 7 
#> Negative:  6, 2, 8, 9, 1 
#> Warning: Requested number is larger than the number of available items (10). Setting to 10.
#> LSI_ 2 
#> Positive:  9, 3, 6, 4, 1 
#> Negative:  2, 10, 8, 7, 5 
#> Warning: Requested number is larger than the number of available items (10). Setting to 10.
#> LSI_ 3 
#> Positive:  6, 5, 4, 10, 7 
#> Negative:  9, 2, 1, 3, 8 
#> Warning: Requested number is larger than the number of available items (10). Setting to 10.
#> LSI_ 4 
#> Positive:  5, 8, 7, 2, 9 
#> Negative:  4, 10, 6, 1, 3 
#> Warning: Requested number is larger than the number of available items (10). Setting to 10.
#> LSI_ 5 
#> Positive:  9, 5, 6, 3, 10 
#> Negative:  7, 4, 1, 8, 2 
if (FALSE) { # \dontrun{
RunSVD(atac_small[['peaks']])
} # }
if (FALSE) { # \dontrun{
RunSVD(atac_small[['peaks']])
} # }
RunSVD(atac_small, features = rownames(atac_small))
#> Running SVD
#> Scaling cell embeddings
#> An object of class Seurat 
#> 1323 features across 100 samples within 3 assays 
#> Active assay: peaks (323 features, 323 variable features)
#>  2 layers present: counts, data
#>  2 other assays present: bins, RNA
#>  2 dimensional reductions calculated: lsi, umap