knitr::opts_chunk$set(echo = TRUE)

Build Network

Load in Data

library(COLDNet)

Modify data to fit needs

# - log value for p value
test_net$abs_rho <- abs(test_net$rho)
test_net$log_p <- -log10(test_net$p_Bonferroni)

# required from and to columns!!!
colnames(test_net)[c(1,2)] <- c("from", "to")

Build igraph + calculate layout

# Takes in a dataframe, uses igraph to make a network
test_net <- build_network(input = test_net)

Calculate graph color / width

### FAST : Render = F, no graph plotted, but parameters written to object
test_net <- plot_ggraph(input_igraph = test_net, render = F)

### SLOWER : Render = T, without labels
test_net <- plot_ggraph(input_igraph = test_net, label = F, render = T)

### SLOWER : Render = T, without labels
test_net <- plot_ggraph(input_igraph = test_net, edge_color = "rho", edge_width = "log_p", scale = "diverge",  render = T, label = F, node_color = "purple", node_size = 2, edge_size_range = c(1, 3))

### SLOWEST : Render = T, with labels
test_net <- plot_ggraph(input_igraph = test_net, edge_color = "rho", edge_width = "log_p", scale = "diverge", render = T, label = T)

### Label subset of nodes
test_net <- plot_ggraph(input_igraph = test_net, edge_color = "rho", edge_width = "log_p", scale = "diverge", render = T, label = T, label_nodes = names(V(test_net))[1:10])

### Change color pallette
test_net <- plot_ggraph(input_igraph = test_net, edge_color = "rho", edge_width = "log_p", scale = "diverge", render = T, edge_colpal = c("gray", "yellow"))

### Subset graph for inset plotting

KLHDC1_graph <- extract_node(test_net, "KLHDC1")
plot_ggraph(input_igraph = KLHDC1_graph, edge_color = "rho", edge_width = "log_p", scale = "diverge", render = T, label = T)

### New layout

KLHDC1_graph <- extract_node(test_net, "KLHDC1", layout = T)
plot_ggraph(input_igraph = KLHDC1_graph, edge_color = "rho", edge_width = "log_p", scale = "diverge", render = T, label = T)

Build and Plot visNetwork

# Takes in the igraph object and runs the shiny app!!

### SLOW, the entire network is rendered at the start.
build_visnetwork(input_igraph = test_net)

### FAST, only the nodes of interest are rendered. 
build_vis_subnetwork(input_igraph = test_net)

build_vis_subnetwork(input_igraph = test_net, return_dataTable = F)

build_vis_subnetwork(input_igraph = test_net, trim_edges = T, return_dataTable = F)

## Changes!
# Zoom in functionality
# Fix data loading issue??
# Function to change color and width in shiny! run plot_ggraph and have it make new color_column each time
# Get data button


kgellatl/COLDNet documentation built on Jan. 23, 2021, 9:29 a.m.