News and Announcements » – Plot heatmap of OTU table


This script visualizes an OTU table as a heatmap where each row corresponds to an OTU and each column corresponds to a sample. The higher the relative abundance of an OTU in a sample, the more intense the color at the corresponsing position in the heatmap. By default, the OTUs (rows) will be clustered by UPGMA hierarchical clustering, and the samples (columns) will be presented in the order in which they appear in the OTU table. Alternatively, the user may supply a tree to sort the OTUs (rows) or samples (columns), or both. The user may also pass in a mapping file for sorting samples. If the user passes in a mapping file and a metadata category, samples (columns) will be grouped by category value and subsequently clustered within each group.

Usage: [options]

Input Arguments:



-i, --otu_table_fp
Path to the input OTU table (i.e., the output from
-o, --output_fp
The output filepath


-t, --otu_tree
Tree file to be used for sorting OTUs in the heatmap
-m, --map_fname
Metadata mapping file to be used for sorting Samples in the heatmap.
-c, --category
Metadata category for sorting samples. Samples will be clustered within each category level using euclidean UPGMA.
-s, --sample_tree
Tree file to be used for sorting samples (e.g, output from If both this and the sample mapping file are provided, the mapping file is ignored.
-g, --imagetype
Type of image to produce (i.e. png, svg, pdf) [default: pdf]
Data will not be log-transformed. Without this option, all zeros will be set to a small value (default is 1/2 the smallest non-zero entry). Data will be translated to be non-negative after log transform, and num_otu_hits will be set to 0.
No UPGMA clustering of OTUs (rows) is performed. If –otu_tree is provided, this flag is ignored.
No UPGMA clustering of Samples (columns) is performed. If –map_fname is provided, this flag is ignored.
Do not normalize samples to sum to 1 [default: False]
Color scheme for figure. see for choices [default: YlGn]
Width of the figure in inches [default: 5]
Height of the figure in inches [default: 5]
Resolution of the figure in dots per inch [default: value of savefig.dpi in matplotlibrc file]
Observation metadata category to plot [default: taxonomy]
The level of observation metadata to plot for hierarchical metadata [default: lowest level]


A single output file is created containing the heatmap of the OTU table (a PDF file by default).

Generate a heatmap as a PDF using all default values: -i otu_table.biom -o heatmap.pdf

Generate a heatmap as a PNG: -i otu_table.biom -o heatmap.png -g png

Sort the heatmap columns (samples) by the order of samples in the mapping file -i otu_table.biom -o heatmap_sorted_samples.pdf -m mapping_file.txt

Sort the heatmap columns (samples) by the order of samples in the mapping file, and sort the heatmap rows by the order of tips in the tree: -i otu_table.biom -o heatmap_sorted.pdf -m mapping_file.txt -t rep_set.tre

Group the heatmap columns (samples) by metadata category (e.g., Treatment), then cluster within each group: -i otu_table.biom -o heatmap_grouped_by_Treatment.pdf -m mapping_file.txt -c Treatment