【问题标题】:ggplot dot plot adjust scaleggplot点图调整比例
【发布时间】:2017-06-15 05:33:26
【问题描述】:

我的数据看起来像

junc                    old         new
X:65961303-65965481(+)  0.025672937 0.004911527
3:90310183-90313113(-)  0.098444488 0.002132802
6:51414210-51415178(-)  3.05E-05    4.37E-06
10:79322700-79323569(+) 0.33095695  0.302002001
4:122972516-122973173(+)    0.939167683 0.932705233
4:53030079-53033983(+)  0.000233548 0.00081976
13:56185646-56189613(-) 4.85E-10    9.43E-09
13:56189703-56197485(-) 4.82E-07    6.96E-09
11:98577839-98579023(-) 0.001854774 0.000894136
10:90615925-90621493(-) 0.000902529 2.84E-05
10:19614164-19624369(-) 4.38E-08    1.26E-06

我想绘制一个点图,其中我的 x 轴是 junc,y 轴是值,理想情况下每个 junc 有两个点(新的和旧的)

到目前为止我所尝试的:

library(ggplot2)
library(reshape2)
dat <- read.delim('~/plot.txt', sep = '\t', header = F)
head(dat)
colnames(dat) = c('junc', 'old', 'new')
head(dat)
mdat <- melt(dat)
head(mdat)

 p = ggplot(mdat, aes(x=mdat$junction, fill=mdat$variable)) + geom_dotplot(binpositions="all")
 p 

得到的图:

如何调整比例并更改绘图,以便我可以看到每个路口的新旧值之间的差异。

[编辑] 图来自 AK88 建议

编辑:

> head(mdat)
                   junc variable        value
1   X:65961303-65965481(+)       old 2.567294e-02
2   3:90310183-90313113(-)       old 9.844449e-02
3   6:51414210-51415178(-)       old 3.048876e-05
4  10:79322700-79323569(+)       old 3.309569e-01
5 4:122972516-122973173(+)       old 9.391677e-01
6   4:53030079-53033983(+)       old 2.335478e-04
> 
>head(mlt)
junc variable value
1   X:65961303-65965481(+)  variable   old
2   3:90310183-90313113(-)  variable   old
3   6:51414210-51415178(-)  variable   old
4  10:79322700-79323569(+)  variable   old
5 4:122972516-122973173(+)  variable   old
6   4:53030079-53033983(+)  variable   old

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    在您的melt 中指定id.vars = "junc"

    mdat = melt(dat, id.vars = "junc")
    
    ggplot(data = mdat, aes(x = junc, y = value, color = variable)) +
      geom_point(position = position_dodge(width = 0.2))
    

    【讨论】:

    • 我在主要问题库中添加了数字,请不要提出您的建议
    • 哇,等等,你能把你的新融化数据的head 贴出来吗?
    • junc variable value 1 X:65961303-65965481(+) variable old 2 3:90310183-90313113(-) variable old 3 6:51414210-51415178(-) variable old 4 10:79322700-79323569(+) variable old 5 4:122972516-122973173(+) variable old 6 4:53030079-53033983(+) variable old
    • 您可以将其发布到您的帖子正文中吗?很难看到这里的列。
    • 两个变量的张贴头
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-20
    • 2011-07-15
    • 1970-01-01
    • 1970-01-01
    • 2019-08-22
    • 1970-01-01
    相关资源
    最近更新 更多