[R] Dealing with missing values in HeatMap generation

Sean Davis sdavis2 at mail.nih.gov
Fri Apr 7 17:59:09 CEST 2006




On 4/7/06 11:54 AM, "Himanshu Ardawatia" <Himanshu.Ardawatia at bccs.uib.no>
wrote:

> Sean Davis wrote:
> 
>> 
>> On 4/7/06 11:01 AM, "Himanshu Ardawatia" <Himanshu.Ardawatia at bccs.uib.no>
>> wrote:
>> 
>>  
>> 
>>> Hi,
>>> 
>>> I want to generate a heatmap for my data (in a matrix). However, the
>>> data has some missing values (represented as blank).
>>> I get the following errors (with the blanks and with blanks replaced by
>>> NA and including the option rm.na = TURE):
>>>    
>>> 
>>>> filename = "input_heatmap.txt"
>>>> g <- as.matrix(filedata)
>>>> fg <- rainbow(nrow(g), start=0, end=.3)
>>>> gg <- rainbow(ncol(g), start=0, end=.3)
>>>> hg <- heatmap(g, col = cm.colors(256), scale="column",na.rm = TRUE,
>>>>      
>>>> 
>>> +  RowSideColors = fg, ColSideColors = gg, margin=c(5,10),
>>> + xlab = "Average per Species", ylab= "Pathways",
>>> + main = "heatmap(<Ka/Ks Average Data per Species>, ..., scale =
>>> \"column\")")
>>> Error in heatmap(g, col = cm.colors(256), scale = "column", na.rm = TRUE,  :
>>>        'x' must be a numeric matrix
>>>    
>>> 
>> 
>> We can't see from your example what "filedata" is, so we can't tell what "g"
>> is.  
>> 
>>  
>> 
>>> Is there anyway to deal with it?
>>>    
>>> 
>> 
>> You will need to assure that "g" is a numeric matrix.
>> 
>>  
>> 
>>> Second question: What is the basis for generation of the dendrogram
>>> (over the heatmap) in the heatmap? Is it simple hierarchical clustering?
>>>    
>>> 
>> 
>> Reading the ?heatmap page will help here.  It describes what the defaults
>> for clustering actually are.
>> 
>> Sean
>> 
>>  
>> 
> Thanks for the quick reply! the data table is as follows (Here I have
> put 'NA', but I could also have just a 'space' in other files): Please see.
> 
>     mouse    mouse1    rat    rat1    human    human1    chimp
> path1    0.12    0.32    0.48    1.2    0.67    0.58    0.01
> path2    0.13    0.90    0.09    1.6    0.23    0.50    0.09
> path3    0.20    0.32    0.05    0.45    0.89    0.34    0.04
> path4    0.23    0.65    0.92    0.67    0.78    0.78    0.91
> path5    0.89    0.01    0.01    1.01    'NA'    0.98    0.79
> path6    0.78    0.32    0.13    1.99    0.54    0.08    0.56
> path7    0.34    0.54    'NA'    0.32    0.70    0.45    0.34
> path8    0.15    0.86    0.85    0.56    0.97    0.86    0.11
> path9    0.10    0.12    0.08    2.01    0.37    0.57    0.04
> 

But from your code above, you never load these data.

Sean




More information about the R-help mailing list