How to export a network of a specific module to Cytoscape - Consensus modules / multiExpr
1
0
Entering edit mode
3.3 years ago
Apprentice ▴ 100

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 • 2.8k views
ADD COMMENT
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

blockwiseConsensusModules() returns many objects that are all stored in the single return variable. Take a look at the working example here: WGCNA exportNetworkToCytoscape issue!!

Also, you may simple need this function to produce the adjacency matrix, which is expected by exportNetworkToCytoscape(): https://rdrr.io/cran/WGCNA/man/adjacency.html

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
2
Entering edit mode
3.3 years ago

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()

ADD COMMENT
1
Entering edit mode

Thank you for your advice. I did it!

ADD REPLY
0
Entering edit mode

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
ADD REPLY
0
Entering edit mode

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)
ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 2518 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6