Question: ggplot scatterplot and lines
gravatar for Pin.Bioinf
14 months ago by
Pin.Bioinf240 wrote:

Hello, I have methylation data, and I graph it as a scatterplot using ggplot like this:

p1<-ggplot(data, aes(meth_matrix$sample1, meth_matrix$sample3)) +
  geom_point() +

which works perfect, but I want to add lines to it: the abline that divides the scatterplot in half:

p1  + geom_abline(color="blue")

and my question is: how can I draw two red lines parallel to that diagonal (y intercept would be 0.2, slope would be the same as the blue line) ??

Also: how can I draw the difference of both samples in a similar scatterplot (it will look like a horizontal scatterplot) with ggplot? right now I can only do it with plot like:

dif_samples<-meth_matrix$sample1- meth_matrix$sample3
plot(dif_samples, main="difference", 
     xlab="CpGs ", ylab="Methylation ", pch=19)

(also I'd like adding the horizontal blue line and the red lines paralllel to the blue line)

Please help!!!

Thank you very much.

ggplot scatterplot • 929 views
ADD COMMENTlink modified 14 months ago by Buffo1.6k • written 14 months ago by Pin.Bioinf240

Not really a bioinformatics question. Ask on stackoverflow.

ADD REPLYlink written 14 months ago by Nicolas Rosewick7.6k
gravatar for Buffo
14 months ago by
Buffo1.6k wrote:

To add lines in ggplot:

geom_hline(yintercept=0.2, linetype="dashed", color = "Black") 

geom_vline(xintercept = c(-3,3), linetype="dashed", color = "black")

ablines in plot():

abline(h = 0.2, v = c(-3,3), lty = 2, col= "Black")
ADD COMMENTlink written 14 months ago by Buffo1.6k
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 844 users visited in the last hour