# Alpha diversity for each phylum

**URL:** <https://forum.qiime2.org/t/alpha-diversity-for-each-phylum/30843>\
**Category:** General Discussion\
**Tags:** diversity\
**Created:** [July 16, 2024, 5:01pm UTC](https://forum.qiime2.org/t/alpha-diversity-for-each-phylum/30843 "2024-07-16T17:01:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![turtle](https://forum.qiime2.org/user_avatar/forum.qiime2.org/turtle/32/14698_2.png) [@turtle](https://forum.qiime2.org/u/turtle)\
**Post date:** [July 16, 2024, 5:01pm UTC](https://forum.qiime2.org/t/alpha-diversity-for-each-phylum/30843/1 "2024-07-16T17:01:04Z")

</div>

Is there any way in qiime2 to measure each phylum's contribution to the alpha diversity, separately? I mean, if I want to see the contribution of different phylum in the alpha diversity between two group of my data does qiime2 has any way for it? If not, is there any way to do it?

Know that I have phyloseq object imported in the RStudio and already created "Shannon", and "Observed" diversity. But now want to know which phylum is effecting more in the diversity and which is less.

---

<div class="post-metadata">

**Author:** ![Mike\_Stevenson](https://forum.qiime2.org/user_avatar/forum.qiime2.org/mike_stevenson/32/18913_2.png) [@Mike\_Stevenson](https://forum.qiime2.org/u/Mike_Stevenson)\
**Post date:** [July 28, 2024, 12:38am UTC](https://forum.qiime2.org/t/alpha-diversity-for-each-phylum/30843/3 "2024-07-28T00:38:57Z")

</div>

Hi @turtle

I think using the function 'subset\_taxa' in the phyloseq package in R is the potential solution to your query.

You can use 'subset\_taxa' function to separate your data into individual phylum groups:

> **Phyloseq - Subset Taxa by Phylum**
>
> ```R
> library(phyloseq)
> library(tidyverse)
> 
> # Assume physeq is your phyloseq object
> 
> # Get a list of unique phyla
> phyla <- unique(tax_table(physeq)[, "Phylum"])
> 
> # Create a list to store subsetted phyloseq objects
> physeq_phyla <- list()
> 
> for (phylum in phyla) {
> physeq_phyla[[phylum]] <- subset_taxa(physeq, Phylum == phylum)
> }
> 
> ```

I think you might have to carry out the Shannon and Observed diversity for each of these subsets again, but then you should be able to analyse the contribution each phylum is making towards your alpha diversity!

Hope that helps!

---

<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:** [August 28, 2024, 6:39am UTC](https://forum.qiime2.org/t/alpha-diversity-for-each-phylum/30843/4 "2024-08-28T06:39:40Z")

</div>

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