R包:ggheatmap热图

news/2024/9/29 2:21:32/

在这里插入图片描述

加载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.ppmy.cn/news/1531729.html

相关文章

给Ubuntu虚拟机设置静态IP地址(固定IP)

查看 为Ubuntu虚拟机配置静态IP地址&#xff08;固定IP&#xff09;的方法经过亲自测试&#xff0c;已被证实有效。 这里你记得网关就可以了&#xff0c;等下要用 查看配置前的网络信息 ifconfig 查看网关 route -n 配置 配置网络文件 cd /etc/netplan/ ls 查看自己的文件的名…

Linux Mint急救模式

在给Linux MInt22安装6.8.0-45-generic的时候&#xff0c;出现一些问题&#xff0c;无法安装&#xff0c;手工单独安装后&#xff0c;发现无法启动。使用急救模式修复。 1 官方网站下载Linux Mint22的ISO镜像 2 下载Rufus刻盘工具 3 使用Rufus将ISO镜像刻到USB设备 4 使用U…

数据结构 随机存取 顺序存取 随机存储 顺序存储

存取结构&#xff1a;分为随机存取和非随机存取&#xff08;又称顺序存取&#xff09; 1、随机存取 就是直接存取&#xff0c;可以通过下标直接访问的那种数据结构&#xff0c;与存储位置无关&#xff0c;例如数组。 非随机存取就是顺序存取了&#xff0c;不能通过下标访问了…

c语言200例 64

大家好&#xff0c;欢迎来到无限大的频道。 今天带领大家来学习c语言。 题目要求&#xff1a; 设计一个进行候选人的选票程序。假设有三位候选人&#xff0c;在屏幕上输入要选择的候选人姓名&#xff0c; 有10次投票机会&#xff0c;最后输出每个人的得票结果。好的&#xff…

react组件入门

react应用程序就是由一个个组件搭建而成。组件有类组件和函数组件两种。 我们之前使用create-react-app创建了app&#xff0c;src下放的就是我们应用的源代码&#xff0c;我们基于这些已生成的文件&#xff0c;来学习和验证组件。 类组件 这里我们创建PostList.js更改这个ap…

程序员数学 | 数学归纳法

目录 一、数学归纳法是什么二、使用编程来模拟数学归纳法的证明 人类做重复性的劳动没有效率&#xff0c;而计算机却能更快更准确的完成重复性劳动。所以以重复为特点的迭代法在编程中有着⼴泛的应⽤。实际项目中是否可以用不断更新变量值或者缩小搜索的区间范围的方法&#xf…

Qt day01

#include "widget3.h" #include<QDebug> #include<QPushButton> #include<QLineEdit> #include<QLabel> Widget3::Widget3(QWidget *parent): QWidget(parent) {qDebug()<<"这个界面的标题"<<this->windowTitle();…

MySQL实战教程:从小白到大神的进阶之路!

目录 一、MySQL概述1、MySQL简介1.1 MySQL的历史背景1.2 MySQL的特点1.3 MySQL的应用场景1.4 MySQL的版本 2、MySQL发展历程2.1 MySQL的起源2.2 MySQL的早期发展2.3 MySQL的成熟与普及2.4 MySQL的商业化与收购2.5 MySQL的持续创新 3、MySQL应用场景3.1 Web应用程序3.2 企业级应…