Skip to contents

Constructs adjacency matrices from a list of data frames, each representing weighted gene–gene interactions.

Usage

generate_adjacency(df_list, nCores = 1)

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 to Gene2.

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.1958075
#> 2          HLA-A       CD74 0.1825388
#> 3           CD3E        JUN 0.1591790
#> 4          HLA-E        FOS 0.1559576
#> 5          ARPC3      ARPC2 0.1531626
#> 6           CD3E       CD3D 0.1510760

wadj_list <- generate_adjacency(networks)
head(wadj_list[[1]])
#>            ACTG1      ARPC2      ARPC3       BTF3       CD3D       CD3E
#> ACTG1 0.00000000 0.02493511 0.01961513 0.01652989 0.02073884 0.01273021
#> ARPC2 0.02922446 0.00000000 0.19580749 0.03729172 0.02895152 0.01989290
#> ARPC3 0.04587756 0.15316255 0.00000000 0.01758217 0.04148737 0.02517191
#> BTF3  0.01668527 0.05526111 0.02164676 0.00000000 0.02587963 0.02079854
#> CD3D  0.01928397 0.01512428 0.02348295 0.02695807 0.00000000 0.05856223
#> CD3E  0.01326815 0.01830392 0.01814102 0.01412293 0.15107604 0.00000000
#>             CD74       CFL1     COX4I1      COX7C      CXCR4     EEF1A1
#> ACTG1 0.08883134 0.13241443 0.02219209 0.04150163 0.02112254 0.03575508
#> ARPC2 0.02595408 0.03649671 0.07782606 0.02715714 0.02192692 0.01735406
#> ARPC3 0.01558391 0.01508012 0.01982806 0.01432990 0.01874117 0.05478942
#> BTF3  0.01184714 0.03926069 0.02328771 0.01977217 0.02031861 0.01937873
#> CD3D  0.01400183 0.03479437 0.02535686 0.01627593 0.02098537 0.02958265
#> CD3E  0.02493609 0.03514325 0.01520519 0.03606816 0.01779641 0.01616632
#>            EEF1D       EEF2       EIF1      EIF3K     EIF4A2        FOS
#> ACTG1 0.10265551 0.02141465 0.03019781 0.03145272 0.03400668 0.03012456
#> ARPC2 0.01989051 0.02000929 0.02112145 0.01709886 0.02050362 0.01373497
#> ARPC3 0.01602088 0.02512840 0.01846733 0.02002010 0.01764248 0.03062107
#> BTF3  0.02927805 0.03136549 0.02183571 0.04800538 0.01874525 0.02027003
#> CD3D  0.01870759 0.05967515 0.01387757 0.02136977 0.04034910 0.01576583
#> CD3E  0.03359357 0.05456821 0.03711578 0.06156763 0.01552984 0.03021396
#>             FTH1        FTL     GNB2L1      HLA-A       HLA-B      HLA-C
#> ACTG1 0.01400532 0.01844659 0.02189152 0.04448960 0.020542365 0.02162012
#> ARPC2 0.01915096 0.01339853 0.01863569 0.02155302 0.030603201 0.03120906
#> ARPC3 0.02532727 0.02243639 0.01100061 0.02116910 0.028595142 0.02207077
#> BTF3  0.02252678 0.06829034 0.03188525 0.02820518 0.046245807 0.02252482
#> CD3D  0.01422817 0.02375772 0.01059342 0.03961776 0.009829607 0.02700100
#> CD3E  0.02553187 0.05977088 0.05362244 0.05350131 0.027918739 0.02712502
#>            HLA-E        JUN       JUNB     MYL12B       MYL6       NACA
#> ACTG1 0.02950453 0.03440864 0.01909864 0.02510698 0.02487530 0.06107672
#> ARPC2 0.13593169 0.01845333 0.01449122 0.02079244 0.01891664 0.03408373
#> ARPC3 0.06226122 0.01673868 0.06776126 0.02295754 0.02177739 0.07866394
#> BTF3  0.02037207 0.01437712 0.05260025 0.02134463 0.02518671 0.04921457
#> CD3D  0.01891514 0.01346938 0.02215629 0.04355098 0.07321885 0.01801307
#> CD3E  0.04109074 0.15917897 0.02240135 0.01607750 0.02633425 0.01116767
#>           PABPC1       PFN1     TMSB4X      UBA52        UBC
#> ACTG1 0.02169809 0.06506835 0.08049746 0.02964736 0.02651774
#> ARPC2 0.01498962 0.02953058 0.03115680 0.01372645 0.02052449
#> ARPC3 0.03193658 0.01927519 0.02367370 0.03580187 0.02763674
#> BTF3  0.03579083 0.01986354 0.02023513 0.01480496 0.04506863
#> CD3D  0.01493916 0.01669910 0.05705149 0.01751023 0.02310793
#> CD3E  0.01739301 0.03117878 0.01892572 0.02286621 0.04043658