risk-network 0.0.8b11__py3-none-any.whl → 0.0.8b12__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 CHANGED
@@ -7,4 +7,4 @@ RISK: RISK Infers Spatial Kinships
7
7
 
8
8
  from risk.risk import RISK
9
9
 
10
- __version__ = "0.0.8-beta.11"
10
+ __version__ = "0.0.8-beta.12"
@@ -186,9 +186,7 @@ def get_description(words_column: pd.Series) -> str:
186
186
 
187
187
  # Ensure that all values in 'words' are strings and include both alphabetic and numeric tokens
188
188
  words = [
189
- str(
190
- word.lower() if word.istitle() else word
191
- ) # Convert to string and lowercase all words except proper nouns (e.g., RNA, mRNA)
189
+ str(word) # Convert to string to ensure consistent processing
192
190
  for word in tokens
193
191
  if word.isalpha()
194
192
  or word.replace(".", "", 1).isdigit() # Keep alphabetic words and numeric strings
risk/network/graph.py CHANGED
@@ -216,9 +216,17 @@ def _transform_colors(
216
216
  Returns:
217
217
  np.ndarray: The transformed array of RGBA colors with adjusted intensities.
218
218
  """
219
+ # Ensure that min_scale is less than max_scale
219
220
  if min_scale == max_scale:
220
221
  min_scale = max_scale - 10e-6 # Avoid division by zero
221
222
 
223
+ # Replace black colors (#000000) with very dark grey (#1A1A1A)
224
+ black_color = np.array([0.0, 0.0, 0.0]) # Pure black RGB
225
+ dark_grey = np.array([0.1, 0.1, 0.1]) # Very dark grey RGB (#1A1A1A)
226
+ # Check where colors are black (very close to [0, 0, 0]) and replace with dark grey
227
+ is_black = np.all(colors[:, :3] == black_color, axis=1)
228
+ colors[is_black, :3] = dark_grey
229
+
222
230
  # Normalize the enrichment sums to the range [0, 1]
223
231
  normalized_sums = enrichment_sums / np.max(enrichment_sums)
224
232
  # Apply power scaling to dim lower values and emphasize higher values
@@ -208,8 +208,8 @@ class Canvas:
208
208
  perimeter_fill_alpha=fill_alpha,
209
209
  )
210
210
 
211
- # Convert color to RGBA using the to_rgba helper function - use outline_alpha for the perimeter
212
- color = to_rgba(color=color, alpha=outline_alpha)
211
+ # Convert color to RGBA using outline_alpha for the line (outline)
212
+ outline_color = to_rgba(color=color)
213
213
  # Extract node coordinates from the network graph
214
214
  node_coordinates = self.graph.node_coordinates
215
215
  # Scale the node coordinates if needed
@@ -222,8 +222,9 @@ class Canvas:
222
222
  levels=levels,
223
223
  bandwidth=bandwidth,
224
224
  grid_size=grid_size,
225
- color=color,
225
+ color=outline_color,
226
226
  linestyle=linestyle,
227
227
  linewidth=linewidth,
228
- alpha=fill_alpha,
228
+ alpha=outline_alpha,
229
+ fill_alpha=fill_alpha,
229
230
  )
@@ -34,6 +34,7 @@ class Labels:
34
34
  scale: float = 1.05,
35
35
  offset: float = 0.10,
36
36
  font: str = "Arial",
37
+ fontcase: Union[str, None] = None,
37
38
  fontsize: int = 10,
38
39
  fontcolor: Union[str, List, Tuple, np.ndarray] = "black",
39
40
  fontalpha: Union[float, None] = 1.0,
@@ -59,6 +60,8 @@ class Labels:
59
60
  scale (float, optional): Scale factor for positioning labels around the perimeter. Defaults to 1.05.
60
61
  offset (float, optional): Offset distance for labels from the perimeter. Defaults to 0.10.
61
62
  font (str, optional): Font name for the labels. Defaults to "Arial".
63
+ fontcase (str, None, optional): Case transformation for the labels. Can be "capitalize", "lower", "title",
64
+ "upper", or None. Defaults to None.
62
65
  fontsize (int, optional): Font size for the labels. Defaults to 10.
63
66
  fontcolor (str, list, tuple, or np.ndarray, optional): Color of the label text. Can be a string or RGBA array.
64
67
  Defaults to "black".
@@ -92,6 +95,7 @@ class Labels:
92
95
  label_perimeter_scale=scale,
93
96
  label_offset=offset,
94
97
  label_font=font,
98
+ label_fontcase=fontcase,
95
99
  label_fontsize=fontsize,
96
100
  label_fontcolor=(
97
101
  "custom" if isinstance(fontcolor, np.ndarray) else fontcolor
@@ -198,6 +202,8 @@ class Labels:
198
202
  centroid = filtered_domain_centroids[domain]
199
203
  # Split by special key TERM_DELIMITER to split annotation into multiple lines
200
204
  annotations = filtered_domain_terms[domain].split(TERM_DELIMITER)
205
+ if fontcase is not None:
206
+ annotations = _apply_str_transformation(words=annotations, transformation=fontcase)
201
207
  self.ax.annotate(
202
208
  "\n".join(annotations),
203
209
  xy=centroid,
@@ -847,3 +853,25 @@ def _swap_and_evaluate(
847
853
  )
848
854
  # Calculate and return the total distance after the swap
849
855
  return _calculate_total_distance(swapped_positions, domain_centroids)
856
+
857
+
858
+ def _apply_str_transformation(words: List[str], transformation: str) -> List[str]:
859
+ """Apply a user-specified case transformation to each word in the list without appending duplicates.
860
+
861
+ Args:
862
+ words (List[str]): A list of words to transform.
863
+ transformation (str): The case transformation to apply (e.g., 'lower', 'upper', 'title', 'capitalize').
864
+
865
+ Returns:
866
+ List[str]: A list of transformed words with no duplicates.
867
+ """
868
+ transformed_words = []
869
+ for word in words:
870
+ if hasattr(word, transformation):
871
+ transformed_word = getattr(word, transformation)() # Apply the string method
872
+
873
+ # Only append if the transformed word is not already in the list
874
+ if transformed_word not in transformed_words:
875
+ transformed_words.append(transformed_word)
876
+
877
+ return transformed_words
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.8b11
3
+ Version: 0.0.8b12
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
@@ -1,8 +1,8 @@
1
- risk/__init__.py,sha256=ZJtZA9wcK29HLGsFPkNjrQgiIa3Le1AHM1yAgOa77WA,113
1
+ risk/__init__.py,sha256=likYFfZ5PmIhnkglQu8_zeaHGOBKURKzUUbrBCBZY8o,113
2
2
  risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
3
  risk/risk.py,sha256=slJXca_a726_D7oXwe765HaKTv3ZrOvhttyrWdCGPkA,21231
4
4
  risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
5
- risk/annotations/annotations.py,sha256=ySc_N3nXnKx5RnOpFaEkM6zvTbswbrRcfFLzM0KdOck,11391
5
+ risk/annotations/annotations.py,sha256=7ilzXxrlHqN75J3q8WeHz0n79D-jAtUQx5czvC9wfIM,11303
6
6
  risk/annotations/io.py,sha256=TTXVJQgUGAlKpnGBcx7Dow146IGyozA03nSbl3S7M5M,9475
7
7
  risk/log/__init__.py,sha256=aDUz5LMFQsz0UlsQI2EdXtiBKRLfml1UMeZKC7QQIGU,134
8
8
  risk/log/config.py,sha256=m8pzj-hN4vI_2JdJUfyOoSvzT8_lhoIfBt27sKbnOes,4535
@@ -13,12 +13,12 @@ risk/neighborhoods/domains.py,sha256=D5MUIghbwyKKCAE8PN_HXvsO9NxLTGejQmyEqetD1Bk
13
13
  risk/neighborhoods/neighborhoods.py,sha256=M-wL4xB_BUTlSZg90swygO5NdrZ6hFUFqs6jsiZaqHk,18260
14
14
  risk/network/__init__.py,sha256=iEPeJdZfqp0toxtbElryB8jbz9_t_k4QQ3iDvKE8C_0,126
15
15
  risk/network/geometry.py,sha256=H1yGVVqgbfpzBzJwEheDLfvGLSA284jGQQTn612L4Vc,6759
16
- risk/network/graph.py,sha256=EwD4-1THC5YNdP6PY01Oe35k2QYYqtZpxWraPVH6wa4,16426
16
+ risk/network/graph.py,sha256=yuWqXG4p3Pmad_7dHcPweLgOd8t4LoeP9uQQ-ZZEdAY,16866
17
17
  risk/network/io.py,sha256=u0PPcKjp6Xze--7eDOlvalYkjQ9S2sjiC-ac2476PUI,22942
18
18
  risk/network/plot/__init__.py,sha256=MfmaXJgAZJgXZ2wrhK8pXwzETlcMaLChhWXKAozniAo,98
19
- risk/network/plot/canvas.py,sha256=-Y2shCy4Udp-stB9tBXGZRTASQZiv8RVqVcQ5lBhVu0,10291
19
+ risk/network/plot/canvas.py,sha256=LXHndwanWIBShChoPag8zgGHF2P9MFWYdEnLKc2eeb0,10295
20
20
  risk/network/plot/contour.py,sha256=YPG8Uz0VlJ4skLdGaTH_FmQN6A_ArK8XSTNo1LzkSws,14276
21
- risk/network/plot/labels.py,sha256=MXUo5F5H1ynzEBkrh5XKE-COLuZ-4LhSxiUvkXSZKYQ,40810
21
+ risk/network/plot/labels.py,sha256=PV21hig6gQJZRgfUAP9-zpn4wEmQFEjS2_X63SgzWMs,42064
22
22
  risk/network/plot/network.py,sha256=83ZXjGGrgRprWvDldWfhRe6SFXTv_QoI20OWzyEmVJU,12593
23
23
  risk/network/plot/plotter.py,sha256=rQV4Db6Ud86FJm11uaBvgSuzpmGsrZxnsRnUKjg6w84,5572
24
24
  risk/network/plot/utils.py,sha256=jZgI8EysSjviQmdYAceZk2MwJXcdeFAkYp-odZNqV0k,6316
@@ -29,8 +29,8 @@ risk/stats/stats.py,sha256=kvShov-94W6ffgDUTb522vB9hDJQSyTsYif_UIaFfSM,7059
29
29
  risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
30
30
  risk/stats/permutation/permutation.py,sha256=D84Rcpt6iTQniK0PfQGcw9bLcHbMt9p-ARcurUnIXZQ,10095
31
31
  risk/stats/permutation/test_functions.py,sha256=lftOude6hee0pyR80HlBD32522JkDoN5hrKQ9VEbuoY,2345
32
- risk_network-0.0.8b11.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
33
- risk_network-0.0.8b11.dist-info/METADATA,sha256=nlUZJH0fpHPUq9lgGvlNJY0Ibf5QBLYoQ6WB6dlGqNc,47498
34
- risk_network-0.0.8b11.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
35
- risk_network-0.0.8b11.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
36
- risk_network-0.0.8b11.dist-info/RECORD,,
32
+ risk_network-0.0.8b12.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
33
+ risk_network-0.0.8b12.dist-info/METADATA,sha256=-wKC6cGDbBGW7fG0wmdkxHRZKHvC5knHUYMqD0egagI,47498
34
+ risk_network-0.0.8b12.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
35
+ risk_network-0.0.8b12.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
36
+ risk_network-0.0.8b12.dist-info/RECORD,,