Abstract: The
function heatmap.2() in the R package ‘gplots’ provides a number
of extensions to the default R function heatmap().
Here is the options
in heatmap.2().
heatmap.2 (x,
# dendrogram control
Rowv = TRUE,
Colv=if(symm)"Rowv" else TRUE,
distfun = dist,
hclustfun = hclust,
dendrogram = c("both","row","column","none"),
reorderfun = function(d, w) reorder(d, w),
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=any(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,
srtRow = NULL,
srtCol = NULL,
adjRow = c(0,NA),
adjCol = c(NA,0),
offsetRow = 0.5,
offsetCol = 0.5,
colRow = NULL,
colCol = NULL,
# color key + density info
key = TRUE,
keysize = 1.5,
density.info=c("histogram","density","none"),
denscol=tracecol,
symkey = any(x < 0, na.rm=TRUE) || symbreaks,
densadj = 0.25,
key.title = NULL,
key.xlab = NULL,
key.ylab = NULL,
key.xtickfun = NULL,
key.ytickfun = NULL,
key.par=list(),
# plot labels
main = NULL,
xlab = NULL,
ylab = NULL,
# plot layout
lmat = NULL,
lhei = NULL,
lwid = NULL,
# extras
extrafun=NULL,
...
)
Here is the default output by heatmap.2(). The colorful bar is added
in heatmap.2().
> library(gplots)
> x<-as.matrix(scale(mtcars))
> #the dafault output
> heatmap.2(x)
#the color palette
my_palette <- colorRampPalette(c("yellow", "white",
'red'))(n = 100)
heatmap.2(x, col=my_palette)
#z scores instead of values
>heatmap.2(x, col=my_palette, scale='row')
#turn off trace
>heatmap.2(x, col=my_palette, scale='row', trace='none')
#other clustering methods
>dist.pear <- function(x) as.dist(1-cor(t(x)))
>hclust.ave <- function(x) hclust(x, method="average")
>heatmap.2(x, col=my_palette, scale='row', trace='none',
distfun=dist.pear, hclust=hclust.ave)
The heatmap by groups using the options ColSideColors or
RowSideColors.
#heatmap by group
>library("ALL")
>data("ALL")
>eset <- ALL[, ALL$mol.biol %in% c("BCR/ABL",
"ALL1/AF4")]
>f <- factor(as.character(eset$mol.biol))
>design <- model.matrix(~f)
>fit <- eBayes(lmFit(eset,design))
>selected <- p.adjust(fit$p.value[, 2]) <0.05
>esetSel <- eset [selected, ]
>color.map <- function(mol.biol) { if (mol.biol=="ALL1/AF4")
"blue" else "red" }
>patientcolors <- unlist(lapply(esetSel$mol.bio, color.map))
#
>heatmap.2(exprs(esetSel), col=my_palette,
ColSideColors=patientcolors, trace='none')
writing date: 20150122
No comments:
Post a Comment