# BulkSignalR : Inference of ligand-receptor interactions from bulk data or spatial transcriptomics

#### Jean-Philippe Villemin

#### Jacques Colinge

#### 09/29/2025

Code

    library(BulkSignalR)

## Cluster-based differential analysis

By default, `BulkSignalR` inference of L-R interactions relies on correlation analysis across all the samples. That is, a putative L-R interaction is assessed for coherent expression of the ligand, the receptor, and target genes in a pathway below receptor across all the samples.

Alternatively, it is possible to define sample clusters based on an independent analysis (outside of `BulkSignalR`) to group similar samples. Based on cluster definitions, it is for instance possible to assess whether L-R interactions are significantly stronger in a cluster compared to all the samples, to all the samples but the chosen cluster, or in comparison with another cluster. In practice, the user must simply provide a table of differential gene or protein expression analysis that is relevant for the selected comparison.

In this mode, L-R interactions are inferred based on gene or protein regulation-associated P-values instead of P-values resulting from the correlation analysis in the default mode. As already stated, differential P-value estimations are left to the user to compute. With bulk data, commonly used libraries such as `DESeq2`, `EdgeR`, or `limma` constitute obvious options.

In the next chunk of code, we illustrate the differential mode using Salivary Duct Carcinoma (SDC) samples where we compare two clusters of patients.

We first create a BSRDataModelComp object as follows:

Code

    data(sdc, package = "BulkSignalR")
    normal <- grep("^N", names(sdc))
    bsrdm.comp <- BSRDataModelComp(sdc[, -normal])

To make a very small example we generate random values, but user should provide his own logFC and associated pvalues from DGE ouputs.

Code

    colA <- as.integer(1:3)
    colB <- as.integer(12:15)

    n <- nrow(ncounts(bsrdm.comp))
    stats <- data.frame(pval = runif(n),
    logFC = rnorm(n, 0, 2),
    expr = runif(n, 0, 10))
    rownames(stats) <- rownames(ncounts(bsrdm.comp))

We define the cluster comparison and add it.

Code

    bsrcc <- BSRClusterComp(bsrdm.comp, colA, colB, stats)
    bsrdm.comp <- addClusterComp(bsrdm.comp, bsrcc, "random.example")

Finally we infer ligand-receptor interactions from the comparison. We use a subset of the reference to speed up inference in the context of the vignette.

Code

    subset <- c("REACTOME_BASIGIN_INTERACTIONS",
    "REACTOME_SYNDECAN_INTERACTIONS",
    "REACTOME_ECM_PROTEOGLYCANS",
    "REACTOME_CELL_JUNCTION_ORGANIZATION")

    reactSubset <- BulkSignalR:::.SignalR$BulkSignalR_Reactome[
    BulkSignalR:::.SignalR$BulkSignalR_Reactome$`Reactome name` %in% subset,]

    resetPathways(dataframe = reactSubset,
    resourceName = "Reactome")

    bsrinf.comp <- BSRInferenceComp(bsrdm.comp,
    reference="REACTOME",
    max.pval = 1,
    "random.example")

    head(LRinter(bsrinf.comp))

    ##           L     R         pw.id                             pw.name       pval
    ## 4     ADAM2 ITGB1  R-HSA-210991       REACTOME_BASIGIN_INTERACTIONS 0.04303774
    ## 41    ADAM2 ITGB1 R-HSA-3000170      REACTOME_SYNDECAN_INTERACTIONS 0.04151202
    ## 42    ADAM2 ITGB1 R-HSA-3000178          REACTOME_ECM_PROTEOGLYCANS 0.03003437
    ## 43    ADAM2 ITGB1  R-HSA-446728 REACTOME_CELL_JUNCTION_ORGANIZATION 0.06109425
    ## 40  COL18A1 ITGA3  R-HSA-210991       REACTOME_BASIGIN_INTERACTIONS 0.05286936
    ## 421 COL18A1 ITGB1  R-HSA-210991       REACTOME_BASIGIN_INTERACTIONS 0.05165398
    ##           qval  L.logFC  R.logFC    LR.pval LR.corr rank len rank.pval
    ## 4   0.07467931 3.190003 3.164760 0.11012936       1    5  10 0.5055933
    ## 41  0.07431163 3.190003 3.164760 0.11012936       1    4   9 0.5566765
    ## 42  0.07097866 3.190003 3.164760 0.11012936       1   12  23 0.4378888
    ## 43  0.08111880 3.190003 3.164760 0.11012936       1   17  32 0.4966110
    ## 40  0.07515742 4.059346 2.784798 0.05385665       1    4   9 0.8748582
    ## 421 0.07515742 4.059346 3.164760 0.13217747       1    5  10 0.5055933
    ##     rank.corr  LR.score   L.expr   R.expr
    ## 4           1 0.1982480 8.253729 5.114754
    ## 41          1 0.1982480 8.253729 5.114754
    ## 42          1 0.1982480 8.253729 5.114754
    ## 43          1 0.1982480 8.253729 5.114754
    ## 40          1 0.1496876 5.000663 2.125529
    ## 421         1 0.1816014 5.000663 5.114754

## Technical notes

The three basic `BulkSignalR` S4 classes BSRDataModel, BSRInference, and BSRSignature were derived into new classes to add the functionalities required by the differential mode:

- BSRDataModelComp, denoted here as `bsrdm.comp` is a daughter class of BSRDataModel, previously denoted `bsrdm`
- BSRInferenceComp, denoted here as `bsrinf.comp` is a daughter class of BSRInference, previously denoted `bsrinf`
- BSRSignatureComp, denoted here as `bsrsig.comp` is a daughter class of BSRSignature, previously denoted `bsrsig`

The new S4 class BSRClusterComp is meant to represent the comparison between two clusters of samples. It primarily contains the results of the user-provided differential analysis in a table containing gene/protein names, P-values, and log-fold-changes (logFC).

Usually, we recommend instantiating a `BSRDataModel` object to contain the expression matrix underlying the differential analysis. Then, it is promoted into a `BSRDataModelComp` object such that cluster definitions and comparisons can be added to it. This can be for instance done with `as(bsrdm, "BSRDataModelComp")`. The `addClusterComp` method of a `BSRDataModelComp` object allows adding one or several comparisons between clusters, each added comparison being defined in a `BSRClusterComp` object.

Thank you for reading this guide and for using `BulkSignalR`.

## Session Information

Code

    sessionInfo()

    ## R version 4.5.1 Patched (2025-06-14 r88325)
    ## Platform: aarch64-apple-darwin20
    ## Running under: macOS Ventura 13.7.5
    ##
    ## Matrix products: default
    ## BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
    ## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1
    ##
    ## locale:
    ## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    ##
    ## time zone: America/New_York
    ## tzcode source: internal
    ##
    ## attached base packages:
    ## [1] stats     graphics  grDevices utils     datasets  methods   base
    ##
    ## other attached packages:
    ## [1] BulkSignalR_1.0.5
    ##
    ## loaded via a namespace (and not attached):
    ##   [1] RColorBrewer_1.1-3          jsonlite_2.0.0
    ##   [3] shape_1.4.6.1               magrittr_2.0.4
    ##   [5] magick_2.9.0                farver_2.1.2
    ##   [7] rmarkdown_2.30              GlobalOptions_0.1.2
    ##   [9] fs_1.6.6                    vctrs_0.6.5
    ##  [11] multtest_2.64.0             memoise_2.0.1
    ##  [13] RCurl_1.98-1.17             ggtree_3.16.3
    ##  [15] rstatix_0.7.2               htmltools_0.5.8.1
    ##  [17] S4Arrays_1.8.1              curl_7.0.0
    ##  [19] broom_1.0.10                SparseArray_1.8.1
    ##  [21] Formula_1.2-5               gridGraphics_0.5-1
    ##  [23] sass_0.4.10                 bslib_0.9.0
    ##  [25] htmlwidgets_1.6.4           plotly_4.11.0
    ##  [27] cachem_1.1.0                igraph_2.1.4
    ##  [29] lifecycle_1.0.4             iterators_1.0.14
    ##  [31] pkgconfig_2.0.3             Matrix_1.7-4
    ##  [33] R6_2.6.1                    fastmap_1.2.0
    ##  [35] GenomeInfoDbData_1.2.14     MatrixGenerics_1.20.0
    ##  [37] clue_0.3-66                 digest_0.6.37
    ##  [39] aplot_0.2.9                 colorspace_2.1-2
    ##  [41] patchwork_1.3.2             S4Vectors_0.46.0
    ##  [43] grr_0.9.5                   GenomicRanges_1.60.0
    ##  [45] RSQLite_2.4.3               ggpubr_0.6.1
    ##  [47] filelock_1.0.3              httr_1.4.7
    ##  [49] abind_1.4-8                 compiler_4.5.1
    ##  [51] withr_3.0.2                 bit64_4.6.0-1
    ##  [53] doParallel_1.0.17           S7_0.2.0
    ##  [55] backports_1.5.0             orthogene_1.14.01
    ##  [57] carData_3.0-5               DBI_1.2.3
    ##  [59] homologene_1.4.68.19.3.27   ggsignif_0.6.4
    ##  [61] MASS_7.3-65                 rappdirs_0.3.3
    ##  [63] DelayedArray_0.34.1         rjson_0.2.23
    ##  [65] tools_4.5.1                 ape_5.8-1
    ##  [67] glue_1.8.0                  stabledist_0.7-2
    ##  [69] nlme_3.1-168                grid_4.5.1
    ##  [71] Rtsne_0.17                  cluster_2.1.8.1
    ##  [73] generics_0.1.4              gtable_0.3.6
    ##  [75] tidyr_1.3.1                 data.table_1.17.8
    ##  [77] car_3.1-3                   XVector_0.48.0
    ##  [79] BiocGenerics_0.54.0         ggrepel_0.9.6
    ##  [81] RANN_2.6.2                  foreach_1.5.2
    ##  [83] pillar_1.11.1               yulab.utils_0.2.1
    ##  [85] babelgene_22.9              circlize_0.4.16
    ##  [87] splines_4.5.1               dplyr_1.1.4
    ##  [89] BiocFileCache_2.16.2        treeio_1.32.0
    ##  [91] lattice_0.22-7              survival_3.8-3
    ##  [93] bit_4.6.0                   tidyselect_1.2.1
    ##  [95] ComplexHeatmap_2.24.1       SingleCellExperiment_1.30.1
    ##  [97] knitr_1.50                  gridExtra_2.3
    ##  [99] IRanges_2.42.0              SummarizedExperiment_1.38.1
    ## [101] stats4_4.5.1                xfun_0.53
    ## [103] Biobase_2.68.0              matrixStats_1.5.0
    ## [105] UCSC.utils_1.4.0            lazyeval_0.2.2
    ## [107] ggfun_0.2.0                 yaml_2.3.10
    ## [109] evaluate_1.0.5              codetools_0.2-20
    ## [111] tibble_3.3.0                ggplotify_0.1.3
    ## [113] cli_3.6.5                   jquerylib_0.1.4
    ## [115] dichromat_2.0-0.1           Rcpp_1.1.0
    ## [117] GenomeInfoDb_1.44.3         dbplyr_2.5.1
    ## [119] gprofiler2_0.2.3            png_0.1-8
    ## [121] parallel_4.5.1              ggplot2_4.0.0
    ## [123] blob_1.2.4                  ggalluvial_0.12.5
    ## [125] bitops_1.0-9                glmnet_4.1-10
    ## [127] SpatialExperiment_1.18.1    viridisLite_0.4.2
    ## [129] tidytree_0.4.6              scales_1.4.0
    ## [131] purrr_1.1.0                 crayon_1.5.3
    ## [133] GetoptLong_1.0.5            rlang_1.1.6