Microbiome stacked bar chart (relative abundance) maker
Using the QIIME 2 taxa barplot directly in a paper usually means a legend dozens of lines long, colours that change from figure to figure, and labels stuck as d__Bacteria;p__…. Paste your summarized table here to get a stacked bar chart of the top genera plus “Others”, with fixed colours and a journal column width.
Your numbers are processed only in this browser. Nothing is sent to a server (it is gone when you close the page).
Samples can be in rows (QIIME 2 layout) or in columns (a provider’s Excel layout). The orientation is detected automatically; if it is wrong, press “Swap rows and columns”. Counts or percentages give the same chart (each sample is rescaled by its total).
Paste groups (sample ID | group)
One line per sample: sample ID and group, separated by a tab (two Excel columns) or a comma. Use this when the table has no group column.
The example data are made up (a soil example: common soil genera with invented counts; 12 samples from 3 sites).
Need higher resolution? Export at 300/600 dpi, PDF and TIFF, and multi-panel figures, are BenchFig Pro features (Windows, ¥3,980/year). Pro export for this stacked bar chart is in preparation. About the app →
Table layout
Open the QIIME 2 taxa barplot (taxa-bar-plots.qzv), choose the level (Level 6 = genus) and use “Download CSV”. Drop the resulting level-6.csv on the box, or paste its contents. For a provider’s Excel file, copy the table and paste it. These layouts are recognised automatically.
QIIME 2 layout (rows = samples): the first column is the sample ID, followed by one column per taxon with the lineage string as the header, then any metadata columns (group, date and so on).
| index | d__Bacteria;p__Actinobacteriota;…;g__Streptomyces | d__Bacteria;…;g__Arthrobacter | … | site |
|---|---|---|---|---|
| A01 | 1520 | 702 | … | SiteA |
| A02 | 988 | 1104 | … | SiteA |
Provider’s Excel layout (rows = taxa): one of the three below, with one column of values per sample to the right.
| (a) Taxonomy | A01 | A02 | … |
|---|---|---|---|
| d__Bacteria;p__…;g__Streptomyces | 1520 | 988 | … |
| (b) Kingdom | Phylum | … | Genus | A01 | A02 |
|---|---|---|---|---|---|
| Bacteria | Actinobacteriota | … | Streptomyces | 1520 | 988 |
| (c) Genus | A01 | A02 | … |
|---|---|---|---|
| Streptomyces | 1520 | 988 | … |
- Values can be counts, percentages or proportions (0–1). Each sample is divided by its total, so the chart is the same. If sample totals are about 100, the page says it read a % table.
- Columns headed Total, Sum, Confidence, Taxonomy and the like, and total rows, are not used (they are listed as ignored).
- Blank and NA cells are read as 0 and counted. Negative values stop the calculation. Samples with a total of 0 are left out.
- The Greengenes form (
k__Bacteria; p__Firmicutes; …), lineages without prefixes (Bacteria;Firmicutes;…), a#OTU IDheader and comment lines at the top are also understood. - If the table has no group column, paste “sample ID | group” in “Paste groups” to get group means.
- Right below the box, the page shows how it read the table, e.g. “Read as: … · 12 samples · 23 taxon rows · 2 metadata column(s) (site, depth_cm)”. Check this first.
How it is calculated
- Aggregate to a level: taxa are grouped by their names down to the chosen level (phylum, family or genus), and rows with the same name are summed.
- Shorten names:
d__Bacteria;…;f__Lachnospiraceae;g__Blautia→ Blautia. When there is no genus name (g__,g__uncultured,__and so on), the lowest named rank is used: “Lachnospiraceae (unclassified genus)”.g__unculturedand an emptyg__in the same family become one “unclassified genus”. When the same genus name appears in two families, the family is added to tell them apart. In a names-only table, rows such as uncultured or NA become one taxon, “No name (uncultured etc.)”, ranked like any other. Genus names are italic in the chart and the legend. - Relative abundance (%): within each sample, each taxon’s value is divided by the sample total and multiplied by 100.
- Top N + Others: the N taxa (default 10) with the highest mean relative abundance across all samples are shown, and the rest are summed as “Others”. With groups, the ranking still uses the mean of all samples, so every group shows the same taxa.
- Unassigned kept apart: sequences not assigned to any taxon (Unassigned) are not counted in N, are not mixed into Others, and are shown in dark grey.
- Group means: the per-sample percentages are averaged within each group (the same idea as phyloseq’s
transform_sample_countsto proportions followed by a group mean; checked to give the same values as R, with phyloseq for the proportions and dplyr for the group means). - Order and colours: within a bar, the top taxon is at the bottom, then the others in rank order, then Unassigned, with Others on top. In the per-sample chart, samples are grouped and, within a group, sorted by the top taxon (or kept in input order). Colours come from a 20-colour set based on the colour-blind-friendly Okabe–Ito palette, assigned in rank order; Others is light grey and Unassigned dark grey. A taxon has the same colour in the group-mean and the per-sample chart. Change any colour with “Change legend colours”.
In the example (genus, top 10), the most abundant genus is Rubrobacter (mean 11.3% across samples), Others average 32.5% and Unassigned 2.3%.
Legend and journal width
Choose 1 column (85 mm) or 2 columns (180 mm) and the page decides whether the legend goes to the right or wraps below the chart. Text is 7 pt. The legend follows the stacking order (Others, Unassigned, …, top taxon from the top down) and has at most N + 2 entries, so the taxa-barplot problem of a legend too long to fit in Word does not arise. Save a PNG at 2× screen size for free.
- A top N of about 8–12 is easiest to read (colours stay distinguishable)
- Use “Group mean” to compare groups; use “Both” to also show sample-to-sample variation
- Quote numbers from the % table, not from the chart (the table pastes straight into Excel)
- In the methods, state how % was computed, how means were taken and how the top N was chosen (copy the sentence below)
How it was checked
Per-sample %, group means, the set and order of the top N, Others and Unassigned, name shortening (unclassified genera, duplicate names), swapping rows and columns, identical results from count and % tables, and the handling of zero-total samples, blank and NA cells and thousands separators were all checked against an independent Python (pandas) implementation (13 cases; differences below 10−9 percentage points, except that comparing a % table rounded to 6 decimals with the count table allows up to 10−4 points for rounding). Because the Python code follows the same naming rules as this page, 7 further cases (QIIME 2 level-1 and level-2 headers, total columns, rows without names and so on) were checked against hand-calculated values. The results were also checked against values computed from the same tables in R 4.6.2 with phyloseq 1.56.0 (tax_glom, transform_sample_counts) and dplyr (7 cases: the example table at phylum, family and genus level; a QIIME 2-format phylum table with an Unassigned column, a Total column, a zero-total sample and groups of 2, 3 and 5; QIIME 2-format genus and family tables with uncultured and empty genera, a zero-total sample and groups of 1, 3 and 4; differences below 10−13 percentage points; apart from the example, the tables hold made-up values generated in R). The R code uses the same naming rule (uncultured and similar names mean “unknown at that rank”).
This page does not cover diversity (alpha or beta), PERMANOVA, tests for differentially abundant taxa (LEfSe, ANCOM, DESeq2 and so on) or rarefaction.
References
- Bolyen E, et al. Reproducible, interactive, scalable and extensible microbiome data science using QIIME 2. Nat Biotechnol. 2019;37:852–857. (QIIME 2 taxa barplot, level-x.csv)
- McMurdie PJ, Holmes S. phyloseq: an R package for reproducible interactive analysis and graphics of microbiome census data. PLoS ONE. 2013;8:e61217. (transform_sample_counts, tax_glom)
- Quast C, et al. The SILVA ribosomal RNA gene database project. Nucleic Acids Res. 2013;41:D590–D596. (the d__, p__… lineage format)
- Gloor GB, et al. Microbiome datasets are compositional: and this is not optional. Front Microbiol. 2017;8:2224. (relative abundances are compositional)
- Okabe M, Ito K. Color Universal Design (CUD): How to make figures and presentations that are friendly to colorblind people. 2008. (the colour set)
FAQ
Why is the group mean the mean of per-sample percentages?
Sequencing depth differs between samples. If you sum counts within a group and then convert to %, the deepest samples dominate. Converting each sample to % first and then averaging gives every sample the same weight. In the example, Rubrobacter in SiteA is 5.9% as a mean of per-sample %, but 6.3% when counts are pooled first.
Can I use a table that was not rarefied?
Yes. Relative abundance divides each sample by its own total, which already removes differences in depth, so a stacked bar chart of relative abundance does not need rarefaction. Samples with very few reads (a few hundred) have noisy proportions, though, so decide whether to include them according to your analysis plan.
What is the difference between Others and Unassigned?
Others collects taxa that were classified but are not in the top N. Unassigned is sequences that could not be assigned to any taxon. They mean different things, so this page shows them in different greys and does not count Unassigned in the top N. Taxa such as “Lachnospiraceae (unclassified genus)”, classified to family but not genus, are ranked like any other taxon.
The colours differ from the QIIME 2 taxa barplot
The QIIME 2 taxa barplot assigns colours to the taxa in the table by its own rules. This page assigns a fixed colour-blind-friendly set to the top N only, in rank order (Others and Unassigned are grey). The colours therefore do not match QIIME 2, but the same table and settings always give the same colours, and a taxon has the same colour in the group-mean and the per-sample chart. You can change colours from the legend.
Is my data sent anywhere?
No. Reading the table, the calculation and the chart all happen in your browser; nothing is sent to a server. Dropped files are read only inside the browser. Everything is gone when you close the page.
Other calculators
Related guides
Product names are trademarks or registered trademarks of their respective owners.