Add selected row names on pheatmap
0
Entering edit mode
ecg1g15 • 0
@ecg1g15-19970
Last seen 6 weeks ago

Could you add selected row names to a pheatmap instead of including them all using show_rownames = T?

Something similar was asked few years ago here https://www.biostars.org/p/258462/ for Pheatmap.2 I wonder if now there is any function or package that can allow it other than doing it manually?

I tried something like this but doesn't work


x = matrix(1:16, nrow = 4, 
           dimnames = list(c("banana","lime","carrot","tomato"), c("A1","A2","B1","B2")))

labgenes<- c(row.names(x)[1], rep('', length(row.names(x))-1))

pheatmap(x, annotation_col = anno, fontsize_row = 10, show_colnames = F, show_rownames = labgenes, color = colorRampPalette(rev(brewer.pal(n = 7, name ="RdYlBu")))(100))
R pheatmap • 78 views
ADD COMMENTlink
0
Entering edit mode

I removed "DESeq2" tag here. Note that tagging a package emails the developers.

ADD REPLYlink
0
Entering edit mode
ATpoint • 390
@atpoint-13662
Last seen 4 hours ago
Germany

That is pretty simply by exploiting the labels_row option where you simply blank those genes you do not want to display:

test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")

labs.row <- rownames(test)

#/ Turn off all but the last two genes (gene 19 and 20):
labs.row[1:(nrow(test)-2)] <- ""
pheatmap(test, labels_row = labs.row)

enter image description here

ADD COMMENTlink

Login before adding your answer.

Similar Posts
Loading Similar Posts
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.3