**40**wrote:

Hi all,

I am trying to export my results from WGCNA for network visualisation with visANT or Cytoscape. This step requires the topological overlap matrix (TOM) to be subset. Tutorial 6 on the WGCNA page deals with this: https://horvath.genetics.ucla.edu/html/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/FemaleLiver-06-ExportNetwork.pdf. I should note here that I used the blockwiseModules function to create the TOM because of the size of my RNAseq data set.

The steps in R are as follows:

```
# choose module
module = "green"
# get list of genes
probes = names(datExpr)
inModule = (moduleColors==module)
modProbes = probes[inModule]
# Select the corresponding Topological Overlap
modTOM = TOM[inModule, inModule]
```

I get the following error:

`Error in TOM[inModule, inModule] : incorrect number of dimensions`

Previously it was suggested that this error might be related to loading the TOM from file, in which case it is not saved as a proper similarity matrix (https://support.bioconductor.org/p/69715/). However, following the advice in that bioconductor thread leads to another error:

```
TOM.mat = as.matrix(TOM)
modTOM = TOM.mat[inModule, inModule]
Error in TOM.mat[inModule, inModule] : (subscript) logical subscript too long
```

I've also run the analysis from scratch to avoid loading the TOM, and I get the same error.

Extra info:

```
length(inModule)
[1] 41047
dim(TOM.mat)
[1] 12664 12664
```

Any thoughts on how to get around this error?

Thanks

**2.3k**• written 7 weeks ago by charles.foster •

**40**

Hi Charles,

I have encountered this problem before. Can you give me the the results of

`dim(datExpr)`

and`dim(TOM)`

?30Hi Andres,

Thanks for the reply. The results are:

The original command to generate the TOM was:

`net = blockwiseModules(datExpr, maxBlockSize = 20000, power = 18, networkType="signed", TOMType = "signed", minModuleSize = 30,reassignThreshold = 0, mergeCutHeight = 0.25,numericLabels = TRUE, pamRespectsDendro = FALSE,saveTOMs = TRUE,saveTOMFileBase = "blockwiseTOM",verbose = 3)`

This command results in three blocks being used. I THINK the as.matrix function is only working on the third block:

40I wasn't able to replicate your error, but I might have an alternitive solution:

let me know if it works

30Hi again Andres,

Thanks for the suggestion. I ran your code and it appeared to work, but the edges etc all had 'NA'. I think the subsetting of datExpr was wrong. I changed it to:

so that only the columns (not rows) were subset based on the genes in the green module. The rest of the code then worked fine, and I have the necessary files for Cytoscape. Thanks!

40