risk-network 0.0.16b0__py3-none-any.whl → 0.0.16b2__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 +2 -2
- risk/{_annotation → annotation}/__init__.py +2 -2
- risk/{_annotation → annotation}/_nltk_setup.py +3 -3
- risk/{_annotation/_annotation.py → annotation/annotation.py} +22 -25
- risk/{_annotation/_io.py → annotation/io.py} +4 -4
- risk/cluster/__init__.py +8 -0
- risk/{_neighborhoods → cluster}/_community.py +37 -37
- risk/cluster/api.py +273 -0
- risk/{_neighborhoods/_neighborhoods.py → cluster/cluster.py} +127 -98
- risk/{_neighborhoods/_domains.py → cluster/label.py} +18 -12
- risk/{_log → log}/__init__.py +2 -2
- risk/{_log/_console.py → log/console.py} +2 -2
- risk/{_log/_parameters.py → log/parameters.py} +20 -10
- risk/network/__init__.py +8 -0
- risk/network/graph/__init__.py +7 -0
- risk/{_network/_graph → network/graph}/_stats.py +2 -2
- risk/{_network/_graph → network/graph}/_summary.py +13 -13
- risk/{_network/_graph/_api.py → network/graph/api.py} +37 -39
- risk/{_network/_graph/_graph.py → network/graph/graph.py} +5 -5
- risk/{_network/_io.py → network/io.py} +9 -4
- risk/network/plotter/__init__.py +6 -0
- risk/{_network/_plotter → network/plotter}/_canvas.py +6 -6
- risk/{_network/_plotter → network/plotter}/_contour.py +4 -4
- risk/{_network/_plotter → network/plotter}/_labels.py +6 -6
- risk/{_network/_plotter → network/plotter}/_network.py +7 -7
- risk/{_network/_plotter → network/plotter}/_plotter.py +5 -5
- risk/network/plotter/_utils/__init__.py +7 -0
- risk/{_network/_plotter/_utils/_colors.py → network/plotter/_utils/colors.py} +3 -3
- risk/{_network/_plotter/_utils/_layout.py → network/plotter/_utils/layout.py} +2 -2
- risk/{_network/_plotter/_api.py → network/plotter/api.py} +5 -5
- risk/{_risk.py → risk.py} +9 -8
- risk/stats/__init__.py +6 -0
- risk/stats/_stats/__init__.py +11 -0
- risk/stats/_stats/permutation/__init__.py +6 -0
- risk/stats/_stats/permutation/_test_functions.py +72 -0
- risk/{_neighborhoods/_stats/_permutation/_permutation.py → stats/_stats/permutation/permutation.py} +35 -37
- risk/{_neighborhoods/_stats/_tests.py → stats/_stats/tests.py} +32 -34
- risk/stats/api.py +202 -0
- {risk_network-0.0.16b0.dist-info → risk_network-0.0.16b2.dist-info}/METADATA +2 -2
- risk_network-0.0.16b2.dist-info/RECORD +43 -0
- risk/_neighborhoods/__init__.py +0 -8
- risk/_neighborhoods/_api.py +0 -354
- risk/_neighborhoods/_stats/__init__.py +0 -11
- risk/_neighborhoods/_stats/_permutation/__init__.py +0 -6
- risk/_neighborhoods/_stats/_permutation/_test_functions.py +0 -72
- risk/_network/__init__.py +0 -8
- risk/_network/_graph/__init__.py +0 -7
- risk/_network/_plotter/__init__.py +0 -6
- risk/_network/_plotter/_utils/__init__.py +0 -7
- risk_network-0.0.16b0.dist-info/RECORD +0 -41
- {risk_network-0.0.16b0.dist-info → risk_network-0.0.16b2.dist-info}/WHEEL +0 -0
- {risk_network-0.0.16b0.dist-info → risk_network-0.0.16b2.dist-info}/licenses/LICENSE +0 -0
- {risk_network-0.0.16b0.dist-info → risk_network-0.0.16b2.dist-info}/top_level.txt +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
risk/_neighborhoods/_stats/_permutation/_test_functions
|
|
3
|
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
4
|
-
"""
|
|
5
|
-
|
|
6
|
-
import numpy as np
|
|
7
|
-
from scipy.sparse import csr_matrix
|
|
8
|
-
|
|
9
|
-
# NOTE: Cython optimizations provided minimal performance benefits.
|
|
10
|
-
# The final version with Cython is archived in the `cython_permutation` branch.
|
|
11
|
-
|
|
12
|
-
# DISPATCH_TEST_FUNCTIONS can be found at the end of the file.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def compute_neighborhood_score_by_sum(
|
|
16
|
-
neighborhoods_matrix: csr_matrix, annotation_matrix: csr_matrix
|
|
17
|
-
) -> np.ndarray:
|
|
18
|
-
"""
|
|
19
|
-
Compute the sum of attribute values for each neighborhood using sparse matrices.
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
neighborhoods_matrix (csr_matrix): Sparse binary matrix representing neighborhoods.
|
|
23
|
-
annotation_matrix (csr_matrix): Sparse matrix representing annotation values.
|
|
24
|
-
|
|
25
|
-
Returns:
|
|
26
|
-
np.ndarray: Dense array of summed attribute values for each neighborhood.
|
|
27
|
-
"""
|
|
28
|
-
# Calculate the neighborhood score as the dot product of neighborhoods and annotation
|
|
29
|
-
neighborhood_score = neighborhoods_matrix @ annotation_matrix # Sparse matrix multiplication
|
|
30
|
-
# Convert the result to a dense array for downstream calculations
|
|
31
|
-
neighborhood_score_dense = neighborhood_score.toarray()
|
|
32
|
-
return neighborhood_score_dense
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def compute_neighborhood_score_by_stdev(
|
|
36
|
-
neighborhoods_matrix: csr_matrix, annotation_matrix: csr_matrix
|
|
37
|
-
) -> np.ndarray:
|
|
38
|
-
"""
|
|
39
|
-
Compute the standard deviation of neighborhood scores for sparse matrices.
|
|
40
|
-
|
|
41
|
-
Args:
|
|
42
|
-
neighborhoods_matrix (csr_matrix): Sparse binary matrix representing neighborhoods.
|
|
43
|
-
annotation_matrix (csr_matrix): Sparse matrix representing annotation values.
|
|
44
|
-
|
|
45
|
-
Returns:
|
|
46
|
-
np.ndarray: Standard deviation of the neighborhood scores.
|
|
47
|
-
"""
|
|
48
|
-
# Calculate the neighborhood score as the dot product of neighborhoods and annotation
|
|
49
|
-
neighborhood_score = neighborhoods_matrix @ annotation_matrix # Sparse matrix multiplication
|
|
50
|
-
# Calculate the number of elements in each neighborhood (sum of rows)
|
|
51
|
-
N = neighborhoods_matrix.sum(axis=1).A.flatten() # Convert to 1D array
|
|
52
|
-
# Avoid division by zero by replacing zeros in N with np.nan temporarily
|
|
53
|
-
N[N == 0] = np.nan
|
|
54
|
-
# Compute the mean of the neighborhood scores
|
|
55
|
-
M = neighborhood_score.multiply(1 / N[:, None]).toarray() # Sparse element-wise division
|
|
56
|
-
# Compute the mean of squares (EXX) directly using squared annotation matrix
|
|
57
|
-
annotation_squared = annotation_matrix.multiply(annotation_matrix) # Element-wise squaring
|
|
58
|
-
EXX = (neighborhoods_matrix @ annotation_squared).multiply(1 / N[:, None]).toarray()
|
|
59
|
-
# Calculate variance as EXX - M^2
|
|
60
|
-
variance = EXX - np.power(M, 2)
|
|
61
|
-
# Compute the standard deviation as the square root of the variance
|
|
62
|
-
neighborhood_stdev = np.sqrt(variance)
|
|
63
|
-
# Replace np.nan back with zeros in case N was 0 (no elements in the neighborhood)
|
|
64
|
-
neighborhood_stdev[np.isnan(neighborhood_stdev)] = 0
|
|
65
|
-
return neighborhood_stdev
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
# Dictionary to dispatch statistical test functions based on the score metric
|
|
69
|
-
DISPATCH_TEST_FUNCTIONS = {
|
|
70
|
-
"sum": compute_neighborhood_score_by_sum,
|
|
71
|
-
"stdev": compute_neighborhood_score_by_stdev,
|
|
72
|
-
}
|
risk/_network/__init__.py
DELETED
risk/_network/_graph/__init__.py
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
risk/__init__.py,sha256=knyE98-BvAZ9sTJDMZ1TNr73YaAC-gqL_0Q1rKvwAHU,143
|
|
2
|
-
risk/_risk.py,sha256=VULCdM41BlWKM1ou4Qc579ffZ9dMZkfhAwKYgbaEeKM,1054
|
|
3
|
-
risk/_annotation/__init__.py,sha256=zr7w1DHkmvrkKFGKdPhrcvZHV-xsfd5TZOaWtFiP4Dc,164
|
|
4
|
-
risk/_annotation/_annotation.py,sha256=psPRC7q4DjXIvpgmE3VLzHYElLarJTJhQpclesz2W0Q,15063
|
|
5
|
-
risk/_annotation/_io.py,sha256=xic3dkEA54X82HbyWfCiXrUpAhPWFPBZ69R8jw31omQ,12457
|
|
6
|
-
risk/_annotation/_nltk_setup.py,sha256=aHHnElLOKiouVDrZ3uON0CSFmBxvzmYfjYPi07v2rJM,3584
|
|
7
|
-
risk/_log/__init__.py,sha256=LX6BsfcGOH0RbAdQaUmIU-LVMmArDdKwn0jFtj45FYo,205
|
|
8
|
-
risk/_log/_console.py,sha256=1jSFzY3w0-vVqIBCgc-IhyJPNT6vRg8GSGxhyw_D9MI,4653
|
|
9
|
-
risk/_log/_parameters.py,sha256=8FkeeBtULDFVw3UijLArK-G3OIjy6YXyRXmPPckK7fU,5893
|
|
10
|
-
risk/_neighborhoods/__init__.py,sha256=eKwjpEUKSUmAirRZ_qPTVF7MLkvhCn_fulPVq158wM8,185
|
|
11
|
-
risk/_neighborhoods/_api.py,sha256=kwCJo8fW1v11fNlCZmC_2XH4TG2ZrIL2j2PvBJrlyj8,18236
|
|
12
|
-
risk/_neighborhoods/_community.py,sha256=Tr-EHO91EWbMmNr_z21UCngiqWOlWIqcjwBig_VXI8c,17850
|
|
13
|
-
risk/_neighborhoods/_domains.py,sha256=Q3MUWW9KjuERpxs4H1dNFhalDjdatMkWSnB12BerUDU,16580
|
|
14
|
-
risk/_neighborhoods/_neighborhoods.py,sha256=9hpQCYG0d9fZLYj-fVACgLJBtw3dW8C-0YbE2OWuX-M,21436
|
|
15
|
-
risk/_neighborhoods/_stats/__init__.py,sha256=iu22scpdgTHm6N_hAN81iXIoZCRPFuFAxf71jYWwsUU,213
|
|
16
|
-
risk/_neighborhoods/_stats/_tests.py,sha256=KWwNWyKJ3Rrb1cI5qJcKv9YhU1-7sJoI-yMR1RqvHOQ,7557
|
|
17
|
-
risk/_neighborhoods/_stats/_permutation/__init__.py,sha256=nfTaW29CK8OZCdFnpMVlHnFaqr1E4AZp6mvhlUazHXM,140
|
|
18
|
-
risk/_neighborhoods/_stats/_permutation/_permutation.py,sha256=e5qVuYWGhiAn5Jv8VILk-WYMOO4km48cGdRYTOl355M,10661
|
|
19
|
-
risk/_neighborhoods/_stats/_permutation/_test_functions.py,sha256=lGI_MkdbW4UHI0jWN_T1OattRjXrq_qmzAmOfels670,3165
|
|
20
|
-
risk/_network/__init__.py,sha256=YrAMfhL0CMWQb3sY-mn1VxK44zZAWeFAvHrBONH9I-A,127
|
|
21
|
-
risk/_network/_io.py,sha256=wmokwNViz24Gv6o3OFRTYHftYYz4sN64VigGrdEGzy8,28057
|
|
22
|
-
risk/_network/_graph/__init__.py,sha256=SFgxgxUiZK4vvw6bdQ04DSMXEr8xjMaQV-Wne6wAIqM,104
|
|
23
|
-
risk/_network/_graph/_api.py,sha256=sp3_mLJDP_xQexYBjyM17iyzLb2oGmiC050kcw-jVho,8474
|
|
24
|
-
risk/_network/_graph/_graph.py,sha256=x2EWT_ZVwxh7m9a01yG4WMdmAxBxiaxX3CvkqP9QAXE,12486
|
|
25
|
-
risk/_network/_graph/_stats.py,sha256=6mxZkuL6LJlwKDsBbP22DAVkNUEhq-JZwYMKhFKD08k,7359
|
|
26
|
-
risk/_network/_graph/_summary.py,sha256=RISQHy6Ur37e6F8ZM9X-IwNOit-hUiUxSCUZU_8-1Tw,10198
|
|
27
|
-
risk/_network/_plotter/__init__.py,sha256=qFRtQKSBGIqmUGwmA7VPL7hTHBb9yvRIt0nLISXnwkY,84
|
|
28
|
-
risk/_network/_plotter/_api.py,sha256=OaV1CCRGsz98wEEzyEhaq2CqEuZh6t2qS7g_rY6HJJs,1727
|
|
29
|
-
risk/_network/_plotter/_canvas.py,sha256=H7rPz4Gv7ED3bDHMif4cf2usdU4ifmxzXeug5A_no68,13599
|
|
30
|
-
risk/_network/_plotter/_contour.py,sha256=E3ILjlv-VBSbK3ClwObB84TvP1D48_B47ODXwtApjIE,15557
|
|
31
|
-
risk/_network/_plotter/_labels.py,sha256=8JXzEOIBQefwr1ngF-2ZYCnYLZXs2Erz-R1c28NnsL0,46915
|
|
32
|
-
risk/_network/_plotter/_network.py,sha256=W9eUUER9_qi1ubGaUfMp12gxAANZP-JNFKcG27I1nAk,14198
|
|
33
|
-
risk/_network/_plotter/_plotter.py,sha256=F2hw-spUdsXjvuG36o0YFR3Pnd-CZOHYUq4vW0Qxzlk,6011
|
|
34
|
-
risk/_network/_plotter/_utils/__init__.py,sha256=JXgjKiBWvXx0X2IeFnrOh5YZQGQoELbhJZ0Zh2mFEOo,211
|
|
35
|
-
risk/_network/_plotter/_utils/_colors.py,sha256=JCliSvz8_-TsjilaRHSEsqdXFBUYlzhXKOSRGdCm9Kw,19177
|
|
36
|
-
risk/_network/_plotter/_utils/_layout.py,sha256=GyGLc2U1WWUVL1Te9uPi_CLqlW_E4TImXRAL5TeA5D8,3633
|
|
37
|
-
risk_network-0.0.16b0.dist-info/licenses/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
38
|
-
risk_network-0.0.16b0.dist-info/METADATA,sha256=RyO3f1BZDQnREPp3my6tw6JI8Y4oFzY3gBDwEO10zL8,5390
|
|
39
|
-
risk_network-0.0.16b0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
40
|
-
risk_network-0.0.16b0.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
|
|
41
|
-
risk_network-0.0.16b0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|