get_association_matrix: Get association matrix

Description Usage Arguments Value Note Examples

View source: R/generics.R

Description

Get association matrix

Usage

1
get_association_matrix(x, tol = 10^-13, ...)

Arguments

x

Either a 'network', 'network_module', or 'matrix' object.

tol

A small tolerance threshold; any entry that is within tol from zero is set to zero.

...

Additional arguments.

Value

An association matrix with entry ij != 0 if node i and j are connected, and 0 otherwise. The diagonal entries are all zero.

Note

The connections in an adjacency matrix and association matrix may differ if the network contains multiple modules. The adjacency matrix only considers direct connections in the network, whereas the association matrix takes into account the fact that overlapping modules can create conditional dependencies between two genes in seperate modules (i.e. genes that don't have a direct connection in the graph).

Examples

1
2
3
4
5
6
7
# Create a random network with 10 nodes and add random edge weights.
nw <- random_network(10)
nw <- gen_partial_correlations(nw)
# Get adjacency matrix for the network or individual modules in the network.
get_association_matrix(nw)
module <- nw$modules[[1]]
get_association_matrix(module)

Example output

               1         2         3          4          5          6
 [1,]  0.0000000 0.0000000 0.0000000  0.0000000  0.0000000  0.0000000
 [2,]  0.0000000 0.0000000 0.0000000  0.0000000  0.0000000  0.0000000
 [3,]  0.0000000 0.0000000 0.0000000  0.3669184  0.3972928  0.2677742
 [4,]  0.0000000 0.0000000 0.3669184  0.0000000  0.0000000  0.0000000
 [5,]  0.0000000 0.0000000 0.3972928  0.0000000  0.0000000  0.0000000
 [6,]  0.0000000 0.0000000 0.2677742  0.0000000  0.0000000  0.0000000
 [7,] -0.3419121 0.0000000 0.4454483  0.0000000  0.0000000  0.4491131
 [8,]  0.0000000 0.3014140 0.0000000  0.0000000 -0.5090547 -0.3527970
 [9,]  0.2879340 0.3940522 0.0000000 -0.2794462  0.0000000  0.0000000
[10,]  0.4582986 0.0000000 0.0000000  0.0000000  0.0000000  0.0000000
               7          8          9        10
 [1,] -0.3419121  0.0000000  0.2879340 0.4582986
 [2,]  0.0000000  0.3014140  0.3940522 0.0000000
 [3,]  0.4454483  0.0000000  0.0000000 0.0000000
 [4,]  0.0000000  0.0000000 -0.2794462 0.0000000
 [5,]  0.0000000 -0.5090547  0.0000000 0.0000000
 [6,]  0.4491131 -0.3527970  0.0000000 0.0000000
 [7,]  0.0000000  0.3223657  0.0000000 0.3961943
 [8,]  0.3223657  0.0000000  0.0000000 0.0000000
 [9,]  0.0000000  0.0000000  0.0000000 0.0000000
[10,]  0.3961943  0.0000000  0.0000000 0.0000000
               1         2         3          4          5          6
 [1,]  0.0000000 0.0000000 0.0000000  0.0000000  0.0000000  0.0000000
 [2,]  0.0000000 0.0000000 0.0000000  0.0000000  0.0000000  0.0000000
 [3,]  0.0000000 0.0000000 0.0000000  0.3669184  0.3972928  0.2677742
 [4,]  0.0000000 0.0000000 0.3669184  0.0000000  0.0000000  0.0000000
 [5,]  0.0000000 0.0000000 0.3972928  0.0000000  0.0000000  0.0000000
 [6,]  0.0000000 0.0000000 0.2677742  0.0000000  0.0000000  0.0000000
 [7,] -0.3419121 0.0000000 0.4454483  0.0000000  0.0000000  0.4491131
 [8,]  0.0000000 0.3014140 0.0000000  0.0000000 -0.5090547 -0.3527970
 [9,]  0.2879340 0.3940522 0.0000000 -0.2794462  0.0000000  0.0000000
[10,]  0.4582986 0.0000000 0.0000000  0.0000000  0.0000000  0.0000000
               7          8          9        10
 [1,] -0.3419121  0.0000000  0.2879340 0.4582986
 [2,]  0.0000000  0.3014140  0.3940522 0.0000000
 [3,]  0.4454483  0.0000000  0.0000000 0.0000000
 [4,]  0.0000000  0.0000000 -0.2794462 0.0000000
 [5,]  0.0000000 -0.5090547  0.0000000 0.0000000
 [6,]  0.4491131 -0.3527970  0.0000000 0.0000000
 [7,]  0.0000000  0.3223657  0.0000000 0.3961943
 [8,]  0.3223657  0.0000000  0.0000000 0.0000000
 [9,]  0.0000000  0.0000000  0.0000000 0.0000000
[10,]  0.3961943  0.0000000  0.0000000 0.0000000

SeqNet documentation built on July 9, 2021, 9:08 a.m.