# FeatureTable\[Frequency\] with taxonomy names rather than codes

**URL:** https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923
**Category:** User Support
**Tags:** taxonomy, feature-table
**Created:** [December 18, 2019, 9:47am UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923 "2019-12-18T09:47:42Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Sparkle](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sparkle/32/6789_2.png) [@Sparkle](https://forum.qiime2.org/u/Sparkle)
#### Post date: [December 18, 2019, 9:47am UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/1 "2019-12-18T09:47:42Z")

</div>

Good morning to everyone,  
I'd like to obtain a FeatureTable[Frequency] object (like the one obtained from `dada2 denoise-paired`) with actual taxonomy identification rather than a self-assigned name made up of a sequence of numbers and letters (like the one below).

[![](https://i.ibb.co/y4Dt5VZ/Code.png) ](https://i.ibb.co/y4Dt5VZ/Code.png)

Of course, at this step of the analysis, taxonomic identification hasn't been performed yet, but it is done later, and I'm not sure how to obtain such table...

I've already checked out this [previous thread](https://forum.qiime2.org/t/how-can-i-create-taxonomy-table-with-frequency/796) and had already tried it as a part my pipeline, **but I'd like to obtain a full file, without performing collapsing** through `qiime taxa collapse` at any taxonomic level.

This would make the results of any further analysis definitely more readable, **without having to group my taxa at a specified level** (but having a general overview of how my taxa behave instead).

I've noticed the plugin `qiime taxa barplot` outputs a plot showing taxa rather than the previously mentioned codes, requiring a previously created taxonomy.qza file as input, but other plugins I used (like `qiime taxa filter-table` to remove mitochondrial and chloroplastic contaminant reads from my features) will just use taxonomy to perform filtering, still outputting a FeatureTable[Frequency] containing the codes.

In particular, I'd be interested in obtaining **such table** , free from contaminants, showing taxonomies rather than codes.

Is there any easy way to perform this, starting from the filtered table obtained from `qiime taxa filter-table` and the taxonomy.qza file resulting from `qiime feature-classifier classify-sklearn`?

Thanks in advance!

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [December 18, 2019, 2:59pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/2 "2019-12-18T14:59:46Z")

</div>

Hello @Sparkle,

There are a lot of parts to this request. Let's take them one at a time.

Getting that full FeatureTable[Frequency] table with taxonomy names (instead of ASV IDs) could be done by [exporting or extracting](https://docs.qiime2.org/2018.11/tutorials/exporting/) your qva file. This can be a bit tricky, but it should give you both the table with counts, and ASV names, and taxonomy names. 👍

* * *

2nd question:

> [@Sparkle](#):
>
> remove mitochondrial and chloroplastic contaminant

Do that filtering with `qiime taxa filter-table` first, then export / extract your table.

Let me know how this works for you!  
Colin

---

<div class="post-metadata">

### Author: ![Sparkle](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sparkle/32/6789_2.png) [@Sparkle](https://forum.qiime2.org/u/Sparkle)
#### Post date: [December 18, 2019, 3:24pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/3 "2019-12-18T15:24:25Z")

</div>

Good afternoon, and thanks for your reply!

I've tried both but apparently I obtained a .biom file in both cases.  
What should I do with it?

Moreover, if I try to visualize the original filtered table (as follows), I still obtain ASV codes, so I guess I have to use somehow the taxonomy file too while exporting/extracting?.

`qiime feature-table tabulate-seqs --i-data table-no-clo-mit.qza --o-visualization table-no-clo-mit.qzv`

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [December 18, 2019, 3:37pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/4 "2019-12-18T15:37:53Z")

</div>

You could convert the .biom table to a tsv file, if you wanted.  
`biom convert -i table.biom -o table.from_biom_w_taxonomy.txt --to-tsv --header-key taxonomy`

> [@Sparkle](#):
>
> so I guess I have to use somehow the taxonomy file too while exporting/extracting?.

That's right! You could export / extract the taxonomy table too, then merge your FeatureTable with your taxonomy table based on the ASV IDs.

---

<div class="post-metadata">

### Author: ![Sparkle](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sparkle/32/6789_2.png) [@Sparkle](https://forum.qiime2.org/u/Sparkle)
#### Post date: [December 18, 2019, 3:45pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/5 "2019-12-18T15:45:54Z")

</div>

Thank you, I'll try this!

Merge through a QIIME plugin or something else?

---

<div class="post-metadata">

### Author: ![colinbrislawn](https://forum.qiime2.org/user_avatar/forum.qiime2.org/colinbrislawn/32/6221_2.png) [@colinbrislawn](https://forum.qiime2.org/u/colinbrislawn)
#### Post date: [December 18, 2019, 6:50pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/6 "2019-12-18T18:50:24Z")

</div>

> [@Sparkle](#):
>
> Merge through a QIIME plugin or something else?

Something else. Say the biom-format package, R, Python, or a spreadsheet program like Excel or Google Sheets.  
Both the tables will have the same ASVs IDs, so you can merge on this shared column.

---

<div class="post-metadata">

### Author: ![Sparkle](https://forum.qiime2.org/user_avatar/forum.qiime2.org/sparkle/32/6789_2.png) [@Sparkle](https://forum.qiime2.org/u/Sparkle)
#### Post date: [December 19, 2019, 10:53am UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/7 "2019-12-19T10:53:05Z")

</div>

> [@colinbrislawn](#):
>
> biom-format package, R, Python, or a spreadsheet program like Excel or Google Sheets.  
> Both the tables will have the same ASVs IDs, so you can merge on this sh

I guessed something similar, and then re-importing them from .tsv to .biom again, and from .biom to .qza ?

I tried to convert a .txt to .biom through `biom convert` but got this.

> biom.exception.TableException: Duplicate observation IDs

I guess this means that different ASVs could be associated to the same taxonomical identification.

And that I have to sum the abundances for taxonomies showing the same names and collpase such duplicate rows into just one before providing the txt to biom.exception again?

I checked on Excel and there were duplicate rows (same taxonomy).

---

<div class="post-metadata">

### Author: ![timanix](https://forum.qiime2.org/user_avatar/forum.qiime2.org/timanix/32/17879_2.png) [@timanix](https://forum.qiime2.org/u/timanix)
#### Post date: [December 19, 2019, 11:36am UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/8 "2019-12-19T11:36:35Z")

</div>

> [@Sparkle](#):
>
> I guess this means that different ASVs could be associated to the same taxonomical identification.

That's right.  
Now you can choose several options, for example:

1. To collapse table in Qiime2 and after it to edit biom table (replace long names with last available taxonomy level, such as genus).
2. To combine taxa and original hash names without collapsing table.  
In my analysis, I chose second option to keep different ASVs rather than collapse it since each ASV can demonstrate different behavior and taxonomy resolution sometimes is too low for the analysis.

---

<div class="post-metadata">

### Author: ![lca123](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/l/47e85d/32.png) [@lca123](https://forum.qiime2.org/u/lca123)
#### Post date: [December 19, 2019, 12:35pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/9 "2019-12-19T12:35:25Z")

</div>

I do a few parses for having a table with counts and taxonomy assigned to each feature. As Timanix mentioned, I also like working with this table rather than a collapsed taxonomy table because there's lots of taxonomies assigned to more than one feature.  
That's what I do:

export a feature-table:  
`qiime tools export --input-path feature-table.qza --output-path .`

and convert .biom to .tsv:  
`biom convert --to-tsv -i feature-table.biom -o feature-table.tsv`

tabulate taxonomies:  
taxonomy.qza is the output from a classifier.  
`qiime metadata tabulate --m-input-file rep-seqs-from-dada2.qza --m-input-file taxonomy.qza --o-visualization viz.qzv`

the viz.qzv has hash ids, DNA sequence and a taxonomy assigned to it, but still lack frequency per sample. So let's create a file from a few parses having all of it.

```
qiime tools export --output-path metadata --input-path viz.qzv
cp metadata/metadata.tsv .

```

Don't know why but join complains these 2 files are not sorted so wont join... as I checked once, they're sorted, but...  
Let's also throw away the first line in both files because join can only understand one line as a header  
`sed -e '1d' feature-table.tsv | awk 'NR<2{print $0;next}{print $0|"sort"}' > a`  
` sed -e '1d' metadata.tsv | awk 'NR<2{print $0;next}{print $0|"sort"}' > b`  
`join --header a b > table-feature-counts-per-sample.tsv`

turn it into a .tsv file:  
`sed -i 's/#OTU ID/#OTUID/g' table-feature-counts-per-sample.tsv`  
`sed -i 's/ /\t/g' table-feature-counts-per-sample.tsv`  
`sed -i 's/\./,/g' table-feature-counts-per-sample.tsv`

bye bye lots of files:  
`rm -rf viz.qzv a b metadata metadata.tsv feature-table.biom feature-table.tsv`

Opening your table-feature-counts-per-sample.tsv in Excel you'll find it:

 ![table](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/4/40bb6a569890e9bc3bd3c8f10f1aefe0bb23c28a.png)

Hope that helps. Cheers.

---

<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: [December 19, 2019, 4:51pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/10 "2019-12-19T16:51:49Z")

</div>

@Sparkle @lca123,  
Here is a tutorial that I think would generate an OTU table text file of the style @lca123 uses, but in what I think is a more streamlined way:

> [@Exporting and modifying BIOM tables (e.g. adding taxonomy annotations)](https://forum.qiime2.org/t/exporting-and-modifying-biom-tables-e-g-adding-taxonomy-annotations/3630):
>
> Creating a TSV BIOM table The following is based on [a post](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/22) by @gregcaporaso. $ qiime tools export table.qza --output-dir ./ $ biom convert -i feature-table.biom -o feature-table.tsv --to-tsv $ biom head -i feature-table.tsv # Constructed from biom file #OTU ID L1S105 L1S140 L1S208 L1S257 L1S281 4b5eeb300368260019c1fbc7a3c718fc 2222.0 0.0 0.0 0.0 0.0 fe30ff0f71a38a39cf1717ec2be3a2fc 5.0 0.0 0.0 0.0 0.0 d29fe3c70564fc0f69f2c03e0d1e5561 0.0 0.0 0.0 0.0 0.0 868528ca947bc57b69ffdf83e6b73bae 0.0 2276…

If you want sequence data in the table (as @lca123 has), you can follow the taxonomy annotation steps a second time, but with the representative sequences file.

I hope this helps.

---

<div class="post-metadata">

### Author: ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)
#### Post date: [January 19, 2020, 10:51pm UTC](https://forum.qiime2.org/t/featuretable-frequency-with-taxonomy-names-rather-than-codes/12923/11 "2020-01-19T22:51:53Z")

</div>

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
