The ggplot2 may or may not display a diagram.

Asked 2 years ago, Updated 2 years ago, 438 views

I am trying to draw using tidyverse and qiime2R in R.
If you enter data and run the script,
The first time it was drawn, but after saving the diagram, closing the diagram window (Quartz), and entering the same script again, Error in UseMethod ("depth"):
There is no method to apply 'depth' to an object in class 'NULL'

does not appear and is not drawn.

What's wrong with using the same data and the same script?
I would appreciate it if you could let me know.

metadata<-read_q2metadata("metadata.tsv")
pco<-read_qza("unweighted_unifrac_pcoa_results.qza")

pco$data$Vectors%>%
  select(SampleID, PC1, PC2)%>%
  left_join(metadata)%>%
  ggplot(aes(x=PC1,y=PC2,color=`Strain`,shape=`FeedSex`))+
  geom_point(alpha=.7, size=3)+
  them_bw()+
  xlab(paste("PC1:", round(100*pco$data$ProportionExplained[1], 2), "%")))+
  ylab(paste("PC2:", round(100*pco$data$ProportionExplained[2], 2), "%")))+
  scale_shape_manual(values=c(16,1,17,2,15,0), name="Feed-Sex")+
  scale_color_manual(values=c("red", "blue", "darkgreen"), name="Strain")+
  guides(shape=guide_legend(order=2), color=guide_legend(order=1))+
  ggtitle("Unweighted UniFrac")+
  theme(aspect.ratio=1,plot.title=element_text(size=20, face="bold"))

R for Mac:4.0.2
tidyverse —1.3.0
qiime2R: 0.99.20

reference:Plotting PCoA
https://forum.qiime2.org/t/tutorial-integrating-qiime2-and-r-for-data-visualization-and-analysis-using-qiime2r/4121

I have included as much information as I can write.
Please let me know if you don't have enough information.

I look forward to your kind cooperation.

r tidyverse ggplot2

2022-09-30 21:50

1 Answers

If you look at past examples, this error on a Mac could be a bug in ggplot2.According to Comment, it looks like a bug around the grid, and as of July 2020, it hasn't been fixed yet.

According to the first post, as a temporary measure, instead of drawing graphs with ggplot,

the_plot<-ggplot
the_plot

It may be avoided by drawing graphs as shown in .


2022-09-30 21:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.