Error while using metadata-based filtering

Hey there @MartinLubell!

Hopefully we can help you out!

Hidden away at the end of this section of the Filtering data tutorial is this little hint:

If your filtering query is more complex than those supported through qiime taxa filter-table, you should use qiime feature-table filter-features.

Sounds like you are a perfect candidate for this, since your query is becoming a bit complex now, and feature-table filter-features supports SQL-based queries, which are super powerful!

So, let's rewrite you command to work with this:

qiime feature-table filter-features \
  --i-table table.qza \
  --m-metadata-file taxonomy.qza \
  --p-where "Taxon='k__Bacteria' OR Taxon LIKE 'k__Bacteria; p__Planctomycetes; c__Planctomycetia; o__Pirellulales; f__Pirellulaceae%'" \
  --o-filtered-table filtered-table.qza

(double-check my spelling in that long taxon string - I am sure I typoed somewhere...)

What this SQL clause is saying is: I want all the features that have the exact (=) taxon string of k__Bacteria. I also want (OR), all the features that start with (LIKE; % at the end of the query string which is a wildcard match) k__Bacteria; p__Planctomycetes; c__Planctomycetia; o__Pirellulales; f__Pirellulaceae.

Hope that helps! Let us know how it goes! :t_rex:

2 Likes