> ## 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 univariate comparison?

The Univariate Comparison module identifies which microbial features (such as species, genes, or pathways) are associated with a categorical variable of interest (such as study condition, disease, ethnicity, or treatment). It compares the groups defined by that variable and tests each feature to find which ones are differentially **abundant** (present at different amounts) or differentially **prevalent** (detected in different proportions of samples).

Alpha diversity, beta diversity, stacked bar charts, and heatmaps reveal the global patterns that distinguish groups. Univariate comparison zooms in to pinpoint which features drive those differences. For example, it can tell you whether *E. coli* differs in abundance or prevalence across your groups, and exactly which groups it separates. It is called *univariate* because each comparison is driven by a single grouping variable.

## How does it work?

The feature table describes which microbial taxa (or other features) appear across the sample profiles in a cohort, and in a typical study it can hold thousands of features. Only a fraction of them drive the differences between groups, and univariate comparison exists to find that fraction. The module works through the table one feature at a time, testing whether each feature differs between the groups defined by the grouping variable.

A feature can differ in two biologically distinct ways, so each is tested separately: **abundance** (how much of the feature is present) and **prevalence** (how often it is detected).

<Steps>
  <Step title="1. Test each feature, for each pair of groups">
    For every feature (for example, each microbial species detected in the cohort), a statistical test compares each possible pair of groups. With four groups (A, B, C, D), that means six unique pairwise comparisons. Each test determines whether the feature differs significantly between the two groups being compared.
  </Step>

  <Step title="2. Assess abundance and prevalence separately">
    Each feature can differ between groups in two distinct ways, so each is tested separately:

    * **Differential abundance** captures whether the *amount* of the feature differs between groups. For example, *E. coli* reaches a higher relative abundance in group A than in group B.
    * **Differential prevalence** captures whether the feature is *detected* in a different proportion of samples per group. For example, *A. baumannii* is present in 30% of group A samples but 70% of group B samples.
  </Step>

  <Step title="3. Correct for multiple testing">
    Testing thousands of features across every pair of groups means testing a very large number of hypotheses at once, and some comparisons would reach significance by chance alone. A **false discovery rate (FDR)** correction is applied to guard against this, bounding the expected proportion of false positives among the comparisons declared significant.
  </Step>

  <Step title="4. Return features associated with your variable of interest">
    The output is a focused list of features whose abundance or prevalence is significantly associated with the variable of interest, along with the specific groups each feature separates.
  </Step>
</Steps>

## Why is it useful?

* **Which features drive the difference between my groups?** Diversity and ordination show *that* groups differ, but not why. Univariate comparison attributes the difference to specific taxa or pathways and, through pairwise testing, tells you between which groups each difference occurs. This reduces a large feature table to a focused set of results.
* **Is a feature different because it is detected more often, or because there is more of it?** The module separates these two signals: a change in how *often* a feature is detected (**prevalence**) versus a change in *how much* of it is present where it occurs (**abundance**). They have different biological meanings, and the module tests them distinctly.
* **With thousands of features tested, how do I know the results are not chance?** Testing a whole table means thousands of simultaneous hypotheses. An **FDR correction** limits the expected fraction of false positives among the features called significant, so the result set comes with a known level of confidence.
