# Abundances of taxa by group

**URL:** https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208
**Category:** User Support
**Tags:** heatmap
**Created:** [September 27, 2018, 1:11pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208 "2018-09-27T13:11:26Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![alfanon](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alfanon](https://forum.qiime2.org/u/alfanon)
#### Post date: [September 27, 2018, 1:11pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/1 "2018-09-27T13:11:27Z")

</div>

Dear all,

I am trying to create a table with the abundances (or relative abundances) of taxa at different taxonomic levels (phylum, family, genus) from my feature table, where the abundances are given not by sample, rather by a category from my metadata file, for example by Sample type. Is this possible or do I need to do it manually summing up the abundances of each sample for that category?  
I know that I can use qiime taxa collapse first to collapse at the level I want, but then I don't know what to do.

A question related to this one is: do you advise to present in a publication the taxonomic barplots and the type of tables I would like to generate which are built from the rarefied feature table or from the complete table?

Thanks a lot in advance

Best wishes

Niccolò

---

<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: [September 27, 2018, 1:59pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/2 "2018-09-27T13:59:11Z")

</div>



---

<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: [September 27, 2018, 10:57pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/3 "2018-09-27T22:57:30Z")

</div>

Hey there @alfanon!

> [@alfanon](#):
>
> rather by a category from my metadata file

You're in luck! Check out [`feature-table group`](https://docs.qiime2.org/2018.8/plugins/available/feature-table/group/) for a way to regroup your feature table based on sample or feature metadata.:qiime2: 🦖

---

<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: [September 27, 2018, 10:57pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/4 "2018-09-27T22:57:32Z")

</div>



---

<div class="post-metadata">

### Author: ![alfanon](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alfanon](https://forum.qiime2.org/u/alfanon)
#### Post date: [September 28, 2018, 8:27am UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/5 "2018-09-28T08:27:20Z")

</div>

Hi @thermokarst,  
thank you for your answer. Great! it worked with that command.  
So I first collapse my table at the taxonomic level I am interested, then use "feature-table group" (options: --p-axis sample --m-metadata-file metadata.tsv --m-metadata-column Sampletype --p-mode sum) and then I am able to export the table I wanted.  
Now, I tried to create an abundance heatmap from that grouped table in order to have the sample type instead of the samples on one axis. I used the following command:  
qiime feature-table heatmap  
--i-table table\_collapsed\_bysampletype.qza  
--m-metadata-file metadata.tsv  
--m-metadata-column Sampletype --p-normalize --p-metric braycurtis  
--p-cluster features --o-visualization table\_collapsed\_bysampletype\_heatmap.qzv  
It gives me an error saying that "The following IDs are not present in the metadata:" listing the sample types of my metadata. What am I doing wrong?

Thank you very much  
Best wishes

Niccolò

---

<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: [September 28, 2018, 12:14pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/6 "2018-09-28T12:14:00Z")

</div>



---

<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: [September 28, 2018, 10:48pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/7 "2018-09-28T22:48:21Z")

</div>

Hello @alfanon!

> [@alfanon](#):
>
> What am I doing wrong?

Well, since you have grouped on new values - you have all new Sample IDs, right?

Run `feature-table summarize` on the new table (`table_collapsed_bysampletype.qza`) to see what I mean! 🔍

---

<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: [September 28, 2018, 10:48pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/8 "2018-09-28T22:48:23Z")

</div>



---

<div class="post-metadata">

### Author: ![alfanon](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alfanon](https://forum.qiime2.org/u/alfanon)
#### Post date: [October 1, 2018, 3:22pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/9 "2018-10-01T15:22:25Z")

</div>

Thank you @thermokarst! I think I have got it. I simply solved it by using the command qiime feature-table heatmap without the –m-metadata-file and –m-metadata-column options.  
Sorry to bother you with another question about this topic. I tried to generate a heatmap based on relative frequencies (so I collapsed the table at the level I wanted, then converted to relative frequencies and then used qiime feature-table heatmap). I get the following error:  
"Argument to parameter 'table' is not a subtype of FeatureTable[Frequency]"  
Is it possible to do what I am trying or the heatmap command already automatically convert itself into relative frequencies?

Thank you  
Best  
Niccolo

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [October 1, 2018, 3:47pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/10 "2018-10-01T15:47:21Z")

</div>



---

<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: [October 2, 2018, 3:51am UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/11 "2018-10-02T03:51:51Z")

</div>

> [@alfanon](#):
>
> I simply solved it by using the command qiime feature-table heatmap without the –m-metadata-file and –m-metadata-column options.

Perfecto!

> [@alfanon](#):
>
> Sorry to bother you with another question about this topic.

Oh c'mon, no need to apologize - that is what we are here for! ❤ 😃

> [@alfanon](#):
>
> Is it possible to do what I am trying or the heatmap command already automatically convert itself into relative frequencies?

This viz is designed to accept a `FeatureTable[Frequency]` Artifact, not `FeatureTable[RelativeFrequency]`. That is because the action provides its own normalization via the `--p-normalize / --p-no-normalize` parameters:

```bash
  --p-normalize / --p-no-normalize
                                  Normalize the feature table by adding a
                                  psuedocount of 1 and then taking the log10
                                  of the table. [default: True]

```

So if I am understanding you correctly, skip the conversion to `FeatureTable[RelativeFrequency]` after you collapse the table and just go straight to the `heatmap`.

:qiime2: 🦖

---

<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: [October 2, 2018, 3:51am UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/12 "2018-10-02T03:51:53Z")

</div>



---

<div class="post-metadata">

### Author: ![alfanon](https://forum.qiime2.org/letter_avatar_proxy/v4/letter/a/db5fbb/32.png) [@alfanon](https://forum.qiime2.org/u/alfanon)
#### Post date: [October 3, 2018, 6:53am UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/13 "2018-10-03T06:53:58Z")

</div>

Nice from you!  
All clear now, thanks a lot 🙂

---

<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: [November 3, 2018, 12:54pm UTC](https://forum.qiime2.org/t/abundances-of-taxa-by-group/6208/14 "2018-11-03T12:54:02Z")

</div>

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