Exporting and modifying BIOM tables (e.g. adding taxonomy annotations)

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
32 Likes
How to make classic otu table with QIIME2?
Biom add-metadata problem
How to keep feature ID and taxonomy in a feature table with QIIME2
Import table of taxonomic composition with Phyloseq
Basic questions regarding classic OTU table in QIIME2
Problem with Biom add metadata
Greengenes Repeated Classifications
Combining feature ID and taxonomy in feature/biom tables
Biom add metadata problem
Error in my Feature Table with Taxonomy .tsv
Table of relative abundances
merging taxonomy assignment table with rarefied feature table
Differences in the depth of the taxonomic assignment
frequencies of feature per sample
report for total ASvs after denoising and mitochondria and chloroplast filtering
Classic OTU table
Trace back taxonomic classification to corresponding read IDs
Exporting with Taxonomy Error
Biom add metadata problem
Filtering Blank Taxonomic Ranks for Import into Phyloseq
How to make OTU table with NCBI taxnonomic ID's
biom.exception.BiomParseException: No header line was found in mapping file
Exporting feature table with taxonomy added not working
Id filtered table has no features?
Some questions about switching from QIIME 1.9X to QIIME 2.0
Tracing ASV to .fastq sequences to ID Unassigned
QIIME2 to PICRUSt
Error exporting and modifying biom
Is the Qiime2 feature table compatible with FUNGuild?
FeatureTable Exporting
i got no taxonomic annotations, why?
Adding taxonomy to BIOM file
Exporting qiime2 biom files with metadata?
Regarding OTu count table generation with taxonomy details using biom commands in qiime2
Virtual Box problem
exported .biom format file qiime2
workflow when importing biom table without sequences
the number of taxonomy.tsv is less than that of feature-table.tsv
How to get a BIOM table with QIIME 2
FeatureTable[Frequency] with taxonomy names rather than codes
Converted biom table does not contain taxonomy
Issue with using summarize_otu_distributions.py (from Earth Microbiome Project) on biom table exported from Qiime2
Help with tables and bar plots in Qiime2

An off-topic reply has been split into a new topic: Exporting feature table and adding taxonomy and converting to tsv

Please keep replies on-topic in the future.

An off-topic reply has been split into a new topic: biom.exception.BiomParseException: No header line was found in mapping file

Please keep replies on-topic in the future.

An off-topic reply has been split into a new topic: Change header names from Feature ID to OTUID in exported TSVTaxonomyDirectoryFormat file

Please keep replies on-topic in the future.

–output-dir no longer works, in case anyone is wondering, instead, use:

–output-path

1 Like

Updated the post, thanks @willwcb!

Ah, and you also have to have --input-path before the input file:

qiime tools export --input-path table.qza --output-path exported

1 Like

An off-topic reply has been split into a new topic: How to get taxonomy annotations in biom file?

Please keep replies on-topic in the future.

An off-topic reply has been split into a new topic: Export to “classic” biom

Please keep replies on-topic in the future.

An off-topic reply has been split into a new topic: How to include confidence in taxonomy-annotated BIOM file?

Please keep replies on-topic in the future.

A post was split to a new topic: Operation not permitted while exporting

A post was split to a new topic: Why it is so not intuitive?

A post was split to a new topic: Output counts and taxonomy to biom

A post was split to a new topic: Help merging metadata with biom file

A post was merged into an existing topic: Problem with Biom add metadata

A post was split to a new topic: Error exporting and modifying biom

An off-topic reply has been split into a new topic: i got no taxonomic annotations, why?

Please keep replies on-topic in the future.