How to add sample metada to feature.table.biom

I generated a collapsed table at level 5 and exported it using qiime tools export plugin. feature.table.biom does not have sample metadata. I want to add sample metadata to biom table and convert to tsv table, (either before exporting or after exporting) but could not any script to do so. biom add metadata adds taxonomy. I would appreciate if you could help me out with this. Thanks.

Hello!
You can convert your biom file to the tsv:
biom convert -i otu_table.biom -o otu_table.tsv --to-tsv
After you can add metadata info in python, R, excel or any other tool you are comfortable with.

Another option is to add metadata directly to the biom and then convert it to tsv if needed.

Best,

2 Likes

Hi Timur
Thanks for the input. I have been adding sample metadata to otu_table.tsv in Excel. I was wondering if there is any script to make it easy.
2nd suggestion, I tried biom add-metadata as described in the link. I got an output file say table-with-smd.biom. Used biom convert to make a txt file, which did not have two rows of sample metadata I was trying to add. Any idea what could have wrong here. Thanks

Hi!
I am not used to Excel, but I am sure that you can transpose your biom table, sort it by sample id, sort your metadata in the same way and then copy it. That's should work.
If you are comfortable with python, I can share a script that I run in Jupyter lab to do the job.