Create a Graph w/ Only the Genes Interaction
1
0
Entering edit mode
Antonio • 0
@44ee1e1d
Last seen 4 months ago
United States

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)
EnrichedPathways GeneInteractionGraph graph • 312 views
ADD COMMENT
0
Entering edit mode
Antonio • 0
@44ee1e1d
Last seen 4 months ago
United States

Thank you all, I solved my issue by creating a for loop.

Cheers!

ADD COMMENT

Login before adding your answer.

Traffic: 496 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6