Colour in heatmap labels
1
0
Entering edit mode
3.0 years ago
kbaitsi • 0
data <- read.table("third.txt", sep = "\t", header = TRUE, row.names = 1)
data_matrix <- as.matrix(data)
colnames(data_matrix) <- c("473", "477", "474", "480", "481", "475", "479", "478", "495", "503", "499", "502", "494", "497", "496", "500")
heatmap(data_matrix)
library("RColorBrewer")
colr <- colorRampPalette(brewer.pal(8, "BuPu"))(256)
heatmap(data_matrix, scale = "column", col = colr, labRow = NA, cexCol = 0.75, margins = c(5, 2), xlab = "Data Samples", ylab = "gene expressions", main = "Differentially expressed genes")

I have written the code above and it produces the following heatmap. I also want to colour the name of the data samples with two different colours or draw a line to seperate the two clusters. Is there any way I could do that? enter image description here

labels colour heatmap • 1.1k views
ADD COMMENT
1
Entering edit mode
3.0 years ago
seidel 11k

One easy way to illustrate the groupings in the heat map would be to simply use a different heat map library. pheatmap is fairly easy to use. The help for pheatmap has some nice examples showing how to have several layers of groupings if you need it.

library(pheatmap)
library("RColorBrewer")

# create a matrix of data
x <- matrix(rnorm(300), nrow=30, ncol=10)
colnames(x) <- paste0("c", 1:ncol(x))
rownames(x) <- paste0("g", 1:ncol(x))

# skew the data so 1/2 the columns cluster together
x[,6:10] <- x[,6:10] + 3

# create a table describing columns
annotation_col <- data.frame(SampeType=rep(c(1,2),each=5))
rownames(annotation_col) <- colnames(x)

# set your color palette
colr <- colorRampPalette(brewer.pal(8, "BuPu"))(256)

# draw the heatmap
pheatmap(x, annotation_col=annotation_col, color=colr)

example heat map

ADD COMMENT

Login before adding your answer.

Traffic: 3032 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6