Is there a way to group a feature table by more than one metadata column?

Hi there!

I am trying to look at my feature table in a different way and I was wondering if it is possible to group a feature table by two metadata columns.

Here is a screenshot of my metadata file...

I want to compare each species to one another by their life stage (i.e., P. leucomystax adults to P. macrotis adults and P. leucomystax tadpoles to P. otilophus tadpoles...etc.). Ultimately I would like to first group or filter by the column Species and then subsequently group those by the column Description. Can I do this in a way that would end up with a feature table where the samples are (for example) P. leucomystax adults, P. macrotis adults, etc.?

Thanks!

Hi @Sarah_McGrath!

Yes, although not quite how you have proposed here. Read on...

Makes sense - thanks for the background!

I might be misunderstanding your proposal, but this wouldn't technically be possible - not just in QIIME 2, but in general. I say that because grouping (and the implied "collapsing" or "pooling") of samples first by species, will ruin you ability to disambiguate the Description - grouping is a lossy process, so you no longer are able to associate something like a previously valid metadata value, because now everything in that "group" is just a big old stew of values. :stew:

Fortunately, the way to go about accomplishing your end-goal is actually super easy - just define a new Metadata column, with the Species & Description merged!

Now, you can specify your new column (here I called it Species-Description) as the column to collapse by. My example above would collapse to the following:

35%20PM

Hope that helps, and keep us posted! :t_rex:

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