Regarding OTUS assigned to a particular taxa

70 views
Skip to first unread message

Muneer Malla

unread,
Mar 2, 2020, 2:28:42 PM3/2/20
to Qiime 1 Forum
 Hello All
 I am facing a problem 
I want to calculate the number of OTUS that are assigned to a particular taxa.
Please suggest me the command.

TonyWalters

unread,
Mar 2, 2020, 2:38:03 PM3/2/20
to Qiime 1 Forum
Hello,

Perhaps inelegant but this should work:
convert your .biom table to a tab delimited form, see:

specifically this example:
biom convert -i otu_table.biom -o otu_table.txt --to-tsv --header-key taxonomy

Then open your table in Excel, sort by taxonomy (right-most column) and then find the taxa in question and see how many rows there are with it.

Alternatively, you could use the .txt convertd file and do:
grep -c "X" otu_table.txt
where X is the taxonomy in question.

Muneer Malla

unread,
Mar 2, 2020, 3:06:59 PM3/2/20
to Qiime 1 Forum
Thanks Tony 
I tried it and it worked. 
However for clarification I am attaching the file
While I looked for Proteobacteria  and I calculate it in rows and it sums up 46.
Second Point now is how can I calculate the mean relative abundance of this group. along with others groups as well. 
proteobacteria.xlsx

Marco Severgnini

unread,
Mar 3, 2020, 4:16:25 AM3/3/20
to Qiime 1 Forum
Hello Muneer, if you want to calculate the relative abundance or the absolute count of reads in all your taxa, the best way should be using the "summarize_taxa.py" script.

The syntax should be the following:

summarize_taxa.py -i otu_table.biom -o tax_mapping/ [-L 2,3,4,5,6] [-a]

  • The "-L" option allows you to specify the taxonomic level of interest. If you are interested only to "Proteobacteria" and other phyla, you could specify "-L 2". Otherwise, by default, QIIME calculates the relative abundances of all levels between phylum (L2) and genera (L6).
  • The "-a" option, on the other hand, allows you to have a table with absolute counts instead of fractions.

You can see all the options with:
summarize_taxa.py -h

Marco

Muneer Malla

unread,
Mar 3, 2020, 4:47:31 AM3/3/20
to Qiime 1 Forum
Thanks Marco
The way Tony last mentioned it I have done that way and I think it worked and I got the exact no of OTUs for each taxa.
However I will also try to run this command.

TonyWalters

unread,
Mar 3, 2020, 5:21:47 AM3/3/20
to Qiime 1 Forum
Hello,

Try this:
biom normalize-table --relative-abund -i input_table -o output_table

using the table created earlier via the biom convert comment as the input_table. This should create a relative abundance form of the table that you can see the individual OTUs in (rather than collapsed by taxa as in the summarize_taxa.py output). 

Muneer Malla

unread,
Mar 3, 2020, 6:55:21 AM3/3/20
to Qiime 1 Forum
Hello Tony
Well I tried the command biom normalize-table --relative-abund
However the command gave the following error
Traceback (most recent call last):
  File "/usr/local/bin/pyqi", line 184, in <module>
    optparse_main(cmd_obj, argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pyqi/core/interfaces/optparse/__init__.py", line 275, in optparse_main
    result = optparse_cmd(local_argv[1:])
  File "/usr/local/lib/python2.7/dist-packages/pyqi/core/interface.py", line 41, in __call__
    return self._output_handler(cmd_result)
  File "/usr/local/lib/python2.7/dist-packages/pyqi/core/interfaces/optparse/__init__.py", line 250, in _output_handler
    opt_value)
  File "/usr/local/lib/python2.7/dist-packages/biom/interfaces/optparse/output_handler.py", line 80, in write_biom_table
    table.to_hdf5(f, generatedby())
  File "/usr/local/lib/python2.7/dist-packages/biom/table.py", line 3484, in to_hdf5
    self.group_metadata(axis='observation'), 'csr', compression)
  File "/usr/local/lib/python2.7/dist-packages/biom/table.py", line 3456, in axis_dump
    formatter[category](grp, category, md, compression)
  File "/usr/local/lib/python2.7/dist-packages/biom/table.py", line 3440, in vlen_list_of_str_formatter
    data[i, :len(value)] = value
TypeError: len() of unsized object
One more thing the file is generated I am also attaching the file

biom_normalized_table

TonyWalters

unread,
Mar 3, 2020, 7:01:01 AM3/3/20
to Qiime 1 Forum
Try your original biom file instead of the .txt file then (NOT the output from summarize_taxa.py).

Muneer Malla

unread,
Mar 3, 2020, 8:32:45 AM3/3/20
to Qiime 1 Forum
Hi again
Sorry I tried the file is generated but upon Opening the file it gives error.
Secondly I have calculate relative abundance in the excel sheet that you mentioned by considering the  OTU of a particular taxa upon the total OTUs .
Will that work or not.

Muneer Malla

unread,
Mar 3, 2020, 1:18:10 PM3/3/20
to Qiime 1 Forum
Hello again 
I am successfully done with the command. After running the 
biom normalize-table --relative-abund -i input_table -o output_table
I generated the table by was unable to open it 
i then ran the command Biom convert and it worked. 
Here I am attaching the table 
Please let me know how I can calculate the overall relative abundance of one taxa across all the three samples.
relative abundance.xlsx

Muneer Malla

unread,
Mar 5, 2020, 2:44:53 AM3/5/20
to Qiime 1 Forum
Hello Tony 
Are U there 
I am waiting to get my confusion cleared.

TonyWalters

unread,
Mar 5, 2020, 3:06:59 AM3/5/20
to Qiime 1 Forum
This board isn't actively monitored, just so you know-all current development is with QIIME2, not QIIME1

If you want to see the relative abundance of one particular taxa, just use the summarize_taxa.py output, and perhaps increase the level to include 7.

Otherwise, you'll need to do your own calculations-get the sum of counts in an absolute counts table across all taxa, then just divide your target taxa by those total counts to get the relative abundance.
Reply all
Reply to author
Forward
0 new messages