risk-network 0.0.6b4__tar.gz → 0.0.6b6__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.6b4 → risk_network-0.0.6b6}/PKG-INFO +1 -1
  2. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/__init__.py +1 -1
  3. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/network/plot.py +137 -67
  4. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk_network.egg-info/PKG-INFO +1 -1
  5. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/LICENSE +0 -0
  6. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/MANIFEST.in +0 -0
  7. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/README.md +0 -0
  8. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/pyproject.toml +0 -0
  9. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/annotations/__init__.py +0 -0
  10. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/annotations/annotations.py +0 -0
  11. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/annotations/io.py +0 -0
  12. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/constants.py +0 -0
  13. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/log/__init__.py +0 -0
  14. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/log/console.py +0 -0
  15. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/log/params.py +0 -0
  16. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/neighborhoods/__init__.py +0 -0
  17. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/neighborhoods/community.py +0 -0
  18. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/neighborhoods/domains.py +0 -0
  19. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/neighborhoods/neighborhoods.py +0 -0
  20. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/network/__init__.py +0 -0
  21. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/network/geometry.py +0 -0
  22. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/network/graph.py +0 -0
  23. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/network/io.py +0 -0
  24. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/risk.py +0 -0
  25. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/__init__.py +0 -0
  26. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/fisher_exact.py +0 -0
  27. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/hypergeom.py +0 -0
  28. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/permutation/__init__.py +0 -0
  29. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/permutation/permutation.py +0 -0
  30. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/permutation/test_functions.py +0 -0
  31. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk/stats/stats.py +0 -0
  32. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk_network.egg-info/SOURCES.txt +0 -0
  33. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk_network.egg-info/dependency_links.txt +0 -0
  34. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk_network.egg-info/requires.txt +0 -0
  35. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/risk_network.egg-info/top_level.txt +0 -0
  36. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/setup.cfg +0 -0
  37. {risk_network-0.0.6b4 → risk_network-0.0.6b6}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.6b4
3
+ Version: 0.0.6b6
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.6-beta.4"
10
+ __version__ = "0.0.6-beta.6"
@@ -137,9 +137,7 @@ class NetworkPlotter:
137
137
  )
138
138
  # Set the transparency of the fill if applicable
139
139
  if fill_alpha > 0:
140
- circle.set_facecolor(
141
- _to_rgba(color, fill_alpha)
142
- ) # Use _to_rgba to set the fill color with transparency
140
+ circle.set_facecolor(_to_rgba(color, fill_alpha))
143
141
 
144
142
  self.ax.add_artist(circle)
145
143
 
@@ -200,7 +198,7 @@ class NetworkPlotter:
200
198
  color=color,
201
199
  linestyle=linestyle,
202
200
  linewidth=linewidth,
203
- alpha=fill_alpha, # Use fill_alpha for the fill
201
+ alpha=fill_alpha,
204
202
  )
205
203
 
206
204
  def plot_network(
@@ -279,7 +277,7 @@ class NetworkPlotter:
279
277
  nodes: List,
280
278
  node_size: Union[int, np.ndarray] = 50,
281
279
  node_shape: str = "o",
282
- node_edgewidth: float = 1.0, # Added node_edgewidth parameter
280
+ node_edgewidth: float = 1.0,
283
281
  edge_width: float = 1.0,
284
282
  node_color: Union[str, List, Tuple, np.ndarray] = "white",
285
283
  node_edgecolor: Union[str, List, Tuple, np.ndarray] = "black",
@@ -313,8 +311,8 @@ class NetworkPlotter:
313
311
  if not node_ids:
314
312
  raise ValueError("No nodes found in the network graph.")
315
313
 
316
- # If node_color is an array, match its length to the found node_ids
317
- if not isinstance(node_color, str):
314
+ # Check if node_color is a single color or a list of colors
315
+ if not isinstance(node_color, (str, tuple, np.ndarray)):
318
316
  node_color = [
319
317
  node_color[nodes.index(node)]
320
318
  for node in nodes
@@ -325,6 +323,7 @@ class NetworkPlotter:
325
323
  node_color = _to_rgba(node_color, node_alpha, num_repeats=len(node_ids))
326
324
  node_edgecolor = _to_rgba(node_edgecolor, 1.0, num_repeats=len(node_ids))
327
325
  edge_color = _to_rgba(edge_color, edge_alpha, num_repeats=len(self.graph.network.edges))
326
+
328
327
  # Get the coordinates of the filtered nodes
329
328
  node_coordinates = {node_id: self.graph.node_coordinates[node_id] for node_id in node_ids}
330
329
 
@@ -358,7 +357,8 @@ class NetworkPlotter:
358
357
  color: Union[str, List, Tuple, np.ndarray] = "white",
359
358
  linestyle: str = "solid",
360
359
  linewidth: float = 1.5,
361
- alpha: float = 0.2,
360
+ alpha: float = 1.0,
361
+ fill_alpha: float = 0.2,
362
362
  ) -> None:
363
363
  """Draw KDE contours for nodes in various domains of a network graph, highlighting areas of high density.
364
364
 
@@ -369,7 +369,8 @@ class NetworkPlotter:
369
369
  color (str, list, tuple, or np.ndarray, optional): Color of the contours. Can be a single color or an array of colors. Defaults to "white".
370
370
  linestyle (str, optional): Line style for the contours. Defaults to "solid".
371
371
  linewidth (float, optional): Line width for the contours. Defaults to 1.5.
372
- alpha (float, optional): Transparency level of the contour fill. Defaults to 0.2.
372
+ alpha (float, optional): Transparency level of the contour lines. Defaults to 1.0.
373
+ fill_alpha (float, optional): Transparency level of the contour fill. Defaults to 0.2.
373
374
  """
374
375
  # Log the contour plotting parameters
375
376
  params.log_plotter(
@@ -380,6 +381,7 @@ class NetworkPlotter:
380
381
  "custom" if isinstance(color, np.ndarray) else color
381
382
  ), # np.ndarray usually indicates custom colors
382
383
  contour_alpha=alpha,
384
+ contour_fill_alpha=fill_alpha,
383
385
  )
384
386
 
385
387
  # Ensure color is converted to RGBA with repetition matching the number of domains
@@ -400,6 +402,7 @@ class NetworkPlotter:
400
402
  linestyle=linestyle,
401
403
  linewidth=linewidth,
402
404
  alpha=alpha,
405
+ fill_alpha=fill_alpha,
403
406
  )
404
407
 
405
408
  def plot_subcontour(
@@ -411,7 +414,8 @@ class NetworkPlotter:
411
414
  color: Union[str, List, Tuple, np.ndarray] = "white",
412
415
  linestyle: str = "solid",
413
416
  linewidth: float = 1.5,
414
- alpha: float = 0.2,
417
+ alpha: float = 1.0,
418
+ fill_alpha: float = 0.2,
415
419
  ) -> None:
416
420
  """Plot a subcontour for a given set of nodes using Kernel Density Estimation (KDE).
417
421
 
@@ -423,7 +427,8 @@ class NetworkPlotter:
423
427
  color (str, list, tuple, or np.ndarray, optional): Color of the contour. Can be a string (e.g., 'white') or RGBA array. Defaults to "white".
424
428
  linestyle (str, optional): Line style for the contour. Defaults to "solid".
425
429
  linewidth (float, optional): Line width for the contour. Defaults to 1.5.
426
- alpha (float, optional): Transparency level of the contour fill. Defaults to 0.2.
430
+ alpha (float, optional): Transparency level of the contour lines. Defaults to 1.0.
431
+ fill_alpha (float, optional): Transparency level of the contour fill. Defaults to 0.2.
427
432
 
428
433
  Raises:
429
434
  ValueError: If no valid nodes are found in the network graph.
@@ -453,6 +458,7 @@ class NetworkPlotter:
453
458
  linestyle=linestyle,
454
459
  linewidth=linewidth,
455
460
  alpha=alpha,
461
+ fill_alpha=fill_alpha,
456
462
  )
457
463
 
458
464
  def _draw_kde_contour(
@@ -466,7 +472,8 @@ class NetworkPlotter:
466
472
  color: Union[str, np.ndarray] = "white",
467
473
  linestyle: str = "solid",
468
474
  linewidth: float = 1.5,
469
- alpha: float = 0.5,
475
+ alpha: float = 1.0,
476
+ fill_alpha: float = 0.2,
470
477
  ) -> None:
471
478
  """Draw a Kernel Density Estimate (KDE) contour plot for a set of nodes on a given axis.
472
479
 
@@ -480,7 +487,8 @@ class NetworkPlotter:
480
487
  color (str or np.ndarray): Color for the contour. Can be a string or RGBA array. Defaults to "white".
481
488
  linestyle (str, optional): Line style for the contour. Defaults to "solid".
482
489
  linewidth (float, optional): Line width for the contour. Defaults to 1.5.
483
- alpha (float, optional): Transparency level for the contour fill. Defaults to 0.5.
490
+ alpha (float, optional): Transparency level for the contour lines. Defaults to 1.0.
491
+ fill_alpha (float, optional): Transparency level for the contour fill. Defaults to 0.2.
484
492
  """
485
493
  # Extract the positions of the specified nodes
486
494
  points = np.array([pos[n] for n in nodes])
@@ -506,8 +514,8 @@ class NetworkPlotter:
506
514
  min_density, max_density = z.min(), z.max()
507
515
  contour_levels = np.linspace(min_density, max_density, levels)[1:]
508
516
  contour_colors = [color for _ in range(levels - 1)]
509
- # Plot the filled contours only if alpha > 0
510
- if alpha > 0:
517
+ # Plot the filled contours using fill_alpha for transparency
518
+ if fill_alpha > 0:
511
519
  ax.contourf(
512
520
  x,
513
521
  y,
@@ -515,10 +523,10 @@ class NetworkPlotter:
515
523
  levels=contour_levels,
516
524
  colors=contour_colors,
517
525
  antialiased=True,
518
- alpha=alpha,
526
+ alpha=fill_alpha,
519
527
  )
520
528
 
521
- # Plot the contour lines without any change in behavior
529
+ # Plot the contour lines with the specified alpha for transparency
522
530
  c = ax.contour(
523
531
  x,
524
532
  y,
@@ -527,7 +535,9 @@ class NetworkPlotter:
527
535
  colors=contour_colors,
528
536
  linestyles=linestyle,
529
537
  linewidths=linewidth,
538
+ alpha=alpha,
530
539
  )
540
+ # Set linewidth for the contour lines to 0 for levels other than the base level
531
541
  for i in range(1, len(contour_levels)):
532
542
  c.collections[i].set_linewidth(0)
533
543
 
@@ -540,6 +550,7 @@ class NetworkPlotter:
540
550
  fontcolor: Union[str, List, Tuple, np.ndarray] = "black",
541
551
  fontalpha: float = 1.0,
542
552
  arrow_linewidth: float = 1,
553
+ arrow_style: str = "->",
543
554
  arrow_color: Union[str, List, Tuple, np.ndarray] = "black",
544
555
  arrow_alpha: float = 1.0,
545
556
  max_labels: Union[int, None] = None,
@@ -547,7 +558,10 @@ class NetworkPlotter:
547
558
  min_words: int = 1,
548
559
  max_word_length: int = 20,
549
560
  min_word_length: int = 1,
550
- words_to_omit: Union[List[str], None] = None,
561
+ words_to_omit: Union[List, None] = None,
562
+ overlay_ids: bool = False,
563
+ ids_to_keep: Union[List, Tuple, np.ndarray, None] = None,
564
+ ids_to_replace: Union[Dict, None] = None,
551
565
  ) -> None:
552
566
  """Annotate the network graph with labels for different domains, positioned around the network for clarity.
553
567
 
@@ -559,6 +573,7 @@ class NetworkPlotter:
559
573
  fontcolor (str, list, tuple, or np.ndarray, optional): Color of the label text. Can be a string or RGBA array. Defaults to "black".
560
574
  fontalpha (float, optional): Transparency level for the font color. Defaults to 1.0.
561
575
  arrow_linewidth (float, optional): Line width of the arrows pointing to centroids. Defaults to 1.
576
+ arrow_style (str, optional): Style of the arrows pointing to centroids. Defaults to "->".
562
577
  arrow_color (str, list, tuple, or np.ndarray, optional): Color of the arrows. Defaults to "black".
563
578
  arrow_alpha (float, optional): Transparency level for the arrow color. Defaults to 1.0.
564
579
  max_labels (int, optional): Maximum number of labels to plot. Defaults to None (no limit).
@@ -566,7 +581,16 @@ class NetworkPlotter:
566
581
  min_words (int, optional): Minimum number of words required to display a label. Defaults to 1.
567
582
  max_word_length (int, optional): Maximum number of characters in a word to display. Defaults to 20.
568
583
  min_word_length (int, optional): Minimum number of characters in a word to display. Defaults to 1.
569
- words_to_omit (List[str], optional): List of words to omit from the labels. Defaults to None.
584
+ words_to_omit (List, optional): List of words to omit from the labels. Defaults to None.
585
+ overlay_ids (bool, optional): Whether to overlay domain IDs in the center of the centroids. Defaults to False.
586
+ ids_to_keep (list, tuple, np.ndarray, or None, optional): IDs of domains that must be labeled. To discover domain IDs,
587
+ you can set `overlay_ids=True`. Defaults to None.
588
+ ids_to_replace (dict, optional): A dictionary mapping domain IDs to custom labels (strings). The labels should be space-separated words.
589
+ If provided, the custom labels will replace the default domain terms. To discover domain IDs, you can set `overlay_ids=True`.
590
+ Defaults to None.
591
+
592
+ Raises:
593
+ ValueError: If the number of provided `ids_to_keep` exceeds `max_labels`.
570
594
  """
571
595
  # Log the plotting parameters
572
596
  params.log_plotter(
@@ -579,6 +603,7 @@ class NetworkPlotter:
579
603
  ), # np.ndarray usually indicates custom colors
580
604
  label_fontalpha=fontalpha,
581
605
  label_arrow_linewidth=arrow_linewidth,
606
+ label_arrow_style=arrow_style,
582
607
  label_arrow_color="custom" if isinstance(arrow_color, np.ndarray) else arrow_color,
583
608
  label_arrow_alpha=arrow_alpha,
584
609
  label_max_labels=max_labels,
@@ -587,9 +612,12 @@ class NetworkPlotter:
587
612
  label_max_word_length=max_word_length,
588
613
  label_min_word_length=min_word_length,
589
614
  label_words_to_omit=words_to_omit,
615
+ label_overlay_ids=overlay_ids,
616
+ label_ids_to_keep=ids_to_keep,
617
+ label_ids_to_replace=ids_to_replace,
590
618
  )
591
619
 
592
- # Convert colors to RGBA using the _to_rgba helper function, applying alpha separately for font and arrow
620
+ # Convert colors to RGBA using the _to_rgba helper function
593
621
  fontcolor = _to_rgba(fontcolor, fontalpha, num_repeats=len(self.graph.domain_to_nodes_map))
594
622
  arrow_color = _to_rgba(
595
623
  arrow_color, arrow_alpha, num_repeats=len(self.graph.domain_to_nodes_map)
@@ -605,55 +633,82 @@ class NetworkPlotter:
605
633
  if nodes: # Skip if the domain has no nodes
606
634
  domain_centroids[domain] = self._calculate_domain_centroid(nodes)
607
635
 
608
- # Initialize empty lists to collect valid indices
636
+ # Initialize dictionaries and lists for valid indices
609
637
  valid_indices = []
610
638
  filtered_domain_centroids = {}
611
639
  filtered_domain_terms = {}
612
- # Loop through domain_centroids with index
613
- for idx, (domain, centroid) in enumerate(domain_centroids.items()):
614
- # Process the domain term
615
- terms = self.graph.trimmed_domain_to_term[domain].split(" ")
616
- # Remove words_to_omit
617
- if words_to_omit:
618
- terms = [term for term in terms if term.lower() not in words_to_omit]
619
- # Filter words based on length
620
- terms = [term for term in terms if min_word_length <= len(term) <= max_word_length]
621
- # Trim to max_words
622
- terms = terms[:max_words]
623
- # Check if the domain passes the word count condition
624
- if len(terms) >= min_words:
625
- # Add to filtered_domain_centroids
626
- filtered_domain_centroids[domain] = centroid
627
- # Store the filtered and trimmed terms
628
- filtered_domain_terms[domain] = " ".join(terms)
629
- # Keep track of the valid index - used for fontcolor and arrow_color
630
- valid_indices.append(idx)
631
-
632
- # If max_labels is specified and less than the available labels
633
- if max_labels is not None and max_labels < len(filtered_domain_centroids):
634
- step = len(filtered_domain_centroids) / max_labels
635
- selected_indices = [int(i * step) for i in range(max_labels)]
636
- # Filter the centroids, terms, and valid_indices to only use the selected indices
637
- filtered_domain_centroids = {
638
- k: v
639
- for i, (k, v) in enumerate(filtered_domain_centroids.items())
640
- if i in selected_indices
641
- }
642
- filtered_domain_terms = {
643
- k: v
644
- for i, (k, v) in enumerate(filtered_domain_terms.items())
645
- if i in selected_indices
646
- }
647
- # Update valid_indices to match selected indices
648
- valid_indices = [valid_indices[i] for i in selected_indices]
640
+ # Handle the ids_to_keep logic
641
+ if ids_to_keep:
642
+ # Check if the number of provided ids_to_keep exceeds max_labels
643
+ if max_labels is not None and len(ids_to_keep) > max_labels:
644
+ raise ValueError(
645
+ f"Number of provided IDs ({len(ids_to_keep)}) exceeds max_labels ({max_labels})."
646
+ )
647
+
648
+ # Process the specified IDs first
649
+ for domain in ids_to_keep:
650
+ if domain in self.graph.trimmed_domain_to_term and domain in domain_centroids:
651
+ # Handle ids_to_replace logic here for ids_to_keep
652
+ if ids_to_replace and domain in ids_to_replace:
653
+ terms = ids_to_replace[domain].split(" ")
654
+ else:
655
+ terms = self.graph.trimmed_domain_to_term[domain].split(" ")
656
+
657
+ # Apply words_to_omit, word length constraints, and max_words
658
+ if words_to_omit:
659
+ terms = [term for term in terms if term.lower() not in words_to_omit]
660
+ terms = [
661
+ term for term in terms if min_word_length <= len(term) <= max_word_length
662
+ ]
663
+ terms = terms[:max_words]
664
+
665
+ # Check if the domain passes the word count condition
666
+ if len(terms) >= min_words:
667
+ filtered_domain_centroids[domain] = domain_centroids[domain]
668
+ filtered_domain_terms[domain] = " ".join(terms)
669
+ valid_indices.append(
670
+ list(domain_centroids.keys()).index(domain)
671
+ ) # Track the valid index
672
+
673
+ # Calculate remaining labels to plot after processing ids_to_keep
674
+ remaining_labels = (
675
+ max_labels - len(ids_to_keep) if ids_to_keep and max_labels else max_labels
676
+ )
677
+ # Process remaining domains to fill in additional labels, if there are slots left
678
+ if remaining_labels and remaining_labels > 0:
679
+ for idx, (domain, centroid) in enumerate(domain_centroids.items()):
680
+ if ids_to_keep and domain in ids_to_keep:
681
+ continue # Skip domains already handled by ids_to_keep
682
+
683
+ # Handle ids_to_replace logic first
684
+ if ids_to_replace and domain in ids_to_replace:
685
+ terms = ids_to_replace[domain].split(" ")
686
+ else:
687
+ terms = self.graph.trimmed_domain_to_term[domain].split(" ")
688
+
689
+ # Apply words_to_omit, word length constraints, and max_words
690
+ if words_to_omit:
691
+ terms = [term for term in terms if term.lower() not in words_to_omit]
692
+
693
+ terms = [term for term in terms if min_word_length <= len(term) <= max_word_length]
694
+ terms = terms[:max_words]
695
+ # Check if the domain passes the word count condition
696
+ if len(terms) >= min_words:
697
+ filtered_domain_centroids[domain] = centroid
698
+ filtered_domain_terms[domain] = " ".join(terms)
699
+ valid_indices.append(idx) # Track the valid index
700
+
701
+ # Stop once we've reached the max_labels limit
702
+ if len(filtered_domain_centroids) >= max_labels:
703
+ break
649
704
 
650
705
  # Calculate the bounding box around the network
651
706
  center, radius = _calculate_bounding_box(self.graph.node_coordinates, radius_margin=scale)
652
- # Calculate the best positions for labels around the perimeter
707
+ # Calculate the best positions for labels
653
708
  best_label_positions = _calculate_best_label_positions(
654
709
  filtered_domain_centroids, center, radius, offset
655
710
  )
656
- # Annotate the network with labels - valid_indices is used for fontcolor and arrow_color
711
+ # Annotate the network with labels
657
712
  for idx, (domain, pos) in zip(valid_indices, best_label_positions.items()):
658
713
  centroid = filtered_domain_centroids[domain]
659
714
  annotations = filtered_domain_terms[domain].split(" ")[:max_words]
@@ -667,8 +722,23 @@ class NetworkPlotter:
667
722
  fontsize=fontsize,
668
723
  fontname=font,
669
724
  color=fontcolor[idx],
670
- arrowprops=dict(arrowstyle="->", color=arrow_color[idx], linewidth=arrow_linewidth),
725
+ arrowprops=dict(
726
+ arrowstyle=arrow_style, color=arrow_color[idx], linewidth=arrow_linewidth
727
+ ),
671
728
  )
729
+ # Overlay domain ID at the centroid if requested
730
+ if overlay_ids:
731
+ self.ax.text(
732
+ centroid[0],
733
+ centroid[1],
734
+ domain,
735
+ ha="center",
736
+ va="center",
737
+ fontsize=fontsize,
738
+ fontname=font,
739
+ color=fontcolor[idx],
740
+ alpha=fontalpha,
741
+ )
672
742
 
673
743
  def plot_sublabel(
674
744
  self,
@@ -688,7 +758,7 @@ class NetworkPlotter:
688
758
  """Annotate the network graph with a single label for the given nodes, positioned at a specified radial angle.
689
759
 
690
760
  Args:
691
- nodes (List[str]): List of node labels to be used for calculating the centroid.
761
+ nodes (List): List of node labels to be used for calculating the centroid.
692
762
  label (str): The label to be annotated on the network.
693
763
  radial_position (float, optional): Radial angle for positioning the label, in degrees (0-360). Defaults to 0.0.
694
764
  scale (float, optional): Scale factor for positioning the label around the perimeter. Defaults to 1.05.
@@ -810,13 +880,13 @@ class NetworkPlotter:
810
880
  return adjusted_network_colors
811
881
 
812
882
  def get_annotated_node_sizes(
813
- self, enriched_nodesize: int = 50, nonenriched_nodesize: int = 25
883
+ self, enriched_size: int = 50, nonenriched_size: int = 25
814
884
  ) -> np.ndarray:
815
885
  """Adjust the sizes of nodes in the network graph based on whether they are enriched or not.
816
886
 
817
887
  Args:
818
- enriched_nodesize (int): Size for enriched nodes. Defaults to 50.
819
- nonenriched_nodesize (int): Size for non-enriched nodes. Defaults to 25.
888
+ enriched_size (int): Size for enriched nodes. Defaults to 50.
889
+ nonenriched_size (int): Size for non-enriched nodes. Defaults to 25.
820
890
 
821
891
  Returns:
822
892
  np.ndarray: Array of node sizes, with enriched nodes larger than non-enriched ones.
@@ -827,11 +897,11 @@ class NetworkPlotter:
827
897
  enriched_nodes.update(nodes)
828
898
 
829
899
  # Initialize all node sizes to the non-enriched size
830
- node_sizes = np.full(len(self.graph.network.nodes), nonenriched_nodesize)
900
+ node_sizes = np.full(len(self.graph.network.nodes), nonenriched_size)
831
901
  # Set the size for enriched nodes
832
902
  for node in enriched_nodes:
833
903
  if node in self.graph.network.nodes:
834
- node_sizes[node] = enriched_nodesize
904
+ node_sizes[node] = enriched_size
835
905
 
836
906
  return node_sizes
837
907
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: risk-network
3
- Version: 0.0.6b4
3
+ Version: 0.0.6b6
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