Entering edit mode
Hey mates,
My script is running perfectly and produces an graph with the genes connected to each other and the pathways. However, now I would like to remove the pathways connection and only have the genes connected to each other.
Here is a sample functioning code that resembles my script;
install.packages(BiocManager)
BiocManager::install("ReactomePA",force = TRUE)
install.packages(c("igraph","dplyr"))
library(ReactomePA)
library(igraph)
random_genes <- c("11171", "8243", "112464", "2194", "9318", "79026", "1654", "65003",
"6240", "3476", "6238", "3836", "4176", "1017", "249")
# Pathway enrichment analysis
enriched_pathways <- enrichPathway(gene = random_genes, organism = "mouse")
# Extract pathway and gene information
pathways <- as.data.frame(enriched_pathways)
`# Create an edge list for the graph
edge_list <- data.frame(
from = rep(pathways$Description, each = length(genes)),
to = rep(genes, times = nrow(pathways)))
# Excluding NON-hallmark pathways [IS THIS STILL NEEDED]
exclude_pathway <- c("Biological oxidations","Arachidonic acid metabolism",
"Platelet homeostasis","Paracetamol ADME","Fatty acid metabolism")
# # Removing pathways not in my interest
edge_list<-edge_list %>% dplyr::filter(!(from %in% exclude_pathway))
# Graph & Results ------------------------------------------------------------------
# Create the graph
g <- graph_from_data_frame(edge_list, directed = FALSE)
# Setting my layout preference
layout<-layout_with_graphopt(g) #drl w/ vertex size 3 looks the best
#graphopt w/ vertex size 1 is next best
# The graph
plot(g, layout = layout, vertex.label.cex = 0.8,
vertex.size = 3, vertex.label.dist = 0.5)