[R] heatmap

Nair, Murlidharan T mnair at iusb.edu
Wed Jul 2 22:14:21 CEST 2008


I tried the following myself and I almost have something to work with. But I still need a little input.

#Plots a filled contour
# Can someone help me in increasing the resolution as my data range is 0-11? Also I need to put the row and column names on the axes.
x <- 1:nrow(data)
y <- 1:ncol(data[,-1])
filled.contour(x, y, as.matrix(data[,-1]), color = terrain.colors,
    plot.title = title(main = "", xlab = "", ylab = ""),
    key.title = title(main="Hex count"),
    key.axes = axis(4,asp=1))# maybe also asp=1


#Plots the image directly.
#Can I specify specific set of colors in for the image to correspond to a particular value in the data matrix?
#I need to put the row and column names on the axes and make a key . Any help here please ?

image(x,y,as.matrix(data[,-1]),col=topo.colors(12)))


Thanks ../Murli




________________________________________
From: r-help-bounces at r-project.org [r-help-bounces at r-project.org] On Behalf Of Nair, Murlidharan T [mnair at iusb.edu]
Sent: Wednesday, July 02, 2008 2:02 PM
To: r-help at r-project.org
Subject: [R] heatmap

I am interested in plotting a matrix of data using heatmap to reflect frequency of  positional occurrence of certain strings. I am not interested in clustering them.  I also want to make a key for the colors.Can someone help me with that.
I am appending a portion of my data here.
Thanks ../Murli

data<-dput(unique.data[1:20,1:20])
structure(list(A1 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), A2 = c(0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L
), A3 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 0L, 1L,
0L, 0L, 0L, 0L, 0L, 0L, 0L), A4 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), A5 = c(0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,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0L, 0L, 0L, 0L,
    0L, 0L, 0L), A18 = c(0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), A19 = c(0L,
    0L, 0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
    0L, 0L, 0L, 0L), A20 = c(0L, 0L, 0L, 0L, 0L, 1L, 0L, 0L,
    0L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("A1",
"A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11",
"A12", "A13", "A14", "A15", "A16", "A17", "A18", "A19", "A20"
), row.names = c("gggggg", "gttagg", "gggtgg", "ggtagg", "aggtag",
"ggggtg", "gtttag", "ggttag", "gggggt", "agttag", "tttagg", "aggggg",
"tggggg", "ggtggg", "gtaggt", "aggttt", "taggtt", "agtttg", "agttcg",
"taggta"), class = "data.frame")

heatmap(as.matrix(data))

______________________________________________
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.



More information about the R-help mailing list