splited = line.split("\t")[2:] if len(splited) > 5: msigdb_genes.append([a.strip() for a in splited]) print(msigdb_genes) l = 1000 n1 = 4 #moj graf plus njihovi sosedi geneset_scores = [] for msigdb_gene_set in msigdb_genes: print(k) k += 1 temp = get_dict(msigdb_gene_set) # name_officialName_dict if (len(temp) > 5 and len(temp) < 20): s = list( set([ name_interactor_dict[name] for name in list(temp) if name in name_interactor_dict.keys() ])) s_with_neighbours = list( set([ item for sublist in [ gene_neighbours[interactor] for interactor in s if interactor in gene_neighbours.keys() ] for item in sublist ])) + s
unija = set(gene_neighbours_2[name_interactor_dict[temp[genes[i]]]]).union( set(gene_neighbours_2[name_interactor_dict[temp[genes[j]]]])) dm[i][j] = 1 - len(presek) / float(len(unija)) return dm tested = ["ECAT1", "DPPA5", "FBXO15", "NANOG", "ERAS", "DNMT3l", "ECAT8", "GDF3", "SOX15", "DPPA4", "DPPA2", "FTHL17", "SALL4", "REX1", "UTF1", "TCL1", "DPPA3", "B-CATENIN", "STAT3", "GRB2"] simon = ["CD4", "IL2RA", "PTPRC", "FOXP3", "CTLA4", "TIGIT", "CD40LG", "THEMIS", "SATB1"] four = ["OCT3", "OCT4", "OCT3/4", "SOX2","KLF4", "C-MYC"] genes_with_gos = pickle.load(open('names_to_test.p', 'rb')) temp = get_dict(tested + simon + four + genes_with_gos) # name_officialName_dict # temp = {'OCT3':'POU5F1', 'SOX2':'SOX2', 'KLF4':'KLF4', 'C-MYC':'MYC', 'DPPA4':'DPPA4', 'FBXO15':'FBXO15', 'NANOG':'NANOG', 'ERAS':'ERAS', 'DNMT3l': 'DNMT3L', 'GDF3':'GDF3', 'SOX15':'SOX15', 'DPPA2':'DPPA2', 'SALL4':'SALL4', 'REX1':'ZFP42', 'UTF1':'UTF1', 'TCL1':'TCL1A', 'STAT3':'STAT3', 'GRB2':'GRB2', 'CD4':'CD4', 'IL2RA':'IL2RA', 'PTPRC':'PTPRC', 'FOXP3':'FOXP3', 'CTLA4':'CTLA4', 'TIGIT':'TIGIT', 'CD40LG':'CD40LG', 'THEMIS':'THEMIS', 'SATB1':'SATB1'} # temp = {'OCT3':'POU5F1', 'SOX2':'SOX2', 'KLF4':'KLF4', 'C-MYC':'MYC', 'DPPA4':'DPPA4', 'DNMT3l': 'DNMT3L', 'UTF1':'UTF1', 'TCL1':'TCL1A', 'STAT3':'STAT3', 'GRB2':'GRB2', 'CD4':'CD4'} plt.savefig('labels.png') interactor_name_dict = {} interactor_index_dict = {} # check if Pajek NET file already exists if exists(os.path.expanduser("~/PycharmProjects/pluripotency/Data/Homo_sapiens_interactions.net")): #if exists( r'.\Data\Homo_sapiens_interactions.net'): print("tuki") interactor_name_dict = pickle.load( open(os.path.expanduser("~/PycharmProjects/pluripotency/Data/interactor_name_dict.p"), "rb" ) ) interactor_index_dict = pickle.load( open(os.path.expanduser("~/PycharmProjects/pluripotency/Data/interactor_index_dict.p"), "rb" ) )
if len(splited) > 5: msigdb_genes.append([a.strip() for a in splited]) print(msigdb_genes) l = 1000 n1 = 4 #moj graf plus njihovi sosedi geneset_scores = [] for msigdb_gene_set in msigdb_genes: print(k) k += 1 temp = get_dict(msigdb_gene_set) # name_officialName_dict if (len(temp) > 5 and len(temp) < 20) : s = list(set([name_interactor_dict[name] for name in list(temp) if name in name_interactor_dict.keys()])) s_with_neighbours = list(set([item for sublist in [gene_neighbours[interactor] for interactor in s if interactor in gene_neighbours.keys()] for item in sublist])) + s S_graph = G.subgraph(s) S_plus_graph = G.subgraph(s_with_neighbours) n_S = float(S_graph.number_of_nodes()) m_S = float(S_graph.number_of_edges()) n = float(G.number_of_nodes()) m = float(G.number_of_edges()) c_S = 0 for (u,v) in S_plus_graph.edges():