diff options
| author | Chris Sobczak <chris@sobczak.family> | 2026-06-13 00:45:16 -0700 |
|---|---|---|
| committer | Chris Sobczak <chris@sobczak.family> | 2026-06-13 00:45:16 -0700 |
| commit | 4763c4720051aec45759d21577739dbb88d22d1e (patch) | |
| tree | 641b1d1feb2e59c6ab867c6b54a83b8d06b29e6d | |
| parent | e62e6df4c80037368526f45ee49a44e6e88cacb8 (diff) | |
Adjust network
| -rw-r--r-- | R/networkplot.R | 15 | ||||
| -rw-r--r-- | man/networkplot.Rd | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/R/networkplot.R b/R/networkplot.R index 1055b08..2401cb1 100644 --- a/R/networkplot.R +++ b/R/networkplot.R @@ -133,7 +133,7 @@ networkplot <- function(R, groups = NULL, title = NULL){ ggraph::geom_conn_bundle( data = con, ggplot2::aes( - edge_alpha = abs(.data$value), + edge_alpha = abs(.data$value)^2, edge_colour = .data$value ), tension = 0.5 @@ -153,20 +153,18 @@ networkplot <- function(R, groups = NULL, title = NULL){ ggraph::geom_node_point( ggplot2::aes( filter = .data$leaf, - colour = .data$group, fill = .data$group ), - size = 3 + size = 1 ) + # labels nodes and groups ggraph::geom_node_text( ggplot2::aes(label = .data$name), # prevents text labels from overlapping repel = TRUE, - size = 3 + size = 1 ) + - ggplot2::theme_void() + - ggplot2::theme(legend.position = 'none') + ggplot2::theme_void() if(!is.null(title)){ p <- p + @@ -175,6 +173,11 @@ networkplot <- function(R, groups = NULL, title = NULL){ plot.title = ggplot2::element_text(hjust = 0.5) ) } + + if(!is.null(groups)){ + p <- p + + ggplot2::scale_fill_discrete(name = 'Superpathway') + } return(p) } diff --git a/man/networkplot.Rd b/man/networkplot.Rd index a4a622d..4337a31 100644 --- a/man/networkplot.Rd +++ b/man/networkplot.Rd @@ -20,7 +20,8 @@ A ggraph object Draw an undirected graph from a square matrix where each variable is a node and the pairwise entries are the strength of the relationship -(ex: correlation, partial correlation) +(ex: correlation, partial correlation). +Based on https://r-graph-gallery.com/310-custom-hierarchical-edge-bundling.html } \examples{ X <- matrix(data = rnorm(100), nrow = 10) |
