risk-network 0.0.8b0__tar.gz → 0.0.8b1__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.
Files changed (37) hide show
  1. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/PKG-INFO +1 -1
  2. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/__init__.py +1 -1
  3. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/io.py +42 -6
  4. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/PKG-INFO +1 -1
  5. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/LICENSE +0 -0
  6. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/MANIFEST.in +0 -0
  7. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/README.md +0 -0
  8. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/pyproject.toml +0 -0
  9. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/annotations/__init__.py +0 -0
  10. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/annotations/annotations.py +0 -0
  11. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/annotations/io.py +0 -0
  12. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/constants.py +0 -0
  13. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/log/__init__.py +0 -0
  14. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/log/config.py +0 -0
  15. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/log/params.py +0 -0
  16. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/__init__.py +0 -0
  17. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/community.py +0 -0
  18. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/domains.py +0 -0
  19. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/neighborhoods/neighborhoods.py +0 -0
  20. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/__init__.py +0 -0
  21. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/geometry.py +0 -0
  22. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/graph.py +0 -0
  23. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/network/plot.py +0 -0
  24. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/risk.py +0 -0
  25. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/__init__.py +0 -0
  26. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/hypergeom.py +0 -0
  27. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/permutation/__init__.py +0 -0
  28. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/permutation/permutation.py +0 -0
  29. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/permutation/test_functions.py +0 -0
  30. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/poisson.py +0 -0
  31. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk/stats/stats.py +0 -0
  32. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/SOURCES.txt +0 -0
  33. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/dependency_links.txt +0 -0
  34. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/requires.txt +0 -0
  35. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/risk_network.egg-info/top_level.txt +0 -0
  36. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/setup.cfg +0 -0
  37. {risk_network-0.0.8b0 → risk_network-0.0.8b1}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.8b0
3
+ Version: 0.0.8b1
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
@@ -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.0"
10
+ __version__ = "0.0.8-beta.1"
@@ -153,8 +153,10 @@ class NetworkIO:
153
153
  params.log_network(filetype=filetype)
154
154
  self._log_loading(filetype)
155
155
 
156
+ # Important: Make a copy of the network to avoid modifying the original
157
+ network_copy = network.copy()
156
158
  # Initialize the graph
157
- return self._initialize_graph(network)
159
+ return self._initialize_graph(network_copy)
158
160
 
159
161
  @staticmethod
160
162
  def load_cytoscape_network(
@@ -475,16 +477,50 @@ class NetworkIO:
475
477
  logger.debug(f"Total edges missing weights: {missing_weights}")
476
478
 
477
479
  def _validate_nodes(self, G: nx.Graph) -> None:
478
- """Validate the graph structure and attributes.
480
+ """Validate the graph structure and attributes with attribute fallback for positions and labels.
479
481
 
480
482
  Args:
481
483
  G (nx.Graph): A NetworkX graph object.
482
484
  """
485
+ # Keep track of nodes missing labels
486
+ nodes_with_missing_labels = []
487
+
483
488
  for node, attrs in G.nodes(data=True):
484
- assert (
485
- "x" in attrs and "y" in attrs
486
- ), f"Node {node} is missing 'x' or 'y' position attributes."
487
- assert "label" in attrs, f"Node {node} is missing a 'label' attribute."
489
+ # Attribute fallback for 'x' and 'y' attributes
490
+ if "x" not in attrs or "y" not in attrs:
491
+ if (
492
+ "pos" in attrs
493
+ and isinstance(attrs["pos"], (tuple, list))
494
+ and len(attrs["pos"]) >= 2
495
+ ):
496
+ attrs["x"], attrs["y"] = attrs["pos"][
497
+ :2
498
+ ] # Use only x and y, ignoring z if present
499
+ else:
500
+ raise ValueError(
501
+ f"Node {node} is missing 'x', 'y', and a valid 'pos' attribute."
502
+ )
503
+
504
+ # Attribute fallback for 'label' attribute
505
+ if "label" not in attrs:
506
+ # Try alternative attribute names for label
507
+ if "name" in attrs:
508
+ attrs["label"] = attrs["name"]
509
+ elif "id" in attrs:
510
+ attrs["label"] = attrs["id"]
511
+ else:
512
+ # Collect nodes with missing labels
513
+ nodes_with_missing_labels.append(node)
514
+ attrs["label"] = str(node) # Use node ID as the label
515
+
516
+ # Issue a single warning if any labels were missing
517
+ if nodes_with_missing_labels:
518
+ total_nodes = len(G.nodes)
519
+ fraction_missing_labels = len(nodes_with_missing_labels) / total_nodes
520
+ logger.warning(
521
+ f"{len(nodes_with_missing_labels)} out of {total_nodes} nodes "
522
+ f"({fraction_missing_labels:.2%}) were missing 'label' attributes and were assigned node IDs."
523
+ )
488
524
 
489
525
  def _assign_edge_lengths(self, G: nx.Graph) -> None:
490
526
  """Prepare the network by adjusting surface depth and calculating edge lengths.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.8b0
3
+ Version: 0.0.8b1
4
4
  Summary: A Python package for biological network analysis
5
5
  Author: Ira Horecka
6
6
  Author-email: Ira Horecka <ira89@icloud.com>
File without changes
File without changes
File without changes
File without changes