今天再给热图添加分类标签时,遇到下面的错误
Error in check.length("fill") :
'gpar' element 'fill' must not be length 0
在网上搜了一下,在设置完分组后添加这个命令就可以了
rownames(annotation_col) <- colnames(big)
完整的代码为
data2<-read.table("haplotype",header = T,sep='\t')
big=data2[c(grep("BRA|BRB|BC|FT",colnames(data2)))]
annotation_col = data.frame( Type = factor(rep(c("BRB", "BRA","FT","BC"),times=c(40,40,40,20))) )
rownames(annotation_col) = paste("Test", 1:140, sep = "")
rownames(annotation_col) <- colnames(big)
ann_colors = list(Type = c(BRB = "#D95F02", BRA = "#7570B3",FT = "#E7298A",BC="#66A61E"))
pheatmap(big,annotation_col = annotation_col,annotation_colors = ann_colors,annotation_legend = FALSE,show_rownames = F,show_colnames = F,cluster_cols = F,cluster_rows=F,filename='big-2.tiff',fontsize_col=10, width=4,height=20, legend=F, angle_col=90, color =colorRampPalette(c("#0b73a9", "#d1d666"))(2))
网友评论