# Making alpha diversity Boxplots in R using .qza files from Qiime2 core-metrics-results

**URL:** https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026
**Category:** Other Bioinformatics Tools
**Tags:** qiime2r, boxplots
**Created:** [October 11, 2021, 10:20pm UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026 "2021-10-11T22:20:43Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![govindsah](https://forum.qiime2.org/user_avatar/forum.qiime2.org/govindsah/32/20232_2.png) [@govindsah](https://forum.qiime2.org/u/govindsah)
#### Post date: [October 11, 2021, 10:20pm UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/1 "2021-10-11T22:20:43Z")

</div>

Dear Qiime2 experts,  
I have completed alpha and beta diversity analysis using qiime2 and now trying to import following files `faith_pd_vector.qza, shannon_vector.qza and observed_features_vector.qza` from `core-metrics-results` folder into R to make box plots as shown below.

 ![Screen Shot 2021-10-11 at 2.14.32 PM](https://forum-qiime2-org.s3.dualstack.us-west-2.amazonaws.com/original/2X/3/3d11c950c911dbf083f306196233d6f65bdd8bbe.png)

When looking online I found a [link](https://www.bioconductor.org/packages/devel/bioc/vignettes/phyloseq/inst/doc/phyloseq-analysis.html?utm_content=bufferc7d22&utm_medium=social&utm_source=twitter.com&utm_campaign=buffer) where `phyloseq` has been used to make some plots in R, however they haven't shown the original file that has been imported.  
I'm not sure if it is even possible to import these files into R or do I need to import `feature table` and do `alpha-diversity analysis` in R to make such plots.

For reference I have attached following .qza and .qzv files for shannon diversity:  
[shannon\_vector.qza](https://forum.qiime2.org/uploads/short-url/yAZkkbegUmWAHMZMbD3qMBN983O.qza) (91.2 KB) [shannon\_vector.qzv](https://forum.qiime2.org/uploads/short-url/lCaMnXxJcnODAQBMqCx22jZ8AE4.qzv) (376.1 KB)

Can someone please help me import my files into R and make box-plots?

Thank you,  
Govind

---

<div class="post-metadata">

### Author: ![timanix](https://forum.qiime2.org/user_avatar/forum.qiime2.org/timanix/32/17879_2.png) [@timanix](https://forum.qiime2.org/u/timanix)
#### Post date: [October 12, 2021, 7:41am UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/2 "2021-10-12T07:41:57Z")

</div>

Hello!  
Short answer is yes, you can export alpha diversity metrics.

Option 1.  
`qiime tools export alpha-diversity_vector.qza --output-dir alpha-diversity`  
Option 2. Just unzip your vector qza in terminal or R, navigate to Data subdirectory to find desired file.

Just read resulted file as a tsv table in R.

---

<div class="post-metadata">

### Author: ![govindsah](https://forum.qiime2.org/user_avatar/forum.qiime2.org/govindsah/32/20232_2.png) [@govindsah](https://forum.qiime2.org/u/govindsah)
#### Post date: [October 12, 2021, 7:53pm UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/3 "2021-10-12T19:53:38Z")

</div>

@timanix thank you for answering my question. However, I need script for making such figures in R.  
Can you please be more specific or send me the script as I'm not an expert in R.  
Thank you,  
Govind

---

<div class="post-metadata">

### Author: ![timanix](https://forum.qiime2.org/user_avatar/forum.qiime2.org/timanix/32/17879_2.png) [@timanix](https://forum.qiime2.org/u/timanix)
#### Post date: [October 13, 2021, 7:14am UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/5 "2021-10-13T07:14:07Z")

</div>

You can use this [tutorial in R](https://www.guru99.com/r-boxplot-tutorial.html) to plot exported alpha diversity metrics

Here is [another tutorial](https://github.com/jbisanz/qiime2R) which is Qiime2-specific

---

<div class="post-metadata">

### Author: ![govindsah](https://forum.qiime2.org/user_avatar/forum.qiime2.org/govindsah/32/20232_2.png) [@govindsah](https://forum.qiime2.org/u/govindsah)
#### Post date: [October 16, 2021, 5:41am UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/6 "2021-10-16T05:41:15Z")

</div>

Thank you @timanix. It was really helpful.

---

<div class="post-metadata">

### Author: ![koala\_guy](https://forum.qiime2.org/user_avatar/forum.qiime2.org/koala_guy/32/12307_2.png) [@koala\_guy](https://forum.qiime2.org/u/koala_guy)
#### Post date: [November 19, 2021, 8:01am UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/7 "2021-11-19T08:01:53Z")

</div>

Hi there,

I know this is a bit late, but I have been using Qiime2R to convert my .qza artifacts into an R-readable format and using phyloseq to do the rest. Using just Q2R you can import various alpha metric files into R and use ggplot to make some graphs.

An example of reading a shannon.qza:  
`shannon<-read_qza("shannon_vector.qza")$data %>% rownames_to_column("SampleID")`

Alternatively you could just move the tree, tax, table, seqs etc. into R using the q2r `qza_to_phyloseq()` command, then use either Phyloseq or Microbiome packages to process/plot your data. You _can_ rarefy your data if you like prior to plotting alpha diversity and make some beautiful figures with minimal effort. You can also generate files containing all your alpha metrics in one place, which I found to be very handy.

If you are still having issues let me know and I can dig up some scripts for you!

Toby

---

<div class="post-metadata">

### Author: ![govindsah](https://forum.qiime2.org/user_avatar/forum.qiime2.org/govindsah/32/20232_2.png) [@govindsah](https://forum.qiime2.org/u/govindsah)
#### Post date: [November 19, 2021, 8:05pm UTC](https://forum.qiime2.org/t/making-alpha-diversity-boxplots-in-r-using-qza-files-from-qiime2-core-metrics-results/21026/8 "2021-11-19T20:05:10Z")

</div>

Hi @koala_guy  
Your suggestions are helpful and I was able to import .qza files and make figures in R.  
Thank you so much.  
Govind
