Exporting otu_table() from phyloseq into either biom or text format

Hello all,

I am having trouble in trying to figure out how to export a phyloseq object as a text or biom file. Also, I have noticed that my tables are different if I import a biom file from MEGAN or export a text file from MEGAN and then convert that into a json biom table. When I do the former, I don’t see the taxa names on the left. I do see them for the latter. I am having no problems running decontam in either case. I am able to use prune_taxa(!contamdf.prev$contaminant, phyloseq-object). And so I have the otu_table that I want. However, I am not sure how to export it as a text or biom file in R so that I can then import it into QIIME2 (i.e. a qza format). I have tried the following write.table() code but that is giving me a table without any taxonomy names.

otu_table(phyloseq-object)[1:5, 1:5]

write.table(t(otu_table(phyloseq-object)), “samples-decontam-filtered.txt”, sep = “\t”, row.names = TRUE, col.names = NA, quote = FALSE)

Samples 1, Sample 2, …
2 11910 14206 12158 14498 7753 4949 7970 15989 18050 22519 19144 18724 23351 84 9037 11037 21407 21180 13367 20958 14329 16279 13851 16400 28022 12854 22574 10828 14208 24573 30444 16504 23558 20564 16114 13050 27812 18564 19158 13868 4326 8856 6720
57723 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 52 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
204434 0 0 0 0 0 0 0 0 0 0 0 0 0 5 671 485 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
658062 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1267533 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1476577 47385

Any help on this would greatly be appreciated!

Hi @SterlingWright2016 ,

Welcome to the forum!
I’m not experienced with MEGAN but exporting objects from phyloseq to QIIME 2 has been covered a few places around this forum. For example, you can try the tutorial here and let us know if it works?

1 Like