networkmatrix: Creates a network matrix for 'neat'

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/neat.R

Description

Internal function, creates a two-column network matrix that can be further processed by neat.

Usage

1
networkmatrix(network, nodes, nettype)

Arguments

network

One of the following objects: an adjacency matrix (class "matrix"), a sparse adjacency matrix (class "dgCMatrix") or an igraph graph (class "igraph")

nodes

Vector containing the (ordered) names of all nodes in the network

nettype

Either 'directed' or 'undirected'

Details

This is an internal function, that is called within neat to convert different types of network objects (see argument 'network' above) into a standard two-column network matrix, that can then be processed by neat.

Value

A two-column matrix, where every row represents and edge. For directed networks, parent nodes must be in the first column, and child nodes in the second.

Author(s)

Mirko Signorelli

References

Signorelli, M., Vinciotti, V., Wit, E. C. (2016). NEAT: an efficient network enrichment analysis test. BMC Bioinformatics, 17:352. Url: https://bmcbioinformatics.biomedcentral.com/articles/10.1186/s12859-016-1203-6.

See Also

neat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# First case: adjacency matrix
n<-50
adjacency <- matrix(sample(0:1, n^2, replace=TRUE, prob=c(0.9,0.1)), ncol=n)
diag(adjacency) <- 0
lab = paste(rep('gene'),1:n)
head(networkmatrix(adjacency, lab, 'directed'))

# Second case: sparse adjacency matrix
library(Matrix)
sparse_adjacency<-Matrix(adjacency,sparse=TRUE)
head(networkmatrix(sparse_adjacency, lab, 'directed'))

# Third case: igraph object
library(igraph)
igraph_graph = erdos.renyi.game(15, 1/3)
lab = paste(rep('gene'),1:15)
head(networkmatrix(igraph_graph, lab, 'directed'))

neat documentation built on Jan. 7, 2021, 9:09 a.m.