Performs response prediction on new data using a PLS model previously
fitted with RunPLS(..., save.model = TRUE). Mirrors the
core behaviour of predict.mvr() from the pls package.
PredictPLS(object, newdata, ...)
# S3 method for class 'DimReduc'
PredictPLS(object, newdata, ncomp = NULL, ...)
# S3 method for class 'Seurat'
PredictPLS(
object,
newdata,
reduction = "pls",
ncomp = NULL,
assay = NULL,
layer = "data",
...
)A DimReduc object or Seurat object containing
a PLS model fitted with save.model = TRUE.
New observations: a cells x features numeric matrix (for the DimReduc method) or a Seurat object (for the Seurat method).
Additional arguments (currently unused).
Integer vector of component counts to predict with. Each value produces a separate set of predictions using the cumulative coefficients for that many components. Default: maximum available.
(Seurat method only) Name of the PLS reduction slot.
Default "pls".
(Seurat method only) Assay to use from newdata.
Default: DefaultAssay(newdata).
(Seurat method only) Layer to use from the assay. Default
"data".
A matrix (n x q) if a single ncomp value, or a 3D array
(n x q x length(ncomp)) if multiple values are given.
When called on a Seurat object, PredictPLS automatically scales the
new data using per-gene mean and standard deviation stored from the training
data layer (saved by RunPLS(..., save.model = TRUE)). This
ensures that new observations are projected into the same coordinate system
used to fit the PLS model. If the model was saved without scaling parameters
(e.g., from an older version), a warning is emitted and prediction proceeds
without scaling.
if (FALSE) { # \dontrun{
# Fit PLS model with save.model = TRUE
obj <- RunPLS(obj, Y = "response", save.model = TRUE)
# Predict on new Seurat object
predictions <- PredictPLS(obj, newdata = new_obj)
} # }