我有以下问题:
WGCNA - http://labs.genetics.ucla.edu/horvath/htdocs/CoexpressionNetwork/Rpackages/WGCNA/Tutorials/
执行1.6节,将网络导出到外部软件(Cytoscape)
我目前正在尝试对一组基因执行WGCNA,但我在获取每个模块的顶级x hub基因时遇到了问题。我正在尝试将网络导出到Cytoscape,并使用与导出到VisANT相同的方法获取顶部x hub基因。
# 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个hub基因,第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()函数的工作方式。
发布于 2016-06-30 20:46:12
modules = "brown";
======> =行名(DatExpr_human)行中的======>数据基因和列中的样本。
inModule = is.finite(match(modules_human,模块))
modTOM = dissTOM_HumaninModule,inModule;
modProbes = probesinModule;
dimnames(modTOM) = list(modProbes,modProbes)
nTop = 30;
datExpr = t(datExpr_human)
IMConn = softConnectivity(datExpr,modProbes);
top =(排名(-IMConn) <= nTop)
cyt = exportNetworkToCytoscape(modTOMtop,edgeFile,edgeFile= paste("CytoscapeInput-edges-",paste(modules,collapse="-"),".txt",sep=""),nodeFile = paste("CytoscapeInput-nodes-",paste(modules,collapse="-"),".txt",sep=""),加权= TRUE)
https://stackoverflow.com/questions/13114681
复制相似问题