PCoA plots with confidence ellipsoids

@John_Blazier,
Good question — skip to the bottom of my post to see the answer! QIIME 2 does not really have a way to make 2D plots with ellipsoids (yet).

I think the issue may be that beta-rarefaction is exporting the data in a goofy format — or qiime1 being goofy. Maybe Try exporting the PCoA coordinates output by core-metrics? If that does not work you may need to massage the data a little bit to make qiime1 happy (sorry can't help you there).

While the authors may have used QIIME 2 for generating the PCoA coordinates, that plot was not made using QIIME 2!

When I want a 2D plot with ellipsoids (which I often do), I do this in python or R, which is probably what the authors of that paper did. Let me give you some R code, since qiime2R makes it easy peasy to load QIIME 2 files in R. See this tutorial:

But you don't just want a PCoA, you want the ellipses — ggplot2 makes this so easy it is just silly! Just add stat_ellipse() to the end of the example shown in that tutorial, so your command should look like this:

pco$data$Vectors %>%
  rename("#SampleID"=SampleID) %>% #rename to match the metadata table
  left_join(metadata) %>%
  left_join(shannon$data %>% rownames_to_column("#SampleID")) %>%
  ggplot(aes(x=PC1, y=PC2, shape=Subject, color=BodySite, size=shannon)) +
  geom_point() +
  xlab(paste("PC1: ", round(100*pco$data$ProportionExplained[1]), "%")) +
  ylab(paste("PC2: ", round(100*pco$data$ProportionExplained[2]), "%")) +
  theme_bw() +
  ggtitle("Unweighted UniFrac")+
  stat_ellipse()

Please give that a spin and please share the output you see!

8 Likes