heatmap.2(gplots)
heatmap.2()所属R语言包:gplots
Enhanced Heat Map
强化传热图
译者:生物统计家园网 机器人LoveR
描述----------Description----------
A heat map is a false color image (basically image(t(x))) with a dendrogram added to the left side and/or 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.
热图是一个树状的左侧和/或顶端的假彩色图像(基本上是image(t(x)))。通常情况下,树状图所施加的限制内的值(行或列的单元)中的一些组所述的行和列进行重排序。
This heatmap provides a number of extensions to the standard R heatmap function.
热图的扩展提供了一些标准的Rheatmap函数。
用法----------Usage----------
heatmap.2 (x,
# dendrogram control
Rowv = TRUE,
Colv=if(symm)"Rowv" else TRUE,
distfun = dist,
hclustfun = hclust,
dendrogram = c("both","row","column","none"),
symm = FALSE,
# data scaling
scale = c("none","row", "column"),
na.rm=TRUE,
# image plot
revC = identical(Colv, "Rowv"),
add.expr,
# mapping data to colors
breaks,
symbreaks=min(x < 0, na.rm=TRUE) || scale!="none",
# colors
col="heat.colors",
# block sepration
colsep,
rowsep,
sepcolor="white",
sepwidth=c(0.05,0.05),
# cell labeling
cellnote,
notecex=1.0,
notecol="cyan",
na.color=par("bg"),
# level trace
trace=c("column","row","both","none"),
tracecol="cyan",
hline=median(breaks),
vline=median(breaks),
linecol=tracecol,
# Row/Column Labeling
margins = c(5, 5),
ColSideColors,
RowSideColors,
cexRow = 0.2 + 1/log10(nr),
cexCol = 0.2 + 1/log10(nc),
labRow = NULL,
labCol = NULL,
# color key + density info
key = TRUE,
keysize = 1.5,
density.info=c("histogram","density","none"),
denscol=tracecol,
symkey = min(x < 0, na.rm=TRUE) || symbreaks,
densadj = 0.25,
# plot labels
main = NULL,
xlab = NULL,
ylab = NULL,
# plot layout
lmat = NULL,
lhei = NULL,
lwid = NULL,
# extras
...
)
参数----------Arguments----------
参数:x
numeric matrix of the values to be plotted.
数值矩阵的值被绘制。
参数:Rowv
determines if and how the row dendrogram should be reordered. By default, it is TRUE, which implies dendrogram is computed and reordered based on row means. If NULL or FALSE, then no dendrogram is computed and no reordering is done. If a dendrogram, then it is used "as-is", ie without any reordering. If a vector of integers, then dendrogram is computed and reordered based on the order of the vector.
决定是否和如何应重新排序的行聚类分析。默认情况下,这是事实,这意味着聚类分析计算和存储将基于行的手段。如果为NULL或FALSE,则没有聚类分析计算,并没有进行重新排序。如果dendrogram,然后是“是”,即没有任何重新排序。如果一个矢量的整数,然后树状图的计算,并重新排列的顺序的基础上的矢量。
参数:Colv
determines if and how the column dendrogram should be reordered. Has the 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.
决定是否以及如何应重新排序列树状图。 Rowv上述论点,另外的选项时x是一个正方形矩阵,Colv = "Rowv"的是指应被视为相同的行,列。
参数:distfun
function used to compute the distance (dissimilarity) between both rows and columns. Defaults to dist.
函数,用于计算两个行和列之间的距离(相异)。默认为dist的。
参数:hclustfun
function used to compute the hierarchical clustering when Rowv or Colv are not dendrograms. Defaults to hclust.
函数用来计算的层次聚类Rowv或Colv不树状图。默认为hclust的。
参数:dendrogram
character string indicating whether to draw 'none', 'row', 'column' or 'both' dendrograms. Defaults to 'both'. However, if Rowv (or Colv) is FALSE or NULL and dendrogram is 'both', then a warning is issued and Rowv (or Colv) arguments are honoured.
字符串指示是否绘制没有,行,列或所有人树状图。默认为两个。然而,,如果Rowv(,或Colv)是FALSE或NULL和聚类分析是“都”,就会出现一个警告发出和Rowv(,或Colv)参数很荣幸的。
参数:symm
logical indicating if x should be treated symmetrically; can only be true when x is a square matrix.
逻辑表明,如果x应该被视为对称的,只能是真实的,当x是一个正方形矩阵。
参数: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.
字符,指示如果值应为中心和缩放的行方向或列方向上,或根本没有。默认值是"row"如果symm假的,"none"否则。
参数:na.rm
logical indicating whether NA's should be removed.
逻辑NA的指示是否应该被删除。
参数: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.
逻辑表明,如果列的顺序应该是reversed的图,这样说,例如,为对称的情况下,对称轴是像往常一样。
参数:add.expr
expression that will be evaluated after the call to image. Can be used to add components to the plot.
表达式将被评估后,调用image。可用于将组件添加到图。
参数:breaks
(optional) Either a numeric vector indicating the splitting points for binning x into colors, or a integer number of break points to be used, in which case the break points will be spaced equally between min(x) and max(x).
(可选的),要么是数字矢量指示的分裂点的像素合并x到颜色,要使用的中断点或整数,在这种情况下,在中断点将等距离间隔之间min(x)和 max(x)。
参数:symbreaks
Boolean indicating whether breaks should be made symmetric about 0. Defaults to TRUE if the data includes negative values, and to FALSE otherwise.
布尔值,指示是否中断,应对称约0。默认为TRUE如果数据包括负值,并FALSE否则。
参数:col
colors used for the image. Defaults to heat colors (heat.colors).
所使用的颜色的图像。默认为热色(heat.colors)。
参数:colsep, rowsep, sepcolor
(optional) vector of integers indicating which columns or rows should be separated from the preceding columns or rows by a narrow space of color sepcolor.
()向量整数列或行应分开从前面的列或行的狭小空间内的颜色sepcolor。
参数:sepwidth
(optional) Vector of length 2 giving the width (colsep) or height (rowsep) the separator box drawn by colsep and rowsep as a function of the width (colsep) or height (rowsep) of a cell. Defaults to c(0.05, 0.05)
(可选)向量的长度为2给予的宽度(colsep)或的高度(rowsep)绘制由colsep和rowsep的的宽度(colsep)作为一个功能或的高度(rowsep)的小区的隔板框。默认为c(0.05, 0.05)
参数:cellnote
(optional) matrix of character strings which will be placed within each color cell, e.g. p-value symbols.
矩阵(可选)将被放置在每一个色彩单元的字符串,例如p-值的符号。
参数:notecex
(optional) numeric scaling factor for cellnote items.
(可选)数字缩放因子cellnote项目。
参数:notecol
(optional) character string specifying the color for cellnote text. Defaults to "green".
(可选)字符串指定cellnote文字的颜色。默认为“绿色”。
参数:na.color
Color to use for missing value (NA). Defaults to the plot background color.
使用的颜色缺失值(NA“)。默认的图背景颜色。
参数:trace
character string indicating whether a solid "trace" line should be drawn across 'row's or down 'column's, 'both' or 'none'. The distance of the line from the center of each color-cell is proportional to the size of the measurement. Defaults to 'column'.
字符串,表示一个坚实的“跟踪”线应画在“行或向下”列的,“都”或“无”。从每种颜色的小区的中心的线之间的距离成比例的大小的测量。默认为“列”。
参数:tracecol
character string giving the color for "trace" line. Defaults to "cyan".
“跟踪”行字符串的颜色。默认为“青色”。
参数:hline, vline, linecol
Vector of values within cells where a horizontal or vertical dotted line should be drawn. The color of the line is controlled by linecol. Horizontal lines are only plotted if trace is 'row' or 'both'. Vertical lines are only drawn if trace 'column' or 'both'. hline and vline default to the median of the breaks, linecol defaults to the value of tracecol.
向量的单元内的值,其中应绘制的水平或垂直的虚线。颜色的线是由linecol。如果只绘制水平线trace是行或所有人。只画垂直线trace列或都。 hline和vline默认情况下,截断的中位数,linecol的价值tracecol默认。
参数:margins
numeric vector of length 2 containing the margins (see par(mar= *)) for column and row names, respectively.
数字矢量长度为2的边缘(见par(mar= *))列名和列名,分别。
参数: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.
(可选)字符向量,长度为ncol(x)含有可以用于标注的列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.
(可选)字符向量,长度为nrow(x)包含可用于注释行x的垂直边栏的颜色名称。
参数:cexRow, cexCol
positive numbers, used as cex.axis in for the row or column axis labeling. The defaults currently only use number of rows or columns, respectively.
正数,作为cex.axis中的行或列轴标签。默认值目前只使用数量的行或列。
参数:labRow, labCol
character vectors with row and column labels to use; these default to rownames(x) or colnames(x), respectively.
特征向量与使用的行和列标签;这些默认rownames(x)或colnames(x),分别。
参数:key
logical indicating whether a color-key should be shown.
逻辑表明是否应该显示的颜色键。
参数:keysize
numeric value indicating the size of the key
数字值,该值指示的大小的关键
参数:density.info
character string indicating whether to superimpose a 'histogram', a 'density' plot, or no plot ('none') on the color-key.
字符串指示是否叠加“直方图”,“密度”图,或没有图(“无”)上的颜色键。
参数:denscol
character string giving the color for the density display specified by density.info, defaults to the same value as tracecol.
的密度为相同的值作为density.infotracecol,默认显示指定的字符串的颜色。
参数:symkey
Boolean indicating whether the color key should be made symmetric about 0. Defaults to TRUE if the data includes negative values, and to FALSE otherwise.
布尔值,指示是否应在0对称的颜色键。默认为TRUE如果数据包括负值,并FALSE否则。
参数:densadj
Numeric scaling value for tuning the kernel width when a density plot is drawn on the color key. (See the adjust parameter for the density function for details.) Defaults to 0.25.
数字缩放值调整内核的宽度时,密度图上绘制的颜色键。 (adjust功能的详细信息,请参阅density参数),默认为0.25。
参数:main, xlab, ylab
main, x- and y-axis titles; defaults to none.
主,X轴和Y轴标题,默认为none。
参数:lmat, lhei, lwid
visual layout: position matrix, column height, column width. See below for details
可视化的布局:位置矩阵,列高,列宽。有关详细信息,请参阅下面的
参数:...
additional arguments passed on to image </table>
额外的参数传递给image</ TABLE>
Details
详细信息----------Details----------
If either Rowv or Colv are dendrograms they are honored (and not reordered). Otherwise, dendrograms are computed as dd <- as.dendrogram(hclustfun(distfun(X))) where X is either x or t(x).<br>
如果是Rowv或Colv是树状图,他们很荣幸(而不是重新排序)。否则,树状图计算dd <- as.dendrogram(hclustfun(distfun(X)))X是x或t(x)。<BR>
If either is a vector (of “weights”) then the appropriate dendrogram is reordered according to the supplied values subject to the constraints imposed by the dendrogram, by reorder(dd, Rowv), in the row case. If either is missing, as by default, then the ordering of the corresponding dendrogram is by the mean value of the rows/columns, i.e., in the case of rows, Rowv <- rowMeans(x, na.rm=na.rm). If either is NULL, no reordering will be done for the corresponding side.
要么是一个向量(“权重”),那么相应的聚类分析是根据所提供的值受限制树状图重新排序,reorder(dd, Rowv),在该行的情况。默认情况下,如果任何一个缺失,那么相应的树形图的排序是由平均值的行/列,即,在的情况下的行,Rowv <- rowMeans(x, na.rm=na.rm)。如果其中一个是NULL,没有重新排序将做相应的。
If scale="row" the rows are scaled to have mean zero and standard deviation one. There is some empirical evidence from genomic plotting that this is useful.
scale="row"如果行扩展到等于0,标准差。有一些从基因组的绘制,这是非常有用的经验证据。
The default colors range from red to white (heat.colors) and are not pretty. Consider using enhancements such as the RColorBrewer package, http://cran.r-project.org/src/contrib/PACKAGES.html#RColorBrewer to select better colors.
的默认颜色范围从红色到白色(heat.colors)和不漂亮。考虑使用RColorBrewer包,http://cran.r-project.org/src/contrib/PACKAGES.html RColorBrewer选择更好的颜色,如增强。
By default four components will be displayed in the plot. At the top left is the color key, top right is the column dendogram, bottom left is the row dendogram, bottom right is the image plot. When RowSideColor or ColSideColor are provided, an additional row or column is inserted in the appropriate location. This layout can be overriden by specifiying appropriate values for lmat, lwid, and lhei. lmat controls the relative postition of each element, while lwid controls the column width, and lhei controls the row height. See the help page for layout for details on how to use these arguments.
在默认情况下,将显示四部分组成的图。在左上角的颜色键,右上方是列dendogram,左下方是行dendogram,右下角是图像的图。当RowSideColor或ColSideColor,在适当的位置插入一个额外的行或列。这样的布局可覆盖通过specifiying适当的值lmat,lwid和lhei。 lmat控制的相对姿的每一个元素,而lwid控制列宽度,和lhei控制行的高度。关于如何使用这些参数的详细信息,请参阅帮助页面layout。
值----------Value----------
Invisibly, a list with components
不可见的,与组件的列表
参数:rowInd
row index permutation vector as returned by order.dendrogram.
行指标置换矢量返回的order.dendrogram。
参数:colInd
column index permutation vector.
列索引置换矢量。
参数:call
the matched call
匹配的呼叫
参数:rowMeans, rowSDs
mean and standard deviation of each row: only present if scale="row"
每一行的平均值和标准偏差:只存在scale="row"
参数:colMeans, colSDs
mean and standard deviation of each column: only present if scale="column"
每一列的平均值和标准偏差:只存在scale="column"
参数:carpet
reordered and scaled 'x' values used generate the main 'carpet'
重新排列和缩放x值产生的主要“地毯”
参数:rowDendrogram
row dendrogram, if present
行聚类分析,如果存在
参数:colDendrogram
column dendrogram, if present
列树状图,如果存在
参数:breaks
values used for color break points
使用彩色破发点的值
参数:col
colors used
使用的颜色
参数:vline
center-line value used for column trace, present only if trace="both" or trace="column"
中心线的列的值,用于跟踪,目前只有trace="both"或trace="column"
参数:hline
center-line value used for row trace, present only if trace="both" or trace="row"
中心线的值用于行跟踪,目前只有trace="both"或trace="row"
参数:colorTable
A three-column data frame providing the lower and upper bound and color for each bin
一个三列的数据框提供的上限和下限,并为每个垃圾桶的颜色
注意----------Note----------
The original rows and columns are reordered in any case to match the dendrogram, e.g., the rows by order.dendrogram(Rowv) where Rowv is the (possibly reorder()ed) row dendrogram.
在任何情况下,原来的行和列重新排序相匹配的聚类分析,例如,行order.dendrogram(Rowv)其中Rowv是(可能reorder()版)行聚类分析。
heatmap.2() uses layout and draws the image in the lower right corner of a 2x2 layout. Consequentially, it can not be used in a multi column/row layout, i.e., when par(mfrow= *) or (mfcol= *) has been called.
heatmap.2()使用layout和绘制image在右下角的2x2布局。作出相应的是,它不能被用于在一个多列/行的布局,即,当par(mfrow= *)或(mfcol= *)已调用。
(作者)----------Author(s)----------
Andy Liaw, original; R. Gentleman, M. Maechler, W. Huber,
G. Warnes, revisions.
参见----------See Also----------
image, hclust
image,hclust
实例----------Examples----------
library(gplots)
data(mtcars)
x <- as.matrix(mtcars)
rc <- rainbow(nrow(x), start=0, end=.3)
cc <- rainbow(ncol(x), start=0, end=.3)
##[#]
## demonstrate the effect of row and column dendogram options[#演示的效果的行和列dendogram选项]
##[#]
heatmap.2(x) ## default - dendrogram plotted and reordering done. [#默认 - 树状图的绘制和重新排序完成。]
heatmap.2(x, dendrogram="none") ## no dendrogram plotted, but reordering done.[#无的树状图绘制,但重新排序完成。]
heatmap.2(x, dendrogram="row") ## row dendrogram plotted and row reordering done.[#行树状图的绘制和行重新排序完成。]
heatmap.2(x, dendrogram="col") ## col dendrogram plotted and col reordering done.[#山坳树状图的绘制和完成山坳重新排序的。]
heatmap.2(x, keysize=2) ## default - dendrogram plotted and reordering done.[#默认 - 树状图的绘制和重新排序完成。]
heatmap.2(x, Rowv=FALSE, dendrogram="both") ## generate warning![#生成警告!]
heatmap.2(x, Rowv=NULL, dendrogram="both") ## generate warning![#生成警告!]
heatmap.2(x, Colv=FALSE, dendrogram="both") ## generate warning![#生成警告!]
## [#]
## Show effect of z-score scaling within columns, blue-red color scale[#显示效果Z-得分缩放的列内,蓝色,红色规模]
##[#]
hv <- heatmap.2(x, col=bluered, scale="column", tracecol="#303030")[303030“)]
###[##]
## Look at the return values[#看看的返回值]
###[##]
names(hv)
## Show the mapping of z-score values to color bins[#显示图的z分数值,色桶]
hv$colorTable
## Extract the range associated with white[#提取的范围与白]
hv$colorTable[hv$colorTable[,"color"]=="#FFFFFF",][FFFFFF“]]
## Determine the original data values that map to white[#确定的原始数据值映射到白色]
whiteBin <- unlist(hv$colorTable[hv$colorTable[,"color"]=="#FFFFFF",1:2])[FFFFFF“,1:2])]
rbind(whiteBin[1] * hv$colSDs + hv$colMeans,
whiteBin[2] * hv$colSDs + hv$colMeans )
##[#]
## A more decorative heatmap, with z-score scaling along columns[#A更具装饰性的热图,沿列z分数比例]
##[#]
hv <- heatmap.2(x, col=cm.colors(255), scale="column",
RowSideColors=rc, ColSideColors=cc, margin=c(5, 10),
xlab="specification variables", ylab= "Car Models",
main="heatmap(<Mtcars data>, ..., scale=\"column\")",
tracecol="green", density="density")
## Note that the breakpoints are now symmetric about 0[#请注意,现在的断点0对称的]
data(attitude)
round(Ca <- cor(attitude), 2)
symnum(Ca) # simple graphic[简单的图形]
# with reorder[与重新排序]
heatmap.2(Ca, symm=TRUE, margin=c(6, 6), trace="none" )
# without reorder[没有重新排序]
heatmap.2(Ca, Rowv=FALSE, symm=TRUE, margin=c(6, 6), trace="none" )
## Place the color key below the image plot[#将颜色键下方的形象图]
heatmap.2(x, lmat=rbind( c(0, 3), c(2,1), c(0,4) ), lhei=c(1.5, 4, 2 ) )
## Place the color key to the top right of the image plot[#将彩色键右上方的形象图]
heatmap.2(x, lmat=rbind( c(0, 3, 4), c(2,1,0 ) ), lwid=c(1.5, 4, 2 ) )
## For variable clustering, rather use distance based on cor():[#变量聚类,而根据相应的使用距离():]
data(USJudgeRatings)
symnum( cU <- cor(USJudgeRatings) )
hU <- heatmap.2(cU, Rowv=FALSE, symm=TRUE, col=topo.colors(16),
distfun=function(c) as.dist(1 - c), trace="none")
## The Correlation matrix with same reordering:[#的相关系数矩阵具有相同的重新排序:]
hM <- format(round(cU, 2))
hM
# now with the correlation matrix on the plot itself[现在随着图本身的相关性矩阵]
heatmap.2(cU, Rowv=FALSE, symm=TRUE, col=rev(heat.colors(16)),
distfun=function(c) as.dist(1 - c), trace="none",
cellnote=hM)
## genechip data examples[#基因芯片数据的例子]
## Not run: [#不运行:]
library(affy)
data(SpikeIn)
pms <- SpikeIn@pm
# just the data, scaled across rows[只是数据,缩放整个行]
heatmap.2(pms, col=rev(heat.colors(16)), main="SpikeIn@pm",
xlab="Relative Concentration", ylab="Probeset",
scale="row")
# fold change vs "12.50" sample[倍比“12.50”样品]
data <- pms / pms[, "12.50"]
data <- ifelse(data>1, data, -1/data)
heatmap.2(data, breaks=16, col=redgreen, tracecol="blue",
main="SpikeIn@pm Fold Changes\nrelative to 12.50 sample",
xlab="Relative Concentration", ylab="Probeset")
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|