Adding taxonomy to BIOM file

Hello all,

I am trying to add taxonomy to the BIOM file, I’ve read previous posts on this argument, e.g. Adding qiime2 taxonomy data to a .biom file
or
Exporting and modifying BIOM tables (e.g. adding taxonomy annotations)

When I run the following command:

biom add-metadata -i feature-table.biom -o table-with-taxonomy.biom --observation-metadata-fp taxo

nomy.txt --sc-separated taxonomy

I get the following error:

Traceback (most recent call last):
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/bin/biom”, line 6, in
sys.exit(biom.cli.cli())
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/click/core.py”, line 722, in call
return self.main(*args, **kwargs)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/click/core.py”, line 697, in main
rv = self.invoke(ctx)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/click/core.py”, line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/click/core.py”, line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/click/core.py”, line 535, in invoke
return callback(*args, **kwargs)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/biom_format-2.1.6-py3.5-linux-x86_64.egg/biom/cli/metadata_adder.py”, line 114, in add_metadata
write_biom_table(result, fmt, output_fp)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/biom_format-2.1.6-py3.5-linux-x86_64.egg/biom/cli/util.py”, line 35, in write_biom_table
table.to_hdf5(f, biom.parse.generatedby())
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/biom_format-2.1.6-py3.5-linux-x86_64.egg/biom/table.py”, line 4123, in to_hdf5
self.group_metadata(axis=‘observation’), ‘csr’, compression)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/biom_format-2.1.6-py3.5-linux-x86_64.egg/biom/table.py”, line 4095, in axis_dump
formatter[category](grp, category, md, compression)
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/biom_format-2.1.6-py3.5-linux-x86_64.egg/biom/table.py”, line 274, in general_formatter
data=[m[header].encode(‘utf8’) for m in md],
File “/media/nec3_HDD/miniconda3/envs/qiime2-2018.8/lib/python3.5/site-packages/biom_format-2.1.6-py3.5-linux-x86_64.egg/biom/table.py”, line 274, in
data=[m[header].encode(‘utf8’) for m in md],
AttributeError: ‘NoneType’ object has no attribute ‘encode’

Here an example of my taxonomy.txt file, which is tab delimited:

#OTUID taxonomy confidence
|—|---|—|
|39c3bee39813c7a3fb86ac37bcbabdfa|k__Bacteria; p__OD1; c__; o__; f__; g__; s__|0.9375202739084277|
|3331842f9f4800ba44dc4e3b27d721a3|k__Bacteria|0.9998922873953952|
|9ba5cf57ce002f21faebfcd8d7398e50|k__Bacteria; p__Proteobacteria; c__Gammaproteobacteria|0.9447318919177142|
|9dcf145da6164bae1c4bf1dbc891d130|k__Bacteria; p__Proteobacteria; c__Deltaproteobacteria; o__[Entotheonellales]; f__[Entotheonellaceae]; g__Candidatus Entotheonella; s__|0.9921146137262434|
|d31750608fe652520c4504297f31b5cd|k__Bacteria; p__BRC1; c__PRR-11; o__; f__; g__; s__|0.8006333484592095|
|df796f517ca7f329ce6a8087690e34df|k__Bacteria; p__Proteobacteria; c__Alphaproteobacteria; o__Rhodobacterales; f__Rhodobacteraceae|0.999817518053217|
|9cbd74ef3dfd155ef61e3e3b009cab2f|k__Bacteria; p__Verrucomicrobia; c__Verrucomicrobiae; o__Verrucomicrobiales; f__Verrucomicrobiaceae; g__; s__|0.9343150557057862|
|0919f06dceed92f48f8e8e12b9b60109|k__Bacteria; p__Bacteroidetes|0.9993982944424319|
|44e0f11509a331d16e6259a46ba84f69|k__Bacteria; p__Proteobacteria; c__Alphaproteobacteria; o__Rhodospirillales; f__Rhodospirillaceae; g__Inquilinus; s__|0.9995164904459591|

Thanks for helping!

Good afternoon,

I think I spotted something!

#OTUID taxonomy confidence
|—|---|—|

That looks like an markdown table with three headings… which means that each line will start and end with a | bar | character |
|39c3bee...
… and all these lines do!

Is your txt file formatted as markdown or did the markdown just sneak in when this was posted on the forums? If it’s in markdown format now, reformatting this as a .tsv file with tabs separating the columns might fix your problem!

Colin

Hi Colin,

thanks for answering. I think it shows up when I copy and paste on the forum. The taxonomy.txt file has been created using “qiime tools export”, then I reckon should be fine.

Hi @Fra,

I have a mini tutorial here for something else that starts with a biom-file and taxonomy gets added to it, maybe it would be of help. I’d love to know if it works.

Hello everybody,

thanks for your help, I found the problem.

Apparently I had to use the file with full taxonomy rather than using filtered taxonomy.

Cheers
Francesco

1 Like