drveera / ggman

R package to create manhattan plots using ggplot
30 stars 12 forks source link

R package to create manhattan plots using ggplot

Note:

The package is currently under development. Please raise issues for any bugs you identify.

Version

0.99.0.beta

Installation

library(devtools)
install_github("drveera/ggman")

Quick Reference

Please refer to package vignette and the wiki page for detailed information on the usage.

Create a basic Manhattan plot

ggman(toy.gwas, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "pvalue")

enter image description here

Use relative positioning

ggman(toy.gwas, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "pvalue", relative.positions = TRUE)

enter image description here

Add labels

#subset only the SNPs with -log10(pvalue) > 8
toy.gwas.sig <- toy.gwas[-log10(toy.gwas$pvalue)>8,]

## save the main layer in a variable
p1 <- ggman(toy.gwas, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "pvalue", relative.positions = TRUE)

##add label
ggmanLabel(p1, labelDfm = toy.gwas.sig, snp = "snp", label = "snp")

enter image description here

Add text

ggmanLabel(p1, labelDfm = toy.gwas.sig, snp = "snp", label = "snp", type = "text")

enter image description here

Highlight a single group of points

ggmanHighlight(p1, highlight = toy.highlights)

enter image description here

Multiple Highlights

ggmanHighlightGroup(p1, highlightDfm = toy.highlights.group, snp = "snp", group = "group", 
                    size = 0.5, legend.title = "Significant groups")

enter image description here

Add clumps

gwas.clump <- read.table("plink.clumped", header = TRUE)

toy.clumps <- ggmanClumps(toy.clumped, index.snp.column = "SNP", clumps.column = "SP2") 

ggman(toy.gwas,clumps = toy.clumps, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "pvalue", relative.positions = TRUE, pointSize = 0.5)

enter image description here

highlight and label the clumps

toy.clumps <- ggmanClumps(toy.clumped, index.snp.column = "SNP", clumps.column = "SP2", group.column = "group", label.column = "label") 

ggman(toy.gwas,clumps = toy.clumps, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "pvalue", relative.positions = TRUE, pointSize = 0.5)

enter image description here

Zoom in to a specific chromosome

ggmanZoom(p1, chromosome = 1)

enter image description here

Zoom in to a specific region of a chromosome

ggmanZoom(p1, chromosome = 1, start.position = 215388741, end.position = 238580695)

enter image description here

Highlight points in the zoomed region

ggmanZoom(p1, chromosome = 1, start.position = 215388741, end.position = 238580695, highlight.group = "gene", legend.title = "Genes")

enter image description here

Inverted Manhattan Plot

ggman(toy.gwas, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "pvalue", invert = TRUE, invert.method = 'or', invert.var = "or")

enter image description here

Plot Odds Ratio

ggman(toy.gwas, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "or", logTransform = FALSE, ymax = 3)

enter image description here

Plot Beta Values

ggman(toy.gwas, snp = "snp", bp = "bp", chrom = "chrom", pvalue = "beta", logTransform = FALSE, ymin = -2, ymax = 2)

enter image description here