risk-network 0.0.7b2__tar.gz → 0.0.7b4__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.7b2 → risk_network-0.0.7b4}/PKG-INFO +1 -1
  2. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/__init__.py +1 -1
  3. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/neighborhoods.py +0 -1
  4. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/graph.py +19 -23
  5. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/risk.py +1 -1
  6. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/PKG-INFO +1 -1
  7. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/LICENSE +0 -0
  8. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/MANIFEST.in +0 -0
  9. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/README.md +0 -0
  10. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/pyproject.toml +0 -0
  11. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/annotations/__init__.py +0 -0
  12. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/annotations/annotations.py +0 -0
  13. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/annotations/io.py +0 -0
  14. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/constants.py +0 -0
  15. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/log/__init__.py +0 -0
  16. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/log/console.py +0 -0
  17. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/log/params.py +0 -0
  18. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/__init__.py +0 -0
  19. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/community.py +0 -0
  20. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/domains.py +0 -0
  21. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/__init__.py +0 -0
  22. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/geometry.py +0 -0
  23. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/io.py +0 -0
  24. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/plot.py +0 -0
  25. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/__init__.py +0 -0
  26. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/fisher_exact.py +0 -0
  27. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/hypergeom.py +0 -0
  28. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/permutation/__init__.py +0 -0
  29. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/permutation/permutation.py +0 -0
  30. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/permutation/test_functions.py +0 -0
  31. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/stats.py +0 -0
  32. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/SOURCES.txt +0 -0
  33. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/dependency_links.txt +0 -0
  34. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/requires.txt +0 -0
  35. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/top_level.txt +0 -0
  36. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/setup.cfg +0 -0
  37. {risk_network-0.0.7b2 → risk_network-0.0.7b4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.7b2
3
+ Version: 0.0.7b4
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.2"
10
+ __version__ = "0.0.7-beta.4"
@@ -200,7 +200,6 @@ def _impute_neighbors_with_similarity(
200
200
  depth = 1
201
201
  rows_to_impute = np.where(binary_enrichment_matrix.sum(axis=1) == 0)[0]
202
202
  while len(rows_to_impute) and depth <= max_depth:
203
- next_rows_to_impute = []
204
203
  # Iterate over all enriched nodes
205
204
  for row_index in range(binary_enrichment_matrix.shape[0]):
206
205
  if binary_enrichment_matrix[row_index].sum() != 0:
@@ -3,7 +3,6 @@ risk/network/graph
3
3
  ~~~~~~~~~~~~~~~~~~
4
4
  """
5
5
 
6
- import random
7
6
  from collections import defaultdict
8
7
  from typing import Any, Dict, List, Tuple, Union
9
8
 
@@ -306,7 +305,8 @@ def _get_colors(
306
305
  Returns:
307
306
  List[Tuple]: List of RGBA colors.
308
307
  """
309
- random.seed(random_seed)
308
+ # Set random seed for reproducibility
309
+ np.random.seed(random_seed)
310
310
  # Determine the number of colors to generate based on the number of domains
311
311
  num_colors_to_generate = len(domain_id_to_node_ids_map)
312
312
  if color:
@@ -321,17 +321,15 @@ def _get_colors(
321
321
  # Step 2: Calculate pairwise distances between centroids
322
322
  centroid_array = np.array(centroids)
323
323
  dist_matrix = np.linalg.norm(centroid_array[:, None] - centroid_array, axis=-1)
324
- # Step 3: Generate positions in the colormap, with a focus on centroids that are close
325
- remaining_indices = set(range(num_colors_to_generate))
326
- # Assign distant colors to close centroids
327
- color_positions = _assign_distant_colors(
328
- remaining_indices, dist_matrix, colormap, num_colors_to_generate
329
- )
330
- # Step 4: Add some random jitter to color positions to avoid overly systematic results
331
- jitter = np.random.uniform(-0.05, 0.05, size=num_colors_to_generate)
332
- color_positions = np.clip(color_positions + jitter, 0, 1)
333
-
334
- # Step 5: Generate colors based on positions
324
+ # Step 3: Assign distant colors to close centroids
325
+ color_positions = _assign_distant_colors(dist_matrix, num_colors_to_generate)
326
+ # Step 4: Randomly shift the entire color palette while maintaining relative distances
327
+ global_shift = np.random.uniform(-0.1, 0.1) # Small global shift to change the overall palette
328
+ color_positions = (color_positions + global_shift) % 1 # Wrap around to keep within [0, 1]
329
+ # Step 5: Ensure that all positions remain between 0 and 1
330
+ color_positions = np.clip(color_positions, 0, 1)
331
+
332
+ # Step 6: Generate RGBA colors based on positions
335
333
  return [colormap(pos) for pos in color_positions]
336
334
 
337
335
 
@@ -358,28 +356,26 @@ def _calculate_centroids(network, domain_id_to_node_ids_map):
358
356
  return centroids
359
357
 
360
358
 
361
- def _assign_distant_colors(remaining_indices, dist_matrix, colormap, num_colors_to_generate):
359
+ def _assign_distant_colors(dist_matrix, num_colors_to_generate):
362
360
  """Assign colors to centroids that are close in space, ensuring stark color differences.
363
361
 
364
362
  Args:
365
- remaining_indices (set): Indices of centroids left to color.
366
363
  dist_matrix (ndarray): Matrix of pairwise centroid distances.
367
- colormap (Colormap): The colormap used to assign colors.
368
364
  num_colors_to_generate (int): Number of colors to generate.
369
365
 
370
366
  Returns:
371
- np.array: Array of color positions in the colormap.
367
+ np.array: Array of color positions in the range [0, 1].
372
368
  """
373
369
  color_positions = np.zeros(num_colors_to_generate)
374
- # Convert the set to a list to index over it
375
- remaining_indices = list(remaining_indices)
376
- # Sort remaining indices by centroid proximity (based on sum of distances to others)
377
- proximity_order = sorted(remaining_indices, key=lambda idx: np.sum(dist_matrix[idx]))
378
- # Assign colors starting with the most distant points in proximity order
370
+ # Step 1: Sort indices by centroid proximity (based on sum of distances to others)
371
+ proximity_order = sorted(
372
+ range(num_colors_to_generate), key=lambda idx: np.sum(dist_matrix[idx])
373
+ )
374
+ # Step 2: Assign colors starting with the most distant points in proximity order
379
375
  for i, idx in enumerate(proximity_order):
380
376
  color_positions[idx] = i / num_colors_to_generate
381
377
 
382
- # Adjust colors so that centroids close to one another are maximally distant on the color spectrum
378
+ # Step 3: Adjust colors so that centroids close to one another are maximally distant on the color spectrum
383
379
  half_spectrum = int(num_colors_to_generate / 2)
384
380
  for i in range(half_spectrum):
385
381
  # Split the spectrum so that close centroids are assigned distant colors
@@ -315,7 +315,7 @@ class RISK(NetworkIO, AnnotationsIO):
315
315
  max_cluster_size=max_cluster_size,
316
316
  )
317
317
 
318
- print_header(f"Optimizing distance threshold for domains")
318
+ print_header("Optimizing distance threshold for domains")
319
319
  # Define domains in the network using the specified clustering settings
320
320
  domains = self._define_domains(
321
321
  neighborhoods=processed_neighborhoods,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.7b2
3
+ Version: 0.0.7b4
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
File without changes
File without changes