做生信好多年了歌粥,熱圖市場(chǎng)還是保溫不下魏宽,幾乎每天都有不同的需求呆馁。今天就遇到倆:
一個(gè)是:
一個(gè)是:
我們看一下第二個(gè)如何共享圖例標(biāo)尺梗摇?
library(pheatmap)
?pheatmap
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 = "")
test2 = matrix(rnorm(200), 20, 10)
test2[1:10, seq(1, 10, 2)] = test2[1:10, seq(1, 10, 2)] + 3
test2[11:20, seq(2, 10, 2)] = test2[11:20, seq(2, 10, 2)] + 2
test2[15:20, seq(2, 10, 2)] = test2[15:20, seq(2, 10, 2)] + 4
colnames(test2) = paste("TestA", 1:10, sep = "")
rownames(test2) = paste("GeneL", 1:20, sep = "")
breaks = seq(min(unlist(c(test,test2))),max(unlist(c(test,test2))),length.out = 100)
p1 <- pheatmap(test,breaks = breaks)
p2 <- pheatmap(test2,breaks = breaks)
library(cowplot)
plot_grid(p1$gtable,p2$gtable,align = 'vh',labels = c('A',"B"),ncol = 2)
然后: