错误:R WGCNA代码中的(下标)逻辑下标太长

时间:2019-02-05 20:35:59

标签: r network-analysis

我收到此错误:

  

TOM [modGenes,modGenes]中的错误:(下标)逻辑下标过长

当我运行以下代码时。我从该问题的类似实例中尝试了大多数适用的调试技巧。大多数与尺寸不匹配有关。由于子集的两个参数都是modGenes,因此这不应该成为问题。有人有提示吗?

#get the numbers of modules and genes in each module
  modTable = table(colors);
  nMods = length(modTable);

  #loop through modules to build vector of module densities
  modDensities = c();
  for (m in 1:nMods) {

#if the current module is grey and skipGrey=T, assign density of 0 and move to next module
checkGrey = names(modTable)[m] == 'grey';
if (skipGrey & checkGrey) {
  modDensities = c(modDensities, 0);
  next;
}

#otherwise get the indices for genes in the current module
#modGenes = colors == names(modTable)[m];
modGenes = is.finite(match(colors, names(modTable)[m]));
#subset the TOM for genes in the current module and compute the density as mean TOM
modTOM = TOM[modGenes, modGenes];
modDensities = c(modDensities, mean(vectorizeMatrix(modTOM, diag=diag)));}

这些是我正在使用的数据集的结构:

Browse[1]> str(nMods)

 int 6

Browse[1]> str(modGenes)

 logi [1:993] FALSE FALSE FALSE FALSE FALSE FALSE ...

Browse[1]> str(modTOM)

Error during wrapup: object 'modTOM' not found

Browse[1]> str(TOM)

 num [1:992, 1:992] 0 0.011894 0.003361 0.000277 0.011767 ...

 - attr(*, "dimnames")=List of 2

  ..$ : chr [1:992] "1" "2" "3" "4" ...

  ..$ : chr [1:992] "1" "2" "3" "4" ...

Browse[1]> str(modDensities)

 NULL

Browse[1]> str(modTable)

 'table' int [1:6(1d)] 151 124 106 339 156 117

 - attr(*, "dimnames")=List of 1

  ..$ colors: chr [1:6] "blue" "brown" "green" "grey" ...

0 个答案:

没有答案