plotpos.by.chr: Utilities for Manhatten plots

Description Usage Arguments Details Value Author(s) Examples

Description

Constructs vectors of plotting positions and colours, for points that have positions on chromosomes.

Usage

1
2
3
4
5
plotpos.by.chr(chr, pos, gap = 5e7,
               chrset = c(1:22, "XY", "X", "Y", "M"))
plotcol.by.chr(chr, cols = NULL, col.missing = "black",
               chrset = c(1:22, "XY", "X", "Y", "M"))
axis.by.chr(chr, plotpos, side = 1, lines = 2)

Arguments

chr

A vector of chromosome identities

pos

A vector of positions within chromosomes

gap

Gap size between chromosomes, in same units as pos

chrset

Set of all chromosomes

cols

Colours for chromosomes, recycled as necessary

col.missing

Colour to use for chromosomes not in chrset

plotpos

A vector of plotting positions

side

Side to plot the axis

lines

Number of lines to distribute chromosome labels over

Details

These functions all convert chr to upper case and remove leading “CHR” if present, before doing anything else.

If argument cols to plotcol.by.chr is left NULL, it is filled with a suitable call to contrasting.rainbow. For an alternative popular style of Manhatten plot, try cols = c("cyan", "grey").

The example illustrates how to use these functions to help draw a Manhatten plot.

Value

plotpos.by.chr returns a vector of plotting positions of length equal to the input chr and pos.

plotcol.by.chr returns a vector of plotting colours of length equal to the input chr.

axis.by.chr draws an axis and returns the positions the ticks were drawn at.

Author(s)

Toby Johnson Toby.x.Johnson@gsk.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## generate dummy GWAS results
gwas <- data.frame(chr = paste("chr", rep(1:22, each = 500), sep = ""),
                   pos = do.call(c, lapply(1:22, function(chr)
return(sort(ceiling(runif(500, 1, 1e8/chr)))))),
                   pval = runif(11000),
                   stringsAsFactors = FALSE)
## example drawing a Manhatten plot
gwas$plotpos <- plotpos.by.chr(gwas$chr, gwas$pos)
gwas$plotcol <- plotcol.by.chr(gwas$chr)
with(gwas, plot(plotpos, -log10(pval), col = plotcol,
                ann = FALSE, xaxt = "n", las = 1))
title(ylab = expression(-log[10](italic(P))))
axis.by.chr(gwas$chr, gwas$plotpos)
mtext("Genomic position by chromosome", side = 1, line = 3)

tobyjohnson/gtx documentation built on Aug. 30, 2019, 8:07 p.m.