Merge biom files

Hi,

I need to merge several biom files in one OTU table. Each file looks like this:

# OTU ID ERR537638_FASTQ_SSU_OTU taxonomy
103181 382 sk__Bacteria
12906 12 sk__Bacteria;k__Bacteria
83222 1 sk__Bacteria;k__Bacteria;p__Acidobacteria
120758 1 sk__Bacteria;k__Bacteria;p__Acidobacteria;c__Holophagae
57104 2 sk__Bacteria;k__Bacteria;p__Actinobacteria

Before I was using qiime with the the command:

merge_otu_tables.py -i input_file1.biom, input_file2.biom, input_file3.biom -o merged_otu_table.biom

Now, I was wondering if in Qiime2 there was a similar command that I could use instead of merge_otu_tables.py, that dosn’t exist anymore

Thanks

Hi @mefistofele82,

If you have them in qiime artifact format, check out the qiime feature-table plugin for operations. If not, you’ll need to import them.

Best,
Justine

1 Like

Hi Justine,

thanks for your quick reply.
I have 20 different hdf5 biom files that I need to merge in one file. They are in a folder named Clean_biom, so, I tried to import them with:

qiime tools import
–input-path Clean_biom
–type ‘FeatureTable[Frequency]’
–input-format BIOMV210Format
–output-path feature-table-2.qza

but I got:

There was a problem importing Clean_biom:

** Clean_biom is not a file.**

It seems work with files not with forder, or maybe I need to specify something

Thanks

Hi @mefistofele82,

I think you need to import them individually.

Best,
Justine

Yes! It worked. I imported them individually and then merge them with:

qiime feature-table merge
–i-tables XXXXXX_FASTQ_SSU_OTU.qza
–i-tables YYYYYY_FASTQ_SSU_OTU.qza
–o-merged-table merged-table.qza

Is there any way to make it easier? I mean…if you have 100 files, instead writing each importing files, is it possible to specify a folder? or make a loop?

Thanks

You can use the --i-tables argument as many times as you like. So you can merge 100 tables together with one command like this:

qiime feature-table merge 
–i-tables XXXXXX_FASTQ_SSU_OTU.qza 
–i-tables YYYYYY_FASTQ_SSU_OTU.qza 
–i-tables ZZZZZZ_FASTQ_SSU_OTU.qza 
–i-tables ... 
–o-merged-table merged-table.qza

If you are comfortable working with the python API this is much easier, since you just input a list of tables to this command, so you can easily glob a whole directory to get this done.

1 Like

Thanks!
In the end, I have found this post, it’s really useful and the ruby script works well.

The only problem is that my final merged file doesn’t have the taxonomy anymore. A taxonomy was present in the original single biom files. Probably because qiime artifact files don’t include taxonomy? Or is there any option that I should include when importing the biom files?

thanks

Correct. QIIME 2 keeps feature tables and metadata (e.g., taxonomy) separate at all times — for one, this makes it much clearer what is stored inside. Feature metadata (e.g., taxonomy) is supplied any time it is needed.

The thing to do is import each of those biom tables a second time as a taxonomy artifact:

qiime tools import \
  --input-path table.biom \
  --output-path taxonomy.qza \
  --source-format BIOMV210Format \
  --type "FeatureData[Taxonomy]"

Great!
Thanks a lot for your help

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.