Question: Stack several manhattan plots
1
gravatar for SheelS
2.5 years 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 • 2.3k views
ADD COMMENTlink modified 4 months ago by bernatgel2.5k • written 2.5 years ago by SheelS40
4
gravatar for VHahaut
2.5 years 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 2.5 years ago • written 2.5 years 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 2.5 years 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 2.5 years ago • written 2.5 years ago by VHahaut1.1k
1
gravatar for bernatgel
4 months ago by
bernatgel2.5k
Barcelona, Spain
bernatgel2.5k wrote:

You can now do it with karyoploteR.

In the karyoploteR tutorial there's a specific page on how to create manhattan plots and it has different plots combining multiple manhattans in a single plot, but none of them is by overlaying them as you ask. To do that you would simply need to call kpPlotManhattan multiple times with different datasets and that would be it.

kp <- plotKaryotype(plot.type=4)
kpPlotManhattan(kp, data1, points.col="red")
kpPlotManhattan(kp, data2, points.col="blue")
kpPlotManhattan(kp, data3, points.col="black")

These are other example plots combining multiple manhattan plots.

enter image description here

enter image description here

ADD COMMENTlink written 4 months ago by bernatgel2.5k
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: 2094 users visited in the last hour