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

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.

When looking online I found a link 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 (91.2 KB) shannon_vector.qzv (376.1 KB)

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

Thank you,
Govind

1 Like

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.

@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

You can use this tutorial in R to plot exported alpha diversity metrics

Here is another tutorial which is Qiime2-specific

2 Likes

Thank you @timanix. It was really helpful.

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

1 Like

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