[R] How to stack two Stack manhattan plots?

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Thu Jun 11 15:54:40 CEST 2020


Hello,

I expected it to look like this:
https://imgur.com/a/pj40c

where x-axis would be CHR, there is 22 of them
> unique(tmp.tidy$CHR)
 [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22

I also have two phenotypes (keys) which I would like to compare
> unique(tmp.tidy$key)
[1] "Pold" "Pnew"

> dim(tmp.tidy)
[1] 2600184       4

I would like the x-axis to be separated by CHR

> sapply(tmp.tidy,class)
        CHR          BP         key       value
  "integer"   "integer" "character"   "numeric"

> str(tmp.tidy)
'data.frame':    2600184 obs. of  4 variables:
 $ CHR  : int  1 1 1 1 1 1 1 1 1 1 ...
 $ BP   : int  785989 1130727 1156131 1158631 1211292 1478153 1500941
1506035 1510801 1721479 ...
 $ key  : chr  "Pold" "Pold" "Pold" "Pold" ...
 $ value: num  0.952 0.475 0.529 0.255 0.295 ...

Unfortunately qqman doesn't do this kind of overlay of two plots

On Wed, Jun 10, 2020 at 11:24 PM John <jwd using surewest.net> wrote:
>
> On Wed, 10 Jun 2020 15:36:11 -0500
> Ana Marija <sokovic.anamarija using gmail.com> wrote:
>
> > Hello,
> >
> > I have a data frame like this:
> >
> > > head(tmp1)
> >   CHR      BP   Pold    Pnew
> > 1   1  785989 0.9521 0.09278
> > 2   1 1130727 0.4750 0.19010
> > 3   1 1156131 0.5289 0.48520
> > 4   1 1158631 0.2554 0.18140
> > 5   1 1211292 0.2954 0.48590
> > 6   1 1478153 0.5542 0.68790
> > ...
> >
> > I did:
> > tmp.tidy <- tmp1 %>% gather(key, value, -BP, -CHR)
> > jpeg("over.jpeg")
> > ggplot(tmp.tidy, aes(BP, value, color=key)) + geom_point() +
> > facet_wrap(~CHR, nrow=1)
> > dev.off()
> >
> > but I got this plot in attach which doesn't make sense. Can you please
> > advise how to make this plot?
> >
> > thanks
> > Ana
>
> If you would, the str() output might help people understand what is
> happening, and also how many records you're looking at.  The head()
> output is a bit thin on information.  There are various manhattan plot
> packages for R including a specialized package for ggplot2.
>
> JWDougherty



More information about the R-help mailing list