# Clustering of gene co-expression network by igraph R package

I have constructed a gene co-expression network from RNA-seq data. The network has more than 10000 nodes and more than 1 million edges.

The network file as an edge list format of memory around 1gb which was created by calculating Pearson correlation of each gene pairs and gene pairs having correlation greater than 95% we're selected to create the edge list. The file is too large to run in cytoscape due to limitation of computer configuration.

In R, I am able to calculate the topological properties of the network. And to cluster the gene coexperssion network, I tried using different community detection methods and but I am unable to identify which community detection is good for obtaining clusters?.

After clustering how to rank the subclusters and save each subcluster in separate files.

• What kind of clustering do you want? Should the clusters be discrete (each node can only belong to a single cluster) or overlapping (each node can belong to multiple clusters)? You say you want to rank the clusters, OK, but according to what value? Cardinality? Connectedness? Something else? Apr 5 '19 at 8:39
• Why not just plot a direct correlation heat map? Very easy indeed via R
– M__
Apr 6 '19 at 22:53

For the first part, do you mean that the file is too large to be run on your computer?

For the second, if I understood correctly, you can use igraph or ggnet2 to color code the nodes based on the conditions you have and see if communities are formed based on condition. This would be a simple way to do this kind of thing.

I personally prefer using ggnet2 as I found it more user friendly. What you can do if you have an adjacency matrix, say adj_mat is to create a color vector based on the conditions for each node in the network, where length(color_vec) = ncol(adj_mat) = nrow(adj_mat) - since it is a square matrix. Following that, you could do something like this:

library(ggplot2)
library(network)

neto <- network(adj_mat, directed = FALSE, loops = FALSE, hyper = FALSE)
#assuming that it is undirected here and a simple network diagram.
#run ?network for more details in case your analysis is to be more complex

color_vec <- as.factor(color_vec)

col_pal <- c("blue", "red", "green") #assuming you only have 3 colors..

names(col_pal) <- levels(color_vec)
neto %v% "color" <- as.character(col_vec)

ggnet2(neto, node.size = .9, color = "color", palette = col_pal,
edge.size = .05, edge.color = "white", mode = "adj")

• I think that Cytoscape has problems with dealing with such big networks even if OP had the computational resources needed.
– llrs
Apr 4 '19 at 8:14
• I don't have much experience with Cytoscape.. Also I have never had to create a network this large. Would it not be feasible in R? Apr 4 '19 at 15:07
• Yes, it is possible to analyse it with igraph. But in which format do you currently have the network and how do you create it?
– llrs
Apr 4 '19 at 15:20