
Create a Consensus Adjacency Matrix from Multiple Networks
Source:R/create_consensus.R
create_consensus.Rd
Builds a consensus adjacency matrix from a list of networks using one
of three methods: "vote"
, "union"
, or "INet"
.
Usage
create_consensus(
adj_matrix_list,
method = "vote",
weighted_list = NULL,
theta = 0.04,
threshold = 0.5,
ncores = 1,
tolerance = 0.1,
nitermax = 50,
verbose = FALSE
)
Arguments
- adj_matrix_list
A list of binary adjacency matrices (square, 0/1) with identical dimensions and matching row/column names.
- method
Character string specifying the consensus strategy. One of:
"vote"
(default): An edge is included if supported by at leastthreshold
fraction of matrices."union"
: An edge is included if present in any matrix."INet"
: Combines normalized weighted matrices usingconsensusNet
.
- weighted_list
A list of weighted adjacency matrices (required if
method = "INet"
).- theta
Numeric. Tuning parameter passed to
consensusNet
(default:0.04
).- threshold
Numeric between 0 and 1. Threshold for "vote" and "INet" methods. Default is
0.5
.- ncores
Integer. Number of CPU cores to use when
method = "INet"
. Default is1
.- tolerance
Numeric. Tolerance for differences between similar graphs in INet method. Default is
0.1
.- nitermax
Integer. Maximum number of iterations for INet algorithm. Default is
50
.- verbose
Logical. If TRUE, display verbose output for INet method. Default is
FALSE
.
Details
Consensus construction depends on the selected method:
- vote
Counts the presence of each edge across all matrices and includes edges supported by at least
threshold × N
matrices.- union
Includes any edge that appears in any matrix.
- INet
Multiplies binary matrices by corresponding weighted matrices, normalizes the results, and applies
consensusNet
to generate a consensus network.
For "INet", both binary and weighted adjacency matrices must be provided with matching dimensions.
Examples
data(count_matrices)
networks <- infer_networks(
count_matrices_list = count_matrices,
method = "GENIE3",
nCores = 1
)
head(networks[[1]])
#> regulatoryGene targetGene weight
#> 1 ARPC2 ARPC3 0.2002341
#> 2 HLA-A CD74 0.1942305
#> 3 CD3E CD3D 0.1647460
#> 4 ARPC3 ARPC2 0.1610786
#> 5 CD3E JUN 0.1571037
#> 6 HLA-E FOS 0.1500092
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.99,
nCores = 1,
debug = TRUE
)
#> [Method: GENIE3] Matrix 1 → Cutoff = 0.10286
#> [Method: GENIE3] Matrix 2 → Cutoff = 0.10876
#> [Method: GENIE3] Matrix 3 → Cutoff = 0.10636
head(binary_listj[[1]])
#> ACTG1 ARPC2 ARPC3 BTF3 CD3D CD3E CD74 CFL1 COX4I1 COX7C CXCR4 EEF1A1
#> ACTG1 0 0 0 0 0 0 0 0 0 0 0 0
#> ARPC2 0 0 1 0 0 0 0 0 0 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 0 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 0 0 0 0 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 0 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 0 0 0 0 0 0 0
#> CD3E 0 0 0 0 0 0 0 0 0 0
consensus <- create_consensus(binary_listj, method = "vote")
head(consensus)
#> ACTG1 ARPC2 ARPC3 BTF3 CD3D CD3E CD74 CFL1 COX4I1 COX7C CXCR4 EEF1A1
#> ACTG1 0 0 0 0 0 0 0 0 0 0 0 0
#> ARPC2 0 0 1 0 0 0 0 0 0 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 0 0 0 0 0 0 0
#> CD3E 0 0 0 0 0 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 0 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 0
#> ARPC3 0 0 0 0 0 0 0 0 0 0 0 0 0
#> BTF3 0 0 0 0 0 0 0 0 0 0 0 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 0 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 0 0 0 0 0 0 0
#> CD3E 0 0 0 0 0 0 0 0 0 0