GO-and-CCC-analyses

Introduction

We identify genes associated with annotated cell types and perform Gene Ontology (GO) Biological Process enrichment using the mouse annotation database org.Mm.eg.db. The example dataset is small, and statistical significance or detectable signalling cannot be guaranteed.

data(norm_ccc_example)
norm <- norm_ccc_example
names(norm)
#> [1] "None"    "SpaNorm"

Differential expression and GO enrichment

The region-specific differential-expression analysis uses a configurable test, including an FDR cutoff of 0.05.

go_result <- calculate_go(
  norm_list = norm,
  cluster_col = "Main_molecular_tissue_region",
  methods = names(norm),
  assay_name = "logcounts",
  OrgDb = org.Mm.eg.db::org.Mm.eg.db,
  key_type = "SYMBOL",
  ont = "BP",
  fdr_cutoff = 0.05,
  min_prop = 0.5,
  min_spots = 10,
  min_genes = 5,
  pvalue_cutoff = 0.05,
  qvalue_cutoff = 0.05,
  p_adjust_method = "BH",
  readable = TRUE,
  test_type = "t"
)

names(go_result)
#> [1] "markers"  "genes"    "go"       "universe"
head(go_result$genes)
#>   method cluster  gene          FDR rank
#> 1   None   CTX_1  NRGN 7.004472e-12    1
#> 2   None   CTX_1 NPTX1 2.393713e-10    2
#> 3   None   CTX_1  TCF4 6.065665e-07    3
#> 4   None   CTX_1   Cck 1.081228e-06    4
#> 5   None   CTX_1 ADCY1 2.003602e-06    5
#> 6   None   CTX_1 EFHD2 1.898462e-05    6
head(go_result$go)
#>           ID          Description GeneRatio BgRatio RichFactor FoldEnrichment
#> 1 GO:0006865 amino acid transport      7/12  32/304    0.21875       5.541667
#>   oddsRatio   zScore       pvalue   p.adjust     qvalue
#> 1    14.952 5.497007 4.089204e-05 0.02801105 0.01233012
#>                                   geneID Count SetSize DESize UniverseSize
#> 1 Slc6a11/Slc17a6/Cck/Grm1/Hrh3/Grm2/Agt     7      32     12          304
#>   method cluster GeneRatio_numeric log10_padj
#> 1   None      TH         0.5833333   1.552671

Visualise enriched biological processes

For each region and normalisation method, we visualise the five most significant GO terms. The top_n argument controls the displayed terms; the original enrichment results remain available in go_result.

if (nrow(go_result$go) > 0L) {
  p_go <- plot_go(
    go_result = go_result,
    top_n = 5,
    method_col = "method",
    cluster_col = "cluster",
    point_size_range = c(2, 7),
    theme_name = "classic",
    title = "GO enrichment",
    ncol = 2
  )
  print(p_go$plot)
} else {
  message("No significant GO terms were detected in the example data.")
}

Visualise differential-expression genes

These plots display significant DE genes used as input to GO enrichment, even when no GO terms reach significance.

if (nrow(go_result$genes) > 0L) {
  p_go_genes <- plot_go_genes(
    go_result = go_result,
    top_n = 5,
    method_col = "method",
    cluster_col = "cluster",
    gene_col = "gene",
    point_size = 3,
    theme_name = "classic"
  )
  print(p_go_genes$plot)
} else {
  message("No significant DE genes were detected in the example data.")
}

Visualise GO enrichment results

We visualise the five most significant GO Biological Process terms for each cell type and normalisation method. Point size represents the number of genes associated with each GO term, while colour represents the adjusted p-value.

if (nrow(go_result$go) > 0L) {

  p_go <- plot_go(
    go_result = go_result,
    top_n = 5,
    method_col = "method",
    cluster_col = "cluster",
    method_order = NULL,
    point_size_range = c(2, 7),
    theme_name = "classic",
    methods = NULL,
    title = "GO enrichment across mouse brain regions",
    subtitle = NULL,#"Comparison across normalisation methods",
    ncol = 3
  )

  p_go$plot

}

Cell-cell communication analysis

CellChat is applied independently to each normalised dataset using the same analysis parameters. This allows us to investigate variation in inferred communication patterns across normalisation methods.

Prepare data for CellChat

For the mouse example data, we use the mouse CellChat database. Spatial scaling factors and interaction distances must be validated for the coordinate units and spatial technology. The values below are illustrative.

data("CellChatDB.mouse", package = "CellChat")
ccc_database <- CellChat::CellChatDB.mouse
ccc_spe <- norm

celltype_col <- "cell_type"
spatial_factors <- data.frame(ratio = 0.5, tol = 12.5)
interaction_range <- 250
contact_range <- 25

Run CellChat across normalisation methods

This workflow requires CellChat and sufficient ligand-receptor genes. An error is informative if the small example contains too few supported interactions.

ccc_results <- run_ccc(
  spelist = ccc_spe,
  celltype_col = celltype_col,
  database = ccc_database,
  spatial_factors = spatial_factors,
  interaction_range = interaction_range,
  contact_range = contact_range,
  assay_name = "logcounts",
  nboot = 10,
  min_cells = 5,
  trim = 0.1,
  scale_distance = 0.1,
  variable_both = FALSE,
  verbose = FALSE
)

Compare signalling pathway strengths

Pathway strengths are summarised using communication probabilities returned by CellChat.

p_ccc_pathways <- plot_ccc_pathways(
  ccc_result = ccc_results,
  top_n = 4,
  method_order = names(ccc_results),
  log_scale = FALSE
)
p_ccc_pathways

Compare ligand-receptor interactions

This comparison examines differences in individual inferred interactions and their associated signalling pathways.

p_ccc_lr <- plot_ccc_lr(
  ccc_result = ccc_results,
  top_n = 15,
  method_order = names(ccc_results),
  log_scale = FALSE
)
p_ccc_lr

Compare sender-receiver communication

Communication between sender and receiver cell-type groups is summarised for each normalisation method.

p_ccc_sender_receiver <- plot_ccc_sender_receiver(
  ccc_result = ccc_results,
  methods = names(ccc_results),
  method_order = names(ccc_results)
)
p_ccc_sender_receiver

Visualise pathway-specific communication networks

The following code visualises a detected signalling pathway using CellChat’s circle layout.

detected_pathways <- unique(unlist(lapply(
  ccc_results,
  function(x) x$cellchat@netP$pathways
)))

if (length(detected_pathways) > 0L) {
  pathway <- detected_pathways[1]
  for (method in names(ccc_results)) {
    cellchat <- ccc_results[[method]]$cellchat
    if (!is.null(cellchat) && pathway %in% cellchat@netP$pathways) {
      CellChat::netVisual_aggregate(
        cellchat,
        signaling = pathway,
        layout = "circle"
      )
    }
  }
}

Summary

These analyses provide a framework for evaluating the sensitivity of inferred cell-cell communication patterns to different normalisation methods.

The comparisons describe differences in computationally inferred communication and should not be interpreted as direct evidence of biological signalling changes.

Session information

sessionInfo()
#> R version 4.6.2 (2026-10-29)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 26.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] STBench_0.99.2 rmarkdown_2.32
#> 
#> loaded via a namespace (and not attached):
#>   [1] RcppHungarian_0.3           splines_4.6.2              
#>   [3] ggplotify_0.1.4             tibble_3.3.1               
#>   [5] polyclip_1.10-7             enrichit_0.2.7             
#>   [7] lifecycle_1.0.5             httr2_1.3.0                
#>   [9] aricode_1.1.0               edgeR_4.99.16              
#>  [11] processx_3.10.0             lattice_0.23-1             
#>  [13] MASS_7.3-66                 magrittr_2.0.5             
#>  [15] limma_3.99.5                sass_0.5.0                 
#>  [17] jquerylib_0.1.4             yaml_2.3.12                
#>  [19] metapod_1.21.1              otel_0.3.0                 
#>  [21] ggtangle_0.1.5              DBI_1.3.0                  
#>  [23] buildtools_1.0.0            RColorBrewer_1.1-3         
#>  [25] abind_1.4-8                 GenomicRanges_1.65.4       
#>  [27] purrr_1.2.2                 BiocGenerics_0.59.13       
#>  [29] yulab.utils_0.2.6           tweenr_2.0.3               
#>  [31] rappdirs_0.3.4              aisdk_1.4.12               
#>  [33] gdtools_0.6.0               clevr_0.1.2                
#>  [35] IRanges_2.47.5              S4Vectors_0.51.10          
#>  [37] enrichplot_1.99.8           ggrepel_0.9.8              
#>  [39] irlba_2.4.1                 tidytree_0.4.9             
#>  [41] maketools_1.3.2             RSpectra_0.16-2            
#>  [43] dqrng_0.4.1                 codetools_0.2-20           
#>  [45] DelayedArray_0.39.8         ggforce_0.5.0              
#>  [47] DOSE_4.7.4                  scuttle_1.23.2             
#>  [49] Banksy_1.9.6                tidyselect_1.2.1           
#>  [51] aplot_0.3.2                 farver_2.1.2               
#>  [53] ScaledMatrix_1.21.0         viridis_0.6.5              
#>  [55] matrixStats_1.5.0           stats4_4.6.2               
#>  [57] Seqinfo_1.3.2               jsonlite_2.0.0             
#>  [59] BiocNeighbors_2.7.3         scater_1.41.3              
#>  [61] systemfonts_1.3.4           dbscan_1.3.0               
#>  [63] tools_4.6.2                 ggnewscale_0.5.2           
#>  [65] treeio_1.37.1               Rcpp_1.1.2                 
#>  [67] glue_1.8.1                  gridExtra_2.3.1            
#>  [69] SparseArray_1.13.5          BiocBaseUtils_1.15.1       
#>  [71] xfun_0.62                   qvalue_2.45.0              
#>  [73] MatrixGenerics_1.25.0       dplyr_1.2.1                
#>  [75] withr_3.0.3                 fastmap_1.2.0              
#>  [77] bluster_1.23.1              callr_3.8.0                
#>  [79] digest_0.6.39               rsvd_2.0.0                 
#>  [81] R6_2.6.1                    gridGraphics_0.5-1         
#>  [83] colorspace_2.1-4            GO.db_3.24.0               
#>  [85] sccore_1.0.7                RSQLite_3.53.3             
#>  [87] tidyr_1.3.2                 generics_0.1.4             
#>  [89] fontLiberation_0.1.0        data.table_1.18.6.1        
#>  [91] treelayout_0.1.0            FNN_1.1.4.1                
#>  [93] htmlwidgets_1.6.4           httr_1.4.9                 
#>  [95] S4Arrays_1.13.3             org.Mm.eg.db_3.24.6        
#>  [97] scatterpie_0.2.6            scatterplot3d_0.3-45       
#>  [99] uwot_0.2.5                  pkgconfig_2.0.3            
#> [101] gtable_0.3.6                blob_1.3.0                 
#> [103] S7_1.0.0                    SingleCellExperiment_1.35.2
#> [105] XVector_0.53.0              sys_3.4.3                  
#> [107] clusterProfiler_4.21.7      htmltools_0.5.9            
#> [109] fontBitstreamVera_0.1.1     scales_1.4.0               
#> [111] Biobase_2.73.2              png_0.1-9                  
#> [113] SpatialExperiment_1.23.0    scran_1.41.1               
#> [115] ggfun_0.2.2                 knitr_1.52                 
#> [117] reshape2_1.4.5              rjson_0.2.23               
#> [119] nlme_3.1-172                cachem_1.1.0               
#> [121] Polychrome_1.6.2            stringr_1.6.0              
#> [123] parallel_4.6.2              vipor_0.4.7                
#> [125] AnnotationDbi_1.75.2        pillar_1.11.1              
#> [127] grid_4.6.2                  vctrs_0.7.3                
#> [129] tidydr_0.0.7                BiocSingular_1.29.3        
#> [131] beachmat_2.29.3             cluster_2.1.8.3            
#> [133] beeswarm_0.4.0              evaluate_1.0.5             
#> [135] magick_2.9.1                cli_3.6.6                  
#> [137] compiler_4.6.2              rlang_1.3.0                
#> [139] crayon_1.5.3                labeling_0.4.3             
#> [141] mclust_6.1.4                ps_1.9.3                   
#> [143] plyr_1.8.9                  fs_2.1.0                   
#> [145] ggbeeswarm_0.7.3            ggiraph_0.9.7              
#> [147] stringi_1.8.9               viridisLite_0.4.3          
#> [149] BiocParallel_1.47.0         Biostrings_2.81.9          
#> [151] lazyeval_0.2.3              fontquiver_0.2.1           
#> [153] GOSemSim_2.39.5             Matrix_1.7-6               
#> [155] patchwork_1.3.2             sparseMatrixStats_1.25.0   
#> [157] bit64_4.8.6                 ggplot2_4.0.4              
#> [159] SpaNorm_1.7.17              KEGGREST_1.53.6            
#> [161] statmod_1.5.2               SummarizedExperiment_1.43.0
#> [163] leidenAlg_1.1.8             igraph_2.3.4               
#> [165] memoise_2.0.1               bslib_0.12.0               
#> [167] ggtree_4.3.2                bit_4.6.0                  
#> [169] gson_0.2.2                  ape_5.8-1