I am constructing a gene network. I have a two column data frame which i converted into and adjacency matrix and use it in igraph. The problem is i have genes that have self loops, I want to get rid of self loops and then get rid of the vertices that have no edge (isolated maybe) from the network. I have tried a few things but somehow they do not work. My code is
InnatedGraph <- graph.data.frame(innate,directed=FALSE)
V(InnatedGraph)$label.cex = 0.4
plot(InnatedGraph,vertex.label=V(InnatedGraph)$symbol, vertex.size=5)
innate is my two column data frame. I have tried the degree function to remove vertices with 0 degree but i guess unfortunately it does not work (maybe becoz the self loop genes have degree 1).
bad.vs<-V(InnatedGraph)[degree(InnatedGraph) == 0]
clean <-delete.vertices(InnatedGraph, bad.vs)
I tried using another function from package BioNet "rmSelfLoops" with the help of which i was able to remove the self loop edges but then still unable to remove the vertices with no edges.
test<-rmSelfLoops(InnatedGraph)
I will also include a picture of my network just to make it easier to understand.