我有以下问题
WGCNA-http://labs.genetics.ucla.edu/horvath/htdocs/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/
处理第1.6节“将网络导出到外部软件(Cytoscape)”
我目前正在尝试对一组基因执行WGCNA,但在获取每个模块的前x集线器基因方面遇到困难。我正在尝试将网络导出到Cytoscape,并使用与导出到VisANT概述的方法相同的方法来获取顶级的x集线器基因。
# Select modules (only interested in one for now)
modules = c("greenyellow")
# Select module probes
probes = names(datExpr)
inModule = is.finite(match(bwModuleColors, modules))
modProbes = probes[inModule]
modGenes = annot$gene_symbols[match(modProbes, annot$geneID)]
# Select the corresponding Topological Overlap
modTOM = TOM[inModule, inModule]
dimnames(modTOM) = list(modProbes, modProbes)
# Restrict the network to the top 30 genes
nTop = 30
IMConn = softConnectivity(datExpr[, modProbes]
top = (order(-IMConn) <= nTop)
# Export the network into a fomat that 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 = ""),
weight = TRUE,
threshold = 0.02,
nodeNames = modProbes,
altNodeNames = modGenes,
nodeAttr = bwModuleColors[inModule])
我已经写了一个简短的循环来计算与每个基因的连接数,它可以按预期工作,但是第x个基因始终具有零连接。假设x为30。如果我将截止值增加到31个集线器基因,则第30个基因现在显示与网络中其他基因的连接,但是第31个基因则什么也不显示。此外,这种变化增加并减少了与网络中其他基因的连接数。这确实让我感到困扰,因为仅应添加连接,因为网络会因一个基因而变大,并且更改应由第30个基因来解释,但输出情况并非如此。
# Split the cytoscape file into two parts: edge and node
node <- cyt$nodeData
edge <- cyt$edgeData
# The limit covers all of the connections in the edge file by determining the length of the column ‘fromNode’
limit <- length(edge$fromNode)
# Create an empty list to store the counts for each gene
counts = list()
# Loop for the genes going from 1 to the number of genes specified for the network, ‘nTop’
for (i in 1:nTop) {
# Reset the count for each new gene and specify the names of the gene of interest and the matching genes
name = node$nodeName[[i]]
count = 0
# Nested loop that searches for matches to the gene in question in both the ‘fromNode’ and ‘toNode’columns, and adds one to the count for each match.
for (j in 1:limit) {
matchName1 = edge$fromNode[[j]]
matchName2 = edge$toNode[[j]]
if (name == matchName1 || name == matchName2)
{count = count + 1}
}
# Create a string for the attribute in the correct format
attribute <- paste(name, "=", count)
# Adds the count to the list
counts <- c(counts, attribute)
}
# End of loop
循环似乎按预期方式工作,因此我认为问题出在网络建设上。我目前正在回溯我对线性代数,矩阵和拓扑的了解,以尝试查看问题是它们的排序方式还是类似的方式,但这可能只是exportNetworkToCytoscape()函数的方式作品。
最佳答案
模块=“棕色”;
探针=行名(datExpr_human)======>行中的数据基因和列中的样本。
inModule = is.finite(match(modules_human,modules))
modTOM = dissTOM_Human [inModule,inModule];
modProbes =探针[inModule];
dimnames(modTOM)=列表(modProbes,modProbes)
nTop = 30;
datExpr = t(datExpr_human)
IMConn = softConnectivity(datExpr [,modProbes]);
顶部=(rank(-IMConn)
cyt = exportNetworkToCytoscape(modTOM [top,top],
edgeFile = paste(“ CytoscapeInput-edges-”,paste(modules,crash =“-”),“ .txt”,sep =“”),
nodeFile = paste(“ CytoscapeInput-nodes-”,paste(modules,crash =“-”),“ .txt”,sep =“”),
加权= TRUE)