risk-network 0.0.9b29__py3-none-any.whl → 0.0.9b30__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 +1 -1
- risk/stats/stat_tests.py +40 -22
- {risk_network-0.0.9b29.dist-info → risk_network-0.0.9b30.dist-info}/METADATA +1 -1
- {risk_network-0.0.9b29.dist-info → risk_network-0.0.9b30.dist-info}/RECORD +7 -7
- {risk_network-0.0.9b29.dist-info → risk_network-0.0.9b30.dist-info}/LICENSE +0 -0
- {risk_network-0.0.9b29.dist-info → risk_network-0.0.9b30.dist-info}/WHEEL +0 -0
- {risk_network-0.0.9b29.dist-info → risk_network-0.0.9b30.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/stats/stat_tests.py
CHANGED
@@ -152,31 +152,49 @@ def compute_hypergeom_test(
|
|
152
152
|
|
153
153
|
# Sparse matrix multiplication for observed counts
|
154
154
|
annotated_in_neighborhood = neighborhoods.T @ annotations # Result is sparse
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
observed_counts
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
155
|
+
# Determine the axis with fewer vectors
|
156
|
+
axis_to_process = 0 if annotations.shape[0] < annotations.shape[1] else 1
|
157
|
+
|
158
|
+
# Initialize p-value arrays
|
159
|
+
depletion_pvals = np.empty(annotated_in_neighborhood.shape, dtype=np.float64)
|
160
|
+
enrichment_pvals = np.empty(annotated_in_neighborhood.shape, dtype=np.float64)
|
161
|
+
|
162
|
+
def compute_pvals_for_index(idx: int):
|
163
|
+
"""Compute p-values for a given index."""
|
164
|
+
if axis_to_process == 0: # Process rows
|
165
|
+
observed_counts = annotated_in_neighborhood[idx, :].toarray().flatten()
|
166
|
+
neigh_total = neighborhood_sums[idx]
|
167
|
+
return (
|
168
|
+
idx,
|
169
|
+
hypergeom.cdf(observed_counts, background_population, annotation_sums, neigh_total),
|
170
|
+
hypergeom.sf(
|
171
|
+
observed_counts - 1, background_population, annotation_sums, neigh_total
|
172
|
+
),
|
173
|
+
)
|
174
|
+
else: # Process columns
|
175
|
+
observed_counts = annotated_in_neighborhood[:, idx].toarray().flatten()
|
176
|
+
ann_total = annotation_sums[idx]
|
177
|
+
return (
|
178
|
+
idx,
|
179
|
+
hypergeom.cdf(observed_counts, background_population, ann_total, neighborhood_sums),
|
180
|
+
hypergeom.sf(
|
181
|
+
observed_counts - 1, background_population, ann_total, neighborhood_sums
|
182
|
+
),
|
183
|
+
)
|
184
|
+
|
185
|
+
# Use ThreadPoolExecutor to process indices in parallel
|
186
|
+
num_indices = annotations.shape[axis_to_process]
|
173
187
|
with ThreadPoolExecutor() as executor:
|
174
|
-
results = executor.map(
|
188
|
+
results = executor.map(compute_pvals_for_index, range(num_indices))
|
175
189
|
|
176
190
|
# Collect results
|
177
|
-
for
|
178
|
-
|
179
|
-
|
191
|
+
for idx, dep_pval, enr_pval in results:
|
192
|
+
if axis_to_process == 0: # Rows
|
193
|
+
depletion_pvals[idx, :] = dep_pval
|
194
|
+
enrichment_pvals[idx, :] = enr_pval
|
195
|
+
else: # Columns
|
196
|
+
depletion_pvals[:, idx] = dep_pval
|
197
|
+
enrichment_pvals[:, idx] = enr_pval
|
180
198
|
|
181
199
|
return {"depletion_pvals": depletion_pvals, "enrichment_pvals": enrichment_pvals}
|
182
200
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=fTPZhSt0RrpQ6uKRXrk-CSsXCmnWnq5_hfufVq6Bu-0,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
|
@@ -30,12 +30,12 @@ risk/network/plotter/utils/colors.py,sha256=VU1sLPRC99ll6EGK4vRNgLMUXU8lja1vjiXU
|
|
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=
|
33
|
+
risk/stats/stat_tests.py,sha256=e6Ep_cedc-JIK6Ap-YimX-X2oCxfFFmT5rHw99mYfYk,13171
|
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=D3XMPM8CasUNytWSRce22TI6KK6XulYn5uGG4lWxaHs,3120
|
37
|
-
risk_network-0.0.
|
38
|
-
risk_network-0.0.
|
39
|
-
risk_network-0.0.
|
40
|
-
risk_network-0.0.
|
41
|
-
risk_network-0.0.
|
37
|
+
risk_network-0.0.9b30.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
38
|
+
risk_network-0.0.9b30.dist-info/METADATA,sha256=BtXlxahgmGpryFSTVXLOOliVwQ5HG3_WNdDwStbkcgo,47627
|
39
|
+
risk_network-0.0.9b30.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
40
|
+
risk_network-0.0.9b30.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
41
|
+
risk_network-0.0.9b30.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|