Skip to main content
This page covers how the PCA Explorer works in Cosmos-Hub 2.0: the plot it produces, how to read it, the files you can export and the parameters you can tune. For the theory behind PCA, see the PCA explorer overview.

Module output and customisation

  • PCA biplot: a biplot showing how samples relate to each other, with options for how groups and features are displayed.
  • Exported files: the plot, the data tables before and after pre-processing, and the numbers behind the plot.

PCA biplot

Pca Biplot Example

PCA biplot. Each point is one sample along PC1 and PC2, with the variance explained shown on each axis. Colour is the Grouping Variable, shape is a second metadata variable, and red vectors are the selected feature loadings.

Each point is one sample, positioned along the first two principal components (PC1 and PC2). The percentage on each axis is how much of the total variation that component explains. A higher percentage means the axis captures a larger share of the differences between samples.

Sample points and grouping

Each point of the plot represents a single sample of the cohort. By assigning categorical variables of interest (for example sample source, health status or treatment group) to colours and shapes, you can see whether samples from different groups differ in their overall microbial community.

Colour by one categorical variable

Choose the main categorical variable of interest with the Grouping Variable parameter to colour the points by group. This shows whether samples from different groups (for example sample source, treatment group or sex) occupy different regions of the plot, and lets you judge visually whether their composition differs.

Add a second variable with shapes

Overlay a second categorical variable with the Shape Variable parameter. This is useful when two factors might both influence the data. For example, colouring points by treatment and shaping them by cohort shows whether the separation follows treatment, cohort or both, without a second plot.

Handling missing metadata

Samples with missing values in the grouping variable can be excluded with Drop samples with missing grouping metadata.
Keeping samples with missing metadata shows where unlabelled samples fall relative to the annotated groups. If an unlabelled sample sits deep inside one group’s cluster, check its metadata for a missing or wrong entry. Position on two components is not reliable enough to assign a sample to a group.

Group ellipses

Ellipses can be drawn around each group’s points to summarise where the group sits and how spread out it is.

Adding group ellipses

The Max Ellipses parameter sets how many ellipses are shown. Ellipses make overlap or separation easier to judge than scattered points alone.

Setting the ellipse size

The Confidence Level sets how large each ellipse is drawn. A higher value draws a wider ellipse that covers more of the group’s samples, a lower value a tighter one. The value changes only how the spread is drawn, not the underlying PCA, so treat ellipses as a visual summary of group position and variability rather than as a strict boundary. Ellipses describe PC1 and PC2 only. Groups that overlap on the plot can still differ along later components, and separated ellipses are not a statistical test. To test whether groups differ in overall composition, use PERMANOVA in Beta diversity.

Loading vectors

Loading vectors show how much each feature of the data table contributes to the principal components. They link the structure in the plot to specific taxa or functions. They are drawn as arrows from the centre of the plot:
  • The direction of an arrow shows towards which side of PC1 and PC2 the feature moves the samples that contain more of it.
  • The length of an arrow shows how strongly the feature contributes to PC1 and PC2, compared with the other arrows on the plot.
The arrows are enlarged so they stay visible next to the sample points, and the plot title reports the enlargement factor. Compare arrow lengths with each other, not with the axis values. In the example above, the arrow for Prevotella melaninogenica points upwards into the orange cluster. Samples with more of this species sit higher on PC2, and the length of the arrow shows that it is one of the main contributors to that axis. The longest arrows usually belong to abundant features whose levels vary a lot between samples. A short arrow does not mean that a feature is biologically unimportant.
An arrow pointing towards a group is a visual hint, not a test. To test whether a feature differs between groups, use Univariate comparison.

Include loading vectors

Set the Number of Vectors parameter to display the top N contributing taxa or functional features.

Exported files

Click Export to download the plot together with the tables behind it. The export contains the files below. In most of the tables the first column is an unnamed row number, which you can ignore.

Parameter reference

The metadata column used to define sample groups. It colours the points, so you can see whether samples cluster by a biological, experimental or technical category.Options · Categorical variables from the metadata table associated with the query used to create the analysisDefault · NoneSuggested · A categorical variable relevant to your study question, such as treatment, disease status, condition, body site, cohort, time point or sequencing batch.
When no grouping variable is selected, samples are shown without group colours. Use a grouping variable to check whether the main variation is associated with a known sample characteristic. For example, colouring by treatment shows whether treated and control samples separate, while colouring by batch helps detect technical effects.
Whether samples with missing values in the grouping variable are excluded from the plot.Options · TRUE or FALSEDefault · TRUE (samples with missing values are dropped)Suggested · Use TRUE when clear group comparisons matter, since it removes samples that cannot be assigned to a group. Use FALSE only when keeping all samples matters more for exploratory visualisation.
Dropping samples with missing group metadata makes the plot easier to interpret, since every displayed sample belongs to a defined group. If disabled, samples with missing values are assigned to NaN_group.
The number of loading vectors drawn on the plot. Vectors indicate which taxa or functions contribute most strongly to the displayed components. This parameter does not change the number of axes, which is always two.Options · Integer from 1 to 10Default · 2Suggested · Use 2 or 3 for a simple, readable plot. Increase it to inspect more features that may contribute to the main patterns.
More vectors give more detail but make the plot harder to read. Use few vectors for presentations and more for exploratory analysis. The full list of feature contributions is in loadings.csv in the export.
The maximum number of group ellipses shown. Ellipses summarise the position and spread of the groups defined by the grouping variable.Options · Integer from 0 to 10Default · 0Suggested · Use 0 to hide ellipses, or 1 to 5 to show them for a small number of groups while keeping the plot readable.
If the grouping variable has more groups than the maximum, only some groups get an ellipse. Ellipses do not affect the PCA calculation. For example, grouping by body site can show whether stool, oral and skin samples occupy different regions.
The confidence level used to draw group ellipses, which controls their size.Options · Integer percentage from 50 to 99Default · 95Suggested · Use the default for standard visualisation. Lower values draw tighter ellipses, higher values draw wider ones.
Ellipses are visual summaries of group position and spread, not strict statistical boundaries, and not proof that exactly 95% of samples fall inside. Overlapping ellipses suggest similar or highly variable profiles. Well-separated ellipses suggest that the grouping variable is associated with one of the main sources of variation shown on PC1 and PC2.
An optional categorical metadata column shown as different point shapes, so you can display a second characteristic on top of the grouping variable.Options · Categorical variables from the metadata table associated with the query used to create the analysisDefault · None (all samples share one shape)Suggested · A categorical variable that adds context, such as sex, cohort, sample type, time point or body site. For example, with points coloured by treatment, the shape can show which cohort or collection site each sample came from.