美文网首页R生信生物信息学与算法Bioconductor for R
多组KEGG富集分析结果怎么展示?

多组KEGG富集分析结果怎么展示?

作者: PriscillaBai | 来源:发表于2019-04-10 16:55 被阅读45次

    先上图


    在做完WGCNA之后,我锁定了两个模块,但是怎么展示这两组的KEGG结果又不会凌乱呢?我最后想到了如上图。

    1. 做KEGG富集分析
    library(clusterProfiler)
    id<-bitr(colnames(turquoise.expr),fromType = "SYMBOL",toType = "ENTREZID",OrgDb = "org.Hs.eg.db")
    tur<-enrichKEGG(id[,2])
    

    其中colnames(turquoise.expr)是基因名

    1. 将得到的tur整理成数据框形式
    tur<-tur@result[which(tur@result$p.adjust<0.05),]
    tur$ratio<-round(tur$Count/6180,3)
    
    1. 画图
    a<-ggplot(tur)+geom_bar(aes(y=ratio,x=Description,fill=p.adjust),stat = "identity")+
      coord_flip()+scale_fill_gradientn(colours=c("red","yellow"))+
      theme(legend.position=c(1,0.3),legend.justification=c(1,1))+
      scale_x_discrete(position = "left")+annotate("text",y=0.05,x=34,label="turquoise",size=5)+
      theme(axis.title.y = element_blank())
    
    1. b图却有了难点,想要图形水平翻转(即镜像形式),才能得到上上图的背靠背效果。但是水平翻转的函数我查了很久都没查到,最后抖了个机灵,将横坐标改成了负值。


    2. 合并,成图

    plot_grid(b,a,labels = "")
    

    问:B图横坐标的负值咋办?
    答:我懒得改了,你直接P吧~

    总结:
    老规矩,为了你的查阅方便,我把ggplot分图层总结了一下,不用谢我是雷锋

    柱形图
    geom_bar(aes(y=ratio,x=Description,fill=p.adjust),stat = "identity")
    X轴与Y轴的旋转
    coord_flip()
    连续类颜色的填充
    scale_fill_gradientn(colours=c("red","yellow"))
    调节图例位置
    theme(legend.position=c(1,0.3),legend.justification=c(1,1))
    调节Y坐标的位置
    scale_x_discrete(position = "left")
    左上角加文字
    annotate("text",y=0.05,x=34,label="turquoise",size=5)
    去掉Y轴标题
    theme(axis.title.y = element_blank())
    合并两个图
    plot_grid(b,a,labels = "")

    好累,今天一口气更了3篇,现在字都不会打了,快帮我点赞吧~

    相关文章

      网友评论

        本文标题:多组KEGG富集分析结果怎么展示?

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