risk-network 0.0.8b8__py3-none-any.whl → 0.0.8b9__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.9"
@@ -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.8b9
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,6 +1,6 @@
1
- risk/__init__.py,sha256=zab0gIovLi7w6nQZ6XkR7oUotDsAaBs5cqIptRVvABM,112
1
+ risk/__init__.py,sha256=ZdYPjV9cVMzz6tSQJbYp9MnzLO53YJLS50zbeWZ1SSI,112
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
@@ -16,11 +16,11 @@ risk/network/geometry.py,sha256=H1yGVVqgbfpzBzJwEheDLfvGLSA284jGQQTn612L4Vc,6759
16
16
  risk/network/graph.py,sha256=EwD4-1THC5YNdP6PY01Oe35k2QYYqtZpxWraPVH6wa4,16426
17
17
  risk/network/io.py,sha256=kY7HqmL3wa1NnqHu61_G8IpT21qpBijpAZ4ixmsseJA,22911
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.8b9.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
33
+ risk_network-0.0.8b9.dist-info/METADATA,sha256=Sq_d-xGJT_RHwo6lxwl0s9ydoIeNTRW-1vrG1V-NknA,47450
34
+ risk_network-0.0.8b9.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
35
+ risk_network-0.0.8b9.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
36
+ risk_network-0.0.8b9.dist-info/RECORD,,