服务热线
178 0020 3020
setwd("D:/geo/GSE70689/")
library("pheatmap")
exprSet = read.csv("exprSet.csv", header = T, row.names = 1)
#查看所有基因的热图
pdf(file = "heatmap_all.pdf", width=6, height=8)
pheatmap(
exprSet,
scale = 'row',
clustering_distance_rows = "euclidean",
display_numbers=F,
number_format="%.2f",
number_color="grey",
fontsize_number=6
)
dev.off()
#查看部分基因的热图,下面展示20个基因的热图,只需要修改下面的基因名称
geneSets = c("Eef1g","Nsep1","3010033P07Rik","Actb","Gapd","Uba52","Rpl13","Rps8","Ubb","Fth1",
"Rpl24","Hist1h2ai","Rps5","Sap30","Rps27a","Rpl41","Krtcap2","Saa3","Rps10")
dataTemp = exprSet[row.names(exprSet) %in% geneSets,]
pdf(file = "heatmap_some_gene.pdf", width=6, height=8)
pheatmap(
dataTemp,
scale = 'row',
clustering_distance_rows = "euclidean",
display_numbers=F,
number_format="%.2f",
number_color="grey",
fontsize_number=6
)
dev.off()
#为每一列添加分组标签
sampleInfo = read.csv("sampleInfo.csv", header = T, row.names = 1)
head(sampleInfo)
data = exprSet
colnames(data) = sampleInfo$title
geneSets = c("Eef1g","Nsep1","3010033P07Rik","Actb","Gapd","Uba52","Rpl13","Rps8","Ubb","Fth1",
"Rpl24","Hist1h2ai","Rps5","Sap30","Rps27a","Rpl41","Krtcap2","Saa3","Rps10")
dataTemp = data[row.names(data) %in% geneSets,]
annotation_col = data.frame(
"Sample" = c("THC_LPS","Cntr","LPS","THC","LPS","THC","THC_LPS","CBD_LPS","Cntr","Cntr","THC","LPS","CBD","Cntr","THC","LPS","CBD","LPS","LPS","THC_LPS","CBD_LPS","THC_LPS","Cntr","Cntr"),
"other" = c(rep(1:6,each=4)) #这个是其他属性
)
row.names(annotation_col) = sampleInfo$title
pdf(file = "heatmap_some_gene_info.pdf", width=8, height=8)
pheatmap(
dataTemp,
scale = 'row',
clustering_distance_rows = "euclidean",
display_numbers=F, #这里改为T,则会在热图的每个格子中显示数值
number_format="%.2f",
number_color="grey",
fontsize_number=6,
annotation_col = annotation_col,
cellwidth = 12, #每个小格子宽度
cellheight = 12, #每个小格子高度
border_color = NA #不需要每个格子的边框
)
dev.off()
附件