0

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)

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 

Figure obtained: enter image description here

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 enter image description here

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

1 Answer 1

1

In your melt specify 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))
Sign up to request clarification or add additional context in comments.

12 Comments

I have added figure in main question base don your suggestion
whoa, wait, can you post the head of your new melted data?
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
Can you post it into the body of your post? It is difficult to see the columns here.
posted head for both the variable
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.