Question: Stack several manhattan plots
1
gravatar for SheelS
14 months ago by
SheelS40
Asia
SheelS40 wrote:

How can I stack several manhattan plots in the same plot looks like this https://imgur.com/a/pj40c using R?

That plot is made using excel and not follow their real map position.

In my case I have 4 p-values from 4 different phenotypes. They are estimated from same SNPs. I want to stack them in the same plot but distinguish phenotypes by different colors.

   # Input data format, example. 
   SNP  CHR POS pval_1  pval_2  pval_3  pval_4
    a   1   100 0.1 0.5 0.2 0.1
    b   2   110 0.2 0.6 0.3 0.5
    c   3   120 0.3 0.7 0.1 0.6
    d   4   130 0.4 0.1 0.4 0.2

qqman is a very useful R package, unfortunately it is only allowed for single trait.

qqman manhattan R • 1.0k views
ADD COMMENTlink modified 7 months ago by zx87546.1k • written 14 months ago by SheelS40
4
gravatar for VHahaut
14 months ago by
VHahaut1.1k
Belgium
VHahaut1.1k wrote:

With a bit of customization you could do it in R with ggplot:

library(dplyr)
library(ggplot2)

tmp <- data_frame(
  POS=seq(1,10000),
  pval1=1/runif(n = 10000, min=0, max=0.2),
  pval2=1/c(runif(n = 9999, min=0, max=0.2), 1e-5),
  pval3=1/runif(n = 10000, min=0, max=0.3),
  pval4=1/runif(n = 10000, min=0, max=0.4))

tmp.tidy <- tmp %>% gather(key, value, -POS)

ggplot(tmp.tidy, aes(POS, value, color=key)) + 
  geom_point()

Example:

https://ibb.co/mYnb3w

Use the + facet_wrap(~CHR) to create a graph per chromosome.

ADD COMMENTlink modified 14 months ago • written 14 months ago by VHahaut1.1k

Thanks, I thought the same thing before posting my question. But I wonder that do you know how to create a column for CHR using my example data (for + facet_wrap(~CHR) usage ) ? Thank you.

ADD REPLYlink written 14 months ago by SheelS40
1

Using the facet_wrap you'll split your graph in as many chromosome as you have:

library(dplyr)
library(ggplot2)

tmp <- data_frame(
  CHR=paste0("chr", sample(1:10, 1000, replace=T)),
  POS=seq(1,1000),
  pval1=1/runif(n = 1000, min=0, max=0.2),
  pval2=1/c(runif(n = 999, min=0, max=0.2), 1e-5),
  pval3=1/runif(n = 1000, min=0, max=0.3),
  pval4=1/runif(n = 1000, min=0, max=0.4))

tmp.tidy <- tmp %>% gather(key, value, -POS, -CHR)

ggplot(tmp.tidy, aes(POS, value, color=key)) + 
  geom_point() + facet_wrap(~CHR, nrow=1)

With the facet_wrap() by chromosome:

http://hpics.li/3db6911

ADD REPLYlink modified 14 months ago • written 14 months ago by VHahaut1.1k
Please log in to add an answer.

Help
Access

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