目前基于热图的绘制需求越来越高,让我们想到的事情逐渐成熟,却已经有人开始实现了这个功能,并上传到了CRAN。复杂热图的绘制长期以来都是基础包omplexHeatmap来实现,现在可以使用了tidyHeatmap了.但是这也不是基于ggplot的版本,所以差强一步。
遗憾的是,cran中包存在问题,我检查发现是版本问题,因此在github上的例子只能安装github版本的tidyHeatmap。
# install.packages("tidyHeatmap")
# devtools::install_github("stemangiola/tidyHeatmap")
library("tidyHeatmap")
library(tidyverse)
tidyHeatmap::pasilla
## # A tibble: 504 x 7
## sample symbol `count normalised ~ condition type location activation
## <chr> <fct> <int> <fct> <fct> <chr> <dbl>
## 1 treate~ Kal1 37 treated singl~ Secretory 1.10
## 2 treate~ Kal1 41 treated paire~ Secretory 1.10
## 3 treate~ Kal1 50 treated paire~ Secretory 1.10
## 4 untrea~ Kal1 1127 untreated singl~ Secretory 1.10
## 5 untrea~ Kal1 1046 untreated singl~ Secretory 1.10
## 6 untrea~ Kal1 932 untreated paire~ Secretory 1.10
## 7 untrea~ Kal1 1018 untreated paire~ Secretory 1.10
## 8 treate~ Ant2 2331 treated singl~ Intracel~ 0.329
## 9 treate~ Ant2 2478 treated paire~ Intracel~ 0.329
## 10 treate~ Ant2 2575 treated paire~ Intracel~ 0.329
## # ... with 494 more rows
首先一定要明白,R语言是以长格式的数据来绘图的;
参数解释:
tidyHeatmap::pasilla %>%
heatmap(
.horizontal = sample,
.vertical = symbol,
.abundance = `count normalised adjusted`,
annotation = c(condition, type),
log_transform = TRUE
)
tidyHeatmap::pasilla %>%
group_by(location, condition) %>%
heatmap(
.horizontal = sample,
.vertical = symbol,
.abundance = `count normalised adjusted`,
annotation = c(type),
log_transform = TRUE
)
# library(dplyr)
tidyHeatmap::N52 %>%
group_by( `Cell type`) %>%
tidyHeatmap::heatmap(
.horizontal = UBR,
.vertical = symbol_ct,
.abundance = `read count normalised log`,
annotation = CAPRA_TOTAL
)
### 人工设定颜色映射
pasilla %>%
heatmap(
.horizontal = sample,
.vertical = symbol,
.abundance = `count normalised adjusted`,
log_transform = TRUE,
palette_abundance = circlize::colorRamp2(c(-2, -1, 0, 1, 2), viridis::magma(5))
)
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有