Skip to main content
This page covers how the heatmap module works in Cosmos-Hub 2.0: how to read each part of the figure and which parameters customize it. For what a heatmap is and when to use one, see the Heatmap overview.

Module output and customization

  • Annotated Heatmap: a highly customizable heatmap to inspect patterns microbial feature abundances across your cohort.
Heatmap Docs

Clustered heatmap of microbial species abundance across skin samples. Species are rows and samples are columns, with both clustered by profile similarity. Colour reports relative abundance, from dark for near zero to yellow for the highest values. The annotation bars above the heatmap label each sample by dermotype and body site, so clusters can be read against the metadata.

Read and customize the heatmap

Choose which features to show

A typical dataset can have hundreds or thousands of features, which makes it difficult to display them all on a single heatmap.
  • Limit how many rows appear by setting the Top features (N) parameter. For example, choosing 10 shows the top 10 features from the full matrix, ordered by your ranking method.
  • Decide how features are ranked by choosing a criterion with the Feature Ranking Method parameter. This sorts the features and keeps the top N:

Set the cell values and colours

The cell is the basic unit of the heatmap. Each cell sits at the intersection of a microbial feature (rows by default) and a sample (columns by default), and its color indicates how abundant that feature is in that sample, with low and high values shown as opposite ends of the color scale.

Setting the feature color palette

Can I display features as columns and samples as rows? Yes, use the Heatmap orientation parameter to switch whether rows represent features or samples.

Transforming abundance values

By default, when working with relative abundances (Analysis metric = relative_abundance), the color scale spans the full range (0 to 100%). This is intuitive, but microbiome data usually has a long tail of low-abundance features, where subtle - but informative - compostional patterns between your groups can be overshadowed by the high intensity of the dominant species. The Value Scaling parameter transforms the values before they’re mapped to color. This is useful to ‘inflate’ low relative abundance values to make it easier to detect differences between low-abundance features:

Add sample and feature annotations

Annotations are colored bars above the sample columns that overlay metadata onto the heatmap, so you can track sample characteristics alongside the microbial data.

Adding Sample (column) annotations

Use the Sample Annotation parameter to choose which metadata variables to add to the samples. Categorical variables (treatment group, body site, disease status) appear as distinct colors, and numerical variables (age, pH, BMI) appear as a graduated scale. The Drop samples with missing annotation option controls whether samples that lack the chosen annotation are removed.

Adding Feature (row) annotations

You can also annotate the features (rows) to add context about the features themselves, such as taxonomic information or other feature-level attributes. Use the Feature Annotation parameter to choose which feature-level variables to display, and Drop features with missing annotation to decide whether unannotated features are kept.

Order samples and features

The order of rows and columns decides which patterns you can see in the heatmap. You can order samples and features in two ways:
  • By annotation. Samples or features are sorted by the values of an annotation, or samples of the same group are merged into one column. Use it to read the heatmap against a variable you already know, for example treatment group or body site.
  • By hierarchical clustering. The abundance profiles decide the order, so that similar samples or features sit next to each other. Use it to find groups you do not know in advance.
Each axis follows only one of the two. Samples that are sorted or collapsed by annotation cannot be clustered, and features sorted by annotation cannot be clustered. The other axis can still be clustered, for example samples sorted by ethnicity and features clustered by similarity.

Order samples by annotation

Choose how samples are arranged with Sample Arrangement. This parameter appears after you select at least one Sample Annotation. Select the metadata columns in Arrange Samples By. The list contains only the columns already selected in Sample Annotation. With more than one column, the first one is the main sort key, and each following column orders only the samples that have the same value in the previous one. Samples In Ascending Order sets the direction for all the selected columns. Samples with identical values keep their original order.
How values are sorted. Numeric columns, for example age, are sorted by value. All other columns are sorted as text, character by character. A text column that contains numbers therefore places Visit 10 before Visit 2, and capital letters before lowercase letters. When Drop samples with missing annotation is unchecked, missing values form a group called NaN_group, which is sorted with the other text values.
Collapse samples by group
With Collapse samples by group (mean), each column is a group of samples, and each cell shows the mean value of a feature across the samples of that group. The column label reports the group and its number of samples, for example caucasian (n=74), and the axis label changes to Sample groups. Samples In Ascending Order sets the order of the groups.
  • The colour bar shows the mean, for example Mean Relative Abundance. With Value Scaling, the mean is calculated on the scaled values, for example the mean of the log10 values.
  • With Presence/Absence scaling, each cell shows the fraction of samples in the group where the feature is present.
  • The mean smooths extreme values, so the colour range is narrower than in a heatmap of single samples.
  • Annotation bars whose values differ among the samples of a group are removed from the heatmap.
Check the number of samples in each column label before you compare groups. A group with one sample shows a single profile, not a mean, and small groups vary more than large ones.

Order features by annotation

Choose how features are arranged with Feature Arrangement. This parameter appears after you select at least one Feature Annotation, which is available for taxonomic profiles. Select the annotation columns in Arrange Features By, and set the direction with Features In Ascending Order. Features with the same annotation value keep the order of Feature Ranking Method. For example, sorting species by genus places the species of each genus next to each other, and within a genus the species ranked higher come first.

Order samples and features by hierarchical clustering

Clustering reorders rows and columns so that similar profiles sit next to each other, which reveals patterns that a fixed order would hide. The heatmap uses hierarchical clustering, a method that builds a tree (called a dendrogram) grouping samples or features by similarity.
How does hierarchical clustering work? It starts with each sample (or feature) on its own, then repeatedly joins the two most similar ones into a group, then joins groups into larger groups, until everything sits in one tree. To decide what “most similar” means, it measures the distance between two profiles using the same metrics as in beta-diversity analysis. The distance metric sets how that similarity is measured, and the linkage sets how groups are joined step by step.
The Clustered Axis parameter sets whether you cluster samples, features, both, or neither. An axis that is sorted or collapsed by annotation is removed from the options.
  • Samples groups together samples with similar overall profiles. This is useful for seeing whether, for example, treatment and control samples separate. Paired with sample annotations, a cluster that matches a shared trait is a strong cue of a biological pattern.
  • Features groups together features with similar abundance patterns across samples. This is useful for spotting co-occurring taxa that may share ecological niches or interactions.
  • Samples and features reorganizes the heatmap so that co-abundant features align with similar samples, revealing blocks, which are sets of features that are characteristically high or low in a particular set of samples. This is often where the most informative patterns emerge, such as a microbial signature specific to a treatment or disease group.
Annotations are especially useful alongside column clustering. If samples cluster by their microbial profiles and the annotation bar shows they share a clinical or experimental trait, that is a strong visual cue of a real association.
Hierarchical clustering is performed on the top N features.
Choosing the distance metric [Advanced]
Choose how the similarity between pairs of profiles or features should be measured in terms of beta-diversity by selecting Distance metric. To see which distance metrics are supported and how to choose, refer to Beta Diversity on the Cosmos-Hub 2.0
Choose the linkage method [Advanced]
Choose Clustering method (linkage), which then sets how clusters are progressively merged into the tree. In hierarchical clustering, linkage defines how the distance between clusters is calculated at each step as they are merged into a tree (dendrogram). Different linkage methods use different rules for “cluster–cluster distance,” for example
We recommend trying a few combinations of Distance metrics and Linkage methods to find the most interpretable structure for your data.

Export the heatmap

Scroll to the end of the output page and click Download Tables and Images to export the heatmap in .svg and .png format, and the data table with the numerical input used to plot it. Choose your profile. Hover an underlined value to see why it is recommended.

Parameters by profile

Suitable and interpretable. A heatmap shows how the most abundant or variable taxa are distributed across samples and metadata groups. It is descriptive: confirm differences with Univariate comparison.
Pre-processing parametersAnalysis parameters

Parameter reference

Features shown

The method used to rank features across the whole cohort before the top N are selected for display.Options · mean, prevalence, variance, percentileDefault · meanSuggested ·
  • percentile is a balanced option for features that are both abundant and informative.
  • Use mean to prioritize highly abundant features
  • prevalence for features seen in many samples
  • variance for features that vary strongly across samples.
The number of top-ranked features to display.Options · Integer from 1 to 30Default · 10Suggested · 10 for a concise, readable heatmap; 20 to 30 for a broader exploratory view.
More features give more detail but reduce readability, use fewer for presentation, more for exploration.

Cell values and colours

The color palette used to display feature values.Options · Palettes configured in the platformDefault · viridisSuggested · Colorblind-friendly continuous palettes such as viridis for most heatmaps; alternatives like inferno when stronger contrast is needed.
The palette only affects display, not the underlying data. Choose one that makes high and low values easy to tell apart.
Whether values are transformed before plotting.Options · None, linear, log2, log10, asinh, clr, presence/absenceDefault · NoneSuggested ·
  • None: display values as directly as possible, especially for relative abundance.
  • log2 / log10: reduce the visual dominance of highly abundant features.
  • asinh: a log-like transform that handles zero values more easily.
  • clr: a composition-aware transformation.
  • presence/absence: reduces each cell to whether a feature is detected, ignoring how much.
Scaling strongly affects interpretation. Without it, highly abundant features can dominate the color range; with it, lower-abundance patterns become easier to see.
Whether features or samples are displayed as rows.Options · features_rows, samples_rowsDefault · features_rowsSuggested · Use features_rows as standard. Use samples_rows when there are more features than samples, or when it improves readability.
Orientation affects only the layout, not the values or clustering results.

Annotations

One or more metadata columns used to annotate samples, shown as colored bars above the heatmap.Options · Columns from the metadata table associated with the query used to create the analysisDefault · NoneSuggested · Variables relevant to the biological question, such as treatment, disease status, body site, cohort, time point, age group, or sex. Annotations help interpret patterns, but selecting too many makes the figure harder to read.
Whether samples with missing values for the selected variable in Sample Annotation are removed from the heatmap.Options · TRUE or FALSEDefault · TRUESuggested · Use TRUE when the annotation is essential and unannotated samples should be removed. Use FALSE to preserve sample size, or to see where unannotated samples cluster relative to annotated ones. With FALSE, unannotated samples are assigned to a default missing-value group.
An annotation used to group or label features (rows).Options · Available feature annotations, depending on the type of profiles in the Data Table (currently available only for taxonomic profiles)Default · NoneSuggested · For taxonomic heatmaps, use a higher taxonomic level (phylum, class, family) to annotate lower-level features such as species.
Feature annotations help show whether related features behave similarly, for example annotating species by phylum reveals whether specific taxonomic groups are enriched in certain samples.
Whether features with missing annotation values are removed.Options · TRUE or FALSEDefault · FALSESuggested · Use FALSE for most taxonomic analyses, so unannotated features stay in the heatmap. Use TRUE to show only features that have an annotation.
If enabled, unannotated features are removed from the heatmap. If disabled, they are kept and assigned to a default missing-value group.

Order by annotation

How samples are arranged along the sample axis, using their annotations. Appears after you select a Sample Annotation.Options · None, Sort samples, Collapse samples by group (mean)Default · NoneSuggested · Sort samples to read the heatmap against a metadata variable while every sample stays visible. Collapse samples by group (mean) for a compact summary of a large cohort. None when you want to cluster the samples.
Sorted or collapsed samples cannot be clustered. To collapse samples, the selected columns must give at least two groups, and at least one group must contain more than one sample.
The metadata columns used to sort the samples, or whose combinations of values define the groups to collapse. Appears when Sample Arrangement is not None.Options · The columns selected in Sample AnnotationDefault · NoneSuggested · One categorical column, such as treatment, body site or disease status. Add a second column only to order the samples within the groups of the first one.
The first column is the main sort key. Numeric columns are sorted by value, and all other columns are sorted as text.
The direction of the sort, applied to every column of Arrange Samples By. When samples are collapsed, it sets the order of the groups. Appears after you select at least one column in Arrange Samples By.Options · TRUE (ascending) or FALSE (descending)Default · TRUE
How features are arranged along the feature axis, using their annotations. Appears after you select a Feature Annotation.Options · None, Sort featuresDefault · NoneSuggested · Sort features to place related taxa next to each other. None when you want to cluster the features.
Sorted features cannot be clustered.
The annotation columns used to sort the features. Appears when Feature Arrangement is Sort features.Options · The columns selected in Feature AnnotationDefault · NoneSuggested · A taxonomic rank above the one displayed, for example genus or phylum for a heatmap of species.
Features with the same annotation value keep the order of Feature Ranking Method.
The direction of the sort, applied to every column of Arrange Features By. Appears after you select at least one column in Arrange Features By.Options · TRUE (ascending) or FALSE (descending)Default · TRUE

Clustering

Which axis is clustered and shown with a dendrogram.Options · None, Features, Samples, Samples and featuresDefault · NoneSuggested · Samples and features to find blocks of co-abundant features in groups of similar samples. Samples or Features to cluster one axis only, for example when the other axis is sorted by annotation. None to keep the original order or the order set by annotation.
An axis that is sorted or collapsed by annotation cannot be clustered, and the matching options are removed from the list. Sample clustering can show whether samples from the same condition have similar profiles. Feature clustering can reveal taxa or functions that behave similarly across samples.
How distances between rows or columns are calculated when clustering is enabled.Options · braycurtis, canberra, correlation, cosine, euclidean, jaccard, and othersDefault · euclidean
Different metrics define community similarity differently and can produce different dendrograms.
How distances are converted into a dendrogram (the linkage method).Options · single, complete, average, centroid, median, ward, weightedDefault · single
The linkage method affects the dendrogram shape and the row/column order, but not the underlying values.

References