Re: [Rd] (PR#7972) row-side color bars ... in heatmap

From: <maechler_at_stat.math.ethz.ch>
Date: Wed 29 Jun 2005 - 14:48:59 GMT


Hi Kevin,

>>>>> "krc" == krc <krc@odin.mdacc.tmc.edu>
>>>>> on Mon, 27 Jun 2005 21:55:37 +0200 (CEST) writes:

    krc> Full_Name: Kevin R. Coombes
    krc> Version: 2.1.0
    krc> OS: Windows XP
    krc> Submission from: (NULL) (143.111.224.169)


    krc> When revC = TRUE and RowSideColors is set to a list of
    krc> colors in heatmap, then the image and dendrogram are
    krc> inverted, but the row-side color map does not     krc> change. The following script illustrates the problem.
    krc> ##############
    krc> set.seed(1023)
    krc> # generate columns of two different types
    krc> d1 <- matrix(rnorm(100*6, rnorm(100, 0.5)), nrow=100, ncol=6, byrow=FALSE)
    krc> d2 <- matrix(rnorm(100*4, rnorm(100, 0.5)), nrow=100, ncol=4, byrow=FALSE)
    krc> # join them together
    krc> dd <- cbind(d1, d2)
    krc> # label them with different colors
    krc> cols <- rep(c('blue', 'green'), times=c(6,4))

    krc> # change the order of the columns and the matching labels
    krc> # to show that reordering occurs in one case in heatmap
    krc> col.order <- sample(10)

    krc> dd <- dd[, col.order]
    krc> cols <- cols[col.order]

    krc> # compute the dendrogram to be used in the display     krc> hc <- hclust(dist(dd, 'euclid'))

a clustering of 100 observational units

    krc> # get the correlation matrix
    krc> m <- cor(dd)

a 10 x 10 matrix ; i.e. 10 row units and 10 column units.

Hence the following never works,
at least not for the heatmap() function as in ``standard R''.

    krc> # this version works correctly
    krc> heatmap(m, Rowv=as.dendrogram(hc), symm=TRUE, revC=FALSE, RowSideColors=cols)

gives immediately the obvious error

 Error in heatmap(m, Rowv = ............ :

         row dendrogram ordering gave index of wrong length

    krc> #this version reverses the dendrogram and image, but not the colors
    krc> heatmap(m, Rowv=as.dendrogram(hc), symm=TRUE, revC=TRUE,
    krc> RowSideColors=cols)

so I wonder what you did want.

Regards,
Martin



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Thu Jun 30 00:51:51 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:09 GMT