美文网首页
Volcano plot

Volcano plot

作者: 苏慕晨枫 | 来源:发表于2018-07-26 10:22 被阅读112次

    火山图

    library(ggplot2)




    4. 画图

    r03 = ggplot(data,aes(log2FC,-1*log10(FDR)))   (先是纵坐标)

     

    r03 + geom_point()

                                                    
    R软件-ggplot2 <wbr>画火山图

    4.1 改变点的颜色

    r03 + geom_point(color ="red")

    r03 +geom_point(aes(color ="red"))

    r03 + geom_point(aes(color =significant))

                                                  
    R软件-ggplot2 <wbr>画火山图R软件-ggplot2 <wbr>画火山图

    4.2 设置坐标轴范围和标题 # xlim(),ylim()函数,labs(title=“..”,x=“..”,y=“..”)函数

    r03xy = r03 +geom_point(aes(color =significant)) + xlim(-4,4) + ylim(0,30)

    r03xy + labs(title="Volcanoplot",x="log2(FC)")

    r03xy + labs(title="Volcanoplot",x=expression_r(log[2](FC)), y=expression_r(-log[10](FDR)))

    R软件-ggplot2 <wbr>画火山图

    4.3 自定义颜色

    r03xyp = r03xy + labs(title="Volcanoplot",x=expression_r(log[2](FC)), y=expression_r(-log[10](FDR)))

    r03xyp + scale_color_manual(values =c("green","black", "red"))

    volcano = r03xyp +scale_color_manual(values = c("#00ba38","#619cff","#f8766d"))

     
    R软件-ggplot2 <wbr>画火山图

    4.4 添加阈值线

    volcano+geom_hline(yintercept=1.3)+geom_vline(xintercept=c(-1,1))

    volcano+geom_hline(yintercept=1.3,linetype=4)+geom_vline(xintercept=c(-1,1),linetype=4)

    R软件-ggplot2 <wbr>画火山图
    5.保存图片

    ggsave("volcano.png")

     

    ggsave("volcano8.png",volcano,width=8,height=8)

    相关文章

      网友评论

          本文标题:Volcano plot

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