搜到一篇手动填写坐标的帖子当时就要哭了,然后想了一个办法,我可真是太机智了
代码如下:
library(matrixStats)
data2 <- matrix(as.numeric(data),ncol = ncol(data),nrow = nrow(data))
FDR_text_table <- data.frame(gene=deg,
height=colMaxs(data2)+0.5,
annotations=signif(ttest_res1$fdr[1:20],3))
FDR_text_table1 <- data.frame(gene=deg,
height=colMaxs(data2)+0.3,
annotations=rep("_____",times=20))
library(ggplot2)
p <- ggplot(data1,aes(x=data1[,2],y=as.numeric(data1[,3]),fill=data1[,4])) +
geom_violin(position = position_dodge(width = 0.8),scale = 'area') +
geom_boxplot(position = position_dodge(width = 0.8),outlier.size = 0,width=0.1,show.legend = F) +
geom_text(inherit.aes = F,data = FDR_text_table,aes(x=gene,y=height,label=annotations),size=3,fontface='bold') +
geom_text(inherit.aes = F,data = FDR_text_table1,aes(x=gene,y=height,label=annotations),size=3) +
theme_bw() + theme(panel.grid = element_line(color = "white")) + ylab("log2(RPM)") + xlab("genes") + labs(fill = "mycn_status")
p
效果如下:
image.png
网友评论