美文网首页基因组数据绘图ggplot2绘图
小提琴图添加已有显著性

小提琴图添加已有显著性

作者: 信你个鬼 | 来源:发表于2020-11-25 01:45 被阅读0次

    搜到一篇手动填写坐标的帖子当时就要哭了,然后想了一个办法,我可真是太机智了

    代码如下:

    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

    相关文章

      网友评论

        本文标题:小提琴图添加已有显著性

        本文链接:https://www.haomeiwen.com/subject/pprgiktx.html