number of taxa (class, phylum, species,...)

Hi,

Anyone knows if there is a way to count how many (phylum, classes, genera, species,…) were assigned? Or i have to do that manually?

Hi Mary,

I'm not aware of direct commands to implement it in QIIME2 but you can export results and make a phyloseq object in R. Then you can use the following codes kindly shared by Mike Mclaren to do the calculation at the reads and ASV level.

Yanxian

Hi @yanxianl,

Thank you for your reply. But i would like to know how many classes, species and so on, exist in my taxonomy and not the number of reads. Is it possible to do that with qiime?

Do you want to know how many taxa were detected in each sample?

If yes, just use qiime taxa collapse, then run qiime diversity alpha --p-metric observed_otus and the counts will be taxa counts at whatever level you collapsed to.

so how many total unique taxa were observed in total across all samples? That you could obtain by looking at the taxonomy file and parsing in R with the second section of the code snippet that @yanxianl shared.

Hi, @Nicholas_Bokulich

I want to know for example: my sample has 20 classes, 90 genus and 160 species. These are the numbers that i want to know

Hi Mary,

Following the methods suggested by Nicholas, you should get what you need.

If you want to know the number of taxa detected in each sample, below is an example at the genus level using feature table and taxonomy file from the "Moving Pictures" tutorial.

# Collapse feature table at genus level
qiime taxa collapse \
  --i-table table.qza \
  --i-taxonomy taxonomy.qza \
  --p-level 6 \
  --o-collapsed-table table-l6.qza

# Compute observed_otus
qiime diversity alpha \
  --i-table table-l6.qza \
  --p-metric 'observed_otus' \
  --o-alpha-diversity observed_features_l6.qza

# Visualize results
qiime metadata tabulate \
  --m-input-file observed_features_l6.qza \
  --o-visualization observed_features_l6.qzv

observed_features_l6.qzv (1.2 MB)

If you want to know the total number of taxa at different taxonomic levels, then you can export the QIIME2 artifacts and compute them in R. Below is an example based on the "GlobalPatterns" data set from the phyloseq package.

library(tidyverse)   
library(phyloseq) 

# load data
data("GlobalPatterns")
ps <- GlobalPatterns

# Compute number of taxa at different taxonomic level
tax_table(ps) %>%
   as("matrix") %>%
   as_tibble(rownames = "OTU") %>%
   gather("Rank", "Name", rank_names(ps)) %>%
   na.omit() %>% # remove rows with NA value
   group_by(Rank) %>%
   summarize(ntaxa = length(unique(Name))) %>% # compute number of unique taxa
   mutate(Rank = factor(Rank, rank_names(ps))) %>%
   arrange(Rank) 
# A tibble: 7 x 2
  Rank    ntaxa
  <fct>   <int>
1 Kingdom     2
2 Phylum     66
3 Class     139
4 Order     204
5 Family    334
6 Genus     983
7 Species   944
6 Likes

which QIIME2 artifact should i download?

A post was split to a new topic: Identification of Most Abundant Organisms

If you mean the feature table and taxonomy file used in the example, you can find them in the QIIME2 tutorial “Moving Pictures”.

For your own data set, use the feature table (e.g., table.qza) and taxonomy (e.g., taxonomy.qza) you got from your analysis.

If you want to do it in R, follow the qiime2R tutorial on how to import QIIME2 artifacts into R. Then, you can use the R codes in the previous thread to get the number of taxa at different taxonomic level.

1 Like

2 posts were split to a new topic: counting unique species in R

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