risk-network 0.0.7b7__py3-none-any.whl → 0.0.7b8__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/neighborhoods/domains.py +11 -11
- risk/neighborhoods/neighborhoods.py +2 -2
- risk/stats/hypergeom.py +1 -3
- risk/stats/poisson.py +0 -3
- {risk_network-0.0.7b7.dist-info → risk_network-0.0.7b8.dist-info}/METADATA +1 -1
- {risk_network-0.0.7b7.dist-info → risk_network-0.0.7b8.dist-info}/RECORD +10 -10
- {risk_network-0.0.7b7.dist-info → risk_network-0.0.7b8.dist-info}/LICENSE +0 -0
- {risk_network-0.0.7b7.dist-info → risk_network-0.0.7b8.dist-info}/WHEEL +0 -0
- {risk_network-0.0.7b7.dist-info → risk_network-0.0.7b8.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/neighborhoods/domains.py
CHANGED
@@ -4,6 +4,7 @@ risk/neighborhoods/domains
|
|
4
4
|
"""
|
5
5
|
|
6
6
|
from contextlib import suppress
|
7
|
+
from itertools import product
|
7
8
|
from tqdm import tqdm
|
8
9
|
from typing import Tuple
|
9
10
|
|
@@ -165,21 +166,20 @@ def _optimize_silhouette_across_linkage_and_metrics(
|
|
165
166
|
total_combinations = len(linkage_methods) * len(linkage_metrics)
|
166
167
|
|
167
168
|
# Evaluating optimal linkage method and metric
|
168
|
-
for method in tqdm(
|
169
|
-
linkage_methods,
|
169
|
+
for method, metric in tqdm(
|
170
|
+
product(linkage_methods, linkage_metrics),
|
170
171
|
desc="Evaluating optimal linkage method and metric",
|
171
172
|
total=total_combinations,
|
172
173
|
bar_format="{l_bar}{bar}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}]",
|
173
174
|
):
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
best_overall_metric = metric
|
175
|
+
with suppress(Exception):
|
176
|
+
Z = linkage(m, method=method, metric=metric)
|
177
|
+
threshold, score = _find_best_silhouette_score(Z, m, metric, linkage_criterion)
|
178
|
+
if score > best_overall_score:
|
179
|
+
best_overall_score = score
|
180
|
+
best_overall_threshold = threshold
|
181
|
+
best_overall_method = method
|
182
|
+
best_overall_metric = metric
|
183
183
|
|
184
184
|
return best_overall_method, best_overall_metric, best_overall_threshold
|
185
185
|
|
@@ -54,10 +54,10 @@ def get_network_neighborhoods(
|
|
54
54
|
network, edge_length_percentile=edge_length_threshold
|
55
55
|
)
|
56
56
|
|
57
|
-
if distance_metric == "greedy_modularity":
|
58
|
-
return calculate_greedy_modularity_neighborhoods(network)
|
59
57
|
if distance_metric == "louvain":
|
60
58
|
return calculate_louvain_neighborhoods(network, louvain_resolution, random_seed=random_seed)
|
59
|
+
if distance_metric == "greedy_modularity":
|
60
|
+
return calculate_greedy_modularity_neighborhoods(network)
|
61
61
|
if distance_metric == "label_propagation":
|
62
62
|
return calculate_label_propagation_neighborhoods(network)
|
63
63
|
if distance_metric == "markov_clustering":
|
risk/stats/hypergeom.py
CHANGED
@@ -22,9 +22,7 @@ def compute_hypergeom_test(
|
|
22
22
|
Returns:
|
23
23
|
dict: Dictionary containing depletion and enrichment p-values.
|
24
24
|
"""
|
25
|
-
#
|
26
|
-
neighborhoods = (neighborhoods > 0).astype(int)
|
27
|
-
annotations = (annotations > 0).astype(int)
|
25
|
+
# Get the total number of nodes in the network
|
28
26
|
total_node_count = neighborhoods.shape[0]
|
29
27
|
|
30
28
|
if null_distribution == "network":
|
risk/stats/poisson.py
CHANGED
@@ -22,9 +22,6 @@ def compute_poisson_test(
|
|
22
22
|
Returns:
|
23
23
|
dict: Dictionary containing depletion and enrichment p-values.
|
24
24
|
"""
|
25
|
-
# Ensure both matrices are binary (presence/absence)
|
26
|
-
neighborhoods = (neighborhoods > 0).astype(int)
|
27
|
-
annotations = (annotations > 0).astype(int)
|
28
25
|
# Matrix multiplication to get the number of annotated nodes in each neighborhood
|
29
26
|
annotated_in_neighborhood = neighborhoods @ annotations
|
30
27
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=kEtmAgswqdIS5KBKHJO1NZkxJRF6s4ww_cjSOrBuJ4A,112
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
3
|
risk/risk.py,sha256=6666BzdMTgOaQl98ZKiJ19c6XBot26eTJ0iIlk-ZCZQ,20515
|
4
4
|
risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
|
@@ -9,22 +9,22 @@ risk/log/console.py,sha256=im9DRExwf6wHlcn9fewoDcKIpo3vPcorZIaNAl-0csY,355
|
|
9
9
|
risk/log/params.py,sha256=Rfdg5UcGCrG80m6V79FyORERWUqIzHFO7tGiY4zAImM,6347
|
10
10
|
risk/neighborhoods/__init__.py,sha256=tKKEg4lsbqFukpgYlUGxU_v_9FOqK7V0uvM9T2QzoL0,206
|
11
11
|
risk/neighborhoods/community.py,sha256=stYYBXeZlGLMV-k8ckQeIqThT6v9y-S3hETobAo9590,6817
|
12
|
-
risk/neighborhoods/domains.py,sha256=
|
13
|
-
risk/neighborhoods/neighborhoods.py,sha256=
|
12
|
+
risk/neighborhoods/domains.py,sha256=vTCKtRE0oFcY862squrF7_cqCjnckiC9Sl0Qh2FM81k,10665
|
13
|
+
risk/neighborhoods/neighborhoods.py,sha256=5WVXCZ0f-MzUfDITdNlL0NgDS3DBamdc_ZVPA-p9j7U,18218
|
14
14
|
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=_LEoom4EEowGALuJKSXcev9RAAHu2FqIeq3u7mkifW0,16479
|
17
17
|
risk/network/io.py,sha256=gG50kOknO-D3HkW1HsbHMkTMvjUtn3l4W4Jwd-rXNr8,21202
|
18
18
|
risk/network/plot.py,sha256=3OucCoKJwx9M9H4lqAvcQdM9YiCSyIxz21jyqDbpffc,62286
|
19
19
|
risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
|
20
|
-
risk/stats/hypergeom.py,sha256=
|
21
|
-
risk/stats/poisson.py,sha256=
|
20
|
+
risk/stats/hypergeom.py,sha256=o6Qnj31gCAKxr2uQirXrbv7XvdDJGEq69MFW-ubx_hA,2272
|
21
|
+
risk/stats/poisson.py,sha256=8x9hB4DCukq4gNIlIKO-c_jYG1-BTwTX53oLauFyfj8,1793
|
22
22
|
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=kmSZ7bQ-AD0TFiQDgIwfxTeqHa4pjp7fIcOzAqyhUNY,9714
|
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.7b8.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
27
|
+
risk_network-0.0.7b8.dist-info/METADATA,sha256=aFjqRdtk2rsHn0AHuofhj9ZtkFFuuxfgLd_DnyX52qA,43142
|
28
|
+
risk_network-0.0.7b8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
29
|
+
risk_network-0.0.7b8.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
30
|
+
risk_network-0.0.7b8.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|