# Sort samples by metadata category

**URL:** <https://forum.qiime2.org/t/sort-samples-by-metadata-category/3269>\
**Category:** User Support\
**Tags:** taxa, barplot\
**Created:** [March 1, 2018, 5:33pm UTC](https://forum.qiime2.org/t/sort-samples-by-metadata-category/3269 "2018-03-01T17:33:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerdynella](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nerdynella/32/21728_2.png) [@nerdynella](https://forum.qiime2.org/u/nerdynella)\
**Post date:** [March 1, 2018, 5:33pm UTC](https://forum.qiime2.org/t/sort-samples-by-metadata-category/3269/1 "2018-03-01T17:33:47Z")

</div>

Hi @jairideout any updates on this yet? Continuing the discussion from [Is there any way to summarize taxa plot by category?](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446/2):

> [@Is there any way to summarize taxa plot by category?](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446/2):
>
> Hi @m-ocejo! We currently don’t have that functionality in QIIME 2’s taxa barplots. I created an issue to track the addition of that feature. Note that you can sort the samples by a metadata category, so that samples from the same category will be grouped together (but each bar will still represent a single sample).

Also, how do I achieve this?

> [@Is there any way to summarize taxa plot by category?](https://forum.qiime2.org/t/is-there-any-way-to-summarize-taxa-plot-by-category/446/2):
>
> sort the samples by a metadata category, so that samples from the same category will be grouped together (but each bar will still represent a single sample)

Many thanks,  
Nsa

---

<div class="post-metadata">

**Author:** ![thermokarst](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/t/8e7dd6/32.png) [@thermokarst](https://forum.qiime2.org/u/thermokarst)\
**Post date:** [March 2, 2018, 5:53pm UTC](https://forum.qiime2.org/t/sort-samples-by-metadata-category/3269/3 "2018-03-02T17:53:22Z")

</div>

Hi @nerdynella!

> [@nerdynella](#):
>
> Hi @jairideout any updates on this yet?

Unfortunately, no. We haven't had a chance to work on this, and we don't have a good ETA at present.

> [@nerdynella](#):
>
> Also, how do I achieve this?

The sort is controlled by the widgets off to the right side of the visualization, under the label "Sort Samples By".

Using the [Moving Pictures barplots](https://view.qiime2.org/visualization/?type=html&src=https%3A%2F%2Fdocs.qiime2.org%2F2018.2%2Fdata%2Ftutorials%2Fmoving-pictures%2Ftaxa-bar-plots.qzv) as an example:

 ![24%20AM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/9/9559cd327b28d1274ec88d997a93f5dd6d4e3c76.png)  
Here we are sorting by `k __Bacteria;p__ Firmicutes`

 ![41%20AM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/f/f1fb1dabb70657028b0814ccca3e0bc929e803e5.png)  
Here we are sorting by `BodySite`. Also note the x-axis labels reflect the body site. This is what @jairideout was referring to.

 ![55%20AM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/1/1abb066632a2cfbbca4da94db2110ed0a8071da9.png)  
You can chain multiple sort parameters by clicking the blue plus icon. Here we are sorting by `BodySite`, and then by `Subject`.

Hope that helps! 🦖

---

<div class="post-metadata">

**Author:** ![nerdynella](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nerdynella/32/21728_2.png) [@nerdynella](https://forum.qiime2.org/u/nerdynella)\
**Post date:** [March 2, 2018, 8:38pm UTC](https://forum.qiime2.org/t/sort-samples-by-metadata-category/3269/5 "2018-03-02T20:38:46Z")

</div>

@thermokarst this definitely helps! I missed the sort sample tab earlier (for some reason i wrongly assumed that it could only sort by taxonomic level prolly because of the k\_bacteria).  
Thank you!  
Nsa

---

<div class="post-metadata">

**Author:** ![system](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/3X/2/1/21af5fe23cb6f4579467c66a9ed94e55274ca7bd.svg) [@system](https://forum.qiime2.org/u/system)\
**Post date:** [April 3, 2018, 2:39am UTC](https://forum.qiime2.org/t/sort-samples-by-metadata-category/3269/6 "2018-04-03T02:39:01Z")

</div>

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