Cell-Cell Communication Analysis (CellChat)

Author

Ahmed M. Elhossiny

1 Setup & Data Loading

Here we use CellChat (Jin et al. 2021) to infer spatially-proximal cell-cell communication directly on the Visium spots, using gene expression and spatial information with default parameters. The analysis is run separately on the PDAC sample dataset and the donor (GoL) sample dataset, restricted to the spatial domains of interest for each.

Code
suppressPackageStartupMessages({
  library(Seurat)
  library(CellChat)
  library(patchwork)
  library(qs)
})

dir.create("outputs/CCC", showWarnings = F, recursive = T)

options(future.globals.maxSize = 50 * 1024^3)
spot.size <- 65  # Visium spot diameter in microns, used to compute spatial.factors below

merged <- qread("outputs/Spatial_Clustering/tumor_tumoradj_GoL_samples_annotated_v2_lite.qs")
Idents(merged) <- merged$main_annotation

2 PDAC Samples

We restrict the PDAC (tumor) samples to the spatial domains of interest and build a CellChat spatial object using the per-spot domain labels and per-sample spatial coordinates.

Code
tumor <- subset(merged, subset = tissue == 'Tumor')
tumor <- subset(tumor, subset = main_annotation %in% c("Ducts", "Immune(TLS)", "PDTumor", "Immune(Plasma_Cells)", "Macrophages", "PanIN/GLTumor", "Fibro2", "Fibro3"))
tumor$main_annotation <- factor(tumor$main_annotation, levels = c("Ducts", "PanIN/GLTumor", "PDTumor",
                                                                  "Fibro2", "Fibro3", "Macrophages",
                                                                  "Immune(TLS)", "Immune(Plasma_Cells)"))

data.input <- GetAssayData(tumor, layer = "data", assay = "Spatial")
meta <- data.frame(labels = tumor$main_annotation, samples = tumor$sample_id)
meta$labels <- factor(meta$labels, levels = unique(meta$labels))
meta$samples <- factor(meta$samples)

spatial.locs <- lapply(names(tumor@images), function(x) {
  GetTissueCoordinates(tumor, image = x)[, c("x", "y")] %>%
    `colnames<-`(c("imagerow", "imagecol"))
}) %>% bind_rows() %>% as.matrix()

spatial.factors <- lapply(names(tumor@images), function(x) {
  return(spot.size / tumor@images[[x]]@scale.factors$spot)
}) %>% unlist()
spatial.factors <- data.frame(ratio = spatial.factors, tol = spot.size / 2)
rownames(spatial.factors) <- unique(tumor$sample_id)

cellchat <- createCellChat(object = data.input,
                           meta = meta,
                           group.by = "labels",
                           datatype = "spatial",
                           coordinates = spatial.locs,
                           spatial.factors = spatial.factors)
cellchat@DB <- subsetDB(CellChatDB.human)

We then run the standard CellChat spatial pipeline: identify overexpressed genes and interactions, compute communication probabilities constrained by signaling range (250 µm) and contact range (100 µm), filter weakly supported interactions, and aggregate the network.

Code
cellchat <- subsetData(cellchat)
future::plan("multisession", workers = 10)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)

future::plan("sequential")
cellchat <- computeCommunProb(
  cellchat,
  type = "truncatedMean",
  trim = 0.1,
  distance.use = FALSE,
  interaction.range = 250,
  contact.dependent = TRUE,
  contact.range = 100
)

cellchat <- filterCommunication(cellchat, min.cells = 10)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
qsave(cellchat, file = "outputs/CCC/cellchat_tumor_all_domains.qs")

3 Donor (GoL) Samples

The same workflow is applied to the donor (Gift of Life) samples, restricted to the spatial domains present in donor tissue.

Code
gol <- subset(merged, subset = tissue == 'GoL')
gol <- subset(gol, subset = main_annotation %in% c("Ducts", "PanIN/GLTumor", "Fibro3", "Immune(Plasma_Cells)"))
gol$main_annotation <- factor(gol$main_annotation, levels = c("Ducts", "PanIN/GLTumor", "Fibro3", "Immune(Plasma_Cells)"))

data.input <- GetAssayData(gol, layer = "data", assay = "Spatial")
meta <- data.frame(labels = gol$main_annotation, samples = gol$sample_id)
meta$labels <- factor(meta$labels, levels = unique(meta$labels))
meta$samples <- factor(meta$samples)

spatial.locs <- lapply(names(gol@images), function(x) {
  GetTissueCoordinates(gol, image = x)[, c("x", "y")] %>%
    `colnames<-`(c("imagerow", "imagecol"))
}) %>% bind_rows() %>% as.matrix()

spatial.factors <- lapply(names(gol@images), function(x) {
  return(spot.size / gol@images[[x]]@scale.factors$spot)
}) %>% unlist()
spatial.factors <- data.frame(ratio = spatial.factors, tol = spot.size / 2)
rownames(spatial.factors) <- unique(gol$sample_id)

cellchat <- createCellChat(object = data.input,
                           meta = meta,
                           group.by = "labels",
                           datatype = "spatial",
                           coordinates = spatial.locs,
                           spatial.factors = spatial.factors)
cellchat@DB <- subsetDB(CellChatDB.human)

cellchat <- subsetData(cellchat)
future::plan("multisession", workers = 10)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)

future::plan("sequential")
cellchat <- computeCommunProb(
  cellchat,
  type = "truncatedMean",
  trim = 0.1,
  distance.use = FALSE,
  interaction.range = 250,
  contact.dependent = TRUE,
  contact.range = 100
)

cellchat <- filterCommunication(cellchat, min.cells = 10)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
qsave(cellchat, file = "outputs/CCC/cellchat_gol_all_domains.rds")

4 Comparing PDAC and Donor Communication Networks

The two CellChat objects can be merged to compare the number and strength of inferred interactions between PDAC and donor tissue, and to identify the signaling pathways (e.g., WNT) that distinguish the two.

Code
cellchat_tumor <- qread("outputs/CCC/cellchat_tumor_all_domains.qs")
cellchat_gol <- qread("outputs/CCC/cellchat_gol_all_domains.rds")

object.list <- list(Donor = cellchat_gol, PDAC = cellchat_tumor)
cellchat <- mergeCellChat(object.list, add.names = names(object.list))
compareInteractions(cellchat, show.legend = F, group = c(1, 2))
compareInteractions(cellchat, show.legend = F, group = c(1, 2), measure = "weight")

cellchat_tumor <- netAnalysis_computeCentrality(cellchat_tumor, slot.name = "netP")
netAnalysis_signalingRole_scatter(cellchat_tumor)

top_pathways <- netAnalysis_signalingRole_heatmap(cellchat_tumor, pattern = "outgoing")@matrix %>% row.names()
netAnalysis_signalingRole_heatmap(cellchat_tumor, pattern = "incoming", signaling = top_pathways[1:30], cluster.rows = F, cluster.cols = T)

WNT pathway ligands, receptors, and downstream targets can be extracted directly from the CellChat ligand-receptor database for use in the WNT signaling figures.

Code
wnt_ligands <- CellChatDB.human$interaction %>% filter(pathway_name %in% c("ncWNT", "WNT")) %>% pull(ligand) %>% unique()
wnt_receptors <- CellChatDB.human$interaction %>% filter(pathway_name %in% c("ncWNT", "WNT")) %>%
  pull(receptor) %>% strsplit("_") %>% unlist() %>% unique()

References

Jin, Suoqin, Christian F Guerrero-Juarez, Lihua Zhang, et al. 2021. “Inference and Analysis of Cell-Cell Communication Using CellChat.” Nature Communications 12 (1): 1088.