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.
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/PKG-INFO +1 -1
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/__init__.py +1 -1
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/neighborhoods.py +0 -1
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/graph.py +19 -23
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/risk.py +1 -1
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/PKG-INFO +1 -1
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/LICENSE +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/MANIFEST.in +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/README.md +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/pyproject.toml +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/annotations/__init__.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/annotations/annotations.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/annotations/io.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/constants.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/log/__init__.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/log/console.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/log/params.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/__init__.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/community.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/neighborhoods/domains.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/__init__.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/geometry.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/io.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/network/plot.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/__init__.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/fisher_exact.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/hypergeom.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/permutation/__init__.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/permutation/permutation.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/permutation/test_functions.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk/stats/stats.py +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/SOURCES.txt +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/dependency_links.txt +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/requires.txt +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/risk_network.egg-info/top_level.txt +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/setup.cfg +0 -0
- {risk_network-0.0.7b2 → risk_network-0.0.7b4}/setup.py +0 -0
@@ -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
|
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:
|
325
|
-
|
326
|
-
#
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
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(
|
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
|
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
|
-
#
|
375
|
-
|
376
|
-
|
377
|
-
|
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(
|
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,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|