
Generate Adjacency Matrices from Gene Interaction Tables
Source:R/generate_adjacency.R
generate_adjacency.Rd
Constructs adjacency matrices from a list of data frames, each representing weighted gene–gene interactions.
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
Gene1
toGene2
.
- 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 list of square numeric adjacency matrices. Each matrix has genes as row and column names, and weights as values. 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("count_matrices")
networks <- infer_networks(
count_matrices_list = count_matrices,
method = "GENIE3",
nCores = 1
)
head(networks[[1]])
#> regulatoryGene targetGene weight
#> 1 ARPC2 ARPC3 0.1959910
#> 2 HLA-A CD74 0.1875812
#> 3 ARPC3 ARPC2 0.1626807
#> 4 CD3E JUN 0.1624397
#> 5 HLA-E FOS 0.1538525
#> 6 CD3E CD3D 0.1494264
wadj_list <- generate_adjacency(networks)
head(wadj_list[[1]])
#> ACTG1 ARPC2 ARPC3 BTF3 CD3D CD3E
#> ACTG1 0.00000000 0.02832299 0.01753526 0.01699788 0.02230549 0.01528201
#> ARPC2 0.03317720 0.00000000 0.19599101 0.03769546 0.03245881 0.01961583
#> ARPC3 0.04323435 0.16268067 0.00000000 0.01744219 0.04161286 0.02439839
#> BTF3 0.01807112 0.06549026 0.01762781 0.00000000 0.02593619 0.01639606
#> CD3D 0.01986211 0.01592791 0.02782829 0.02412273 0.00000000 0.06987442
#> CD3E 0.01286351 0.01842987 0.02071226 0.01497493 0.14942643 0.00000000
#> CD74 CFL1 COX4I1 COX7C CXCR4 EEF1A1
#> ACTG1 0.087638951 0.12659853 0.01735412 0.04490139 0.02248803 0.03506407
#> ARPC2 0.022661764 0.03592273 0.08346611 0.03163808 0.02365879 0.02072585
#> ARPC3 0.022493855 0.01762201 0.02242091 0.01685321 0.02019137 0.04907603
#> BTF3 0.016210343 0.04002826 0.02533011 0.01905180 0.02168921 0.01874530
#> CD3D 0.008804433 0.03789438 0.02898106 0.01633403 0.02213540 0.02817097
#> CD3E 0.024574143 0.03507785 0.01439576 0.02762145 0.01711345 0.01987653
#> EEF1D EEF2 EIF1 EIF3K EIF4A2 FOS
#> ACTG1 0.09688009 0.02204211 0.02980673 0.02963460 0.02996928 0.03174129
#> ARPC2 0.01805174 0.01637683 0.02161916 0.01833129 0.02394727 0.01811026
#> ARPC3 0.01981155 0.02763186 0.01875709 0.02124901 0.01954239 0.02959960
#> BTF3 0.03222559 0.03271172 0.02065869 0.04573911 0.01938410 0.02141429
#> CD3D 0.02402568 0.06072265 0.01421886 0.02074864 0.04103970 0.01504695
#> CD3E 0.03600947 0.05395135 0.04605847 0.05159757 0.01531389 0.02909144
#> FTH1 FTL GNB2L1 HLA-A HLA-B HLA-C
#> ACTG1 0.01388872 0.01553574 0.02431071 0.04061202 0.02076803 0.02366466
#> ARPC2 0.01782208 0.01341718 0.01762429 0.02200161 0.03177205 0.03093026
#> ARPC3 0.02291710 0.02492107 0.01277969 0.02511682 0.02985012 0.02117155
#> BTF3 0.02641253 0.06628646 0.02784850 0.02578200 0.04887162 0.02512390
#> CD3D 0.01415634 0.02171067 0.01159030 0.03404427 0.01012676 0.02874007
#> CD3E 0.02749416 0.06026172 0.05179918 0.04723050 0.02859215 0.02271152
#> HLA-E JUN JUNB MYL12B MYL6 NACA
#> ACTG1 0.03830224 0.02974235 0.01920442 0.02701545 0.02116263 0.05819878
#> ARPC2 0.13961418 0.01816109 0.01616408 0.02231932 0.01859323 0.03528330
#> ARPC3 0.06545537 0.01689630 0.06874730 0.02487870 0.01925972 0.07622093
#> BTF3 0.01895971 0.01788382 0.05239739 0.02136046 0.02401155 0.05094271
#> CD3D 0.01593608 0.01002373 0.02351432 0.04312919 0.07730301 0.02047962
#> CD3E 0.03576888 0.16243965 0.01806702 0.01471705 0.02849379 0.01278128
#> PABPC1 PFN1 TMSB4X UBA52 UBC
#> ACTG1 0.02176479 0.06346611 0.08263517 0.03339064 0.02273925
#> ARPC2 0.01528026 0.02879681 0.03143849 0.01251786 0.02393751
#> ARPC3 0.03000109 0.01730300 0.02121940 0.03440732 0.02790380
#> BTF3 0.03614242 0.01912414 0.01739369 0.01389901 0.04278149
#> CD3D 0.01468346 0.01655120 0.05144660 0.01767825 0.02492923
#> CD3E 0.02078488 0.03268575 0.01701430 0.02190365 0.03661500