cpCommunitySizeDistribution: Plotting Clique Percolation Community Size Distribution

Description Usage Arguments Details Value Author(s) Examples

View source: R/cpCommunitySizeDistribution.R

Description

Function for plotting the frequency distribution of community sizes from clique percolation community detection.

Usage

1
cpCommunitySizeDistribution(list.of.communities, color.line = "#bc0031")

Arguments

list.of.communities

List object taken from results of cpAlgorithm function; see also cpAlgorithm

color.line

string indicating the color of the line in the plot as described in par; default is "#bc0031"

Details

The function takes the results of cpAlgorithm (see also cpAlgorithm), that is, either the list.of.communities.numbers or the list.of.communities.labels and plots the community size distribution. If there are no communities, no plot can be generated. An error is printed indicating this.

Value

The function primarily plots the community size distribution. Additionally, it returns a list with a data frame containing all community sizes and their frequencies (size.distribution).

Author(s)

Jens Lange, lange.jens@outlook.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# create qgraph object; 150 nodes; 1/7 of all edges are different from zero
W <- matrix(c(0), nrow = 150, ncol = 150, byrow = TRUE)
set.seed(4186)
W[upper.tri(W)] <- sample(c(rep(0,6),1), length(W[upper.tri(W)]), replace = TRUE)
rand_w <- stats::rnorm(length(which(W == 1)), mean = 0.3, sd = 0.1)
W[which(W == 1)] <- rand_w
W <- Matrix::forceSymmetric(W)
W <- qgraph::qgraph(W, DoNotPlot = TRUE)

# run clique percolation for weighted networks
cp.results <- cpAlgorithm(W, k = 3, method = "weighted", I = 0.38)

# plot community size distribution with blue line
cp.size.dist <- cpCommunitySizeDistribution(cp.results$list.of.communities.numbers,
                                            color.line = "#0000ff")

chr1swallace/FasterCliquePercolation documentation built on Dec. 19, 2021, 3:59 p.m.