risk-network 0.0.9b33__py3-none-any.whl → 0.0.9b34__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: Regional Inference of Significant Kinships
7
7
 
8
8
  from risk.risk import RISK
9
9
 
10
- __version__ = "0.0.9-beta.33"
10
+ __version__ = "0.0.9-beta.34"
risk/neighborhoods/api.py CHANGED
@@ -280,7 +280,7 @@ class NeighborhoodsAPI:
280
280
  null_distribution: str = "network",
281
281
  random_seed: int = 888,
282
282
  ) -> Dict[str, Any]:
283
- """Load significant neighborhoods for the network using the Z-score test.
283
+ """Load significant neighborhoods for the network using the z-score test.
284
284
 
285
285
  Args:
286
286
  network (nx.Graph): The network graph.
@@ -299,8 +299,8 @@ class NeighborhoodsAPI:
299
299
  Returns:
300
300
  Dict[str, Any]: Computed significance of neighborhoods.
301
301
  """
302
- log_header("Running Z-score test")
303
- # Compute neighborhood significance using the Z-score test
302
+ log_header("Running z-score test")
303
+ # Compute neighborhood significance using the z-score test
304
304
  return self._load_neighborhoods_by_statistical_test(
305
305
  network=network,
306
306
  annotations=annotations,
risk/network/io.py CHANGED
@@ -262,8 +262,25 @@ class NetworkIO:
262
262
  attribute_table.columns = attribute_table.iloc[0]
263
263
  # Skip first four rows, select source and target columns, and reset index
264
264
  attribute_table = attribute_table.iloc[4:, :]
265
- attribute_table = attribute_table[[source_label, target_label]]
265
+ try:
266
+ # Attempt to filter the attribute_table with the given labels
267
+ attribute_table = attribute_table[[source_label, target_label]]
268
+ except KeyError as e:
269
+ # Find which key(s) caused the issue
270
+ missing_keys = [
271
+ key
272
+ for key in [source_label, target_label]
273
+ if key not in attribute_table.columns
274
+ ]
275
+ # Raise the KeyError with details about the issue and available options
276
+ available_columns = ", ".join(attribute_table.columns)
277
+ raise KeyError(
278
+ f"The column(s) '{', '.join(missing_keys)}' do not exist in the table. "
279
+ f"Available columns are: {available_columns}."
280
+ ) from e
281
+
266
282
  attribute_table = attribute_table.dropna().reset_index(drop=True)
283
+
267
284
  # Create a graph
268
285
  G = nx.Graph()
269
286
  # Add edges and nodes
@@ -271,7 +288,6 @@ class NetworkIO:
271
288
  source = row[source_label]
272
289
  target = row[target_label]
273
290
  G.add_edge(source, target)
274
-
275
291
  if source not in G:
276
292
  G.add_node(source) # Optionally add x, y coordinates here if available
277
293
  if target not in G:
risk/stats/stat_tests.py CHANGED
@@ -215,7 +215,7 @@ def compute_zscore_test(
215
215
  null_distribution: str = "network",
216
216
  ) -> Dict[str, Any]:
217
217
  """
218
- Compute Z-score test for enrichment and depletion in neighborhoods with selectable null distribution.
218
+ Compute z-score test for enrichment and depletion in neighborhoods with selectable null distribution.
219
219
 
220
220
  Args:
221
221
  neighborhoods (csr_matrix): Sparse binary matrix representing neighborhoods.
@@ -257,10 +257,10 @@ def compute_zscore_test(
257
257
  * (1 - neighborhood_sums / background_population)
258
258
  )
259
259
  std_dev[std_dev == 0] = np.nan # Avoid division by zero
260
- # Compute Z-scores
260
+ # Compute z-scores
261
261
  z_scores = (observed - expected) / std_dev
262
262
 
263
- # Convert Z-scores to depletion and enrichment p-values
263
+ # Convert z-scores to depletion and enrichment p-values
264
264
  enrichment_pvals = norm.sf(z_scores) # Upper tail
265
265
  depletion_pvals = norm.cdf(z_scores) # Lower tail
266
266
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: risk-network
3
- Version: 0.0.9b33
3
+ Version: 0.0.9b34
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,4 +1,4 @@
1
- risk/__init__.py,sha256=tx937GNV-GVI2M_OD_HsV2h_fKyIPshKazJbidEHhC4,127
1
+ risk/__init__.py,sha256=cTy-m3C1NBx0HNgsqjqpPnJIoDJdLzqQMmYuajGlWQk,127
2
2
  risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
3
  risk/risk.py,sha256=s827_lRknFseOP9O4zW8sP-IcCd2EzrpV_tnVY_tz5s,1104
4
4
  risk/annotations/__init__.py,sha256=parsbcux1U4urpUqh9AdzbDWuLj9HlMidycMPkpSQFo,179
@@ -8,13 +8,13 @@ risk/log/__init__.py,sha256=7LxDysQu7doi0LAvlY2YbjN6iJH0fNknqy8lSLgeljo,217
8
8
  risk/log/console.py,sha256=PgjyEvyhYLUSHXPUKEqOmxsDsfrjPICIgqo_cAHq0N8,4575
9
9
  risk/log/parameters.py,sha256=VtwfMzLU1xI4yji3-Ch5vHjH-KdwTfwaEMmi7hFQTs0,5716
10
10
  risk/neighborhoods/__init__.py,sha256=Q74HwTH7okI-vaskJPy2bYwb5sNjGASTzJ6m8V8arCU,234
11
- risk/neighborhoods/api.py,sha256=TjIMVnSPC702zMlwyaz2i0ofNx-d9L9g3P-TTSBMx90,23341
11
+ risk/neighborhoods/api.py,sha256=ywngw2TQVV27gYlWDXcs8-qnmeepnvb-W9ov6J6VEPM,23341
12
12
  risk/neighborhoods/community.py,sha256=5Q_-VAJC-5SY5EUsB8gIlemeDoAL85uLjyl16pItHiQ,16699
13
13
  risk/neighborhoods/domains.py,sha256=jMJ4-Qzwgmo6Hya8h0E2_IcMaLpbuH_FWlmSjJl2ikc,12832
14
14
  risk/neighborhoods/neighborhoods.py,sha256=l9FhADB1C-OxM8E9QXOcA4osUDgA1vs4ud-OCGKKybc,21457
15
15
  risk/network/__init__.py,sha256=oVi3FA1XXKD84014Cykq-9bpX4_s0F3aAUfNOU-07Qw,73
16
16
  risk/network/geometry.py,sha256=eVtGHMgBf9fEqQZUFdHWjw-zFYYpfUONoHFSAxoRkug,6219
17
- risk/network/io.py,sha256=V90Me_qZ5Rt584q4qVGaLZ7I_Po5EJC544y9Vjqycnw,20917
17
+ risk/network/io.py,sha256=RCH4nQdgYDXcNwMfpSz7qEmPO0pJ1p9fL0rNQptsQrc,21673
18
18
  risk/network/graph/__init__.py,sha256=ziGJew3yhtqvrb9LUuneDu_LwW2Wa9vd4UuhoL5l1CA,91
19
19
  risk/network/graph/api.py,sha256=t5Mh5_lD2uTLioEJFfCRe7ncc5iLNYzxd6r05wSiv7s,8169
20
20
  risk/network/graph/graph.py,sha256=qEWyZvuaGT_vvjhreBdmRPX3gst2wQFaXhFAvikPSqw,12158
@@ -30,12 +30,12 @@ risk/network/plotter/utils/colors.py,sha256=EaiKsNPy_lcjrPp-QTNy3LnQdAZMjz2Legbe
30
30
  risk/network/plotter/utils/layout.py,sha256=OPqV8jzV9dpnOhYU4SYMSfsIXalVzESrlBSI_Y43OGU,3640
31
31
  risk/stats/__init__.py,sha256=2zdLv3tUHKyAjwAo7LprVXRaak1cHgrpYMVMSik6JM4,324
32
32
  risk/stats/significance.py,sha256=6cKv2xBQXWTHZ6HpNWIqlNfKKS5pG_BcCUdMM3r_zw4,7336
33
- risk/stats/stat_tests.py,sha256=MR59l5k0i5AiEIjPFPKIKHcj_nQ2wxvwW4eqYV7jOa0,11776
33
+ risk/stats/stat_tests.py,sha256=tj0ri9w89_1fsjGLuafTWpfBEwZXpSLn7Ej2aAQ5lxk,11776
34
34
  risk/stats/permutation/__init__.py,sha256=OLmYLm2uj96hPsSaUs0vUqFYw6Thwch_aHtpL7L0ZFw,127
35
35
  risk/stats/permutation/permutation.py,sha256=BWjgdBpLVcHvmwHy0bmD4aJFccxifNBSrrCBPppyKf4,10569
36
36
  risk/stats/permutation/test_functions.py,sha256=KlECWTz1EZ6EPF_OAgHb0uznaIhopiVYb_AKUKuC4no,3120
37
- risk_network-0.0.9b33.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
- risk_network-0.0.9b33.dist-info/METADATA,sha256=StXA3M84MbWRUp_6g1654AQ0rg4PirZ4HKBmGs6V_ug,47627
39
- risk_network-0.0.9b33.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
40
- risk_network-0.0.9b33.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
- risk_network-0.0.9b33.dist-info/RECORD,,
37
+ risk_network-0.0.9b34.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
+ risk_network-0.0.9b34.dist-info/METADATA,sha256=_UuXRbPm_x9dm0NHjL0V2LhLNrTXSaN1ViIrkpwpvEE,47627
39
+ risk_network-0.0.9b34.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
40
+ risk_network-0.0.9b34.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
+ risk_network-0.0.9b34.dist-info/RECORD,,