Performs Partial Least Squares regression analysis on single-cell data. This function provides methods for plsr, spls, and cppls from the pls and spls packages.

RunPLS(object, ...)

# Default S3 method
RunPLS(
  object,
  assay = NULL,
  ncomp = 20,
  Y = NULL,
  Y.add = NULL,
  pls.function = c("plsr", "spls", "cppls"),
  verbose = TRUE,
  ndims.print = 1:5,
  nfeatures.print = 30,
  reduction.name = "pls",
  reduction.key = "PLS_",
  seed.use = 42,
  eta = 0.5,
  save.model = FALSE,
  ...
)

# S3 method for class 'IterableMatrix'
RunPLS(
  object,
  assay = NULL,
  ncomp = 20,
  Y = NULL,
  Y.add = NULL,
  pls.function = c("plsr", "spls", "cppls"),
  verbose = TRUE,
  ndims.print = 1:5,
  nfeatures.print = 30,
  reduction.name = "pls",
  reduction.key = "PLS_",
  seed.use = 42,
  eta = 0.5,
  save.model = FALSE,
  threads = 1L,
  ...
)

# S3 method for class 'Assay'
RunPLS(
  object,
  assay = NULL,
  features = NULL,
  ncomp = 20,
  Y = NULL,
  Y.add = NULL,
  pls.function = c("plsr", "spls", "cppls"),
  verbose = TRUE,
  ndims.print = 1:5,
  nfeatures.print = 30,
  reduction.name = "pls",
  reduction.key = "PLS_",
  seed.use = 42,
  eta = 0.5,
  save.model = FALSE,
  threads = 1L,
  ...
)

# S3 method for class 'StdAssay'
RunPLS(
  object,
  assay = NULL,
  features = NULL,
  layer = "scale.data",
  ncomp = 20,
  Y = NULL,
  Y.add = NULL,
  pls.function = c("plsr", "spls", "cppls"),
  verbose = TRUE,
  ndims.print = 1:5,
  nfeatures.print = 30,
  reduction.name = "pls",
  reduction.key = "PLS_",
  seed.use = 42,
  eta = 0.5,
  save.model = FALSE,
  threads = 1L,
  ...
)

# S3 method for class 'Seurat'
RunPLS(
  object,
  assay = NULL,
  features = NULL,
  ncomp = 20,
  Y = NULL,
  Y.add = NULL,
  pls.function = c("plsr", "spls", "cppls"),
  verbose = TRUE,
  ndims.print = 1:5,
  nfeatures.print = 30,
  reduction.name = "pls",
  reduction.key = "PLS_",
  seed.use = 42,
  eta = 0.5,
  save.model = FALSE,
  threads = 1L,
  ...
)

Arguments

object

An object to run PLS on

...

Additional arguments to be passed to the PLS function

assay

Name of Assay PLS is being run on

ncomp

Number of components to compute

Y

The response variable(s) for PLS regression. Accepted formats:

  • A character vector of column names in the Seurat object metadata (Seurat method only).

  • A data.frame, which is converted via model.matrix(~. + 0, data = Y).

  • A numeric matrix (used as-is).

  • A numeric vector (promoted to a single-column matrix).

The number of rows must match the number of cells/samples.

Y.add

Additional response variable(s) containing relevant information about the observations. Only used for cppls. Accepts the same formats as Y.

pls.function

PLS function from pls package to run (options: plsr, spls, cppls)

verbose

Print progress messages, diagnostics (e.g. R2), and the top genes associated with high/low loadings for the components

ndims.print

components to print genes for

nfeatures.print

Number of genes to print for each component

reduction.name

the name of the DimReduc object

reduction.key

dimensional reduction key, specifies the string before the number for the dimension names.

seed.use

Set a random seed. Setting NULL will not set a seed.

eta

Thresholding parameter that controls the sparsity of the spls method (larger –> sparser). eta should be between 0 and 1.

save.model

Logical; if TRUE, save model components (coefficients, Xmeans, Ymeans, feature.mean, feature.sd) into the misc slot for later prediction. The per-gene feature.mean and feature.sd are computed from the training data layer so that PredictPLS can scale new data into the same coordinate system. Default FALSE.

threads

Integer; number of threads for BPCells parallel computation (IterableMatrix path only). 1 (default) = single-threaded; 0 = auto-detect via parallel::detectCores(logical = FALSE); values \(\ge 2\) use that many threads. Ignored for in-memory data.

features

Features to compute PLS on

layer

The layer in assay to use when running PLS analysis.

Value

Returns a DimReduc object with PLS results

Examples

if (FALSE) { # \dontrun{
# Run PLS on a Seurat object using metadata column names
seurat_obj <- RunPLS(seurat_obj, Y = "condition", ncomp = 10)

# Run PLS with a pre-built numeric design matrix
design_mat <- model.matrix(~ age + sex, data = seurat_obj[[]])
seurat_obj <- RunPLS(seurat_obj, Y = design_mat, ncomp = 10)
} # }