Skip to contents

A simple wrapper for fitting a PLS-DA model using mixOmics package. The object can then be passed to many of the mixOmics functions for prediction, performance evaluation etc.

  • mixomics_plsda A simple PLS-DA model with set number of components and all features

  • mixomics_plsda_optimize Test different numbers of components, choose the one with minimal balanced error rate

  • mixomics_splsda_optimize Test different numbers of components and features, choose the one with minimal balanced error rate

Usage

mixomics_plsda(
  object,
  y,
  ncomp,
  plot_scores = TRUE,
  all_features = FALSE,
  covariates = NULL,
  assay.type = NULL,
  ...
)

mixomics_plsda_optimize(
  object,
  y,
  ncomp,
  folds = 5,
  nrepeat = 50,
  plot_scores = TRUE,
  all_features = FALSE,
  covariates = NULL,
  assay.type = NULL,
  ...
)

mixomics_splsda_optimize(
  object,
  y,
  ncomp,
  dist,
  n_features = c(seq_len(10), seq(20, 300, 10)),
  folds = 5,
  nrepeat = 50,
  plot_scores = TRUE,
  all_features = FALSE,
  covariates = NULL,
  assay.type = NULL,
  ...
)

Arguments

object

a SummarizedExperiment or MetaboSet object

y

character, column name of the grouping variable to predict

ncomp

the number of X components

plot_scores

logical, if TRUE, a scatter plot with the first two PLS- components as x and y-axis will be drawn, with both prediction surface and ellipses

all_features

logical, should all features be included in the model? if FALSE, flagged features are left out

covariates

character, column names of pheno data to use as covariates in the model, in addition to molecular features

assay.type

character, assay to be used in case of multiple assays

...

any parameters passed to plsda

folds

the number of folds to use in k-fold cross validation

nrepeat

the number of times to repeat the cross validation. Lower this for faster testing.

dist

the distance metric to use, one of "max.dist", "mahalanobis.dist", "centroids.dist". use mixomics_plsda_optimize to find the best distance metric

n_features

the number of features to try for each component

Value

An object of class "mixo_plsda".

Examples

data(example_set)
noqc <- drop_qcs(example_set)
plsda_res <- mixomics_plsda(noqc, y = "Group", ncomp = 2)
#> INFO [2025-06-23 22:38:00] Fitting PLS-DA
# Cross-validation repeated only 5 times for quick run time 
set.seed(38)
plsda_opt <- mixomics_plsda_optimize(noqc, 
  y = "Group", ncomp = 3, nrepeat = 5
)
#> INFO [2025-06-23 22:38:06] Fitting PLS-DA
#> INFO [2025-06-23 22:38:06] Evaluating PLS-DA performance
#> INFO [2025-06-23 22:38:08] Choosing a PLS-DA model with 1 components using centroids.dist
#> INFO [2025-06-23 22:38:08] Fitting PLS-DA
set.seed(38)
splsda_opt <- mixomics_splsda_optimize(noqc,
  y = "Group", dist = "max.dist", ncomp = 2,
  n_features <- c(1:10, 12, 15, 20), nrepeat = 5
)
#> INFO [2025-06-23 22:38:08] Tuning sPLS-DA
#> INFO [2025-06-23 22:38:11] Final model has 1 components with the numbers of features: 1