Skip to contents

Evaluates similarity between a ground truth community structure and one or more predicted community structures. Computes community assignment metrics (VI, NMI, ARI) and raw topological properties (Modularity, Number of Communities, Density, Transitivity). Visualizes results via a radar plot for community assignment and bar plots for topology.

Usage

community_similarity(control_output, predicted_list)

Arguments

control_output

A list output from community_path() representing the ground truth network. Must contain a graph (igraph object) and communities$membership.

predicted_list

A list of lists, each output from community_path() representing predicted networks to compare.

Value

A list containing:

  • community_metrics: A data frame with VI, NMI, and ARI scores for each prediction.

  • topology_measures: A data frame with raw topological metrics for each prediction.

  • control_topology: A list of raw topological metrics for the ground truth network.

Details

This function requires the igraph and fmsb packages. Community similarity is measured using variation of information (VI), normalized mutual information (NMI), and adjusted Rand index (ARI). Topological properties are compared by directly plotting raw values without normalization.

Examples

data(count_matrices)
data(adj_truth)
networks <- infer_networks(
    count_matrices_list = count_matrices,
    method = "GENIE3",
    nCores = 1
)
head(networks[[1]])
#>   regulatoryGene targetGene    weight
#> 1          ARPC2      ARPC3 0.2073381
#> 2          HLA-A       CD74 0.1839465
#> 3          HLA-E        FOS 0.1588802
#> 4          ARPC3      ARPC2 0.1555905
#> 5           CD3E        JUN 0.1533672
#> 6         GNB2L1      UBA52 0.1464058

wadj_list <- generate_adjacency(networks)
swadj_list <- symmetrize(wadj_list, weight_function = "mean")

binary_listj <- cutoff_adjacency(
    count_matrices = count_matrices,
    weighted_adjm_list = swadj_list,
    n = 2,
    method = "GENIE3",
    quantile_threshold = 0.95,
    nCores = 1,
    debug = TRUE
)
#> [Method: GENIE3] Matrix 1 → Cutoff = 0.06433
#> [Method: GENIE3] Matrix 2 → Cutoff = 0.06662
#> [Method: GENIE3] Matrix 3 → Cutoff = 0.06582
head(binary_listj[[1]])
#>       ACTG1 ARPC2 ARPC3 BTF3 CD3D CD3E CD74 CFL1 COX4I1 COX7C CXCR4 EEF1A1
#> ACTG1     0     0     0    0    0    0    1    1      0     0     0      0
#> ARPC2     0     0     1    0    0    0    0    0      1     0     0      0
#> ARPC3     0     1     0    0    0    0    0    0      0     0     0      0
#> BTF3      0     0     0    0    0    0    0    0      0     0     0      0
#> CD3D      0     0     0    0    0    1    0    0      0     0     0      0
#> CD3E      0     0     0    0    1    0    0    0      0     0     0      0
#>       EEF1D EEF2 EIF1 EIF3K EIF4A2 FOS FTH1 FTL GNB2L1 HLA-A HLA-B HLA-C HLA-E
#> ACTG1     1    0    0     0      0   0    0   0      0     0     0     0     0
#> ARPC2     0    0    0     0      0   0    0   0      0     0     0     0     1
#> ARPC3     0    0    0     0      0   0    0   0      0     0     0     0     0
#> BTF3      0    0    0     0      0   0    0   1      0     0     1     0     0
#> CD3D      0    0    0     0      0   0    0   0      0     0     0     0     0
#> CD3E      0    0    0     0      0   0    0   0      0     1     0     0     0
#>       JUN JUNB MYL12B MYL6 NACA PABPC1 PFN1 TMSB4X UBA52 UBC
#> ACTG1   0    0      0    0    0      0    0      0     0   0
#> ARPC2   0    0      0    0    0      0    0      0     0   0
#> ARPC3   0    0      0    0    0      0    0      0     0   0
#> BTF3    0    0      0    0    0      0    0      0     0   0
#> CD3D    0    0      0    1    0      0    0      0     0   0
#> CD3E    1    0      0    0    0      0    0      0     0   0

consensus <- create_consensus(binary_listj, method = "vote")
comm_cons <- community_path(consensus)
#> Detecting communities...

#> Running pathway enrichment...
comm_truth <- community_path(adj_truth)
#> Detecting communities...

#> Running pathway enrichment...
#> 'select()' returned 1:1 mapping between keys and columns
#> Reading KEGG annotation online: "https://rest.kegg.jp/link/hsa/pathway"...
#> Reading KEGG annotation online: "https://rest.kegg.jp/list/pathway/hsa"...
#> 'select()' returned 1:1 mapping between keys and columns
#> 'select()' returned 1:1 mapping between keys and columns

sim_score <- community_similarity(comm_truth, list(comm_cons))