美文网首页WGCNA分析
WGCNA-errorLength of 'xLabels' m

WGCNA-errorLength of 'xLabels' m

作者: 天涯清水 | 来源:发表于2020-02-12 22:50 被阅读0次

Error in labeledHeatmap(Matrix = moduleTraitCor, xLabels = colnames(design), : Length of 'xLabels' must equal the number of columns in 'Matrix.'

用以前的代码,跑其他的样本第5步的时候出现了

STEP5:模块和性状的关系
MEs是一个关于modules的特征量矩阵,行数等于筛选的modules数,列数等于样本数;

if(T){
  nGenes = ncol(datExpr)
  nSamples = nrow(datExpr)
  design=model.matrix(~0+ datTraits$ClinicalTraits)
  colnames(design)=levels(datTraits$ClinicalTraits)
  moduleColors <- labels2colors(net$colors)
  # Recalculate MEs with color labels
  MEs0 = moduleEigengenes(datExpr, moduleColors)$eigengenes
  MEs = orderMEs(MEs0); ##不同颜色的模块的ME值矩 (样本vs模块)
  moduleTraitCor = cor(MEs, design , use = "p");
  moduleTraitPvalue = corPvalueStudent(moduleTraitCor, nSamples)
  
  sizeGrWindow(10,6)
  # Will display correlations and their p-values
  textMatrix = paste(signif(moduleTraitCor, 2), "\n(",
                     signif(moduleTraitPvalue, 1), ")", sep = "");
  dim(textMatrix) = dim(moduleTraitCor)
  png("step5-Module-trait-relationships.png",width = 800,height = 1200,res = 120)
  #pdf("step5-Module-trait-relationships.pdf",width = 36, height = 36)
  par(mar = c(6, 8.5, 3, 3));
  
  # Display the correlation values within a heatmap plot
  
  labeledHeatmap(Matrix = moduleTraitCor,
                 xLabels = colnames(design),
                 yLabels = names(MEs),
                 ySymbols = names(MEs),
                 colorLabels = FALSE,
                 colors = greenWhiteRed(50),
                 textMatrix = textMatrix,
                 setStdMargins = FALSE,
                 cex.text = 0.5,
                 zlim = c(-1,1),
                 main = paste("Module-trait relationships"))
  dev.off()
}

报错信息:

Error in labeledHeatmap(Matrix = moduleTraitCor, 
xLabels = colnames(design),  :    
Length of 'xLabels' must equal the number of columns in 'Matrix.'

出图的时候错了。搜索也找不到答案,不知道如何解决。

colnames(design)的结果为null,把colnames(design)转化为因子也不能解决。

今天(2020.02.13)把上面的问题解决了,的确是把colnames(design)转化为因子。准确的说应该是吧。design转化为因子。

colnames(design)=levels(as.factor(datTraits$ClinicalTraits))

但是会有警告信息,不过不影响结果:

Warning message:
In greenWhiteRed(50) :
  WGCNA::greenWhiteRed: this palette is not suitable for people
with green-red color blindness (the most common kind of color blindness).
Consider using the function blueWhiteRed instead.

相关文章

  • WGCNA-errorLength of 'xLabels' m

    Error in labeledHeatmap(Matrix = moduleTraitCor, xLabels ...

  • 关于matplotlib.pyplot.xsticks,x轴标签

    1.x——表示x刻度的取值范围2.xlabels——表示与x每个值相对应的标签 例如(x取值范围与xs不相同时):...

  • 嗯m m m

    今天唯一比较开心还不是特别开心的事情大概就是发现今天星期四了吧,还以为星期三,一看手机,星期四

  • 知识点八上

    M 1 M 2 M 3 M 4 M 5 M 6 M 7 M 8 M 9 M 10 M 11 M 12

  • 作文题八上

    M1 M 2 M 3 M 4 M 5 M 6 M 7 M 8 M 9 M 10 M 11 M 12

  • 泪的告白

    [m] [m] [m] [m] [m]泪的告白 [m] [m]

  • 知识点七上

    M 1 M 2 M 3 M 4 M 5 M 6 M 7 M 8 M 9 M 10

  • M.M

    高数极限的复习

  • M.M

    钢筋混凝土材料基本性能

  • M.M

    今天用思维导图整理了《网络传播概论》里微信群的知识点,收获满满(•͈˽•͈)

网友评论

    本文标题:WGCNA-errorLength of 'xLabels' m

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