risk-network 0.0.8b20__py3-none-any.whl → 0.0.8b21__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/io.py +1 -1
- risk/network/plot/canvas.py +2 -2
- risk/network/plot/contour.py +1 -1
- risk/network/plot/labels.py +1 -1
- risk/network/plot/network.py +1 -1
- risk/network/plot/utils/color.py +4 -4
- risk/risk.py +29 -17
- {risk_network-0.0.8b20.dist-info → risk_network-0.0.8b21.dist-info}/METADATA +1 -1
- {risk_network-0.0.8b20.dist-info → risk_network-0.0.8b21.dist-info}/RECORD +13 -13
- {risk_network-0.0.8b20.dist-info → risk_network-0.0.8b21.dist-info}/LICENSE +0 -0
- {risk_network-0.0.8b20.dist-info → risk_network-0.0.8b21.dist-info}/WHEEL +0 -0
- {risk_network-0.0.8b20.dist-info → risk_network-0.0.8b21.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/network/io.py
CHANGED
@@ -491,7 +491,7 @@ class NetworkIO:
|
|
491
491
|
if "x" not in attrs or "y" not in attrs:
|
492
492
|
if (
|
493
493
|
"pos" in attrs
|
494
|
-
and isinstance(attrs["pos"], (
|
494
|
+
and isinstance(attrs["pos"], (list, tuple, np.ndarray))
|
495
495
|
and len(attrs["pos"]) >= 2
|
496
496
|
):
|
497
497
|
attrs["x"], attrs["y"] = attrs["pos"][
|
risk/network/plot/canvas.py
CHANGED
@@ -137,7 +137,7 @@ class Canvas:
|
|
137
137
|
perimeter_linestyle=linestyle,
|
138
138
|
perimeter_linewidth=linewidth,
|
139
139
|
perimeter_color=(
|
140
|
-
"custom" if isinstance(color, (
|
140
|
+
"custom" if isinstance(color, (list, tuple, np.ndarray)) else color
|
141
141
|
), # np.ndarray usually indicates custom colors
|
142
142
|
perimeter_outline_alpha=outline_alpha,
|
143
143
|
perimeter_fill_alpha=fill_alpha,
|
@@ -210,7 +210,7 @@ class Canvas:
|
|
210
210
|
perimeter_grid_size=grid_size,
|
211
211
|
perimeter_linestyle=linestyle,
|
212
212
|
perimeter_linewidth=linewidth,
|
213
|
-
perimeter_color=("custom" if isinstance(color, (
|
213
|
+
perimeter_color=("custom" if isinstance(color, (list, tuple, np.ndarray)) else color),
|
214
214
|
perimeter_outline_alpha=outline_alpha,
|
215
215
|
perimeter_fill_alpha=fill_alpha,
|
216
216
|
)
|
risk/network/plot/contour.py
CHANGED
@@ -122,7 +122,7 @@ class Contour:
|
|
122
122
|
ValueError: If no valid nodes are found in the network graph.
|
123
123
|
"""
|
124
124
|
# Check if nodes is a list of lists or a flat list
|
125
|
-
if any(isinstance(item, (
|
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
128
|
# Convert color to RGBA arrays to match the number of groups
|
risk/network/plot/labels.py
CHANGED
@@ -282,7 +282,7 @@ class Labels:
|
|
282
282
|
arrow_tip_shrink (float, optional): Distance between the arrow tip and the centroid. Defaults to 0.0.
|
283
283
|
"""
|
284
284
|
# Check if nodes is a list of lists or a flat list
|
285
|
-
if any(isinstance(item, (
|
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
288
|
# Convert fontcolor and arrow_color to RGBA arrays to match the number of groups
|
risk/network/plot/network.py
CHANGED
@@ -141,7 +141,7 @@ class Network:
|
|
141
141
|
ValueError: If no valid nodes are found in the network graph.
|
142
142
|
"""
|
143
143
|
# Flatten nested lists of nodes, if necessary
|
144
|
-
if any(isinstance(item, (
|
144
|
+
if any(isinstance(item, (list, tuple, np.ndarray)) for item in nodes):
|
145
145
|
nodes = [node for sublist in nodes for node in sublist]
|
146
146
|
|
147
147
|
# Filter to get node IDs and their coordinates
|
risk/network/plot/utils/color.py
CHANGED
@@ -377,7 +377,7 @@ def to_rgba(
|
|
377
377
|
if isinstance(c, str):
|
378
378
|
# Convert color names or hex values (e.g., 'red', '#FF5733') to RGBA
|
379
379
|
rgba = np.array(mcolors.to_rgba(c))
|
380
|
-
elif isinstance(c, (
|
380
|
+
elif isinstance(c, (list, tuple, np.ndarray)) and len(c) in [3, 4]:
|
381
381
|
# Convert RGB (3) or RGBA (4) values to RGBA format
|
382
382
|
rgba = np.array(mcolors.to_rgba(c))
|
383
383
|
else:
|
@@ -396,8 +396,8 @@ def to_rgba(
|
|
396
396
|
# Handle a single color (string or RGB/RGBA list/tuple)
|
397
397
|
if (
|
398
398
|
isinstance(color, str)
|
399
|
-
or isinstance(color, (
|
400
|
-
and not any(isinstance(c, (str,
|
399
|
+
or isinstance(color, (list, tuple, np.ndarray))
|
400
|
+
and not any(isinstance(c, (str, list, tuple, np.ndarray)) for c in color)
|
401
401
|
):
|
402
402
|
rgba_color = convert_to_rgba(color)
|
403
403
|
if num_repeats:
|
@@ -407,7 +407,7 @@ def to_rgba(
|
|
407
407
|
return np.array([rgba_color]) # Return a single color wrapped in a numpy array
|
408
408
|
|
409
409
|
# Handle a list/array of colors
|
410
|
-
elif isinstance(color, (
|
410
|
+
elif isinstance(color, (list, tuple, np.ndarray)):
|
411
411
|
rgba_colors = np.array(
|
412
412
|
[convert_to_rgba(c) for c in color]
|
413
413
|
) # Convert each color in the list to RGBA
|
risk/risk.py
CHANGED
@@ -3,7 +3,7 @@ risk/risk
|
|
3
3
|
~~~~~~~~~
|
4
4
|
"""
|
5
5
|
|
6
|
-
from typing import Any, Dict, Tuple, Union
|
6
|
+
from typing import Any, Dict, List, Tuple, Union
|
7
7
|
|
8
8
|
import networkx as nx
|
9
9
|
import numpy as np
|
@@ -58,9 +58,9 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
58
58
|
self,
|
59
59
|
network: nx.Graph,
|
60
60
|
annotations: Dict[str, Any],
|
61
|
-
distance_metric: str = "louvain",
|
61
|
+
distance_metric: Union[str, List, Tuple, np.ndarray] = "louvain",
|
62
62
|
louvain_resolution: float = 0.1,
|
63
|
-
edge_length_threshold: float = 0.5,
|
63
|
+
edge_length_threshold: Union[float, List, Tuple, np.ndarray] = 0.5,
|
64
64
|
null_distribution: str = "network",
|
65
65
|
random_seed: int = 888,
|
66
66
|
) -> Dict[str, Any]:
|
@@ -69,9 +69,13 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
69
69
|
Args:
|
70
70
|
network (nx.Graph): The network graph.
|
71
71
|
annotations (Dict[str, Any]): The annotations associated with the network.
|
72
|
-
distance_metric (str, optional):
|
72
|
+
distance_metric (str, List, Tuple, or np.ndarray, optional): The distance metric(s) to use. Can be a string for one
|
73
|
+
metric or a list/tuple/ndarray of metrics ('greedy_modularity', 'louvain', 'label_propagation',
|
74
|
+
'markov_clustering', 'walktrap', 'spinglass'). Defaults to 'louvain'.
|
73
75
|
louvain_resolution (float, optional): Resolution parameter for Louvain clustering. Defaults to 0.1.
|
74
|
-
edge_length_threshold (float, optional): Edge length threshold for
|
76
|
+
edge_length_threshold (float, List, Tuple, or np.ndarray, optional): Edge length threshold(s) for creating subgraphs.
|
77
|
+
Can be a single float for one threshold or a list/tuple of floats corresponding to multiple thresholds.
|
78
|
+
Defaults to 0.5.
|
75
79
|
null_distribution (str, optional): Type of null distribution ('network' or 'annotations'). Defaults to "network".
|
76
80
|
random_seed (int, optional): Seed for random number generation. Defaults to 888.
|
77
81
|
|
@@ -111,9 +115,9 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
111
115
|
self,
|
112
116
|
network: nx.Graph,
|
113
117
|
annotations: Dict[str, Any],
|
114
|
-
distance_metric: str = "louvain",
|
118
|
+
distance_metric: Union[str, List, Tuple, np.ndarray] = "louvain",
|
115
119
|
louvain_resolution: float = 0.1,
|
116
|
-
edge_length_threshold: float = 0.5,
|
120
|
+
edge_length_threshold: Union[float, List, Tuple, np.ndarray] = 0.5,
|
117
121
|
null_distribution: str = "network",
|
118
122
|
random_seed: int = 888,
|
119
123
|
) -> Dict[str, Any]:
|
@@ -122,9 +126,13 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
122
126
|
Args:
|
123
127
|
network (nx.Graph): The network graph.
|
124
128
|
annotations (Dict[str, Any]): The annotations associated with the network.
|
125
|
-
distance_metric (str, optional):
|
129
|
+
distance_metric (str, List, Tuple, or np.ndarray, optional): The distance metric(s) to use. Can be a string for one
|
130
|
+
metric or a list/tuple/ndarray of metrics ('greedy_modularity', 'louvain', 'label_propagation',
|
131
|
+
'markov_clustering', 'walktrap', 'spinglass'). Defaults to 'louvain'.
|
126
132
|
louvain_resolution (float, optional): Resolution parameter for Louvain clustering. Defaults to 0.1.
|
127
|
-
edge_length_threshold (float, optional): Edge length threshold for
|
133
|
+
edge_length_threshold (float, List, Tuple, or np.ndarray, optional): Edge length threshold(s) for creating subgraphs.
|
134
|
+
Can be a single float for one threshold or a list/tuple of floats corresponding to multiple thresholds.
|
135
|
+
Defaults to 0.5.
|
128
136
|
null_distribution (str, optional): Type of null distribution ('network' or 'annotations'). Defaults to "network".
|
129
137
|
random_seed (int, optional): Seed for random number generation. Defaults to 888.
|
130
138
|
|
@@ -164,9 +172,9 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
164
172
|
self,
|
165
173
|
network: nx.Graph,
|
166
174
|
annotations: Dict[str, Any],
|
167
|
-
distance_metric: str = "louvain",
|
175
|
+
distance_metric: Union[str, List, Tuple, np.ndarray] = "louvain",
|
168
176
|
louvain_resolution: float = 0.1,
|
169
|
-
edge_length_threshold: float = 0.5,
|
177
|
+
edge_length_threshold: Union[float, List, Tuple, np.ndarray] = 0.5,
|
170
178
|
score_metric: str = "sum",
|
171
179
|
null_distribution: str = "network",
|
172
180
|
num_permutations: int = 1000,
|
@@ -178,9 +186,13 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
178
186
|
Args:
|
179
187
|
network (nx.Graph): The network graph.
|
180
188
|
annotations (Dict[str, Any]): The annotations associated with the network.
|
181
|
-
distance_metric (str, optional):
|
189
|
+
distance_metric (str, List, Tuple, or np.ndarray, optional): The distance metric(s) to use. Can be a string for one
|
190
|
+
metric or a list/tuple/ndarray of metrics ('greedy_modularity', 'louvain', 'label_propagation',
|
191
|
+
'markov_clustering', 'walktrap', 'spinglass'). Defaults to 'louvain'.
|
182
192
|
louvain_resolution (float, optional): Resolution parameter for Louvain clustering. Defaults to 0.1.
|
183
|
-
edge_length_threshold (float, optional): Edge length threshold for
|
193
|
+
edge_length_threshold (float, List, Tuple, or np.ndarray, optional): Edge length threshold(s) for creating subgraphs.
|
194
|
+
Can be a single float for one threshold or a list/tuple of floats corresponding to multiple thresholds.
|
195
|
+
Defaults to 0.5.
|
184
196
|
score_metric (str, optional): Scoring metric for neighborhood significance. Defaults to "sum".
|
185
197
|
null_distribution (str, optional): Type of null distribution ('network' or 'annotations'). Defaults to "network".
|
186
198
|
num_permutations (int, optional): Number of permutations for significance testing. Defaults to 1000.
|
@@ -353,7 +365,7 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
353
365
|
def load_plotter(
|
354
366
|
self,
|
355
367
|
graph: NetworkGraph,
|
356
|
-
figsize: Tuple = (10, 10),
|
368
|
+
figsize: Union[List, Tuple, np.ndarray] = (10, 10),
|
357
369
|
background_color: str = "white",
|
358
370
|
background_alpha: Union[float, None] = 1.0,
|
359
371
|
pad: float = 0.3,
|
@@ -362,7 +374,7 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
362
374
|
|
363
375
|
Args:
|
364
376
|
graph (NetworkGraph): The graph to plot.
|
365
|
-
figsize (Tuple, optional): Size of the figure. Defaults to (10, 10).
|
377
|
+
figsize (List, Tuple, or np.ndarray, optional): Size of the plot. Defaults to (10, 10)., optional): Size of the figure. Defaults to (10, 10).
|
366
378
|
background_color (str, optional): Background color of the plot. Defaults to "white".
|
367
379
|
background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides
|
368
380
|
any existing alpha values found in background_color. Defaults to 1.0.
|
@@ -385,9 +397,9 @@ class RISK(NetworkIO, AnnotationsIO):
|
|
385
397
|
def _load_neighborhoods(
|
386
398
|
self,
|
387
399
|
network: nx.Graph,
|
388
|
-
distance_metric: str = "louvain",
|
400
|
+
distance_metric: Union[str, List, Tuple, np.ndarray] = "louvain",
|
389
401
|
louvain_resolution: float = 0.1,
|
390
|
-
edge_length_threshold: float = 0.5,
|
402
|
+
edge_length_threshold: Union[float, List, Tuple, np.ndarray] = 0.5,
|
391
403
|
random_seed: int = 888,
|
392
404
|
) -> np.ndarray:
|
393
405
|
"""Load significant neighborhoods for the network.
|
@@ -1,6 +1,6 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=rwU6NXlpU-Cu31fRh5iXEwcYq9jIr2prM7bv_iAaksI,113
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
|
-
risk/risk.py,sha256=
|
3
|
+
risk/risk.py,sha256=8J2cvtXYy99PCoOHEYNXt0vcYrcHqxi2O1VvYQNNPt4,23217
|
4
4
|
risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
|
5
5
|
risk/annotations/annotations.py,sha256=KHGeF5vBDmX711nA08DfhxI9z7Z1Oaeo91ueWhM6vs8,11370
|
6
6
|
risk/annotations/io.py,sha256=powWzeimVdE0WCwlBCXyu5otMyZZHQujC0DS3m5DC0c,9505
|
@@ -14,14 +14,14 @@ risk/neighborhoods/neighborhoods.py,sha256=OPGNfeGQR533vWjger7f34ZPSgw9250LQXcTE
|
|
14
14
|
risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
|
15
15
|
risk/network/geometry.py,sha256=Y3Brp0XYWoBL2VHJX7I-gW5x-q7lGiEMqr2kqtutgkQ,6811
|
16
16
|
risk/network/graph.py,sha256=-91JL84LYbdWohzybKFQ3NdWnervxP-wwbpaUOdRVLE,8576
|
17
|
-
risk/network/io.py,sha256=
|
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=
|
19
|
+
risk/network/plot/canvas.py,sha256=P8XzcesrbxjLcrT40hf15QgLTvearER2Yid3QefQF20,10778
|
20
|
+
risk/network/plot/contour.py,sha256=vo1BeXrMKW-EipLB-9pB5AMfzmiJJduo2H_xgWUoDYo,15027
|
21
|
+
risk/network/plot/labels.py,sha256=wdIi5UfAGVeZ1UM6AAuOQ0I4dBqQqzVe1euGCdiv91o,45115
|
22
|
+
risk/network/plot/network.py,sha256=U-3oYxq-QTZolc72khmesS85pNlep6L40kIT-qZVljE,13615
|
23
23
|
risk/network/plot/plotter.py,sha256=iTPMiTnTTatM_-q1Ox_bjt5Pvv-Lo8gceiYB6TVzDcw,5770
|
24
|
-
risk/network/plot/utils/color.py,sha256=
|
24
|
+
risk/network/plot/utils/color.py,sha256=WSs1ge2oZ8yXwyVk2QqBF-avRd0aYT-sYZr9cxxAn7M,19626
|
25
25
|
risk/network/plot/utils/layout.py,sha256=5DpRLvabgnPWwVJ-J3W6oFBBvbjCrudvvW4HDOzzoTo,1960
|
26
26
|
risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
|
27
27
|
risk/stats/hypergeom.py,sha256=oc39f02ViB1vQ-uaDrxG_tzAT6dxQBRjc88EK2EGn78,2282
|
@@ -30,8 +30,8 @@ risk/stats/stats.py,sha256=07yMULKlCurK62x674SHKJavZtz9ge2K2ZsHix_z_pw,7088
|
|
30
30
|
risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
|
31
31
|
risk/stats/permutation/permutation.py,sha256=meBNSrbRa9P8WJ54n485l0H7VQJlMSfHqdN4aCKYCtQ,10105
|
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.8b21.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
34
|
+
risk_network-0.0.8b21.dist-info/METADATA,sha256=WAMLlJBw45mKR3apG1PxGAQfMOm9flaJxsz_h_rwnGs,47498
|
35
|
+
risk_network-0.0.8b21.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
36
|
+
risk_network-0.0.8b21.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
37
|
+
risk_network-0.0.8b21.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|