[R] heatmap.2() problems with re-ordering of rows and columns

bioinformatics_guy wwwhitener at gmail.com
Thu Sep 17 15:53:44 CEST 2009


Schalk, 

Thats a great function! The only question is, is it as flexible as
heatmap.2?

I figured out how to get it from rearranging the rows and columns but I
can't figure out how to label the rows and columns? What I like about the
heatmap.2 is that it gives a grid and histogram of the heatmap which is
nice.

I'm trying to 

library(gplots)
data=read.table("filein.txt",header=FALSE)
mat=as.matrix(data)
heatmap.2(mat,dendrogram=c("none"),trace=c("none"),Rowv=F,Colv=F)

which works but labels my columns V1 thru V21 and rows 1-21.  Id like them
to be different an under the man pages for heatmap.2 it states:

                         # 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,

So I'm adding cexRow=30-3(nr) (as I want it to decrement by 3 for each row
but R spits back an error say nr is not recognized.  I was looking at other
help pages but couldn't find out how to lable the axis the way I wanted to. 

Schalk Heunis wrote:
> 
> Hi bioinformatics_guy
> I think you are looking for the "image" function:
> image(mat)
> 
> The heatmap.2 function does hierarchical clustering on rows and columns
> and
> then orders the rows and columns according to the results of the
> clustering.
>  Image simply plots the matrix.
> 
> HTH
> Schalk Heunis
> 
> 
> On Thu, Sep 17, 2009 at 2:23 PM, bioinformatics_guy
> <wwwhitener at gmail.com>wrote:
> 
>>
>> I have a file of the following form
>>
>> -11 -10 -9 -8
>> -10 -9   -8   NA
>> -9   -7    NA NA
>> -8    NA  NA NA
>>
>> So basically a NxN matrix of log scores.  I want to get a heatmap of
>> these
>> log scores but I'm having a problem.
>>
>> I'm using the following code
>>
>> library(gplots)
>> data=read.table("filein.txt",header=FALSE)
>> mat=as.matrix(data)
>> heatmap.2(mat,dendrogram=c("none"))
>>
>> But on the picture, it rearranges all my row,columns.  I want it the y
>> axis
>> to be labeled from [10,-10] and the x axis to be the same [-10,10] so
>> that
>> the bottom left cell is -10,-10 and the top right cell is 10,10 -- which
>> is
>> the way the matrix is laid out.  Why is it rearranging my cells?
>>
>> --
>> View this message in context:
>> http://www.nabble.com/heatmap.2%28%29-problems-with-re-ordering-of-rows-and-columns-tp25490249p25490249.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: http://www.nabble.com/heatmap.2%28%29-problems-with-re-ordering-of-rows-and-columns-tp25490249p25491683.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list