This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to export a network of a specific module to Cytoscape - Consensus modules / multiExpr

Hi

I constructed a consensus network based on six data sets of gene expression profiles. To construct the network, I used blockwiseConsensusModules function of WGCNA package. And then, I extracted a module associated with outcome from the network.

Because I would like to draw a network of the module, I need to export the network data of the module to Cytoscape.

Could you tell me how to export a network of a specific module obtained from blockwiseConsensusModules function to Cytoscape?

gene expression wgcna

Take a look at the exportNetworkToCytoscape function, in particular, the parameters that are passed to this function. Looking at nodeNames, for example, you should be able to export only what you want to export.

Thank you for your quick reply.

I have tried to use the exportNetworkToCytoscape function as below.


mods = blockwiseConsensusModules(multiExpr, maxBlockSize = 30000, corType = "bicor", power = STPowers, networkType = "signed hybrid", TOMDenom = "mean", checkMissingData = FALSE, deepSplit = 3, reassignThresholdPS = 0, pamRespectsDendro = FALSE, mergeCutHeight = 0.25, numericLabels = TRUE, getTOMScalingSamples = TRUE, consensusQuantile = 0.25, verbose = 3, indent = 2);

exportNetworkToCytoscape(mods,nodeNames=geneNames)


However, It doesn't work. I got a error message " adjacency is not numeric".

Could you tell me why it doesn't work?

Thank you for your kindly comments.

I could know that the adjacency matrix was needed to do exportNetworkToCytoscape. However, I can't find how to get the adjacency matrix from expression data in the multi-set format.

The link, which you suggested, explains how to get the adjacency matrix from expression data in the single-set format.

Could you tell me how to get the matrix from expression data in the multi-set format?

1 answer

I see. For multi-set data, I believe you can achieve it with these commands:

consensusTOM <- consensusDissTOMandTree(multiExpr, softPower = 8, TOM = NULL)
exportNetworkToCytoscape(consensusTOM$consensusTOM)

You will want to take a look at the other parameters, particularly the values of TOM that are passed to consensusDissTOMandTree()

Thank you for your advice. I did it!

how can I add the node attributes based on which module it belongs?

based on the tutorial and your suggested code, I have tried:

consensusTOM <- consensusDissTOMandTree(multiExpr, softPower = 10, TOM = NULL)

annot = read.csv2(file = "GeneAnnotation.csv")
modules = c("brown", "red")
probes = names(multiExpr)
inModule = is.finite(match(moduleColors, modules));
modProbes = probes[inModule];
modGenes = annot$external_gene_name[match(modProbes, annot$ensembl_gene_id)];
modTOM = consensusTOM[inModule, inModule];
dimnames(modTOM) = list(modProbes, modProbes)

cyt = exportNetworkToCytoscape(consensusTOM$consensusTOM,
                               edgeFile = paste("CytoscapeInput-edges-", paste(modules, collapse="-"), ".txt", sep=""),
                               nodeFile = paste("CytoscapeInput-nodes-", paste(modules, collapse="-"), ".txt", sep=""),
                               weighted = TRUE,
                               threshold = 0.02,
                               nodeNames = modProbes,
                               altNodeNames = modGenes,
                               nodeAttr = moduleColors[inModule]);

however, I get the error

Error in consensusTOM[inModule, inModule] : 
  incorrect number of dimensions

Please trace back through each step in order to find out from where the error could be originating. I am not 100% familiar with all of these WGCNA functions.

I am unsure what you are doing with this line:

modTOM = consensusTOM[inModule, inModule]

Are you sure that this is doing what you hope?

Is this returning anything?

match(moduleColors, modules)

Module colors is loaded from

lnames = load(file = "Consensus-NetworkConstruction-auto.RData");

Although I did not write the code, I assume it simply gets the strings "brown" and "red" from the list modules.

The output of match(moduleColors, modules) looks like this:

> match(moduleColors, modules)
   [1] NA NA NA NA  1  1 NA NA NA NA NA  2 NA NA NA  1 NA NA NA NA NA NA NA NA NA  1 NA  2 NA NA  1 NA NA  1 NA NA
  [37] NA NA NA NA  2 NA NA  1 NA NA NA NA NA NA NA NA NA NA NA NA  1 NA  2 NA  1 NA NA NA NA NA  1 NA NA NA NA NA
  [73]  1 NA NA  2 NA NA NA  2 NA NA  1 NA NA  1 NA NA NA NA NA NA NA NA NA NA NA NA NA NA  2 NA NA NA NA NA NA NA

I edited the code based on section 6.b of this tutorial. I have noticed the structure of the output from consensusDissTOMandTree and TOMsimilarityFromExpr is quite different but I am not sure how to work around it.

Well, there is one major problem that needs debugging, i.e., this match() command

Log in to answer this question.