The function heatmap() allows to specify row/column labels
via the options labRow/labCol. From the code of heatmap(),
I understand that when no labels are specified, the row/column
labels (or indices) of the input matrix are taken as labels and
re-ordered together with the rows and columns of the matrix before
plotting, whereas labels supplied via labRow/labCol are plotted
in the original order.
Code from heatmap(), R 1.8.1:
x <- x[rowInd, colInd]
if (is.null(labRow))
labRow <- if (is.null(rownames(x)))
(1:nr)[rowInd]
else rownames(x)
if (is.null(labCol))
labCol <- if (is.null(colnames(x)))
(1:nc)[colInd]
else colnames(x)
...
axis(1, 1:nc, labels = labCol, las = 2, line = -0.5, tick = 0,
cex.axis = cexCol)
axis(4, iy, labels = labRow, las = 2, line = -0.5, tick = 0,
cex.axis = cexRow)
To see an example, try
a <- matrix(c(1,1,1,2,0,2), nrow=3)
rownames(a) <- 1:3
x11()
heatmap(a)
x11()
heatmap(a, labRow=rownames(a))
Is this really meant to work like this? - From
the help of heatmap(), one might expect also user-supplied
labels to be re-ordered together with the rows and
columns of the matrix.
Cheers,
Anja
--
Dr. Anja von Heydebreck
Max Planck Institute for Molecular Genetics
Dept. Computational Molecular Biology
Ihnestr. 73
14195 Berlin, Germany
heydebre at molgen.mpg.de phone: +49-30-8413-1168
http://www.molgen.mpg.de/~heydebre fax: +49-30-8413-1152
{I'm vading through old "todo" e-mails...}
>>>>> "Anja" == Anja von Heydebreck <heydebre at
molgen.mpg.de>
>>>>> on Mon, 16 Feb 2004 11:41:13 +0100 writes:
Anja> The function heatmap() allows to specify row/column labels
Anja> via the options labRow/labCol. From the code of heatmap(),
Anja> I understand that when no labels are specified, the row/column
Anja> labels (or indices) of the input matrix are taken as labels and
Anja> re-ordered together with the rows and columns of the matrix before
Anja> plotting, whereas labels supplied via labRow/labCol are plotted
Anja> in the original order.
<..........>
Anja> To see an example, try
Anja> a <- matrix(c(1,1,1,2,0,2), nrow=3)
Anja> rownames(a) <- 1:3
Anja> x11()
Anja> heatmap(a)
Anja> x11()
Anja> heatmap(a, labRow=rownames(a))
Anja> Is this really meant to work like this? - From
Anja> the help of heatmap(), one might expect also user-supplied
Anja> labels to be re-ordered together with the rows and
Anja> columns of the matrix.
Yes, indeed -- and as you suggest, the current behavior is not
what it should be.
This is being fixed in R-patched aka "R 1.9.1 alpha" (to be
1.9.1 later this month).
Thanking you for the clear report,
Martin Maechler