This is a test version of Biostars. For the public version, visit https://www.biostars.org.
manhattan plot for different colorw

Hi everyone,

I try to draw a Manhattan plot via the R programming language, but every chromosome has two different colors. Look at the example below, input, and expected output, please.

this is just an example of manhattan plot

library(qqman)

manhattan(gwasResults, chr="CHR", bp="BP", snp="SNP", p="P" )

this is my data set looks like

     SNP CHR  BP            P   SNP CHR  BP           P
1     rs1   1   1 0.9148060435 rs751   1 751 0.244920995
2     rs2   1   2 0.9370754133 rs752   1 752 0.087635909
3     rs3   1   3 0.2861395348 rs753   1 753 0.391108497
4     rs4   1   4 0.8304476261 rs754   1 754 0.182561425
5     rs5   1   5 0.6417455189 rs755   1 755 0.133624785
6     rs6   1   6 0.5190959491 rs756   1 756 0.257462913
7     rs7   1   7 0.7365883146 rs757   1 757 0.553247048

and the expected output will be enter image description here

genome r

I will appreciate for any comment

I don't know much about qqman, but this is strange, I think. Are there also squares and circles? or is it an effect of image compression? In any case, if you want to use another package to plot the manhattan, you can take a look at the karyoploteR tutorial on how to plot manhattan plots ([https://bernatgel.github.io/karyoploter_tutorial//Tutorial/PlotManhattan/PlotManhattan.html]). It is quite flexible regarding colors, shapes, etc... and you can include other data types (genes, for example) to the plot.

1 answer

Hi Mag,

If you look at the "manhattan" function help, you can see that there is a "col" parameter. (https://rdrr.io/cran/qqman/man/manhattan.html)

col: A character vector indicating which colors to alternate.

So you can try to add this parameter to your function call with the color (or colors) you want, like so:

library(qqman)
# Single color
manhattan(gwasResults, chr="CHR", bp="BP", snp="SNP", p="P", col = c("chartreuse4"))
# Three colors
manhattan(gwasResults, chr="CHR", bp="BP", snp="SNP", p="P", col = c("chartreuse4", "coral4", "dodgerblue3"))

Let me know if this works.

No this shows separated colors

Log in to answer this question.