コード例 #1
0
def findPathways(cvDict,gmtName, geneDict):
	aliasDict, dict1, dict2={}, {}, {} # set up dicts for reading KEGG files
	# read in kegg gene symbol dictionaries
	nc.parseKEGGdicthsa('inputData/hsa00001.keg',aliasDict,dict1)
	nc.parseKEGGdict('inputData/ko00001.keg',aliasDict,dict2)
	namelist=find_overlaps(gmtName,cvDict) # find list of pathways with overlaps with the genes from omics data
	print('num of overlap nodes: ' + str(len(namelist)))
	for name in namelist:
		retrieveGraph(name,aliasDict,dict1,dict2, cvDict, geneDict) # find and store gpickles for graphs found
コード例 #2
0
def pipeline_fig_s3(filename):
    #Utility for supplementaryFigure3
    #python2 version, uses a GMT file as input
    aliasDict, dict1, dict2 = {}, {}, {}  # set up dicts for reading KEGG files
    nc.parseKEGGdicthsa('inputData/hsa00001.keg', aliasDict,
                        dict1)  #read in kegg gene symbol dictionaries
    nc.parseKEGGdict('inputData/ko00001.keg', aliasDict, dict2)
    keggDict = read_gmt(filename)  # read in GMT file
    namelist = keggDict.keys()  # retain all pathways
    pathwayGraphs = {}  #dictionary of digraphs
    for name in namelist:
        pathwayGraphs[name] = retrieveGraph(
            name, aliasDict, dict1,
            dict2)  # find and store gpickles for graphs found
    pickle.dump(pathwayGraphs, open('pathwayGraphs.pickle',
                                    "wb"))  # save data in correct format
    pathwayGraphs = pickle.Unpickler(open('pathwayGraphs.pickle', "rb")).load()
    supplement_S3(pathwayGraphs)
コード例 #3
0
Created on Thu May 14 10:28:45 2020
@author: Swapnil Keshari
Summary: This file rewires the network form the Dict 2 which is imported from dataprocessing_1 file
Networkx Version 2.2
"""

import networkx as nx
import matplotlib.pyplot as plt
import networkConstructor as nc
from dataprocessing_1 import Dict2
G = nx.DiGraph()

#Creates a network
code = '04060'
aliasDict, dict1, dict2 = {}, {}, {}  # set up dicts for reading KEGG files
nc.parseKEGGdicthsa('inputData/hsa00001.keg', aliasDict, dict1)
nc.parseKEGGdict('inputData/ko00001.keg', aliasDict, dict2)
coder = str('ko' + code)
nc.uploadKEGGcodes([coder], G, dict2)
coder = str('hsa' + code)
nc.uploadKEGGcodes_hsa([coder], G, dict1, dict2)

#Check for common Genes in the graph and the data (CSV) genes
Gene = set(Dict2.keys())
Gene1 = set(G.nodes())
Gene2 = Gene1.intersection(Gene)

nx.write_gml(G, "04060_initial.gml")
#Remove Self Edges
for edge in list(G.edges()):
    if edge[0] == edge[1]: