risk-network 0.0.5b6__py3-none-any.whl → 0.0.6b0__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.5-beta.6"
10
+ __version__ = "0.0.6-beta.0"
risk/network/io.py CHANGED
@@ -418,29 +418,37 @@ class NetworkIO:
418
418
  return G
419
419
 
420
420
  def _remove_invalid_graph_properties(self, G: nx.Graph) -> None:
421
- """Remove invalid properties from the graph.
421
+ """Remove invalid properties from the graph, including self-loops, nodes with fewer edges than
422
+ the threshold, and isolated nodes.
422
423
 
423
424
  Args:
424
425
  G (nx.Graph): A NetworkX graph object.
425
426
  """
426
- # First, Remove self-loop edges to ensure correct edge count
427
+ # Count number of nodes and edges before cleaning
428
+ num_initial_nodes = G.number_of_nodes()
429
+ num_initial_edges = G.number_of_edges()
430
+ # Remove self-loops to ensure correct edge count
427
431
  G.remove_edges_from(list(nx.selfloop_edges(G)))
428
- # Then, iteratively remove nodes with fewer edges than the specified threshold
432
+ # Iteratively remove nodes with fewer edges than the threshold
429
433
  while True:
430
- nodes_to_remove = [
431
- node for node in G.nodes() if G.degree(node) < self.min_edges_per_node
432
- ]
434
+ nodes_to_remove = [node for node in G.nodes if G.degree(node) < self.min_edges_per_node]
433
435
  if not nodes_to_remove:
434
- break # Exit loop if no more nodes to remove
435
-
436
- # Remove the nodes and their associated edges
436
+ break # Exit loop if no more nodes need removal
437
437
  G.remove_nodes_from(nodes_to_remove)
438
438
 
439
- # Optionally: Remove any isolated nodes if needed
439
+ # Remove isolated nodes
440
440
  isolated_nodes = list(nx.isolates(G))
441
441
  if isolated_nodes:
442
442
  G.remove_nodes_from(isolated_nodes)
443
443
 
444
+ # Log the number of nodes and edges before and after cleaning
445
+ num_final_nodes = G.number_of_nodes()
446
+ num_final_edges = G.number_of_edges()
447
+ print(f"Initial node count: {num_initial_nodes}")
448
+ print(f"Final node count: {num_final_nodes}")
449
+ print(f"Initial edge count: {num_initial_edges}")
450
+ print(f"Final edge count: {num_final_edges}")
451
+
444
452
  def _assign_edge_weights(self, G: nx.Graph) -> None:
445
453
  """Assign weights to the edges in the graph.
446
454
 
@@ -502,6 +510,7 @@ class NetworkIO:
502
510
  print(f"Edge weight: {'Included' if self.include_edge_weight else 'Excluded'}")
503
511
  if self.include_edge_weight:
504
512
  print(f"Weight label: {self.weight_label}")
513
+ print(f"Minimum edges per node: {self.min_edges_per_node}")
505
514
  print(f"Projection: {'Sphere' if self.compute_sphere else 'Plane'}")
506
515
  if self.compute_sphere:
507
516
  print(f"Surface depth: {self.surface_depth}")
risk/network/plot.py CHANGED
@@ -630,12 +630,16 @@ class NetworkPlotter:
630
630
  return domain_central_node
631
631
 
632
632
  def get_annotated_node_colors(
633
- self, nonenriched_color: str = "white", random_seed: int = 888, **kwargs
633
+ self,
634
+ nonenriched_color: Union[str, List, Tuple, np.ndarray] = "white",
635
+ random_seed: int = 888,
636
+ **kwargs,
634
637
  ) -> np.ndarray:
635
638
  """Adjust the colors of nodes in the network graph based on enrichment.
636
639
 
637
640
  Args:
638
- nonenriched_color (str, optional): Color for non-enriched nodes. Defaults to "white".
641
+ nonenriched_color (str, list, tuple, or np.ndarray, optional): Color for non-enriched nodes.
642
+ Defaults to "white". If an alpha channel is provided, it will be used to darken the RGB values.
639
643
  random_seed (int, optional): Seed for random number generation. Defaults to 888.
640
644
  **kwargs: Additional keyword arguments for `get_domain_colors`.
641
645
 
@@ -648,12 +652,23 @@ class NetworkPlotter:
648
652
  # Convert the non-enriched color from string to RGBA
649
653
  nonenriched_color = mcolors.to_rgba(nonenriched_color)
650
654
 
655
+ # Ensure nonenriched_color is a NumPy array
656
+ nonenriched_color = np.array(nonenriched_color)
657
+ # If alpha is provided (4th value), darken the RGB values based on alpha
658
+ if len(nonenriched_color) == 4 and nonenriched_color[3] < 1.0:
659
+ alpha = nonenriched_color[3]
660
+ # Adjust RGB based on alpha (darken)
661
+ nonenriched_color[:3] = nonenriched_color[:3] * alpha
662
+ # Set alpha to 1.0 after darkening the color
663
+ nonenriched_color[3] = 1.0
664
+
651
665
  # Adjust node colors: replace any fully transparent nodes (enriched) with the non-enriched color
652
666
  adjusted_network_colors = np.where(
653
- np.all(network_colors == 0, axis=1, keepdims=True),
654
- np.array([nonenriched_color]),
655
- network_colors,
667
+ np.all(network_colors[:, :3] == 0, axis=1, keepdims=True), # Check RGB values only
668
+ np.array([nonenriched_color]), # Apply the non-enriched color (with adjusted alpha)
669
+ network_colors, # Keep the original colors
656
670
  )
671
+
657
672
  return adjusted_network_colors
658
673
 
659
674
  def get_annotated_node_sizes(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.5b6
3
+ Version: 0.0.6b0
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
@@ -710,8 +710,7 @@ Requires-Dist: threadpoolctl
710
710
  Requires-Dist: tqdm
711
711
 
712
712
  <p align="center">
713
- <img src="./docs/github/risk-logo-dark.png#gh-dark-mode-only" width="400" />
714
- <img src="./docs/github/risk-logo-light.png#gh-light-mode-only" width="400" />
713
+ <img src="https://i.imgur.com/Fo9EmnK.png" width="400" />
715
714
  </p>
716
715
 
717
716
  <p align="center">
@@ -736,7 +735,7 @@ RISK is a software tool for visualizing spatial relationships in networks. It ai
736
735
 
737
736
  *Saccharomyces cerevisiae* proteins oriented by physical interactions discovered through affinity enrichment and mass spectrometry (Michaelis et al., 2023).
738
737
 
739
- ![PPI Network Demo](./docs/github/network.png)
738
+ ![PPI Network Demo](https://i.imgur.com/NnyK6nO.png)
740
739
 
741
740
  ## Installation
742
741
 
@@ -1,4 +1,4 @@
1
- risk/__init__.py,sha256=UDR_mfSH0Yt17WiBlUHBj2-WkPQBIs6qKklXCo37n74,112
1
+ risk/__init__.py,sha256=IF4pnbb0hT2Ku49jwIG1EpkhgqUxp5qnolYAmF2ujds,112
2
2
  risk/constants.py,sha256=XInRaH78Slnw_sWgAsBFbUHkyA0h0jL0DKGuQNbOvjM,550
3
3
  risk/risk.py,sha256=UYM_Pf2Db-lbf4O5T2v5zKutz_GLXK-f43PgYT6xRyY,21328
4
4
  risk/annotations/__init__.py,sha256=vUpVvMRE5if01Ic8QY6M2Ae3EFGJHdugEe9PdEkAW4Y,138
@@ -14,8 +14,8 @@ risk/neighborhoods/neighborhoods.py,sha256=SqYJaT49rUj77ts0XsPXb9cURM11aGh2Teks0
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=DTjNRQwgQbt6jJYDBHm7sgrdbZUDLL4HiZpdixkSI7Y,12433
17
- risk/network/io.py,sha256=otiRG6uT6HLgbbJql7X2wjYxab8OFJSgRoWJlcDoyu4,20291
18
- risk/network/plot.py,sha256=XB-fH67SqIm3bonFj_UvbO85725Zp1z0Ug6LblDEUYo,41062
17
+ risk/network/io.py,sha256=8oncBfUaE-uDqWOr4OOWhR3ouhuOOzhnGlTUVxst3hs,20851
18
+ risk/network/plot.py,sha256=SXbHSBPNzrRw0m9xoENyRSgR6qHm2YoWMQat3PrFkI8,41866
19
19
  risk/stats/__init__.py,sha256=e-BE_Dr_jgiK6hKM-T-tlG4yvHnId8e5qjnM0pdwNVc,230
20
20
  risk/stats/fisher_exact.py,sha256=-bPwzu76-ob0HzrTV20mXUTot7v-MLuqFaAoab-QxPg,4966
21
21
  risk/stats/hypergeom.py,sha256=lrIFdhCWRjvM4apYw1MlOKqT_IY5OjtCwrjdtJdt6Tg,4954
@@ -23,8 +23,8 @@ risk/stats/stats.py,sha256=kvShov-94W6ffgDUTb522vB9hDJQSyTsYif_UIaFfSM,7059
23
23
  risk/stats/permutation/__init__.py,sha256=neJp7FENC-zg_CGOXqv-iIvz1r5XUKI9Ruxhmq7kDOI,105
24
24
  risk/stats/permutation/permutation.py,sha256=qLWdwxEY6nmkYPxpM8HLDcd2mbqYv9Qr7CKtJvhLqIM,9220
25
25
  risk/stats/permutation/test_functions.py,sha256=HuDIM-V1jkkfE1rlaIqrWWBSKZt3dQ1f-YEDjWpnLSE,2343
26
- risk_network-0.0.5b6.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
27
- risk_network-0.0.5b6.dist-info/METADATA,sha256=QbGxhcKULWkZ064qoWmSI43caZIrvaXostHJqCnezwc,43236
28
- risk_network-0.0.5b6.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
29
- risk_network-0.0.5b6.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
30
- risk_network-0.0.5b6.dist-info/RECORD,,
26
+ risk_network-0.0.6b0.dist-info/LICENSE,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
27
+ risk_network-0.0.6b0.dist-info/METADATA,sha256=TWOChIBPVrDKpp8wPEoCXayEWSp8M3uwdSQQw18rdMQ,43142
28
+ risk_network-0.0.6b0.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
29
+ risk_network-0.0.6b0.dist-info/top_level.txt,sha256=NX7C2PFKTvC1JhVKv14DFlFAIFnKc6Lpsu1ZfxvQwVw,5
30
+ risk_network-0.0.6b0.dist-info/RECORD,,