risk-network 0.0.9b2__py3-none-any.whl → 0.0.9b3__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/graph/network.py +2 -2
- risk/network/graph/summary.py +9 -15
- {risk_network-0.0.9b2.dist-info → risk_network-0.0.9b3.dist-info}/METADATA +1 -1
- {risk_network-0.0.9b2.dist-info → risk_network-0.0.9b3.dist-info}/RECORD +8 -8
- {risk_network-0.0.9b2.dist-info → risk_network-0.0.9b3.dist-info}/LICENSE +0 -0
- {risk_network-0.0.9b2.dist-info → risk_network-0.0.9b3.dist-info}/WHEEL +0 -0
- {risk_network-0.0.9b2.dist-info → risk_network-0.0.9b3.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/network/graph/network.py
CHANGED
@@ -10,7 +10,7 @@ import networkx as nx
|
|
10
10
|
import numpy as np
|
11
11
|
import pandas as pd
|
12
12
|
|
13
|
-
from risk.network.graph.summary import
|
13
|
+
from risk.network.graph.summary import AnalysisSummary
|
14
14
|
|
15
15
|
|
16
16
|
class NetworkGraph:
|
@@ -73,7 +73,7 @@ class NetworkGraph:
|
|
73
73
|
self.node_coordinates = _extract_node_coordinates(self.network)
|
74
74
|
|
75
75
|
# NOTE: Only after the above attributes are initialized, we can create the summary
|
76
|
-
self.summary =
|
76
|
+
self.summary = AnalysisSummary(annotations, neighborhoods, self)
|
77
77
|
|
78
78
|
@staticmethod
|
79
79
|
def _create_domain_id_to_node_ids_map(domains: pd.DataFrame) -> Dict[int, Any]:
|
risk/network/graph/summary.py
CHANGED
@@ -3,8 +3,6 @@ risk/network/graph/summary
|
|
3
3
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
4
4
|
"""
|
5
5
|
|
6
|
-
import warnings
|
7
|
-
from functools import lru_cache
|
8
6
|
from typing import Any, Dict, Tuple, Union
|
9
7
|
|
10
8
|
import numpy as np
|
@@ -14,11 +12,7 @@ from statsmodels.stats.multitest import fdrcorrection
|
|
14
12
|
from risk.log.console import logger, log_header
|
15
13
|
|
16
14
|
|
17
|
-
|
18
|
-
warnings.filterwarnings("ignore")
|
19
|
-
|
20
|
-
|
21
|
-
class Summary:
|
15
|
+
class AnalysisSummary:
|
22
16
|
"""Handles the processing, storage, and export of network analysis results.
|
23
17
|
|
24
18
|
The Results class provides methods to process significance and depletion data, compute
|
@@ -79,7 +73,6 @@ class Summary:
|
|
79
73
|
|
80
74
|
logger.info(f"Results summary exported to text file: {filepath}")
|
81
75
|
|
82
|
-
@lru_cache(maxsize=None)
|
83
76
|
def load(self) -> pd.DataFrame:
|
84
77
|
"""Load and process domain and annotation data into a DataFrame with significance metrics.
|
85
78
|
|
@@ -91,7 +84,7 @@ class Summary:
|
|
91
84
|
pd.DataFrame: Processed DataFrame containing significance scores, p-values, q-values,
|
92
85
|
and annotation member information.
|
93
86
|
"""
|
94
|
-
log_header("Loading
|
87
|
+
log_header("Loading analysis summary")
|
95
88
|
# Calculate significance and depletion q-values from p-value matrices in `annotations`
|
96
89
|
enrichment_pvals = self.neighborhoods["enrichment_pvals"]
|
97
90
|
depletion_pvals = self.neighborhoods["depletion_pvals"]
|
@@ -132,12 +125,12 @@ class Summary:
|
|
132
125
|
result_type="expand",
|
133
126
|
)
|
134
127
|
# Add annotation members and their counts
|
135
|
-
results["Annotation Members"] = results["Annotation"].apply(
|
128
|
+
results["Annotation Members in Network"] = results["Annotation"].apply(
|
136
129
|
lambda desc: self._get_annotation_members(desc)
|
137
130
|
)
|
138
|
-
results["Annotation Member Count"] = results[
|
139
|
-
|
140
|
-
)
|
131
|
+
results["Annotation Member in Network Count"] = results[
|
132
|
+
"Annotation Members in Network"
|
133
|
+
].apply(lambda x: len(x.split(";")) if x else 0)
|
141
134
|
|
142
135
|
# Reorder columns and drop rows with NaN values
|
143
136
|
results = (
|
@@ -145,8 +138,8 @@ class Summary:
|
|
145
138
|
[
|
146
139
|
"Domain ID",
|
147
140
|
"Annotation",
|
148
|
-
"Annotation Members",
|
149
|
-
"Annotation Member Count",
|
141
|
+
"Annotation Members in Network",
|
142
|
+
"Annotation Member in Network Count",
|
150
143
|
"Summed Significance Score",
|
151
144
|
"Enrichment P-value",
|
152
145
|
"Enrichment Q-value",
|
@@ -230,6 +223,7 @@ class Summary:
|
|
230
223
|
except ValueError:
|
231
224
|
return "" # Description not found
|
232
225
|
|
226
|
+
# Get nodes present for the annotation and sort by node label
|
233
227
|
nodes_present = np.where(self.annotations["matrix"][:, annotation_idx] == 1)[0]
|
234
228
|
node_labels = sorted(
|
235
229
|
self.graph.node_id_to_node_label_map[node_id]
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=japxenqMvqgfrLH-PHOulkDBiW_CZRMVUaDbR92setc,112
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
3
|
risk/risk.py,sha256=De1vn8Xc-TKz6aTL0bvJI-SVrIqU3k0IWAbKc7dde1c,23618
|
4
4
|
risk/annotations/__init__.py,sha256=kXgadEXaCh0z8OyhOhTj7c3qXGmWgOhaSZ4gSzSb59U,147
|
@@ -15,8 +15,8 @@ risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
|
|
15
15
|
risk/network/geometry.py,sha256=gFtYUj9j9aul4paKq_qSGJn39Nazxu_MXv8m-tYYtrk,6840
|
16
16
|
risk/network/io.py,sha256=AWSbZGLZHtl72KSlafQlcYoG00YLSznG7UYDi_wDT7M,22958
|
17
17
|
risk/network/graph/__init__.py,sha256=H0YEiwqZ02LBTkH4blPwUjQ-DOUnhaTTNHM0BcXii6U,81
|
18
|
-
risk/network/graph/network.py,sha256=
|
19
|
-
risk/network/graph/summary.py,sha256=
|
18
|
+
risk/network/graph/network.py,sha256=o7Rdp2S8cxYiT90IvGLqsn93wq9YA1vKRZ7fedLUir0,10208
|
19
|
+
risk/network/graph/summary.py,sha256=f4j-ERlddzAhd9qEELiGdzmPqpzgoRODyHNe9QuRT7k,9190
|
20
20
|
risk/network/plot/__init__.py,sha256=MfmaXJgAZJgXZ2wrhK8pXwzETlcMaLChhWXKAozniAo,98
|
21
21
|
risk/network/plot/canvas.py,sha256=TlCpNtvoceizAumNr9I02JcBrBO6FiAFAa2ZC0bx3SU,13356
|
22
22
|
risk/network/plot/contour.py,sha256=2ZVOlduo4Y4yIpXDJMIKO-v7eULcJ2QacQyOc7pUAxE,15267
|
@@ -32,8 +32,8 @@ risk/stats/stats.py,sha256=z8NrhiVj4BzJ250bVLfytpmfC7RzYu7mBuIZD_l0aCA,7222
|
|
32
32
|
risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
|
33
33
|
risk/stats/permutation/permutation.py,sha256=meBNSrbRa9P8WJ54n485l0H7VQJlMSfHqdN4aCKYCtQ,10105
|
34
34
|
risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
|
35
|
-
risk_network-0.0.
|
36
|
-
risk_network-0.0.
|
37
|
-
risk_network-0.0.
|
38
|
-
risk_network-0.0.
|
39
|
-
risk_network-0.0.
|
35
|
+
risk_network-0.0.9b3.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
36
|
+
risk_network-0.0.9b3.dist-info/METADATA,sha256=nUhDrkDb3ZbsCcKRxKOgx6yL6t1FHK4SRbrQNjdktII,47497
|
37
|
+
risk_network-0.0.9b3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
38
|
+
risk_network-0.0.9b3.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
39
|
+
risk_network-0.0.9b3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|