This is a test version of Biostars. For the public version, visit https://www.biostars.org.
WGCNA exportNetworkToCytoscape issue!!

Hi, I am trying to export network to cytoscape using WGCNA. I am selecting top 30 genes to export following the tutorial given by WGCNA authors.

In the following snippet of codes, nodeNames = modgenes selects the first 30 genes from genelist within module, not the top 30 genes. Inside the "cyt" function, modTOM[top,top] does provide right matrix with gene names, but once we export, the 30 genes are first 30 genes, not the top 30 genes. I am sure there is something that needs to be changed in "nodeNames = modgenes" section, but not sure how to address this.

<h6>#</h6>
modules = "blue"
genes = names(soyseq.t)
inModule = is.finite(match(moduleColors, modules))

modgenes = genes[inModule]
modGenes = annot$TAIR[match(modgenes, annot$SoyID)]

# Select the corresponding Topological Overlap
modTOM = TOM[inModule, inModule]
dimnames(modTOM) = list(modgenes, modgenes)

nTop = 30;
IMConn = softConnectivity(soyseq.t[, modgenes]);
top = (rank(-IMConn) <= nTop)

# Export the network into edge and node list files Cytoscape can read
cyt = exportNetworkToCytoscape(modTOM[top,top],
                               edgeFile = paste("CytoscapeInput-edges-", paste(modules, collapse="-"), ".txt", sep=""),
                               nodeFile = paste("CytoscapeInput-nodes-", paste(modules, collapse="-"), ".txt", sep=""),
                               weighted = TRUE,
                               threshold = 0.02,
                               nodeNames = modgenes,
                               altNodeNames = modGenes,
                               nodeAttr = moduleColors[inModule])
<h6>#</h6>
wgcna r

Hello, I know WGCNA use TOM , the function exportNetworkToCytoscape needs adjacency matrix as input. It's TOM suits here?

1 answer

Solved the issue myself by adding two more line of codes as shown below where I sorted the module gene list according to the rank.

modules = "blue"
genes = names(soyseq.t)
inModule = is.finite(match(moduleColors, modules))

modgenes = genes[inModule]

top.genes.logical = cbind(modgenes,top) ;
top.genes.sort = as.matrix (top.genes.logical[order(-top, modgenes)])

modGenes = annot$TAIR[match(top.genes.sort, annot$SoyID)]

I tried this but for my module it is still giving all genes instead of the top 30. After your modGenes call, everything else remained the same? This doesn't make sense because your top.genes.sort calls 'top' but according to your update, if the two lines you added come before modGenes then you are calling 'top' after modGenes..so this can't work.

Log in to answer this question.