用R做heatmap时,分组出现了混乱的问题,
此为我的代码
datExp = read.csv("./GPL15159/expressiongene.csv",header=TRUE,row.names=1,check.names = FALSE)
View(head(datExp))
#处理数据 把第一列基因名称改成行名
#读取患者分组信息
datTraits = read.table("./GPL15159/target.txt",sep='\t',header=T)
View(datTraits)
color = factor(datTraits$sample.source,labels=c('orange','blue'),levels = c("Normal","tumor"))
class(color)
View(color)
#数据转换(因为上一步读出的数据为 data.frame,而heatmap读入需要matrix)
datExp = as.matrix(datExp)
View(datExp)
#聚类热图
heatmap.2(datExp,col = greenred(75),
hclust=function(x) hclust(x,method = 'ward.D2'),
distfun=function(x) dist(x,method='euclidean'),
scale = "row",dendrogram = 'both',
key = TRUE, symkey = FALSE, density.info = "none",
trace = "none", cexRow = 0.5,
ColSideColors = as.character(color)
)
dev.off("./GPL15159")
请问出现分组混乱的原因是什么呀,怎样改正呢 谢谢!