risk-network 0.0.8b18__py3-none-any.whl → 0.0.9b26__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.
Files changed (50) hide show
  1. risk/__init__.py +2 -2
  2. risk/annotations/__init__.py +2 -2
  3. risk/annotations/annotations.py +133 -72
  4. risk/annotations/io.py +50 -34
  5. risk/log/__init__.py +4 -2
  6. risk/log/{config.py → console.py} +5 -3
  7. risk/log/{params.py → parameters.py} +21 -46
  8. risk/neighborhoods/__init__.py +3 -5
  9. risk/neighborhoods/api.py +446 -0
  10. risk/neighborhoods/community.py +281 -96
  11. risk/neighborhoods/domains.py +92 -38
  12. risk/neighborhoods/neighborhoods.py +210 -149
  13. risk/network/__init__.py +1 -3
  14. risk/network/geometry.py +69 -58
  15. risk/network/graph/__init__.py +6 -0
  16. risk/network/graph/api.py +194 -0
  17. risk/network/graph/network.py +269 -0
  18. risk/network/graph/summary.py +254 -0
  19. risk/network/io.py +58 -48
  20. risk/network/plotter/__init__.py +6 -0
  21. risk/network/plotter/api.py +54 -0
  22. risk/network/{plot → plotter}/canvas.py +80 -26
  23. risk/network/{plot → plotter}/contour.py +43 -34
  24. risk/network/{plot → plotter}/labels.py +123 -113
  25. risk/network/plotter/network.py +424 -0
  26. risk/network/plotter/utils/colors.py +416 -0
  27. risk/network/plotter/utils/layout.py +94 -0
  28. risk/risk.py +11 -469
  29. risk/stats/__init__.py +8 -4
  30. risk/stats/binom.py +51 -0
  31. risk/stats/chi2.py +69 -0
  32. risk/stats/hypergeom.py +28 -18
  33. risk/stats/permutation/__init__.py +1 -1
  34. risk/stats/permutation/permutation.py +45 -39
  35. risk/stats/permutation/test_functions.py +25 -17
  36. risk/stats/poisson.py +17 -11
  37. risk/stats/stats.py +20 -16
  38. risk/stats/zscore.py +68 -0
  39. {risk_network-0.0.8b18.dist-info → risk_network-0.0.9b26.dist-info}/METADATA +9 -5
  40. risk_network-0.0.9b26.dist-info/RECORD +44 -0
  41. {risk_network-0.0.8b18.dist-info → risk_network-0.0.9b26.dist-info}/WHEEL +1 -1
  42. risk/network/graph.py +0 -159
  43. risk/network/plot/__init__.py +0 -6
  44. risk/network/plot/network.py +0 -282
  45. risk/network/plot/plotter.py +0 -137
  46. risk/network/plot/utils/color.py +0 -353
  47. risk/network/plot/utils/layout.py +0 -53
  48. risk_network-0.0.8b18.dist-info/RECORD +0 -37
  49. {risk_network-0.0.8b18.dist-info → risk_network-0.0.9b26.dist-info}/LICENSE +0 -0
  50. {risk_network-0.0.8b18.dist-info → risk_network-0.0.9b26.dist-info}/top_level.txt +0 -0
@@ -9,9 +9,9 @@ import matplotlib.pyplot as plt
9
9
  import numpy as np
10
10
 
11
11
  from risk.log import params
12
- from risk.network.graph import NetworkGraph
13
- from risk.network.plot.utils.color import to_rgba
14
- from risk.network.plot.utils.layout import calculate_bounding_box
12
+ from risk.network.graph.network import NetworkGraph
13
+ from risk.network.plotter.utils.colors import to_rgba
14
+ from risk.network.plotter.utils.layout import calculate_bounding_box
15
15
 
16
16
 
17
17
  class Canvas:
@@ -34,8 +34,9 @@ class Canvas:
34
34
  title_fontsize: int = 20,
35
35
  subtitle_fontsize: int = 14,
36
36
  font: str = "Arial",
37
- title_color: Union[str, list, tuple, np.ndarray] = "black",
38
- subtitle_color: Union[str, list, tuple, np.ndarray] = "gray",
37
+ title_color: Union[str, List, Tuple, np.ndarray] = "black",
38
+ subtitle_color: Union[str, List, Tuple, np.ndarray] = "gray",
39
+ title_x: float = 0.5,
39
40
  title_y: float = 0.975,
40
41
  title_space_offset: float = 0.075,
41
42
  subtitle_offset: float = 0.025,
@@ -48,10 +49,11 @@ class Canvas:
48
49
  title_fontsize (int, optional): Font size for the title. Defaults to 20.
49
50
  subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to 14.
50
51
  font (str, optional): Font family used for both title and subtitle. Defaults to "Arial".
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
+ title_color (str, List, Tuple, or np.ndarray, optional): Color of the title text. Can be a string or an array of colors.
52
53
  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
+ subtitle_color (str, List, Tuple, or np.ndarray, optional): Color of the subtitle text. Can be a string or an array of colors.
54
55
  Defaults to "gray".
56
+ title_x (float, optional): X-axis position of the title. Defaults to 0.5.
55
57
  title_y (float, optional): Y-axis position of the title. Defaults to 0.975.
56
58
  title_space_offset (float, optional): Fraction of figure height to leave for the space above the plot. Defaults to 0.075.
57
59
  subtitle_offset (float, optional): Offset factor to position the subtitle below the title. Defaults to 0.025.
@@ -85,7 +87,7 @@ class Canvas:
85
87
  fontsize=title_fontsize,
86
88
  color=title_color,
87
89
  fontname=font,
88
- x=0.5, # Center the title horizontally
90
+ x=title_x,
89
91
  ha="center",
90
92
  va="top",
91
93
  y=title_y,
@@ -112,6 +114,8 @@ class Canvas:
112
114
  def plot_circle_perimeter(
113
115
  self,
114
116
  scale: float = 1.0,
117
+ center_offset_x: float = 0.0,
118
+ center_offset_y: float = 0.0,
115
119
  linestyle: str = "dashed",
116
120
  linewidth: float = 1.5,
117
121
  color: Union[str, List, Tuple, np.ndarray] = "black",
@@ -122,9 +126,13 @@ class Canvas:
122
126
 
123
127
  Args:
124
128
  scale (float, optional): Scaling factor for the perimeter diameter. Defaults to 1.0.
129
+ center_offset_x (float, optional): Horizontal offset as a fraction of the diameter.
130
+ Negative values shift the center left, positive values shift it right. Defaults to 0.0.
131
+ center_offset_y (float, optional): Vertical offset as a fraction of the diameter.
132
+ Negative values shift the center down, positive values shift it up. Defaults to 0.0.
125
133
  linestyle (str, optional): Line style for the network perimeter circle (e.g., dashed, solid). Defaults to "dashed".
126
134
  linewidth (float, optional): Width of the circle's outline. Defaults to 1.5.
127
- color (str, list, tuple, or np.ndarray, optional): Color of the network perimeter circle. Defaults to "black".
135
+ color (str, List, Tuple, or np.ndarray, optional): Color of the network perimeter circle. Defaults to "black".
128
136
  outline_alpha (float, None, optional): Transparency level of the circle outline. If provided, it overrides any existing alpha
129
137
  values found in color. Defaults to 1.0.
130
138
  fill_alpha (float, None, optional): Transparency level of the circle fill. If provided, it overrides any existing alpha values
@@ -134,6 +142,8 @@ class Canvas:
134
142
  params.log_plotter(
135
143
  perimeter_type="circle",
136
144
  perimeter_scale=scale,
145
+ perimeter_center_offset_x=center_offset_x,
146
+ perimeter_center_offset_y=center_offset_y,
137
147
  perimeter_linestyle=linestyle,
138
148
  perimeter_linewidth=linewidth,
139
149
  perimeter_color=(
@@ -143,33 +153,37 @@ class Canvas:
143
153
  perimeter_fill_alpha=fill_alpha,
144
154
  )
145
155
 
146
- # Convert color to RGBA using the to_rgba helper function - use outline_alpha for the perimeter
147
- color = to_rgba(
148
- color=color, alpha=outline_alpha, num_repeats=1
149
- ) # num_repeats=1 for a single color
150
- # Set the fill_alpha to 0 if not provided
151
- fill_alpha = fill_alpha if fill_alpha is not None else 0.0
152
156
  # Extract node coordinates from the network graph
153
157
  node_coordinates = self.graph.node_coordinates
154
158
  # Calculate the center and radius of the bounding box around the network
155
159
  center, radius = calculate_bounding_box(node_coordinates)
160
+ # Adjust the center based on user-defined offsets
161
+ adjusted_center = _calculate_adjusted_center(
162
+ center, radius, center_offset_x, center_offset_y
163
+ )
156
164
  # Scale the radius by the scale factor
157
165
  scaled_radius = radius * scale
158
166
 
167
+ # Convert color to RGBA using the to_rgba helper function - use outline_alpha for the perimeter
168
+ outline_color_rgba = to_rgba(
169
+ color=color, alpha=outline_alpha, num_repeats=1
170
+ ) # num_repeats=1 for a single color
171
+ fill_color_rgba = to_rgba(
172
+ color=color, alpha=fill_alpha, num_repeats=1
173
+ ) # num_repeats=1 for a single color
174
+
159
175
  # Draw a circle to represent the network perimeter
160
176
  circle = plt.Circle(
161
- center,
177
+ adjusted_center,
162
178
  scaled_radius,
163
179
  linestyle=linestyle,
164
180
  linewidth=linewidth,
165
- color=color,
166
- fill=fill_alpha > 0, # Fill the circle if fill_alpha is greater than 0
181
+ color=outline_color_rgba,
167
182
  )
168
183
  # Set the transparency of the fill if applicable
169
- if fill_alpha > 0:
170
- circle.set_facecolor(
171
- to_rgba(color=color, alpha=fill_alpha, num_repeats=1)
172
- ) # num_repeats=1 for a single color
184
+ circle.set_facecolor(
185
+ to_rgba(color=fill_color_rgba, num_repeats=1)
186
+ ) # num_repeats=1 for a single color
173
187
 
174
188
  self.ax.add_artist(circle)
175
189
 
@@ -193,7 +207,7 @@ class Canvas:
193
207
  levels (int, optional): Number of contour levels. Defaults to 3.
194
208
  bandwidth (float, optional): Bandwidth for the KDE. Controls smoothness. Defaults to 0.8.
195
209
  grid_size (int, optional): Grid resolution for the KDE. Higher values yield finer contours. Defaults to 250.
196
- color (str, list, tuple, or np.ndarray, optional): Color of the network perimeter contour. Defaults to "black".
210
+ color (str, List, Tuple, or np.ndarray, optional): Color of the network perimeter contour. Defaults to "black".
197
211
  linestyle (str, optional): Line style for the network perimeter contour (e.g., dashed, solid). Defaults to "solid".
198
212
  linewidth (float, optional): Width of the contour's outline. Defaults to 1.5.
199
213
  outline_alpha (float, None, optional): Transparency level of the contour outline. If provided, it overrides any existing
@@ -216,12 +230,13 @@ class Canvas:
216
230
  )
217
231
 
218
232
  # Convert color to RGBA using outline_alpha for the line (outline)
219
- outline_color = to_rgba(color=color, num_repeats=1) # num_repeats=1 for a single color
233
+ outline_color_rgba = to_rgba(color=color, num_repeats=1) # num_repeats=1 for a single color
220
234
  # Extract node coordinates from the network graph
221
235
  node_coordinates = self.graph.node_coordinates
222
236
  # Scale the node coordinates if needed
223
237
  scaled_coordinates = node_coordinates * scale
224
238
  # Use the existing _draw_kde_contour method
239
+ # NOTE: This is a technical debt that should be refactored in the future - only works when inherited by NetworkPlotter
225
240
  self._draw_kde_contour(
226
241
  ax=self.ax,
227
242
  pos=scaled_coordinates,
@@ -229,9 +244,48 @@ class Canvas:
229
244
  levels=levels,
230
245
  bandwidth=bandwidth,
231
246
  grid_size=grid_size,
232
- color=outline_color,
247
+ color=outline_color_rgba,
233
248
  linestyle=linestyle,
234
249
  linewidth=linewidth,
235
- alpha=outline_alpha,
236
250
  fill_alpha=fill_alpha,
237
251
  )
252
+
253
+
254
+ def _calculate_adjusted_center(
255
+ center: Tuple[float, float],
256
+ radius: float,
257
+ center_offset_x: float = 0.0,
258
+ center_offset_y: float = 0.0,
259
+ ) -> Tuple[float, float]:
260
+ """Calculate the adjusted center for the network perimeter circle based on user-defined offsets.
261
+
262
+ Args:
263
+ center (Tuple[float, float]): Original center coordinates of the network graph.
264
+ radius (float): Radius of the bounding box around the network.
265
+ center_offset_x (float, optional): Horizontal offset as a fraction of the diameter.
266
+ Negative values shift the center left, positive values shift it right. Allowed
267
+ values are in the range [-1, 1]. Defaults to 0.0.
268
+ center_offset_y (float, optional): Vertical offset as a fraction of the diameter.
269
+ Negative values shift the center down, positive values shift it up. Allowed
270
+ values are in the range [-1, 1]. Defaults to 0.0.
271
+
272
+ Returns:
273
+ Tuple[float, float]: Adjusted center coordinates after applying the offsets.
274
+
275
+ Raises:
276
+ ValueError: If the center offsets are outside the valid range [-1, 1].
277
+ """
278
+ # Flip the y-axis to match the plot orientation
279
+ flipped_center_offset_y = -center_offset_y
280
+ # Validate the center offsets
281
+ if not -1 <= center_offset_x <= 1:
282
+ raise ValueError("Horizontal center offset must be in the range [-1, 1].")
283
+ if not -1 <= center_offset_y <= 1:
284
+ raise ValueError("Vertical center offset must be in the range [-1, 1].")
285
+
286
+ # Calculate adjusted center by applying offset fractions of the diameter
287
+ adjusted_center_x = center[0] + (center_offset_x * radius * 2)
288
+ adjusted_center_y = center[1] + (flipped_center_offset_y * radius * 2)
289
+
290
+ # Return the adjusted center coordinates
291
+ return adjusted_center_x, adjusted_center_y
@@ -3,7 +3,7 @@ risk/network/plot/contour
3
3
  ~~~~~~~~~~~~~~~~~~~~~~~~~
4
4
  """
5
5
 
6
- from typing import List, Tuple, Union
6
+ from typing import Any, Dict, List, Tuple, Union
7
7
 
8
8
  import matplotlib.pyplot as plt
9
9
  import numpy as np
@@ -12,8 +12,8 @@ from scipy.ndimage import label
12
12
  from scipy.stats import gaussian_kde
13
13
 
14
14
  from risk.log import params, logger
15
- from risk.network.graph import NetworkGraph
16
- from risk.network.plot.utils.color import get_annotated_domain_colors, to_rgba
15
+ from risk.network.graph.network import NetworkGraph
16
+ from risk.network.plotter.utils.colors import get_annotated_domain_colors, to_rgba
17
17
 
18
18
 
19
19
  class Contour:
@@ -46,7 +46,7 @@ class Contour:
46
46
  levels (int, optional): Number of contour levels to plot. Defaults to 5.
47
47
  bandwidth (float, optional): Bandwidth for KDE. Controls the smoothness of the contour. Defaults to 0.8.
48
48
  grid_size (int, optional): Resolution of the grid for KDE. Higher values create finer contours. Defaults to 250.
49
- color (str, list, tuple, or np.ndarray, optional): Color of the contours. Can be a single color or an array of colors.
49
+ color (str, List, Tuple, or np.ndarray, optional): Color of the contours. Can be a single color or an array of colors.
50
50
  Defaults to "white".
51
51
  linestyle (str, optional): Line style for the contours. Defaults to "solid".
52
52
  linewidth (float, optional): Line width for the contours. Defaults to 1.5.
@@ -63,31 +63,34 @@ class Contour:
63
63
  contour_color=(
64
64
  "custom" if isinstance(color, np.ndarray) else color
65
65
  ), # np.ndarray usually indicates custom colors
66
+ contour_linestyle=linestyle,
67
+ contour_linewidth=linewidth,
66
68
  contour_alpha=alpha,
67
69
  contour_fill_alpha=fill_alpha,
68
70
  )
69
71
 
70
72
  # Ensure color is converted to RGBA with repetition matching the number of domains
71
- color = to_rgba(
73
+ color_rgba = to_rgba(
72
74
  color=color, alpha=alpha, num_repeats=len(self.graph.domain_id_to_node_ids_map)
73
75
  )
74
76
  # Extract node coordinates from the network graph
75
77
  node_coordinates = self.graph.node_coordinates
76
78
  # Draw contours for each domain in the network
77
79
  for idx, (_, node_ids) in enumerate(self.graph.domain_id_to_node_ids_map.items()):
80
+ # Use the provided alpha value if it's not None, otherwise use the color's alpha
81
+ current_fill_alpha = fill_alpha if fill_alpha is not None else color_rgba[idx][3]
78
82
  if len(node_ids) > 1:
79
83
  self._draw_kde_contour(
80
84
  self.ax,
81
85
  node_coordinates,
82
86
  node_ids,
83
- color=color[idx],
87
+ color=color_rgba[idx],
84
88
  levels=levels,
85
89
  bandwidth=bandwidth,
86
90
  grid_size=grid_size,
87
91
  linestyle=linestyle,
88
92
  linewidth=linewidth,
89
- alpha=alpha,
90
- fill_alpha=fill_alpha,
93
+ fill_alpha=current_fill_alpha,
91
94
  )
92
95
 
93
96
  def plot_subcontour(
@@ -105,11 +108,11 @@ class Contour:
105
108
  """Plot a subcontour for a given set of nodes or a list of node sets using Kernel Density Estimation (KDE).
106
109
 
107
110
  Args:
108
- nodes (list, tuple, or np.ndarray): List of node labels or list of lists of node labels to plot the contour for.
111
+ nodes (List, Tuple, or np.ndarray): List of node labels or list of lists of node labels to plot the contour for.
109
112
  levels (int, optional): Number of contour levels to plot. Defaults to 5.
110
113
  bandwidth (float, optional): Bandwidth for KDE. Controls the smoothness of the contour. Defaults to 0.8.
111
114
  grid_size (int, optional): Resolution of the grid for KDE. Higher values create finer contours. Defaults to 250.
112
- color (str, list, tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array.
115
+ color (str, List, Tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array.
113
116
  Can be a single color or an array of colors. Defaults to "white".
114
117
  linestyle (str, optional): Line style for the contour. Defaults to "solid".
115
118
  linewidth (float, optional): Line width for the contour. Defaults to 1.5.
@@ -148,6 +151,8 @@ class Contour:
148
151
 
149
152
  # Draw the KDE contour for the specified nodes
150
153
  node_coordinates = self.graph.node_coordinates
154
+ # Use the provided alpha value if it's not None, otherwise use the color's alpha
155
+ current_fill_alpha = fill_alpha if fill_alpha is not None else color_rgba[idx][3]
151
156
  self._draw_kde_contour(
152
157
  self.ax,
153
158
  node_coordinates,
@@ -158,8 +163,7 @@ class Contour:
158
163
  grid_size=grid_size,
159
164
  linestyle=linestyle,
160
165
  linewidth=linewidth,
161
- alpha=alpha,
162
- fill_alpha=fill_alpha,
166
+ fill_alpha=current_fill_alpha,
163
167
  )
164
168
 
165
169
  def _draw_kde_contour(
@@ -173,7 +177,6 @@ class Contour:
173
177
  color: Union[str, np.ndarray] = "white",
174
178
  linestyle: str = "solid",
175
179
  linewidth: float = 1.5,
176
- alpha: Union[float, None] = 1.0,
177
180
  fill_alpha: Union[float, None] = 0.2,
178
181
  ) -> None:
179
182
  """Draw a Kernel Density Estimate (KDE) contour plot for a set of nodes on a given axis.
@@ -181,22 +184,20 @@ class Contour:
181
184
  Args:
182
185
  ax (plt.Axes): The axis to draw the contour on.
183
186
  pos (np.ndarray): Array of node positions (x, y).
184
- nodes (list): List of node indices to include in the contour.
187
+ nodes (List): List of node indices to include in the contour.
185
188
  levels (int, optional): Number of contour levels. Defaults to 5.
186
189
  bandwidth (float, optional): Bandwidth for the KDE. Controls smoothness. Defaults to 0.8.
187
190
  grid_size (int, optional): Grid resolution for the KDE. Higher values yield finer contours. Defaults to 250.
188
191
  color (str or np.ndarray): Color for the contour. Can be a string or RGBA array. Defaults to "white".
189
192
  linestyle (str, optional): Line style for the contour. Defaults to "solid".
190
193
  linewidth (float, optional): Line width for the contour. Defaults to 1.5.
191
- alpha (float, None, optional): Transparency level for the contour lines. If provided, it overrides any existing alpha
192
- values found in color. Defaults to 1.0.
193
194
  fill_alpha (float, None, optional): Transparency level for the contour fill. If provided, it overrides any existing
194
195
  alpha values found in color. Defaults to 0.2.
195
196
  """
196
197
  # Extract the positions of the specified nodes
197
198
  points = np.array([pos[n] for n in nodes])
198
199
  if len(points) <= 1:
199
- return None # Not enough points to form a contour
200
+ return # Not enough points to form a contour
200
201
 
201
202
  # Check if the KDE forms a single connected component
202
203
  connected = False
@@ -220,12 +221,12 @@ class Contour:
220
221
  except Exception as e:
221
222
  # Catch any other exceptions and log them
222
223
  logger.error(f"Unexpected error when drawing KDE contour: {e}")
223
- return None
224
+ return
224
225
 
225
226
  # If z is still None, the KDE computation failed
226
227
  if z is None:
227
228
  logger.error("Failed to compute KDE. Skipping contour plot for these nodes.")
228
- return None
229
+ return
229
230
 
230
231
  # Define contour levels based on the density
231
232
  min_density, max_density = z.min(), z.max()
@@ -233,18 +234,20 @@ class Contour:
233
234
  logger.warning(
234
235
  "Contour levels could not be created due to lack of variation in density."
235
236
  )
236
- return None
237
+ return
237
238
 
238
239
  # Create contour levels based on the density values
239
240
  contour_levels = np.linspace(min_density, max_density, levels)[1:]
240
241
  if len(contour_levels) < 2 or not np.all(np.diff(contour_levels) > 0):
241
242
  logger.error("Contour levels must be strictly increasing. Skipping contour plot.")
242
- return None
243
+ return
243
244
 
244
- # Set the contour color and linestyle
245
+ # Set the contour color, fill, and linestyle
245
246
  contour_colors = [color for _ in range(levels - 1)]
246
247
  # Plot the filled contours using fill_alpha for transparency
247
248
  if fill_alpha and fill_alpha > 0:
249
+ # Fill alpha works differently than alpha for contour lines
250
+ # Contour fill cannot be specified by RGBA, while contour lines can
248
251
  ax.contourf(
249
252
  x,
250
253
  y,
@@ -255,43 +258,46 @@ class Contour:
255
258
  alpha=fill_alpha,
256
259
  )
257
260
 
258
- # Plot the contour lines with the specified alpha for transparency
259
- c = ax.contour(
261
+ # Plot the base contour line with the specified RGBA alpha for transparency
262
+ base_contour_color = [color]
263
+ base_contour_level = [contour_levels[0]]
264
+ ax.contour(
260
265
  x,
261
266
  y,
262
267
  z,
263
- levels=contour_levels,
264
- colors=contour_colors,
268
+ levels=base_contour_level,
269
+ colors=base_contour_color,
265
270
  linestyles=linestyle,
266
271
  linewidths=linewidth,
267
- alpha=alpha,
268
272
  )
269
273
 
270
- # Set linewidth for the contour lines to 0 for levels other than the base level
271
- for i in range(1, len(contour_levels)):
272
- c.collections[i].set_linewidth(0)
273
-
274
274
  def get_annotated_contour_colors(
275
275
  self,
276
276
  cmap: str = "gist_rainbow",
277
- color: Union[str, list, tuple, np.ndarray, None] = None,
277
+ color: Union[str, List, Tuple, np.ndarray, None] = None,
278
+ blend_colors: bool = False,
279
+ blend_gamma: float = 2.2,
278
280
  min_scale: float = 0.8,
279
281
  max_scale: float = 1.0,
280
282
  scale_factor: float = 1.0,
283
+ ids_to_colors: Union[Dict[int, Any], None] = None,
281
284
  random_seed: int = 888,
282
285
  ) -> np.ndarray:
283
286
  """Get colors for the contours based on node annotations or a specified colormap.
284
287
 
285
288
  Args:
286
289
  cmap (str, optional): Name of the colormap to use for generating contour colors. Defaults to "gist_rainbow".
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.
290
+ 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
291
  If None, the colormap will be used. Defaults to None.
292
+ blend_colors (bool, optional): Whether to blend colors for nodes with multiple domains. Defaults to False.
293
+ blend_gamma (float, optional): Gamma correction factor for perceptual color blending. Defaults to 2.2.
289
294
  min_scale (float, optional): Minimum intensity scale for the colors generated by the colormap.
290
295
  Controls the dimmest colors. Defaults to 0.8.
291
296
  max_scale (float, optional): Maximum intensity scale for the colors generated by the colormap.
292
297
  Controls the brightest colors. Defaults to 1.0.
293
- scale_factor (float, optional): Exponent for adjusting color scaling based on enrichment scores.
298
+ scale_factor (float, optional): Exponent for adjusting color scaling based on significance scores.
294
299
  A higher value increases contrast by dimming lower scores more. Defaults to 1.0.
300
+ ids_to_colors (Dict[int, Any], None, optional): Mapping of domain IDs to specific colors. Defaults to None.
295
301
  random_seed (int, optional): Seed for random number generation to ensure reproducibility. Defaults to 888.
296
302
 
297
303
  Returns:
@@ -301,9 +307,12 @@ class Contour:
301
307
  graph=self.graph,
302
308
  cmap=cmap,
303
309
  color=color,
310
+ blend_colors=blend_colors,
311
+ blend_gamma=blend_gamma,
304
312
  min_scale=min_scale,
305
313
  max_scale=max_scale,
306
314
  scale_factor=scale_factor,
315
+ ids_to_colors=ids_to_colors,
307
316
  random_seed=random_seed,
308
317
  )
309
318