I want to draw a heatmap, using heatmap.2(), in which I want to define colseps in several different colors.
I have tried specifiyng sepcolor by concatenation:
heatmap.2 (as.matrix(order_by27_T[rowsToDraw,]), Rowv=FALSE, Colv=FALSE, dendrogram="none", col=hmColors, breaks=seq(0,1,(1/120)), trace="none", colsep=c(60,120,180), sepcolor=c("white","pink","green"))
Further, I tried to create a character vector specfiying the desired colors in the desired order and to assign this vector to sepcolor:
sepColour<-c("white","pink","green")
heatmap.2 (as.matrix(order_by27_T[rowsToDraw,]), Rowv=FALSE, Colv=FALSE, dendrogram="none", col=hmColors, breaks=seq(0,1,(1/120)), trace="none", colsep=c(60,120,180), sepcolor=sepColour)
In both cases, all there seprators defined were green (the last element of the vector).
Is what I'm trying to do possible at all?
thanks in advance
The colsep
argument takes a vector of numbers indicating whether the columns should be separated by a space of colour. From the documentation:
(optional) vector of integers indicating which columns or rows should be separated from the preceding columns or rows by a narrow space of color sepcolor
In your example, this would be something like:
heatmap.2(as.matrix(order_by27_T[rowsToDraw,]), colsep=1:5,
sepcolor=c("red", "blue"), ....)
This would separate columns 1 to 5 with the colours red
and blue
Just in case you only want to specify a custom palette (not what you asked for), here is some code:
full = matrix(runif(100, -5, 5), ncol= 10)
my_p = colorRampPalette(c("white","pink","green"))
breaks = c(seq(min(full), 0, length.out=128),
seq(0, max(full), length.out=128))
heatmap.2(full, dendrogram="row", Colv=FALSE,
col=my_p, key=TRUE,
breaks=breaks, symkey=FALSE, density.info="none",
trace="none", cexRow=0.5, cexCol=0.75)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.