risk-network 0.0.6b4__py3-none-any.whl → 0.0.6b5__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.py +32 -22
- {risk_network-0.0.6b4.dist-info → risk_network-0.0.6b5.dist-info}/METADATA +1 -1
- {risk_network-0.0.6b4.dist-info → risk_network-0.0.6b5.dist-info}/RECORD +7 -7
- {risk_network-0.0.6b4.dist-info → risk_network-0.0.6b5.dist-info}/LICENSE +0 -0
- {risk_network-0.0.6b4.dist-info → risk_network-0.0.6b5.dist-info}/WHEEL +0 -0
- {risk_network-0.0.6b4.dist-info → risk_network-0.0.6b5.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/network/plot.py
CHANGED
@@ -137,9 +137,7 @@ class NetworkPlotter:
|
|
137
137
|
)
|
138
138
|
# Set the transparency of the fill if applicable
|
139
139
|
if fill_alpha > 0:
|
140
|
-
circle.set_facecolor(
|
141
|
-
_to_rgba(color, fill_alpha)
|
142
|
-
) # Use _to_rgba to set the fill color with transparency
|
140
|
+
circle.set_facecolor(_to_rgba(color, fill_alpha))
|
143
141
|
|
144
142
|
self.ax.add_artist(circle)
|
145
143
|
|
@@ -200,7 +198,7 @@ class NetworkPlotter:
|
|
200
198
|
color=color,
|
201
199
|
linestyle=linestyle,
|
202
200
|
linewidth=linewidth,
|
203
|
-
alpha=fill_alpha,
|
201
|
+
alpha=fill_alpha,
|
204
202
|
)
|
205
203
|
|
206
204
|
def plot_network(
|
@@ -279,7 +277,7 @@ class NetworkPlotter:
|
|
279
277
|
nodes: List,
|
280
278
|
node_size: Union[int, np.ndarray] = 50,
|
281
279
|
node_shape: str = "o",
|
282
|
-
node_edgewidth: float = 1.0,
|
280
|
+
node_edgewidth: float = 1.0,
|
283
281
|
edge_width: float = 1.0,
|
284
282
|
node_color: Union[str, List, Tuple, np.ndarray] = "white",
|
285
283
|
node_edgecolor: Union[str, List, Tuple, np.ndarray] = "black",
|
@@ -313,8 +311,8 @@ class NetworkPlotter:
|
|
313
311
|
if not node_ids:
|
314
312
|
raise ValueError("No nodes found in the network graph.")
|
315
313
|
|
316
|
-
#
|
317
|
-
if not isinstance(node_color, str):
|
314
|
+
# Check if node_color is a single color or a list of colors
|
315
|
+
if not isinstance(node_color, (str, tuple, np.ndarray)):
|
318
316
|
node_color = [
|
319
317
|
node_color[nodes.index(node)]
|
320
318
|
for node in nodes
|
@@ -325,6 +323,7 @@ class NetworkPlotter:
|
|
325
323
|
node_color = _to_rgba(node_color, node_alpha, num_repeats=len(node_ids))
|
326
324
|
node_edgecolor = _to_rgba(node_edgecolor, 1.0, num_repeats=len(node_ids))
|
327
325
|
edge_color = _to_rgba(edge_color, edge_alpha, num_repeats=len(self.graph.network.edges))
|
326
|
+
|
328
327
|
# Get the coordinates of the filtered nodes
|
329
328
|
node_coordinates = {node_id: self.graph.node_coordinates[node_id] for node_id in node_ids}
|
330
329
|
|
@@ -358,7 +357,8 @@ class NetworkPlotter:
|
|
358
357
|
color: Union[str, List, Tuple, np.ndarray] = "white",
|
359
358
|
linestyle: str = "solid",
|
360
359
|
linewidth: float = 1.5,
|
361
|
-
alpha: float = 0
|
360
|
+
alpha: float = 1.0,
|
361
|
+
fill_alpha: float = 0.2,
|
362
362
|
) -> None:
|
363
363
|
"""Draw KDE contours for nodes in various domains of a network graph, highlighting areas of high density.
|
364
364
|
|
@@ -369,7 +369,8 @@ class NetworkPlotter:
|
|
369
369
|
color (str, list, tuple, or np.ndarray, optional): Color of the contours. Can be a single color or an array of colors. Defaults to "white".
|
370
370
|
linestyle (str, optional): Line style for the contours. Defaults to "solid".
|
371
371
|
linewidth (float, optional): Line width for the contours. Defaults to 1.5.
|
372
|
-
alpha (float, optional): Transparency level of the contour
|
372
|
+
alpha (float, optional): Transparency level of the contour lines. Defaults to 1.0.
|
373
|
+
fill_alpha (float, optional): Transparency level of the contour fill. Defaults to 0.2.
|
373
374
|
"""
|
374
375
|
# Log the contour plotting parameters
|
375
376
|
params.log_plotter(
|
@@ -380,6 +381,7 @@ class NetworkPlotter:
|
|
380
381
|
"custom" if isinstance(color, np.ndarray) else color
|
381
382
|
), # np.ndarray usually indicates custom colors
|
382
383
|
contour_alpha=alpha,
|
384
|
+
contour_fill_alpha=fill_alpha,
|
383
385
|
)
|
384
386
|
|
385
387
|
# Ensure color is converted to RGBA with repetition matching the number of domains
|
@@ -400,6 +402,7 @@ class NetworkPlotter:
|
|
400
402
|
linestyle=linestyle,
|
401
403
|
linewidth=linewidth,
|
402
404
|
alpha=alpha,
|
405
|
+
fill_alpha=fill_alpha,
|
403
406
|
)
|
404
407
|
|
405
408
|
def plot_subcontour(
|
@@ -411,7 +414,8 @@ class NetworkPlotter:
|
|
411
414
|
color: Union[str, List, Tuple, np.ndarray] = "white",
|
412
415
|
linestyle: str = "solid",
|
413
416
|
linewidth: float = 1.5,
|
414
|
-
alpha: float = 0
|
417
|
+
alpha: float = 1.0,
|
418
|
+
fill_alpha: float = 0.2,
|
415
419
|
) -> None:
|
416
420
|
"""Plot a subcontour for a given set of nodes using Kernel Density Estimation (KDE).
|
417
421
|
|
@@ -423,7 +427,8 @@ class NetworkPlotter:
|
|
423
427
|
color (str, list, tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array. Defaults to "white".
|
424
428
|
linestyle (str, optional): Line style for the contour. Defaults to "solid".
|
425
429
|
linewidth (float, optional): Line width for the contour. Defaults to 1.5.
|
426
|
-
alpha (float, optional): Transparency level of the contour
|
430
|
+
alpha (float, optional): Transparency level of the contour lines. Defaults to 1.0.
|
431
|
+
fill_alpha (float, optional): Transparency level of the contour fill. Defaults to 0.2.
|
427
432
|
|
428
433
|
Raises:
|
429
434
|
ValueError: If no valid nodes are found in the network graph.
|
@@ -453,6 +458,7 @@ class NetworkPlotter:
|
|
453
458
|
linestyle=linestyle,
|
454
459
|
linewidth=linewidth,
|
455
460
|
alpha=alpha,
|
461
|
+
fill_alpha=fill_alpha,
|
456
462
|
)
|
457
463
|
|
458
464
|
def _draw_kde_contour(
|
@@ -466,7 +472,8 @@ class NetworkPlotter:
|
|
466
472
|
color: Union[str, np.ndarray] = "white",
|
467
473
|
linestyle: str = "solid",
|
468
474
|
linewidth: float = 1.5,
|
469
|
-
alpha: float = 0
|
475
|
+
alpha: float = 1.0,
|
476
|
+
fill_alpha: float = 0.2,
|
470
477
|
) -> None:
|
471
478
|
"""Draw a Kernel Density Estimate (KDE) contour plot for a set of nodes on a given axis.
|
472
479
|
|
@@ -480,7 +487,8 @@ class NetworkPlotter:
|
|
480
487
|
color (str or np.ndarray): Color for the contour. Can be a string or RGBA array. Defaults to "white".
|
481
488
|
linestyle (str, optional): Line style for the contour. Defaults to "solid".
|
482
489
|
linewidth (float, optional): Line width for the contour. Defaults to 1.5.
|
483
|
-
alpha (float, optional): Transparency level for the contour
|
490
|
+
alpha (float, optional): Transparency level for the contour lines. Defaults to 1.0.
|
491
|
+
fill_alpha (float, optional): Transparency level for the contour fill. Defaults to 0.2.
|
484
492
|
"""
|
485
493
|
# Extract the positions of the specified nodes
|
486
494
|
points = np.array([pos[n] for n in nodes])
|
@@ -506,8 +514,8 @@ class NetworkPlotter:
|
|
506
514
|
min_density, max_density = z.min(), z.max()
|
507
515
|
contour_levels = np.linspace(min_density, max_density, levels)[1:]
|
508
516
|
contour_colors = [color for _ in range(levels - 1)]
|
509
|
-
# Plot the filled contours
|
510
|
-
if
|
517
|
+
# Plot the filled contours using fill_alpha for transparency
|
518
|
+
if fill_alpha > 0:
|
511
519
|
ax.contourf(
|
512
520
|
x,
|
513
521
|
y,
|
@@ -515,10 +523,10 @@ class NetworkPlotter:
|
|
515
523
|
levels=contour_levels,
|
516
524
|
colors=contour_colors,
|
517
525
|
antialiased=True,
|
518
|
-
alpha=
|
526
|
+
alpha=fill_alpha,
|
519
527
|
)
|
520
528
|
|
521
|
-
# Plot the contour lines
|
529
|
+
# Plot the contour lines with the specified alpha for transparency
|
522
530
|
c = ax.contour(
|
523
531
|
x,
|
524
532
|
y,
|
@@ -527,7 +535,9 @@ class NetworkPlotter:
|
|
527
535
|
colors=contour_colors,
|
528
536
|
linestyles=linestyle,
|
529
537
|
linewidths=linewidth,
|
538
|
+
alpha=alpha,
|
530
539
|
)
|
540
|
+
# Set linewidth for the contour lines to 0 for levels other than the base level
|
531
541
|
for i in range(1, len(contour_levels)):
|
532
542
|
c.collections[i].set_linewidth(0)
|
533
543
|
|
@@ -810,13 +820,13 @@ class NetworkPlotter:
|
|
810
820
|
return adjusted_network_colors
|
811
821
|
|
812
822
|
def get_annotated_node_sizes(
|
813
|
-
self,
|
823
|
+
self, enriched_size: int = 50, nonenriched_size: int = 25
|
814
824
|
) -> np.ndarray:
|
815
825
|
"""Adjust the sizes of nodes in the network graph based on whether they are enriched or not.
|
816
826
|
|
817
827
|
Args:
|
818
|
-
|
819
|
-
|
828
|
+
enriched_size (int): Size for enriched nodes. Defaults to 50.
|
829
|
+
nonenriched_size (int): Size for non-enriched nodes. Defaults to 25.
|
820
830
|
|
821
831
|
Returns:
|
822
832
|
np.ndarray: Array of node sizes, with enriched nodes larger than non-enriched ones.
|
@@ -827,11 +837,11 @@ class NetworkPlotter:
|
|
827
837
|
enriched_nodes.update(nodes)
|
828
838
|
|
829
839
|
# Initialize all node sizes to the non-enriched size
|
830
|
-
node_sizes = np.full(len(self.graph.network.nodes),
|
840
|
+
node_sizes = np.full(len(self.graph.network.nodes), nonenriched_size)
|
831
841
|
# Set the size for enriched nodes
|
832
842
|
for node in enriched_nodes:
|
833
843
|
if node in self.graph.network.nodes:
|
834
|
-
node_sizes[node] =
|
844
|
+
node_sizes[node] = enriched_size
|
835
845
|
|
836
846
|
return node_sizes
|
837
847
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=jf5xP5gj27WAK2wVj_hGCCzypgykcOCBS7791xT2wDA,112
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
3
|
risk/risk.py,sha256=PONl5tzN5DSVUf4MgczfOvzGV-5JoAOLTQ6YWl10mZ8,20697
|
4
4
|
risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
|
@@ -15,7 +15,7 @@ risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
|
|
15
15
|
risk/network/geometry.py,sha256=H1yGVVqgbfpzBzJwEheDLfvGLSA284jGQQTn612L4Vc,6759
|
16
16
|
risk/network/graph.py,sha256=scPFQIJjioup1FjQLyxNrAB17RmskY9MmvoFHrMlqNI,13135
|
17
17
|
risk/network/io.py,sha256=gG50kOknO-D3HkW1HsbHMkTMvjUtn3l4W4Jwd-rXNr8,21202
|
18
|
-
risk/network/plot.py,sha256=
|
18
|
+
risk/network/plot.py,sha256=j9e_9kV5VMMpsBwtIx_QqlUJnFHXIFlnO8RLWqNiEog,55852
|
19
19
|
risk/stats/__init__.py,sha256=e-BE_Dr_jgiK6hKM-T-tlG4yvHnId8e5qjnM0pdwNVc,230
|
20
20
|
risk/stats/fisher_exact.py,sha256=-bPwzu76-ob0HzrTV20mXUTot7v-MLuqFaAoab-QxPg,4966
|
21
21
|
risk/stats/hypergeom.py,sha256=lrIFdhCWRjvM4apYw1MlOKqT_IY5OjtCwrjdtJdt6Tg,4954
|
@@ -23,8 +23,8 @@ risk/stats/stats.py,sha256=kvShov-94W6ffgDUTb522vB9hDJQSyTsYif_UIaFfSM,7059
|
|
23
23
|
risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
|
24
24
|
risk/stats/permutation/permutation.py,sha256=qLWdwxEY6nmkYPxpM8HLDcd2mbqYv9Qr7CKtJvhLqIM,9220
|
25
25
|
risk/stats/permutation/test_functions.py,sha256=HuDIM-V1jkkfE1rlaIqrWWBSKZt3dQ1f-YEDjWpnLSE,2343
|
26
|
-
risk_network-0.0.
|
27
|
-
risk_network-0.0.
|
28
|
-
risk_network-0.0.
|
29
|
-
risk_network-0.0.
|
30
|
-
risk_network-0.0.
|
26
|
+
risk_network-0.0.6b5.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
27
|
+
risk_network-0.0.6b5.dist-info/METADATA,sha256=CNH8nImHfKqJCbvwEApq9r4qIaf2tV8HRU179Jj6njU,43142
|
28
|
+
risk_network-0.0.6b5.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
|
29
|
+
risk_network-0.0.6b5.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
30
|
+
risk_network-0.0.6b5.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|