当前位置: 首页 > article >正文

R包:ggheatmap热图

在这里插入图片描述

加载R包

# devtools::install_github("XiaoLuo-boy/ggheatmap")

library(ggheatmap)
library(tidyr)

数据

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

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

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

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

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

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"))))

在这里插入图片描述

参考

  • https://github.com/XiaoLuo-boy/ggheatmap

http://www.kler.cn/a/324854.html

相关文章:

  • 大数据新视界 -- 大数据大厂之 Impala 性能飞跃:分区修剪优化的应用案例(下)(22 / 30)
  • 高光谱深度学习调研
  • 《操作系统 - 清华大学》3 -3:连续内存分配:内存碎片与分区的动态分配
  • 跨域 总 结 CORS
  • 深入List集合:ArrayList与LinkedList的底层逻辑与区别
  • JS学习日记(jQuery库)
  • linux 下80端口被占用
  • 经典sql题(十二)UDTF之Explode炸裂函数
  • ceph pg rebalance
  • 大数据-148 Apache Kudu 从 Flink 下沉数据到 Kudu
  • 探索顶级低代码开发平台,实现创新
  • 解决Android Studio 右上角Gradle不显示task
  • Docker技术深度解析与实践案例
  • 解决macOS搭建flutter错误 CocoaPods not installed
  • 自然语言处理实战项目:从理论到实现
  • 3. 轴指令(omron 机器自动化控制器)——>MC_MoveRelative
  • ChatGPT+R语言强强联合,数据分析不再难!回归与混合效应模型、多元统计分析、结构方程模型(SEM)(lavaan)、Meta分析、贝叶斯回归等应用
  • CORE MVC 过滤器 (筛选器)
  • 使用WPF实现一个快速切换JDK版本的客户端工具
  • 视频格式转换:avi格式转mp4格式
  • Linux中查找在某一文件夹下有没有给定名字的文件
  • springboot+satoken实现刷新token(值变化)
  • 威胁检测与防范:如何及时、准确对抗安全风险
  • react-markdown 使用 rehype-katex,解决锚点跳转后渲染异常
  • linux 下mailx 的使用。发送短信
  • 在vue项目中禁用鼠标右键,选中