Transform otu_table(In absolute Abundance) to relative abundance

2,849 views
Skip to first unread message

EricG

unread,
Jun 13, 2013, 2:13:31 PM6/13/13
to qiime...@googlegroups.com
Hello Dear Qiimers,
I just wonder if there is a script to transform the otu_table.biom(In absolute Abundance) to otu_table.biom (In relative abundance), or anyone know a fancy way to do it using R (phyloseq->otu_table)

Cheers,

Eric

Will Van Treuren

unread,
Jun 15, 2013, 3:33:56 PM6/15/13
to qiime...@googlegroups.com
Hi Eric,

QIIME/Biom do not currently have a script which does this conversion. summarize_taxa.py will summarize your otu table and in the process convert to relative abundance, but this will alter the table as it will collapse any otus which have the same taxonomic classification. The operation is very straightforward in python, but I am not sure how you would do it in R. The operation in python is:

from biom.parse import parse_biom_table
bt = parse_biom_table(open('/path/to/your/biom_table.biom')
ra_bt = bt.normSampleByObservation()
ra_bt_str = ra_bt.getBiomFormatJsonString('generated_by_will')
o = open('/path/to/new/biom.biom','w')
o.writelines(ra_bt_str)
o.close()

You should then have your new, relative abundance biom table written out. You can add a feature request for this functionality on the biom format gituhub here.

Best, 
Will 


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

Eric JC Galvez B

unread,
Aug 9, 2013, 6:35:28 PM8/9/13
to qiime...@googlegroups.com
Sorry For the delay delay answer, it is working perfect, thanks a lot :), Just for the people there is one parenthesis left at the end of the second line:),

cheers!

Eric

You received this message because you are subscribed to a topic in the Google Groups "Qiime Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qiime-forum/kuD6382BseM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qiime-forum...@googlegroups.com.

Jennifer

unread,
Apr 24, 2014, 1:49:55 PM4/24/14
to qiime...@googlegroups.com
Hi Will thanks for providing this solution, however the script calculates the relative abundance of each OTU over it's total abundance in all samples instead of the relative abundance of each OTU within each sample. The latter I think is appropriate for most applications.

Take care,
Jen

Eric JC Galvez

unread,
Apr 24, 2014, 2:35:56 PM4/24/14
to qiime-forum
Hallo Jen,
Thanks for sharing the best way that I found was via R phyloseq
Using 

mysamples_RelAbundance = transform_sample_counts(mysample_phyloseq, function(x) x/sum(x))

It should be implemented in qiime soon and more after this

Best,
Eric


--

---
You received this message because you are subscribed to a topic in the Google Groups "Qiime Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qiime-forum/kuD6382BseM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qiime-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
     Eric JC Gálvez B.
            Biólogo
     Estudiante MSc.
Microbiología-Los Andes
+571-3394949 Ext.2768

Zoey

unread,
May 7, 2014, 11:00:36 AM5/7/14
to qiime...@googlegroups.com
Thanks to Will for the python scripts. 

I would like to mention that this script generates an OTU table with reads per OTU divided by the total counts of that OTU, which is different from reads per OTU in a sample by the total reads in that sample. Depending on how you define relative abundance, if the latter, it can be done in R with a .txt OTU table easily. 

Cheers,
Zoey

在 2013年6月13日星期四UTC-7上午11时13分31秒,EricG写道:

Eric JC Galvez

unread,
May 7, 2014, 8:10:48 PM5/7/14
to qiime-forum
Thank you for your clarification, 
Best


--

---
You received this message because you are subscribed to a topic in the Google Groups "Qiime Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qiime-forum/kuD6382BseM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qiime-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luis Peña

unread,
May 20, 2015, 4:39:01 PM5/20/15
to qiime...@googlegroups.com
Useful question :)
Reply all
Reply to author
Forward
0 new messages