risk-network 0.0.5b1__tar.gz → 0.0.5b3__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.5b1 → risk_network-0.0.5b3}/PKG-INFO +1 -1
  2. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/__init__.py +1 -1
  3. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/network/graph.py +1 -2
  4. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/network/plot.py +11 -7
  5. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk_network.egg-info/PKG-INFO +1 -1
  6. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/LICENSE +0 -0
  7. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/MANIFEST.in +0 -0
  8. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/README.md +0 -0
  9. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/pyproject.toml +0 -0
  10. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/annotations/__init__.py +0 -0
  11. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/annotations/annotations.py +0 -0
  12. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/annotations/io.py +0 -0
  13. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/constants.py +0 -0
  14. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/log/__init__.py +0 -0
  15. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/log/console.py +0 -0
  16. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/log/params.py +0 -0
  17. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/neighborhoods/__init__.py +0 -0
  18. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/neighborhoods/community.py +0 -0
  19. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/neighborhoods/domains.py +0 -0
  20. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/neighborhoods/neighborhoods.py +0 -0
  21. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/network/__init__.py +0 -0
  22. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/network/geometry.py +0 -0
  23. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/network/io.py +0 -0
  24. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/risk.py +0 -0
  25. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/__init__.py +0 -0
  26. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/fisher_exact.py +0 -0
  27. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/hypergeom.py +0 -0
  28. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/permutation/__init__.py +0 -0
  29. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/permutation/permutation.py +0 -0
  30. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/permutation/test_functions.py +0 -0
  31. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk/stats/stats.py +0 -0
  32. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk_network.egg-info/SOURCES.txt +0 -0
  33. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk_network.egg-info/dependency_links.txt +0 -0
  34. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk_network.egg-info/requires.txt +0 -0
  35. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/risk_network.egg-info/top_level.txt +0 -0
  36. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/setup.cfg +0 -0
  37. {risk_network-0.0.5b1 → risk_network-0.0.5b3}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.5b1
3
+ Version: 0.0.5b3
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.5-beta.1"
10
+ __version__ = "0.0.5-beta.3"
@@ -11,7 +11,6 @@ import networkx as nx
11
11
  import numpy as np
12
12
  import pandas as pd
13
13
  import matplotlib
14
- import matplotlib.cm as cm
15
14
 
16
15
 
17
16
  class NetworkGraph:
@@ -270,7 +269,7 @@ def _get_colors(
270
269
  rgba = matplotlib.colors.to_rgba(kwargs["color"])
271
270
  rgbas = [rgba] * num_colors_to_generate
272
271
  else:
273
- colormap = cm.get_cmap(cmap)
272
+ colormap = matplotlib.colormaps.get_cmap(cmap)
274
273
  # Generate evenly distributed color positions
275
274
  color_positions = np.linspace(0, 1, num_colors_to_generate)
276
275
  random.shuffle(color_positions) # Shuffle the positions to randomize colors
@@ -413,6 +413,8 @@ class NetworkPlotter:
413
413
  max_labels: Union[int, None] = None,
414
414
  max_words: int = 10,
415
415
  min_words: int = 1,
416
+ max_word_length: int = 20,
417
+ min_word_length: int = 1,
416
418
  words_to_omit: Union[List[str], None] = None,
417
419
  ) -> None:
418
420
  """Annotate the network graph with labels for different domains, positioned around the network for clarity.
@@ -428,6 +430,8 @@ class NetworkPlotter:
428
430
  max_labels (int, optional): Maximum number of labels to plot. Defaults to None (no limit).
429
431
  max_words (int, optional): Maximum number of words in a label. Defaults to 10.
430
432
  min_words (int, optional): Minimum number of words required to display a label. Defaults to 1.
433
+ max_word_length (int, optional): Maximum number of characters in a word to display. Defaults to 20.
434
+ min_word_length (int, optional): Minimum number of characters in a word to display. Defaults to 1.
431
435
  words_to_omit (List[str], optional): List of words to omit from the labels. Defaults to None.
432
436
  """
433
437
  # Log the plotting parameters
@@ -442,7 +446,9 @@ class NetworkPlotter:
442
446
  label_max_labels=max_labels,
443
447
  label_max_words=max_words,
444
448
  label_min_words=min_words,
445
- label_words_to_omit=words_to_omit, # Log words_to_omit parameter
449
+ label_max_word_length=max_word_length,
450
+ label_min_word_length=min_word_length,
451
+ label_words_to_omit=words_to_omit,
446
452
  )
447
453
 
448
454
  # Convert color strings to RGBA arrays if necessary
@@ -471,13 +477,15 @@ class NetworkPlotter:
471
477
  # Remove words_to_omit
472
478
  if words_to_omit:
473
479
  terms = [term for term in terms if term.lower() not in words_to_omit]
480
+ # Filter words based on length
481
+ terms = [term for term in terms if min_word_length <= len(term) <= max_word_length]
474
482
  # Trim to max_words
475
483
  terms = terms[:max_words]
476
484
  # Check if the domain passes the word count condition
477
485
  if len(terms) >= min_words:
478
486
  # Add to filtered_domain_centroids
479
487
  filtered_domain_centroids[domain] = centroid
480
- # Store the trimmed terms
488
+ # Store the filtered and trimmed terms
481
489
  filtered_domain_terms[domain] = " ".join(terms)
482
490
  # Keep track of the valid index
483
491
  valid_indices.append(idx)
@@ -499,10 +507,6 @@ class NetworkPlotter:
499
507
  fontcolor = fontcolor[selected_indices]
500
508
  arrow_color = arrow_color[selected_indices]
501
509
 
502
- # Update the terms in the graph after omitting words and filtering
503
- for domain, terms in filtered_domain_terms.items():
504
- self.graph.trimmed_domain_to_term[domain] = terms
505
-
506
510
  # Calculate the bounding box around the network
507
511
  center, radius = _calculate_bounding_box(
508
512
  self.graph.node_coordinates, radius_margin=perimeter_scale
@@ -514,7 +518,7 @@ class NetworkPlotter:
514
518
  # Annotate the network with labels
515
519
  for idx, (domain, pos) in enumerate(best_label_positions.items()):
516
520
  centroid = filtered_domain_centroids[domain]
517
- annotations = self.graph.trimmed_domain_to_term[domain].split(" ")[:max_words]
521
+ annotations = filtered_domain_terms[domain].split(" ")[:max_words]
518
522
  self.ax.annotate(
519
523
  "\n".join(annotations),
520
524
  xy=centroid,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.5b1
3
+ Version: 0.0.5b3
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