2017-06-15 76 views
0

我的數據看起來像ggplot散點圖調整規模

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 

圖獲得:enter image description here

我如何調整比例和改變劇情,讓我可以看到差異是每個junc的舊值和新值。

[編輯]從AK88建議 圖 enter image description here

編輯:

> 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 

回答

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)) 
+0

I H ave在主要問題基礎上增加了數字不要您的建議 – novicebioinforesearcher

+0

whoa,等等,您可以發佈新融化數據的「頭部」嗎? – AK88

+0

'JUNC變量值 1 X:65961303-65965481(+)變量老 2 3:90310183-90313113( - )變量老 3 6:51414210-51415178( - )變量老 4 10:79322700-79323569(+ )變量舊 5 4:122972516-122973173(+)變量舊 6 4:53030079-53033983(+)變量舊' – novicebioinforesearcher