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

View source: R/centralityFunctions.R

Compute local clustering coefficients, both signed and unsigned and both for weighted and for unweighted networks.

1 2 3 4 | ```
clustcoef_auto(x, thresholdWS = 0, thresholdON = 0)
clustWS(x, thresholdWS=0)
clustZhang(x)
clustOnnela(x, thresholdON=0)
``` |

`x` |
An undirected graph. Can be a |

`thresholdWS` |
The threshold used to binarize a weighted network |

`thresholdON` |
In the computation of Onnela's clustering coefficient |

`clustWS`

computes the clustering coefficient for unweighted networks introduced by Watts & Strogatz (1998) and the corresponding signed version (Costantini & Perugini, in press).
`ClustZhang`

computes the clustering coefficient for weighted networks introduced by Zhang & Horvath (2005) and the corresponding signed version (Costantini & Perugini, in press).
`clustOnnela`

computes the clustering coefficient for weighted networks introduced by Onnela et al. (2005) and the corresponding signed version (Costantini & Perugini, in press).
`clustering_auto`

automatically recognizes the kind of the input network `x`

(weighted vs. unweighted, signed vs. unsigned) and computes a subset of indices according to the kind of the network: signed indices are not computed for unsigned networks and weighted indices are not computed for unweighted networks. However the unsigned indices are computed for signed networks, by considering the absolute value of the weights, and the unweighted indices are computed for weighted networks, after a binarization according to the parameter `thresholdWS`

. `clustering_auto`

computes also the weighted clustering coefficient by Barrat et al. (2004), relying on function `transitivity`

from package `igraph`

.
For the computation of the local clustering coefficient, a node must have at least two neighbors: for nodes with less than two neighbors `NaN`

is returned.

A dataframe that includes one or more of the following indices.

`clustWS` |
The Watts & Strogatz's (1998) unweighted clustering coefficient |

`signed_clustWS` |
The signed version of the Watts & Strogatz's clustering coefficient |

`clustZhang` |
The Zhang & Horvath's (2005) weighted clustering coefficient |

`signed_clustZhang` |
The signed version of the Zhang & Horvath's (2005) clustering coefficient |

`clustOnnela` |
The Onnela et al.'s (2005) clustering coefficient |

`signed_clustOnnela` |
The signed version of the Onnela et al.'s (2005) clustering coefficient |

`clustBarrat` |
The Barrat et al.'s (2004) weighted clustering coefficient |

The function requires an undirected network. To convert a directed network to undirected use for instance function `upper.tri`

(see examples).

Part of the code has been adapted from package `WGCNA`

(Langfelder & Horvath, 2008).

Giulio Costantini ([email protected]), Sacha Epskamp ([email protected])

Barrat, A., Barthelemy, M., Pastor-Satorras, R., & Vespignani, A. (2004). The architecture of complex weighted networks. In Proc. Natl. Acad. Sci. USA 101 (pp. 3747-3752).

Costantini, G., Perugini, M. (in press), Generalization of Clustering Coefficients to Signed Correlation Networks

Langfelder, P., & Horvath, S. (2008). WGCNA: an R package for weighted correlation network analysis. BMC Bioinformatics, 9, 559.

Onnela, J. P., Saramaki, J., Kertesz, J., & Kaski, K. (2005). Intensity and coherence of motifs in weighted complex networks. Physical Review E, 71(6), 065103.

Watts, D. J., & Strogatz, S. H. (1998). Collective dynamics of "small-world" networks. Nature, 393(6684), 440-442.

Zhang, B., & Horvath, S. (2005). A general framework for weighted gene co-expression network analysis. Statistical Applications in Genetics and Molecular Biology, 4(1).

1 2 3 4 5 6 7 8 9 10 11 12 13 | ```
set.seed(1)
# generate a random (directed) network:
net_ig <- igraph::erdos.renyi.game(n=8, p.or.m=.4, type="gnp", directed=TRUE)
# convert it to an adjacency matrix:
net <- as.matrix(igraph:::get.adjacency(net_ig, type="both"))
# convert it to a signed and weighted network:
net <- net*matrix(rnorm(ncol(net)^2), ncol=ncol(net))
# make it undirected:
net[upper.tri(net)] <- t(net)[upper.tri(net)]
clustcoef_auto(net)
``` |

```
clustWS signed_clustWS clustZhang signed_clustZhang clustOnnela
1 0.0000000 0.0000000 0.00000000 0.00000000 0.00000000
2 0.3000000 0.1000000 0.05438561 0.01722044 0.08565427
3 0.3333333 -0.3333333 0.25843334 -0.25843334 0.10413827
4 0.0000000 0.0000000 0.00000000 0.00000000 0.00000000
5 0.6666667 0.6666667 0.24768680 0.24768680 0.18137595
6 1.0000000 1.0000000 0.14036980 0.14036980 0.37844734
7 0.0000000 0.0000000 0.00000000 0.00000000 0.00000000
8 0.3333333 0.0000000 0.10420660 -0.07715652 0.07968255
signed_clustOnnela clustBarrat
1 0.00000000 0.0000000
2 0.02317131 0.2223099
3 -0.10413827 0.4538294
4 0.00000000 0.0000000
5 0.18137595 0.5572809
6 0.37844734 1.0000000
7 0.00000000 0.0000000
8 -0.02445571 0.3511171
```

qgraph documentation built on April 25, 2018, 5:04 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.