install.packages("tidyheatmaps")
library(tidyheatmaps)
# 下方仅为载入代码,需要提取安装
library(scales)
library(dplyr)
mydata <- data_exprs %>%
select("external_gene_name", "sample", "expression", "group", "direction") %>% # 提取5个变量
filter(external_gene_name %in% c("Apol6", "Col5a3", "Ankrd54", "Bag1", # 提取8个基因
"Kif1a", "Pttg1", "Sh3tc1", "Smim10l2a"))
summary(mydata); head(mydata)
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression)
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression,
display_numbers = TRUE)
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression,
color_legend_min = 0,
color_legend_max = 12,
color_legend_n = 8)
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression,
colors = c("steelblue", "gold", "red")) # 手动定义颜色
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression,
annotation_row = direction)
假设还想给列注释,可以使用代码annotation_col:
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression,
annotation_row = direction,
gaps_row = direction,
annotation_col = group)
tidyheatmap(mydata,
rows = external_gene_name,
columns = sample,
values = expression,
annotation_row = direction,
annotation_col = group,
annotation_colors = list(
direction = c("up" = "orange", "down" = "steelblue"), # 分类变量
group = alpha(c("Hin" = "#FF0000", "Ein" = "#80FF00",
"Eip" = "#00FFFF", "Hip" = "#8000FF"), 0.5)),
show_selected_row_labels = c("Apol6", "Ankrd54", "Pttg1", "Sh3tc1")) # 选取想展示的行名称
[1]. https://github.com/jbengler/tidyheatmaps