Skip to content

Heatmap.2 error

2 messages · Pijush Das, Adams, Jean

#
Dear Sir,

Please help me solving the error occurring during the execution of the code
given below.


library("openxlsx")
library(gplots)
library("RColorBrewer")

rix <- read.xlsx(file.choose(), sheet = 1, colNames = TRUE,rowNames = TRUE)
rawdata <- data.matrix(rix)


colors =
c(seq(-2,-0.5,length=100),seq(-0.5,1,length=100),seq(1,2,length=100))
my_palette <- colorRampPalette(c("green", "black", "red"))(n = 299)

 heatmap.2(rawdata, col=my_palette, scale="row",  key=TRUE, symkey=FALSE,
density.info="none", trace="none", cexRow=0.5, Rowv = FALSE, Colv=FALSE,
breaks=colors)


Error in seq.default(min.raw, max.raw, by = min(diff(breaks)/4)) :  invalid
(to - from)/by in seq(.)
In addition: Warning messages:
1: In heatmap.2(rawdata, col = my_palette, scale = "row", key = TRUE,  :
  Using scale="row" or scale="column" when breaks arespecified can produce
unpredictable results.Please consider using only one or the other.
2: In heatmap.2(rawdata, col = my_palette, scale = "row", key = TRUE,  :
  Discrepancy: Rowv is FALSE, while dendrogram is `none'. Omitting row
dendogram.
Please find the data set attached with the email.


Thanking you.

Regards
Pijush
#
Pijush,

The error is a result of you having repeated color values.  The warnings
can be addressed by changing the arguments that you use.  Attachments are
removed from posts to R Help, so I used different data to show you an
example.

Jean


library(gplots)

data(mtcars)
x  <- as.matrix(mtcars[1:6, 3:4])
x[1:3, ] <- -x[1:3, ]

colors1 <- c(seq(-170, 0, 10), seq(0, 370, 10))
my_palette1 <- colorRampPalette(c("green", "black",
"red"))(n=length(colors1)-1)
heatmap.2(x, col=my_palette1, breaks=colors1, symkey=FALSE, density.info
="none",
  trace="none", dendrogram="none")

colors2 <- unique(colors1)
my_palette2 <- colorRampPalette(c("green", "black",
"red"))(n=length(colors2)-1)
heatmap.2(x, col=my_palette2, breaks=colors2, symkey=FALSE, density.info
="none",
  trace="none", dendrogram="none")
On Fri, Jun 19, 2015 at 9:02 AM, Pijush Das <topijush at gmail.com> wrote: