risk-network 0.0.9b33__py3-none-any.whl → 0.0.9b35__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/api.py +3 -3
- risk/network/graph/summary.py +6 -6
- risk/network/io.py +18 -2
- risk/stats/stat_tests.py +3 -3
- {risk_network-0.0.9b33.dist-info → risk_network-0.0.9b35.dist-info}/METADATA +1 -1
- {risk_network-0.0.9b33.dist-info → risk_network-0.0.9b35.dist-info}/RECORD +10 -10
- {risk_network-0.0.9b33.dist-info → risk_network-0.0.9b35.dist-info}/LICENSE +0 -0
- {risk_network-0.0.9b33.dist-info → risk_network-0.0.9b35.dist-info}/WHEEL +0 -0
- {risk_network-0.0.9b33.dist-info → risk_network-0.0.9b35.dist-info}/top_level.txt +0 -0
risk/__init__.py
CHANGED
risk/neighborhoods/api.py
CHANGED
@@ -280,7 +280,7 @@ class NeighborhoodsAPI:
|
|
280
280
|
null_distribution: str = "network",
|
281
281
|
random_seed: int = 888,
|
282
282
|
) -> Dict[str, Any]:
|
283
|
-
"""Load significant neighborhoods for the network using the
|
283
|
+
"""Load significant neighborhoods for the network using the z-score test.
|
284
284
|
|
285
285
|
Args:
|
286
286
|
network (nx.Graph): The network graph.
|
@@ -299,8 +299,8 @@ class NeighborhoodsAPI:
|
|
299
299
|
Returns:
|
300
300
|
Dict[str, Any]: Computed significance of neighborhoods.
|
301
301
|
"""
|
302
|
-
log_header("Running
|
303
|
-
# Compute neighborhood significance using the
|
302
|
+
log_header("Running z-score test")
|
303
|
+
# Compute neighborhood significance using the z-score test
|
304
304
|
return self._load_neighborhoods_by_statistical_test(
|
305
305
|
network=network,
|
306
306
|
annotations=annotations,
|
risk/network/graph/summary.py
CHANGED
@@ -103,9 +103,9 @@ class Summary:
|
|
103
103
|
# Add minimum p-values and q-values to DataFrame
|
104
104
|
results[
|
105
105
|
[
|
106
|
-
"Enrichment P-
|
106
|
+
"Enrichment P-Value",
|
107
107
|
"Enrichment Q-value",
|
108
|
-
"Depletion P-
|
108
|
+
"Depletion P-Value",
|
109
109
|
"Depletion Q-value",
|
110
110
|
]
|
111
111
|
] = results.apply(
|
@@ -137,9 +137,9 @@ class Summary:
|
|
137
137
|
"Annotation Members in Network",
|
138
138
|
"Annotation Members in Network Count",
|
139
139
|
"Summed Significance Score",
|
140
|
-
"Enrichment P-
|
140
|
+
"Enrichment P-Value",
|
141
141
|
"Enrichment Q-value",
|
142
|
-
"Depletion P-
|
142
|
+
"Depletion P-Value",
|
143
143
|
"Depletion Q-value",
|
144
144
|
]
|
145
145
|
]
|
@@ -156,9 +156,9 @@ class Summary:
|
|
156
156
|
"Annotation Members in Network": "",
|
157
157
|
"Annotation Members in Network Count": 0,
|
158
158
|
"Summed Significance Score": 0.0,
|
159
|
-
"Enrichment P-
|
159
|
+
"Enrichment P-Value": 1.0,
|
160
160
|
"Enrichment Q-value": 1.0,
|
161
|
-
"Depletion P-
|
161
|
+
"Depletion P-Value": 1.0,
|
162
162
|
"Depletion Q-value": 1.0,
|
163
163
|
}
|
164
164
|
)
|
risk/network/io.py
CHANGED
@@ -262,8 +262,25 @@ class NetworkIO:
|
|
262
262
|
attribute_table.columns = attribute_table.iloc[0]
|
263
263
|
# Skip first four rows, select source and target columns, and reset index
|
264
264
|
attribute_table = attribute_table.iloc[4:, :]
|
265
|
-
|
265
|
+
try:
|
266
|
+
# Attempt to filter the attribute_table with the given labels
|
267
|
+
attribute_table = attribute_table[[source_label, target_label]]
|
268
|
+
except KeyError as e:
|
269
|
+
# Find which key(s) caused the issue
|
270
|
+
missing_keys = [
|
271
|
+
key
|
272
|
+
for key in [source_label, target_label]
|
273
|
+
if key not in attribute_table.columns
|
274
|
+
]
|
275
|
+
# Raise the KeyError with details about the issue and available options
|
276
|
+
available_columns = ", ".join(attribute_table.columns)
|
277
|
+
raise KeyError(
|
278
|
+
f"The column(s) '{', '.join(missing_keys)}' do not exist in the table. "
|
279
|
+
f"Available columns are: {available_columns}."
|
280
|
+
) from e
|
281
|
+
|
266
282
|
attribute_table = attribute_table.dropna().reset_index(drop=True)
|
283
|
+
|
267
284
|
# Create a graph
|
268
285
|
G = nx.Graph()
|
269
286
|
# Add edges and nodes
|
@@ -271,7 +288,6 @@ class NetworkIO:
|
|
271
288
|
source = row[source_label]
|
272
289
|
target = row[target_label]
|
273
290
|
G.add_edge(source, target)
|
274
|
-
|
275
291
|
if source not in G:
|
276
292
|
G.add_node(source) # Optionally add x, y coordinates here if available
|
277
293
|
if target not in G:
|
risk/stats/stat_tests.py
CHANGED
@@ -215,7 +215,7 @@ def compute_zscore_test(
|
|
215
215
|
null_distribution: str = "network",
|
216
216
|
) -> Dict[str, Any]:
|
217
217
|
"""
|
218
|
-
Compute
|
218
|
+
Compute z-score test for enrichment and depletion in neighborhoods with selectable null distribution.
|
219
219
|
|
220
220
|
Args:
|
221
221
|
neighborhoods (csr_matrix): Sparse binary matrix representing neighborhoods.
|
@@ -257,10 +257,10 @@ def compute_zscore_test(
|
|
257
257
|
* (1 - neighborhood_sums / background_population)
|
258
258
|
)
|
259
259
|
std_dev[std_dev == 0] = np.nan # Avoid division by zero
|
260
|
-
# Compute
|
260
|
+
# Compute z-scores
|
261
261
|
z_scores = (observed - expected) / std_dev
|
262
262
|
|
263
|
-
# Convert
|
263
|
+
# Convert z-scores to depletion and enrichment p-values
|
264
264
|
enrichment_pvals = norm.sf(z_scores) # Upper tail
|
265
265
|
depletion_pvals = norm.cdf(z_scores) # Lower tail
|
266
266
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
risk/__init__.py,sha256=
|
1
|
+
risk/__init__.py,sha256=r0xnE00ojEe_XG3ZBNV_1n3-vl0XWYuOA9-na0o5v2w,127
|
2
2
|
risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
|
3
3
|
risk/risk.py,sha256=s827_lRknFseOP9O4zW8sP-IcCd2EzrpV_tnVY_tz5s,1104
|
4
4
|
risk/annotations/__init__.py,sha256=parsbcux1U4urpUqh9AdzbDWuLj9HlMidycMPkpSQFo,179
|
@@ -8,17 +8,17 @@ risk/log/__init__.py,sha256=7LxDysQu7doi0LAvlY2YbjN6iJH0fNknqy8lSLgeljo,217
|
|
8
8
|
risk/log/console.py,sha256=PgjyEvyhYLUSHXPUKEqOmxsDsfrjPICIgqo_cAHq0N8,4575
|
9
9
|
risk/log/parameters.py,sha256=VtwfMzLU1xI4yji3-Ch5vHjH-KdwTfwaEMmi7hFQTs0,5716
|
10
10
|
risk/neighborhoods/__init__.py,sha256=Q74HwTH7okI-vaskJPy2bYwb5sNjGASTzJ6m8V8arCU,234
|
11
|
-
risk/neighborhoods/api.py,sha256=
|
11
|
+
risk/neighborhoods/api.py,sha256=ywngw2TQVV27gYlWDXcs8-qnmeepnvb-W9ov6J6VEPM,23341
|
12
12
|
risk/neighborhoods/community.py,sha256=5Q_-VAJC-5SY5EUsB8gIlemeDoAL85uLjyl16pItHiQ,16699
|
13
13
|
risk/neighborhoods/domains.py,sha256=jMJ4-Qzwgmo6Hya8h0E2_IcMaLpbuH_FWlmSjJl2ikc,12832
|
14
14
|
risk/neighborhoods/neighborhoods.py,sha256=l9FhADB1C-OxM8E9QXOcA4osUDgA1vs4ud-OCGKKybc,21457
|
15
15
|
risk/network/__init__.py,sha256=oVi3FA1XXKD84014Cykq-9bpX4_s0F3aAUfNOU-07Qw,73
|
16
16
|
risk/network/geometry.py,sha256=eVtGHMgBf9fEqQZUFdHWjw-zFYYpfUONoHFSAxoRkug,6219
|
17
|
-
risk/network/io.py,sha256=
|
17
|
+
risk/network/io.py,sha256=RCH4nQdgYDXcNwMfpSz7qEmPO0pJ1p9fL0rNQptsQrc,21673
|
18
18
|
risk/network/graph/__init__.py,sha256=ziGJew3yhtqvrb9LUuneDu_LwW2Wa9vd4UuhoL5l1CA,91
|
19
19
|
risk/network/graph/api.py,sha256=t5Mh5_lD2uTLioEJFfCRe7ncc5iLNYzxd6r05wSiv7s,8169
|
20
20
|
risk/network/graph/graph.py,sha256=qEWyZvuaGT_vvjhreBdmRPX3gst2wQFaXhFAvikPSqw,12158
|
21
|
-
risk/network/graph/summary.py,sha256=
|
21
|
+
risk/network/graph/summary.py,sha256=Y_0rL2C1UoQeZQIPVe5LbaCO356Mcc8HisnrXwQsRm8,10289
|
22
22
|
risk/network/plotter/__init__.py,sha256=4gWtQHGzQVNHmEBXi31Zf0tX0y2sTcE66J_yGnn7268,99
|
23
23
|
risk/network/plotter/api.py,sha256=oJIj7vYv-3VpfN41ndCNtxcWIuhT2ULwAaPPU2f4oeM,1785
|
24
24
|
risk/network/plotter/canvas.py,sha256=ifyTMyXYRzlcdSYy6C23k3dmwtbLDrOfdMvEjkW2gLg,13460
|
@@ -30,12 +30,12 @@ risk/network/plotter/utils/colors.py,sha256=EaiKsNPy_lcjrPp-QTNy3LnQdAZMjz2Legbe
|
|
30
30
|
risk/network/plotter/utils/layout.py,sha256=OPqV8jzV9dpnOhYU4SYMSfsIXalVzESrlBSI_Y43OGU,3640
|
31
31
|
risk/stats/__init__.py,sha256=2zdLv3tUHKyAjwAo7LprVXRaak1cHgrpYMVMSik6JM4,324
|
32
32
|
risk/stats/significance.py,sha256=6cKv2xBQXWTHZ6HpNWIqlNfKKS5pG_BcCUdMM3r_zw4,7336
|
33
|
-
risk/stats/stat_tests.py,sha256=
|
33
|
+
risk/stats/stat_tests.py,sha256=tj0ri9w89_1fsjGLuafTWpfBEwZXpSLn7Ej2aAQ5lxk,11776
|
34
34
|
risk/stats/permutation/__init__.py,sha256=OLmYLm2uj96hPsSaUs0vUqFYw6Thwch_aHtpL7L0ZFw,127
|
35
35
|
risk/stats/permutation/permutation.py,sha256=BWjgdBpLVcHvmwHy0bmD4aJFccxifNBSrrCBPppyKf4,10569
|
36
36
|
risk/stats/permutation/test_functions.py,sha256=KlECWTz1EZ6EPF_OAgHb0uznaIhopiVYb_AKUKuC4no,3120
|
37
|
-
risk_network-0.0.
|
38
|
-
risk_network-0.0.
|
39
|
-
risk_network-0.0.
|
40
|
-
risk_network-0.0.
|
41
|
-
risk_network-0.0.
|
37
|
+
risk_network-0.0.9b35.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
38
|
+
risk_network-0.0.9b35.dist-info/METADATA,sha256=0rVbcV_Dh2DepCIKj-AbFry3t8J1yPNLyY_Kluq141A,47627
|
39
|
+
risk_network-0.0.9b35.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
40
|
+
risk_network-0.0.9b35.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
41
|
+
risk_network-0.0.9b35.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|