Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/satijalab/seurat-wrappers/llms.txt

Use this file to discover all available pages before exploring further.

RunOptimizeALS() wraps the LIGER optimizeALS algorithm to perform integrative non-negative matrix factorization (iNMF) on a merged Seurat object. Each dataset’s cells share a common factor matrix W while having dataset-specific matrices H and V.

Syntax

RunOptimizeALS(
  object,
  k,
  assay = NULL,
  split.by = "orig.ident",
  lambda = 5,
  thresh = 1e-6,
  max.iters = 30,
  reduction.name = "iNMF_raw",
  reduction.key = "riNMF_",
  nrep = 1,
  H.init = NULL,
  W.init = NULL,
  V.init = NULL,
  rand.seed = 1,
  print.obj = FALSE,
  ...
)

Parameters

object
Seurat
required
A merged Seurat object containing cells from multiple datasets.
k
integer
required
Number of factors (latent dimensions) to compute.
assay
character
default:"NULL"
Assay to use. Defaults to the active default assay.
split.by
character
default:"orig.ident"
Metadata column used to split cells into per-dataset subsets.
lambda
numeric
default:"5"
Regularization parameter. Larger values increase dataset-specific penalty.
thresh
numeric
default:"1e-6"
Convergence threshold for the ALS objective.
max.iters
integer
default:"30"
Maximum number of ALS iterations.
reduction.name
character
default:"iNMF_raw"
Name for the resulting DimReduc object.
reduction.key
character
default:"riNMF_"
Prefix for the iNMF embedding column names.
nrep
integer
default:"1"
Number of restarts. The best factorization is kept.
H.init
matrix
default:"NULL"
Initial value for the H (cell factor) matrices.
W.init
matrix
default:"NULL"
Initial value for the W (shared gene factor) matrix.
V.init
matrix
default:"NULL"
Initial value for the V (dataset-specific gene factor) matrices.
rand.seed
integer
default:"1"
Random seed for reproducibility.
print.obj
logical
default:"FALSE"
Print the objective value at each iteration.

Returns

A Seurat object with:
  • A DimReduc under reduction.name containing iNMF cell embeddings and feature loadings
  • Per-dataset feature loading matrices stored in the Tool slot (accessible via Tool(object))

Examples

library(SeuratWrappers)
install.packages("rliger")

# Preprocess: normalize and scale (without centering)
object <- NormalizeData(object)
object <- FindVariableFeatures(object)
object <- ScaleData(object, split.by = "orig.ident", do.center = FALSE)

# Run iNMF factorization
object <- RunOptimizeALS(object, k = 20, split.by = "orig.ident")

# Quantile normalize
object <- RunQuantileNorm(object, split.by = "orig.ident")

# Cluster and visualize
object <- FindNeighbors(object, reduction = "iNMF", dims = 1:ncol(Embeddings(object, "iNMF")))
object <- FindClusters(object)
object <- RunUMAP(object, reduction = "iNMF", dims = 1:ncol(Embeddings(object, "iNMF")))

See Also

Build docs developers (and LLMs) love