LDheatmap {geneHapR}R Documentation

This function produces a pairwise LD plot.

Description

LDheatmap() is used to produce a graphical display, as a heat map, of pairwise linkage disequilibrium (LD) measurements for SNPs. The heat map is a false color image in the upper-left diagonal of a square plot. Optionally, a line parallel to the diagonal of the image indicating the physical or genetic map positions of the SNPs may be added, along with text reporting the total length of the genomic region considered.

Usage

plot_LDheatmap(
  hap,
  gff,
  Chr,
  start,
  end,
  geneID = NULL,
  distances = "physical",
  LDmeasure = "r",
  title = "Pairwise LD",
  add.map = TRUE,
  map.height = 1,
  colorLegend = TRUE,
  geneMapLocation = 0.15,
  geneMapLabelX = NULL,
  geneMapLabelY = NULL,
  SNP.name = TRUE,
  color = NULL,
  color_gmodel = "grey",
  color_snp = "grey",
  color_snpname = "grey40",
  cex_snpname = 0.8,
  snpmarks_height = NULL,
  newpage = TRUE,
  name = "ldheatmap",
  vp.name = NULL,
  pop = FALSE,
  text = FALSE
)

Arguments

hap

R object of hapSummary or hapResult class.

gff

annotations

Chr, start, end, geneID

chromosome, start and end position, gene ID for extract annotation in target range.

distances

A character string to specify whether the provided map locations are in physical or genetic distances. If distances = "physical" (default), the text describing the total length of the region will be “Physical Length:XXkb” where XX is the length of the region in kilobases. If distances = "genetic", the text will be “Genetic Map Length:YYcM” where YY is the length of the region in centiMorgans. If gdat is an object of class LDheatmap, distances is taken from gdat.

LDmeasure

A character string specifying the measure of LD

  • either allelic correlation r^2 or Lewontin's |D'|; default = "r" for r^2; type "D'" for |D'|. This argument is ignored when the user has already supplied calculated LD measurements through gdat (i.e., when gdat is a matrix of pairwise LD measurements or an object of class "LDheatmap").

title

A character string for the main title of the plot. Default is “Pairwise LD”.

add.map

If TRUE (default) a diagonal line indicating the physical or genetic map positions of the SNPs will be added to the plot, along with text indicating the total length of the genetic region.

map.height

the height of gene map, default is 0.02

colorLegend

If TRUE (default) the color legend is drawn.

geneMapLocation

A numeric value specifying the position of the line parallel to the diagonal of the matrix; the larger the value, the farther it lies from the matrix diagonal. Ignored when add.map = FALSE.

geneMapLabelX

A numeric value specifying the x-coordinate of the text indicating the total length of the genomic region being considered. Ignored when add.map = FALSE.

geneMapLabelY

A numeric value specifying the y-coordinate of the text indicating the total length of the genomic region being considered. Ignored when add.map = FALSE.

SNP.name

a logical vector indicated wherther display SNP names using positions.

color

A range of colors to be used for drawing the heat map. Default is grDevices::colorRampPalette(c("red", "grey"))(30).

color_gmodel, color_snp, color_snpname

the color of gene model and snp and snp names respectively, default as grey80.

cex_snpname

the size of snp names/labels

snpmarks_height

the height of snp marks, if set as NULL, nothing will display on gene model where the heat map is going to be drawn.

newpage

If TRUE (default), the heat map will be drawn on a new page.

name

A character string specifying the name of the LDheatmap graphical object (grob) to be produced.

vp.name

A character string specifying the name of the viewport

pop

If TRUE, the viewport where the heat map is drawn is popped (i.e. removed) from the viewport tree after drawing. Default = FALSE.

text

If TRUE, the LD measurements are printed on each cell.

Details

The input object gdat can be a data frame of genotype objects (a data structure from the genetics package), a SnpMatrix object (a data structure from the snpStats package), or any square matrix with values between 0 and 1 inclusive. LD computation is much faster for SnpMatrix objects than for genotype objects. In the case of a matrix of LD values between 0 and 1, the values above the diagonal will be plotted. In the display of LD, SNPs appear in the order supplied by the user as the horizontal and vertical coordinates are increased and one moves along the off-diagonal line, from the bottom-left to the top-right corner. To achieve this, the conventions of the image() function have been adopted, in which horizontal coordinates correspond to the rows of the matrix and vertical coordinates correspond to columns, and vertical coordinates are indexed in increasing order from bottom to top. See the package vignette LDheatmap for more examples and details of the implementation. Examples of adding “tracks” of genomic annotation above a flipped heatmap are in the package vignette addTracks.

Value

An object of class "LDheatmap" which contains the following components:

LDmatrix

The matrix of pairwise LD measurements plotted in the heat map.

LDheatmapGrob

A grid graphical object (grob) representing the produced heat map.

heatmapVP

The viewport in which the heat map is drawn. See viewport.

genetic.distances

The vector of the supplied physical or genetic map locations, or the vector of equispaced marker distances when no distance vector is supplied.

distances

A character string specifying whether the provided map distances are physical or genetic.

color

The range of colors used for drawing the heat map.

The grob LDheatmapGrob has three grobs as its children (components). They are listed below along with their own children and respectively represent the color image with main title, genetic map and color key of the heat map: "heatMap" - "heatmap", "title"; "geneMap" - "diagonal", "segments", "title", "symbols", "SNPnames"; and "Key" - "colorKey", "title", "labels", "ticks", "box".

Note

The produced heat map can be modified in two ways. First, it is possible to edit interactively the grob components of the heat map, by using the function grid.edit; the function will not work if there is no open graphical device showing the heat map. Alternatively, the user can use the function editGrob and work with the grob LDheatmapGrob returned by LDheatmap. See Examples for usage. LDheatmap() uses Grid, which does not respond to par() settings. Hence modifying par() settings of mfrow and mfcol will not work with LDheatmap(). The Examples section shows how to display multiple heat maps on one plot without the use of par().

References

Shin J-H, Blay S, McNeney B and Graham J (2006). LDheatmap: An R Function for Graphical Display of Pairwise Linkage Disequilibria Between Single Nucleotide Polymorphisms. Journal of Statistical Software, 16 Code Snippet 3

Examples

# Pass LDheatmap a SnpMatrix object
data(geneHapR_test)
plot_LDheatmap(hap = hapResult,
               gff = gff,
               Chr = hapResult[1,2],
               start = 4000, end = 8200)

[Package geneHapR version 1.2.4 Index]