CrosstalkX: Mutual Information–Based Inference of Pathway Crosstalk

Menna Arafat

2026-02-15

knitr::opts_chunk$set( 
  fig.path = "fig/",
  fig.align = "center",
  collapse = TRUE, comment = ">")

Under the hood of CrosstalkX

Pathway enrichment approaches such as ORA and GSEA summarize transcriptomic changes, but enriched pathways are often interpreted in isolation. CrosstalkX adds a systems layer by quantifying functional coupling between terms (pathways and regulators) using expression data, a background interaction network, and mutual information (MI).

The central idea is to move beyond “which pathways are enriched?” toward “which enriched pathways and regulators are coupled in the expression profile, and how strong is that coupling?” CrosstalkX does this by estimating MI on gene–gene edges, aggregating edge-level evidence to term–term scores, and assigning permutation-based significance.

Overview:

The tutorial proceeds in three stages. First, it prepares expression and DE-derived inputs. Second, it prioritizes genes by testing whether their network neighborhoods are enriched for DE genes more than expected by chance. Third, it performs enrichment on prioritized genes, then infers significant term–term crosstalk and visualizes the result.

Input

CrosstalkX expects a two-column enrichment table: 1. Pathway/term identifier 2. Gene hits as a single string separated by “/” or “,” And expression matrix where row names are genes and column names are samples

Installation

 # install.packages("devtools")
 # devtools::install_github("Menna-Arafat/CrosstalkX", 
 # build_vignettes = TRUE, dependencies = TRUE)

Load libraries and example data

#load lib
library(CrosstalkX)
library(dplyr)
library(tibble)

Module0: Data preparation

# Expression matrix is expected as genes × samples, with gene IDs in rownames.
# group_names is used downstream to support group-aware preprocessing (e.g., handling NAs).
expr = CrosstalkX::expr |> tibble::column_to_rownames("V1")
group_names = c("Normal", "Tumor")

# Differential expression results are used in two ways:
# 1) fold-change values (linear FC) for pathway enrichment with directionality
# 2) t-statistics for TF activity inference based on downstream targets
de_res = CrosstalkX::de_res |> tibble::column_to_rownames("V1")

# Convert log2 fold change to linear fold change for enrichment inputs that use FC values.
de_res$FC = 2 ^ de_res$log2FoldChange
de_fc = setNames(de_res$FC, row.names(de_res))

# Define DE genes for the gene-prioritization step.
# These represent the "labels" whose local enrichment in the network will be tested.
de_genes = de_res |>
            dplyr::filter(abs(log2FoldChange) >= log2(2), padj <= 0.01) |>
            row.names()

# Compute a signed statistic for TF enrichment.
# The t-statistic captures both effect direction and uncertainty (via the SE).
de_res$t_stat = de_res$log2FoldChange / de_res$lfcSE
tstat_named = setNames(de_res$t_stat, rownames(de_res))

Module1: Gene prioritization by DE-neighborhood enrichment

# retrieve_net() provides the interaction scaffold used to define each gene's neighborhood.
# If net is not supplied, CrosstalkX loads its bundled default network.
net = retrieve_net()

# prioritize_de() tests each gene of interest for an unusually high number of DE neighbors.
# It uses permutation to build an empirical null distribution, then returns significant genes.
myres = prioritize_de(genes_oi = row.names(expr), de_genes = de_genes, net = net)
top_de= myres$sig
head(top_de, 100)
>              gene obs_de_neighbors null_mean   null_sd z_empirical       pval
> GAPDH       GAPDH              456    416.91 15.396507    2.538888 0.01980198
> SP1           SP1              384    317.30 13.185928    5.058423 0.00990099
> FN1           FN1              298    220.50 10.424815    7.434185 0.00990099
> CD4           CD4              289    199.80  9.718253    9.178604 0.00990099
> HIF1A       HIF1A              277    248.16 10.944045    2.635223 0.00990099
> TGFB1       TGFB1              239    181.17  9.452759    6.117791 0.00990099
> FOS           FOS              238    192.84 10.508986    4.297275 0.00990099
> MMP9         MMP9              232    168.29  8.299075    7.676759 0.00990099
> CCNB1       CCNB1              222    158.48 10.798878    5.882093 0.00990099
> EGF           EGF              222    181.60 10.060424    4.015736 0.00990099
> CDC20       CDC20              218    140.00  8.436333    9.245723 0.00990099
> CREB1       CREB1              217    185.33  9.909749    3.195843 0.00990099
> CCND1       CCND1              213    192.77 10.741080    1.883423 0.03960396
> TOP2A       TOP2A              212    141.00  9.409859    7.545277 0.00990099
> AURKA       AURKA              211    132.08  8.625403    9.149717 0.00990099
> PLK1         PLK1              208    155.76  8.818163    5.924136 0.00990099
> CDCA8       CDCA8              200    131.32  8.222757    8.352429 0.00990099
> AURKB       AURKB              198    129.57  8.673954    7.889136 0.00990099
> BIRC5       BIRC5              195    113.82  7.873212   10.310912 0.00990099
> TLR4         TLR4              194    149.68  8.146239    5.440547 0.00990099
> BUB1B       BUB1B              192    115.07  8.306326    9.261616 0.00990099
> KIF11       KIF11              190    104.71  7.878234   10.826031 0.00990099
> CEBPB       CEBPB              190    164.22  9.296008    2.773234 0.00990099
> FOXM1       FOXM1              187    107.98  7.714580   10.242942 0.00990099
> KIF23       KIF23              185    105.66  8.033038    9.876712 0.00990099
> CALM3       CALM3              185    158.64  9.838617    2.679238 0.01980198
> CCNB2       CCNB2              184    105.28  8.026572    9.807425 0.00990099
> CDC6         CDC6              184    112.23  8.653667    8.293594 0.00990099
> ERBB2       ERBB2              184    160.64  9.474602    2.465539 0.03960396
> BUB1         BUB1              180     97.86  7.388252   11.117651 0.00990099
> EXO1         EXO1              179    111.51  8.843756    7.631373 0.00990099
> PXDN         PXDN              179    144.25  8.976259    3.871323 0.00990099
> MAD2L1     MAD2L1              178    114.91  8.894551    7.093107 0.00990099
> CALML5     CALML5              177    145.24  9.922040    3.200955 0.00990099
> CDK2         CDK2              177    154.62  9.605112    2.330009 0.01980198
> PECAM1     PECAM1              170    120.74  7.144426    6.894885 0.00990099
> KIF2C       KIF2C              168     85.07  6.284911   13.195096 0.00990099
> KIF20A     KIF20A              168     86.08  6.445858   12.708936 0.00990099
> ANLN         ANLN              168     95.44  7.906422    9.177349 0.00990099
> ITGAM       ITGAM              168    115.86  8.686481    6.002431 0.00990099
> CD34         CD34              166    115.39  7.462898    6.781548 0.00990099
> ICAM1       ICAM1              166    124.15  8.037004    5.207164 0.00990099
> E2F1         E2F1              165    147.13  9.480075    1.885006 0.04950495
> RRM2         RRM2              162     90.29  7.785372    9.210863 0.00990099
> UBE2C       UBE2C              162    104.13  7.975537    7.255938 0.00990099
> NUF2         NUF2              160     75.44  6.478122   13.053166 0.00990099
> MKI67       MKI67              160     74.61  7.020741   12.162533 0.00990099
> ESPL1       ESPL1              160     92.61  7.265381    9.275495 0.00990099
> FEN1         FEN1              160    105.50  7.944886    6.859759 0.00990099
> EGR1         EGR1              159    137.78  8.778509    2.417267 0.01980198
> TTK           TTK              157     72.09  6.993641   12.141030 0.00990099
> MMP2         MMP2              157    113.89  7.771867    5.546930 0.00990099
> FOXO1       FOXO1              157    139.48  7.709996    2.272375 0.02970297
> NDC80       NDC80              154     74.40  6.466698   12.309219 0.00990099
> MCM10       MCM10              154     75.48  7.178081   10.938857 0.00990099
> DLGAP5     DLGAP5              153     66.39  6.256948   13.842213 0.00990099
> COL1A1     COL1A1              153    107.73  7.603634    5.953732 0.00990099
> NEK2         NEK2              152     79.18  6.440685   11.306251 0.00990099
> SOX9         SOX9              151    101.47  7.521625    6.585013 0.00990099
> RACGAP1   RACGAP1              149     80.63  6.817469   10.028649 0.00990099
> APOE         APOE              149    117.03  7.407961    4.315628 0.00990099
> CDK4         CDK4              149    128.35  9.197469    2.245183 0.00990099
> ITGB1       ITGB1              149    133.57  9.225848    1.672475 0.04950495
> CDT1         CDT1              148     87.13  6.995893    8.700819 0.00990099
> KDR           KDR              148    117.32  7.532931    4.072784 0.00990099
> KIF4A       KIF4A              147     72.86  6.010126   12.335848 0.00990099
> PTTG1       PTTG1              146     74.42  6.592282   10.858152 0.00990099
> MELK         MELK              145     59.81  6.227497   13.679654 0.00990099
> MCM3         MCM3              145     85.89  7.870024    7.510778 0.00990099
> GATA3       GATA3              145    107.83  7.908639    4.699924 0.00990099
> THBS1       THBS1              144    108.00  6.894589    5.221486 0.00990099
> TPX2         TPX2              143     65.87  5.679406   13.580645 0.00990099
> CXCL10     CXCL10              143     89.27  6.642160    8.089237 0.00990099
> LEP           LEP              143    103.46  7.479831    5.286215 0.00990099
> CD36         CD36              143    119.48  8.432118    2.789335 0.00990099
> CEBPA       CEBPA              143    126.36  8.814038    1.887897 0.04950495
> MCM6         MCM6              142     81.95  7.861651    7.638345 0.00990099
> TK1           TK1              141     74.24  6.276652   10.636243 0.00990099
> CDCA5       CDCA5              140     59.08  5.804352   13.941263 0.00990099
> SMC4         SMC4              140     76.26  6.857305    9.295197 0.00990099
> MCM5         MCM5              140     86.16  7.901822    6.813619 0.00990099
> FBXO5       FBXO5              140     97.91  7.086899    5.939128 0.00990099
> TRIP13     TRIP13              139     66.94  6.608565   10.904031 0.00990099
> VCAM1       VCAM1              139     95.55  7.451357    5.831152 0.00990099
> SPAG5       SPAG5              138     62.34  6.018859   12.570488 0.00990099
> PCNA         PCNA              137    109.11  7.928844    3.517537 0.00990099
> NCAPH       NCAPH              136     61.31  6.235602   11.977994 0.00990099
> CEP55       CEP55              135     62.07  5.983572   12.188372 0.00990099
> NCAPG       NCAPG              135     62.59  6.770547   10.694853 0.00990099
> MYBL2       MYBL2              135     82.12  7.973795    6.631723 0.00990099
> RRM1         RRM1              135     93.34  7.650470    5.445417 0.00990099
> HJURP       HJURP              134     58.74  5.575234   13.498985 0.00990099
> IL7R         IL7R              134     81.52  6.456506    8.128236 0.00990099
> SERPINE1 SERPINE1              134     92.12  6.490521    6.452486 0.00990099
> UHRF1       UHRF1              133     65.92  6.373366   10.525050 0.00990099
> KPNA2       KPNA2              131     84.89  6.786640    6.794231 0.00990099
> CDCA3       CDCA3              129     54.44  5.492548   13.574757 0.00990099
> DTL           DTL              129     78.15  6.846624    7.427018 0.00990099
> RAD51AP1 RAD51AP1              128     61.18  6.171587   10.827037 0.00990099
> KIFC1       KIFC1              128     64.80  6.159496   10.260579 0.00990099
>               padj
> GAPDH    0.2217696
> SP1      0.1384965
> FN1      0.1384965
> CD4      0.1384965
> HIF1A    0.1384965
> TGFB1    0.1384965
> FOS      0.1384965
> MMP9     0.1384965
> CCNB1    0.1384965
> EGF      0.1384965
> CDC20    0.1384965
> CREB1    0.1384965
> CCND1    0.3793191
> TOP2A    0.1384965
> AURKA    0.1384965
> PLK1     0.1384965
> CDCA8    0.1384965
> AURKB    0.1384965
> BIRC5    0.1384965
> TLR4     0.1384965
> BUB1B    0.1384965
> KIF11    0.1384965
> CEBPB    0.1384965
> FOXM1    0.1384965
> KIF23    0.1384965
> CALM3    0.2217696
> CCNB2    0.1384965
> CDC6     0.1384965
> ERBB2    0.3793191
> BUB1     0.1384965
> EXO1     0.1384965
> PXDN     0.1384965
> MAD2L1   0.1384965
> CALML5   0.1384965
> CDK2     0.2217696
> PECAM1   0.1384965
> KIF2C    0.1384965
> KIF20A   0.1384965
> ANLN     0.1384965
> ITGAM    0.1384965
> CD34     0.1384965
> ICAM1    0.1384965
> E2F1     0.4413048
> RRM2     0.1384965
> UBE2C    0.1384965
> NUF2     0.1384965
> MKI67    0.1384965
> ESPL1    0.1384965
> FEN1     0.1384965
> EGR1     0.2217696
> TTK      0.1384965
> MMP2     0.1384965
> FOXO1    0.3042513
> NDC80    0.1384965
> MCM10    0.1384965
> DLGAP5   0.1384965
> COL1A1   0.1384965
> NEK2     0.1384965
> SOX9     0.1384965
> RACGAP1  0.1384965
> APOE     0.1384965
> CDK4     0.1384965
> ITGB1    0.4413048
> CDT1     0.1384965
> KDR      0.1384965
> KIF4A    0.1384965
> PTTG1    0.1384965
> MELK     0.1384965
> MCM3     0.1384965
> GATA3    0.1384965
> THBS1    0.1384965
> TPX2     0.1384965
> CXCL10   0.1384965
> LEP      0.1384965
> CD36     0.1384965
> CEBPA    0.4413048
> MCM6     0.1384965
> TK1      0.1384965
> CDCA5    0.1384965
> SMC4     0.1384965
> MCM5     0.1384965
> FBXO5    0.1384965
> TRIP13   0.1384965
> VCAM1    0.1384965
> SPAG5    0.1384965
> PCNA     0.1384965
> NCAPH    0.1384965
> CEP55    0.1384965
> NCAPG    0.1384965
> MYBL2    0.1384965
> RRM1     0.1384965
> HJURP    0.1384965
> IL7R     0.1384965
> SERPINE1 0.1384965
> UHRF1    0.1384965
> KPNA2    0.1384965
> CDCA3    0.1384965
> DTL      0.1384965
> RAD51AP1 0.1384965
> KIFC1    0.1384965
head(top_de, 100)
>              gene obs_de_neighbors null_mean   null_sd z_empirical       pval
> GAPDH       GAPDH              456    416.91 15.396507    2.538888 0.01980198
> SP1           SP1              384    317.30 13.185928    5.058423 0.00990099
> FN1           FN1              298    220.50 10.424815    7.434185 0.00990099
> CD4           CD4              289    199.80  9.718253    9.178604 0.00990099
> HIF1A       HIF1A              277    248.16 10.944045    2.635223 0.00990099
> TGFB1       TGFB1              239    181.17  9.452759    6.117791 0.00990099
> FOS           FOS              238    192.84 10.508986    4.297275 0.00990099
> MMP9         MMP9              232    168.29  8.299075    7.676759 0.00990099
> CCNB1       CCNB1              222    158.48 10.798878    5.882093 0.00990099
> EGF           EGF              222    181.60 10.060424    4.015736 0.00990099
> CDC20       CDC20              218    140.00  8.436333    9.245723 0.00990099
> CREB1       CREB1              217    185.33  9.909749    3.195843 0.00990099
> CCND1       CCND1              213    192.77 10.741080    1.883423 0.03960396
> TOP2A       TOP2A              212    141.00  9.409859    7.545277 0.00990099
> AURKA       AURKA              211    132.08  8.625403    9.149717 0.00990099
> PLK1         PLK1              208    155.76  8.818163    5.924136 0.00990099
> CDCA8       CDCA8              200    131.32  8.222757    8.352429 0.00990099
> AURKB       AURKB              198    129.57  8.673954    7.889136 0.00990099
> BIRC5       BIRC5              195    113.82  7.873212   10.310912 0.00990099
> TLR4         TLR4              194    149.68  8.146239    5.440547 0.00990099
> BUB1B       BUB1B              192    115.07  8.306326    9.261616 0.00990099
> KIF11       KIF11              190    104.71  7.878234   10.826031 0.00990099
> CEBPB       CEBPB              190    164.22  9.296008    2.773234 0.00990099
> FOXM1       FOXM1              187    107.98  7.714580   10.242942 0.00990099
> KIF23       KIF23              185    105.66  8.033038    9.876712 0.00990099
> CALM3       CALM3              185    158.64  9.838617    2.679238 0.01980198
> CCNB2       CCNB2              184    105.28  8.026572    9.807425 0.00990099
> CDC6         CDC6              184    112.23  8.653667    8.293594 0.00990099
> ERBB2       ERBB2              184    160.64  9.474602    2.465539 0.03960396
> BUB1         BUB1              180     97.86  7.388252   11.117651 0.00990099
> EXO1         EXO1              179    111.51  8.843756    7.631373 0.00990099
> PXDN         PXDN              179    144.25  8.976259    3.871323 0.00990099
> MAD2L1     MAD2L1              178    114.91  8.894551    7.093107 0.00990099
> CALML5     CALML5              177    145.24  9.922040    3.200955 0.00990099
> CDK2         CDK2              177    154.62  9.605112    2.330009 0.01980198
> PECAM1     PECAM1              170    120.74  7.144426    6.894885 0.00990099
> KIF2C       KIF2C              168     85.07  6.284911   13.195096 0.00990099
> KIF20A     KIF20A              168     86.08  6.445858   12.708936 0.00990099
> ANLN         ANLN              168     95.44  7.906422    9.177349 0.00990099
> ITGAM       ITGAM              168    115.86  8.686481    6.002431 0.00990099
> CD34         CD34              166    115.39  7.462898    6.781548 0.00990099
> ICAM1       ICAM1              166    124.15  8.037004    5.207164 0.00990099
> E2F1         E2F1              165    147.13  9.480075    1.885006 0.04950495
> RRM2         RRM2              162     90.29  7.785372    9.210863 0.00990099
> UBE2C       UBE2C              162    104.13  7.975537    7.255938 0.00990099
> NUF2         NUF2              160     75.44  6.478122   13.053166 0.00990099
> MKI67       MKI67              160     74.61  7.020741   12.162533 0.00990099
> ESPL1       ESPL1              160     92.61  7.265381    9.275495 0.00990099
> FEN1         FEN1              160    105.50  7.944886    6.859759 0.00990099
> EGR1         EGR1              159    137.78  8.778509    2.417267 0.01980198
> TTK           TTK              157     72.09  6.993641   12.141030 0.00990099
> MMP2         MMP2              157    113.89  7.771867    5.546930 0.00990099
> FOXO1       FOXO1              157    139.48  7.709996    2.272375 0.02970297
> NDC80       NDC80              154     74.40  6.466698   12.309219 0.00990099
> MCM10       MCM10              154     75.48  7.178081   10.938857 0.00990099
> DLGAP5     DLGAP5              153     66.39  6.256948   13.842213 0.00990099
> COL1A1     COL1A1              153    107.73  7.603634    5.953732 0.00990099
> NEK2         NEK2              152     79.18  6.440685   11.306251 0.00990099
> SOX9         SOX9              151    101.47  7.521625    6.585013 0.00990099
> RACGAP1   RACGAP1              149     80.63  6.817469   10.028649 0.00990099
> APOE         APOE              149    117.03  7.407961    4.315628 0.00990099
> CDK4         CDK4              149    128.35  9.197469    2.245183 0.00990099
> ITGB1       ITGB1              149    133.57  9.225848    1.672475 0.04950495
> CDT1         CDT1              148     87.13  6.995893    8.700819 0.00990099
> KDR           KDR              148    117.32  7.532931    4.072784 0.00990099
> KIF4A       KIF4A              147     72.86  6.010126   12.335848 0.00990099
> PTTG1       PTTG1              146     74.42  6.592282   10.858152 0.00990099
> MELK         MELK              145     59.81  6.227497   13.679654 0.00990099
> MCM3         MCM3              145     85.89  7.870024    7.510778 0.00990099
> GATA3       GATA3              145    107.83  7.908639    4.699924 0.00990099
> THBS1       THBS1              144    108.00  6.894589    5.221486 0.00990099
> TPX2         TPX2              143     65.87  5.679406   13.580645 0.00990099
> CXCL10     CXCL10              143     89.27  6.642160    8.089237 0.00990099
> LEP           LEP              143    103.46  7.479831    5.286215 0.00990099
> CD36         CD36              143    119.48  8.432118    2.789335 0.00990099
> CEBPA       CEBPA              143    126.36  8.814038    1.887897 0.04950495
> MCM6         MCM6              142     81.95  7.861651    7.638345 0.00990099
> TK1           TK1              141     74.24  6.276652   10.636243 0.00990099
> CDCA5       CDCA5              140     59.08  5.804352   13.941263 0.00990099
> SMC4         SMC4              140     76.26  6.857305    9.295197 0.00990099
> MCM5         MCM5              140     86.16  7.901822    6.813619 0.00990099
> FBXO5       FBXO5              140     97.91  7.086899    5.939128 0.00990099
> TRIP13     TRIP13              139     66.94  6.608565   10.904031 0.00990099
> VCAM1       VCAM1              139     95.55  7.451357    5.831152 0.00990099
> SPAG5       SPAG5              138     62.34  6.018859   12.570488 0.00990099
> PCNA         PCNA              137    109.11  7.928844    3.517537 0.00990099
> NCAPH       NCAPH              136     61.31  6.235602   11.977994 0.00990099
> CEP55       CEP55              135     62.07  5.983572   12.188372 0.00990099
> NCAPG       NCAPG              135     62.59  6.770547   10.694853 0.00990099
> MYBL2       MYBL2              135     82.12  7.973795    6.631723 0.00990099
> RRM1         RRM1              135     93.34  7.650470    5.445417 0.00990099
> HJURP       HJURP              134     58.74  5.575234   13.498985 0.00990099
> IL7R         IL7R              134     81.52  6.456506    8.128236 0.00990099
> SERPINE1 SERPINE1              134     92.12  6.490521    6.452486 0.00990099
> UHRF1       UHRF1              133     65.92  6.373366   10.525050 0.00990099
> KPNA2       KPNA2              131     84.89  6.786640    6.794231 0.00990099
> CDCA3       CDCA3              129     54.44  5.492548   13.574757 0.00990099
> DTL           DTL              129     78.15  6.846624    7.427018 0.00990099
> RAD51AP1 RAD51AP1              128     61.18  6.171587   10.827037 0.00990099
> KIFC1       KIFC1              128     64.80  6.159496   10.260579 0.00990099
>               padj
> GAPDH    0.2217696
> SP1      0.1384965
> FN1      0.1384965
> CD4      0.1384965
> HIF1A    0.1384965
> TGFB1    0.1384965
> FOS      0.1384965
> MMP9     0.1384965
> CCNB1    0.1384965
> EGF      0.1384965
> CDC20    0.1384965
> CREB1    0.1384965
> CCND1    0.3793191
> TOP2A    0.1384965
> AURKA    0.1384965
> PLK1     0.1384965
> CDCA8    0.1384965
> AURKB    0.1384965
> BIRC5    0.1384965
> TLR4     0.1384965
> BUB1B    0.1384965
> KIF11    0.1384965
> CEBPB    0.1384965
> FOXM1    0.1384965
> KIF23    0.1384965
> CALM3    0.2217696
> CCNB2    0.1384965
> CDC6     0.1384965
> ERBB2    0.3793191
> BUB1     0.1384965
> EXO1     0.1384965
> PXDN     0.1384965
> MAD2L1   0.1384965
> CALML5   0.1384965
> CDK2     0.2217696
> PECAM1   0.1384965
> KIF2C    0.1384965
> KIF20A   0.1384965
> ANLN     0.1384965
> ITGAM    0.1384965
> CD34     0.1384965
> ICAM1    0.1384965
> E2F1     0.4413048
> RRM2     0.1384965
> UBE2C    0.1384965
> NUF2     0.1384965
> MKI67    0.1384965
> ESPL1    0.1384965
> FEN1     0.1384965
> EGR1     0.2217696
> TTK      0.1384965
> MMP2     0.1384965
> FOXO1    0.3042513
> NDC80    0.1384965
> MCM10    0.1384965
> DLGAP5   0.1384965
> COL1A1   0.1384965
> NEK2     0.1384965
> SOX9     0.1384965
> RACGAP1  0.1384965
> APOE     0.1384965
> CDK4     0.1384965
> ITGB1    0.4413048
> CDT1     0.1384965
> KDR      0.1384965
> KIF4A    0.1384965
> PTTG1    0.1384965
> MELK     0.1384965
> MCM3     0.1384965
> GATA3    0.1384965
> THBS1    0.1384965
> TPX2     0.1384965
> CXCL10   0.1384965
> LEP      0.1384965
> CD36     0.1384965
> CEBPA    0.4413048
> MCM6     0.1384965
> TK1      0.1384965
> CDCA5    0.1384965
> SMC4     0.1384965
> MCM5     0.1384965
> FBXO5    0.1384965
> TRIP13   0.1384965
> VCAM1    0.1384965
> SPAG5    0.1384965
> PCNA     0.1384965
> NCAPH    0.1384965
> CEP55    0.1384965
> NCAPG    0.1384965
> MYBL2    0.1384965
> RRM1     0.1384965
> HJURP    0.1384965
> IL7R     0.1384965
> SERPINE1 0.1384965
> UHRF1    0.1384965
> KPNA2    0.1384965
> CDCA3    0.1384965
> DTL      0.1384965
> RAD51AP1 0.1384965
> KIFC1    0.1384965

Module2: Enrichment

# Enrichment is performed on prioritized genes rather than on all expressed genes, which
# tends to sharpen signal by focusing on network-coherent regions enriched for DE effects.
gset = CrosstalkX::gset

# Restrict FC vector to prioritized genes before pathway enrichment.
fc_named = de_fc[names(de_fc) %in% row.names(top_de)]

# enrich_path() applies internally either ORA or GSEA enrichment functions from clusterprofiler package.
# it returns enriched pathways with member genes and direction.
# The output is standardized to the columns CrosstalkX expects downstream.
enriched_path = enrich_path(fc_named, enrich = "ORA", gset)
enriched_path = enriched_path |> dplyr::select(ID, geneID, direction)

# TF enrichment uses only regulatory edges (mor != 0) from the network.
# TF activity is inferred from the statistics of downstream targets using functions from decoupleR package.
TF = net |> dplyr::filter(mor != 0)
named_tstat = tstat_named[names(tstat_named) %in% row.names(top_de)]
enriched_tf = enrich_TF(named_tstat, net = TF)

# Combine TF and pathway enrichment into a single term table for crosstalk inference.
# This allows TF–pathway and pathway–pathway couplings to be handled uniformly.
names(enriched_tf) = names(enriched_path)
enrichment_df = rbind(enriched_tf, enriched_path)

# This example focuses on upregulated programs; adjust this filter if you want "down" or both.
enrichment_df = enrichment_df |> dplyr::filter(direction == "up")
row.names(enrichment_df) = NULL
head(enrichment_df)
> # A tibble: 6 × 3
>   ID    geneID                                                         direction
>   <chr> <chr>                                                          <chr>    
> 1 E2F1  PLAU/E2F1/SERPINE2/CDC6/PCNA/ACAN/SIVA1/BIRC5/MYBL2/NRP1/ASF1… up       
> 2 E2F2  CDC6/PCNA/BIRC5/MCM5/ASF1B/CDCA4/CDT1/E2F1/FBXO5/FOXO1/GMNN/M… up       
> 3 E2F3  E2F1/CDC6/BIRC5/CCNB1/AURKA/CDK2/PLK1/ASF1B/CDCA4/CDT1/FBXO5/… up       
> 4 E2F4  E2F1/STMN1/CCNB2/PLK1/CCNB1/DTL/FBXO5/BIRC5/MYBL2/CDC6/NASP/P… up       
> 5 EP300 BIRC5/CCNB2/KRT16/LAMA3/MMP9/PCNA/THBD/VCAM1                   up       
> 6 GLI2  COL10A1/TGFB1/FST/PDGFRA/BCL6/BMP1/BMP7/CDC7/CKS1B/COL5A2/E2F… up

Module3: Crosstalk inference

# crosstalk() is the single-call pipeline that:
# prepares term gene sets, preprocesses expression, loads/uses a background network,
# computes MI on gene–gene edges, aggregates MI to term–term scores, and runs permutation tests.
res = crosstalk(enrichment_df, expr, group_names, iter = 100)
> [1] "Total Run Time: 20.65 sec"
# filtration:
# low Jaccard overlap reduces trivial links driven by shared genes,
# p-values provide permutation-based evidence of non-random coupling,
# and an MI strength filter helps focus on the stronger half of interactions.
sig = res |>
      dplyr::filter((pval_deg_norm <= 0.05 | pval_mi_norm <= 0.05) & Jaccard < 0.2) |>
      dplyr::filter(mi_norm > quantile(mi_norm, 0.5, na.rm = TRUE))

# A compact string representation of significant couplings for quick inspection.
paste0(gsub("%.*", "", sig$Term1), " >> ", gsub("%.*", "", sig$Term2))
>  [1] "E2F1 >> GLI2"                                                   
>  [2] "E2F1 >> RUNX2"                                                  
>  [3] "E2F1 >> HALLMARK_ALLOGRAFT_REJECTION"                           
>  [4] "E2F1 >> PID_SYNDECAN_1_PATHWAY"                                 
>  [5] "GLI2 >> RUNX2"                                                  
>  [6] "GLI2 >> HALLMARK_ALLOGRAFT_REJECTION"                           
>  [7] "GLI2 >> HALLMARK_MITOTIC_SPINDLE"                               
>  [8] "HALLMARK_ALLOGRAFT_REJECTION >> RUNX2"                          
>  [9] "E2F3 >> RUNX2"                                                  
> [10] "HALLMARK_MITOTIC_SPINDLE >> RUNX2"                              
> [11] "GLI2 >> PID_SYNDECAN_1_PATHWAY"                                 
> [12] "E2F2 >> RUNX2"                                                  
> [13] "E2F2 >> GLI2"                                                   
> [14] "GLI2 >> HALLMARK_ESTROGEN_RESPONSE_LATE"                        
> [15] "PID_SYNDECAN_1_PATHWAY >> RUNX2"                                
> [16] "HALLMARK_ALLOGRAFT_REJECTION >> PID_SYNDECAN_1_PATHWAY"         
> [17] "HALLMARK_ESTROGEN_RESPONSE_LATE >> RUNX2"                       
> [18] "HALLMARK_ALLOGRAFT_REJECTION >> HALLMARK_ESTROGEN_RESPONSE_LATE"
> [19] "HALLMARK_MITOTIC_SPINDLE >> PID_SYNDECAN_1_PATHWAY"             
> [20] "RUNX2 >> SYNDECAN-1-MEDIATED SIGNALING EVENTS"                  
> [21] "HALLMARK_ESTROGEN_RESPONSE_LATE >> PID_SYNDECAN_1_PATHWAY"

Interpretation note:

When Jaccard overlap is low but permutation p-values are strong, the coupling is less likely to be a simple gene-overlap artifact and more consistent with network-mediated coordination.

Module4: Visualization

# Nodes are labeled with shortened names for readability; colors reflect enrichment direction.
all_labels = unique(c(sig$Term1, sig$Term2))

new_labels = all_labels |>
              stringr::str_sub(1, 50) |>
              gsub("\\%.*|\\*", "", x = _) |>
              gsub("_", " ", x = _)

named_labels = setNames(new_labels, all_labels)

enrichment_df$new_colors = ifelse(enrichment_df$direction == "up", "#CC4248FF", "#2B0B57FF")
idx = match(all_labels, enrichment_df$ID)
new_colors = setNames(enrichment_df$new_colors[idx], all_labels)

# visualize_crosstalk() renders a network view of significant couplings.
visualize_crosstalk(sig, named_labels = named_labels, named_colors = new_colors)

# scatter_plot() shows scatter plot between jaccard similarity and crosstalk significance. low correlation indicates that inference is not derived by terms similarity..
scatter_plot(sig)
> Warning in cor.test.default(result$x_val, result$y_val, method = model.fit):
> Cannot compute exact p-value with ties
> `geom_smooth()` using formula = 'y ~ x'
> `geom_smooth()` using formula = 'y ~ x'

Step by step pipeline


# load example data
enrichment_df= CrosstalkX::enrichment_df
expr= CrosstalkX::expr |> column_to_rownames("V1")

# Turn enrichment df to list of pathways. each term has gene hits
gset_list= prepare_sets(enrichment_df, expr)
genes= unique(unlist(gset_list))

# Prepare Expression data
# prepare_data function applies z-score normalization, impute within each group using median approach, ensure missing values equally distributed between groups
# Note that it is required to assign group to each sample, e.g. (sample1_Tumor), (sample2_Normal) if there is missing values
# Optionally map gene IDs to gene symbol using biomart
group_names= c("Normal", "Tumor")
z_score= prepare_data(expr, group_names, genes)

# Compute mutual infrmation between each gene pairs
mi_df= compute_mi(z_score, net)

# Compute Crosstalk inference between terms
res= compute_crosstalk(gset_list, mi_df,iter=100)
head(res)