def test_lioness(): print('Start lioness test!') #1. First generate temporary PANDA files as inputs for Lioness ppi ='tests/ToyData/ToyPPIData.txt' motif ='tests/ToyData/ToyMotifData.txt' expression_data='tests/ToyData/ToyExpressionData.txt' lioness_file ='Travis' rm_missing =False output_file ='panda.npy' gt_file ='tests/panda/test_panda.txt' panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file)) # Set parameters lioness_obj = Lioness(panda_obj) lioness_obj.save_lioness_results(lioness_file) # Read first lioness network res = np.load('lioness_output/lioness.1.npy') gt = np.load('tests/lioness/lioness.1.npy') # Compare to ground truth assert(np.allclose(gt,res)) #2. Testing Lioness with motif set to None to compute Lioness on coexpression networks motif = None # Make sure to keep epxression matrix for next step panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True) lioness_obj = Lioness(panda_obj) lioness_obj.save_lioness_results(lioness_file) # Read first lioness network res = np.load('lioness_output/lioness.1.npy') gt = np.load('tests/lioness/lionessCoexpression.1.npy') # Compare to ground truth assert(np.allclose(gt,res))
def main(argv): #Create variables expression_data = None motif = None ppi = None output_file = "output_panda.txt" rm_missing = False lioness_file = False # Get input options try: opts, args = getopt.getopt(argv, 'he:m:p:o:rq:', ['help', 'expression=', 'motif=', 'ppi=', 'out=', 'rm_missing', 'lioness']) except getopt.GetoptError: print(__doc__) sys.exit() for opt, arg in opts: if opt in ('-h', '--help'): print(__doc__) sys.exit() elif opt in ('-e', '--expression'): expression_data = arg elif opt in ('-m', '--motif'): motif = arg elif opt in ('-p', '--ppi'): ppi = arg elif opt in ('-o', '--out'): output_file = arg elif opt in ('-r', '--rm_missing'): rm_missing = arg elif opt in ('-q', '--lioness'): lioness_file = arg #Check if required options are given print('Input data:') print('Expression:', expression_data) print('Motif data:', motif) print('PPI data:', ppi) if expression_data is None and motif is None: print('Missing inputs!') print(__doc__) sys.exit() # Run PANDA print('Start Panda run ...') panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file)) #panda_obj = pypanda.Panda(expression_data, motif, None, save_tmp=True, remove_missing=rm_missing) #panda_obj = pypanda.Panda(None, motif, ppi, save_tmp=True, remove_missing=rm_missing) #panda_obj = pypanda.Panda(None, motif, None, save_tmp=True, remove_missing=rm_missing) #panda_obj = pypanda.Panda(expression_data, None, ppi, save_tmp=True, remove_missing=rm_missing) panda_obj.save_panda_results(output_file) #panda_obj.top_network_plot(top=70, file='panda_topgenes.png') #indegree = panda_obj.return_panda_indegree() #outdegree = panda_obj.return_panda_outdegree() if lioness_file: from netZooPy.lioness.lioness import Lioness lioness_obj = Lioness(panda_obj) lioness_obj.save_lioness_results(lioness_file) print('All done!')
def test_panda(): #print(os.getcwd()) print('Start Panda run ...') ppi = 'tests/ToyData/ToyPPIData.txt' motif = 'tests/ToyData/ToyMotifData.txt' expression_data = 'tests/ToyData/ToyExpressionData.txt' lioness_file = '' rm_missing = False output_file = 'travis_test_panda.txt' gt_file = 'tests/panda/test_panda.txt' #1. Vanilla panda panda_obj = Panda(expression_data, motif, ppi, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file)) panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file, sep=' ', header=None) #assert(gt.equals(round(res,3))) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #2. with argument values rm_missing = False panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True) panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) assert (np.allclose(gt.iloc[:, 3], res.transpose().values.flatten())) print('Test panda passed was successful!') #3. From command line os.system( 'python3 run_panda.py -e ./tests/ToyData/ToyExpressionData.txt -m ./tests/ToyData/ToyMotifData.txt -p ./tests/ToyData/ToyPPIData.txt -o test_panda.txt -q output_panda.txt' ) res2 = pd.read_csv(output_file, sep=' ', header=None) pd.testing.assert_frame_equal(res, res2, check_less_precise=False, check_exact=False)
def test_panda(): #print(os.getcwd()) print('Start Panda run ...') ppi = 'tests/puma/ToyData/ToyPPIData.txt' motif = 'tests/puma/ToyData/ToyMotifData.txt' expression_data = 'tests/puma/ToyData/ToyExpressionData.txt' lioness_file = '' rm_missing = False output_file = 'travis_test_panda.txt' gt_file = 'tests/panda/union_test_panda.txt' gt_file_inter = 'tests/panda/inter_test_panda.txt' #0. Intersection panda_obj = Panda(expression_data, motif, ppi, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file), modeProcess='intersection') panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file_inter, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #0.1 Intersection via DataFrame expression = pd.read_csv(expression_data, sep='\t', header=None, index_col=0) motif_data = pd.read_csv(motif, sep='\t', names=['source', 'target', 'w']) ppi_data = pd.read_csv(ppi, sep='\t', header=None) panda_obj = Panda(expression, motif_data, ppi_data, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file), modeProcess='intersection') panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file_inter, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #0.2 Intersection with symmetric PPI ppi_data = pd.read_csv(ppi, sep='\t', header=None) new_df = pd.DataFrame(data={ 0: ppi_data[0], 1: ppi_data[1], 2: ppi_data[2] }) ppi_data_symm = pd.concat([ppi_data, new_df]) panda_obj = Panda(expression, motif_data, ppi_data_symm, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file), modeProcess='intersection') panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file_inter, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #1. Union panda_obj = Panda(expression_data, motif, ppi, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file), modeProcess='union') panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #2. In-degree and out-degree panda_obj = Panda(expression_data, motif, ppi, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file), modeProcess='union', save_memory=False) panda_obj.return_panda_indegree() panda_obj.return_panda_outdegree() # Lazy test assert (np.round(panda_obj.panda_indegree.iloc[0].loc['force'], 5) == 1.13971) assert (np.round(panda_obj.panda_outdegree.iloc[0].loc['force'], 5) == 1030.06840) #3. Legacy panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True, modeProcess='legacy') panda_obj.save_panda_results(output_file) gt_file = 'tests/panda/legacy_test_panda.txt' res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) print('Test panda passed was successful!') #4. None Types i = 0 gt_test_panda = 'gt_panda' test_panda = 'test_panda' for modeProcess in ['legacy', 'union', 'intersection']: print(modeProcess) #Motif i = i + 1 panda_obj = Panda(expression_data, None, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True, modeProcess=modeProcess) panda_obj.save_panda_results(test_panda + str(i) + '.txt') res = pd.read_csv(test_panda + str(i) + '.txt', sep=' ', header=None) os.system( 'curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooPy/tutorial_datasets/' + gt_test_panda + str(i) + '.txt') gt = pd.read_csv(gt_test_panda + str(i) + '.txt', sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #PPI i = i + 1 panda_obj = Panda(expression_data, motif, None, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True, modeProcess=modeProcess) panda_obj.save_panda_results(test_panda + str(i) + '.txt') res = pd.read_csv(test_panda + str(i) + '.txt', sep=' ', header=None) os.system( 'curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooPy/tutorial_datasets/' + gt_test_panda + str(i) + '.txt') gt = pd.read_csv(gt_test_panda + str(i) + '.txt', sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #Expression i = i + 1 panda_obj = Panda(None, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True, modeProcess=modeProcess) panda_obj.save_panda_results(test_panda + str(i) + '.txt') res = pd.read_csv(test_panda + str(i) + '.txt', sep=' ', header=None) os.system( 'curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooPy/tutorial_datasets/' + gt_test_panda + str(i) + '.txt') gt = pd.read_csv(gt_test_panda + str(i) + '.txt', sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #Expression and PPI i = i + 1 panda_obj = Panda(None, motif, None, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True, modeProcess=modeProcess) panda_obj.save_panda_results(test_panda + str(i) + '.txt') res = pd.read_csv(test_panda + str(i) + '.txt', sep=' ', header=None) os.system( 'curl -O https://netzoo.s3.us-east-2.amazonaws.com/netZooPy/tutorial_datasets/' + gt_test_panda + str(i) + '.txt') gt = pd.read_csv(gt_test_panda + str(i) + '.txt', sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False)
def main(argv): """ Description: Run LIONESS algorithm from the command line. Usage: -h, --help: help -e, --expression: expression matrix (.npy) -m, --motif: motif matrix, normalized (.npy) -p, --ppi: ppi matrix, normalized (.npy) -g, --comp: use cpu (default) or gpu -r, --pre: number of digits to calcluate -c, --ncores: number cores -n, --npy: PANDA network (.npy) -o, --out: output folder -f, --format: output format (txt, npy, or mat) start: to start from nth sample (optional) end: to end at nth sample (optional, must with start) Example: python3 run_lioness.py -e ../../tests/ToyData/ToyExpressionData.txt -m ../../tests/ToyData/ToyMotifData.txt -p ../../tests/ToyData/ToyPPIData.txt -g cpu -r single -c 2 -o /tmp -f npy 1 2 Reference: Kuijjer, Marieke Lydia, et al. "Estimating sample-specific regulatory networks." Iscience 14 (2019): 226-240. """ #Create variables expression_data = None motif = None ppi = None comp = None pre = None ncores = None save_dir = None save_fmt = None try: opts, args = getopt.getopt(argv, 'he:m:p:g:r:c:n:o:f:', ['help', 'expression=', 'motif=','ppi=','comp=','pre=','ncores=', 'out=', 'format=']) except getopt.GetoptError as err: print(str(err)) # will print something like "option -a not recognized" print(__doc__) return 2 for opt, arg in opts: if opt in ('-h', '--help'): print(__doc__) return 0 elif opt in ('-e', '--expression'): expression_data = arg elif opt in ('-m', '--motif'): motif = arg elif opt in ('-p', '--ppi'): ppi = arg elif opt in ('-g', '--comp'): comp = arg elif opt in ('-r', '--pre'): pre = arg elif opt in ('-c', '--ncores'): ncores = arg elif opt in ('-n'): panda_net = arg elif opt in ('-o', '--out'): save_dir = arg elif opt in ('-f', '--format'): save_fmt = arg else: print('Unknown option', opt) return 1 start, end = 1, None if len(args) == 2: start, end = map(int, args) #Check if required options are given if expression_data is None or motif is None or ppi is None \ or save_dir is None or save_fmt is None: print('Missing argument!') print(__doc__) return 1 else: print('Input data:') print('Expression: ', expression_data) print('Motif matrix: ', motif) print('PPI matrix: ', ppi) print('compute core: ', comp) print('precision: ', pre) print('n cores: ', ncores) print('Output folder:', save_dir) print('Output format:', save_fmt) print('Sample range: ', start, '-', end) # Run panda print('Start LIONESS run ...') obj = Panda(expression_data, motif, ppi, keep_expression_matrix=True,save_memory=False) L = Lioness(obj, computing=comp, precision=pre,ncores=ncores,start=start, end=end, save_dir=save_dir, save_fmt=save_fmt) print('All done!')
def test_panda(): #print(os.getcwd()) print('Start Panda run ...') ppi = 'tests/puma/ToyData/ToyPPIData.txt' motif = 'tests/puma/ToyData/ToyMotifData.txt' expression_data = 'tests/puma/ToyData/ToyExpressionData.txt' lioness_file = '' rm_missing = False output_file = 'travis_test_panda.txt' gt_file = 'tests/panda/union_test_panda.txt' #1. Union panda_obj = Panda(expression_data, motif, ppi, save_tmp=False, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file), modeProcess='union') panda_obj.save_panda_results(output_file) res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) #3. In-degree and out-degree panda_obj.return_panda_indegree() panda_obj.return_panda_outdegree() # Lazy test assert (round(panda_obj.panda_indegree.iloc[0].loc['force'], 5) == 1.13971) assert (round(panda_obj.panda_outdegree.iloc[0].loc['force'], 5) == 1030.06840) #2. Legacy panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=True, save_memory=True, modeProcess='legacy') panda_obj.save_panda_results(output_file) gt_file = 'tests/panda/legacy_test_panda.txt' res = pd.read_csv(output_file, sep=' ', header=None) gt = pd.read_csv(gt_file, sep=' ', header=None) pd.testing.assert_frame_equal(res, gt, check_less_precise=False, check_exact=False) print('Test panda passed was successful!')
def main(argv): #Create variables expression_data = None motif = None ppi = None save_dir = None save_fmt = None try: opts, args = getopt.getopt( argv, 'he:m:p:n:o:f:', ['help', 'expression=', 'motif=', 'ppi=', 'out=', 'format=']) except getopt.GetoptError as err: print(str(err)) # will print something like "option -a not recognized" print(__doc__) return 2 for opt, arg in opts: if opt in ('-h', '--help'): print(__doc__) return 0 elif opt in ('-e', '--expression'): expression_data = arg elif opt in ('-m', '--motif'): motif = arg elif opt in ('-p', '--ppi'): ppi = arg elif opt in ('-n'): panda_net = arg elif opt in ('-o', '--out'): save_dir = arg elif opt in ('-f', '--format'): save_fmt = arg else: print('Unknown option', opt) return 1 start, end = 1, None if len(args) == 2: start, end = map(int, args) #Check if required options are given if expression_data is None or motif is None or ppi is None \ or save_dir is None or save_fmt is None: print('Missing argument!') print(__doc__) return 1 else: print('Input data:') print('Expression: ', expression_data) print('Motif matrix: ', motif) print('PPI matrix: ', ppi) print('Output folder:', save_dir) print('Output format:', save_fmt) print('Sample range: ', start, '-', end) # Run panda print('Start LIONESS run ...') obj = Panda(expression_data, motif, ppi, keep_expression_matrix=True) L = Lioness(obj, start=start, end=end, save_dir=save_dir, save_fmt=save_fmt) print('All done!')
def main(argv): """ Description: Run PANDA algorithm from the command line. Inputs: -h, --help: help -e, --expression: expression values -m, --motif: pair file of motif edges, or Pearson correlation matrix when not provided -p, --ppi: pair file of PPI edges -o, --out: output file -r, --rm_missing -q, --lioness: output for Lioness single sample networks Example: python run_panda.py -e ../../tests/ToyData/ToyExpressionData.txt -m ../../tests/ToyData/ToyMotifData.txt -p ../../tests/ToyData/ToyPPIData.txt -o test_panda.txt -q output_panda.txt Reference: Glass, Kimberly, et al. "Passing messages between biological networks to refine predicted interactions." PloS one 8.5 (2013): e64832. """ #Create variables expression_data = None motif = None ppi = None output_file = "output_panda.txt" rm_missing = False lioness_file = False # Get input options try: opts, args = getopt.getopt(argv, 'he:m:p:o:rq:', [ 'help', 'expression=', 'motif=', 'ppi=', 'out=', 'rm_missing', 'lioness' ]) except getopt.GetoptError: print(__doc__) sys.exit() for opt, arg in opts: if opt in ('-h', '--help'): print(__doc__) sys.exit() elif opt in ('-e', '--expression'): expression_data = arg elif opt in ('-m', '--motif'): motif = arg elif opt in ('-p', '--ppi'): ppi = arg elif opt in ('-o', '--out'): output_file = arg elif opt in ('-r', '--rm_missing'): rm_missing = arg elif opt in ('-q', '--lioness'): lioness_file = arg #Check if required options are given print('Input data:') print('Expression:', expression_data) print('Motif data:', motif) print('PPI data:', ppi) if expression_data is None and motif is None: print('Missing inputs!') print(__doc__) sys.exit() # Run PANDA print('Start Panda run ...') panda_obj = Panda(expression_data, motif, ppi, save_tmp=True, remove_missing=rm_missing, keep_expression_matrix=bool(lioness_file)) #panda_obj = pypanda.Panda(expression_data, motif, None, save_tmp=True, remove_missing=rm_missing) #panda_obj = pypanda.Panda(None, motif, ppi, save_tmp=True, remove_missing=rm_missing) #panda_obj = pypanda.Panda(None, motif, None, save_tmp=True, remove_missing=rm_missing) #panda_obj = pypanda.Panda(expression_data, None, ppi, save_tmp=True, remove_missing=rm_missing) panda_obj.save_panda_results(output_file) #panda_obj.top_network_plot(top=70, file='panda_topgenes.png') #indegree = panda_obj.return_panda_indegree() #outdegree = panda_obj.return_panda_outdegree() if lioness_file: from netZooPy.lioness.lioness import Lioness lioness_obj = Lioness(panda_obj) lioness_obj.save_lioness_results(lioness_file) print('All done!')
def __init__(self, expression_file, motif_file, ppi_file, mir_file, modeProcess='union', computing='cpu', precision='double',save_memory = False, save_tmp=True, remove_missing=False, keep_expression_matrix = False, alpha=0.1): """ Description: Intialize instance of Puma class and load data. Inputs: expression_file : Path to file containing the gene expression data. motif_file : Path to file containing the transcription factor DNA binding motif data in the form of TF-gene-weight(0/1). If set to none, the gene coexpression matrix is returned as a result network. ppi_file : Path to file containing the PPI data. mir_file : Path to file containing miRNA data. computing : 'cpu' uses Central Processing Unit (CPU) to run PANDA. 'gpu' use the Graphical Processing Unit (GPU) to run PANDA. precision : 'double' computes the regulatory network in double precision (15 decimal digits). 'single' computes the regulatory network in single precision (7 decimal digits) which is fastaer, requires half the memory but less accurate. save_memory : True : removes temporary results from memory. The result network is weighted adjacency matrix of size (nTFs, nGenes). False: keeps the temporary files in memory. The result network has 4 columns in the form gene - TF - weight in motif prior - PUMA edge. save_tmp : Save temporary variables. remove_missing : Removes the gens and TFs that are not present in one of the priors. Works only if modeProcess='legacy'. keep_expression_matrix: Keeps the input expression matrix in the result Puma object. modeProcess : The input data processing mode. 'legacy': refers to the processing mode in netZooPy<=0.5 (Default)'union': takes the union of all TFs and genes across priors and fills the missing genes in the priors with zeros. 'intersection': intersects the input genes and TFs across priors and removes the missing TFs/genes. alpha : Learning rate (default: 0.1) """ # ===================================================================== # Data loading # ===================================================================== Panda.processData(self, modeProcess, motif_file, expression_file, ppi_file, remove_missing, keep_expression_matrix) with Timer('Loading miR data ...'): with open(mir_file, "r") as f: miR = f.read().splitlines() TFNames = self.unique_tfs sort_idx = np.argsort(TFNames) self.s1 = sort_idx[np.searchsorted(TFNames, miR, sorter=sort_idx)] if remove_missing and motif_file is not None: self.__remove_missing() # ===================================================================== # Network construction # ===================================================================== with Timer('Calculating coexpression network ...'): if self.expression_data is None: self.correlation_matrix = np.identity(self.num_genes,dtype=int) else: self.correlation_matrix = np.corrcoef(self.expression_data) if np.isnan(self.correlation_matrix).any(): np.fill_diagonal(self.correlation_matrix, 1) self.correlation_matrix = np.nan_to_num(self.correlation_matrix) if self.motif_data is None: print('Returning the correlation matrix of expression data in <Puma_obj>.correlation_matrix') #self.puma_network = self.correlation_matrix self.__pearson_results_data_frame() return # Auxiliary dicts gene2idx = {x: i for i,x in enumerate(self.gene_names)} tf2idx = {x: i for i,x in enumerate(self.unique_tfs)} with Timer('Creating motif network ...'): self.motif_matrix_unnormalized = np.zeros((self.num_tfs, self.num_genes)) idx_tfs = [tf2idx[x] for x in self.motif_data[0]] idx_genes = [gene2idx[x] for x in self.motif_data[1]] idx = np.ravel_multi_index((idx_tfs, idx_genes), self.motif_matrix_unnormalized.shape) self.motif_matrix_unnormalized.ravel()[idx] = self.motif_data[2] if self.ppi_data is None: self.ppi_matrix = np.identity(self.num_tfs,dtype=int) else: with Timer('Creating PPI network ...'): self.ppi_matrix = np.identity(self.num_tfs) idx_tf1 = [tf2idx[x] for x in self.ppi_data[0]] idx_tf2 = [tf2idx[x] for x in self.ppi_data[1]] idx = np.ravel_multi_index((idx_tf1, idx_tf2), self.ppi_matrix.shape) self.ppi_matrix.ravel()[idx] = self.ppi_data[2] idx = np.ravel_multi_index((idx_tf2, idx_tf1), self.ppi_matrix.shape) self.ppi_matrix.ravel()[idx] = self.ppi_data[2] # ===================================================================== # Network normalization # ===================================================================== with Timer('Normalizing networks ...'): self.correlation_matrix = self._normalize_network(self.correlation_matrix) with np.errstate(invalid='ignore'): # silly warning bothering people self.motif_matrix = self._normalize_network(self.motif_matrix_unnormalized) self.ppi_matrix = self._normalize_network(self.ppi_matrix) if precision=='single': self.correlation_matrix=np.float32(self.correlation_matrix) self.motif_matrix=np.float32(self.motif_matrix) self.ppi_matrix=np.float32(self.ppi_matrix) # ===================================================================== # Clean up useless variables to release memory # ===================================================================== if save_memory: print("Clearing motif and ppi data, unique tfs, and gene names for speed") del self.motif_data, self.ppi_data, self.unique_tfs, self.gene_names, self.motif_matrix_unnormalized # ===================================================================== # Saving middle data to tmp # ===================================================================== if save_tmp: with Timer('Saving expression matrix and normalized networks ...'): if self.expression_data is not None: np.save('/tmp/expression.npy', self.expression_data.values) np.save('/tmp/motif.normalized.npy', self.motif_matrix) np.save('/tmp/ppi.normalized.npy', self.ppi_matrix) # Clean up useless variables to release memory if keep_expression_matrix: self.expression_matrix = self.expression_data.values del self.expression_data # ===================================================================== # Running PUMA algorithm # ===================================================================== print('Running PUMA algorithm ...') self.puma_network = self.puma_loop(self.correlation_matrix, self.motif_matrix, self.ppi_matrix, computing, alpha)