做生信好多年了,热图市场还是保温不下,几乎每天都有不同的需求。今天就遇到俩:
一个是:
一个是:
我们看一下第二个如何共享图例标尺?
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)
然后:
网友评论