link_positions: Calculate link position vectors

Description Usage Arguments Details Value References Examples

View source: R/link_positions.r

Description

Counts the number of times each link in a network occurs in each unique link position within the motifs

Usage

1
link_positions(M, six_node = FALSE, weights, normalisation = "none")

Arguments

M

A numeric matrix representing interactions between two groups of nodes. Each row corresponds to a node in one level and each column corresponds to a node in the other level. Elements of M are positive numbers if nodes interact, and 0 otherwise. Formally, M is a biadjacency matrix. When nodes i and j interact, m_ij > 0; if they do not interact, m_ij = 0.

six_node

Logical; should positions in six node motifs be counted? Defaults to FALSE.

weights

Logical; Should weights of the links be taken into account?

normalisation

Which normalisation should be used: 'none','sum', 'position', 'sizeclass', 'sizeclass_plus1', 'sizeclass_NAzero', 'levelsize', 'levelsize_plus1', 'levelsize_NAzero','motif', 'motif_plus1' or 'motif_NAzero'? Defaults to "none". (see details)

Details

Counts the number of times each link in a network occurs in each of the 29 (if six_node = FALSE) or 106 (if six_node = TRUE) unique link positions within motifs (to quantify a link's structural role). If six_node = FALSE, link positions in all motifs containing between 2 and 5 nodes are counted. If six_node = TRUE, link positions in all motifs containing between 2 and 6 nodes are counted. Analyses where six_node = FALSE are substantially faster than when six_node = TRUE, especially for large networks. For large networks, counting six node motifs is also memory intensive. In some cases, R can crash if there is not enough memory.

If interactions are weighted (non-zero matrix elements take values other than 1), these can be incorporated by setting weights = TRUE. If weights = TRUE, the function will return the number of times each link occurs in each position, multiplied by the weight of the link, following Mora et al. (2018).

Links between nodes with more interactions will tend to appear in more positions. Normalisation helps control for this effect. bmotif include four types of normalisation:

If a matrix is provided without row or column names, default names will be assigned: the first row will be called called 'r1', the second row will be called 'r2' and so on. Similarly, the first column will be called 'c1', the second column will be called 'c2' and so on.

Value

Returns a data frame with one column for each link position: 29 columns if six_node is FALSE, and 106 columns if six_node is TRUE. Columns names are given as "lpx" where x is the ID of the position as described in the motif dictionary. To view the 'motif dictionary' showing which link position a given ID corresponds to, enter vignette("bmotif-dictionary").

Each row corresponds to one link in the network. Row names are gives as "x – y", where x is the species in the first level (rows) and y is the species in the second level (columns).

By default, the elements of the data frame will be the raw link position counts. If weight = TRUE, link position counts will be multiplied by the link weight. If normalisation is set to "sum", "sizeclass" or "position", the elements will be normalised position counts as described above.

References

Mora, B.B., Cirtwill, A.R. and Stouffer, D.B., 2018. pymfinder: a tool for the motif analysis of binary and quantitative complex networks. bioRxiv, 364703.

Simmons, B. I., Sweering, M. J. M., Dicks, L. V., Sutherland, W. J. and Di Clemente, R. bmotif: a package for counting motifs in bipartite networks. bioRxiv. doi: 10.1101/302356

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
set.seed(123)
row <- 10
col <- 10

# link positions in a binary network
m <- matrix(sample(0:1, row*col, replace=TRUE), row, col)
link_positions(M = m, six_node = TRUE, weights = FALSE, normalisation = "none")

# link positions in a weighted network
m[m>0] <- stats::runif(sum(m), 0, 100)
link_positions(M = m, six_node = TRUE, weights = TRUE, normalisation = "none")

bmotif documentation built on Sept. 13, 2020, 5:10 p.m.