Symmetrizes each adjacency matrix in a SummarizedExperiment by ensuring entries (i, j) and (j, i) are identical, using a specified combination function.
Arguments
- matrix_list
A SummarizedExperiment object containing adjacency matrices to symmetrize.
- weight_function
Character string or function. Method to combine entries (i, j) and (j, i). Options include
"mean","max","min", or a user-defined function.- nCores
Integer. Number of CPU cores to use for parallel processing. Defaults to the number of available workers in the current BiocParallel backend.
Value
A SummarizedExperiment object with symmetrized adjacency matrices, where for each matrix \(A[i, j] = A[j, i]\) for all \(i \neq j\).
Details
For each pair of off-diagonal elements (i, j) and (j, i):
If one value is zero, the non-zero value is used.
If both are non-zero, they are combined using the specified
weight_function.
Diagonal entries are preserved as-is and not modified.
Parallelization is managed via BiocParallel for improved performance.
Examples
data("toy_counts")
# Infer networks (toy_counts is already a MultiAssayExperiment)
networks <- infer_networks(
count_matrices_list = toy_counts,
method = "GENIE3",
nCores = 1
)
head(networks[[1]])
#> regulatoryGene targetGene weight
#> 1 HLA-B FTL 0.2104941
#> 2 HLA-A HLA-B 0.1541252
#> 3 FTL FTH1 0.1455606
#> 4 FTH1 FTL 0.1452081
#> 5 CD74 CXCR4 0.1442952
#> 6 HLA-B HLA-A 0.1419966
# Generate adjacency matrices
wadj_se <- generate_adjacency(networks)
swadj_se <- symmetrize(wadj_se, weight_function = "mean")
