# How to add taxonomy to feature-table.qza and get otu id of each taxonomy and number of otus

**URL:** https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470
**Category:** User Support
**Tags:** taxonomy, otus
**Created:** [March 19, 2018, 7:48am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470 "2018-03-19T07:48:41Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 19, 2018, 7:48am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/1 "2018-03-19T07:48:41Z")

</div>

hi I don't know how to use qiime1 and new to qiime2,after i run the following:  
biom add-metadata -i feature-table.biom -o table-with-taxonomy.biom --observation-metadata-fp biom-taxonomy.tsv --sc-separated taxonomy  
qiime tools import   
--input-path table-with-taxonomy.biom   
--type 'FeatureTable[Frequency]'   
--source-format BIOMV210Format   
--output-path feature-table-2.qza  
qiime taxa barplot   
--i-table feature-table-2.qza   
--i-taxonomy taxonomy.qza   
--m-metadata-file sample-metadata.tsv   
--o-visualization taxa-bar-plots\_otuid.qzv  
qiime feature-table summarize   
--i-table feature-table-2.qza   
--o-visualization feature-table-2.qzv   
--m-sample-metadata-file sample-metadata.tsv

i still cannot get the taxonomy in feature-table-2.qzv and no otu id in taxa-bar-plots\_otuid.qzv. really confusing. what i want is an OTU ID to each taxonomy and numbers of otu in the taxonomy. thanks very much.

---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 19, 2018, 9:22am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/2 "2018-03-19T09:22:57Z")

</div>

![1](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/2/21cbe15fca79a049b39c29f02b39d7cab155aeab.png)  
meaning I also want otu id in arrow mark place

---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 19, 2018, 10:08am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/3 "2018-03-19T10:08:57Z")

</div>

![2](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/6/69aa92fc1539ea4c51a9c3e66ef6b131a04a7549.png)  
for example the marked one, i want this id showing in taxa-bar-plots.tsv

---

<div class="post-metadata">

### Author: ![ebolyen](https://forum.qiime2.org/user_avatar/forum.qiime2.org/ebolyen/32/11_2.png) [@ebolyen](https://forum.qiime2.org/u/ebolyen)
#### Post date: [March 19, 2018, 3:02pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/4 "2018-03-19T15:02:11Z")

</div>



---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 20, 2018, 10:47am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/5 "2018-03-20T10:47:14Z")

</div>

Hi @Yanfei-Geng,  
I think I can help with part of what you're looking for, but some of it may be functionality that we don't currently have in QIIME 2.

First, I think what you are looking for is the [`qiime taxa collapse`](https://docs.qiime2.org/2018.2/plugins/available/taxa/collapse/) command. This will group features together based on their taxonomy, and generate a new feature table where the feature ids are taxonomic labels.

You could run this as follows:

```bash
qiime taxa collapse \
  --i-table feature-table-2.qza \
  --i-taxonomy taxonomy.qza \
  --p-level 3 \
  --o-collapsed-table feature-table-class.qza

```

The value that you provide for `--p-level` may change, depending on how many taxonomic levels are used in your taxonomy. In my case, I'm assuming kingdom is level 1, phylum is level 2, and class is level 3.

In QIIME 2, the taxonomy is never included in the feature table, but always in the corresponding `FeatureData[Taxonomy]` artifact (the `taxonomy.qza` file, in this example). This is so that different taxonomies can be easily associated with a single feature table. If you want a `.biom` file with taxonomy, you can see how to do that [here](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446/2).

We don't currently include feature ids (such as your _JX870786_) in the taxonomy barplots, as often there will be too many of them for that to be useful. You might try running `qiime feature-table summarize` and looking for that feature in the _Feature Detail_ tab, as there will be some basic information about it there. Alternatively, if you need to see counts of that feature on a per sample basis, you can export the feature table, convert it to tsv with `biom convert`, and find that feature in the resulting tsv file to get that information.

We also don't currently have a way to generate counts of the features that were grouped into each taxonomy. It should be fairly straight-forward to get that information though from the tabulated taxonomy. You can access that by running the following command, and then clicking the button for _Download metadata as TSV file_:

```bash
qiime metadata tabulate \
  --m-input-file taxonomy.qza \
  --o-visualization taxonomy.qzv

```

I hope this helps. Please let me know if you have any additional questions, or if I've misunderstood any of your questions.

---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 20, 2018, 10:47am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/6 "2018-03-20T10:47:33Z")

</div>



---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 20, 2018, 2:48pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/7 "2018-03-20T14:48:15Z")

</div>

Dear @gregcaporaso,  
Thank you for your generous help. I think I didn't make my questions clear before. To my understanding, take 16S analysis for example, **consensus\_taxonomy\_all\_levels.txt** includes two information,one is genbank accession no.(like my second image), two is the corresponding taxon information, and **97\_otus\_16S.fasta** also includes two information, one is genbank accession no., two is corresponding sequences. After we run  
qiime feature-classifier classify-sklearn \

# --i-classifier classifier.qza \

# --i-reads rep-seqs.qza \

# --o-classification taxonomy.qza

and other scripts needed, we can get taxonomy all levels you want. But for me, I am looking for the genbank accession no. for each taxonomy for my data. Hope I make my questions clear this time. Thank you for your time.

---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 20, 2018, 7:22pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/8 "2018-03-20T19:22:48Z")

</div>



---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 21, 2018, 7:07pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/9 "2018-03-21T19:07:19Z")

</div>

Hi @Yanfei-Geng,  
I think I understand - it sounds like you'd like to know which genbank ids were most similar to your sequences (in the `rep-seqs.qza` file). Is that right? We unfortunately don't have a way to get that information at the moment, though it is something we would like to add. This is in part because, with taxonomy assignment, typically more than one of the reference sequences is informing each individual taxonomy assignment.

If I understand what you're looking for, you may be able to get this information using `vsearch` directly (not through QIIME 2). `vsearch` will already be installed in your QIIME 2 environment. A command that I've used for this before is:

```bash
vsearch --db dna-sequences.fasta \
  --usearch_global queries.fasta \
  --alnout out.aln \
  --blast6out out.bl6 \
  --id 0.0 \
  --maxaccepts 10 \
  --qmask none

```

This will do a BLAST-like search of all of the sequences in `queries.fasta` against the sequences in `dna-sequences.fasta`, and will report back the 10 best matches for each sequence in `queries.fasta`. [We plan to make this accessible as a method in QIIME 2](https://github.com/qiime2/q2-vsearch/issues/35), but we haven't done that yet. If this does do what you're looking for, can you let me know? That type of feedback helps us to prioritize new functionality.

---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 21, 2018, 7:07pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/10 "2018-03-21T19:07:21Z")

</div>



---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 22, 2018, 2:37am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/11 "2018-03-22T02:37:50Z")

</div>

Dear @gregcaporaso,  
What i look for is exactly what you mentioned in your anwser. Now I am working on a project on diets of wild animals. We have our plants in animal feces analysed by vsearch, but the rumen bacterial community analysed by qiime2. So now it is hard for me to do the mantel test between plants diversity and bacterial diversity. Thank you again for your help.

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [March 22, 2018, 12:43pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/12 "2018-03-22T12:43:12Z")

</div>



---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 22, 2018, 4:06pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/13 "2018-03-22T16:06:13Z")

</div>

> [@Yanfei-Geng](#):
>
> What i look for is exactly what you mentioned in your anwser.

Great!

> [@Yanfei-Geng](#):
>
> So now it is hard for me to do the mantel test between plants diversity and bacterial diversity.

I'm happy to try to help with that if you explain the issue that you're having. This should definitely be possible to achieve with QIIME 2 if you have a feature table where the features are plant taxa (e.g., species identifiers) and the samples are the same (i.e., have the same identifiers) as the ones for which you have bacterial data.

---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 22, 2018, 4:31pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/14 "2018-03-22T16:31:12Z")

</div>



---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 26, 2018, 8:23am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/15 "2018-03-26T08:23:37Z")

</div>

what confuses me now is not mantel test any more, i finally find a way for mantel. I wonder how could I have an otu table, not the taxon table of every sample (like in the image)? Best.

 ![5](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/b/ba617b7560537749aa83e5fe5b642dc740accd9d.png)

---

<div class="post-metadata">

### Author: ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)
#### Post date: [March 26, 2018, 3:01pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/16 "2018-03-26T15:01:02Z")

</div>



---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 26, 2018, 6:14pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/17 "2018-03-26T18:14:07Z")

</div>

Hi @Yanfei-Geng, I think the OTU table that you're looking for should be the `feature-table-2.qza` artifact that you've been working with. You could export that with `qiime tools export`, and then convert the resulting `.biom` file to tab-separated text with `biom convert --to-tsv`. Would that get you what you need? If not, can you describe what the features are in your `feature-table-2.qza` file, and what you would like the features to be in the table you're trying to generate?

---

<div class="post-metadata">

### Author: ![gregcaporaso](https://forum.qiime2.org/user_avatar/forum.qiime2.org/gregcaporaso/32/17769_2.png) [@gregcaporaso](https://forum.qiime2.org/u/gregcaporaso)
#### Post date: [March 26, 2018, 6:14pm UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/18 "2018-03-26T18:14:24Z")

</div>



---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 27, 2018, 1:32am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/19 "2018-03-27T01:32:42Z")

</div>

hi@gregcaporaso the one you told me the output is like this

 ![6](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/c/c938214b0484ee210d11e313541eb8e950221d4b.png)  
but the one I want is like following, is this possible?  
 ![7](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/6/62102465ee3ca2b6549d61a6e9838804a82095fc.png)

---

<div class="post-metadata">

### Author: ![Yanfei-Geng](https://forum.qiime2.org/user_avatar/forum.qiime2.org/yanfei-geng/32/812_2.png) [@Yanfei-Geng](https://forum.qiime2.org/u/Yanfei-Geng)
#### Post date: [March 27, 2018, 8:56am UTC](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470/20 "2018-03-27T08:56:12Z")

</div>

@gregcaporaso hi,  
I found something in alpha-rarefaction.qzv

 ![8](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/e/e3ad325b37d0cc6ef62ba6f26e183e1aa71257b5.png)  
after downloading, the table is like this ![9](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/7/78f0041d95b4bba5c21d7ed7b7cfd9a6d5a25f15.png)  
did i understand this table correctly? Thank you so so much.

[Next page](https://forum.qiime2.org/t/how-to-add-taxonomy-to-feature-table-qza-and-get-otu-id-of-each-taxonomy-and-number-of-otus/3470.md?page=2)
