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


(Matthew Ryan Dillon) #1

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 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:

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

How to make classic otu table with QIIME2?
Biom add-metadata problem
Import table of taxonomic composition with Phyloseq
Basic questions regarding classic OTU table in QIIME2
How to keep feature ID and taxonomy in a feature table with QIIME2
Greengenes Repeated Classifications
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
Filtering Blank Taxonomic Ranks for Import into Phyloseq
Table of relative abundances
(Nicholas Bokulich) #2

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.


(Nicholas Bokulich) #3

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.


(Greg Caporaso) #4

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.


Change header names from Feature ID to OTUID in exported TSVTaxonomyDirectoryFormat file
(Greg Caporaso) #5

(Greg Caporaso) #6