Package 'heatmap4'

Title: Simple Heatmap Function
Description: A color image of a numerical matrix. A dendrogram can be added to the left side and to the top. This package takes the original heatmap function and reduces the argument complexity.
Authors: Ritu Roy <[email protected]>, Adam Olshen <[email protected]>, Anishka Dhar <[email protected]>
Maintainer: Ritu Roy <[email protected]>
License: GPL (>=2)
Version: 0.1.8
Built: 2025-02-12 01:27:00 UTC
Source: https://github.com/rituroy/heatmap4

Help Index


Gene amplification status

Description

A numeric matrix of 0s and 1s of the same dimension as genomDat. ...

Usage

amplifDat

Format

amplifDat

A matrix with 3469 rows and 39 columns.


Gene information

Description

A data.frame containing gene information. ...

Usage

anno

Format

anno

A data.frame with 3469 rows and 2 columns.


Chromosomal information

Description

A data.frame containing information for each chromosome. ...

Usage

chrInfo

Format

chrInfo

A data.frame with 24 rows and 3 columns.


Calibration bar for color images.

Description

Produces a color image (color bar)

Usage

colorBar(
  x,
  horizontal = TRUE,
  col = grDevices::heat.colors(50),
  scale = 1:length(x),
  k = 10,
  cexAxis = 1,
  ...
)

Arguments

x

.

horizontal

.

col

.

scale

.

k

.

cexAxis

.

...

additional arguments.

Value

A color vector.


Cluster designation.

Description

Cuts the tree into desired number of groups.

Usage

cutCluster(clustObj, ann, nClust = 2, rev = F)

Arguments

clustObj

a hclust object.

ann

a data.frame containing annotation for each observation.

nClust

number of groups desired.

rev

reverse the order of observations.

Value

a data.frame.


Generate a Heat Map.

Description

A heat map is a false color image (basically image(t(x))) with a dendrogram added to the left side and to the top. Typically, reordering of the rows and columns according to some set of values (row or column means) within the restrictions imposed by the dendrogram is carried out. This package takes the original heatmap function and reduces the argument complexity.

Usage

generate_heatmap(
  x,
  col_lab = c(FALSE, TRUE),
  row_lab = c(FALSE, TRUE),
  col_lab_vtr = NULL,
  row_lab_vtr = NULL,
  col_anno = c(FALSE, TRUE),
  row_anno = c(FALSE, TRUE),
  col_info = NULL,
  row_info = NULL,
  col_anno_var = NULL,
  row_anno_var = NULL,
  col_var_info = NULL,
  row_var_info = NULL,
  col_dend = c(FALSE, TRUE),
  row_dend = c(FALSE, TRUE),
  col_anno_name = NULL,
  row_anno_name = NULL,
  col_clust = NULL,
  row_clust = NULL,
  plot_info = list(margins = c(0.5, 0.5), cexCol = NULL, cexRow = NULL, cexColSide =
    NULL, cexRowSide = NULL, colorCatCol = NULL, colorCatRow = NULL, colorContCol = NULL,
    colorContRow = NULL),
  file_name = NULL,
  h_title = NULL,
  input_legend = c(FALSE, TRUE),
  legend_title = NULL,
  plotHeatmap = TRUE,
  heatmap_color = c("red", "blue", "grey"),
  zlm = c(-0.5, 0.5),
  ...
)

Arguments

x

numeric matrix; values to be plotted in the heatmap.

col_lab

boolean (T, F); to display column labels; default is FALSE.

row_lab

boolean (T, F); to display row labels; default is FALSE.

col_lab_vtr

character vector; with column labels to use; defaults to colnames(x).

row_lab_vtr

character vector; with row labels to use; defaults to rownames(x).

col_anno

boolean (T, F); to display column annotations; defaults to FALSE.

row_anno

boolean (T, F); to display row annotations; defaults to FALSE.

col_info

data frame; data to be used in column annotations; default is NULL.

row_info

data frame; data to be used in row annotations; default is NULL.

col_anno_var

character vector; with specific column annotation variables to see in column annotations; defaults to colnames(col_info).

row_anno_var

character vector; with specific row annotation variables to see in row annotations; defaults to colnames(row_info).

col_var_info

nested list; of column annotation variables that need specific colors and placement; options are "color", "level" for characters, "limit" for numerics and "mode"=c("character","numeric"); default is NULL.

row_var_info

nested list; of row annotation variables that need specific colors and placement; options are "color", "level" for characters, "limit" for numerics and "mode"=c("character","numeric"); default is NULL.

col_dend

boolean (T, F); to display column dendrogram; default is FALSE.

row_dend

boolean (T, F); to display row dendrogram; default is FALSE.

col_anno_name

character vector; to name column color bars; default is NULL.

row_anno_name

character vector; to name row color bars; default is NULL.

col_clust

variable of hclust or dendrogram class; to cluster by the column; default NULL when col_dend is FALSE.

row_clust

variable of hclust or dendrogram class; to cluster by the row; default NULL when row_dend is FALSE.

plot_info

list; of 8 variables to control heatmap and annotation column/row label size (in that order); default is list( margins=c(0.5,0.5), "cexCol" = NULL, "cexRow" = NULL, "cexColSide" = NULL, "cexRowSide" = NULL, colorCatCol=NULL, colorCatRow=NULL, colorContCol=NULL, colorContRow=NULL); 'cex': heatmap labels and 'cexSide': annotation labels.

file_name

string; denotes the name of the file, must contain one of the following file types: .pdf, .jpeg, .png, .tiff; default is NULL.

h_title

string; gives the heatmap output a title; default is NULL.

input_legend

boolean (T, F); to display annotations legend; row, column or both will be added if selected; default is FALSE.

legend_title

string; denotes the title of the legend; default is NULL.

plotHeatmap

logical indicating if heatmap will be plotted; defaults to TRUE.

heatmap_color

character vector of length 3; colors for high, low and middle values respectively; default is c("red","blue","grey").

zlm

numeric vector of length 2; the minimum and maximum x values for which colors should be plotted; default is c(-0.5, 0.5).

...

additional arguments.

Value

A list.


Gene expression data

Description

A numeric matrix with gene expression data with rows representing genes and columns representing subjects. ...

Usage

genomDat

Format

genomDat

A matrix with 3469 rows and 39 columns.


Hierarchical cluster analysis based on various distance methods.

Description

Computes distance matrix and then performs hierarchical clustering.

Usage

getCluster(dat, distMethod, linkMethod, absolute = F)

Arguments

dat

a numeric matrix.

distMethod

distance function.

linkMethod

agglomeration method.

absolute

a logical value. TRUE means absolute value of correlation is to be returned.

Value

an object of class "hclust".


Cosine distance based distance matrix.

Description

Computes cosine distances and returns them as a distance matrix.

Usage

getCosineDist(x)

Arguments

x

a numeric matrix.

Value

an object of class "dist".


Returns a distance matrix.

Description

Computes correlation coefficients and returns them as a distance matrix.

Usage

getDist(dat, method = "pearson", absolute = FALSE)

Arguments

dat

a numeric matrix passed to function cor.

method

a character string indicating which correlation coefficient is to be computed. One of "pearson" (default), "kendall", or "spearman": can be abbreviated.

absolute

a logical value. TRUE means absolute value of correlation is to be returned.

Value

an object of class "dist".


Cohen's kappa coefficient based distance matrix.

Description

Computes Cohen's kappa coefficients and returns them as a distance matrix.

Usage

getKappaDist(x, type = "Cohen", absolute = FALSE)

Arguments

x

a numeric matrix passed to function cor.

type

a character string indicating which correlation coefficient (or covariance) is to be computed. One of "pearson" (default), "kendall", or "spearman": can be abbreviated.

absolute

a logical value. TRUE means absolute value of correlation is to be returned.

Value

an object of class "dist".


Heatmap internal function.

Description

Called by generate_heatmap to create heatmap.

Usage

heatmap4(
  x,
  imp = TRUE,
  Rowv = NA,
  Colv = NULL,
  distfun = stats::dist,
  hclustfun = stats::hclust,
  add.expr,
  symm = FALSE,
  revC = identical(Colv, "Rowv"),
  scale = "none",
  na.rm = TRUE,
  margins = c(5, 5),
  ColSideColors,
  RowSideColors,
  cexRow = 0.2 + 1/log10(nr),
  cexCol = 0.2 + 1/log10(nc),
  fontRow = 1,
  fontCol = 1,
  labRow = NULL,
  labCol = NULL,
  lineRow = NULL,
  lineCol = NULL,
  lineColor = "black",
  totalR = nr,
  totalC = nc,
  ncr = NA,
  ncc = NA,
  main = NULL,
  xlab = NULL,
  ylab = NULL,
  verbose = getOption("verbose"),
  methodR = "ward.D",
  methodC = "ward.D",
  zlm = c(-0.5, 0.5),
  high = "green",
  low = "red",
  mid = "black",
  addAmp = NULL,
  colAmp = NULL,
  cexAmp = 0.25,
  addText = NULL,
  cexText = 1,
  lwdRect = graphics::par("lwd"),
  lwidHeatmap = 4,
  lheiHeatmap = 4,
  lwidRowSide = 0.2,
  lheiColSide = 0.2,
  cexRowSide = 1,
  cexColSide = 1,
  densColor = NULL,
  sideLabRow = 4,
  sideLabCol = 1,
  layoutRespect = T,
  sideColSide = c("left", "right"),
  sideRowSide = c("bottom", "top"),
  plotHeatmap = TRUE,
  ...
)

Arguments

x

numeric matrix of the values to be plotted.

imp

logical impute missing values if TRUE.

Rowv

determines if and how the row dendrogram should be computed and reordered. Either a dendrogram or a vector of values used to reorder the row dendrogram or NA to suppress any row dendrogram (and reordering) or by default, NULL, see ‘Details’ below.

Colv

determines if and how the column dendrogram should be reordered. Has the same options as the Rowv argument above and additionally when x is a square matrix, Colv = "Rowv" means that columns should be treated identically to the rows (and so if there is to be no row dendrogram there will not be a column one either).

distfun

function used to compute the distance (dissimilarity) between both rows and columns. Defaults to dist.

hclustfun

function used to compute the hierarchical clustering when Rowv or Colv are not dendrograms. Defaults to hclust. Should take as argument a result of distfun and return an object to which as.dendrogram can be applied.

add.expr

expression that will be evaluated after the call to image. Can be used to add components to the plot.

symm

logical indicating if x should be treated symmetrically; can only be true when x is a square matrix.

revC

logical indicating if the column order should be reversed for plotting, such that e.g., for the symmetric case, the symmetry axis is as usual.

scale

character indicating if the values should be centered and scaled in either the row direction or the column direction, or none. The default is "row" if symm false, and "none" otherwise.

na.rm

logical indicating whether NA's should be removed.

margins

numeric vector of length 2 containing the margins (see graphics::par(mar = *)) for column and row names, respectively.

ColSideColors

(optional) character vector of length ncol(x) containing the color names for a horizontal side bar that may be used to annotate the columns of x.

RowSideColors

(optional) character vector of length nrow(x) containing the color names for a vertical side bar that may be used to annotate the rows of x.

cexRow

positive number, used as cex.axis in for the row axis labeling. The default currently only uses number of rows.

cexCol

positive number, used as cex.axis in for the column axis labeling. The default currently only uses number of columns.

fontRow

positive number, used as font.axis in for the row axis labeling. The default is 1.

fontCol

positive number, used as font.axis in for the column axis labeling. The default is 1.

labRow

character vector with row labels to use; defaults to rownames(x).

labCol

character vector with column labels to use; these defaults to colnames(x).

lineRow

(optional) positive number vector, used to draw horiontal lines. The default is NULL.

lineCol

(optional) positive number vector, used to draw vertical lines. The default is NULL.

lineColor

(optional) Color of lines drawn with lineRow and lineCol.

totalR

.

totalC

.

ncr

.

ncc

.

main

main title; defaults to none.

xlab

x-axis title; defaults to none.

ylab

y-axis title; defaults to none.

verbose

logical indicating if information should be printed.

methodR

Agglomeration method for clustering rows.

methodC

Agglomeration method for clustering columns.

zlm

the minimum and maximum x values for which colors should be plotted.

high

color for high values.

low

color for low values.

mid

color for middle values.

addAmp

(optional) matrix 0s and 1s of the same size as x to be added to the heatmap.

colAmp

(optional) color of addAmp.

cexAmp

(optional) size of addAmp.

addText

(optional) character matrix of the same size as x to be added to the heatmap.

cexText

(optional) color of addText.

lwdRect

.

lwidHeatmap

.

lheiHeatmap

.

lwidRowSide

.

lheiColSide

.

cexRowSide

.

cexColSide

.

densColor

.

sideLabRow

.

sideLabCol

.

layoutRespect

.

sideColSide

.

sideRowSide

.

plotHeatmap

logical indicating if heatmap will be plotted; defaults to TRUE.

...

additional arguments passed on to image, e.g., col specifying the colors.

Value

A List.


Returns a color bar.

Description

Produces a color image (color bar) which can be used for the legend to another color image obtained from heatmap4.

Usage

heatmapColorBar(
  limit,
  cols = c("green", "red", "black"),
  main = NULL,
  marginHMCBar = NULL,
  cexAxisHMCBar = 1,
  ...
)

Arguments

limit

.

cols

.

main

.

marginHMCBar

.

cexAxisHMCBar

.

...

additional arguments.

Value

A color vector.


Phenotypic (patient information) data

Description

A data.frame containing subject information. ...

Usage

phen

Format

phen

A data.frame with 39 rows and 7 columns.


rect.hclust.my.

Description

Draws rectangles around the branches of a dendrogram highlighting the corresponding clusters. First the dendrogram is cut at a certain level, then a rectangle is drawn around selected branches.

Usage

rect.hclust.my(
  tree,
  k = NULL,
  which = NULL,
  x = NULL,
  h = NULL,
  border = 2,
  cluster = NULL,
  horiz = FALSE,
  lwd = graphics::par("lwd")
)

Arguments

tree

an object of the type produced by hclust.

k

Scalar. Cut the dendrogram such that exactly k clusters are produced.

which

A vector selecting the clusters around which a rectangle should be drawn. which selects clusters by number (from left to right in the tree). Default is which = 1:k.

x

A vector selecting the clusters around which a rectangle should be drawn. x selects clusters containing the respective horizontal coordinates.

h

Scalar. Cut the dendrogram by cutting at height h.

border

Vector with border colors for the rectangles.

cluster

Optional vector with cluster memberships as returned by stats::cutree(hclust.obj, k = k), can be specified for efficiency if already computed.

horiz

Horizontal or vertical.

lwd

Line width of the rectangles.

Value

(Invisibly) returns a list where each element contains a vector of data points contained in the respective cluster.


Returns a legend.

Description

Adds legends to row and column color bars.

Usage

sampleColorLegend(
  tls,
  col = NULL,
  lty = NULL,
  border = NULL,
  pch = NULL,
  lwd = NULL,
  legendTitle = NULL,
  cex = NULL,
  density = NULL,
  ...
)

Arguments

tls

.

col

.

lty

.

border

.

pch

.

lwd

.

legendTitle

.

cex

.

density

.

...

additional arguments.