[R] Adding segments to a dot plot in ggplot2

Kate Ignatius kate.ignatius at gmail.com
Thu May 22 20:25:08 CEST 2014


I'm trying to plot a GWAS (in you will) with lined segments
representing an overall p-value for each gene.  Here is my code:

skatg <- ggplot(comm, aes(x = position,y = p, colour = grey)) +
                     geom_point(size = 0.75) +
                      geom_segment(data=rare, aes(x = txStart, y =
-log10(p), xend=txEnd,  yend = -log10(p), colour = darkgreen))   +
                      labs(x = "Position",y = "-log10 P value") +
                      facet_wrap(~ Chrom, scales = "free", ncol = 4)

Where comm is a file with 250k+ variants and genes.in.locus is a file
with about 18k genes.

When running this script, I get the error

Don't know how to automatically pick scale for object of type
function. Defaulting to continuous
Error in data.frame(x = c(40840353L, 31902418L, 19468080L, 236748505L,  :
  arguments imply differing number of rows: 79746, 0

Is this because there are different number of rows in each data frame
I'm trying to plot?  If so, what is a best way to overcome this error?

Example of my data is as follows:

comm:

         Name        gene Chrom       position         p
1  rs10000037    FAM114A1     4  38924330 0.7513597
2  rs10000250      CC2D2A     4  15482477 0.9202882
4  rs10000911       USP38     4 144136193 0.8335902
5     rs10001      STXBP2    19   7711221 0.4709547
7  rs10001370       USP46     4  53463730 0.8759828
8   rs1000152      ZNF462     9 109687288 0.3451001
10 rs10002583        POLN     4   2194953 0.7878575
12 rs10002971         EGF     4 110896050 0.5082255
15 rs10003873      SORBS2     4 186605868 0.2309855
16 rs10003909    ARHGAP24     4  86915848 0.8714853
17 rs10003947       ANXA3     4  79512800 0.5141532
18    rs10004        SSR1     6   7310259 0.6851725
20 rs10004136       STX18     4   4463587 0.5296092
21 rs10004516       ENPEP     4 111398208 0.8564897
22  rs1000521      SLC8A3    14  70522484 0.6234326
23 rs10005849       DCHS2     4 155287317 0.8192577
24 rs10006362       RGS12     4   3319271 0.8061674
25  rs1000640        WWP2    6  69905668 0.2682735
26 rs10006580      PCDH18     4 138449812 0.5178650
27 rs10006676       CYTL1     4   5021086 0.3531493
28 rs10006845       PCDH7     4  31116375 0.4817453
29 rs10007075       NEIL3     4 178274694 0.5433481
31 rs10008636 TMPRSS11BNL     4  69083563 0.8346434
32 rs10008910        UBA6     4  68500171 0.5705853
33 rs10009228      CHRNA9     4  40356422 0.4223378


rare:

       geneName txStart  txEnd Chrom    position         p
36131    YTHDC1    6026  45746     4   6026 0.5009490
10898   FAM110C   38813  46588     19  38813 1.0000000
37306    ZNF595   53178  88099     4  53178 0.1261045
16450   KIR2DL4   57208  68123    19  57208 0.0000156
28406    SCAND3   61610  77316     6  61610 0.2568
19926       MPG  127017 135850    6 127017 00.000987456
34149    TRIM27  174179 195169     6 174179 0.025698

I haven't included all information here.

Any help will be greatly appreciated.

Thanks!



More information about the R-help mailing list