risk-network 0.0.9b23__tar.gz → 0.0.9b25__tar.gz
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_network-0.0.9b23 → risk_network-0.0.9b25}/PKG-INFO +1 -1
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/__init__.py +1 -1
- risk_network-0.0.9b25/risk/annotations/__init__.py +7 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/annotations/annotations.py +9 -9
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/annotations/io.py +0 -2
- risk_network-0.0.9b25/risk/log/__init__.py +11 -0
- risk_network-0.0.9b25/risk/neighborhoods/__init__.py +8 -0
- risk_network-0.0.9b23/risk/risk.py → risk_network-0.0.9b25/risk/neighborhoods/api.py +226 -286
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/neighborhoods/community.py +4 -2
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/neighborhoods/domains.py +28 -1
- risk_network-0.0.9b25/risk/network/__init__.py +6 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/network/graph/__init__.py +1 -1
- risk_network-0.0.9b25/risk/network/graph/api.py +194 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/network/graph/summary.py +6 -2
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/network/io.py +0 -2
- risk_network-0.0.9b25/risk/network/plotter/__init__.py +6 -0
- risk_network-0.0.9b25/risk/network/plotter/api.py +54 -0
- {risk_network-0.0.9b23/risk/network/plot → risk_network-0.0.9b25/risk/network/plotter}/canvas.py +3 -3
- {risk_network-0.0.9b23/risk/network/plot → risk_network-0.0.9b25/risk/network/plotter}/contour.py +2 -2
- {risk_network-0.0.9b23/risk/network/plot → risk_network-0.0.9b25/risk/network/plotter}/labels.py +3 -3
- {risk_network-0.0.9b23/risk/network/plot → risk_network-0.0.9b25/risk/network/plotter}/network.py +136 -3
- {risk_network-0.0.9b23/risk/network/plot → risk_network-0.0.9b25/risk/network/plotter}/utils/colors.py +15 -6
- risk_network-0.0.9b25/risk/risk.py +33 -0
- risk_network-0.0.9b25/risk/stats/__init__.py +13 -0
- risk_network-0.0.9b25/risk/stats/binom.py +51 -0
- risk_network-0.0.9b25/risk/stats/chi2.py +69 -0
- risk_network-0.0.9b25/risk/stats/hypergeom.py +64 -0
- risk_network-0.0.9b25/risk/stats/permutation/__init__.py +6 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/stats/permutation/permutation.py +44 -55
- risk_network-0.0.9b25/risk/stats/permutation/test_functions.py +69 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/stats/poisson.py +15 -9
- risk_network-0.0.9b25/risk/stats/zscore.py +68 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk_network.egg-info/PKG-INFO +1 -1
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk_network.egg-info/SOURCES.txt +13 -8
- risk_network-0.0.9b23/risk/annotations/__init__.py +0 -7
- risk_network-0.0.9b23/risk/log/__init__.py +0 -11
- risk_network-0.0.9b23/risk/neighborhoods/__init__.py +0 -10
- risk_network-0.0.9b23/risk/network/__init__.py +0 -8
- risk_network-0.0.9b23/risk/network/plot/__init__.py +0 -6
- risk_network-0.0.9b23/risk/network/plot/plotter.py +0 -143
- risk_network-0.0.9b23/risk/stats/__init__.py +0 -9
- risk_network-0.0.9b23/risk/stats/hypergeom.py +0 -54
- risk_network-0.0.9b23/risk/stats/permutation/__init__.py +0 -6
- risk_network-0.0.9b23/risk/stats/permutation/test_functions.py +0 -61
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/LICENSE +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/MANIFEST.in +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/README.md +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/pyproject.toml +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/constants.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/log/console.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/log/parameters.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/neighborhoods/neighborhoods.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/network/geometry.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/network/graph/network.py +0 -0
- {risk_network-0.0.9b23/risk/network/plot → risk_network-0.0.9b25/risk/network/plotter}/utils/layout.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk/stats/stats.py +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk_network.egg-info/dependency_links.txt +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk_network.egg-info/requires.txt +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/risk_network.egg-info/top_level.txt +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/setup.cfg +0 -0
- {risk_network-0.0.9b23 → risk_network-0.0.9b25}/setup.py +0 -0
@@ -16,6 +16,7 @@ from nltk.tokenize import word_tokenize
|
|
16
16
|
from nltk.corpus import stopwords
|
17
17
|
|
18
18
|
from risk.log import logger
|
19
|
+
from scipy.sparse import csr_matrix
|
19
20
|
|
20
21
|
|
21
22
|
def _setup_nltk():
|
@@ -47,17 +48,15 @@ def load_annotations(
|
|
47
48
|
annotations_input (Dict[str, Any]): A dictionary with annotations.
|
48
49
|
min_nodes_per_term (int, optional): The minimum number of network nodes required for each annotation
|
49
50
|
term to be included. Defaults to 2.
|
51
|
+
use_sparse (bool, optional): Whether to return the annotations matrix as a sparse matrix. Defaults to True.
|
50
52
|
|
51
53
|
Returns:
|
52
|
-
Dict[str, Any]: A dictionary containing ordered nodes, ordered annotations, and the binary annotations
|
54
|
+
Dict[str, Any]: A dictionary containing ordered nodes, ordered annotations, and the sparse binary annotations
|
55
|
+
matrix.
|
53
56
|
|
54
57
|
Raises:
|
55
58
|
ValueError: If no annotations are found for the nodes in the network.
|
56
59
|
ValueError: If no annotations have at least min_nodes_per_term nodes in the network.
|
57
|
-
|
58
|
-
Comment:
|
59
|
-
This function should be optimized to handle large networks and annotations efficiently. An attempt
|
60
|
-
to use sparse matrices did not yield significant performance improvements, so it was not implemented.
|
61
60
|
"""
|
62
61
|
# Flatten the dictionary to a list of tuples for easier DataFrame creation
|
63
62
|
flattened_annotations = [
|
@@ -78,7 +77,6 @@ def load_annotations(
|
|
78
77
|
raise ValueError("No terms found in the annotation file for the nodes in the network.")
|
79
78
|
|
80
79
|
# Filter out annotations with fewer than min_nodes_per_term occurrences
|
81
|
-
# This assists in reducing noise and focusing on more relevant annotations for statistical analysis
|
82
80
|
num_terms_before_filtering = annotations_pivot.shape[1]
|
83
81
|
annotations_pivot = annotations_pivot.loc[
|
84
82
|
:, (annotations_pivot.sum(axis=0) >= min_nodes_per_term)
|
@@ -96,13 +94,15 @@ def load_annotations(
|
|
96
94
|
# Extract ordered nodes and annotations
|
97
95
|
ordered_nodes = tuple(annotations_pivot.index)
|
98
96
|
ordered_annotations = tuple(annotations_pivot.columns)
|
99
|
-
# Convert the annotations_pivot matrix to a numpy array
|
100
|
-
|
97
|
+
# Convert the annotations_pivot matrix to a numpy array or sparse matrix
|
98
|
+
annotations_pivot_binary = (annotations_pivot.fillna(0).to_numpy() > 0).astype(int)
|
99
|
+
# Convert the binary annotations matrix to a sparse matrix
|
100
|
+
annotations_pivot_binary = csr_matrix(annotations_pivot_binary)
|
101
101
|
|
102
102
|
return {
|
103
103
|
"ordered_nodes": ordered_nodes,
|
104
104
|
"ordered_annotations": ordered_annotations,
|
105
|
-
"matrix":
|
105
|
+
"matrix": annotations_pivot_binary,
|
106
106
|
}
|
107
107
|
|
108
108
|
|