# Is there any way to summarize taxa plot by category?

**URL:** <https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446>\
**Category:** User Support\
**Created:** [March 15, 2017, 10:21am UTC](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446 "2017-03-15T10:21:28Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jairideout](https://forum.qiime2.org/user_avatar/forum.qiime2.org/jairideout/32/9_2.png) [@jairideout](https://forum.qiime2.org/u/jairideout)\
**Post date:** [March 16, 2017, 5:03pm UTC](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446/2 "2017-03-16T17:03:53Z")

</div>

Hi @m-ocejo! We currently don't have that functionality in QIIME 2's taxa barplots. I created [an issue](https://github.com/qiime2/q2-taxa/issues/71) to track the addition of that feature. Note that you can sort the samples by a metadata category, so that samples from the same category will be grouped together (but each bar will still represent a single sample).

If you're interested in using QIIME 1 to produce these grouped barplots, you can export your BIOM table and taxonomy data from your .qza files. In order to use summarize\_taxa\_through\_plots.py, you'll need to export a feature table that _hasn't_ been collapsed to a particular taxonomic level yet, along with the table's corresponding taxonomic annotations.

For example:

```auto
qiime tools export table.qza --output-dir exported
qiime tools export taxonomy.qza --output-dir exported

```

Next, we'll need to modify the exported taxonomy file's header before using it with BIOM software. Before modifying that file, make a copy:

```auto
cp exported/taxonomy.tsv biom-taxonomy.tsv

```

The first few lines in `biom-taxonomy.tsv` should look something like this (the actual data will differ):

```auto
Feature ID	Taxon	Confidence
0204aa97a655fab087a6f6902be35eb6	k __Bacteria; p__ Bacteroidetes; c __Sphingobacteriia; o__ Sphingobacteriales; f __Sphingobacteriaceae; g__ Sphingobacterium; s__faecium	-1.0
5cfeeb662c643e512cbfc724c984f53d	k __Bacteria; p__ Firmicutes; c __Bacilli; o__ Lactobacillales; f __Lactobacillaceae; g__ Lactobacillus; s__	-1.0
4dc10ad4afd35b9803d853e819d3cec5	k __Bacteria; p__ Firmicutes; c __Clostridia; o__ Clostridiales; f __Lachnospiraceae; g__ ; s__	-1.0
...

```

Change the first line of `biom-taxonomy.tsv` (i.e. the header) to this:

```auto
#OTUID	taxonomy	confidence

```

Note that you'll need to use tab characters in the header since this is a TSV file.

Your `biom-taxonomy.tsv` file should now look something like this (the actual data will differ):

```auto
#OTUID	taxonomy	confidence
0204aa97a655fab087a6f6902be35eb6	k __Bacteria; p__ Bacteroidetes; c __Sphingobacteriia; o__ Sphingobacteriales; f __Sphingobacteriaceae; g__ Sphingobacterium; s__faecium	-1.0
5cfeeb662c643e512cbfc724c984f53d	k __Bacteria; p__ Firmicutes; c __Bacilli; o__ Lactobacillales; f __Lactobacillaceae; g__ Lactobacillus; s__	-1.0
4dc10ad4afd35b9803d853e819d3cec5	k __Bacteria; p__ Firmicutes; c __Clostridia; o__ Clostridiales; f __Lachnospiraceae; g__ ; s__	-1.0
...

```

Finally, add the taxonomy data to your .biom file:

```auto
biom add-metadata -i exported/feature-table.biom -o table-with-taxonomy.biom --observation-metadata-fp biom-taxonomy.tsv --sc-separated taxonomy

```

You can now use `table-with-taxonomy.biom` as input to `summarize_taxa_through_plots.py`.

Let us know how it goes!

---

_[View the full topic](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446)._
