Creating a TSV BIOM table
The following is based on a post 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.0 2156.0 1205.0 1772.0
154709e160e8cada6bfb21115acc80f5 812.0 1176.0 713.0 407.0 242.0
Creating a BIOM table with taxonomy annotations
The following is based on a post by @jairideout.
qiime tools export --input-path table.qza --output-path exported
qiime tools export --input-path taxonomy.qza --output-path 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:
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):
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:
#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):
#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:
biom add-metadata -i exported/feature-table.biom -o table-with-taxonomy.biom --observation-metadata-fp biom-taxonomy.tsv --sc-separated taxonomy