merging feature_table.qza and taxonomy.qza

I suck at this but I'm just puttering along trying my best. Any help would be greatly appreciated

I am working on gut microbiology samples sequenced by Illumina for a member of my lab. They are trying to get this one last figure before publishing, it needs to match some of their prior work so there are some constraints. Specifically they wanted me to use Deblur, and once completed I need to deliver the results in a .biom file they can use to import into the schools programs to create said figures that look the same.

What I've done so far
I successfully:

  • Imported the files into Qiime2
  • Ran deblur. (output feature table is named table.qza)
  • got taxonomy. (output artifact named taxonomy.qza)
  • Everything has been checked and worked successfully through visualizations

What I need
I need to output a .biom file of a the combined table.qza and taxonomy.qza. The features match up for them, so It kind of makes sense.

I have currently exported both of them and I am trying to combine them manually in a Jupyter-notebook, but I'm sure there is a better way to do this. I am thinking the final table I'm creating have samples along one axis and taxonomy along the other, and the numbers per feature as the values, then importing that back into Qiime just to export it as a .biom file. But this seems a little absurd.

Please let me know if anything is unclear or if you can help!
Thank you!

Hi @Kyle_Brand,
Welcome to the :qiime2: forum!
There are a couple of options here!

I don' think taxa-collapse is what you are looking for but that might be an option. Have you checked out qiime feature-table taxa-collapse?

Otherwise doing this in python might be the best way to accomplish what you are saying. Could you share your code so I can give advice. The downside of this way is you will lose all provenance from your feature-table ):

Thank you @cherman2

I did manage to do it in Python. I ended with a table that had the Taxonomy as the rows and samples_numbers as the columns with their corresponding values in the middle. To me this seems a format that I would be able to upload into qiime to make a 'table' and easily export as a .biom format..... But qiime wasn't cooperating, so I wrote my own script to create a .biom file. It worked, and my lab mate is super pleased.

I would like like to understand this better though. Any idea why I wasn't able to import a .tsv file that seems to be fairly simple. I tried a few commands but let's focus on this one

$ qiime tools import \
  --type FeatureTable[Frequency] \
  --input-path taxa_table.tsv \
  --output-path combined_feature_table.qza

this threw the error:
There was a problem importing taxa_table.tsv:

taxa_table.tsv is not a(n) BIOMV210Format file

for clarity, this was not a messy .tsv. I summed up the index. df.shape was 33x17 and the values made sense.


Hi @Kyle_Brand,
Glad I could help!
That all makes sense to me! qiime2 only accepts a biomfile on the command line so you will need to convert to a biom file! Here are the docs: Converting between file formats —

Also you you could do this in python too so that you just have an artifact that is ready to go.

I just ran this code so I will drop and example below:

The imports you will need:

from qiime2 import Artifact, Metadata
import pandas as pd

Importing a dataframe as an artifact:

feature_table = Artifact.import_data(type = "FeatureTable[Frequency]", view =feature_table)

Saving the artifact to your file system so you can use it in qiime

engraftment_feature_table = Artifact.import_data(type = "FeatureTable[Frequency]", view =feature_table)

Hope that helps!

1 Like

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