R包:ggheatmap热图

加载R包

r 复制代码
# devtools::install_github("XiaoLuo-boy/ggheatmap")

library(ggheatmap)
library(tidyr)

数据

r 复制代码
set.seed(123)
df <- matrix(runif(225,0,10),ncol = 15)
colnames(df) <- paste("sample",1:15,sep = "")
rownames(df) <- sapply(1:15, function(x)paste(sample(LETTERS,3,replace = F),collapse = ""))
df[1:4,1:4]


row_metaData <- data.frame(exprtype=sample(c("Up","Down"),15,replace = T),
                           genetype=sample(c("Metabolism","Immune","None"),15,replace = T))
rownames(row_metaData) <- rownames(df)
col_metaData <- data.frame(tissue=sample(c("Normal","Tumor"),15,replace = T),
                           risklevel=sample(c("High","Low"),15,replace = T))
rownames(col_metaData) <- colnames(df)
exprcol <- c("#EE0000FF","#008B45FF" )
names(exprcol) <- c("Up","Down")
genecol <- c("#EE7E30","#5D9AD3","#D0DFE6FF")
names(genecol) <- c("Metabolism","Immune","None")
tissuecol <- c("#98D352","#FF7F0E")
names(tissuecol) <- c("Normal","Tumor")
riskcol <- c("#EEA236FF","#46B8DAFF")
names(riskcol) <- c("High","Low")
col <- list(exprtype=exprcol,genetype=genecol,tissue=tissuecol,risklevel=riskcol)
text_rows <- sample(rownames(df),3)

图1

r 复制代码
p<- ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
              text_show_rows = text_rows,
              cluster_num = c(3,3),
              tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
              tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
              annotation_rows = row_metaData,
              annotation_cols = col_metaData,
              annotation_color = col
)
p

图2

r 复制代码
p%>%
  ggheatmap_theme(1:5,
                  theme =list(
                    theme(axis.text.x = element_text(angle = 90,face = "bold",size = 10),
                          axis.text.y = element_text(colour = "red",face = "bold")),
                    theme(legend.title = element_text(face = "bold")),
                    theme(legend.title = element_text(face = "bold")),
                    theme(legend.title = element_text(face = "bold")),
                    theme(legend.title = element_text(face = "bold"))
                    ))

图3

r 复制代码
ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
              text_show_rows = text_rows,
              border = "grey",
              cluster_num = c(3,3),
              tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
              tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
              annotation_rows = row_metaData,
              annotation_cols = col_metaData,
              annotation_color = col
)%>%
  ggheatmap_theme(1,theme =list(theme(axis.text.x = element_text(angle = 90,face = "bold",size = 10),
                          axis.text.y = element_text(colour = "red",face = "bold"))))

图4

r 复制代码
ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
          text_show_rows = text_rows,
          border = "grey",
          shape = "circle",
          cluster_num = c(3,3),
          tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
          tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
          annotation_rows = row_metaData,
          annotation_cols = col_metaData,
          annotation_color = col
)%>%
  ggheatmap_theme(1,theme =list(theme(axis.text.x = element_text(angle = 90,face = "bold",size = 10),
                                      axis.text.y = element_text(colour = "red",face = "bold"))))

图5

r 复制代码
ggheatmap(df,cluster_rows = T,cluster_cols = T,scale = "row",
          text_show_rows = text_rows,
          border = "grey",
          cluster_num = c(3,3),
          tree_color_rows = c("#008B45FF","#631879FF","#008280FF"),
          tree_color_cols = c("#1F77B4FF","#FF7F0EFF","#2CA02CFF"),
          annotation_rows = row_metaData,
          annotation_cols = col_metaData,
          annotation_color = col,
          text_position_rows = "left",
          text_position_cols = "top",
          tree_position_rows = "right",
          tree_position_cols = "bottom",
          annotation_position_rows = "right",
          annotation_position_cols = "bottom"
          
)%>%
  ggheatmap_theme(1,theme =list(theme(axis.text.x = element_text(angle = 90,face = "bold",size = 10),
                                      axis.text.y = element_text(colour = "red",face = "bold"))))

参考

相关推荐
RestCloud21 小时前
如何理解ETLCloud在iPaas中的关键角色
etl·数据可视化·数据集成·数据传输·ipaas·集成工具
有梦想的Frank博士21 小时前
R语言*号标识显著性差异判断组间差异是否具有统计意义
开发语言·信息可视化·r语言
B站计算机毕业设计超人2 天前
计算机毕业设计Hadoop+PySpark深度学习游戏推荐系统 游戏可视化 游戏数据分析 游戏爬虫 Scrapy 机器学习 人工智能 大数据毕设
大数据·人工智能·爬虫·spark·课程设计·数据可视化·推荐算法
李恒-聆机智能专精数采2 天前
从零开始了解数采(十二)——汽车锂电池板自动装配线数据采集方案
大数据·数据挖掘·云计算·汽车·边缘计算·制造·数据可视化
界面开发小八哥2 天前
「实战应用」如何用图表控件LightningChart .NET在WPF中制作表格?(一)
.net·wpf·数据可视化·图表控件·图表·lightningchart
希艾席蒂恩3 天前
探索四款强大的免费报表工具,提升数据可视化能力
前端·数据库·信息可视化·统计·报表·数据可视化
安冬的码畜日常4 天前
【D3.js in Action 3 精译_039】4.3 D3 面积图的绘制方法及其边界标签的添加
前端·javascript·数据可视化·d3.js·d3面积图
逆风远航4 天前
R语言贝叶斯:INLA下的贝叶斯回归、生存分析、随机游走、广义可加模型、极端数据的贝叶斯分析
开发语言·r语言·贝叶斯·生态学·结构方程·环境科学·混合效应
Faxxtty4 天前
【R语言】解决package ‘qvalue’ is not available (for R version 3.6.1)
开发语言·r语言
Cachel wood5 天前
Vue前端框架:Vue前端项目文件目录
java·前端·vue.js·python·算法·r语言·前端框架