def test_read_pickled_and_run_reporter(self): from nampy.multipartiteanalysis import reporterfeatures from nampy.networkio import networkio the_network = networkio.load_pickled_network(test_reporter_input_network_filename) the_network.convert_to_multipartite() p_values_dict = {} for the_reaction in the_network.nodetypes.get_by_id('reaction').nodes: p_values_dict[the_reaction.id] = 1E-3 the_reporter_dict = reporterfeatures.calculate_reporter_scores(the_network, p_values_dict, 'metabolite', 'reaction', number_of_randomizations = 100, verbose = False) self.assertEqual(len(the_reporter_dict['p_values']), len(the_network.nodetypes.get_by_id('metabolite').nodes))
the_model_gene_pval_dict[the_gene_id] = aggregated_pvalue_dict['mapped'][the_gene_id] # Check how many mapped len(the_model_gene_pval_dict.keys()) len(the_entrez_ids) # Now we need to map back to the model transcripts the_transcript_pval_dict = {} for the_transcript in the_network.nodetypes.get_by_id("gene").nodes: the_gene_id = the_transcript.id.split(".")[0] if the_gene_id in the_model_gene_pval_dict.keys(): the_transcript_pval_dict[the_transcript.id] = the_model_gene_pval_dict[the_gene_id] # Now we map to model reactions and then run reporter metabolites hyperedge_score_dict = reporterfeatures.evaluate_reaction_pvalues(the_network, the_transcript_pval_dict) the_reporter_dict = reporterfeatures.calculate_reporter_scores(the_network, hyperedge_score_dict['p'], 'metabolite', 'reaction', number_of_randomizations = 10000) # We can prepare summar calculations to # help with network visualization. # These files can be imported to Cytoscape # to visualize the results. from math import log10 node_property_dict = {} # Uncorrected p's for the nodes from copy import deepcopy node_property_dict['uncorrected_p'] = deepcopy(hyperedge_score_dict['p']) node_property_dict['dir'] = deepcopy(hyperedge_score_dict['dir']) transcript_uncorrected_p = {} for the_transcript_id in the_transcript_pval_dict.keys():