heatmapChr: Heatmap of GRanges Object

View source: R/heatmapChr.R

heatmapChrR Documentation

Heatmap of GRanges Object

Description

A function to create a heatmap or a graphical representation of data where the individual values contained in a matrix are represented as colors of the GRanges object.

Usage

heatmapChr(
  GR,
  filename = NULL,
  chr,
  sample.id = NULL,
  factor.scale = 10^6,
  absolute = FALSE,
  xtitle = NULL,
  Barpalette,
  format = "tiff",
  width = 4000,
  height = 790,
  fontfamily = "sans",
  font = 2,
  mar.scale = c(2, 2, 2, 2),
  mgp.scale = c(3, 1, 0),
  mar.heatmap = c(2, 2, 2, 2),
  mgp.heatmap = c(3.5, 1, 0),
  compression = "lzw",
  res = 900,
  pointsize = 1,
  col.bar.lwd = 1,
  cex = 1,
  cex.xaxis = 1.6,
  cex.yaxis = 2,
  cex.xtitle = 2,
  cex.bar.lab = 2,
  lwd.ticks = 0.5,
  xaxis.labels.pos = 0.1,
  oma = c(2, 2, 2, 2),
  oma.scale = c(0, 0, 0, 0),
  xaxis.adj = c(0.5, 1),
  tick.breaks = 500,
  line.xtitle = NA,
  jpg.type = c("cairo", "cairo-png", "Xlib", "quartz"),
  ylas = 1,
  bar.las = 1,
  ...
)

Arguments

GR

A Grange object with the variable of interest in its metacolumn.

filename

This is the name of the image file in which we want to output the heatmap.

chr

This is a required argument which corresponds to the chromosome of interest in the data.

sample.id

This is the id or column name which is the sample of the GRange object.

factor.scale

A number to scale chromosome position into "bp", "kbp", or "Mbp", depending on chromosome size

absolute

If absolute == TRUE, all the values taken for the heatmap would be absolute values of the GRange object.

xtitle

This is the x axis title for the heatmap which will be produced..

Barpalette

This is a required argument which defines the barpalette for the heatmap which can be a colorRampPalette object.

format

This is the format of the output file which will have the heatmap. Possible formats are "jpg", "png", "tiff" and "pdf". The default value for this is "tiff with compression = "lzw" and res = 600.

width

This is the width of the heatmap image which will be produced.

height

This is the height of the heatmap image which will be produced.

fontfamily

This value defines the name of the font family which will be used in text or labels for the heatmap. Standard values are "serif", "sans" and "mono", and the Hershey font families are also available.

font

value to pass in to parameter 'font' from function par. An integer which specifies which font to use for text. If possible, device drivers arrange so that 1 corresponds to plain text (the default), 2 to bold face, 3 to italic and 4 to bold italic.

mar.scale

A numeric vector of length 4, which sets the margin sizes in the following order: bottom, left, top, and right.

mgp.scale

A numeric vector of length 3, which sets the axis label locations relative to the edge of the inner plot window. The first value represents the location the labels (i.e. xlab and ylab in plot), the second the tick-mark labels, and third the tick marks.

compression

This is the the type of compression to be used. The default compression type is "lzw".

res

This is the nominal resolution in ppi which will be recorded in the bitmap file, if a positive integer. Also used for units other than the default, and to convert points to pixels. The defualt resolution is 300ppi.

pointsize

The pointsize of plotted text, interpreted as big points (1/72 inch) at res ppi. The default value for this is 1.

col.bar.lwd

Line width grphical parameter for the color bar.

cex

As in par, it is numerical value giving the amount by which plotting text and symbols should be magnified relative to the default. This starts as 1 when a device is opened, and is reset when the layout is changed, e.g. by setting mfrow.

cex.xaxis, cex.yaxis, cex.xtitle, cex.bar.lab

Cex values for x-axis, y-axis, x-title, and color-bar labels, respectively. As in par, these are the magnification to be used for x-axis, y-axis, and label annotations relative to the current setting of cex.

lwd.ticks

Line width for axis and ticks (heatmap only).

xaxis.labels.pos

Y-coordinate for x-axis labels.

oma, oma.scale

Same as 'oma' graphical parameter (see par). 'oma' is used in the heatmap and oma.scale in the color bar.

xaxis.adj

Adjustment of the x-axis labels.

tick.breaks

An integer number used to introduce the number breaks in the chromosome scale where the tick will be located.

line.xtitle

specifying a value for xline.label overrides the default placement of x-axis title, and places them this many lines outwards from the plot edge

jpg.type

Paramter 'type' from 'jpeg' functions (see ?jpeg).

ylas, bar.las

numeric in 0,1,2,3; the style of y-axis and colo-bar labels, as given for graphical parameters "las" (see par).

...

Additional graphical parameters for 'par' R function used in the heatmap (not in the color bar).

Details

This function creates a heatmap is a false color image with a color scale added to the right side and a chromosome scale to the bottom.

Value

A GRanges object with the new genomic regions and their corresponding summarized statistic.

Author(s)

Robersy Sanchez

Examples

data(GRMatrix)
## The pallette used in the bar color
bar.palette <- colorRampPalette(c(rep("cyan",4), "green",rep("yellow", 2),
                                  rep("red", 3), rep("darkblue", 2),
                                  rep("black",2)), bias = 1.1, space = "rgb")

## heatmap construction
k <- "Chr1"
file <- paste0(getwd(), "/heatmap_", k)
xlab <- paste0("CG. Chromosome ", sub("Chr", "", k), " (Mbp)")
heatmapChr(GR = GRMatrix, filename = file, format = "tiff", 
           chr = k, xtitle = xlab,
           Barpalette = bar.palette, mar = c(4, 6, 0, 0), res = 600,
           height = 350, width =2500, font = 2, fontfamily = "serif", ylas=1,
           lwd = 0.1, mar.scale = c(4, 5, 0.5, 3), cex.xtitle = 2.5,
           cex.bar.lab = 2, mgp = c(3,1,0), pointsize = 2, cex.xaxis = 2,
           cex.yaxis = 2, oma=c(1,1,1,0), xaxis.adj = c(0.5, 0.7),
           lwd.ticks = 0.1, line.xtitle = 3, mgp.scale = c(3, 1, 0),
           col.bar.lwd = 0.1, factor.scale = 10^3,
           sample.id = c("CT1", "CT2", "CT3", "TT1", "TT2", "TT3"))
## To remove the file containing the heatmap
file.remove(paste0(file, ".tiff"))


genomaths/MethylIT.utils documentation built on July 4, 2023, 12:05 a.m.