I am working with networks in igraph, I have a network where there are short connected nodes that overlap eachother and so we donot exaclt see the edge. I want to delete al such short connected nodes as they are not connected to the main network. The degree thing doesnt work here as the nodes are not 0 degree., they are either connected to 1 or more genes but still not in the main network.Even the main network shows some overlapping genes, I want to correct that too.
net <- simplify(InnatedGraph, remove.multiple = T, remove.loops = T, )
bad.vs<-V(net)[degree(net) == 0]
net <-delete.vertices(net, bad.vs)
plot(net,vertex.label=NA, edge.curved=.1, edge.width = 1,edge.arrow.width = 0.3,vertex.size = 3,asp=-1,edge.arrow.size = 0.5,vertex.label.cex = 0.3)
After doing all this i get a network like this
The genes you see around the main network are not isolated nodes but connected to other nodes that are overlapped. Is there are way to delete these genes and prevent overlapping in the main network.
You want the main component. First, find the components and then subset the graph based on those components. Where g is your network:
V(g)$comp <- components(g)$membership
main <- induced_subgraph(g,V(g)$comp==1)
As far as overlapping nodes, check out the different layouts available in igraph. ?igraph::layout
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With