txt to biom including taxonomy

1,769 views
Skip to first unread message

Stef

unread,
Feb 3, 2017, 8:39:40 AM2/3/17
to Qiime 1 Forum
Hi,
My pipeline outputs the OTU table as a .txt and I need help converting it in order to used it in Qiime. How do I do this and also preserve the phylogeny?
I attach a small table as an example.
Thanks a lot for the help!
/Stef
ALL.unoise.vsearch_short.txt

Colin Brislawn

unread,
Feb 3, 2017, 11:58:38 AM2/3/17
to Qiime 1 Forum
Hello Stef,

You should be able to convert this into a .biom table using the biom-format program.

Maybe something like: 
  • biom convert -i otu_table.txt -o new_otu_table.biom --to-json --table-type="OTU table" --process-obs-metadata taxonomy
    

Colin

Stef

unread,
Feb 6, 2017, 2:52:43 AM2/6/17
to Qiime 1 Forum
Thank you for the suggestion, Colin. Unfortunately, it does not work:
biom convert -i ALL.unoise.vsearch_short.txt -o ALL.unoise.vsearch_short.biom --to-json --table-type="OTU table" --process-obs-metadata taxonomy
Traceback (most recent call last):
  File "/macqiime/anaconda/bin/pyqi", line 184, in <module>
    optparse_main(cmd_obj, argv[1:])
  File "/macqiime/anaconda/lib/python2.7/site-packages/pyqi/core/interfaces/optparse/__init__.py", line 275, in optparse_main
    result = optparse_cmd(local_argv[1:])
  File "/macqiime/anaconda/lib/python2.7/site-packages/pyqi/core/interface.py", line 38, in __call__
    cmd_input = self._input_handler(in_, *args, **kwargs)
  File "/macqiime/anaconda/lib/python2.7/site-packages/pyqi/core/interfaces/optparse/__init__.py", line 194, in _input_handler
    self._optparse_input[optparse_clean_name])
  File "/macqiime/anaconda/lib/python2.7/site-packages/biom/interfaces/optparse/input_handler.py", line 42, in load_biom_table
    return parse_biom_table(table_f)
  File "/macqiime/anaconda/lib/python2.7/site-packages/biom/parse.py", line 313, in parse_biom_table
    t = Table.from_tsv(fp, None, None, lambda x: x)
  File "/macqiime/anaconda/lib/python2.7/site-packages/biom/table.py", line 3824, in from_tsv
    t_md_name) = Table._extract_data_from_tsv(lines, **kwargs)
  File "/macqiime/anaconda/lib/python2.7/site-packages/biom/table.py", line 3969, in _extract_data_from_tsv
    values = map(dtype, fields[1:-1])
ValueError: could not convert string to float: Bacteria;Fusobacteria;Fusobacteriia;Fusobacteriales;Fusobacteriaceae;Fusobacterium;Fusobacterium_nucleatum;

How can I solve this issue?
Thanks again!
Cheers,
Stef

Colin Brislawn

unread,
Feb 6, 2017, 12:02:31 PM2/6/17
to Qiime 1 Forum
Hello Stef,

I took a look in that error message for clues:
ValueError: could not convert string to float: Bacteria;Fusobacteria;Fusobacteriia;Fusobacteriales;Fusobacteriaceae;Fusobacterium;Fusobacterium_nucleatum;
Looks like the script got surprised by the taxonomy string, and tried to parse it as a number.

In the example command I provided, I listed --process-obs-metadata taxonomy, while your txt file uses Taxonomy (with a capital T). Linux is case sensitive, so you could try rerunning this command using Taxonomy.

Let me know if that helps!
Colin

Jennifer Lang

unread,
Mar 24, 2017, 11:52:20 PM3/24/17
to Qiime 1 Forum
Hi All,

I had the same question! I have some old data from a previous study conducted in the lab and I was given two files.

1. OTU table: rows = samples, columns= otus labeled "taxon_id"
2. taxa list: column1= "taxon_id" column2 = taxa name

I was able to reverse engineer the biom table by looking at the section below online. I went from biom to text of a different file I had to see what the txt file looked like so I could create a new txt file that matched that format.

Round-tripping between biom and tsv:    http://biom-format.org/documentation/biom_conversion.html


Process:
1. Transpose the OTU table so it is OTUxsamples
2. Add the taxa name as the last column (labeled with taxonomy) by using VLOOKUP in excel (I did this because the OTUs were out of order but I guess you could just sort them in excel. I usually prefer VLOOKUP just incase the files dont match.)
3.***THE IMPORTANT PART*** Insert a blank row 1 and add "#Constructed from biom file"
4. Confirm proper format using: biom summarize-table

Once I added that extra row I was able to get a summarized table.

Hope this helps!
Jennifer

Colin Brislawn

unread,
Mar 25, 2017, 1:58:50 PM3/25/17
to Qiime 1 Forum
Thanks for posting your solution. Thats super helpful!
Colin
Reply all
Reply to author
Forward
0 new messages