R WGCNA Cytoscape hub基因

时间:2012-10-29 00:55:23

标签: r attributes count genetics cytoscape

我的

有以下问题

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

我写了一个简短的循环来计算每个基因的连接数,它按预期工作,但xth基因始终没有连接。假设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()函数的方式的工作原理。

1 个答案:

答案 0 :(得分:-1)

modules =“brown”;

probes = rownames(datExpr_human)======&gt;行中的数据基因和列中的样本。

inModule = is.finite(match(modules_human,modules))

modTOM = dissTOM_Human [inModule,inModule];

modProbes = probes [inModule];

dimnames(modTOM)= list(modProbes,modProbes)

nTop = 30;

datExpr = t(datExpr_human)

IMConn = softConnectivity(datExpr [,modProbes]);

top =(rank(-IMConn)&lt; = nTop)

cyt = exportNetworkToCytoscape(modTOM [top,top], edgeFile = paste(“CytoscapeInput-edges-”,paste(modules,collapse =“ - ”),“。txt”,sep =“”), nodeFile = paste(“CytoscapeInput-nodes-”,paste(modules,collapse =“ - ”),“。txt”,sep =“”), 加权= TRUE)