This vignette shows how to apply CellChat to the comparison analysis of multiple datasets with different cell type compositions. Almost all the CellChat’s functionalities can be applied.
library(CellChat)
library(ggplot2)
library(patchwork)
library(igraph)
For the datasets with slightly different cell type (group)
compositions, CellChat can lift up the cell groups to the same cell
labels across all datasets using the function liftCellChat
,
and then perform comparison analysis as the joint analysis of datasets
with the same cell type compositions.
Here we take an example of comparison analysis of two embryonic mouse skin scRNA-seq datasets from days E13.5 and E14.5. There are 11 shared skin cell populations at E13.5 and E14.5 and additional two populations (i.e., dermal DC and pericytes) specific to E14.5. Therefore, we will lift up the cell groups from E13.5 to the same cell labels as E14.5.
USERS need to run CellChat on each dataset seperately and then merge
different CellChat objects together. Here we also do
updateCellChat
because these two objects are obtained using
the earlier version (< 1.6.0) of CellChat.
#cellchat.E13 <- readRDS(url("https://ndownloader.figshare.com/files/25957094"))
cellchat.E13 <- readRDS("/Users/jinsuoqin/Documents/CellChat/tutorial/cellchat_embryonic_E13.rds")
cellchat.E13 <- updateCellChat(cellchat.E13)
#> Update slot 'var.features' from a vector to a list
#cellchat.E14 <- readRDS(url("https://ndownloader.figshare.com/files/25957634"))
cellchat.E14 <- readRDS("/Users/jinsuoqin/Documents/CellChat/tutorial/cellchat_embryonic_E14.rds")
cellchat.E14 <- updateCellChat(cellchat.E14)
#> Update slot 'var.features' from a vector to a list
Since there are additional two populations (i.e., dermal DC and
pericytes) specific to E14.5 compared to E13.5, we lift up
cellchat.E13
by lifting up the cell groups to the same cell
labels as E14.5. liftCellChat
will only update the slot
related to the cell-cell communication network, including slots object@net, object@netP and object@idents.
# Define the cell labels to lift up
group.new = levels(cellchat.E14@idents)
cellchat.E13 <- liftCellChat(cellchat.E13, group.new)
#> The CellChat object will be lifted up using the cell labels FIB-A, FIB-B, FIB-P, DC, Pericyte, MYL, Immune, ENDO, Muscle, MELA, Basal-P, Basal, Spinious
#> Update slots object@net, object@netP, object@idents in a single dataset...
object.list <- list(E13 = cellchat.E13, E14 = cellchat.E14)
cellchat <- mergeCellChat(object.list, add.names = names(object.list), cell.prefix = TRUE)
#> Warning in mergeCellChat(object.list, add.names = names(object.list),
#> cell.prefix = TRUE): Prefix cell names!
#> The cell barcodes in merged 'meta' is rep1_AAACCTGCACCAACCG rep1_AAACGGGAGCCGATTT rep1_AAACGGGAGTATCGAA rep1_AAACGGGCATCTCCCA rep1_AAAGATGCACTTGGAT rep1_AAAGATGCAGTTCATG
#> Warning in mergeCellChat(object.list, add.names = names(object.list), cell.prefix = TRUE): The cell barcodes in merged 'meta' is different from those in the used data matrix.
#> We now simply assign the colnames in the data matrix to the rownames of merged 'mata'!
#> Merge the following slots: 'data.signaling','images','net', 'netP','meta', 'idents', 'var.features' , 'DB', and 'LR'.
# Hierarchy plot
pathways.show <- c("WNT")
weight.max <- getMaxWeight(object.list, slot.name = c("netP"), attribute = pathways.show) # control the edge weights across different datasets
vertex.receiver = seq(1,10) # Left portion of hierarchy plot the shows signaling to dermal cells and right portion shows signaling to epidermal cells
par(mfrow = c(1,2), xpd=TRUE)
for (i in 1:length(object.list)) {
netVisual_aggregate(object.list[[i]], signaling = pathways.show, vertex.receiver = vertex.receiver, edge.weight.max = weight.max[1], edge.width.max = 10, signaling.name = paste(pathways.show, names(object.list)[i]))
}
# Circle plot
pathways.show <- c("WNT")
weight.max <- getMaxWeight(object.list, slot.name = c("netP"), attribute = pathways.show) # control the edge weights across different datasets
par(mfrow = c(1,2), xpd=TRUE)
for (i in 1:length(object.list)) {
netVisual_aggregate(object.list[[i]], signaling = pathways.show, layout = "circle", edge.weight.max = weight.max[1], edge.width.max = 10, signaling.name = paste(pathways.show, names(object.list)[i]))
}
# Chord diagram
pathways.show <- c("WNT")
par(mfrow = c(1,2), xpd=TRUE)
for (i in 1:length(object.list)) {
netVisual_aggregate(object.list[[i]], signaling = pathways.show, layout = "chord", signaling.name = paste(pathways.show, names(object.list)[i]))
}
For the chord diagram, CellChat has an independent function
netVisual_chord_cell
to flexibly visualize the signaling
network by adjusting different parameters in the circlize package. For
example, we can define a named char vector group
to create
multiple-group chord diagram, e.g., grouping cell clusters into
different cell types.
# Chord diagram
group.merged <- c(rep("Dermal", 10), rep("Epidermal", 3)) # grouping cell clusters into dermal and epidermal cells to study the cell-cell communication between dermal and epidermal
names(group.merged) <- levels(object.list[[1]]@idents)
pathways.show <- c("WNT")
par(mfrow = c(1,2), xpd=TRUE)
for (i in 1:length(object.list)) {
netVisual_chord_cell(object.list[[i]], signaling = pathways.show, group = group.merged, title.name = paste0(pathways.show, " signaling network - ", names(object.list)[i]))
}
#> Plot the aggregated cell-cell communication network at the signaling pathway level
#> Plot the aggregated cell-cell communication network at the signaling pathway level
CellChat can be used to compare cell-cell communication patterns between two scRNA-seq datasets from vastly distinct biological contexts – embryonic morphogenesis vs. wound-induced repair. For the datasets with vastly different cell type (group) compositions, most of the CellChat’s functionalities can be applied, except for the following two aspects:
Compare the differential number of interactions and interaction
strength among different cell populations using
netVisual_diffInteraction
. However, USERS can still use
netVisual_circle
fucntion to show the number of
interactions and interaction strength.
Identify signaling groups based on their functional similarity
using
computeNetSimilarityPairwise(cellchat, type = "functional")
.
However, USERS can still use
computeNetSimilarityPairwise(cellchat, type = "structural")
to perform structure similarity analysis.
Please check out our paper for the comparison analysis of two scRNA-seq datasets, one from embryonic day E13.5 skin and another from adult day 12 wound skin.
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur 10.16
#>
#> Matrix products: default
#> BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
#>
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] patchwork_1.1.1 CellChat_1.6.0 Biobase_2.54.0
#> [4] BiocGenerics_0.40.0 ggplot2_3.3.5 igraph_1.3.4
#> [7] dplyr_1.0.7
#>
#> loaded via a namespace (and not attached):
#> [1] colorspace_2.0-2 ggsignif_0.6.3 rjson_0.2.20
#> [4] ellipsis_0.3.2 circlize_0.4.13 GlobalOptions_0.1.2
#> [7] BiocNeighbors_1.12.0 clue_0.3-60 ggpubr_0.4.0
#> [10] listenv_0.8.0 ggrepel_0.9.1 RSpectra_0.16-0
#> [13] fansi_0.5.0 codetools_0.2-18 doParallel_1.0.16
#> [16] knitr_1.40 jsonlite_1.7.2 broom_0.7.10
#> [19] gridBase_0.4-7 cluster_2.1.2 png_0.1-7
#> [22] compiler_4.1.2 backports_1.4.1 assertthat_0.2.1
#> [25] Matrix_1.3-4 fastmap_1.1.0 htmltools_0.5.2
#> [28] tools_4.1.2 coda_0.19-4 gtable_0.3.0
#> [31] glue_1.6.0 reshape2_1.4.4 Rcpp_1.0.7
#> [34] carData_3.0-4 statnet.common_4.5.0 jquerylib_0.1.4
#> [37] NMF_0.23.0 vctrs_0.3.8 svglite_2.0.0
#> [40] iterators_1.0.13 ggalluvial_0.12.3 xfun_0.33
#> [43] stringr_1.4.0 globals_0.14.0 network_1.17.1
#> [46] lifecycle_1.0.1 irlba_2.3.5 rngtools_1.5.2
#> [49] rstatix_0.7.0 future_1.23.0 scales_1.1.1
#> [52] parallel_4.1.2 RColorBrewer_1.1-2 ComplexHeatmap_2.10.0
#> [55] yaml_2.2.1 reticulate_1.22 pbapply_1.5-0
#> [58] pkgmaker_0.32.2 ggnetwork_0.5.10 sass_0.4.0
#> [61] stringi_1.7.6 highr_0.9 S4Vectors_0.32.3
#> [64] foreach_1.5.1 BiocParallel_1.28.3 shape_1.4.6
#> [67] rlang_0.4.12 pkgconfig_2.0.3 systemfonts_1.0.2
#> [70] matrixStats_0.61.0 evaluate_0.17 lattice_0.20-45
#> [73] purrr_0.3.4 cowplot_1.1.1 tidyselect_1.1.1
#> [76] parallelly_1.30.0 plyr_1.8.6 magrittr_2.0.1
#> [79] R6_2.5.1 IRanges_2.28.0 generics_0.1.1
#> [82] sna_2.6 DBI_1.1.2 pillar_1.6.4
#> [85] withr_2.4.3 abind_1.4-5 tibble_3.1.6
#> [88] future.apply_1.8.1 crayon_1.4.2 car_3.0-12
#> [91] utf8_1.2.2 rmarkdown_2.17 GetoptLong_1.0.5
#> [94] grid_4.1.2 FNN_1.1.3 digest_0.6.29
#> [97] xtable_1.8-4 tidyr_1.1.4 stats4_4.1.2
#> [100] munsell_0.5.0 registry_0.5-1 bslib_0.3.1