
Generate Adjacency Matrices from Gene Interaction Tables
Source:R/generate_adjacency.R
generate_adjacency.RdConstructs adjacency matrices from a list of data frames (network edge lists) and returns them in a SummarizedExperiment object.
Arguments
- df_list
A list of data frames. Each data frame must have three columns:
- Gene1
Character. First gene in the interaction.
- Gene2
Character. Second gene in the interaction.
- Weight
Numeric. Weight or strength of the interaction from
Gene1toGene2.
- nCores
Integer. Number of CPU cores to use for parallel processing. Defaults to the number of available workers from the current BiocParallel backend.
Value
A SummarizedExperiment object where each assay is a square numeric adjacency matrix (p×p genes). Diagonal entries are set to zero (no self-interactions).
Details
The function first identifies all unique genes across all data frames to define the matrix dimensions. For each interaction table, it places the corresponding weights at the appropriate gene-pair positions. Parallelization is handled by BiocParallel for improved performance on multiple datasets.
Missing weights (NA) are ignored during construction. Only
gene pairs matching the global gene list are inserted.
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.2036247
#> 2 HLA-B HLA-A 0.1552891
#> 3 CD74 CXCR4 0.1528027
#> 4 HLA-A HLA-B 0.1483888
#> 5 FTL FTH1 0.1440317
#> 6 FTH1 FTL 0.1376746
# Generate adjacency matrices
wadj_se <- generate_adjacency(networks) # returns SummarizedExperiment
head(wadj_se[[1]])
#> [1] "ACTG1" "ARPC2" "ARPC3" "BTF3" "CD3D" "CD3E"