[英]ggplot dot plot adjust scale
My data looks like 我的数据看起来像
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
I would like to plot a dot plot where my x axis is junc and y axis is value and each junc would ideally have two dots (new and old) 我想绘制一个点图,其中我的x轴是junc,y轴是value,每个junc最好有两个点(新的和旧的)
What I have tried so far: 到目前为止我尝试过的是:
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
How do i adjust the scale and change the plot in such a way that I can visualize difference is old and new value for each junc. 我如何调整比例并更改图表,以便可以直观地看到每个垃圾邮件的新旧值之间的差异。
[edit] figure from AK88 suggestion [编辑]来自AK88建议的图
EDIT: 编辑:
> 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
In your melt
specify id.vars = "junc"
: 在您的
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))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.