Read the edge list of a graph from a file and construct the adjacency matrix.
The connection to read from. This should be a .txt file, with one edge in a line, the two vertices separated by a delimiter.
The names of all vertices in the graph.
Whether the graph to read is directed.
edgelist2adj accepts a list of edges and constructs the 0-1 adjacency matrix corresponding to the graph. If
file contains an incomplete list of edges, the function determines the actual size of the graph through the vector
Although named as
edgelist2adj, the user can also construct a 0-1 matrix corresponding to non-edges, i.e. connections that do not exist between any two vertices.
file contains incomplete information, the returned 0-1 adjacency matrix (for edges or non-edges) can be used as input in
covsel to estimate the complete (and weighted) adjacency matrix.
A 0-1 adjacency matrix of dimension p \times p corresponding to the edges defined in
file, where p is the length of the vector
Ali Shojaie and Jing Ma
Ma, J., Shojaie, A. & Michailidis, G. (2014). Network-based pathway enrichment analysis with incomplete network information, submitted. http://arxiv.org/abs/1411.7919.
1 2 3 4 5 6 7 8 9 10 11 12 13
#Read the data data(edgelist) data(nonedgelist) #Generate the .txt files write.table(edgelist, file="edgelist.txt", row.names=FALSE) write.table(nonedgelist, file="nonedgelist.txt", row.names=FALSE) #Read the edge/nonedge list from files oneMat = edgelist2adj(file="edgelist.txt", vertex.names=paste0("gene", 1:100), mode="undirected") zeroMat = edgelist2adj(file="nonedgelist.txt", vertex.names=paste0("gene", 1:100), mode="undirected")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.