美文网首页R 出现的问题汇总
Error in check.length("fill") :

Error in check.length("fill") :

作者: 7f0a92cda77c | 来源:发表于2021-05-25 14:54 被阅读0次

    在绘制热图,出现了报错信息

    Error in check.length("fill") :
    'gpar' element 'fill' must not be length 0

    得到了表达矩阵,如下

    表达矩阵
    dat <- expression_cpm
    tmp <- sort(apply(dat,1,mad),decreasing =T)[1:500]#取其表达矩阵前500
    exprSet <- dat[names(tmp),]
    

    计算相关性

    library(corrplot)
    M <- cor(exprSet)
    
    转换后行名会自动变换了
    rownames(M)
     [1] "PC.1"   "CP.2"   "CP.4"   "CO.1"   "CP.1"   "M.1"    "OF.1"   "PC.2"   "CO.2"  
    [10] "M.2"    "OF.2"   "PC.3"   "CO.3" "M.3"    "OF.3"   "CP.3"   "CO.4"   "M.4"   
    [19] "OF.4"   "PC.4"   "CO.5"   "M.5"    "OF.5"   "PC.5" 
     colnames(M)
     [1] "PC-1" "CP-2" "CP-4" "CO-1" "CP-1" "M-1"  "OF-1" "PC-2" "CO-2" "M-2"  "OF-2" "PC-3"
    [13] "CO-3" "M-3"  "OF-3" "CP-3" "CO-4" "M-4"  "OF-4" "PC-4" "CO-5" "M-5"  "OF-5" "PC-5" 
    
    做一个分组信息
    library(pheatmap)
    anno <- data.frame(sampleType=group_list)
    pheatmap(M,display_numbers = T,fontsize = 12,cellheight = 40,cellwidth = 40,cluster_cols = T,cluster_rows = T,annotation = anno)#出现报错
    
    anno-原始文件

    查了下相关的网站,原因如下:
    the anno is to have the EXACT SAME row names between M matrix
    注释的文件Anno行名必须和这个要绘图的矩阵M行名一致

    https://stackoverflow.com/questions/51851868/error-in-check-lengthfill-gpar-element-fill-must-not-be-length-0
    https://www.biostars.org/p/240404/
    http://environmentalcomputing.net/heat-maps/?fbclid=IwAR2-6wdTdeK0lModZhbD_C6nNy-K5QCuSeOhYeKWxbnT_bTM47yrhC_nf8k

    修改下anno这个文件的名称
    rownames(anno) <- rownames(M)#满足条件
    
    anno
    再重新绘图,就不会报错了
    pheatmap(M,display_numbers = T,fontsize = 12,cellheight = 40,cellwidth = 40,cluster_cols = T,cluster_rows = T,annotation = anno) 
    #字体大小,聚类的行名,列名,聚类的分组信息
    
    pheatmap

    相关文章

      网友评论

        本文标题:Error in check.length("fill") :

        本文链接:https://www.haomeiwen.com/subject/jcyqsltx.html