Filtering OTUs from table by abundance?

3134 views
Skip to first unread message

SJDebenport

unread,
Jun 24, 2013, 8:22:06 AM6/24/13
to qiime...@googlegroups.com
Hello all,

I am interested in looking at the taxonomic distribution of OTUs in different ranks from my OTU table. For instance, I would like to see diversity with just the top 10 OTUs, from the top 11-100 OTUs, 101-1,000, etc. I have found the filter_otus_from_otu_table.py script, but this appears to only take in counts for filtering, so I am curious if anyone has any suggestions for filtering by rank abundance.

Thank you for any help you can give!

Spencer

Tony Walters

unread,
Jun 24, 2013, 10:46:07 AM6/24/13
to qiime...@googlegroups.com
Hello Spencer,

There isn't built-in functionality that will automate this process. You probably will have to do this by hand.

You could convert your OTU table to tab-separated format, using the example of:
convert_biom.py -i table.biom -o table.from_biom_w_taxonomy.txt -b --header_key taxonomy
and later back into biom format using this example:
convert_biom.py -i otu_table.taxonomy.txt -o otu_table.from_txt.biom --biom_table_type="otu table" --process_obs_metadata taxonomy

The tab-separated file could be opened in Excel, and you could get the sum of each OTU count as a column (starting at row 2, column 2, and going to the row 2 and the last column before the taxonomy string) as another column past the taxonomy string column. Then you could sort according to this column, and use the OTU counts to guide where you want to make cutoffs at. Next you would save these cutoff tab separated OTU tables (with the added OTU counts column removed), and convert back to .biom format.

Hope this helps,
Tony


--
 
---
You received this message because you are subscribed to the Google Groups "Qiime Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qiime-forum...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

SJDebenport

unread,
Jun 27, 2013, 8:00:47 AM6/27/13
to qiime...@googlegroups.com
Hello Tony,

I did just as was mentioned here (converted biom table to .txt format, converted .txt to .csv, opened in Excel, created a counts column, sorted according to that, removed the counts column, saved as .csv with tab delimited columns, converted .csv to .txt, and then attempted to convert that .txt file to .biom format using the function you provided above. When I attempt to do this, I get the error "ValueError: Input does not look like a classic table. Do you need to pass -b?". Do you have any additional advice here?

Thank you very much for your assistance,
Spencer

Tony Walters

unread,
Jun 27, 2013, 11:39:00 AM6/27/13
to qiime...@googlegroups.com
Hello Spencer,

Can you post the command used with convert_biom.py, and the tab separated .txt file you're trying to convert back?

Tony Walters

unread,
Jun 27, 2013, 11:42:59 AM6/27/13
to qiime...@googlegroups.com
You can send the file directly to me if you don't feel comfortable posting it here (william(dot)a(dot)walters(at)gmail(dot)com)

SJDebenport

unread,
Jun 27, 2013, 11:46:33 AM6/27/13
to qiime...@googlegroups.com
Hello Tony,

Yes, the command I was using was just as you told me before:

convert_biom.py -i otus_11_100.txt -o otus_11_100.biom --biom_table_type="otu table" --process_obs_metadata taxonomy

The file is the one which I just sent to you as well.

Thank you for your help!

Spencer

Andrew Krohn

unread,
Sep 16, 2013, 2:01:25 PM9/16/13
to qiime...@googlegroups.com
Hi Spencer,

I don't know if this was ever resolved for you, but I've been converting biom tables back and forth for different analyses lately, and there are a couple of things to remember.

First, this page has some handy examples, even if the syntax is out of date: http://biom-format.org/documentation/biom_conversion.html

Use convert_biom.py --help to see the current syntax for your command

To convert from biom to txt (tab delimited), use the following:

convert_biom.py -i otu_table.biom -o otu_table.txt -b

However, this command leaves the taxonomy behind, so upon conversion back to biom, you will be missing some crucial metadata.  Write the taxonomy into your tab-delimited file this way:

convert_biom.py -i otu_table.biom -o otu_table.txt -b --header_key='taxonomy"

When converting back to biom, you must specify table type, and your metadata (taxonomy) field:

convert_biom.py -i otu_table.txt -o new_otu_table.biom --biom_table_type="otu table" --process_obs_metadata="taxonomy"

Hope this is helpful

Jason Norman

unread,
Jan 1, 2014, 8:49:17 PM1/1/14
to qiime...@googlegroups.com
Hi Andrew and all QIIMErs,
Thanks for posting the steps to sort an otu table by abundance and to convert back to .biom format.  I'm having an issue where my abundance_sort_otu_table.biom does not remain sorted by abundance when I perform downstream analyses (e.g. summarize_taxa.py or summarize_taxa_through_plots.py).  Is there a simple fix for this?
Best,
Jason

Antonio González Peña

unread,
Jan 2, 2014, 9:27:40 AM1/2/14
to Qiime Forum
No that I know of. You need to resort after each iteration. Anyway, I
have added an issue to Qiime about this:
https://github.com/qiime/qiime/issues/1312

Thanks for letting us know.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Qiime Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to qiime-forum...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Antonio
Reply all
Reply to author
Forward
0 new messages