美文网首页手机好文RR语言做生信
R语言泡泡图— —小泡泡如何变大泡泡?

R语言泡泡图— —小泡泡如何变大泡泡?

作者: 赵玉鑫0507 | 来源:发表于2019-04-18 15:50 被阅读98次

    我们使用R绘制泡泡图时,可能会遇到这样一种情况,即count点太小 ,但又不知道应该如何调大,如下图:

    图1 泡泡图

    附代码:

    library(ggplot2)

    pathway = read.csv("1KEGG.csv",header=TRUE,row.names=1,check.names = FALSE)

    p = ggplot(pathway,aes(Pvalue,pathway))

    p=p + geom_point()

    p=p + geom_point(aes(size=Count))

    pbubble = p+ geom_point(aes(size=Count,color=-1*log10(Pvalue)))

    pr = pbubble+scale_color_gradient(low="blue",high = "red")

    pr = pr+labs(color=expression(-log[10](Pvalue)),size="Count", 

                x="-Log10(Pvalue)",y="KEGG pathway",title="KEGG Pathway")

    pr + theme_bw()

    pr


    经学习(向大神请教)后,修改了一下range的大小【+scale_size_continuous(range = c(4.5,7.5))】,如下图:

    图2 修改后的泡泡图

    附代码:

    library(ggplot2)

    pathway = read.csv("1KEGG.csv",header=TRUE,row.names=1,check.names = FALSE)

    p = ggplot(pathway,aes(Pvalue,pathway))

    p=p + geom_point()

    p=p + geom_point(aes(size=Count))+scale_size_continuous(range = c(4.5,7.5))

    pbubble = p+ geom_point(aes(size=Count,color=-1*log10(Pvalue)))+scale_size_continuous(range = c(4.5,7.5))

    pr = pbubble+scale_color_gradient(low="blue",high = "red")

    pr = pr+labs(color=expression(-log[10](Pvalue)),size="Count", 

                x="-Log10(Pvalue)",y="KEGG pathway",title="KEGG Pathway")

    pr + theme_bw()

    pr


    问题就这么轻松解决啦,小泡泡变大泡泡,是不是很简单?

    相关文章

      网友评论

        本文标题:R语言泡泡图— —小泡泡如何变大泡泡?

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