I am trying to create a Manhattan plot using the qplot function.
I am plotting 500K points (the p-values of a genomic study).
I am not aware of any ggplot function specifically dedicated to this
kind of analysis, so this is the code that I was trying to use.
The result is absolutely good -- thanks to ggplot!.
genetics = qplot(Position,logpvalue, colour = factor
(Chromosomes),data = gwas, shape = snptype, xlab = "Chromosomes",
ylab = "-log10(Observed p-value)") + opts (legend.position = "none")
+ scale_x_continuous(breaks = c
(40108,82834,118522,150265,182666,218456,247383,276598,301702,329213,354
963,380422,400153,417428,433047,448851,462680,478287,487628,500917,50868
8,516645),labels = c
(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)) +
geom_hline(yintercept=seq(3, 6, by=1))
The only two things that I am still not able to do are the following:
1) I need to include 3 cutoffs lines, corresponding to specific
values of the y axis variable (the -log 10 of the pvalues). I tried
to use geom_hline but it does not work (geom_hline(yintercept=seq(3,
6, by=1))).
I am sure I am missing something somewhere but I cannot find where.
2) I tried to save the plot to import it in Photoshop (to actually
add the cutoff lines) but I was not able to get it done.
I used the following command:
ggsave (genetics, file = "genetics.tiff", width = 480, height = 480)
assuming that the resolution is 300 dpi (which is also the resolution
requested by the journal where this plot might be submitted).
Am I using it correctly?
The plot is quite heavy (pdf format = 768 KB) so I was not sure if
the attachment was a good idea, but if you think so and it makes
easier to understand the problem I am more than happy to share it
with you.
Any help would be highly appreciated.
Thank you in advance,
Guia
Great :)
> genetics = qplot(Position,logpvalue, colour = factor
> (Chromosomes),data = gwas, shape = snptype, xlab = "Chromosomes",
> ylab = "-log10(Observed p-value)") + opts (legend.position = "none")
> + scale_x_continuous(breaks = c
> (40108,82834,118522,150265,182666,218456,247383,276598,301702,329213,354
> 963,380422,400153,417428,433047,448851,462680,478287,487628,500917,50868
> 8,516645),labels = c
> (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22)) +
> geom_hline(yintercept=seq(3, 6, by=1))
>
> The only two things that I am still not able to do are the following:
>
> 1) I need to include 3 cutoffs lines, corresponding to specific
> values of the y axis variable (the -log 10 of the pvalues). I tried
> to use geom_hline but it does not work (geom_hline(yintercept=seq(3,
> 6, by=1))).
> I am sure I am missing something somewhere but I cannot find where.
Well looking at the range of your breaks (40108 to 516645), it seems
unlikely you'd want lines drawn at 3, 4, 5 and 6.
> 2) I tried to save the plot to import it in Photoshop (to actually
> add the cutoff lines) but I was not able to get it done.
> I used the following command:
>
> ggsave (genetics, file = "genetics.tiff", width = 480, height = 480)
>
> assuming that the resolution is 300 dpi (which is also the resolution
> requested by the journal where this plot might be submitted).
> Am I using it correctly?
Width and height are measured in inches!
Hadley
Thanks,
Guia