View source: R/centralityFunctions.R
clustcoef_auto | R Documentation |
Compute local clustering coefficients, both signed and unsigned and both for weighted and for unweighted networks.
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 (giulio.costantini@unimib.it), Sacha Epskamp (mail@sachaepskamp.com)
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).
centrality_auto
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.