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)
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,2),"%")) + ylab(paste(round(100*ord$data$ProportionExplained,2),"%")) +
Thanks Mehrbod. A quick breakdown of these dense lines:
ord$data: Would be the imported artifact from
$ProportionExplained: is a vector of the proportion of variation explained
 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
ylab() are the ggplot functions to create the x and y label respectively.
Thank you everyone for help
Thanks jbisanz. Great job on this pretty package.
Hey, I hope it is okay if I am also posting a PCoA issue in here, as this thread was the closest one to my issue, still being open.
First of all thanks a lot for creating this great package @jbisanz
I used the PCoA from your tutorial as:
faithpd<-read_qza(“alpha_faithpd.qza”)$data %>% rownames_to_column(“SampleID”)
uwunifrac$data$Vectors %>% select(SampleID, PC1, PC2) %>% left_join(metadata) %>% left_join(faithpd) %>% ggplot(aes(x=PC1, y=PC2, color=`horizon`, shape=`layer`, size=faithpd)) + geom_point(alpha=0.5) + theme_q2r() + scale_shape_manual(values=c(16,1), name="Layer") + scale_size_continuous(name="Phylogenetic diversity") + scale_color_discrete(name="Horizon") ggsave("PCoA.pdf", height=4, width=5, device="pdf")
But get the error message:
Joining, by = “SampleID”
Joining, by = “SampleID”
Error: Aesthetics must be either length 1 or the same as the data (9): size
rlang::last_error() to see where the error occurred.
Aesthetics must be either length 1 or the same as the data (9): size
1. ±(function (x, …) …
5. -ggplot2:::by_layer(function(l, d) l$compute_aesthetics(d, plot))
6. -ggplot2:::f(l = layers[[i]], d = data[[i]])
7. -l$compute_aesthetics(d, plot)
8. -ggplot2:::f(…, self = self)
9. -ggplot2:::check_aesthetics(evaled, n)
Can you please help me understanding what I did not consider here? Thanks a lot
The tip off is
Error: Aesthetics must be either length 1 or the same as the data (9): size. This suggests something is funky with the
size=faithpd. If you look at the the faithpd table you imported I think you will find the column storing the value is called
faith_pd such that you need to set up the mapping as
ggplot(aes(... size=faith_pd)) +