Continuing the discussion from PCoA plots with confidence ellipsoids:
Hello, I've tried to use stat_ellipse () in my R graphs, integrating from QIIME2
(Tutorial: Integrating QIIME2 and R for data visualization and analysis using qiime2R - #21)
Here is my code:
IJ$data$Vectors %>%
dplyr::select(SampleID, PC1, PC2) %>%
left_join(imetadata) %>%
left_join(ishannon) %>%
ggplot(aes(x=PC1, y=PC2, color=Group, shape=Vagotomy, size = shannon_entropy)) +
scale_color_manual(values=c("black","grey50", "steelblue1", "navy")) +
geom_point(alpha=0.85) + alpha controls transparency and helps when points are overlapping
theme_bw() +
scale_size_continuous(name="Shannon") +
stat_ellipse()
ggtitle("Ileum_Jaccard")
I get the following warning...
"The following aesthetics were dropped during statistical transformation: size
This can happen when ggplot fails to infer the correct grouping structure in the data. Did you forget to specify a group
aesthetic or to convert a numerical variable into a factor?"
my size = shannon diversity, which I have when I get from reading in my .qza file of my qiime2 output shannon_vector.qza.
Without stat_ellipse, I get a beautiful graph and the size of all my objects is based on shannon diversity. When I add "stat_ellipse" suddenly black bars appear over my shannon figure legend. This also occurred in an earlier topic, but was not addressed. I've tried size = as.numeric or size = as.factor in the aes code, neither works. Any assistance would be appreciated!
1st screenshot = graph with stat_ellipse() code. The 2nd screenshot is the result when I remove the line stat_ellipse from my R code