Filtering feature table based on metadata value


I’m just wondering if there is a way to filter the feature table based on numeric metadata with the “where” syntax, for example, if I only want to keep sample taken before day 100 of the experiment period? I’m aware of only one way to do this filtering which is to create a list of samples to keep or a list of samples to discard, but what if there are many samples and the list is very long?

Would be grateful if you could point me to some tips!

Hey there @AllieNguyen!

This guide covers metadata-based filtering in general:

How about something like this (I am assuming day is the name of your metadata column, so update as necessary):

--p-where "CAST(day AS INTEGER) < 100" 
1 Like

Thanks @thermokarst! It worked perfectly and created the same the filtered table with the one I did by id-based filtering. I’m just thinking that it would be a good idea to include this in the tutorial on filtering because all the example there gave me an impression that the “where” syntax can only be applied to categorical data using “=” or NOT “=”. Would the syntax work with “>” or “< =” and “> =” as well?

1 Like

I think so!

Thanks for the feedback @AllieNguyen! I challenge you to submit that change to the docs repository - or start here with a Community Tutorial! QIIME 2 is a community driven effort, and its growth and progress relies on these kinds of contributions! If that is something you are interested in working on, we would love to help out with that!

Thanks! :qiime2: :t_rex:

1 Like

Hi @thermokarst,

I’d like to submit the change to the docs repository, could you kindly show me the way to do that please?

1 Like

@AllieNguyen, great question, I’m wondering too! Maybe here ?

@ariel — that's a great place to post suggestions for features that you would like to see added to :qiime2:.

Allie wants to actually contribute to the documentation, though:

Here is the filtering tutorial source doc in the docs repository — you need to be familiar with github to submit a pull request to get your changes added to the docs.

@thermokarst also posted the link to the forum's "Community Tutorials" section, which is a great place for users to write tutorials.

In this case, I think adding to the source docs would be the best place, ultimately, for your changes @AllieNguyen — and you and I have chatted on another thread about making changes to the docs, so it would be great to have your input!

However, if you are not familiar with working with github and don't want to learn right now, feel free to make a community tutorial and we can eventually work those changes into the core docs.


1 Like

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