This function performs a statistical assessment of the overlap (number of edges) between a graph and a set of node IDs. This is useful for eg assessing the overlap (number of edges) between a PPI network and a set of node IDs representing protein sets of interests such as eg. a CORUM complex, a KEGG pathway, or a set of proteins associated with a disease.

testConnectivity(ids, gr, nr.reps = 1000)

Arguments

ids

character. A set of ids. Need at least three IDs present as nodes in the graph. Can also be a list with each element being a set of IDs to sequentially test a collection of sets.

gr

graph. An object of class graphNEL from the graph package.

nr.reps

integer. Number of replications. Defaults to 1000.

Value

A p-value that is calculated as for a permutation test, ie as the relative frequency of obtaining as many or more edges in a randomized setup when compared to the observed number of edges within the input set of node IDs.

Details

The test is based on network randomization. In each replication, the network is randomized/re-wired and the number of edges within the input set of node IDs is compared against the observed number of edges. The observed number of edges corresponds here to the number of edges within the input set of node IDs based on the true / non-randomized version of the input graph.

Examples

  library(graph)
  n <- LETTERS[1:10]
  edl <- vector("list", length = 10)
  names(edl) <- n
  for(i in 1:10) edl[[i]] <- list(edges = 11 - i)
  gr <- graphNEL(nodes = n, edgeL = edl)
  
  ids <- LETTERS[c(1:2, 9:10)]
  testConnectivity(ids, gr, nr.reps = 100) 
#> [1] 0.02970297