> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cosmosid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

# What is PLS-DA?

Partial least squares discriminant analysis (PLS-DA) is a supervised multivariate method that finds the combination of features that best distinguishes predefined groups of samples. It adapts partial least squares (PLS) regression to classification. The group of each sample, for example a control diet or a high fibre diet, is coded as a number. PLS-DA then builds new axes, called components, as weighted combinations of all features, chosen so that the sample scores on each component vary as closely as possible with the group labels.

The result is a plot of the samples on the first components, together with a measure of how much each feature contributes to the separation. In metabolomics, PLS-DA is widely used to summarise hundreds of metabolites in a two dimensional plot and to rank the metabolites that differ most between conditions.

> [!NOTE]
>
> PLS-DA is supported is currently supported for [Metabolomics data](metabo).

## Why is it useful?

Omics profiles measure the abundance of many **features** in each sample at once. For example, a metagenomic profile reports hundreds of taxa or genes, and an untargeted metabolomics run measures hundreds to thousands of mass spectrometry signals produced by the metabolites in the sample.

A common goal of omics studies is to find the features that differ between conditions of interest, or that are associated with them. In metabolomics, testing each feature on its own, known as univariate analysis, shows which metabolites change between groups. This approach can miss a difference made of many small, coordinated changes, which is common because metabolites of the same pathway tend to rise and fall together. **Multivariate** methods consider all features at once and can detect these patterns.

Use PLS-DA to answer questions like these.

* **Compare groups.** Do samples from different conditions, such as two diets, differ in their overall metabolite profile?
* **Find the features behind a difference.** Which metabolites contribute most to the separation between groups, and in which group are they higher?
* **Detect coordinated changes.** Do several metabolites shift together, such as the short chain fatty acids produced by fibre fermentation, even when each one changes only a little?
* **Predict group membership.** How reliably does the metabolite profile of a sample tell which group it belongs to?

## How to read a PLS-DA plot

Partial least squares discriminant analysis (PLS-DA) is a supervised multivariate method. It condenses hundreds of microbial features into a few new axes, called components, and chooses them so that your sample groups separate as clearly as possible.

Microbiome datasets usually have many more features than samples, and many features are correlated because taxa, and functions, tend to occur together. Classical linear discriminant analysis (LDA) cannot be computed in this situation. PLS-DA handles it by building each component as a weighted combination of all features.

The weights, called **loadings**, show which features drive each component. The **variable importance in projection (VIP)** score summarises the contribution of a feature over all components, and features with a VIP above 1 are commonly treated as influential. Together they point to the combination of taxa or functions that best distinguishes your groups.

> [!NOTE]
>
> **A PLS-DA plot is an ordination plot, like a PCA plot.** Both project the samples onto a few components, each a weighted combination of the features. They differ in how the components are chosen.
>
> | | PCA | PLS-DA |
> | :- | :- | :- |
> | Type of method | Unsupervised | Supervised |
> | Uses the group labels | No | Yes |
> | Components chosen to | Capture the most variation in the data | Best separate the groups |
> | Group separation in the plot | Reflects a pattern that exists without the labels | Expected by design, so it needs [validation](#check-that-the-separation-is-real) |
>
> To explore your samples without group labels, use the [PCA Explorer](https://docs.cosmosid.com/DAP_docs/pca-explorer.md).

## Check that the separation is real

PLS-DA searches for the components that separate your groups, and when there are many features and few samples it always finds some. The more features a dataset has, the more combinations of them exist, and the higher the chance that one combination separates the groups through random noise alone. Even random data with arbitrary group labels can give a clean separation in the score plot, as [Westerhuis and colleagues showed for metabolomics data](https://doi.org/10.1007/s11306-007-0099-6). This is called **overfitting**, where the model describes noise in the samples it was built on. A separation in the score plot alone is therefore not evidence of a real difference between groups.

Group A
Group B
24 samples

New random data

Number of random features

Random data with 24 samples and two groups assigned at random. With more features, PLS-DA separates the groups more clearly, but its cross validated error stays close to the 50% chance level.

Two checks tell a real difference from an artefact of the method.

* **Cross validation** builds the model on part of the samples, tests it on the samples left out, and repeats this until every sample has been tested once. A model that predicts the left out samples well describes a real difference.
* A **permutation test** shuffles the group labels many times and refits the model each time. A real difference gives better performance than most of the models built on shuffled labels.

> [!WARNING]
>
> Report the validation results together with the score plot, and confirm the features with the highest VIP scores with a univariate test before you interpret them as markers of a group.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.