risk-network 0.0.8b27__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/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,
@@ -259,9 +250,9 @@ class RISK(NetworkIO, AnnotationsIO):
259
250
  network: nx.Graph,
260
251
  annotations: Dict[str, Any],
261
252
  neighborhoods: Dict[str, Any],
262
- tail: str = "right", # OPTIONS: "right" (enrichment), "left" (depletion), "both"
263
- pval_cutoff: float = 0.01, # OPTIONS: Any value between 0 to 1
264
- fdr_cutoff: float = 0.9999, # OPTIONS: Any value between 0 to 1
253
+ tail: str = "right",
254
+ pval_cutoff: float = 0.01,
255
+ fdr_cutoff: float = 0.9999,
265
256
  impute_depth: int = 0,
266
257
  prune_threshold: float = 0.0,
267
258
  linkage_criterion: str = "distance",
@@ -274,8 +265,8 @@ 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.
278
- neighborhoods (Dict[str, Any]): Neighborhood enrichment data.
268
+ annotations (Dict[str, Any]): The annotations associated with the network.
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.
281
272
  fdr_cutoff (float, optional): FDR cutoff for significance. Defaults to 0.9999.
@@ -360,19 +351,21 @@ class RISK(NetworkIO, AnnotationsIO):
360
351
  max_cluster_size=max_cluster_size,
361
352
  )
362
353
 
363
- # Prepare node mapping and enrichment sums for the final NetworkGraph object
354
+ # Prepare node mapping and significance sums for the final NetworkGraph object
364
355
  ordered_nodes = annotations["ordered_nodes"]
365
356
  node_label_to_id = dict(zip(ordered_nodes, range(len(ordered_nodes))))
366
- node_enrichment_sums = processed_neighborhoods["node_enrichment_sums"]
357
+ node_significance_sums = processed_neighborhoods["node_significance_sums"]
367
358
 
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,
374
367
  node_label_to_node_id_map=node_label_to_id,
375
- node_enrichment_sums=node_enrichment_sums,
368
+ node_significance_sums=node_significance_sums,
376
369
  )
377
370
 
378
371
  def load_plotter(
@@ -467,7 +460,7 @@ class RISK(NetworkIO, AnnotationsIO):
467
460
  Args:
468
461
  network (nx.Graph): The network graph.
469
462
  annotations (Dict[str, Any]): Annotations data for the network.
470
- neighborhoods (Dict[str, Any]): Neighborhood enrichment data.
463
+ neighborhoods (Dict[str, Any]): Neighborhood significance data.
471
464
  min_cluster_size (int, optional): Minimum size for clusters. Defaults to 5.
472
465
  max_cluster_size (int, optional): Maximum size for clusters. Defaults to 1000.
473
466
 
@@ -476,16 +469,18 @@ class RISK(NetworkIO, AnnotationsIO):
476
469
  """
477
470
  # Extract necessary data from annotations and neighborhoods
478
471
  ordered_annotations = annotations["ordered_annotations"]
479
- neighborhood_enrichment_sums = neighborhoods["neighborhood_enrichment_counts"]
480
- significant_enrichment_matrix = neighborhoods["significant_enrichment_matrix"]
481
- significant_binary_enrichment_matrix = neighborhoods["significant_binary_enrichment_matrix"]
472
+ neighborhood_significance_sums = neighborhoods["neighborhood_significance_counts"]
473
+ significant_significance_matrix = neighborhoods["significant_significance_matrix"]
474
+ significant_binary_significance_matrix = neighborhoods[
475
+ "significant_binary_significance_matrix"
476
+ ]
482
477
  # Call external function to define top annotations
483
478
  return define_top_annotations(
484
479
  network=network,
485
480
  ordered_annotation_labels=ordered_annotations,
486
- neighborhood_enrichment_sums=neighborhood_enrichment_sums,
487
- significant_enrichment_matrix=significant_enrichment_matrix,
488
- significant_binary_enrichment_matrix=significant_binary_enrichment_matrix,
481
+ neighborhood_significance_sums=neighborhood_significance_sums,
482
+ significant_significance_matrix=significant_significance_matrix,
483
+ significant_binary_significance_matrix=significant_binary_significance_matrix,
489
484
  min_cluster_size=min_cluster_size,
490
485
  max_cluster_size=max_cluster_size,
491
486
  )
@@ -498,7 +493,7 @@ class RISK(NetworkIO, AnnotationsIO):
498
493
  linkage_method: str,
499
494
  linkage_metric: str,
500
495
  ) -> pd.DataFrame:
501
- """Define domains in the network based on enrichment data.
496
+ """Define domains in the network based on significance data.
502
497
 
503
498
  Args:
504
499
  neighborhoods (Dict[str, Any]): Enrichment data for neighborhoods.
@@ -510,12 +505,12 @@ class RISK(NetworkIO, AnnotationsIO):
510
505
  Returns:
511
506
  pd.DataFrame: Matrix of defined domains.
512
507
  """
513
- # Extract the significant enrichment matrix from the neighborhoods data
514
- significant_neighborhoods_enrichment = neighborhoods["significant_enrichment_matrix"]
508
+ # Extract the significant significance matrix from the neighborhoods data
509
+ significant_neighborhoods_significance = neighborhoods["significant_significance_matrix"]
515
510
  # Call external function to define domains based on the extracted data
516
511
  return define_domains(
517
512
  top_annotations=top_annotations,
518
- significant_neighborhoods_enrichment=significant_neighborhoods_enrichment,
513
+ significant_neighborhoods_significance=significant_neighborhoods_significance,
519
514
  linkage_criterion=linkage_criterion,
520
515
  linkage_method=linkage_method,
521
516
  linkage_metric=linkage_metric,
risk/stats/stats.py CHANGED
@@ -44,7 +44,7 @@ def calculate_significance_matrices(
44
44
  enrichment_pvals, enrichment_qvals, pval_cutoff=pval_cutoff, fdr_cutoff=fdr_cutoff
45
45
  )
46
46
  # Compute the enrichment matrix using both q-values and p-values
47
- enrichment_matrix = (enrichment_qvals**2) * (enrichment_pvals**0.5)
47
+ enrichment_matrix = (enrichment_pvals**0.5) * (enrichment_qvals**2)
48
48
  else:
49
49
  # Compute threshold matrices based on p-value cutoffs only
50
50
  depletion_alpha_threshold_matrix = _compute_threshold_matrix(
@@ -62,7 +62,7 @@ def calculate_significance_matrices(
62
62
  log_enrichment_matrix = -np.log10(enrichment_matrix)
63
63
 
64
64
  # Select the appropriate significance matrices based on the specified tail
65
- enrichment_matrix, significant_binary_enrichment_matrix = _select_significance_matrices(
65
+ significance_matrix, significant_binary_significance_matrix = _select_significance_matrices(
66
66
  tail,
67
67
  log_depletion_matrix,
68
68
  depletion_alpha_threshold_matrix,
@@ -71,14 +71,14 @@ def calculate_significance_matrices(
71
71
  )
72
72
 
73
73
  # Filter the enrichment matrix using the binary significance matrix
74
- significant_enrichment_matrix = np.where(
75
- significant_binary_enrichment_matrix == 1, enrichment_matrix, 0
74
+ significant_significance_matrix = np.where(
75
+ significant_binary_significance_matrix == 1, significance_matrix, 0
76
76
  )
77
77
 
78
78
  return {
79
- "enrichment_matrix": enrichment_matrix,
80
- "significant_binary_enrichment_matrix": significant_binary_enrichment_matrix,
81
- "significant_enrichment_matrix": significant_enrichment_matrix,
79
+ "significance_matrix": significance_matrix,
80
+ "significant_significance_matrix": significant_significance_matrix,
81
+ "significant_binary_significance_matrix": significant_binary_significance_matrix,
82
82
  }
83
83
 
84
84
 
@@ -109,15 +109,15 @@ def _select_significance_matrices(
109
109
 
110
110
  if tail == "left":
111
111
  # Select depletion matrix and corresponding alpha threshold for left-tail analysis
112
- enrichment_matrix = -log_depletion_matrix
112
+ significance_matrix = -log_depletion_matrix
113
113
  alpha_threshold_matrix = depletion_alpha_threshold_matrix
114
114
  elif tail == "right":
115
115
  # Select enrichment matrix and corresponding alpha threshold for right-tail analysis
116
- enrichment_matrix = log_enrichment_matrix
116
+ significance_matrix = log_enrichment_matrix
117
117
  alpha_threshold_matrix = enrichment_alpha_threshold_matrix
118
118
  elif tail == "both":
119
119
  # Select the matrix with the highest absolute values while preserving the sign
120
- enrichment_matrix = np.where(
120
+ significance_matrix = np.where(
121
121
  np.abs(log_depletion_matrix) >= np.abs(log_enrichment_matrix),
122
122
  -log_depletion_matrix,
123
123
  log_enrichment_matrix,
@@ -129,10 +129,10 @@ def _select_significance_matrices(
129
129
 
130
130
  # Create a binary significance matrix where valid indices meet the alpha threshold
131
131
  valid_idxs = ~np.isnan(alpha_threshold_matrix)
132
- significant_binary_enrichment_matrix = np.zeros(alpha_threshold_matrix.shape)
133
- significant_binary_enrichment_matrix[valid_idxs] = alpha_threshold_matrix[valid_idxs]
132
+ significant_binary_significance_matrix = np.zeros(alpha_threshold_matrix.shape)
133
+ significant_binary_significance_matrix[valid_idxs] = alpha_threshold_matrix[valid_idxs]
134
134
 
135
- return enrichment_matrix, significant_binary_enrichment_matrix
135
+ return significance_matrix, significant_binary_significance_matrix
136
136
 
137
137
 
138
138
  def _compute_threshold_matrix(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.8b27
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>
@@ -0,0 +1,39 @@
1
+ risk/__init__.py,sha256=ICwmPcHgPSGMULpN30hPbaL4pu5GlN6TVBB5aduUyVM,112
2
+ risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
+ risk/risk.py,sha256=De1vn8Xc-TKz6aTL0bvJI-SVrIqU3k0IWAbKc7dde1c,23618
4
+ risk/annotations/__init__.py,sha256=kXgadEXaCh0z8OyhOhTj7c3qXGmWgOhaSZ4gSzSb59U,147
5
+ risk/annotations/annotations.py,sha256=m3WeCdE1a2undpSl_Q2I17drD95r2McKtpzhiiSdxHY,13143
6
+ risk/annotations/io.py,sha256=eOkPD9G6KzkhGRc_ZW2McxQ8665o-H3uDG8bmKlzQ80,9591
7
+ risk/log/__init__.py,sha256=gy7C5L6D222AYUChq5lkc0LsCJ_QMQPaFiBJKbecdac,201
8
+ risk/log/console.py,sha256=C52s3FgQ2e9kQWcXL8m7rs_pnKXt5Yy8PBHmQkOTiNo,4537
9
+ risk/log/parameters.py,sha256=o4StqYCa0kt7_Ht4mKa1DwwvhGUwkC_dGBaiUIc0GB0,5683
10
+ risk/neighborhoods/__init__.py,sha256=tKKEg4lsbqFukpgYlUGxU_v_9FOqK7V0uvM9T2QzoL0,206
11
+ risk/neighborhoods/community.py,sha256=MAgIblbuisEPwVU6mFZd4Yd9NUKlaHK99suw51r1Is0,7065
12
+ risk/neighborhoods/domains.py,sha256=cMp2McuaSxRp7lQvzjgZnlt5dzxwyj6HAWKyT9u2sng,11662
13
+ risk/neighborhoods/neighborhoods.py,sha256=0TAP-xi4hgtnrK0cKQPHQHq9IVGHOMF1wYEcx6tsxRA,22241
14
+ risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
15
+ risk/network/geometry.py,sha256=gFtYUj9j9aul4paKq_qSGJn39Nazxu_MXv8m-tYYtrk,6840
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
20
+ risk/network/plot/__init__.py,sha256=MfmaXJgAZJgXZ2wrhK8pXwzETlcMaLChhWXKAozniAo,98
21
+ risk/network/plot/canvas.py,sha256=TlCpNtvoceizAumNr9I02JcBrBO6FiAFAa2ZC0bx3SU,13356
22
+ risk/network/plot/contour.py,sha256=2ZVOlduo4Y4yIpXDJMIKO-v7eULcJ2QacQyOc7pUAxE,15267
23
+ risk/network/plot/labels.py,sha256=YqeOhE7nah16kK3L88JnOJVqE6WWj7lm23niVdEc8cU,45504
24
+ risk/network/plot/network.py,sha256=_yyOUoxJ_jelZV3TMCCTcGnt014TBYMUfecSLOiUb7E,13788
25
+ risk/network/plot/plotter.py,sha256=iTPMiTnTTatM_-q1Ox_bjt5Pvv-Lo8gceiYB6TVzDcw,5770
26
+ risk/network/plot/utils/color.py,sha256=rGOx4WAdjyaeWFALybkKzJabm9VSmsWb5_hsb__pcNg,19701
27
+ risk/network/plot/utils/layout.py,sha256=RnJq0yODpoheZnDl7KKFPQeXrnrsS3FLIdxupoYVZq4,3553
28
+ risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
29
+ risk/stats/hypergeom.py,sha256=oc39f02ViB1vQ-uaDrxG_tzAT6dxQBRjc88EK2EGn78,2282
30
+ risk/stats/poisson.py,sha256=polLgwS08MTCNzupYdmMUoEUYrJOjAbcYtYwjlfeE5Y,1803
31
+ risk/stats/stats.py,sha256=z8NrhiVj4BzJ250bVLfytpmfC7RzYu7mBuIZD_l0aCA,7222
32
+ risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
33
+ risk/stats/permutation/permutation.py,sha256=meBNSrbRa9P8WJ54n485l0H7VQJlMSfHqdN4aCKYCtQ,10105
34
+ risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
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,,
@@ -1,37 +0,0 @@
1
- risk/__init__.py,sha256=ac92cxvpV3NMnUqcZb1WHPrNCiY2Du_Nl1UOytIwoyg,113
2
- risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
- risk/risk.py,sha256=8GTUpj3TC7XLwEUD22-fDTKXtW7PndzW9TixWaZ23bI,23853
4
- risk/annotations/__init__.py,sha256=kXgadEXaCh0z8OyhOhTj7c3qXGmWgOhaSZ4gSzSb59U,147
5
- risk/annotations/annotations.py,sha256=dHO6kQOQjMA57nYA-yTAU1uB-ieiZ5sknAKvX6vF0Os,13024
6
- risk/annotations/io.py,sha256=powWzeimVdE0WCwlBCXyu5otMyZZHQujC0DS3m5DC0c,9505
7
- risk/log/__init__.py,sha256=xKeU9uK1AnVk7Yt9GTp-E-dn7Ealow2igEXZZnQRa2c,135
8
- risk/log/console.py,sha256=C52s3FgQ2e9kQWcXL8m7rs_pnKXt5Yy8PBHmQkOTiNo,4537
9
- risk/log/params.py,sha256=qSTktJ3OazldTzgtDGZkh0s30vu5kiXPkiNGLdSFDvg,6416
10
- risk/neighborhoods/__init__.py,sha256=tKKEg4lsbqFukpgYlUGxU_v_9FOqK7V0uvM9T2QzoL0,206
11
- risk/neighborhoods/community.py,sha256=MAgIblbuisEPwVU6mFZd4Yd9NUKlaHK99suw51r1Is0,7065
12
- risk/neighborhoods/domains.py,sha256=3iV0-nRLF2sL9_7epHY5b9AtTU-QQ84hOWO76VwFcrs,11685
13
- risk/neighborhoods/neighborhoods.py,sha256=cT9CCi1uQLn9Kv9Lxt8AN_4s63SKIlOZspvUZnx27nE,21832
14
- risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
15
- risk/network/geometry.py,sha256=gFtYUj9j9aul4paKq_qSGJn39Nazxu_MXv8m-tYYtrk,6840
16
- risk/network/graph.py,sha256=-tslu8nSbuBaqNGf6TQ8ON7C27v-BLH_37J2aC6Ke14,9602
17
- risk/network/io.py,sha256=-NJ9Tg1s-DxhlDbwQGO4o87rbMqO4-BzShgnIgFoRRE,22962
18
- risk/network/plot/__init__.py,sha256=MfmaXJgAZJgXZ2wrhK8pXwzETlcMaLChhWXKAozniAo,98
19
- risk/network/plot/canvas.py,sha256=TlCpNtvoceizAumNr9I02JcBrBO6FiAFAa2ZC0bx3SU,13356
20
- risk/network/plot/contour.py,sha256=CwX4i3uE5HL0W4kfx34U7YyoTTqMxyb7xaXKRVoNLzY,15265
21
- risk/network/plot/labels.py,sha256=fNccRds6seShMFPN6WX_7M1_qnscBkcWEH3QOJAKalk,45502
22
- risk/network/plot/network.py,sha256=6RURL1OdBFyQ34qNcwM_uH3LSQGYZZ8tZT51dggH1a0,13685
23
- risk/network/plot/plotter.py,sha256=iTPMiTnTTatM_-q1Ox_bjt5Pvv-Lo8gceiYB6TVzDcw,5770
24
- risk/network/plot/utils/color.py,sha256=WSs1ge2oZ8yXwyVk2QqBF-avRd0aYT-sYZr9cxxAn7M,19626
25
- risk/network/plot/utils/layout.py,sha256=RnJq0yODpoheZnDl7KKFPQeXrnrsS3FLIdxupoYVZq4,3553
26
- risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
27
- risk/stats/hypergeom.py,sha256=oc39f02ViB1vQ-uaDrxG_tzAT6dxQBRjc88EK2EGn78,2282
28
- risk/stats/poisson.py,sha256=polLgwS08MTCNzupYdmMUoEUYrJOjAbcYtYwjlfeE5Y,1803
29
- risk/stats/stats.py,sha256=6iGi0-oN05mTmupg6X_VEBxEQvi2rujNhfPk4aLjwNI,7186
30
- risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
31
- risk/stats/permutation/permutation.py,sha256=meBNSrbRa9P8WJ54n485l0H7VQJlMSfHqdN4aCKYCtQ,10105
32
- risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
33
- risk_network-0.0.8b27.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
34
- risk_network-0.0.8b27.dist-info/METADATA,sha256=7PXFvXkTlaMC7TB5B7P1ePXPwDPZqpXMeeKb_pVZL8o,47498
35
- risk_network-0.0.8b27.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
36
- risk_network-0.0.8b27.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
37
- risk_network-0.0.8b27.dist-info/RECORD,,