Dear R community! I am trying to create a heatmap based on the following data. As you can see the diagonal (0,0 to 10,10) is always 0). If I run the heatmap command like i posted it I get a graph with horizontal lines. What is my mistake?> heatmap(activity.matrix, Rowv = NA, Colv = NA, scale="column", xlab="x Compounds", ylab="y Compounds", col=topo.colors(100)) > activity.matrix[,1] [,2] [,3] [,4] [,5] [,6] [1,] 0.0000000 -0.1017802 0.3635007 0.62522118 0.8869417 -0.4652809 [2,] 0.1017802 0.0000000 0.4652809 0.72700138 0.9887219 -0.3635007 [3,] -0.3635007 -0.4652809 0.0000000 0.26172050 0.5234410 -0.8287816 [4,] -0.6252212 -0.7270014 -0.2617205 0.00000000 0.2617205 -1.0905021 [5,] -0.8869417 -0.9887219 -0.5234410 -0.26172050 0.0000000 -1.3522226 [6,] 0.4652809 0.3635007 0.8287816 1.09050206 1.3522226 0.0000000 [7,] -0.2471805 -0.3489607 0.1163202 0.37804072 0.6397612 -0.7124613 [8,] 1.0032619 0.9014817 1.3667626 1.62848308 1.8902036 0.5379810 [9,] -0.6833813 -0.7851615 -0.3198806 -0.05816011 0.2035604 -1.1486622 [10,] 1.0759620 0.9741818 1.4394627 1.70118322 1.9629037 0.6106812 [,7] [,8] [,9] [,10] [1,] 0.2471805 -1.00326190 0.68338129 -1.07596204 [2,] 0.3489607 -0.90148171 0.78516149 -0.97418184 [3,] -0.1163202 -1.36676259 0.31988061 -1.43946272 [4,] -0.3780407 -1.62848308 0.05816011 -1.70118322 [5,] -0.6397612 -1.89020358 -0.20356039 -1.96290371 [6,] 0.7124613 -0.53798102 1.14866217 -0.61068116 [7,] 0.0000000 -1.25044237 0.43620083 -1.32314250 [8,] 1.2504424 0.00000000 1.68664319 -0.07270014 [9,] -0.4362008 -1.68664319 0.00000000 -1.75934333 [10,] 1.3231425 0.07270014 1.75934333 0.00000000 Thanks in advance. Greets, Markus
2009/7/20 Markus M?hlbacher <muehliman at yahoo.com>:> What is my mistake?I don't know about the heatmap function, but I have often used 'image' with 'heat.colors' without any problems. There is a nice example here: http://addictedtor.free.fr/graphiques/graphcode.php?graph=20 It should be fairly easy to fit your data into that one. I guess that this should work: x = 1:length(activity.matrix) y = 1:length(activity.matrix) image(x, y, activity.matrix, col=heat.colors(100)) -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
since heatmap is a graphic image it needs the "graphics" library. you can see these two in the examples for heatmap. require(graphics); require(grDevices) Markus M?hlbacher wrote:> > Dear R community! > > I am trying to create a heatmap based on the following data. As you can > see the diagonal (0,0 to 10,10) is always 0). If I run the heatmap command > like i posted it I get a graph with horizontal lines. > > What is my mistake? > >> heatmap(activity.matrix, Rowv = NA, Colv = NA, scale="column", xlab="x >> Compounds", ylab="y Compounds", col=topo.colors(100)) >> activity.matrix > [,1] [,2] [,3] [,4] [,5] [,6] > [1,] 0.0000000 -0.1017802 0.3635007 0.62522118 0.8869417 -0.4652809 > [2,] 0.1017802 0.0000000 0.4652809 0.72700138 0.9887219 -0.3635007 > [3,] -0.3635007 -0.4652809 0.0000000 0.26172050 0.5234410 -0.8287816 > [4,] -0.6252212 -0.7270014 -0.2617205 0.00000000 0.2617205 -1.0905021 > [5,] -0.8869417 -0.9887219 -0.5234410 -0.26172050 0.0000000 -1.3522226 > [6,] 0.4652809 0.3635007 0.8287816 1.09050206 1.3522226 0.0000000 > [7,] -0.2471805 -0.3489607 0.1163202 0.37804072 0.6397612 -0.7124613 > [8,] 1.0032619 0.9014817 1.3667626 1.62848308 1.8902036 0.5379810 > [9,] -0.6833813 -0.7851615 -0.3198806 -0.05816011 0.2035604 -1.1486622 > [10,] 1.0759620 0.9741818 1.4394627 1.70118322 1.9629037 0.6106812 > [,7] [,8] [,9] [,10] > [1,] 0.2471805 -1.00326190 0.68338129 -1.07596204 > [2,] 0.3489607 -0.90148171 0.78516149 -0.97418184 > [3,] -0.1163202 -1.36676259 0.31988061 -1.43946272 > [4,] -0.3780407 -1.62848308 0.05816011 -1.70118322 > [5,] -0.6397612 -1.89020358 -0.20356039 -1.96290371 > [6,] 0.7124613 -0.53798102 1.14866217 -0.61068116 > [7,] 0.0000000 -1.25044237 0.43620083 -1.32314250 > [8,] 1.2504424 0.00000000 1.68664319 -0.07270014 > [9,] -0.4362008 -1.68664319 0.00000000 -1.75934333 > [10,] 1.3231425 0.07270014 1.75934333 0.00000000 > > Thanks in advance. > > Greets, > Markus > > > > > ______________________________________________ > 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-plot-tp24572168p24574102.html Sent from the R help mailing list archive at Nabble.com.
2009/7/20 Markus M?hlbacher <muehliman at yahoo.com>:> Gives the attached image. Again I am missing the white diagonal. Is there some kind of sorting that I do not consider?Maybe col=c("white",heat.colors(100)) will do the trick? -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
2009/7/21 Markus M?hlbacher <muehliman at yahoo.com>:> So just that I understand right. x and y are the scalings of the x and y axis and the matrix represents the color of the points at each gridpoint?Precisely! Try ?image for more details. -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/
2009/7/21 Markus M?hlbacher <muehliman at yahoo.com>:> I tried to add white to the colors, but this did not change my problem. Still the values of the diagonal seem to be different from those occurring in the matrix. Or in other words all squares of the diagonal should have to SAME color!If you can send me the matrix as a text file -- ready to import in R -- I can give it a try. Best, Michael -- Michael Knudsen micknudsen at gmail.com http://lifeofknudsen.blogspot.com/