risk-network 0.0.8b16__py3-none-any.whl → 0.0.8b18__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/network/plot/canvas.py +13 -7
- risk/network/plot/contour.py +10 -8
- risk/network/plot/labels.py +43 -29
- risk/network/plot/network.py +17 -11
- risk/network/plot/plotter.py +7 -5
- risk/network/plot/utils/color.py +31 -29
- {risk_network-0.0.8b16.dist-info → risk_network-0.0.8b18.dist-info}/METADATA +1 -1
- {risk_network-0.0.8b16.dist-info → risk_network-0.0.8b18.dist-info}/RECORD +12 -12
- {risk_network-0.0.8b16.dist-info → risk_network-0.0.8b18.dist-info}/LICENSE +0 -0
- {risk_network-0.0.8b16.dist-info → risk_network-0.0.8b18.dist-info}/WHEEL +0 -0
- {risk_network-0.0.8b16.dist-info → risk_network-0.0.8b18.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/network/plot/canvas.py
CHANGED
@@ -34,8 +34,8 @@ class Canvas:
|
|
34
34
|
title_fontsize: int = 20,
|
35
35
|
subtitle_fontsize: int = 14,
|
36
36
|
font: str = "Arial",
|
37
|
-
title_color: str = "black",
|
38
|
-
subtitle_color: str = "gray",
|
37
|
+
title_color: Union[str, list, tuple, np.ndarray] = "black",
|
38
|
+
subtitle_color: Union[str, list, tuple, np.ndarray] = "gray",
|
39
39
|
title_y: float = 0.975,
|
40
40
|
title_space_offset: float = 0.075,
|
41
41
|
subtitle_offset: float = 0.025,
|
@@ -48,8 +48,10 @@ class Canvas:
|
|
48
48
|
title_fontsize (int, optional): Font size for the title. Defaults to 20.
|
49
49
|
subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to 14.
|
50
50
|
font (str, optional): Font family used for both title and subtitle. Defaults to "Arial".
|
51
|
-
title_color (str, optional): Color of the title text.
|
52
|
-
|
51
|
+
title_color (str, list, tuple, or np.ndarray, optional): Color of the title text. Can be a string or an array of colors.
|
52
|
+
Defaults to "black".
|
53
|
+
subtitle_color (str, list, tuple, or np.ndarray, optional): Color of the subtitle text. Can be a string or an array of colors.
|
54
|
+
Defaults to "gray".
|
53
55
|
title_y (float, optional): Y-axis position of the title. Defaults to 0.975.
|
54
56
|
title_space_offset (float, optional): Fraction of figure height to leave for the space above the plot. Defaults to 0.075.
|
55
57
|
subtitle_offset (float, optional): Offset factor to position the subtitle below the title. Defaults to 0.025.
|
@@ -142,7 +144,9 @@ class Canvas:
|
|
142
144
|
)
|
143
145
|
|
144
146
|
# Convert color to RGBA using the to_rgba helper function - use outline_alpha for the perimeter
|
145
|
-
color = to_rgba(
|
147
|
+
color = to_rgba(
|
148
|
+
color=color, alpha=outline_alpha, num_repeats=1
|
149
|
+
) # num_repeats=1 for a single color
|
146
150
|
# Set the fill_alpha to 0 if not provided
|
147
151
|
fill_alpha = fill_alpha if fill_alpha is not None else 0.0
|
148
152
|
# Extract node coordinates from the network graph
|
@@ -163,7 +167,9 @@ class Canvas:
|
|
163
167
|
)
|
164
168
|
# Set the transparency of the fill if applicable
|
165
169
|
if fill_alpha > 0:
|
166
|
-
circle.set_facecolor(
|
170
|
+
circle.set_facecolor(
|
171
|
+
to_rgba(color=color, alpha=fill_alpha, num_repeats=1)
|
172
|
+
) # num_repeats=1 for a single color
|
167
173
|
|
168
174
|
self.ax.add_artist(circle)
|
169
175
|
|
@@ -210,7 +216,7 @@ class Canvas:
|
|
210
216
|
)
|
211
217
|
|
212
218
|
# Convert color to RGBA using outline_alpha for the line (outline)
|
213
|
-
outline_color = to_rgba(color=color)
|
219
|
+
outline_color = to_rgba(color=color, num_repeats=1) # num_repeats=1 for a single color
|
214
220
|
# Extract node coordinates from the network graph
|
215
221
|
node_coordinates = self.graph.node_coordinates
|
216
222
|
# Scale the node coordinates if needed
|
risk/network/plot/contour.py
CHANGED
@@ -110,7 +110,7 @@ class Contour:
|
|
110
110
|
bandwidth (float, optional): Bandwidth for KDE. Controls the smoothness of the contour. Defaults to 0.8.
|
111
111
|
grid_size (int, optional): Resolution of the grid for KDE. Higher values create finer contours. Defaults to 250.
|
112
112
|
color (str, list, tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array.
|
113
|
-
Defaults to "white".
|
113
|
+
Can be a single color or an array of colors. Defaults to "white".
|
114
114
|
linestyle (str, optional): Line style for the contour. Defaults to "solid".
|
115
115
|
linewidth (float, optional): Line width for the contour. Defaults to 1.5.
|
116
116
|
alpha (float, None, optional): Transparency level of the contour lines. If provided, it overrides any existing alpha values
|
@@ -125,15 +125,16 @@ class Contour:
|
|
125
125
|
if any(isinstance(item, (list, tuple, np.ndarray)) for item in nodes):
|
126
126
|
# If it's a list of lists, iterate over sublists
|
127
127
|
node_groups = nodes
|
128
|
+
# Convert color to RGBA arrays to match the number of groups
|
129
|
+
color_rgba = to_rgba(color=color, alpha=alpha, num_repeats=len(node_groups))
|
128
130
|
else:
|
129
131
|
# If it's a flat list of nodes, treat it as a single group
|
130
132
|
node_groups = [nodes]
|
131
|
-
|
132
|
-
|
133
|
-
color_rgba = to_rgba(color=color, alpha=alpha)
|
133
|
+
# Wrap the RGBA color in an array to index the first element
|
134
|
+
color_rgba = to_rgba(color=color, alpha=alpha, num_repeats=1)
|
134
135
|
|
135
136
|
# Iterate over each group of nodes (either sublists or flat list)
|
136
|
-
for sublist in node_groups:
|
137
|
+
for idx, sublist in enumerate(node_groups):
|
137
138
|
# Filter to get node IDs and their coordinates for each sublist
|
138
139
|
node_ids = [
|
139
140
|
self.graph.node_label_to_node_id_map.get(node)
|
@@ -151,7 +152,7 @@ class Contour:
|
|
151
152
|
self.ax,
|
152
153
|
node_coordinates,
|
153
154
|
node_ids,
|
154
|
-
color=color_rgba,
|
155
|
+
color=color_rgba[idx],
|
155
156
|
levels=levels,
|
156
157
|
bandwidth=bandwidth,
|
157
158
|
grid_size=grid_size,
|
@@ -273,7 +274,7 @@ class Contour:
|
|
273
274
|
def get_annotated_contour_colors(
|
274
275
|
self,
|
275
276
|
cmap: str = "gist_rainbow",
|
276
|
-
color: Union[str, None] = None,
|
277
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
277
278
|
min_scale: float = 0.8,
|
278
279
|
max_scale: float = 1.0,
|
279
280
|
scale_factor: float = 1.0,
|
@@ -283,7 +284,8 @@ class Contour:
|
|
283
284
|
|
284
285
|
Args:
|
285
286
|
cmap (str, optional): Name of the colormap to use for generating contour colors. Defaults to "gist_rainbow".
|
286
|
-
color (str or None, optional): Color to use for the contours.
|
287
|
+
color (str, list, tuple, np.ndarray, or None, optional): Color to use for the contours. Can be a single color or an array of colors.
|
288
|
+
If None, the colormap will be used. Defaults to None.
|
287
289
|
min_scale (float, optional): Minimum intensity scale for the colors generated by the colormap.
|
288
290
|
Controls the dimmest colors. Defaults to 0.8.
|
289
291
|
max_scale (float, optional): Maximum intensity scale for the colors generated by the colormap.
|
risk/network/plot/labels.py
CHANGED
@@ -285,13 +285,19 @@ class Labels:
|
|
285
285
|
if any(isinstance(item, (list, tuple, np.ndarray)) for item in nodes):
|
286
286
|
# If it's a list of lists, iterate over sublists
|
287
287
|
node_groups = nodes
|
288
|
+
# Convert fontcolor and arrow_color to RGBA arrays to match the number of groups
|
289
|
+
fontcolor_rgba = to_rgba(color=fontcolor, alpha=fontalpha, num_repeats=len(node_groups))
|
290
|
+
arrow_color_rgba = to_rgba(
|
291
|
+
color=arrow_color, alpha=arrow_alpha, num_repeats=len(node_groups)
|
292
|
+
)
|
288
293
|
else:
|
289
294
|
# If it's a flat list of nodes, treat it as a single group
|
290
295
|
node_groups = [nodes]
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
296
|
+
# Wrap the RGBA fontcolor and arrow_color in an array to index the first element
|
297
|
+
fontcolor_rgba = np.array(to_rgba(color=fontcolor, alpha=fontalpha, num_repeats=1))
|
298
|
+
arrow_color_rgba = np.array(
|
299
|
+
to_rgba(color=arrow_color, alpha=arrow_alpha, num_repeats=1)
|
300
|
+
)
|
295
301
|
|
296
302
|
# Calculate the bounding box around the network
|
297
303
|
center, radius = calculate_bounding_box(self.graph.node_coordinates, radius_margin=scale)
|
@@ -303,7 +309,7 @@ class Labels:
|
|
303
309
|
)
|
304
310
|
|
305
311
|
# Iterate over each group of nodes (either sublists or flat list)
|
306
|
-
for sublist in node_groups:
|
312
|
+
for idx, sublist in enumerate(node_groups):
|
307
313
|
# Map node labels to IDs
|
308
314
|
node_ids = [
|
309
315
|
self.graph.node_label_to_node_id_map.get(node)
|
@@ -327,10 +333,10 @@ class Labels:
|
|
327
333
|
va="center",
|
328
334
|
fontsize=fontsize,
|
329
335
|
fontname=font,
|
330
|
-
color=fontcolor_rgba,
|
336
|
+
color=fontcolor_rgba[idx],
|
331
337
|
arrowprops=dict(
|
332
338
|
arrowstyle=arrow_style,
|
333
|
-
color=arrow_color_rgba,
|
339
|
+
color=arrow_color_rgba[idx],
|
334
340
|
linewidth=arrow_linewidth,
|
335
341
|
shrinkA=arrow_base_shrink,
|
336
342
|
shrinkB=arrow_tip_shrink,
|
@@ -631,7 +637,7 @@ class Labels:
|
|
631
637
|
def get_annotated_label_colors(
|
632
638
|
self,
|
633
639
|
cmap: str = "gist_rainbow",
|
634
|
-
color: Union[str, None] = None,
|
640
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
635
641
|
min_scale: float = 0.8,
|
636
642
|
max_scale: float = 1.0,
|
637
643
|
scale_factor: float = 1.0,
|
@@ -641,7 +647,8 @@ class Labels:
|
|
641
647
|
|
642
648
|
Args:
|
643
649
|
cmap (str, optional): Name of the colormap to use for generating label colors. Defaults to "gist_rainbow".
|
644
|
-
color (str or None, optional): Color to use for the labels.
|
650
|
+
color (str, list, tuple, np.ndarray, or None, optional): Color to use for the labels. Can be a single color or an array
|
651
|
+
of colors. If None, the colormap will be used. Defaults to None.
|
645
652
|
min_scale (float, optional): Minimum intensity scale for the colors generated by the colormap.
|
646
653
|
Controls the dimmest colors. Defaults to 0.8.
|
647
654
|
max_scale (float, optional): Maximum intensity scale for the colors generated by the colormap.
|
@@ -871,28 +878,35 @@ def _apply_str_transformation(
|
|
871
878
|
Returns:
|
872
879
|
List[str]: A list of transformed words with no duplicates.
|
873
880
|
"""
|
881
|
+
# Initialize a list to store transformed words
|
874
882
|
transformed_words = []
|
875
883
|
for word in words:
|
876
|
-
#
|
877
|
-
|
878
|
-
|
879
|
-
#
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
884
|
+
# Split word into subwords by space
|
885
|
+
subwords = word.split(" ")
|
886
|
+
transformed_subwords = []
|
887
|
+
# Apply transformation to each subword
|
888
|
+
for subword in subwords:
|
889
|
+
transformed_subword = subword # Start with the original subword
|
890
|
+
# If transformation is a string, apply it to all subwords
|
891
|
+
if isinstance(transformation, str):
|
892
|
+
if hasattr(subword, transformation):
|
893
|
+
transformed_subword = getattr(subword, transformation)()
|
894
|
+
|
895
|
+
# If transformation is a dictionary, apply case-specific transformations
|
896
|
+
elif isinstance(transformation, dict):
|
897
|
+
for case_type, transform in transformation.items():
|
898
|
+
if case_type == "lower" and subword.islower() and transform:
|
899
|
+
transformed_subword = getattr(subword, transform)()
|
900
|
+
elif case_type == "upper" and subword.isupper() and transform:
|
901
|
+
transformed_subword = getattr(subword, transform)()
|
902
|
+
elif case_type == "title" and subword.istitle() and transform:
|
903
|
+
transformed_subword = getattr(subword, transform)()
|
904
|
+
|
905
|
+
# Append the transformed subword to the list
|
906
|
+
transformed_subwords.append(transformed_subword)
|
907
|
+
|
908
|
+
# Rejoin the transformed subwords into a single string to preserve structure
|
909
|
+
transformed_word = " ".join(transformed_subwords)
|
896
910
|
# Only append if the transformed word is not already in the list
|
897
911
|
if transformed_word not in transformed_words:
|
898
912
|
transformed_words.append(transformed_word)
|
risk/network/plot/network.py
CHANGED
@@ -47,8 +47,10 @@ class Network:
|
|
47
47
|
edge_width (float, optional): Width of the edges. Defaults to 1.0.
|
48
48
|
node_color (str, list, tuple, or np.ndarray, optional): Color of the nodes. Can be a single color or an array of colors.
|
49
49
|
Defaults to "white".
|
50
|
-
node_edgecolor (str, list, tuple, or np.ndarray, optional): Color of the node edges.
|
51
|
-
|
50
|
+
node_edgecolor (str, list, tuple, or np.ndarray, optional): Color of the node edges. Can be a single color or an array of colors.
|
51
|
+
Defaults to "black".
|
52
|
+
edge_color (str, list, tuple, or np.ndarray, optional): Color of the edges. Can be a single color or an array of colors.
|
53
|
+
Defaults to "black".
|
52
54
|
node_alpha (float, None, optional): Alpha value (transparency) for the nodes. If provided, it overrides any existing alpha
|
53
55
|
values found in node_color. Defaults to 1.0. Annotated node_color alphas will override this value.
|
54
56
|
edge_alpha (float, None, optional): Alpha value (transparency) for the edges. If provided, it overrides any existing alpha
|
@@ -194,12 +196,12 @@ class Network:
|
|
194
196
|
def get_annotated_node_colors(
|
195
197
|
self,
|
196
198
|
cmap: str = "gist_rainbow",
|
197
|
-
color: Union[str, None] = None,
|
199
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
198
200
|
min_scale: float = 0.8,
|
199
201
|
max_scale: float = 1.0,
|
200
202
|
scale_factor: float = 1.0,
|
201
203
|
alpha: Union[float, None] = 1.0,
|
202
|
-
nonenriched_color: Union[str,
|
204
|
+
nonenriched_color: Union[str, list, tuple, np.ndarray] = "white",
|
203
205
|
nonenriched_alpha: Union[float, None] = 1.0,
|
204
206
|
random_seed: int = 888,
|
205
207
|
) -> np.ndarray:
|
@@ -207,15 +209,17 @@ class Network:
|
|
207
209
|
|
208
210
|
Args:
|
209
211
|
cmap (str, optional): Colormap to use for coloring the nodes. Defaults to "gist_rainbow".
|
210
|
-
color (str or None, optional): Color to use for the nodes.
|
212
|
+
color (str, list, tuple, np.ndarray, or None, optional): Color to use for the nodes. Can be a single color or an array of colors.
|
213
|
+
If None, the colormap will be used. Defaults to None.
|
211
214
|
min_scale (float, optional): Minimum scale for color intensity. Defaults to 0.8.
|
212
215
|
max_scale (float, optional): Maximum scale for color intensity. Defaults to 1.0.
|
213
216
|
scale_factor (float, optional): Factor for adjusting the color scaling intensity. Defaults to 1.0.
|
214
|
-
alpha (float, None, optional): Alpha value for enriched nodes. If provided, it overrides any existing alpha values
|
215
|
-
|
216
|
-
nonenriched_color (str, list, tuple, or np.ndarray, optional): Color for non-enriched nodes.
|
217
|
-
|
218
|
-
|
217
|
+
alpha (float, None, optional): Alpha value for enriched nodes. If provided, it overrides any existing alpha values found in `color`.
|
218
|
+
Defaults to 1.0.
|
219
|
+
nonenriched_color (str, list, tuple, or np.ndarray, optional): Color for non-enriched nodes. Can be a single color or an array of colors.
|
220
|
+
Defaults to "white".
|
221
|
+
nonenriched_alpha (float, None, optional): Alpha value for non-enriched nodes. If provided, it overrides any existing alpha values found
|
222
|
+
in `nonenriched_color`. Defaults to 1.0.
|
219
223
|
random_seed (int, optional): Seed for random number generation. Defaults to 888.
|
220
224
|
|
221
225
|
Returns:
|
@@ -234,7 +238,9 @@ class Network:
|
|
234
238
|
# Apply the alpha value for enriched nodes
|
235
239
|
network_colors[:, 3] = alpha # Apply the alpha value to the enriched nodes' A channel
|
236
240
|
# Convert the non-enriched color to RGBA using the to_rgba helper function
|
237
|
-
nonenriched_color = to_rgba(
|
241
|
+
nonenriched_color = to_rgba(
|
242
|
+
color=nonenriched_color, alpha=nonenriched_alpha, num_repeats=1
|
243
|
+
) # num_repeats=1 for a single color
|
238
244
|
# Adjust node colors: replace any nodes where all three RGB values are equal and less than 0.1
|
239
245
|
# 0.1 is a predefined threshold for the minimum color intensity
|
240
246
|
adjusted_network_colors = np.where(
|
risk/network/plot/plotter.py
CHANGED
@@ -59,7 +59,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
59
59
|
self,
|
60
60
|
graph: NetworkGraph,
|
61
61
|
figsize: Tuple,
|
62
|
-
background_color: Union[str,
|
62
|
+
background_color: Union[str, list, tuple, np.ndarray],
|
63
63
|
background_alpha: Union[float, None],
|
64
64
|
pad: float,
|
65
65
|
) -> plt.Axes:
|
@@ -68,9 +68,9 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
68
68
|
Args:
|
69
69
|
graph (NetworkGraph): The network data and attributes to be visualized.
|
70
70
|
figsize (tuple): Size of the figure in inches (width, height).
|
71
|
-
background_color (str): Background color of the plot.
|
72
|
-
background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides any
|
73
|
-
|
71
|
+
background_color (str, list, tuple, or np.ndarray): Background color of the plot. Can be a single color or an array of colors.
|
72
|
+
background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides any existing
|
73
|
+
alpha values found in `background_color`.
|
74
74
|
pad (float, optional): Padding value to adjust the axis limits.
|
75
75
|
|
76
76
|
Returns:
|
@@ -99,7 +99,9 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
|
|
99
99
|
|
100
100
|
# Set the background color of the plot
|
101
101
|
# Convert color to RGBA using the to_rgba helper function
|
102
|
-
fig.patch.set_facecolor(
|
102
|
+
fig.patch.set_facecolor(
|
103
|
+
to_rgba(color=background_color, alpha=background_alpha, num_repeats=1)
|
104
|
+
) # num_repeats=1 for single color
|
103
105
|
ax.invert_yaxis() # Invert the y-axis to match typical image coordinates
|
104
106
|
# Remove axis spines for a cleaner look
|
105
107
|
for spine in ax.spines.values():
|
risk/network/plot/utils/color.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"""
|
2
|
-
risk/network/plot/utils/
|
3
|
-
|
2
|
+
risk/network/plot/utils/color
|
3
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
4
4
|
"""
|
5
5
|
|
6
6
|
from typing import Any, Dict, List, Tuple, Union
|
@@ -16,7 +16,7 @@ from risk.network.plot.utils.layout import calculate_centroids
|
|
16
16
|
def get_annotated_domain_colors(
|
17
17
|
graph: NetworkGraph,
|
18
18
|
cmap: str = "gist_rainbow",
|
19
|
-
color: Union[str, None] = None,
|
19
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
20
20
|
min_scale: float = 0.8,
|
21
21
|
max_scale: float = 1.0,
|
22
22
|
scale_factor: float = 1.0,
|
@@ -27,13 +27,12 @@ def get_annotated_domain_colors(
|
|
27
27
|
Args:
|
28
28
|
graph (NetworkGraph): The network data and attributes to be visualized.
|
29
29
|
cmap (str, optional): Colormap to use for generating domain colors. Defaults to "gist_rainbow".
|
30
|
-
color (str or None, optional): Color to use for the domains.
|
31
|
-
|
32
|
-
|
33
|
-
max_scale (float, optional): Maximum scale for color intensity when generating domain colors.
|
34
|
-
|
35
|
-
|
36
|
-
enrichment. Higher values increase the contrast. Defaults to 1.0.
|
30
|
+
color (str, list, tuple, np.ndarray, or None, optional): Color to use for the domains. Can be a single color or an array of colors.
|
31
|
+
If None, the colormap will be used. Defaults to None.
|
32
|
+
min_scale (float, optional): Minimum scale for color intensity when generating domain colors. Defaults to 0.8.
|
33
|
+
max_scale (float, optional): Maximum scale for color intensity when generating domain colors. Defaults to 1.0.
|
34
|
+
scale_factor (float, optional): Factor for adjusting the contrast in the colors generated based on enrichment. Higher values
|
35
|
+
increase the contrast. Defaults to 1.0.
|
37
36
|
random_seed (int, optional): Seed for random number generation to ensure reproducibility. Defaults to 888.
|
38
37
|
|
39
38
|
Returns:
|
@@ -69,7 +68,7 @@ def get_annotated_domain_colors(
|
|
69
68
|
def get_domain_colors(
|
70
69
|
graph: NetworkGraph,
|
71
70
|
cmap: str = "gist_rainbow",
|
72
|
-
color: Union[str, None] = None,
|
71
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
73
72
|
min_scale: float = 0.8,
|
74
73
|
max_scale: float = 1.0,
|
75
74
|
scale_factor: float = 1.0,
|
@@ -80,15 +79,15 @@ def get_domain_colors(
|
|
80
79
|
Args:
|
81
80
|
graph (NetworkGraph): The network data and attributes to be visualized.
|
82
81
|
cmap (str, optional): Name of the colormap to use for generating domain colors. Defaults to "gist_rainbow".
|
83
|
-
color (str or None, optional): A specific color to use for all
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
82
|
+
color (str, list, tuple, np.ndarray, or None, optional): A specific color or array of colors to use for all domains.
|
83
|
+
If None, the colormap will be used. Defaults to None.
|
84
|
+
min_scale (float, optional): Minimum intensity scale for the colors generated by the colormap. Controls the dimmest colors.
|
85
|
+
Defaults to 0.8.
|
86
|
+
max_scale (float, optional): Maximum intensity scale for the colors generated by the colormap. Controls the brightest colors.
|
87
|
+
Defaults to 1.0.
|
88
|
+
scale_factor (float, optional): Exponent for adjusting the color scaling based on enrichment scores. Higher values increase
|
89
|
+
contrast by dimming lower scores more. Defaults to 1.0.
|
90
|
+
random_seed (int, optional): Seed for random number generation to ensure reproducibility of color assignments. Defaults to 888.
|
92
91
|
|
93
92
|
Returns:
|
94
93
|
np.ndarray: Array of RGBA colors generated for each domain, based on enrichment or the specified color.
|
@@ -111,7 +110,7 @@ def get_domain_colors(
|
|
111
110
|
def _get_domain_colors(
|
112
111
|
graph: NetworkGraph,
|
113
112
|
cmap: str = "gist_rainbow",
|
114
|
-
color: Union[str, None] = None,
|
113
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
115
114
|
random_seed: int = 888,
|
116
115
|
) -> Dict[str, Any]:
|
117
116
|
"""Get colors for each domain.
|
@@ -119,7 +118,8 @@ def _get_domain_colors(
|
|
119
118
|
Args:
|
120
119
|
graph (NetworkGraph): The network data and attributes to be visualized.
|
121
120
|
cmap (str, optional): The name of the colormap to use. Defaults to "gist_rainbow".
|
122
|
-
color (str or None, optional): A specific color
|
121
|
+
color (str, list, tuple, np.ndarray, or None, optional): A specific color or array of colors to use for the domains.
|
122
|
+
If None, the colormap will be used. Defaults to None.
|
123
123
|
random_seed (int, optional): Seed for random number generation. Defaults to 888.
|
124
124
|
|
125
125
|
Returns:
|
@@ -163,7 +163,7 @@ def _get_colors(
|
|
163
163
|
network,
|
164
164
|
domain_id_to_node_ids_map,
|
165
165
|
cmap: str = "gist_rainbow",
|
166
|
-
color: Union[str, None] = None,
|
166
|
+
color: Union[str, list, tuple, np.ndarray, None] = None,
|
167
167
|
random_seed: int = 888,
|
168
168
|
) -> List[Tuple]:
|
169
169
|
"""Generate a list of RGBA colors based on domain centroids, ensuring that domains
|
@@ -173,8 +173,9 @@ def _get_colors(
|
|
173
173
|
network (NetworkX graph): The graph representing the network.
|
174
174
|
domain_id_to_node_ids_map (dict): Mapping from domain IDs to lists of node IDs.
|
175
175
|
cmap (str, optional): The name of the colormap to use. Defaults to "gist_rainbow".
|
176
|
-
color (str or None, optional): A specific color to use for
|
177
|
-
|
176
|
+
color (str, list, tuple, np.ndarray, or None, optional): A specific color or array of colors to use for the domains.
|
177
|
+
If None, the colormap will be used. Defaults to None.
|
178
|
+
random_seed (int, optional): Seed for random number generation. Defaults to 888.
|
178
179
|
|
179
180
|
Returns:
|
180
181
|
List[Tuple]: List of RGBA colors.
|
@@ -282,16 +283,17 @@ def _transform_colors(
|
|
282
283
|
|
283
284
|
|
284
285
|
def to_rgba(
|
285
|
-
color: Union[str,
|
286
|
+
color: Union[str, list, tuple, np.ndarray],
|
286
287
|
alpha: Union[float, None] = None,
|
287
288
|
num_repeats: Union[int, None] = None,
|
288
289
|
) -> np.ndarray:
|
289
290
|
"""Convert color(s) to RGBA format, applying alpha and repeating as needed.
|
290
291
|
|
291
292
|
Args:
|
292
|
-
color (
|
293
|
-
|
294
|
-
|
293
|
+
color (str, list, tuple, np.ndarray): The color(s) to convert. Can be a string (e.g., 'red'), a list or tuple of RGB/RGBA values,
|
294
|
+
or an `np.ndarray` of colors.
|
295
|
+
alpha (float, None, optional): Alpha value (transparency) to apply. If provided, it overrides any existing alpha values found
|
296
|
+
in color.
|
295
297
|
num_repeats (int, None, optional): If provided, the color(s) will be repeated this many times. Defaults to None.
|
296
298
|
|
297
299
|
Returns:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=EoQiOdiY9moo1L8d1ybzWAGTSGsM9MzK9H_PfU8miI4,113
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
3
|
risk/risk.py,sha256=slJXca_a726_D7oXwe765HaKTv3ZrOvhttyrWdCGPkA,21231
|
4
4
|
risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
|
@@ -16,12 +16,12 @@ risk/network/geometry.py,sha256=H1yGVVqgbfpzBzJwEheDLfvGLSA284jGQQTn612L4Vc,6759
|
|
16
16
|
risk/network/graph.py,sha256=x5cur1meitkR0YuE5vGxX0s_IFa5wkx8z44f_C1vK7U,6509
|
17
17
|
risk/network/io.py,sha256=u0PPcKjp6Xze--7eDOlvalYkjQ9S2sjiC-ac2476PUI,22942
|
18
18
|
risk/network/plot/__init__.py,sha256=MfmaXJgAZJgXZ2wrhK8pXwzETlcMaLChhWXKAozniAo,98
|
19
|
-
risk/network/plot/canvas.py,sha256=
|
20
|
-
risk/network/plot/contour.py,sha256=
|
21
|
-
risk/network/plot/labels.py,sha256=
|
22
|
-
risk/network/plot/network.py,sha256=
|
23
|
-
risk/network/plot/plotter.py,sha256=
|
24
|
-
risk/network/plot/utils/color.py,sha256=
|
19
|
+
risk/network/plot/canvas.py,sha256=JnjPQaryRb_J6LP36BT2-rlsbJO3T4tTBornL8Oqqbs,10778
|
20
|
+
risk/network/plot/contour.py,sha256=8uwJ7K-Z6VMyr_uQ5VUyoQSqDHA7zDvR_nYAmLn60-I,14647
|
21
|
+
risk/network/plot/labels.py,sha256=ttEUiKkDq024v4MI-ZADW3sT7uRNQ6aL3kNB598Em90,44468
|
22
|
+
risk/network/plot/network.py,sha256=9blVFeCp5x5XoGhPwOOdADegXC4gC72c2vrM2u4QPe0,13235
|
23
|
+
risk/network/plot/plotter.py,sha256=lN-_GDXRk9V3IFu8q7QmPjJGBZiP0QYwSvU6dVVDV2E,5770
|
24
|
+
risk/network/plot/utils/color.py,sha256=_ZLIw_uv--nTXhUhZVaF0iCaYmfURTn_WnoFYdUcPrc,15575
|
25
25
|
risk/network/plot/utils/layout.py,sha256=znssSqe2VZzzSz47hLZtTuXwMTpHR9b8lkQPL0BX7OA,1950
|
26
26
|
risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
|
27
27
|
risk/stats/hypergeom.py,sha256=o6Qnj31gCAKxr2uQirXrbv7XvdDJGEq69MFW-ubx_hA,2272
|
@@ -30,8 +30,8 @@ risk/stats/stats.py,sha256=kvShov-94W6ffgDUTb522vB9hDJQSyTsYif_UIaFfSM,7059
|
|
30
30
|
risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
|
31
31
|
risk/stats/permutation/permutation.py,sha256=D84Rcpt6iTQniK0PfQGcw9bLcHbMt9p-ARcurUnIXZQ,10095
|
32
32
|
risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
|
33
|
-
risk_network-0.0.
|
34
|
-
risk_network-0.0.
|
35
|
-
risk_network-0.0.
|
36
|
-
risk_network-0.0.
|
37
|
-
risk_network-0.0.
|
33
|
+
risk_network-0.0.8b18.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
34
|
+
risk_network-0.0.8b18.dist-info/METADATA,sha256=CYJnBG0E8gmlzPx15UYKAjbbsC3zs2Mmsq42NPzi1mY,47498
|
35
|
+
risk_network-0.0.8b18.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
36
|
+
risk_network-0.0.8b18.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
37
|
+
risk_network-0.0.8b18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|