risk-network 0.0.8b8__py3-none-any.whl → 0.0.8b10__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.8"
10
+ __version__ = "0.0.8-beta.10"
@@ -121,7 +121,7 @@ def trim_domains_and_top_annotations(
121
121
  ].transform(lambda x: (x.rank(pct=True) * 10).apply(np.ceil).astype(int))
122
122
  # Multiply 'words' column by normalized values
123
123
  top_annotations["words"] = top_annotations.apply(
124
- lambda row: " ".join([row["words"]] * row["normalized_value"]), axis=1
124
+ lambda row: " ".join([str(row["words"])] * row["normalized_value"]), axis=1
125
125
  )
126
126
 
127
127
  # Generate domain labels
risk/network/io.py CHANGED
@@ -13,6 +13,7 @@ import zipfile
13
13
  from xml.dom import minidom
14
14
 
15
15
  import networkx as nx
16
+ import numpy as np
16
17
  import pandas as pd
17
18
 
18
19
  from risk.network.geometry import assign_edge_lengths
@@ -490,7 +491,7 @@ class NetworkIO:
490
491
  if "x" not in attrs or "y" not in attrs:
491
492
  if (
492
493
  "pos" in attrs
493
- and isinstance(attrs["pos"], (tuple, list))
494
+ and isinstance(attrs["pos"], (list, tuple, np.ndarray))
494
495
  and len(attrs["pos"]) >= 2
495
496
  ):
496
497
  attrs["x"], attrs["y"] = attrs["pos"][
@@ -44,8 +44,8 @@ class Canvas:
44
44
  Args:
45
45
  title (str, optional): Title of the plot. Defaults to None.
46
46
  subtitle (str, optional): Subtitle of the plot. Defaults to None.
47
- title_fontsize (int, optional): Font size for the title. Defaults to 16.
48
- subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to 12.
47
+ title_fontsize (int, optional): Font size for the title. Defaults to 20.
48
+ subtitle_fontsize (int, optional): Font size for the subtitle. Defaults to 14.
49
49
  font (str, optional): Font family used for both title and subtitle. Defaults to "Arial".
50
50
  title_color (str, optional): Color of the title text. Defaults to "black".
51
51
  subtitle_color (str, optional): Color of the subtitle text. Defaults to "gray".
@@ -90,11 +90,14 @@ class Canvas:
90
90
 
91
91
  # Plot subtitle if provided
92
92
  if subtitle:
93
- # Calculate the subtitle's y position based on title's position and subtitle_offset
94
- subtitle_y_position = title_y - subtitle_offset
93
+ # Calculate the subtitle's y position based on the midpoint of the title and subtitle_offset
94
+ # Calculate the approximate height of the title in relative axis units
95
+ title_height = title_fontsize / fig.bbox.height
96
+ # Position the subtitle relative to the title's center (title_y - half the title height)
97
+ subtitle_y_position = title_y - (title_height / 2) - subtitle_offset
95
98
  self.ax.figure.text(
96
99
  0.5, # Ensure horizontal centering for subtitle
97
- subtitle_y_position,
100
+ subtitle_y_position, # Position subtitle based on the center of the title
98
101
  subtitle,
99
102
  ha="center",
100
103
  va="top",
@@ -8,6 +8,7 @@ from typing import List, Tuple, Union
8
8
  import matplotlib.pyplot as plt
9
9
  import numpy as np
10
10
 
11
+ from risk.log import params
11
12
  from risk.network.graph import NetworkGraph
12
13
  from risk.network.plot.canvas import Canvas
13
14
  from risk.network.plot.contour import Contour
@@ -30,6 +31,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
30
31
  figsize: Tuple = (10, 10),
31
32
  background_color: Union[str, List, Tuple, np.ndarray] = "white",
32
33
  background_alpha: Union[float, None] = 1.0,
34
+ pad: float = 0.3,
33
35
  ) -> None:
34
36
  """Initialize the NetworkPlotter with a NetworkGraph object and plotting parameters.
35
37
 
@@ -39,6 +41,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
39
41
  background_color (str, list, tuple, np.ndarray, optional): Background color of the plot. Defaults to "white".
40
42
  background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides
41
43
  any existing alpha values found in background_color. Defaults to 1.0.
44
+ pad (float, optional): Padding value to adjust the axis limits. Defaults to 0.3.
42
45
  """
43
46
  self.graph = graph
44
47
  # Initialize the plot with the specified parameters
@@ -47,6 +50,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
47
50
  figsize=figsize,
48
51
  background_color=background_color,
49
52
  background_alpha=background_alpha,
53
+ pad=pad,
50
54
  )
51
55
  super().__init__(graph=graph, ax=self.ax)
52
56
 
@@ -56,6 +60,7 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
56
60
  figsize: Tuple,
57
61
  background_color: Union[str, List, Tuple, np.ndarray],
58
62
  background_alpha: Union[float, None],
63
+ pad: float,
59
64
  ) -> plt.Axes:
60
65
  """Set up the plot with figure size and background color.
61
66
 
@@ -65,10 +70,19 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
65
70
  background_color (str): Background color of the plot.
66
71
  background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides any
67
72
  existing alpha values found in background_color.
73
+ pad (float, optional): Padding value to adjust the axis limits.
68
74
 
69
75
  Returns:
70
76
  plt.Axes: The axis object for the plot.
71
77
  """
78
+ # Log the plotter settings
79
+ params.log_plotter(
80
+ figsize=figsize,
81
+ background_color=background_color,
82
+ background_alpha=background_alpha,
83
+ pad=pad,
84
+ )
85
+
72
86
  # Extract node coordinates from the network graph
73
87
  node_coordinates = graph.node_coordinates
74
88
  # Calculate the center and radius of the bounding box around the network
@@ -78,8 +92,8 @@ class NetworkPlotter(Canvas, Network, Contour, Labels):
78
92
  fig, ax = plt.subplots(figsize=figsize)
79
93
  fig.tight_layout() # Adjust subplot parameters to give specified padding
80
94
  # Set axis limits based on the calculated bounding box and radius
81
- ax.set_xlim([center[0] - radius - 0.3, center[0] + radius + 0.3])
82
- ax.set_ylim([center[1] - radius - 0.3, center[1] + radius + 0.3])
95
+ ax.set_xlim([center[0] - radius - pad, center[0] + radius + pad])
96
+ ax.set_ylim([center[1] - radius - pad, center[1] + radius + pad])
83
97
  ax.set_aspect("equal") # Ensure the aspect ratio is equal
84
98
 
85
99
  # Set the background color of the plot
risk/risk.py CHANGED
@@ -356,6 +356,7 @@ class RISK(NetworkIO, AnnotationsIO):
356
356
  figsize: Tuple = (10, 10),
357
357
  background_color: str = "white",
358
358
  background_alpha: Union[float, None] = 1.0,
359
+ pad: float = 0.3,
359
360
  ) -> NetworkPlotter:
360
361
  """Get a NetworkPlotter object for plotting.
361
362
 
@@ -365,16 +366,12 @@ class RISK(NetworkIO, AnnotationsIO):
365
366
  background_color (str, optional): Background color of the plot. Defaults to "white".
366
367
  background_alpha (float, None, optional): Transparency level of the background color. If provided, it overrides
367
368
  any existing alpha values found in background_color. Defaults to 1.0.
369
+ pad (float, optional): Padding value to adjust the axis limits. Defaults to 0.3.
368
370
 
369
371
  Returns:
370
372
  NetworkPlotter: A NetworkPlotter object configured with the given parameters.
371
373
  """
372
374
  log_header("Loading plotter")
373
- # Log the plotter settings
374
- params.log_plotter(
375
- figsize=figsize,
376
- background_color=background_color,
377
- )
378
375
 
379
376
  # Initialize and return a NetworkPlotter object
380
377
  return NetworkPlotter(
@@ -382,6 +379,7 @@ class RISK(NetworkIO, AnnotationsIO):
382
379
  figsize=figsize,
383
380
  background_color=background_color,
384
381
  background_alpha=background_alpha,
382
+ pad=pad,
385
383
  )
386
384
 
387
385
  def _load_neighborhoods(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.8b8
3
+ Version: 0.0.8b10
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
@@ -709,7 +709,7 @@ Requires-Dist: statsmodels
709
709
  Requires-Dist: threadpoolctl
710
710
  Requires-Dist: tqdm
711
711
 
712
- # RISK
712
+ # RISK Network
713
713
 
714
714
  <p align="center">
715
715
  <img src="https://i.imgur.com/8TleEJs.png" width="50%" />
@@ -728,8 +728,8 @@ Requires-Dist: tqdm
728
728
 
729
729
  ## Documentation and Tutorial
730
730
 
731
- - **Documentation**: Comprehensive documentation is available at [Documentation link].
732
- - **Tutorial**: An interactive Jupyter notebook tutorial can be found at [Tutorial link].
731
+ - **Documentation**: Comprehensive documentation is available [here](Documentation link).
732
+ - **Tutorial**: An interactive Jupyter notebook tutorial can be found [here](https://github.com/riskportal/network-tutorial).
733
733
  We highly recommend new users to consult the documentation and tutorial early on to fully leverage RISK's capabilities.
734
734
 
735
735
  ## Installation
@@ -753,7 +753,7 @@ pip install risk-network
753
753
 
754
754
  We applied RISK to a *Saccharomyces cerevisiae* protein–protein interaction network, revealing both established and novel functional relationships. The visualization below highlights key biological processes such as ribosomal assembly and mitochondrial organization.
755
755
 
756
- ![RISK Main Figure](https://i.imgur.com/TUVfvfH.jpeg)
756
+ ![RISK Main Figure](https://i.imgur.com/5OP3Hqe.jpeg)
757
757
 
758
758
  RISK successfully detected both known and novel functional clusters within the yeast interactome. Clusters related to Golgi transport and actin nucleation were clearly defined and closely located, showcasing RISK's ability to map well-characterized interactions. Additionally, RISK identified links between mRNA processing pathways and vesicle trafficking proteins, consistent with recent studies demonstrating the role of vesicles in mRNA localization and stability.
759
759
 
@@ -1,6 +1,6 @@
1
- risk/__init__.py,sha256=zab0gIovLi7w6nQZ6XkR7oUotDsAaBs5cqIptRVvABM,112
1
+ risk/__init__.py,sha256=g94euQClUjYvQpsJgeNIK5CSnh3r7a0yl_YD4_tYSz8,113
2
2
  risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
- risk/risk.py,sha256=uZH7GuADCAAkDIx-rPlS6O_is6tUU2Hg28P8xpR-d9g,21240
3
+ risk/risk.py,sha256=slJXca_a726_D7oXwe765HaKTv3ZrOvhttyrWdCGPkA,21231
4
4
  risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
5
5
  risk/annotations/annotations.py,sha256=ySc_N3nXnKx5RnOpFaEkM6zvTbswbrRcfFLzM0KdOck,11391
6
6
  risk/annotations/io.py,sha256=TTXVJQgUGAlKpnGBcx7Dow146IGyozA03nSbl3S7M5M,9475
@@ -9,18 +9,18 @@ risk/log/config.py,sha256=m8pzj-hN4vI_2JdJUfyOoSvzT8_lhoIfBt27sKbnOes,4535
9
9
  risk/log/params.py,sha256=DUmsqPo9hi3rQHFgLTunP14I-vVoyQSFZbx5aSYmVts,6363
10
10
  risk/neighborhoods/__init__.py,sha256=tKKEg4lsbqFukpgYlUGxU_v_9FOqK7V0uvM9T2QzoL0,206
11
11
  risk/neighborhoods/community.py,sha256=stYYBXeZlGLMV-k8ckQeIqThT6v9y-S3hETobAo9590,6817
12
- risk/neighborhoods/domains.py,sha256=Ov52EEr-tWqy96y8_0tJ9f1K8FI-8tZQxHR7a59A1k8,10738
12
+ risk/neighborhoods/domains.py,sha256=D5MUIghbwyKKCAE8PN_HXvsO9NxLTGejQmyEqetD1Bk,10743
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
16
  risk/network/graph.py,sha256=EwD4-1THC5YNdP6PY01Oe35k2QYYqtZpxWraPVH6wa4,16426
17
- risk/network/io.py,sha256=kY7HqmL3wa1NnqHu61_G8IpT21qpBijpAZ4ixmsseJA,22911
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=NQ5otHhPYWgXVbtpGjr-RUZwxpqEwvFjBu4JQ2H4vDI,9963
19
+ risk/network/plot/canvas.py,sha256=-Y2shCy4Udp-stB9tBXGZRTASQZiv8RVqVcQ5lBhVu0,10291
20
20
  risk/network/plot/contour.py,sha256=YPG8Uz0VlJ4skLdGaTH_FmQN6A_ArK8XSTNo1LzkSws,14276
21
21
  risk/network/plot/labels.py,sha256=o_V_eWQZB_otjXpw6aAwEPp1Uu-auQNcxQYpGBOL7uU,40777
22
22
  risk/network/plot/network.py,sha256=83ZXjGGrgRprWvDldWfhRe6SFXTv_QoI20OWzyEmVJU,12593
23
- risk/network/plot/plotter.py,sha256=h9BZ7GlLwtbb5m4AMa0gbyhQ7E-XQPS04yeDwoAU1Ao,5090
23
+ risk/network/plot/plotter.py,sha256=rQV4Db6Ud86FJm11uaBvgSuzpmGsrZxnsRnUKjg6w84,5572
24
24
  risk/network/plot/utils.py,sha256=jZgI8EysSjviQmdYAceZk2MwJXcdeFAkYp-odZNqV0k,6316
25
25
  risk/stats/__init__.py,sha256=WcgoETQ-hS0LQqKRsAMIPtP15xZ-4eul6VUBuUx4Wzc,220
26
26
  risk/stats/hypergeom.py,sha256=o6Qnj31gCAKxr2uQirXrbv7XvdDJGEq69MFW-ubx_hA,2272
@@ -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.8b8.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
33
- risk_network-0.0.8b8.dist-info/METADATA,sha256=IYS6QIFovmrWW7Y6N70ffAhp9PBXBP5b8JH6aBkLlrU,47450
34
- risk_network-0.0.8b8.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
35
- risk_network-0.0.8b8.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
36
- risk_network-0.0.8b8.dist-info/RECORD,,
32
+ risk_network-0.0.8b10.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
33
+ risk_network-0.0.8b10.dist-info/METADATA,sha256=JW-DI1zDrNww_zynk48_IEneCDYcEczfTGhhLU77hxY,47498
34
+ risk_network-0.0.8b10.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
35
+ risk_network-0.0.8b10.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
36
+ risk_network-0.0.8b10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.2.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5