Last data update: 2014.03.03

R: Heatmap for data with variables of mixed types
mix.heatmapR Documentation

Heatmap for data with variables of mixed types

Description

Produces a heatmap visualizing all samples and variables of a dataset. Both samples and variables are clustered using methods suitable for mixed-type data. Different types of variables are indicated by different color schemes.

Usage

mix.heatmap(data, D.subjects, D.variables, dend.subjects, dend.variables, varweights,
dist.variables.method = c("associationMeasures", "ClustOfVar"), 
associationFun = association, rowlab, rowmar = 3, lab.cex = 1.5, 
ColSideColors, RowSideColors, 
col.cont = marray::maPalette(low = "lightblue", high = "darkblue", k = 50), 
col.ord = list(low = "lightgreen", high = "darkgreen"), 
col.cat = c("indianred1","darkred","orangered","orange","palevioletred1",
          "violetred4","red3","indianred4"), 
legend.colbar, legend.rowbar, legend.mat = FALSE, legend.cex = 1)

Arguments

data

data frame where columns are variables (of different data types) and rows are observations (subjects, samples)

D.subjects

A previously calculated distance matrix (class dissimilarity for subjects can be given. If missing, it is calculated by dist.subjects. If set to NULL, no clustering is done and original order in data will be preserved.

D.variables

A previously calculated distance matrix (of class dissimilarity for variables can be given. If missing, it is calculated by dist.variables. If set to NULL, no clustering is done and original order in data will be preserved.

dend.subjects

A dendrogram for subjects can be given; then no distances between subjects will be calculated and D.subjects will be ignored.

dend.variables

A dendrogram for variables can be given; then no distances between variables will be calculated and D.variables will be ignored.

varweights

optional vector of variable weights, used for calculating Gower's distances between subjects

dist.variables.method

If "associationMeasures", similarities between variables are assessed by combination of appropriate measures of association for different pairs of data types. Then a dendrogram is derived by standard hierarchical clustering (hclust with default options). If "ClustOfVar", variables are clustered by the ClustOfVar{ClustOfVar} approach.

associationFun

By default, appropriate association measures are chosen for each pair of variables, see association for details. But the user can also define a function that for any two variables calculates a similarity measure. Ignored if dist.variables.method = "ClustOfVar"

rowlab

row (variable) labels; if missing, column names of data are used

rowmar

margin for row (variable) labels

lab.cex

size of row (variable) labels

ColSideColors

vector of length nrow(data) specifying colors for a color bar added on top of the heatmap

RowSideColors

vector of length ncol(data) specifying colors for a color bar added to the left of the heatmap

col.cont

color palette for continuous variables; defaults to red-blue color palette

col.ord

List with names of colors for the lowest and highest categories of ordinal variables. A color palette will be created correspondingly based on the number of categories. Defaults to a green color palette

col.cat

vector of colors for categorical variables

legend.colbar

class labels for subject groups defined by ColSideColors

legend.rowbar

class labels for variable groups defined by RowSideColors

legend.mat

shall legend matrix for heatmap be shown?

legend.cex

size of legend text

Details

If no dendrograms or distance matrices are given, subjects and/or samples are clustered with methods for mixed-type data. Similarities between subjects are measured by Gower's general similarity coefficient with an extension of Podani for ordinal variables, see gowdis. Similarities between variables are assessed by combination of appropriate measures of association for different pairs of data types, see association. Then standard hierarchical clustering is applied. Alternatively, variables can also be clustered by the ClustOfVar{ClustOfVar} approach.

Variables are shown as rows of the heatmap, samples as columns.

Value

A mixed-data heatmap with dendrograms and annotation

Note

The heatmap is currently limited to 200 variables = columns of data = heatmap rows.

Author(s)

Manuela Hummel, m.hummel@dkfz.de

References

Gower J (1971). A general coefficient of similarity and some of its properties. Biometrics, 27:857-871.

Chavent M, Kuentz-Simonet V, Liquet B, Saracco J (2012). ClustOfVar: An R Package for the Clustering of Variables. Journal of Statistical Software, 50:1-16.

See Also

dist.variables, dist.subjects, dendro.variables, dendro.subjects,distmap

Examples

data(mixdata)

mix.heatmap(mixdata, rowmar=7, legend.mat=TRUE)

## with (random) color bars 
colbar <- rep(5:7, nrow(mixdata))
rowbar <- rep(c("darkorange","grey"), ncol(mixdata))
mix.heatmap(mixdata, ColSideColors=colbar, RowSideColors=rowbar, 
legend.colbar=c("1","2","3"), legend.rowbar=c("a","b"), rowmar=7)

## example with variable weights
w <- rep(1:2, each=5)
mix.heatmap(mixdata, varweights=w, rowmar=7)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(CluMix)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/CluMix/mix.heatmap.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mix.heatmap
> ### Title: Heatmap for data with variables of mixed types
> ### Aliases: mix.heatmap
> ### Keywords: hplot
> 
> ### ** Examples
> 
> data(mixdata)
> 
> mix.heatmap(mixdata, rowmar=7, legend.mat=TRUE)
> 
> ## with (random) color bars 
> colbar <- rep(5:7, nrow(mixdata))
> rowbar <- rep(c("darkorange","grey"), ncol(mixdata))
> mix.heatmap(mixdata, ColSideColors=colbar, RowSideColors=rowbar, 
+ legend.colbar=c("1","2","3"), legend.rowbar=c("a","b"), rowmar=7)
> 
> ## example with variable weights
> w <- rep(1:2, each=5)
> mix.heatmap(mixdata, varweights=w, rowmar=7)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>