kpHeatmap {karyoploteR} | R Documentation

## kpHeatmap

### Description

Plots the given data as a heatmap along the genome

### Usage

    kpHeatmap(karyoplot, data=NULL, chr=NULL, x0=NULL, x1=x0, y=NULL, ymax=NULL, ymin=NULL, r0=NULL, r1=NULL, data.panel=1, colors=c("blue", "white", "yellow"), clipping=TRUE, ...)

### Arguments

`karyoplot` | (a `KaryoPlot` object) This is the first argument to all data plotting functions of `karyoploteR`. A KaryoPlot object referring to the currently active plot.
`data` | (a `GRanges`) A GRanges object with the data. If `data` is present, `chr` will be set to `seqnames(data)` and `x` to the midpoints of the rages in data. If no parameter `y` is specified and `data` has a column named `y` or `value` this column will be used to define the `y` value of each data point. (defaults to NULL)
`chr` | (a charecter vector) A vector of chromosome names specifying the chromosomes of the data points. If `data` is not NULL, `chr` is ignored. (defaults to NULL)
`x0` | (numeric) the position (in base pairs) where the data region starts
`x1` | (numeric) the position (in base pairs) where the data region ends
`y` | (a numeric vector) A numeric vector with the values of the data points. If `y` is not NULL, it is used instead of any data column in `data`. (defaults to NULL)
`ymax` | (numeric) The maximum value of `y` to be plotted. If NULL, it is set to the max value of the selected data panel. (defaults to NULL)
`ymin` | (numeric) The minimum value of `y` to be plotted. If NULL, it is set to the min value of the selected data panel. (defaults to NULL)
`r0` | (numeric) r0 and r1 define the vertical range of the data panel to be used to draw this plot. They can be used to split the data panel in different vertical ranges (similar to tracks in a genome browser) to plot differents data. If NULL, they are set to the min and max of the data panel, it is, to use all the available space. (defaults to NULL)
`r1` | (numeric) r0 and r1 define the vertical range of the data panel to be used to draw this plot. They can be used to split the data panel in different vertical ranges (similar to tracks in a genome browser) to plot differents data. If NULL, they are set to the min and max of the data panel, it is, to use all the available space. (defaults to NULL)
`data.panel` | (numeric) The identifier of the data panel where the data is to be plotted. The available data panels depend on the plot type selected in the call to `plotKaryotype`. (defaults to 1)
`colors` | (colors) A set of color used to determine the color associated with each value. Internally, it uses `colorRamp`. (defaults to c("blue", "white", "yellow"))
`clipping` | (boolean) Only used if zooming is active. If TRUE, the data representation will be not drawn out of the drawing area (i.e. in margins, etc) even if the data overflows the drawing area. If FALSE, the data representation may overflow into the margins of the plot. (defaults to TRUE)
`...` | The ellipsis operator can be used to specify any additional graphical parameters. Any additional parameter will be passed to the internal calls to the R base plotting functions.

### Details

Given regions of the genome with a start, end and a value, draws a heatmap-like representation, with the color of the region determined by its value. It is important to note that `kpHeatmap` will not extend the regions in any way, so if regions are not contiguous, they will appear as a series of rectangles and not as a continuous plot.

### Value

Returns the original karyoplot object, unchanged.

### See Also

`plotKaryotype`, `kpRect`, `kpLines`

### Examples

    dd <- toGRanges(data.frame(chr="chr1", start=4980000*(0:49), end=4980000*(1:50)))
    y <- sin(x=c(1:length(dd))/2)

    kp <- plotKaryotype("hg19", plot.type=1, chromosomes=c("chr1", "chr2"))

    kpLines(kp, dd, y=y, r0=0.4, r1=0.6, ymin=-1, ymax=1)
    kpAxis(kp, r0=0.4, r1=0.6, ymin=-1, ymax=1, cex=0.5)

    kpHeatmap(kp, dd, y=y, colors = c("red", "black", "green"), r0=0, r1=0.2)
    kpHeatmap(kp, dd, y=y, colors = c("green", "black", "red"), r0=0.2, r1=0.4)

    #or we can provide all data into a single GRanges object
    mcols(dd) <- data.frame(y=y)

    kpHeatmap(kp, dd, r0=0.6, r1=0.8)
    #non-contiguous regions appear as solitary rectangles
    kpHeatmap(kp, sample(x = dd, 10), r0=0.8, r1=1, color=c("orange", "black", "purple", "green"))

[Package karyoploteR version 1.20.3 Index]