From f2b4115f67b668fbc4dd9c5d65d683cbe3decab5 Mon Sep 17 00:00:00 2001 From: Daniel Morgan Date: Fri, 8 May 2020 12:48:54 +0800 Subject: [PATCH 1/3] tiny OOP bug fix --- netZooPy/panda/panda.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/netZooPy/panda/panda.py b/netZooPy/panda/panda.py index e0c46882..25a8db60 100755 --- a/netZooPy/panda/panda.py +++ b/netZooPy/panda/panda.py @@ -30,11 +30,6 @@ class Panda(object): (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. remove_missing: removes the gens and TFs that are not present in one of the priors. Works only if modeProcess='legacy' - 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. - Methods: return_panda_indegree: computes indegree of panda network, only if save_memory = False @@ -43,7 +38,7 @@ class Panda(object): Outputs: Authors: - cychen, davidvi, alessandromarin, Marouen Ben Guebila, Daniel Morgan + cychen, davidvi, alessandromarin """ def __init__(self, expression_file, motif_file, ppi_file, computing='cpu',precision='double',save_memory = False, save_tmp=True, remove_missing=False, keep_expression_matrix = False, modeProcess = 'union'): @@ -95,7 +90,6 @@ def __init__(self, expression_file, motif_file, ppi_file, computing='cpu',precis self.panda_network = self.correlation_matrix self.__pearson_results_data_frame() - def __remove_missing(self): '''Remove genes and tfs not present in all files.''' if self.expression_data is not None: @@ -462,7 +456,7 @@ def gupdate_diagonal(diagonal_matrix, num, alpha, step): correlation_matrix=cp.array(correlation_matrix) W = 0.5 * (gt_function(ppi_matrix, motif_matrix) + gt_function(motif_matrix, correlation_matrix)) # W = (R + A) / 2 hamming = cp.abs(motif_matrix - W).mean() - motif_matrix=cp.array(motif_matrix) + motif_matrix *= (1 - alpha) motif_matrix += (alpha * W) @@ -513,7 +507,7 @@ def gupdate_diagonal(diagonal_matrix, num, alpha, step): tfs = np.tile(self.unique_tfs, (len(self.gene_names), 1)).flatten() genes = np.repeat(self.gene_names,self.num_tfs) motif = self.motif_matrix_unnormalized.flatten(order='F') - force = self.motif_matrix.flatten(order='F') + force = motif_matrix.flatten(order='F') self.export_panda_results = pd.DataFrame({'tf':tfs, 'gene': genes,'motif': motif, 'force': force}) #self.export_panda_results = np.column_stack((tfs,genes,motif,force)) return motif_matrix From e19bb8b7b18cf4b83ff4d7745d04aed7012e53ae Mon Sep 17 00:00:00 2001 From: Daniel Morgan Date: Fri, 8 May 2020 13:03:49 +0800 Subject: [PATCH 2/3] tiny OOP bug fix --- netZooPy/panda/panda.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/netZooPy/panda/panda.py b/netZooPy/panda/panda.py index 25a8db60..3d76f6fc 100755 --- a/netZooPy/panda/panda.py +++ b/netZooPy/panda/panda.py @@ -30,7 +30,11 @@ class Panda(object): (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. remove_missing: removes the gens and TFs that are not present in one of the priors. Works only if modeProcess='legacy' - + 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. + Methods: return_panda_indegree: computes indegree of panda network, only if save_memory = False return_panda_outdegree: computes outdegree of panda network, only if save_memory = False @@ -38,7 +42,7 @@ class Panda(object): Outputs: Authors: - cychen, davidvi, alessandromarin + cychen, davidvi, alessandromarin, Marouen Ben Guebila, Daniel Morgan """ def __init__(self, expression_file, motif_file, ppi_file, computing='cpu',precision='double',save_memory = False, save_tmp=True, remove_missing=False, keep_expression_matrix = False, modeProcess = 'union'): @@ -90,6 +94,7 @@ def __init__(self, expression_file, motif_file, ppi_file, computing='cpu',precis self.panda_network = self.correlation_matrix self.__pearson_results_data_frame() + def __remove_missing(self): '''Remove genes and tfs not present in all files.''' if self.expression_data is not None: @@ -456,7 +461,7 @@ def gupdate_diagonal(diagonal_matrix, num, alpha, step): correlation_matrix=cp.array(correlation_matrix) W = 0.5 * (gt_function(ppi_matrix, motif_matrix) + gt_function(motif_matrix, correlation_matrix)) # W = (R + A) / 2 hamming = cp.abs(motif_matrix - W).mean() - + motif_matrix=cp.array(motif_matrix) motif_matrix *= (1 - alpha) motif_matrix += (alpha * W) @@ -507,7 +512,7 @@ def gupdate_diagonal(diagonal_matrix, num, alpha, step): tfs = np.tile(self.unique_tfs, (len(self.gene_names), 1)).flatten() genes = np.repeat(self.gene_names,self.num_tfs) motif = self.motif_matrix_unnormalized.flatten(order='F') - force = motif_matrix.flatten(order='F') + force = self.motif_matrix.flatten(order='F') self.export_panda_results = pd.DataFrame({'tf':tfs, 'gene': genes,'motif': motif, 'force': force}) #self.export_panda_results = np.column_stack((tfs,genes,motif,force)) return motif_matrix From 99b34439262ab157476c59f9b9a2477084a48564 Mon Sep 17 00:00:00 2001 From: Daniel Morgan Date: Fri, 8 May 2020 13:07:46 +0800 Subject: [PATCH 3/3] tiny OOP bug fix --- netZooPy/panda/panda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netZooPy/panda/panda.py b/netZooPy/panda/panda.py index 3d76f6fc..c48f22dc 100755 --- a/netZooPy/panda/panda.py +++ b/netZooPy/panda/panda.py @@ -512,7 +512,7 @@ def gupdate_diagonal(diagonal_matrix, num, alpha, step): tfs = np.tile(self.unique_tfs, (len(self.gene_names), 1)).flatten() genes = np.repeat(self.gene_names,self.num_tfs) motif = self.motif_matrix_unnormalized.flatten(order='F') - force = self.motif_matrix.flatten(order='F') + force = motif_matrix.flatten(order='F') self.export_panda_results = pd.DataFrame({'tf':tfs, 'gene': genes,'motif': motif, 'force': force}) #self.export_panda_results = np.column_stack((tfs,genes,motif,force)) return motif_matrix