
Orthogonal Partial Least Squares Discriminant Analysis (OPLS-DA)
gly_oplsda.Rd
Perform orthogonal partial least squares discriminant analysis on the expression data.
The function uses ropls::opls()
to perform OPLS-DA and returns tidy results.
Usage
gly_oplsda(
exp,
group_col = "group",
pred_i = 1,
ortho_i = NA,
scale = TRUE,
add_info = TRUE,
...
)
gly_oplsda_(expr_mat, groups, pred_i = 1, ortho_i = NA, scale = TRUE, ...)
Arguments
- exp
A
glyexp::experiment()
object containing expression matrix and sample information.- group_col
A character string specifying the column name in sample information that contains group labels. Default is "group".
- pred_i
An integer indicating the number of predictive components to include. Default is 1.
- ortho_i
An integer indicating the number of orthogonal components to include. Default is NA (automatic).
- scale
A logical indicating whether to scale the data. Default is TRUE.
- add_info
A logical value. If TRUE (default), sample and variable information from the experiment will be added to the result tibbles. If FALSE, only the OPLS-DA results are returned. Only applicable to
gly_oplsda()
.- ...
Additional arguments passed to
ropls::opls()
.- expr_mat
A numeric matrix with variables as rows and samples as columns.
- groups
A factor or character vector specifying group membership for each sample. Must have exactly 2 levels. Character vectors will be automatically converted to factors.
Value
A list containing:
tidy_result
: A list of tibbles with OPLS-DA results:samples
: OPLS-DA scores for each sample containing the following columns:sample
: Sample namegroup
: Group assignmentp1
,p2
, etc.: Predictive component scoreso1
,o2
, etc.: Orthogonal component scores
variables
: OPLS-DA loadings for each variable containing the following columns:variable
: Variable namep1
,p2
, etc.: Predictive component loadingso1
,o2
, etc.: Orthogonal component loadingspcorr1
,pcorr2
, etc.: Correlation between each variable and the corresponding predictive component
variance
: OPLS-DA explained variance containing the following columns:component
: Component name (p1, o1, etc.)prop_var_explained
: Proportion of variance explained by each componentcumulative_prop_var
: Cumulative proportion of variance explained
vip
: Variable Importance in Projection scores containing the following columns:variable
: Variable namevip
: VIP score
perm_test
: Permutation test results containing the following columns:model
: Model type ("Original" for the original model, "Permutation" for permuted models)perm_id
: Permutation ID (0 for original model, 1+ for permutations)Additional columns from the permutation test matrix (e.g., R2X, R2Y, Q2, etc.)
raw_result
: The raw ropls opls object fromropls::opls()
Details
gly_oplsda()
is the top-level API that works with glyexp::experiment()
objects and supports
the add_info
parameter for joining experiment metadata.
gly_oplsda_()
is the underlying API that works with matrices and factor vectors directly,
providing more flexibility for users who don't use the glyexp package.
Required packages
This function requires the following packages to be installed:
ropls
for OPLS-DA analysis