risk-network 0.0.9b31__py3-none-any.whl → 0.0.9b32__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.31"
10
+ __version__ = "0.0.9-beta.32"
@@ -46,19 +46,23 @@ def compute_neighborhood_score_by_stdev(
46
46
  neighborhood_score = neighborhoods_matrix @ annotation_matrix # Sparse matrix multiplication
47
47
  # Calculate the number of elements in each neighborhood (sum of rows)
48
48
  N = neighborhoods_matrix.sum(axis=1).A.flatten() # Convert to 1D array
49
- # Avoid division by zero by replacing zeros in N with np.nan temporarily
50
- N[N == 0] = np.nan
49
+ if np.any(N == 0):
50
+ # Replace zeros in N with small positive values to avoid division errors
51
+ N = np.where(N == 0, np.nan, N)
52
+
51
53
  # Compute the mean of the neighborhood scores
52
54
  M = neighborhood_score.multiply(1 / N[:, None]).toarray() # Sparse element-wise division
53
55
  # Compute the mean of squares (EXX) directly using squared annotation matrix
54
56
  annotation_squared = annotation_matrix.multiply(annotation_matrix) # Element-wise squaring
55
57
  EXX = (neighborhoods_matrix @ annotation_squared).multiply(1 / N[:, None]).toarray()
56
- # Calculate variance as EXX - M^2
57
- variance = EXX - np.power(M, 2)
58
+
59
+ # Calculate variance as EXX - M^2, ensuring no negative variances
60
+ variance = np.maximum(EXX - np.power(M, 2), 0)
58
61
  # Compute the standard deviation as the square root of the variance
59
62
  neighborhood_stdev = np.sqrt(variance)
60
- # Replace np.nan back with zeros in case N was 0 (no elements in the neighborhood)
63
+ # Replace np.nan back with zeros for rows where N was 0
61
64
  neighborhood_stdev[np.isnan(neighborhood_stdev)] = 0
65
+
62
66
  return neighborhood_stdev
63
67
 
64
68
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: risk-network
3
- Version: 0.0.9b31
3
+ Version: 0.0.9b32
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=u9we76elYKA9qWrJZg4C-XZbyChmetziqTr0kOIDH18,127
1
+ risk/__init__.py,sha256=qajW0v2X0MIHZ7-xLzacsw7D5QIhAUNYIMV5sbIS7o4,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
@@ -33,9 +33,9 @@ risk/stats/significance.py,sha256=6cKv2xBQXWTHZ6HpNWIqlNfKKS5pG_BcCUdMM3r_zw4,73
33
33
  risk/stats/stat_tests.py,sha256=MR59l5k0i5AiEIjPFPKIKHcj_nQ2wxvwW4eqYV7jOa0,11776
34
34
  risk/stats/permutation/__init__.py,sha256=OLmYLm2uj96hPsSaUs0vUqFYw6Thwch_aHtpL7L0ZFw,127
35
35
  risk/stats/permutation/permutation.py,sha256=BWjgdBpLVcHvmwHy0bmD4aJFccxifNBSrrCBPppyKf4,10569
36
- risk/stats/permutation/test_functions.py,sha256=D3XMPM8CasUNytWSRce22TI6KK6XulYn5uGG4lWxaHs,3120
37
- risk_network-0.0.9b31.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
- risk_network-0.0.9b31.dist-info/METADATA,sha256=cX2PA1RUzQx0gTvycUyJBiolwlIxQKtzuCQQmHnGYn0,47627
39
- risk_network-0.0.9b31.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
40
- risk_network-0.0.9b31.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
- risk_network-0.0.9b31.dist-info/RECORD,,
36
+ risk/stats/permutation/test_functions.py,sha256=WQpSIkCsaAMolkFUWbL58l_a4V9wUT7eyHbKKEXNGsU,3187
37
+ risk_network-0.0.9b32.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
38
+ risk_network-0.0.9b32.dist-info/METADATA,sha256=0x1A_lAgtqv9qxhRkQ_aH0jTxyIBdNPYoCwX6dsjjaQ,47627
39
+ risk_network-0.0.9b32.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
40
+ risk_network-0.0.9b32.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
41
+ risk_network-0.0.9b32.dist-info/RECORD,,