Performs a sparse Partial Least Squares Discriminant Analysis (sPLS-DA) on a DEprot object. Differently from a PCA, which looks for the directions carrying the most variance whatever their origin, sPLS-DA looks for the directions that separate a set of classes given by the user, and selects at the same time the small group of proteins responsible for that separation.
perform.sPLSDA(
DEprot.object,
group.column,
which.data = "imputed",
sample.subset = NULL,
ncomp = 3,
keepX = NULL,
test.keepX = NULL,
scale.data = TRUE,
reference.group = NULL,
validate = TRUE,
validation = "Mfold",
folds = 5,
nrepeat = 10,
dist = "max.dist",
n.cores = 1,
seed = 1234
)An object of class DEprot or DEprot.analyses.
String indicating the column of the metadata table holding the classes to discriminate (e.g., "condition"). No default.
String indicating which type of counts should be used. One among: 'raw', 'normalized', 'norm', 'randomized', 'random', 'imputed', 'imp'. Default: "imputed".
String vector indicating the column names (samples) to keep in the counts table (the 'column.id' in the metadata table). Default: NULL (no subsetting).
Integer number indicating the number of components to compute. Values lower than 3 are raised to 3, since the third component is what tells whether the separation seen on the first two is the whole story. Default: 3.
Number of proteins to retain on each component. A single value is recycled over all the components, a vector must have one value per component. When NULL (default) the value is tuned by cross-validation over test.keepX.
Numeric vector of the values of keepX tested during the tuning. Used only when keepX = NULL. Default: NULL (c(5, 10, 15, 20, 30, 50, 100), capped to the number of proteins available).
Logical value indicating whether each protein should be scaled to unit variance. Default: TRUE.
String indicating the class placed on the positive side of every component. Default: NULL (the first level of group.column).
Logical value indicating whether the performance of the model should be estimated by cross-validation. This is a second resampling run, roughly as expensive as the tuning, so it can be skipped while exploring. Default: TRUE.
String indicating the cross-validation scheme. One among: 'Mfold', 'loo'. Default: "Mfold".
Number of folds of the cross-validation. Automatically capped to the size of the smallest class. Default: 5.
Number of times the cross-validation is repeated. Ignored for leave-one-out. Default: 10.
String indicating the prediction distance used during the tuning. One among: 'max.dist', 'centroids.dist', 'mahalanobis.dist'. All three are reported by the validation. Default: "max.dist".
Number of cores used for the tuning and the validation. Default: 1.
Numeric value used to seed the resampling, so that the tuning and the error rates are reproducible. Default: 1234.
A DEprot.sPLSDA object.
Both the tuning of keepX and the estimation of the performances happen inside this function: neither of them changes as long as the model does not change, so keeping them apart would only mean carrying around three objects that must be kept in sync by hand.
Alongside the sparse model, a plain (non-sparse) PLS-DA is fitted on the same data and the same number of components. It costs nothing, since no resampling is involved, and it gives a complete loading vector over every protein of the matrix. That vector is what get.sPLSDA.ranking returns for a GSEA: the sparse loadings are zero for all the proteins that were not selected, which leaves a ranking made mostly of ties and an enrichment score that depends on the order in which those ties happen to be sorted.
The orientation of the components returned by mixOmics is arbitrary. Here the sign of each component is fixed so that reference.group always sits on the positive side, which also means that a protein with a positive loading is a protein higher in that group. The mixOmics object stored in the splsda slot keeps its original orientation, so that anything computed on it directly stays consistent with the mixOmics documentation.
# Model with a fixed number of proteins per component (no tuning)
splsda <- perform.sPLSDA(DEprot.object = DEprot::test.toolbox$dpo.imp,
group.column = "condition",
keepX = c(10, 10, 5),
validate = FALSE)
#> Warning: The number of 'folds' (5) is larger than the smallest class (4 samples): 'folds' has been set to 4.
# \donttest{
# Tuned model, cross-validated (both steps resample the samples)
splsda.tuned <- perform.sPLSDA(DEprot.object = DEprot::test.toolbox$dpo.imp,
group.column = "condition",
test.keepX = c(5, 10, 20),
folds = 3,
nrepeat = 1)
#> Tuning 'keepX' by cross-validation over 3 values...
#> Note that the number of components cannot be reliably tuned with nrepeat < 3 or validaion = 'loo'.
#> Estimating the classification performances by cross-validation...
#> Warning: Values in '$choice.ncomp' will reflect component count with the minimum error rate rather than the best based on a one-way t.test
# }