Filtering samples by metadata for AGP returns blank table

I’m trying to filter AGP metadata that I’ve pulled down from redbiom. I first filter the table features for minimum frequency of 10. I then tried to filter the samples where mental_illness=‘FALSE’ and I get an empty table in return. I’ve checked that there are samples with mental_illness as FALSE, I’ve checked that the sample names match for the feature table and the metadata. I’m at a loss as to what else the issue could be. I’m using qiime2-2019.7

Here’s the command I ran:
qiime feature-table filter-samples
–i-table agp_10_table.qza
–m-metadata-file 2019-08-22_agp_metadata.txt
–p-where “[mental_illness]=‘FALSE’”
–o-filtered-table agp_10_table_filt_test.qza

Because it’s AGP and the files are big, here’s a link to the files I used:
https://drive.google.com/drive/folders/1SUSzu-epJ5dUiXeMPKP8HSAbUMAMUPHq?usp=sharing

Let me know if there are any other commands or information you need to figure out where I went wrong. Thank you!

1 Like

Hey there @sthansen!

Looks like none of the samples actually have a mental_illness value of FALSE:

# grab the mental_health column       | trim header  | sort | get unique vals
cut -f578 2019-08-22_agp_metadata.txt | sed -n '1!p' | sort | uniq

false
No
not applicable
Not provided
true
Yes

So, the simplest solution is to change FALSE to false in your query:

 qiime feature-table filter-samples \                      
  --i-table agp_10_table.qza \
  --m-metadata-file 2019-08-22_agp_metadata.txt \
  --p-where "[mental_illness]='false'" \
  --o-filtered-table agp_10_table_filt_test.qza

But, it looks like the metadata values are a little messy, you might want to consider false & No as the same result:

 qiime feature-table filter-samples \                      
  --i-table agp_10_table.qza \
  --m-metadata-file 2019-08-22_agp_metadata.txt \
  --p-where "[mental_illness] IN ('false', 'No')" \
  --o-filtered-table agp_10_table_filt_test.qza

You can also “cast” the data to bool:

 qiime feature-table filter-samples \                      
  --i-table agp_10_table.qza \
  --m-metadata-file 2019-08-22_agp_metadata.txt \
  --p-where "CAST([mental_illness] AS BOOL)=FALSE" \
  --o-filtered-table agp_10_table_filt_test.qza

Hope that helps! :t_rex:

2 Likes

Thank you! This definitely fixed it. I believe this is due to the way the metadata was pulled down from redbiom, but I had been trying to find this error for way too long.

3 Likes

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