qiime2r: % explained variance in PCoA plot

Thank you very much for the tutorial,i just recently discovered it and its awesome. I am relatively new to Qiime 2R and i may have a basic clarification.Is it possible to get the percentage of explained variance on the x and y axis in the unweighted unifrac (or any other ordination plots) in qiime 2R?

I don’t know about Qiime2R, but you always can unzip a pcoa.qza file, parse “/data/ordination.txt” file and find there proportions for each ax in order (you should multiply it by 100)

Hi @evon,
Welcome to the forum!

Here is an example of this using Qiime2r to import an ordination artifact from Qiime2.
In short you’ll just need to use the xlab and ylab

  xlab(paste(round(100*ord$data$ProportionExplained[1],2),"%")) +
  ylab(paste(round(100*ord$data$ProportionExplained[2],2),"%")) + 

Thanks Mehrbod. A quick breakdown of these dense lines:
-ord$data: Would be the imported artifact from read_qza()
-$ProportionExplained: is a vector of the proportion of variation explained
-[1] or [2] is denoting which axis you want the variation from, this would assume axis 1 is on the x axis and 2 is on the y.
-100* is multiplying by 100 to get a percent
-round(., 2) is saying to round to 2 decimal places
-paste(., “%”) is saying to combine the number rounded to 2 decimals with a percent sign in the axis label
-xlab() and ylab() are the ggplot functions to create the x and y label respectively.

1 Like

Thank you everyone for help :slightly_smiling_face: