risk-network 0.0.9b1__py3-none-any.whl → 0.0.9b2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
risk/__init__.py CHANGED
@@ -7,4 +7,4 @@ RISK: RISK Infers Spatial Kinships
7
7
 
8
8
  from risk.risk import RISK
9
9
 
10
- __version__ = "0.0.9-beta.1"
10
+ __version__ = "0.0.9-beta.2"
risk/annotations/io.py CHANGED
@@ -76,11 +76,13 @@ class AnnotationsIO:
76
76
  _log_loading(filetype, filepath=filepath)
77
77
 
78
78
  # Load the specified sheet from the Excel file
79
- df = pd.read_excel(filepath, sheet_name=sheet_name)
79
+ annotation = pd.read_excel(filepath, sheet_name=sheet_name)
80
80
  # Split the nodes column by the specified nodes_delimiter
81
- df[nodes_colname] = df[nodes_colname].apply(lambda x: x.split(nodes_delimiter))
81
+ annotation[nodes_colname] = annotation[nodes_colname].apply(
82
+ lambda x: x.split(nodes_delimiter)
83
+ )
82
84
  # Convert the DataFrame to a dictionary pairing labels with their corresponding nodes
83
- label_node_dict = df.set_index(label_colname)[nodes_colname].to_dict()
85
+ label_node_dict = annotation.set_index(label_colname)[nodes_colname].to_dict()
84
86
 
85
87
  # Load the annotations into the provided network
86
88
  return load_annotations(network, label_node_dict)
@@ -203,11 +205,11 @@ def _load_matrix_file(
203
205
  Dict[str, Any]: A dictionary where each label is paired with its respective list of nodes.
204
206
  """
205
207
  # Load the CSV or TSV file into a DataFrame
206
- df = pd.read_csv(filepath, delimiter=delimiter)
208
+ annotation = pd.read_csv(filepath, delimiter=delimiter)
207
209
  # Split the nodes column by the nodes_delimiter to handle multiple nodes per label
208
- df[nodes_colname] = df[nodes_colname].apply(lambda x: x.split(nodes_delimiter))
210
+ annotation[nodes_colname] = annotation[nodes_colname].apply(lambda x: x.split(nodes_delimiter))
209
211
  # Create a dictionary pairing labels with their corresponding list of nodes
210
- label_node_dict = df.set_index(label_colname)[nodes_colname].to_dict()
212
+ label_node_dict = annotation.set_index(label_colname)[nodes_colname].to_dict()
211
213
  return label_node_dict
212
214
 
213
215
 
risk/log/__init__.py CHANGED
@@ -4,6 +4,8 @@ risk/log
4
4
  """
5
5
 
6
6
  from .console import logger, log_header, set_global_verbosity
7
- from .params import Params
7
+ from .parameters import Params
8
8
 
9
+ # Initialize the global parameters logger
9
10
  params = Params()
11
+ params.initialize()
@@ -1,50 +1,22 @@
1
1
  """
2
- risk/log/params
3
- ~~~~~~~~~~~~~~~
2
+ risk/log/parameters
3
+ ~~~~~~~~~~~~~~~~~~~
4
4
  """
5
5
 
6
6
  import csv
7
7
  import json
8
8
  import warnings
9
9
  from datetime import datetime
10
- from functools import wraps
11
10
  from typing import Any, Dict
12
11
 
13
12
  import numpy as np
14
13
 
15
- from .console import logger, log_header
14
+ from risk.log.console import logger, log_header
16
15
 
17
16
  # Suppress all warnings - this is to resolve warnings from multiprocessing
18
17
  warnings.filterwarnings("ignore")
19
18
 
20
19
 
21
- def _safe_param_export(func):
22
- """A decorator to wrap parameter export functions in a try-except block for safe execution.
23
-
24
- Args:
25
- func (function): The function to be wrapped.
26
-
27
- Returns:
28
- function: The wrapped function with error handling.
29
- """
30
-
31
- @wraps(func)
32
- def wrapper(*args, **kwargs):
33
- try:
34
- result = func(*args, **kwargs)
35
- filepath = (
36
- kwargs.get("filepath") or args[1]
37
- ) # Assuming filepath is always the second argument
38
- logger.info(f"Parameters successfully exported to filepath: {filepath}")
39
- return result
40
- except Exception as e:
41
- filepath = kwargs.get("filepath") or args[1]
42
- logger.error(f"An error occurred while exporting parameters to {filepath}: {e}")
43
- return None
44
-
45
- return wrapper
46
-
47
-
48
20
  class Params:
49
21
  """Handles the storage and logging of various parameters for network analysis.
50
22
 
@@ -106,7 +78,6 @@ class Params:
106
78
  """
107
79
  self.plotter = {**self.plotter, **kwargs}
108
80
 
109
- @_safe_param_export
110
81
  def to_csv(self, filepath: str) -> None:
111
82
  """Export the parameters to a CSV file.
112
83
 
@@ -128,7 +99,8 @@ class Params:
128
99
  else:
129
100
  writer.writerow([parent_key, "", parent_value])
130
101
 
131
- @_safe_param_export
102
+ logger.info(f"Parameters exported to CSV file: {filepath}")
103
+
132
104
  def to_json(self, filepath: str) -> None:
133
105
  """Export the parameters to a JSON file.
134
106
 
@@ -138,7 +110,8 @@ class Params:
138
110
  with open(filepath, "w") as json_file:
139
111
  json.dump(self.load(), json_file, indent=4)
140
112
 
141
- @_safe_param_export
113
+ logger.info(f"Parameters exported to JSON file: {filepath}")
114
+
142
115
  def to_txt(self, filepath: str) -> None:
143
116
  """Export the parameters to a text file.
144
117
 
@@ -155,6 +128,8 @@ class Params:
155
128
  # Add a blank line after each entry
156
129
  txt_file.write("\n")
157
130
 
131
+ logger.info(f"Parameters exported to text file: {filepath}")
132
+
158
133
  def load(self) -> Dict[str, Any]:
159
134
  """Load and process various parameters, converting any np.ndarray values to lists.
160
135
 
@@ -101,7 +101,7 @@ def trim_domains_and_top_annotations(
101
101
  max_cluster_size (int, optional): Maximum size of a cluster to be retained. Defaults to 1000.
102
102
 
103
103
  Returns:
104
- Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]: A tuple containing:
104
+ Tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]:
105
105
  - Trimmed annotations (pd.DataFrame)
106
106
  - Trimmed domains (pd.DataFrame)
107
107
  - A DataFrame with domain labels (pd.DataFrame)
@@ -177,7 +177,7 @@ def _optimize_silhouette_across_linkage_and_metrics(
177
177
  linkage_metric (str): Linkage metric for clustering.
178
178
 
179
179
  Returns:
180
- Tuple[str, str, float]: A tuple containing:
180
+ Tuple[str, str, float]:
181
181
  - Best linkage method (str)
182
182
  - Best linkage metric (str)
183
183
  - Best threshold (float)
@@ -231,7 +231,7 @@ def _find_best_silhouette_score(
231
231
  resolution (float, optional): Desired resolution for the best threshold. Defaults to 0.001.
232
232
 
233
233
  Returns:
234
- Tuple[float, float]: A tuple containing:
234
+ Tuple[float, float]:
235
235
  - Best threshold (float): The threshold that yields the best silhouette score.
236
236
  - Best silhouette score (float): The highest silhouette score achieved.
237
237
  """
@@ -233,7 +233,7 @@ def _impute_neighbors(
233
233
  max_depth (int): Maximum depth of nodes to traverse for imputing values.
234
234
 
235
235
  Returns:
236
- tuple: A tuple containing:
236
+ Tuple[np.ndarray, np.ndarray, np.ndarray]:
237
237
  - np.ndarray: The imputed significance matrix.
238
238
  - np.ndarray: The imputed alpha threshold matrix.
239
239
  - np.ndarray: The significant significance matrix with non-significant entries set to zero.
@@ -269,7 +269,7 @@ def _impute_neighbors_with_similarity(
269
269
  max_depth (int): Maximum depth of nodes to traverse for imputing values.
270
270
 
271
271
  Returns:
272
- Tuple[np.ndarray, np.ndarray]: A tuple containing:
272
+ Tuple[np.ndarray, np.ndarray]:
273
273
  - The imputed significance matrix.
274
274
  - The imputed alpha threshold matrix.
275
275
  """
@@ -397,7 +397,7 @@ def _prune_neighbors(
397
397
  distance_threshold (float): Rank threshold (0 to 1) to determine outliers.
398
398
 
399
399
  Returns:
400
- tuple: A tuple containing:
400
+ Tuple[np.ndarray, np.ndarray, np.ndarray]:
401
401
  - np.ndarray: The updated significance matrix with outliers set to zero.
402
402
  - np.ndarray: The updated alpha threshold matrix with outliers set to zero.
403
403
  - np.ndarray: The significant significance matrix, where non-significant entries are set to zero.
@@ -0,0 +1,6 @@
1
+ """
2
+ risk/network/graph
3
+ ~~~~~~~~~~~~~~~~~~
4
+ """
5
+
6
+ from .network import NetworkGraph
@@ -1,6 +1,6 @@
1
1
  """
2
- risk/network/graph
3
- ~~~~~~~~~~~~~~~~~~
2
+ risk/network/graph/network
3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
4
4
  """
5
5
 
6
6
  from collections import defaultdict
@@ -10,6 +10,8 @@ import networkx as nx
10
10
  import numpy as np
11
11
  import pandas as pd
12
12
 
13
+ from risk.network.graph.summary import Summary
14
+
13
15
 
14
16
  class NetworkGraph:
15
17
  """A class to represent a network graph and process its nodes and edges.
@@ -23,6 +25,8 @@ class NetworkGraph:
23
25
  def __init__(
24
26
  self,
25
27
  network: nx.Graph,
28
+ annotations: Dict[str, Any],
29
+ neighborhoods: Dict[str, Any],
26
30
  top_annotations: pd.DataFrame,
27
31
  domains: pd.DataFrame,
28
32
  trimmed_domains: pd.DataFrame,
@@ -33,12 +37,15 @@ class NetworkGraph:
33
37
 
34
38
  Args:
35
39
  network (nx.Graph): The network graph.
40
+ annotations (Dict[str, Any]): The annotations associated with the network.
41
+ neighborhoods (Dict[str, Any]): Neighborhood significance data.
36
42
  top_annotations (pd.DataFrame): DataFrame containing annotations data for the network nodes.
37
43
  domains (pd.DataFrame): DataFrame containing domain data for the network nodes.
38
44
  trimmed_domains (pd.DataFrame): DataFrame containing trimmed domain data for the network nodes.
39
45
  node_label_to_node_id_map (Dict[str, Any]): A dictionary mapping node labels to their corresponding IDs.
40
46
  node_significance_sums (np.ndarray): Array containing the significant sums for the nodes.
41
47
  """
48
+ # Initialize self.network downstream of the other attributes
42
49
  self.top_annotations = top_annotations
43
50
  self.domain_id_to_node_ids_map = self._create_domain_id_to_node_ids_map(domains)
44
51
  self.domains = domains
@@ -58,12 +65,16 @@ class NetworkGraph:
58
65
  zip(node_label_to_node_id_map.keys(), node_significance_sums)
59
66
  )
60
67
  self.node_label_to_node_id_map = node_label_to_node_id_map
68
+
61
69
  # NOTE: Below this point, instance attributes (i.e., self) will be used!
62
70
  self.domain_id_to_node_labels_map = self._create_domain_id_to_node_labels_map()
63
71
  # Unfold the network's 3D coordinates to 2D and extract node coordinates
64
72
  self.network = _unfold_sphere_to_plane(network)
65
73
  self.node_coordinates = _extract_node_coordinates(self.network)
66
74
 
75
+ # NOTE: Only after the above attributes are initialized, we can create the summary
76
+ self.summary = Summary(annotations, neighborhoods, self)
77
+
67
78
  @staticmethod
68
79
  def _create_domain_id_to_node_ids_map(domains: pd.DataFrame) -> Dict[int, Any]:
69
80
  """Create a mapping from domains to the list of node IDs belonging to each domain.
@@ -0,0 +1,239 @@
1
+ """
2
+ risk/network/graph/summary
3
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
4
+ """
5
+
6
+ import warnings
7
+ from functools import lru_cache
8
+ from typing import Any, Dict, Tuple, Union
9
+
10
+ import numpy as np
11
+ import pandas as pd
12
+ from statsmodels.stats.multitest import fdrcorrection
13
+
14
+ from risk.log.console import logger, log_header
15
+
16
+
17
+ # Suppress all warnings - this is to resolve warnings from multiprocessing
18
+ warnings.filterwarnings("ignore")
19
+
20
+
21
+ class Summary:
22
+ """Handles the processing, storage, and export of network analysis results.
23
+
24
+ The Results class provides methods to process significance and depletion data, compute
25
+ FDR-corrected q-values, and structure information on domains and annotations into a
26
+ DataFrame. It also offers functionality to export the processed data in CSV, JSON,
27
+ and text formats for analysis and reporting.
28
+ """
29
+
30
+ def __init__(
31
+ self,
32
+ annotations: Dict[str, Any],
33
+ neighborhoods: Dict[str, Any],
34
+ graph, # Avoid type hinting NetworkGraph to avoid circular import
35
+ ):
36
+ """Initialize the Results object with analysis components.
37
+
38
+ Args:
39
+ annotations (Dict[str, Any]): Annotation data, including ordered annotations and matrix of associations.
40
+ neighborhoods (Dict[str, Any]): Neighborhood data containing p-values for significance and depletion analysis.
41
+ graph (NetworkGraph): Graph object representing domain-to-node and node-to-label mappings.
42
+ """
43
+ self.annotations = annotations
44
+ self.neighborhoods = neighborhoods
45
+ self.graph = graph
46
+
47
+ def to_csv(self, filepath: str) -> None:
48
+ """Export significance results to a CSV file.
49
+
50
+ Args:
51
+ filepath (str): The path where the CSV file will be saved.
52
+ """
53
+ # Load results and export directly to CSV
54
+ results = self.load()
55
+ results.to_csv(filepath, index=False)
56
+ logger.info(f"Results summary exported to CSV file: {filepath}")
57
+
58
+ def to_json(self, filepath: str) -> None:
59
+ """Export significance results to a JSON file.
60
+
61
+ Args:
62
+ filepath (str): The path where the JSON file will be saved.
63
+ """
64
+ # Load results and export directly to JSON
65
+ results = self.load()
66
+ results.to_json(filepath, orient="records", indent=4)
67
+ logger.info(f"Results summary exported to JSON file: {filepath}")
68
+
69
+ def to_txt(self, filepath: str) -> None:
70
+ """Export significance results to a text file.
71
+
72
+ Args:
73
+ filepath (str): The path where the text file will be saved.
74
+ """
75
+ # Load results and export directly to text file
76
+ results = self.load()
77
+ with open(filepath, "w") as txt_file:
78
+ txt_file.write(results.to_string(index=False))
79
+
80
+ logger.info(f"Results summary exported to text file: {filepath}")
81
+
82
+ @lru_cache(maxsize=None)
83
+ def load(self) -> pd.DataFrame:
84
+ """Load and process domain and annotation data into a DataFrame with significance metrics.
85
+
86
+ Args:
87
+ graph (Any): Graph object containing domain-to-node and node-to-label mappings.
88
+ annotations (Dict[str, Any]): Annotation details, including ordered annotations and matrix.
89
+
90
+ Returns:
91
+ pd.DataFrame: Processed DataFrame containing significance scores, p-values, q-values,
92
+ and annotation member information.
93
+ """
94
+ log_header("Loading parameters")
95
+ # Calculate significance and depletion q-values from p-value matrices in `annotations`
96
+ enrichment_pvals = self.neighborhoods["enrichment_pvals"]
97
+ depletion_pvals = self.neighborhoods["depletion_pvals"]
98
+ enrichment_qvals = self._calculate_qvalues(enrichment_pvals)
99
+ depletion_qvals = self._calculate_qvalues(depletion_pvals)
100
+
101
+ # Initialize DataFrame with domain and annotation details
102
+ results = pd.DataFrame(
103
+ [
104
+ {"Domain ID": domain_id, "Annotation": desc, "Summed Significance Score": score}
105
+ for domain_id, info in self.graph.domain_id_to_domain_info_map.items()
106
+ for desc, score in zip(info["full_descriptions"], info["significance_scores"])
107
+ ]
108
+ )
109
+ # Sort by Domain ID and Summed Significance Score
110
+ results = results.sort_values(
111
+ by=["Domain ID", "Summed Significance Score"], ascending=[True, False]
112
+ ).reset_index(drop=True)
113
+
114
+ # Add minimum p-values and q-values to DataFrame
115
+ results[
116
+ [
117
+ "Enrichment P-value",
118
+ "Enrichment Q-value",
119
+ "Depletion P-value",
120
+ "Depletion Q-value",
121
+ ]
122
+ ] = results.apply(
123
+ lambda row: self._get_significance_values(
124
+ row["Domain ID"],
125
+ row["Annotation"],
126
+ enrichment_pvals,
127
+ depletion_pvals,
128
+ enrichment_qvals,
129
+ depletion_qvals,
130
+ ),
131
+ axis=1,
132
+ result_type="expand",
133
+ )
134
+ # Add annotation members and their counts
135
+ results["Annotation Members"] = results["Annotation"].apply(
136
+ lambda desc: self._get_annotation_members(desc)
137
+ )
138
+ results["Annotation Member Count"] = results["Annotation Members"].apply(
139
+ lambda x: len(x.split(";")) if x else 0
140
+ )
141
+
142
+ # Reorder columns and drop rows with NaN values
143
+ results = (
144
+ results[
145
+ [
146
+ "Domain ID",
147
+ "Annotation",
148
+ "Annotation Members",
149
+ "Annotation Member Count",
150
+ "Summed Significance Score",
151
+ "Enrichment P-value",
152
+ "Enrichment Q-value",
153
+ "Depletion P-value",
154
+ "Depletion Q-value",
155
+ ]
156
+ ]
157
+ .dropna()
158
+ .reset_index(drop=True)
159
+ )
160
+
161
+ return results
162
+
163
+ @staticmethod
164
+ def _calculate_qvalues(pvals: np.ndarray) -> np.ndarray:
165
+ """Calculate q-values (FDR) for each row of a p-value matrix.
166
+
167
+ Args:
168
+ pvals (np.ndarray): 2D array of p-values.
169
+
170
+ Returns:
171
+ np.ndarray: 2D array of q-values, with FDR correction applied row-wise.
172
+ """
173
+ return np.apply_along_axis(lambda row: fdrcorrection(row)[1], 1, pvals)
174
+
175
+ def _get_significance_values(
176
+ self,
177
+ domain_id: int,
178
+ description: str,
179
+ enrichment_pvals: np.ndarray,
180
+ depletion_pvals: np.ndarray,
181
+ enrichment_qvals: np.ndarray,
182
+ depletion_qvals: np.ndarray,
183
+ ) -> Tuple[Union[float, None], Union[float, None], Union[float, None], Union[float, None]]:
184
+ """Retrieve the most significant p-values and q-values (FDR) for a given annotation.
185
+
186
+ Args:
187
+ domain_id (int): The domain ID associated with the annotation.
188
+ description (str): The annotation description.
189
+ enrichment_pvals (np.ndarray): Matrix of significance p-values.
190
+ depletion_pvals (np.ndarray): Matrix of depletion p-values.
191
+ enrichment_qvals (np.ndarray): Matrix of significance q-values.
192
+ depletion_qvals (np.ndarray): Matrix of depletion q-values.
193
+
194
+ Returns:
195
+ Tuple[Union[float, None], Union[float, None], Union[float, None], Union[float, None]]:
196
+ Minimum significance p-value, significance q-value, depletion p-value, depletion q-value.
197
+ """
198
+ try:
199
+ annotation_idx = self.annotations["ordered_annotations"].index(description)
200
+ except ValueError:
201
+ return None, None, None, None # Description not found
202
+
203
+ node_indices = self.graph.domain_id_to_node_ids_map.get(domain_id, [])
204
+ if not node_indices:
205
+ return None, None, None, None # No associated nodes
206
+
207
+ sig_p = enrichment_pvals[node_indices, annotation_idx]
208
+ dep_p = depletion_pvals[node_indices, annotation_idx]
209
+ sig_q = enrichment_qvals[node_indices, annotation_idx]
210
+ dep_q = depletion_qvals[node_indices, annotation_idx]
211
+
212
+ return (
213
+ np.min(sig_p) if sig_p.size > 0 else None,
214
+ np.min(sig_q) if sig_q.size > 0 else None,
215
+ np.min(dep_p) if dep_p.size > 0 else None,
216
+ np.min(dep_q) if dep_q.size > 0 else None,
217
+ )
218
+
219
+ def _get_annotation_members(self, description: str) -> str:
220
+ """Retrieve node labels associated with a given annotation description.
221
+
222
+ Args:
223
+ description (str): The annotation description.
224
+
225
+ Returns:
226
+ str: ';'-separated string of node labels that are associated with the annotation.
227
+ """
228
+ try:
229
+ annotation_idx = self.annotations["ordered_annotations"].index(description)
230
+ except ValueError:
231
+ return "" # Description not found
232
+
233
+ nodes_present = np.where(self.annotations["matrix"][:, annotation_idx] == 1)[0]
234
+ node_labels = sorted(
235
+ self.graph.node_id_to_node_label_map[node_id]
236
+ for node_id in nodes_present
237
+ if node_id in self.graph.node_id_to_node_label_map
238
+ )
239
+ return ";".join(node_labels)
risk/network/io.py CHANGED
@@ -165,12 +165,12 @@ class NetworkIO:
165
165
  filepath: str,
166
166
  source_label: str = "source",
167
167
  target_label: str = "target",
168
+ view_name: str = "",
168
169
  compute_sphere: bool = True,
169
170
  surface_depth: float = 0.0,
170
171
  min_edges_per_node: int = 0,
171
172
  include_edge_weight: bool = True,
172
173
  weight_label: str = "weight",
173
- view_name: str = "",
174
174
  ) -> nx.Graph:
175
175
  """Load a network from a Cytoscape file.
176
176
 
@@ -178,7 +178,7 @@ class NetworkIO:
178
178
  filepath (str): Path to the Cytoscape file.
179
179
  source_label (str, optional): Source node label. Defaults to "source".
180
180
  target_label (str, optional): Target node label. Defaults to "target".
181
- view_name (str, optional): Specific view name to load. Defaults to None.
181
+ view_name (str, optional): Specific view name to load. Defaults to "".
182
182
  compute_sphere (bool, optional): Whether to map nodes to a sphere. Defaults to True.
183
183
  surface_depth (float, optional): Surface depth for the sphere. Defaults to 0.0.
184
184
  min_edges_per_node (int, optional): Minimum number of edges per node. Defaults to 0.
@@ -215,7 +215,7 @@ class NetworkIO:
215
215
  filepath (str): Path to the Cytoscape file.
216
216
  source_label (str, optional): Source node label. Defaults to "source".
217
217
  target_label (str, optional): Target node label. Defaults to "target".
218
- view_name (str, optional): Specific view name to load. Defaults to None.
218
+ view_name (str, optional): Specific view name to load. Defaults to "".
219
219
 
220
220
  Returns:
221
221
  nx.Graph: Loaded and processed network.
risk/risk.py CHANGED
@@ -42,19 +42,10 @@ class RISK(NetworkIO, AnnotationsIO):
42
42
  """
43
43
  # Set global verbosity for logging
44
44
  set_global_verbosity(verbose)
45
- # Initialize and log network parameters
46
- params.initialize()
45
+ # Provide public access to the logged network parameters
46
+ self.params = params
47
47
  super().__init__()
48
48
 
49
- @property
50
- def params(self) -> params:
51
- """Access the logged network parameters.
52
-
53
- Returns:
54
- Params: An instance of the Params class with logged parameters and methods to access or update them.
55
- """
56
- return params
57
-
58
49
  def load_neighborhoods_by_hypergeom(
59
50
  self,
60
51
  network: nx.Graph,
@@ -274,7 +265,7 @@ class RISK(NetworkIO, AnnotationsIO):
274
265
 
275
266
  Args:
276
267
  network (nx.Graph): The network graph.
277
- annotations (pd.DataFrame): DataFrame containing annotation data for the network.
268
+ annotations (Dict[str, Any]): The annotations associated with the network.
278
269
  neighborhoods (Dict[str, Any]): Neighborhood significance data.
279
270
  tail (str, optional): Type of significance tail ("right", "left", "both"). Defaults to "right".
280
271
  pval_cutoff (float, optional): p-value cutoff for significance. Defaults to 0.01.
@@ -368,6 +359,8 @@ class RISK(NetworkIO, AnnotationsIO):
368
359
  # Return the fully initialized NetworkGraph object
369
360
  return NetworkGraph(
370
361
  network=network,
362
+ annotations=annotations,
363
+ neighborhoods=neighborhoods,
371
364
  top_annotations=top_annotations,
372
365
  domains=domains,
373
366
  trimmed_domains=trimmed_domains,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.9b1
3
+ Version: 0.0.9b2
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
@@ -1,21 +1,22 @@
1
- risk/__init__.py,sha256=7yr2460_NPFOQzQdsQIZ9NxTv-tlleTl5DPCHWKAOvg,112
1
+ risk/__init__.py,sha256=ICwmPcHgPSGMULpN30hPbaL4pu5GlN6TVBB5aduUyVM,112
2
2
  risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
- risk/risk.py,sha256=HVH8zXQuTWuckswsaqm7uM8u34FL4SYa_082Fjvp6xQ,23790
3
+ risk/risk.py,sha256=De1vn8Xc-TKz6aTL0bvJI-SVrIqU3k0IWAbKc7dde1c,23618
4
4
  risk/annotations/__init__.py,sha256=kXgadEXaCh0z8OyhOhTj7c3qXGmWgOhaSZ4gSzSb59U,147
5
5
  risk/annotations/annotations.py,sha256=m3WeCdE1a2undpSl_Q2I17drD95r2McKtpzhiiSdxHY,13143
6
- risk/annotations/io.py,sha256=powWzeimVdE0WCwlBCXyu5otMyZZHQujC0DS3m5DC0c,9505
7
- risk/log/__init__.py,sha256=xKeU9uK1AnVk7Yt9GTp-E-dn7Ealow2igEXZZnQRa2c,135
6
+ risk/annotations/io.py,sha256=eOkPD9G6KzkhGRc_ZW2McxQ8665o-H3uDG8bmKlzQ80,9591
7
+ risk/log/__init__.py,sha256=gy7C5L6D222AYUChq5lkc0LsCJ_QMQPaFiBJKbecdac,201
8
8
  risk/log/console.py,sha256=C52s3FgQ2e9kQWcXL8m7rs_pnKXt5Yy8PBHmQkOTiNo,4537
9
- risk/log/enrichment.py,sha256=blDqaUo5KtHn0VxkvxuAIBbwlsTrdFeQxfOyOfvUmZE,346
10
- risk/log/params.py,sha256=qSTktJ3OazldTzgtDGZkh0s30vu5kiXPkiNGLdSFDvg,6416
9
+ risk/log/parameters.py,sha256=o4StqYCa0kt7_Ht4mKa1DwwvhGUwkC_dGBaiUIc0GB0,5683
11
10
  risk/neighborhoods/__init__.py,sha256=tKKEg4lsbqFukpgYlUGxU_v_9FOqK7V0uvM9T2QzoL0,206
12
11
  risk/neighborhoods/community.py,sha256=MAgIblbuisEPwVU6mFZd4Yd9NUKlaHK99suw51r1Is0,7065
13
- risk/neighborhoods/domains.py,sha256=_Womb95Ik8i4gfnx9zpLGXyZ4dyZmqTk2XlsC6qSeTI,11722
14
- risk/neighborhoods/neighborhoods.py,sha256=KDT3zelogaioNH0HrtZrel_RQAphHCxnj3jv_XYX0sI,22229
12
+ risk/neighborhoods/domains.py,sha256=cMp2McuaSxRp7lQvzjgZnlt5dzxwyj6HAWKyT9u2sng,11662
13
+ risk/neighborhoods/neighborhoods.py,sha256=0TAP-xi4hgtnrK0cKQPHQHq9IVGHOMF1wYEcx6tsxRA,22241
15
14
  risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
16
15
  risk/network/geometry.py,sha256=gFtYUj9j9aul4paKq_qSGJn39Nazxu_MXv8m-tYYtrk,6840
17
- risk/network/graph.py,sha256=S9f8zBPBubfqBDTZJr4Fb9Ne-SPIWBdyMU4VRDtVoM4,9662
18
- risk/network/io.py,sha256=-NJ9Tg1s-DxhlDbwQGO4o87rbMqO4-BzShgnIgFoRRE,22962
16
+ risk/network/io.py,sha256=AWSbZGLZHtl72KSlafQlcYoG00YLSznG7UYDi_wDT7M,22958
17
+ risk/network/graph/__init__.py,sha256=H0YEiwqZ02LBTkH4blPwUjQ-DOUnhaTTNHM0BcXii6U,81
18
+ risk/network/graph/network.py,sha256=4tDtQExFo9U1smaaxf-CaoxHOY99aagM2G11ap_DKbY,10192
19
+ risk/network/graph/summary.py,sha256=zxkI9VyrYN5y41jlqLOIcDX0fF4wt24khtr6to36_uc,9239
19
20
  risk/network/plot/__init__.py,sha256=MfmaXJgAZJgXZ2wrhK8pXwzETlcMaLChhWXKAozniAo,98
20
21
  risk/network/plot/canvas.py,sha256=TlCpNtvoceizAumNr9I02JcBrBO6FiAFAa2ZC0bx3SU,13356
21
22
  risk/network/plot/contour.py,sha256=2ZVOlduo4Y4yIpXDJMIKO-v7eULcJ2QacQyOc7pUAxE,15267
@@ -31,8 +32,8 @@ risk/stats/stats.py,sha256=z8NrhiVj4BzJ250bVLfytpmfC7RzYu7mBuIZD_l0aCA,7222
31
32
  risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
32
33
  risk/stats/permutation/permutation.py,sha256=meBNSrbRa9P8WJ54n485l0H7VQJlMSfHqdN4aCKYCtQ,10105
33
34
  risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
34
- risk_network-0.0.9b1.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
35
- risk_network-0.0.9b1.dist-info/METADATA,sha256=3c5uAqoFdzK2gIz7kl1FYYE2uEZLv0LEeQ6_Fad3QgQ,47497
36
- risk_network-0.0.9b1.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
37
- risk_network-0.0.9b1.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
38
- risk_network-0.0.9b1.dist-info/RECORD,,
35
+ risk_network-0.0.9b2.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
36
+ risk_network-0.0.9b2.dist-info/METADATA,sha256=ccV7eOOwXIFCkiyfNIvCwLkTNQed1DuOmwXL84Nx2dY,47497
37
+ risk_network-0.0.9b2.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
38
+ risk_network-0.0.9b2.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
39
+ risk_network-0.0.9b2.dist-info/RECORD,,
risk/log/enrichment.py DELETED
@@ -1,18 +0,0 @@
1
- """
2
- risk/log/enrichment
3
- ~~~~~~~~~~~~~~~~~~~
4
- """
5
-
6
- import csv
7
- import json
8
- import warnings
9
- from datetime import datetime
10
- from functools import wraps
11
- from typing import Any, Dict
12
-
13
- import numpy as np
14
-
15
- from .console import logger, log_header
16
-
17
- # Suppress all warnings - this is to resolve warnings from multiprocessing
18
- warnings.filterwarnings("ignore")