<jupyter_start><jupyter_text>Plotting GRNCreating network plot for GRN. Only plotting top 20 highest connectivity nodes. SetupKey packages here are igraph (Network analysis tools) and ggnetwork (A variation of ggplot2 for networks, utilising edges and nodes)Centrality calculations are from prior analysis (02_Annotate_GRN.ipynb)<jupyter_code>library(tidyverse)
library(annotables)
library(igraph)
library(ggnetwork)
library(viridis)
# Network import from 02_Annotate_GRN.ipynb

edges <- suppressMessages(read_tsv("MLL-AF4/AggregatedGraph_MLL-AF4_edges.tsv"))
nodes <- suppressMessages(read_tsv("MLL-AF4/AggregatedGraph_MLL-AF4_nodes.tsv"))<jupyter_output><empty_output><jupyter_text>Graph creationFilter nodes by degree - we're not interested in nodes with low connectivity. Network then filtered by the new node set.<jupyter_code>top.nodes <- nodes %>% 
  top_n(20, degree)

top.edges <- edges %>% 
  filter(from %in% top.nodes$name, to %in% top.nodes$name)
top.nodes %>% arrange(desc(degree))<jupyter_output><empty_output><jupyter_text>Graph layout using ggnetwork<jupyter_code># Build the graph using annotates node table
graph <- graph_from_data_frame(top.edges, directed = T, vertices = top.nodes)

fortified.graph <- graph %>% 
  ggnetwork()<jupyter_output><empty_output><jupyter_text>Plotting nodesGGnetwork is stochastic, but creates a stable graph once run. Nodes can then be annotated based on the various RNA-seq and centrality statistics, as annotated previously.<jupyter_code>grn.plot <- fortified.graph %>% 
  ggplot(aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(color = "grey70", size = .3, curvature = .2, 
             arrow = arrow(length = unit(6, "pt"), type = "open")) +
  geom_nodes(aes(size = degree, col = degree)) +
  geom_nodetext(aes(label = symbol, size =  0.1 * degree)) +
  scale_size(range = c(5,15)) +
  scale_color_viridis() +
  theme_blank() +
  labs(title = "MLL network - col by degree") +
  theme(legend.position = "bottom")


grn.plot

grn.plot <- fortified.graph %>% 
  ggplot(aes(x = x, y = y, xend = xend, yend = yend)) +
  geom_edges(color = "grey70", size = .3, curvature = .2, 
             arrow = arrow(length = unit(6, "pt"), type = "open")) +
  geom_nodes(aes(size = degree, col = MLL.AF4.logFC)) +
  geom_nodetext(aes(label = symbol, size =  0.1 * degree)) +
  scale_size(range = c(5,15)) +
  scale_color_gradient2(low = "blue", mid = "white", high = "red", midpoint = 0) +
  theme_blank() +
  labs(title = "MLL network - col by MLL-AF4 KD logFC") +
  theme(legend.position = "bottom")


grn.plot
ggsave("Network_Plots/SIMA6_top20.pdf", grn.plot, width = 7, height = 5, units = "in",
       useDingbats = F)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13180303591262496, 'fraction_numerical': 0.01554979637171418, 'mean_word_length': 4.83585313174946, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '483453', 'license': 'MIT', 'n_tokens_mistral': 1013, 'n_tokens_neox': 939, 'n_words': 235, 'path': '03_NetworkPlot.ipynb', 'repo_name': 'JoeHarman/MLLAF4-GRN_paper_2021', 'size': '2701'}