connect_module_structure: Connect disconnected components in an adjacency matrix

Description Usage Arguments Value Note Examples

View source: R/modules.R

Description

Connect disconnected components in an adjacency matrix

Usage

1
2
connect_module_structure(adj, weights = NULL, alpha = 100, beta = 1,
  epsilon = 10^-5)

Arguments

adj

An adjacency matrix to modify.

weights

(Optional) weights used for sampling nodes.

alpha

A positive value used to parameterize the Beta distribution.

beta

A positive value used to parameterize the Beta distribution.

epsilon

A small constant added to the sampling probability of each node.

Value

A modified adjacency matrix

Note

When connecting two components, a node is sampled from each with probability proportional to ecdf(weights)(weights)^eta + epsilon, where 'weights' are subset to only those nodes in the corresponding component. When 'eta' = 0, this results in uniform sampling. When 'eta' > 0, nodes having larger 'weight' are more likely to be selected, where 'weight' is equal to 'weights' + degree. (If Arugment 'weights' is NULL, then 'weight' is simply the node degree).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# This function is used in `random_module_structure()` to reconnect any
# disconnected components. To demonstrate, we'll create a random structure,
# remove connections to one of the nodes (that node will then be a disconnected
# component), and use `connect_module_structure()` to reconnect it back to
# the main component.
adj <- random_module_structure(10)
adj <- remove_connections_to_node(adj, 1, prob_remove = 1)
# Note that there are now two components in the network:
components_in_adjacency(adj) 
g <- plot_network(adj)
# After connecting, the network contains one component.
adj <- connect_module_structure(adj)
components_in_adjacency(adj) 
plot_network(adj, g)

tgrimes/SeqNet documentation built on Sept. 1, 2020, 7:50 a.m.