1、就是控制这个dendrogram参数heatmap.2(x, dendrogram=none) 然后我们控制一下聚类树row) 只显示行向量的聚类情况col)只显示列向量的聚类情况下面还是在调控聚类树,但是我没看懂跟上面的参数有啥子区别! heatmap.2(x, keysize=2) # default - dendrogram plotted and reordering done. heatmap.2(x, Rowv=FALSE, dendrogram=both) # generate warning! heatmap.2(x, Rowv=NULL, dendrogram= heatma
2、p.2(x, Colv=FALSE, dendrogram=接下来我们可以调控行列向量的label的字体大小方向首先我们调控列向量,也就是x轴的label heatmap.2(x, srtCol=NULL) heatmap.2(x, srtCol=0, adjCol = c(0.5,1) ) heatmap.2(x, srtCol=45, adjCol = c(1,1) ) heatmap.2(x, srtCol=135, adjCol = c(1,0) ) heatmap.2(x, srtCol=180, adjCol = c(0.5,0) ) heatmap.2(x, srtCol=225
3、, adjCol = c(0,0) ) # not very useful heatmap.2(x, srtCol=270, adjCol = c(0,0.5) ) heatmap.2(x, srtCol=315, adjCol = c(0,1) ) heatmap.2(x, srtCol=360, adjCol = c(0.5,1) )然后我们调控一下行向量,也就是y轴的label heatmap.2(x, srtRow=45, adjRow=c(0, 1) ) heatmap.2(x, srtRow=45, adjRow=c(0, 1), srtCol=45, adjCol=c(1,1)
4、) heatmap.2(x, srtRow=45, adjRow=c(0, 1), srtCol=270, adjCol=c(0,0.5) )设置 offsetRow/offsetCol 可以把label跟热图隔开! # Show effect of offsetRow/offsetCol (only works when srtRow/srtCol is # not also present) heatmap.2(x, offsetRow=0, offsetCol=0) heatmap.2(x, offsetRow=1, offsetCol=1) heatmap.2(x, offsetRow
5、=2, offsetCol=2) heatmap.2(x, offsetRow=-1, offsetCol=-1) heatmap.2(x, srtRow=0, srtCol=90, offsetRow=0, offsetCol=0) heatmap.2(x, srtRow=0, srtCol=90, offsetRow=1, offsetCol=1) heatmap.2(x, srtRow=0, srtCol=90, offsetRow=2, offsetCol=2) heatmap.2(x, srtRow=0, srtCol=90, offsetRow=-1, offsetCol=-1)#
6、 Show effect of z-score scaling within columns, blue-red color scale # hv names(hv)可以看到hv对象里面有很多子对象rowInd colIndcallcolMeanscolSDscarpetrowDendrogramcolDendrogrambreaksvlinecolorTable # Show the mapping of z-score values to color bins hv$colorTable # Extract the range associated with white我们得到了热图的颜色
7、的数值映射矩阵,接下来就可以进行一系列的操作! hv$colorTablehv$colorTable,color=#FFFFFF,首先得到了白色所对应的数值区间!然后还可以通过一下命令,直接求出属于白色区间的那些数值。whiteBin - unlist(hv$colorTablehv$colorTable,1:2) rbind(whiteBin1 * hv$colSDs + hv$colMeans, whiteBin2 * hv$colSDs + hv$colMeans )调整scale参数选择按照列还是行来进行数据的标准化heatmap.2(x, col=bluered, scale=如果选
8、择了标准化,那么还可以手工调整标准化的参数:rowMeans, rowSDsmean and standard deviation of each row: only present if scale=colMeans, colSDsmean and standard deviation of each column:通过hclustfun参数来调整聚类方法参考:Cluster_Method-c( ward, singlecompleteaveragemcquittymediancentroid#R语言里面自带的hclust函数共有7种聚类方法for (i in 1:length(Cluste
9、r_Method) #make a function to extract the cluster method myclust-function(x) hclust(x,method=Cluster_Methodi) #make heatmap by jpeg jpeg(filename=paste(Cluster_Methodi,.jpg),width=1024,height=728) heatmap.2(as.matrix(Data_Top1k_Var), trace=none, hclustfun=myclust, labRow=NA, ColSideColors=c(black,gr
10、ey(0.4),lightgrey)as.factor(CellLine_Anno$Type), xlab=CellLines ylab=Probes main=Cluster_Methodi, col=greenred(64) dev.off()这样就可以一下子把七种cluster的方法依次用到heatmap上面来。而且通过对cluster树的比较,我们可以从中挑选出最好、最稳定到cluster方法,为后续分析打好基础!对下面这个数据聚类: require(graphics) hc - hclust(dist(USArrests), ave plot(hc)首先对一个数据框用dist函数处理得到一个dist对象!Dist对象比较特殊,专门为hclust函数来画聚类树的!
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1