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,
...
)An object to run PLS on
Additional arguments to be passed to the PLS function
Name of Assay PLS is being run on
Number of components to compute
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.
Additional response variable(s) containing relevant
information about the observations. Only used for cppls. Accepts the same
formats as Y.
PLS function from pls package to run (options: plsr, spls, cppls)
Print progress messages, diagnostics (e.g. R2), and the top genes associated with high/low loadings for the components
components to print genes for
Number of genes to print for each component
the name of the DimReduc object
dimensional reduction key, specifies the string before the number for the dimension names.
Set a random seed. Setting NULL will not set a seed.
Thresholding parameter that controls the sparsity of the spls method (larger –> sparser). eta should be between 0 and 1.
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.
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 to compute PLS on
The layer in assay to use when running PLS analysis.
Returns a DimReduc object with PLS results
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)
} # }