这个是有读者在B站给我的留言问到的问题
image.png
热图每隔三行分开一小段 怎么实现?我最开始的想法是用ggplot2来做,将数据拆分,每三行数据做一个图,最后采取拼图的方式来实现。
后来想起来R语言里有一个做热图功能非常强大的R包ComplexHeatmap应该能够实现这个目的,所以查了一下这个R包的帮助文档,找到了实现办法。
参考文档链接
https://jokergoo.github.io/ComplexHeatmap-reference/book/index.html
ComplexHeatmap的安装方法,如果没有安装这个R包,运行如下命令
https://bioconductor.org/packages/release/bioc/html/ComplexHeatmap.html
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("ComplexHeatmap")
image.png
mat<-read.csv("20221230.csv",row.names = 1)
mat
library(ComplexHeatmap)
Heatmap(mat)
image.png
Heatmap(mat,
cluster_rows = FALSE,
cluster_columns = FALSE)
image.png
Heatmap(mat,
cluster_rows = FALSE,
cluster_columns = FALSE,
row_split = rep(c("A","B","C"),each=6),
column_split = rep(c("A","B","C","D"),each=6))
image.png
Heatmap(mat,
cluster_rows = FALSE,
cluster_columns = FALSE,
row_split = rep(c("A","B","C"),each=6),
column_split = rep(c("A","B","C","D"),each=6),
row_title = NULL,
column_title = NULL)