risk-network 0.0.7b12__tar.gz → 0.0.8b0__tar.gz

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.
Files changed (37) hide show
  1. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/PKG-INFO +1 -1
  2. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/__init__.py +1 -1
  3. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/permutation/permutation.py +20 -7
  4. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/PKG-INFO +1 -1
  5. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/LICENSE +0 -0
  6. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/MANIFEST.in +0 -0
  7. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/README.md +0 -0
  8. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/pyproject.toml +0 -0
  9. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/annotations/__init__.py +0 -0
  10. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/annotations/annotations.py +0 -0
  11. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/annotations/io.py +0 -0
  12. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/constants.py +0 -0
  13. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/log/__init__.py +0 -0
  14. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/log/config.py +0 -0
  15. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/log/params.py +0 -0
  16. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/__init__.py +0 -0
  17. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/community.py +0 -0
  18. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/domains.py +0 -0
  19. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/neighborhoods/neighborhoods.py +0 -0
  20. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/__init__.py +0 -0
  21. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/geometry.py +0 -0
  22. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/graph.py +0 -0
  23. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/io.py +0 -0
  24. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/network/plot.py +0 -0
  25. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/risk.py +0 -0
  26. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/__init__.py +0 -0
  27. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/hypergeom.py +0 -0
  28. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/permutation/__init__.py +0 -0
  29. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/permutation/test_functions.py +0 -0
  30. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/poisson.py +0 -0
  31. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk/stats/stats.py +0 -0
  32. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/SOURCES.txt +0 -0
  33. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/dependency_links.txt +0 -0
  34. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/requires.txt +0 -0
  35. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/risk_network.egg-info/top_level.txt +0 -0
  36. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/setup.cfg +0 -0
  37. {risk_network-0.0.7b12 → risk_network-0.0.8b0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.7b12
3
+ Version: 0.0.8b0
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
@@ -7,4 +7,4 @@ RISK: RISK Infers Spatial Kinships
7
7
 
8
8
  from risk.risk import RISK
9
9
 
10
- __version__ = "0.0.7-beta.12"
10
+ __version__ = "0.0.8-beta.0"
@@ -133,6 +133,7 @@ def _run_permutation_test(
133
133
  observed_neighborhood_scores,
134
134
  neighborhood_score_func,
135
135
  subset_size + (1 if i < remainder else 0),
136
+ num_permutations,
136
137
  progress_counter,
137
138
  max_workers,
138
139
  rng, # Pass the random number generator to each worker
@@ -144,11 +145,9 @@ def _run_permutation_test(
144
145
  results = pool.starmap_async(_permutation_process_subset, params_list, chunksize=1)
145
146
 
146
147
  # Update progress bar based on progress_counter
147
- # NOTE: Waiting for results to be ready while updating progress bar gives a big improvement
148
- # in performance, especially for large number of permutations and workers
149
148
  while not results.ready():
150
149
  progress.update(progress_counter.value - progress.n)
151
- results.wait(0.05) # Wait for 50ms
150
+ results.wait(0.1) # Wait for 100ms
152
151
  # Ensure progress bar reaches 100%
153
152
  progress.update(total_progress - progress.n)
154
153
 
@@ -167,6 +166,7 @@ def _permutation_process_subset(
167
166
  observed_neighborhood_scores: np.ndarray,
168
167
  neighborhood_score_func: Callable,
169
168
  subset_size: int,
169
+ num_permutations: int,
170
170
  progress_counter: ValueProxy,
171
171
  max_workers: int,
172
172
  rng: np.random.Generator,
@@ -180,6 +180,7 @@ def _permutation_process_subset(
180
180
  observed_neighborhood_scores (np.ndarray): Observed neighborhood scores.
181
181
  neighborhood_score_func (Callable): Function to calculate neighborhood scores.
182
182
  subset_size (int): Number of permutations to run in this subset.
183
+ num_permutations (int): Number of total permutations across all subsets.
183
184
  progress_counter (multiprocessing.managers.ValueProxy): Shared counter for tracking progress.
184
185
  max_workers (int): Number of workers for multiprocessing.
185
186
  rng (np.random.Generator): Random number generator object.
@@ -190,11 +191,15 @@ def _permutation_process_subset(
190
191
  # Initialize local count matrices for this worker
191
192
  local_counts_depletion = np.zeros(observed_neighborhood_scores.shape)
192
193
  local_counts_enrichment = np.zeros(observed_neighborhood_scores.shape)
194
+
193
195
  # NOTE: Limit the number of threads used by NumPy's BLAS implementation to 1 when more than one worker is used.
194
- # This can help prevent oversubscription of CPU resources during multiprocessing, ensuring that each process
195
- # doesn't use more than one CPU core.
196
196
  limits = None if max_workers == 1 else 1
197
197
  with threadpool_limits(limits=limits, user_api="blas"):
198
+ # Initialize a local counter for batched progress updates
199
+ local_progress = 0
200
+ # Calculate the modulo value based on total permutations for 1/100th frequency updates
201
+ modulo_value = max(1, num_permutations // 100)
202
+
198
203
  for _ in range(subset_size):
199
204
  # Permute the annotation matrix using the RNG
200
205
  annotation_matrix_permut = annotation_matrix[rng.permutation(idxs)]
@@ -212,7 +217,15 @@ def _permutation_process_subset(
212
217
  local_counts_enrichment,
213
218
  permuted_neighborhood_scores >= observed_neighborhood_scores,
214
219
  )
215
- # Update the shared progress counter
216
- progress_counter.value += 1
220
+
221
+ # Update local progress counter
222
+ local_progress += 1
223
+ # Update shared progress counter every 1/100th of total permutations
224
+ if local_progress % modulo_value == 0:
225
+ progress_counter.value += modulo_value
226
+
227
+ # Final progress update for any remaining iterations
228
+ if local_progress % modulo_value != 0:
229
+ progress_counter.value += modulo_value
217
230
 
218
231
  return local_counts_depletion, local_counts_enrichment
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.7b12
3
+ Version: 0.0.8b0
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
File without changes
File without changes