Question by error in (Tutorial: Integrating QIIME2 and R for data visualization and analysis using qiime2R)

Hi all, I am working with my data following the tutorial I mentioned in the title, and when I try to do the PCoA as indicated in the tutorial I get the following error:

Error occurred in the 1st layer.
Caused by error in check_aesthetics():
! Aesthetics must be either length 1 or the same as the data (32)
:heavy_multiplication_x: Fix the following mappings: size

I am attaching my data just in case

and my code is the following

metadatartl2<-read_q2metadata("muestra-metadatos-rtl.tsv")
uwunifracrtl2<-read_qza("unweighted_unifrac_pcoa_results-rtl-2.qza")
shannonrtl2<-read_qza("shannon_vector-rtl2.qza")$data %>% rownames_to_column("SampleID")

uwunifracrtl2$data$Vectors %>%
select(SampleID, PC1, PC2) %>%
left_join(metadatartl2) %>%
left_join(shannonrtl2) %>%
ggplot(aes(x=PC1, y=PC2, color=depth, shape=year, size=shannonrtl2)) +
geom_point(alpha=0.5) +
theme_q2r() +
scale_shape_manual(values=c(16,1), name="Camp") +
scale_size_continuous(name="Shannon Diversity") +
scale_color_discrete(name="Depth")
ggsave("PCoA.pdf", height=4, width=5, device="pdf")

Has anyone else had this error? Any idea how I can fix it?
It would be a great help, THANKS!

sample-metadata-rtl.tsv (1.5 KB)
shannon_vector-rtl2.qza (63.5 KB)
unweighted_unifrac_pcoa_results-rtl-2.qza (81.1 KB)

I believe your issue is here: size=shannonrtl2. The size aesthetic needs to be mapped to a column in the table whereas it appears you indicated the entire table. In your case, I think it is shannon_entropy. Changing it to size=shannon_entropy should fix your problem.

thanks, I fixed that and now it appears:Error: Continuous value supplied to discrete scale :frowning:

It looks like depth is stored as a numeric variable but you are trying to use a discrete color scale (usually things like group A, group B, etc). You can either convert depth to be a factor before starting the plot ... %>% mutate(Depth=as.factor(Depth)) %>% ggplot(...) or use a continuous color scale.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.