Im trying to plot my PCOA with qiime2R and ggplot2 since I find 2D UniFrac plots more informative than those given with Emperor in 3D. So I followed the qiime2R tutorial, but Im having trouble adding different aesthetics, I have seen other post but I don’t really understand the issue. Here’s my code
metadata<-read_q2metadata("Metadata.tsv") uwunifrac<-read_qza("weighted_unifrac_pcoa_results.qza") shannon<-read_qza("shannon_vector.qza")$data %>% rownames_to_column("SampleID") uwunifrac$data$Vectors %>% select(SampleID, PC1, PC2) %>% left_join(metadata) %>% left_join(shannon) %>% ggplot(aes(x=PC1, y=PC2, color=`Name`, shape=`Origen`, size=shannon)) + geom_point(alpha=0.5) +#alpha controls transparency and helps when points are overlapping theme_q2r() + scale_shape_manual(values=c(16,1), name="Name") + scale_size_continuous(name="Shannon Diversity") + scale_color_discrete(name="Name") ggsave("PCoA.pdf", height=4, width=5, device="pdf")
When I try to compile I get the following error message:
Error: Aesthetics must be either length 1 or the same as the data (9): size
But If I only include 1 aesthetic as told, for instance:
ggplot(aes(x=PC1, y=PC2, color=
It does compile. I was wondering If there’s a way of including all the aesthetic like I tried in the first place.