Skip to main content
RunGLMPCA() runs GLM-PCA on the raw count data in a Seurat object, avoiding the statistical artifacts introduced by normalizing sparse count matrices before PCA.

Syntax

RunGLMPCA(
  object,
  L = 5,
  assay = NULL,
  features = NULL,
  reduction.name = "glmpca",
  reduction.key = "GLMPC_",
  verbose = TRUE,
  ...
)

Parameters

object
Seurat
required
A Seurat object. Must have counts in the counts slot.
L
integer
default:"5"
Number of dimensions (latent factors) to return.
assay
character
default:"NULL"
Assay to use. Defaults to the active default assay.
features
character vector
default:"NULL"
Features to use for GLM-PCA. Defaults to variable features set on the object.
reduction.name
character
default:"glmpca"
Name for the resulting DimReduc object.
reduction.key
character
default:"GLMPC_"
Prefix for the column names of the GLM-PCA embedding.
verbose
logical
default:"TRUE"
Print progress messages.
...
any
Additional parameters passed to glmpca::glmpca().

Returns

A Seurat object with a new DimReduc object stored under reduction.name containing:
  • Cell embeddings (factors)
  • Feature loadings
  • Standard deviations (L2 norms of factors)
The raw glmpca result metadata (excluding factors/loadings) is stored in the DimReduc misc slot.

Examples

library(SeuratWrappers)
install.packages("glmpca")  # or: remotes::install_github("willtownes/glmpca")

# Find variable features first
object <- FindVariableFeatures(object, nfeatures = 2000)

# Run GLM-PCA with 10 dimensions
object <- RunGLMPCA(object, L = 10)

# Use for clustering
object <- FindNeighbors(object, reduction = "glmpca", dims = 1:10)
object <- FindClusters(object)

# Visualize
object <- RunUMAP(object, reduction = "glmpca", dims = 1:10)
DimPlot(object)
Do not call NormalizeData() or use normalized data before RunGLMPCA(). The function reads from the counts slot and performs its own statistical normalization internally.

See Also