1. load libraries
2. Load Seurat Object
#Load Seurat Object Integrated Object
load("Melange_v3.Robj")
Melange
An object of class Seurat
59684 features across 81220 samples within 3 assays
Active assay: SCT (23076 features, 3000 variable features)
3 layers present: counts, data, scale.data
2 other assays present: RNA, ADT
2 dimensional reductions calculated: pca, umap
DefaultAssay(Melange) <- "SCT"
3. Data input & processing and initialization of CellChat
object
#------------------------------------------------------------------------------
# **Part I: Data input & processing and initialization of CellChat object**
#------------------------------------------------------------------------------
# Loading and Preparing Data
Melange <- AddMetaData(object = Melange,
metadata = paste0("Cluster_", Melange$seurat_clusters),
col.name = 'Clusters')
#Melange[["RNA"]] <- JoinLayers(Melange[["RNA"]])
# Extract the normalized data
#data_input <- GetAssayData(Melange, assay = "RNA", slot = "data")
data.input <- Melange@assays$SCT$data
#1. Create CellChat object
cellchat <- createCellChat(object = data.input, meta = Melange@meta.data, group.by = "Clusters")
[1] "Create a CellChat object from a data matrix"
Warning: The 'meta' data does not have a column named `samples`. We now add this column and all cells are assumed to belong to `sample1`!
Set cell identities for the new CellChat object
The cell groups used for CellChat analysis are Cluster_0, Cluster_1, Cluster_10, Cluster_11, Cluster_12, Cluster_13, Cluster_14, Cluster_15, Cluster_16, Cluster_17, Cluster_18, Cluster_19, Cluster_2, Cluster_20, Cluster_21, Cluster_22, Cluster_23, Cluster_24, Cluster_25, Cluster_26, Cluster_27, Cluster_28, Cluster_29, Cluster_3, Cluster_4, Cluster_5, Cluster_6, Cluster_7, Cluster_8, Cluster_9
#2. Set the ligand-receptor interaction database
cellchatDB <- CellChatDB.human # or CellChatDB.mouse
showDatabaseCategory(cellchatDB)

# Show the structure of the database
dplyr::glimpse(cellchatDB$interaction)
Rows: 3,233
Columns: 28
$ interaction_name <chr> "TGFB1_TGFBR1_TGFBR2", "TGFB2_TGFBR1_TGFBR2", "TGFB3_TGFBR1_TGFBR2", "TGFB1_ACVR1B_TGFBR2", "TGFB…
$ pathway_name <chr> "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "TGFb", "…
$ ligand <chr> "TGFB1", "TGFB2", "TGFB3", "TGFB1", "TGFB1", "TGFB2", "TGFB2", "TGFB3", "TGFB3", "TGFB1", "TGFB2"…
$ receptor <chr> "TGFbR1_R2", "TGFbR1_R2", "TGFbR1_R2", "ACVR1B_TGFbR2", "ACVR1C_TGFbR2", "ACVR1B_TGFbR2", "ACVR1C…
$ agonist <chr> "TGFb agonist", "TGFb agonist", "TGFb agonist", "TGFb agonist", "TGFb agonist", "TGFb agonist", "…
$ antagonist <chr> "TGFb antagonist", "TGFb antagonist", "TGFb antagonist", "TGFb antagonist", "TGFb antagonist", "T…
$ co_A_receptor <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "…
$ co_I_receptor <chr> "TGFb inhibition receptor", "TGFb inhibition receptor", "TGFb inhibition receptor", "TGFb inhibit…
$ evidence <chr> "KEGG: hsa04350", "KEGG: hsa04350", "KEGG: hsa04350", "PMID: 27449815", "PMID: 27449815", "PMID: …
$ annotation <chr> "Secreted Signaling", "Secreted Signaling", "Secreted Signaling", "Secreted Signaling", "Secreted…
$ interaction_name_2 <chr> "TGFB1 - (TGFBR1+TGFBR2)", "TGFB2 - (TGFBR1+TGFBR2)", "TGFB3 - (TGFBR1+TGFBR2)", "TGFB1 - (ACVR1B…
$ is_neurotransmitter <lgl> FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,…
$ ligand.symbol <chr> "TGFB1", "TGFB2", "TGFB3", "TGFB1", "TGFB1", "TGFB2", "TGFB2", "TGFB3", "TGFB3", "TGFB1", "TGFB2"…
$ ligand.family <chr> "TGF-beta", "TGF-beta", "TGF-beta", "TGF-beta", "TGF-beta", "TGF-beta", "TGF-beta", "TGF-beta", "…
$ ligand.location <chr> "Extracellular matrix, Secreted, Extracellular space", "Extracellular matrix, Secreted, Extracell…
$ ligand.keyword <chr> "Disease variant, Signal, Reference proteome, Extracellular matrix, Disulfide bond, Secreted, Mit…
$ ligand.secreted_type <chr> "growth factor", "growth factor", "cytokine;growth factor", "growth factor", "growth factor", "gr…
$ ligand.transmembrane <lgl> FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FAL…
$ receptor.symbol <chr> "TGFBR2, TGFBR1", "TGFBR2, TGFBR1", "TGFBR2, TGFBR1", "TGFBR2, ACVR1B", "TGFBR2, ACVR1C", "TGFBR2…
$ receptor.family <chr> "Protein kinase superfamily, TKL Ser/Thr protein kinase", "Protein kinase superfamily, TKL Ser/Th…
$ receptor.location <chr> "Cell membrane, Secreted, Membrane raft, Cell surface, Cell junction, Tight junction", "Cell memb…
$ receptor.keyword <chr> "Membrane, Secreted, Disulfide bond, Kinase, Transmembrane, Differentiation, ATP-binding, Recepto…
$ receptor.surfaceome_main <chr> "Receptors", "Receptors", "Receptors", "Receptors", "Receptors", "Receptors", "Receptors", "Recep…
$ receptor.surfaceome_sub <chr> "Act.TGFB;Kinase", "Act.TGFB;Kinase", "Act.TGFB;Kinase", "Act.TGFB;Kinase", "Act.TGFB;Kinase", "A…
$ receptor.adhesome <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "…
$ receptor.secreted_type <chr> "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "…
$ receptor.transmembrane <lgl> TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, T…
$ version <chr> "CellChatDB v1", "CellChatDB v1", "CellChatDB v1", "CellChatDB v1", "CellChatDB v1", "CellChatDB …
# use a subset of CellChatDB for cell-cell communication analysis
cellchatDB.use <- subsetDB(cellchatDB, search = "Secreted Signaling", key = "annotation") # use Secreted Signaling
# set the used database in the object
cellchat@DB <- cellchatDB.use
#------------------------------------------------------------------------------
# **Preprocessing the expression data for cell-cell communication analysis**
#------------------------------------------------------------------------------
#3. Preprocess the expression data
cellchat <- subsetData(cellchat)
cellchat <- identifyOverExpressedGenes(cellchat)
cellchat <- identifyOverExpressedInteractions(cellchat)
| | 0 % ~calculating
|+ | 1 % ~00s
|++ | 2 % ~00s
|++ | 4 % ~00s
|+++ | 5 % ~00s
|+++ | 6 % ~00s
|++++ | 7 % ~00s
|+++++ | 8 % ~00s
|+++++ | 9 % ~00s
|++++++ | 11% ~00s
|++++++ | 12% ~00s
|+++++++ | 13% ~00s
|++++++++ | 14% ~00s
|++++++++ | 15% ~00s
|+++++++++ | 16% ~00s
|+++++++++ | 18% ~00s
|++++++++++ | 19% ~00s
|++++++++++ | 20% ~00s
|+++++++++++ | 21% ~00s
|++++++++++++ | 22% ~00s
|++++++++++++ | 24% ~00s
|+++++++++++++ | 25% ~00s
|+++++++++++++ | 26% ~00s
|++++++++++++++ | 27% ~00s
|+++++++++++++++ | 28% ~00s
|+++++++++++++++ | 29% ~00s
|++++++++++++++++ | 31% ~00s
|++++++++++++++++ | 32% ~00s
|+++++++++++++++++ | 33% ~00s
|++++++++++++++++++ | 34% ~00s
|++++++++++++++++++ | 35% ~00s
|+++++++++++++++++++ | 36% ~00s
|+++++++++++++++++++ | 38% ~00s
|++++++++++++++++++++ | 39% ~00s
|++++++++++++++++++++ | 40% ~00s
|+++++++++++++++++++++ | 41% ~00s
|++++++++++++++++++++++ | 42% ~00s
|++++++++++++++++++++++ | 44% ~00s
|+++++++++++++++++++++++ | 45% ~00s
|+++++++++++++++++++++++ | 46% ~00s
|++++++++++++++++++++++++ | 47% ~00s
|+++++++++++++++++++++++++ | 48% ~00s
|+++++++++++++++++++++++++ | 49% ~00s
|++++++++++++++++++++++++++ | 51% ~00s
|++++++++++++++++++++++++++ | 52% ~00s
|+++++++++++++++++++++++++++ | 53% ~00s
|++++++++++++++++++++++++++++ | 54% ~00s
|++++++++++++++++++++++++++++ | 55% ~00s
|+++++++++++++++++++++++++++++ | 56% ~00s
|+++++++++++++++++++++++++++++ | 58% ~00s
|++++++++++++++++++++++++++++++ | 59% ~00s
|++++++++++++++++++++++++++++++ | 60% ~00s
|+++++++++++++++++++++++++++++++ | 61% ~00s
|++++++++++++++++++++++++++++++++ | 62% ~00s
|++++++++++++++++++++++++++++++++ | 64% ~00s
|+++++++++++++++++++++++++++++++++ | 65% ~00s
|+++++++++++++++++++++++++++++++++ | 66% ~00s
|++++++++++++++++++++++++++++++++++ | 67% ~00s
|+++++++++++++++++++++++++++++++++++ | 68% ~00s
|+++++++++++++++++++++++++++++++++++ | 69% ~00s
|++++++++++++++++++++++++++++++++++++ | 71% ~00s
|++++++++++++++++++++++++++++++++++++ | 72% ~00s
|+++++++++++++++++++++++++++++++++++++ | 73% ~00s
|++++++++++++++++++++++++++++++++++++++ | 74% ~00s
|++++++++++++++++++++++++++++++++++++++ | 75% ~00s
|+++++++++++++++++++++++++++++++++++++++ | 76% ~00s
|+++++++++++++++++++++++++++++++++++++++ | 78% ~00s
|++++++++++++++++++++++++++++++++++++++++ | 79% ~00s
|++++++++++++++++++++++++++++++++++++++++ | 80% ~00s
|+++++++++++++++++++++++++++++++++++++++++ | 81% ~00s
|++++++++++++++++++++++++++++++++++++++++++ | 82% ~00s
|++++++++++++++++++++++++++++++++++++++++++ | 84% ~00s
|+++++++++++++++++++++++++++++++++++++++++++ | 85% ~00s
|+++++++++++++++++++++++++++++++++++++++++++ | 86% ~00s
|++++++++++++++++++++++++++++++++++++++++++++ | 87% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++ | 88% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++ | 89% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++ | 91% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++ | 92% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 93% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 94% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 95% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
| | 0 % ~calculating
|+ | 1 % ~00s
|++ | 2 % ~00s
|++ | 4 % ~00s
|+++ | 5 % ~00s
|+++ | 6 % ~00s
|++++ | 7 % ~00s
|+++++ | 8 % ~00s
|+++++ | 9 % ~00s
|++++++ | 11% ~00s
|++++++ | 12% ~00s
|+++++++ | 13% ~00s
|++++++++ | 14% ~00s
|++++++++ | 15% ~00s
|+++++++++ | 16% ~00s
|+++++++++ | 18% ~00s
|++++++++++ | 19% ~00s
|++++++++++ | 20% ~00s
|+++++++++++ | 21% ~00s
|++++++++++++ | 22% ~00s
|++++++++++++ | 24% ~00s
|+++++++++++++ | 25% ~00s
|+++++++++++++ | 26% ~00s
|++++++++++++++ | 27% ~00s
|+++++++++++++++ | 28% ~00s
|+++++++++++++++ | 29% ~00s
|++++++++++++++++ | 31% ~00s
|++++++++++++++++ | 32% ~00s
|+++++++++++++++++ | 33% ~00s
|++++++++++++++++++ | 34% ~00s
|++++++++++++++++++ | 35% ~00s
|+++++++++++++++++++ | 36% ~00s
|+++++++++++++++++++ | 38% ~00s
|++++++++++++++++++++ | 39% ~00s
|++++++++++++++++++++ | 40% ~00s
|+++++++++++++++++++++ | 41% ~00s
|++++++++++++++++++++++ | 42% ~00s
|++++++++++++++++++++++ | 44% ~00s
|+++++++++++++++++++++++ | 45% ~00s
|+++++++++++++++++++++++ | 46% ~00s
|++++++++++++++++++++++++ | 47% ~00s
|+++++++++++++++++++++++++ | 48% ~00s
|+++++++++++++++++++++++++ | 49% ~00s
|++++++++++++++++++++++++++ | 51% ~00s
|++++++++++++++++++++++++++ | 52% ~00s
|+++++++++++++++++++++++++++ | 53% ~00s
|++++++++++++++++++++++++++++ | 54% ~00s
|++++++++++++++++++++++++++++ | 55% ~00s
|+++++++++++++++++++++++++++++ | 56% ~00s
|+++++++++++++++++++++++++++++ | 58% ~00s
|++++++++++++++++++++++++++++++ | 59% ~00s
|++++++++++++++++++++++++++++++ | 60% ~00s
|+++++++++++++++++++++++++++++++ | 61% ~00s
|++++++++++++++++++++++++++++++++ | 62% ~00s
|++++++++++++++++++++++++++++++++ | 64% ~00s
|+++++++++++++++++++++++++++++++++ | 65% ~00s
|+++++++++++++++++++++++++++++++++ | 66% ~00s
|++++++++++++++++++++++++++++++++++ | 67% ~00s
|+++++++++++++++++++++++++++++++++++ | 68% ~00s
|+++++++++++++++++++++++++++++++++++ | 69% ~00s
|++++++++++++++++++++++++++++++++++++ | 71% ~00s
|++++++++++++++++++++++++++++++++++++ | 72% ~00s
|+++++++++++++++++++++++++++++++++++++ | 73% ~00s
|++++++++++++++++++++++++++++++++++++++ | 74% ~00s
|++++++++++++++++++++++++++++++++++++++ | 75% ~00s
|+++++++++++++++++++++++++++++++++++++++ | 76% ~00s
|+++++++++++++++++++++++++++++++++++++++ | 78% ~00s
|++++++++++++++++++++++++++++++++++++++++ | 79% ~00s
|++++++++++++++++++++++++++++++++++++++++ | 80% ~00s
|+++++++++++++++++++++++++++++++++++++++++ | 81% ~00s
|++++++++++++++++++++++++++++++++++++++++++ | 82% ~00s
|++++++++++++++++++++++++++++++++++++++++++ | 84% ~00s
|+++++++++++++++++++++++++++++++++++++++++++ | 85% ~00s
|+++++++++++++++++++++++++++++++++++++++++++ | 86% ~00s
|++++++++++++++++++++++++++++++++++++++++++++ | 87% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++ | 88% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++ | 89% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++ | 91% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++ | 92% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 93% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 94% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 95% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
| | 0 % ~calculating
|+ | 1 % ~00s
|++ | 2 % ~00s
|++ | 3 % ~00s
|+++ | 4 % ~00s
|+++ | 5 % ~00s
|++++ | 6 % ~00s
|++++ | 7 % ~00s
|+++++ | 8 % ~00s
|+++++ | 9 % ~00s
|++++++ | 10% ~00s
|++++++ | 11% ~00s
|+++++++ | 12% ~00s
|+++++++ | 13% ~00s
|++++++++ | 14% ~00s
|++++++++ | 15% ~00s
|+++++++++ | 16% ~00s
|+++++++++ | 17% ~00s
|++++++++++ | 18% ~00s
|++++++++++ | 19% ~00s
|+++++++++++ | 20% ~00s
|+++++++++++ | 21% ~00s
|++++++++++++ | 22% ~00s
|++++++++++++ | 23% ~00s
|+++++++++++++ | 24% ~00s
|+++++++++++++ | 25% ~00s
|++++++++++++++ | 26% ~00s
|++++++++++++++ | 27% ~00s
|+++++++++++++++ | 28% ~00s
|+++++++++++++++ | 29% ~00s
|++++++++++++++++ | 30% ~00s
|++++++++++++++++ | 31% ~00s
|+++++++++++++++++ | 32% ~00s
|+++++++++++++++++ | 33% ~00s
|++++++++++++++++++ | 34% ~00s
|++++++++++++++++++ | 35% ~00s
|+++++++++++++++++++ | 36% ~00s
|+++++++++++++++++++ | 37% ~00s
|++++++++++++++++++++ | 38% ~00s
|++++++++++++++++++++ | 39% ~00s
|+++++++++++++++++++++ | 40% ~00s
|+++++++++++++++++++++ | 41% ~00s
|++++++++++++++++++++++ | 42% ~00s
|++++++++++++++++++++++ | 43% ~00s
|+++++++++++++++++++++++ | 44% ~00s
|+++++++++++++++++++++++ | 45% ~00s
|++++++++++++++++++++++++ | 46% ~00s
|++++++++++++++++++++++++ | 47% ~00s
|+++++++++++++++++++++++++ | 48% ~00s
|+++++++++++++++++++++++++ | 49% ~00s
|++++++++++++++++++++++++++ | 51% ~00s
|++++++++++++++++++++++++++ | 52% ~00s
|+++++++++++++++++++++++++++ | 53% ~00s
|+++++++++++++++++++++++++++ | 54% ~00s
|++++++++++++++++++++++++++++ | 55% ~00s
|++++++++++++++++++++++++++++ | 56% ~00s
|+++++++++++++++++++++++++++++ | 57% ~00s
|+++++++++++++++++++++++++++++ | 58% ~00s
|++++++++++++++++++++++++++++++ | 59% ~00s
|++++++++++++++++++++++++++++++ | 60% ~00s
|+++++++++++++++++++++++++++++++ | 61% ~00s
|+++++++++++++++++++++++++++++++ | 62% ~00s
|++++++++++++++++++++++++++++++++ | 63% ~00s
|++++++++++++++++++++++++++++++++ | 64% ~00s
|+++++++++++++++++++++++++++++++++ | 65% ~00s
|+++++++++++++++++++++++++++++++++ | 66% ~00s
|++++++++++++++++++++++++++++++++++ | 67% ~00s
|++++++++++++++++++++++++++++++++++ | 68% ~00s
|+++++++++++++++++++++++++++++++++++ | 69% ~00s
|+++++++++++++++++++++++++++++++++++ | 70% ~00s
|++++++++++++++++++++++++++++++++++++ | 71% ~00s
|++++++++++++++++++++++++++++++++++++ | 72% ~00s
|+++++++++++++++++++++++++++++++++++++ | 73% ~00s
|+++++++++++++++++++++++++++++++++++++ | 74% ~00s
|++++++++++++++++++++++++++++++++++++++ | 75% ~00s
|++++++++++++++++++++++++++++++++++++++ | 76% ~00s
|+++++++++++++++++++++++++++++++++++++++ | 77% ~00s
|+++++++++++++++++++++++++++++++++++++++ | 78% ~00s
|++++++++++++++++++++++++++++++++++++++++ | 79% ~00s
|++++++++++++++++++++++++++++++++++++++++ | 80% ~00s
|+++++++++++++++++++++++++++++++++++++++++ | 81% ~00s
|+++++++++++++++++++++++++++++++++++++++++ | 82% ~00s
|++++++++++++++++++++++++++++++++++++++++++ | 83% ~00s
|++++++++++++++++++++++++++++++++++++++++++ | 84% ~00s
|+++++++++++++++++++++++++++++++++++++++++++ | 85% ~00s
|+++++++++++++++++++++++++++++++++++++++++++ | 86% ~00s
|++++++++++++++++++++++++++++++++++++++++++++ | 87% ~00s
|++++++++++++++++++++++++++++++++++++++++++++ | 88% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++ | 89% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++ | 90% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++ | 91% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++ | 92% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 93% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++ | 94% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 95% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++ | 96% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 97% ~00s
|+++++++++++++++++++++++++++++++++++++++++++++++++ | 98% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 99% ~00s
|++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=00s
The number of highly variable ligand-receptor pairs used for signaling inference is 675
4. Inference of cell-cell communication network
#------------------------------------------------------------------------------
# **Part II: Inference of cell-cell communication network**
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------------
# **Compute the communication probability and infer cellular communication network**
#------------------------------------------------------------------------------------
#4. Compute communication probability and infer cellular communication network
cellchat <- computeCommunProb(cellchat)
triMean is used for calculating the average gene expression per cell group.
[1] ">>> Run CellChat on sc/snRNA-seq data <<< [2024-09-12 15:29:38.877459]"
|
| | 0%
|
|= | 0%
|
|= | 1%
|
|== | 1%
|
|== | 2%
|
|=== | 2%
|
|=== | 3%
|
|==== | 3%
|
|==== | 4%
|
|===== | 4%
|
|====== | 5%
|
|======= | 5%
|
|======= | 6%
|
|======== | 6%
|
|======== | 7%
|
|========= | 7%
|
|========= | 8%
|
|========== | 8%
|
|========== | 9%
|
|=========== | 9%
|
|============ | 9%
|
|============ | 10%
|
|============= | 10%
|
|============= | 11%
|
|============== | 11%
|
|============== | 12%
|
|=============== | 12%
|
|=============== | 13%
|
|================ | 13%
|
|================= | 14%
|
|================== | 14%
|
|================== | 15%
|
|=================== | 15%
|
|=================== | 16%
|
|==================== | 16%
|
|==================== | 17%
|
|===================== | 17%
|
|====================== | 18%
|
|======================= | 19%
|
|======================== | 19%
|
|======================== | 20%
|
|========================= | 20%
|
|========================= | 21%
|
|========================== | 21%
|
|========================== | 22%
|
|=========================== | 22%
|
|=========================== | 23%
|
|============================ | 23%
|
|============================= | 23%
|
|============================= | 24%
|
|============================== | 24%
|
|============================== | 25%
|
|=============================== | 25%
|
|=============================== | 26%
|
|================================ | 26%
|
|================================ | 27%
|
|================================= | 27%
|
|================================== | 28%
|
|=================================== | 28%
|
|=================================== | 29%
|
|==================================== | 29%
|
|==================================== | 30%
|
|===================================== | 30%
|
|===================================== | 31%
|
|====================================== | 31%
|
|====================================== | 32%
|
|======================================= | 32%
|
|======================================== | 32%
|
|======================================== | 33%
|
|========================================= | 33%
|
|========================================= | 34%
|
|========================================== | 34%
|
|========================================== | 35%
|
|=========================================== | 35%
|
|=========================================== | 36%
|
|============================================ | 36%
|
|============================================= | 37%
|
|============================================== | 37%
|
|============================================== | 38%
|
|=============================================== | 38%
|
|=============================================== | 39%
|
|================================================ | 39%
|
|================================================ | 40%
|
|================================================= | 40%
|
|================================================== | 41%
|
|=================================================== | 41%
|
|=================================================== | 42%
|
|==================================================== | 42%
|
|==================================================== | 43%
|
|===================================================== | 43%
|
|===================================================== | 44%
|
|====================================================== | 44%
|
|====================================================== | 45%
|
|======================================================= | 45%
|
|======================================================== | 46%
|
|========================================================= | 46%
|
|========================================================= | 47%
|
|========================================================== | 47%
|
|========================================================== | 48%
|
|=========================================================== | 48%
|
|=========================================================== | 49%
|
|============================================================ | 49%
|
|============================================================= | 50%
|
|============================================================== | 51%
|
|=============================================================== | 51%
|
|=============================================================== | 52%
|
|================================================================ | 52%
|
|================================================================ | 53%
|
|================================================================= | 53%
|
|================================================================= | 54%
|
|================================================================== | 54%
|
|=================================================================== | 55%
|
|==================================================================== | 55%
|
|==================================================================== | 56%
|
|===================================================================== | 56%
|
|===================================================================== | 57%
|
|====================================================================== | 57%
|
|====================================================================== | 58%
|
|======================================================================= | 58%
|
|======================================================================= | 59%
|
|======================================================================== | 59%
|
|========================================================================= | 60%
|
|========================================================================== | 60%
|
|========================================================================== | 61%
|
|=========================================================================== | 61%
|
|=========================================================================== | 62%
|
|============================================================================ | 62%
|
|============================================================================ | 63%
|
|============================================================================= | 63%
|
|============================================================================== | 64%
|
|=============================================================================== | 64%
|
|=============================================================================== | 65%
|
|================================================================================ | 65%
|
|================================================================================ | 66%
|
|================================================================================= | 66%
|
|================================================================================= | 67%
|
|================================================================================== | 67%
|
|================================================================================== | 68%
|
|=================================================================================== | 68%
|
|==================================================================================== | 68%
|
|==================================================================================== | 69%
|
|===================================================================================== | 69%
|
|===================================================================================== | 70%
|
|====================================================================================== | 70%
|
|====================================================================================== | 71%
|
|======================================================================================= | 71%
|
|======================================================================================= | 72%
|
|======================================================================================== | 72%
|
|========================================================================================= | 73%
|
|========================================================================================== | 73%
|
|========================================================================================== | 74%
|
|=========================================================================================== | 74%
|
|=========================================================================================== | 75%
|
|============================================================================================ | 75%
|
|============================================================================================ | 76%
|
|============================================================================================= | 76%
|
|============================================================================================= | 77%
|
|============================================================================================== | 77%
|
|=============================================================================================== | 77%
|
|=============================================================================================== | 78%
|
|================================================================================================ | 78%
|
|================================================================================================ | 79%
|
|================================================================================================= | 79%
|
|================================================================================================= | 80%
|
|================================================================================================== | 80%
|
|================================================================================================== | 81%
|
|=================================================================================================== | 81%
|
|==================================================================================================== | 82%
|
|===================================================================================================== | 83%
|
|====================================================================================================== | 83%
|
|====================================================================================================== | 84%
|
|======================================================================================================= | 84%
|
|======================================================================================================= | 85%
|
|======================================================================================================== | 85%
|
|======================================================================================================== | 86%
|
|========================================================================================================= | 86%
|
|========================================================================================================== | 87%
|
|=========================================================================================================== | 87%
|
|=========================================================================================================== | 88%
|
|============================================================================================================ | 88%
|
|============================================================================================================ | 89%
|
|============================================================================================================= | 89%
|
|============================================================================================================= | 90%
|
|============================================================================================================== | 90%
|
|============================================================================================================== | 91%
|
|=============================================================================================================== | 91%
|
|================================================================================================================ | 91%
|
|================================================================================================================ | 92%
|
|================================================================================================================= | 92%
|
|================================================================================================================= | 93%
|
|================================================================================================================== | 93%
|
|================================================================================================================== | 94%
|
|=================================================================================================================== | 94%
|
|=================================================================================================================== | 95%
|
|==================================================================================================================== | 95%
|
|===================================================================================================================== | 96%
|
|====================================================================================================================== | 96%
|
|====================================================================================================================== | 97%
|
|======================================================================================================================= | 97%
|
|======================================================================================================================= | 98%
|
|======================================================================================================================== | 98%
|
|======================================================================================================================== | 99%
|
|========================================================================================================================= | 99%
|
|========================================================================================================================= | 100%
|
|==========================================================================================================================| 100%
[1] ">>> CellChat inference is done. Parameter values are stored in `object@options$parameter` <<< [2024-09-12 15:37:26.883988]"
cellchat <- filterCommunication(cellchat, min.cells = 10)
#------------------------------------------------------------------------------
# **Infer the cell-cell communication at a signaling pathway level**
#------------------------------------------------------------------------------
#5. Compute communication at the pathway level
cellchat <- computeCommunProbPathway(cellchat)
#------------------------------------------------------------------------------
# **Calculate the aggregated cell-cell communication network**
#------------------------------------------------------------------------------
#6. Aggregate the inferred cell-cell communication network
cellchat <- aggregateNet(cellchat)
#7. Visualize the communication network
groupSize <- as.numeric(table(cellchat@idents))
netVisual_circle(cellchat@net$count, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Number of interactions")


netVisual_circle(cellchat@net$weight, vertex.weight = groupSize, weight.scale = T, label.edge= F, title.name = "Interaction weights/strength")

mat <- cellchat@net$weight
par(mfrow = c(3,4), xpd=TRUE)

for (i in 1:nrow(mat)) {
mat2 <- matrix(0, nrow = nrow(mat), ncol = ncol(mat), dimnames = dimnames(mat))
mat2[i, ] <- mat[i, ]
netVisual_circle(mat2, vertex.weight = groupSize, weight.scale = T, edge.weight.max = max(mat), title.name = rownames(mat)[i])
}


NA

5. Visualization of cell-cell communication network
#------------------------------------------------------------------------------
# **Part III: Visualization of cell-cell communication network**
#------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------
# **Visualize each signaling pathway using Hierarchy plot, Circle plot or Chord diagram**
#----------------------------------------------------------------------------------------------------
pathways.show <- c("IL2")
# Hierarchy plot
# Here we define `vertex.receive` so that the left portion of the hierarchy plot shows signaling to fibroblast and the right portion shows signaling to immune cells
vertex.receiver = seq(1,4) # a numeric vector.
netVisual_aggregate(cellchat, signaling = pathways.show, vertex.receiver = vertex.receiver)

# Circle plot
par(mfrow=c(1,1))

netVisual_aggregate(cellchat, signaling = pathways.show, layout = "circle")

# Chord diagram
par(mfrow=c(1,1))

netVisual_aggregate(cellchat, signaling = pathways.show, layout = "chord")

# Heatmap
par(mfrow=c(1,1))

netVisual_heatmap(cellchat, signaling = pathways.show, color.heatmap = "Reds")
Do heatmap based on a single object

#> Do heatmap based on a single object
# Get the levels of cell types
cell_types <- levels(cellchat@idents)
# Chord diagram
group.cellType <- c(rep("MK", 4), rep("IL2", 4), rep("TNF", 4))
group.cellType <- rep(NA, length(cell_types))
# Assign each cell type to a group
# You'll need to adjust this based on your actual data and biological knowledge
group.cellType[1:8] <- "MK"
group.cellType[9:16] <- "IL2"
group.cellType[17:30] <- "TNF"
# Name the vector with the cell types
names(group.cellType) <- cell_types
# Check the result
print(group.cellType)
Cluster_0 Cluster_1 Cluster_10 Cluster_11 Cluster_12 Cluster_13 Cluster_14 Cluster_15 Cluster_16 Cluster_17 Cluster_18 Cluster_19
"MK" "MK" "MK" "MK" "MK" "MK" "MK" "MK" "IL2" "IL2" "IL2" "IL2"
Cluster_2 Cluster_20 Cluster_21 Cluster_22 Cluster_23 Cluster_24 Cluster_25 Cluster_26 Cluster_27 Cluster_28 Cluster_29 Cluster_3
"IL2" "IL2" "IL2" "IL2" "TNF" "TNF" "TNF" "TNF" "TNF" "TNF" "TNF" "TNF"
Cluster_4 Cluster_5 Cluster_6 Cluster_7 Cluster_8 Cluster_9
"TNF" "TNF" "TNF" "TNF" "TNF" "TNF"
netVisual_chord_cell(cellchat, signaling = pathways.show, group = group.cellType, title.name = paste0(pathways.show, " signaling network"))
Plot the aggregated cell-cell communication network at the signaling pathway level


#> Plot the aggregated cell-cell communication network at the signaling pathway level
# Compute the contribution of each ligand-receptor pair to the overall signaling pathway and visualize cell-cell
#communication mediated by a single ligand-receptor pair
netAnalysis_contribution(cellchat, signaling = pathways.show)

pairLR.CXCL <- extractEnrichedLR(cellchat, signaling = pathways.show, geneLR.return = FALSE)
LR.show <- pairLR.CXCL[1,] # show one ligand-receptor pair
# Hierarchy plot
vertex.receiver = seq(1,4) # a numeric vector
netVisual_individual(cellchat, signaling = pathways.show, pairLR.use = LR.show, vertex.receiver = vertex.receiver)
[[1]]


#> [[1]]
# Circle plot
netVisual_individual(cellchat, signaling = pathways.show, pairLR.use = LR.show, layout = "circle")
[[1]]


#> [[1]]
# Chord diagram
netVisual_individual(cellchat, signaling = pathways.show, pairLR.use = LR.show, layout = "chord")
[[1]]


# Access all the signaling pathways showing significant communications
pathways.show.all <- cellchat@netP$pathways
# check the order of cell identity to set suitable vertex.receiver
levels(cellchat@idents)
[1] "Cluster_0" "Cluster_1" "Cluster_10" "Cluster_11" "Cluster_12" "Cluster_13" "Cluster_14" "Cluster_15" "Cluster_16"
[10] "Cluster_17" "Cluster_18" "Cluster_19" "Cluster_2" "Cluster_20" "Cluster_21" "Cluster_22" "Cluster_23" "Cluster_24"
[19] "Cluster_25" "Cluster_26" "Cluster_27" "Cluster_28" "Cluster_29" "Cluster_3" "Cluster_4" "Cluster_5" "Cluster_6"
[28] "Cluster_7" "Cluster_8" "Cluster_9"
vertex.receiver = seq(1,4)
for (i in 1:length(pathways.show.all)) {
# Visualize communication network associated with both signaling pathway and individual L-R pairs
netVisual(cellchat, signaling = pathways.show.all[i], vertex.receiver = vertex.receiver, layout = "hierarchy")
# Compute and visualize the contribution of each ligand-receptor pair to the overall signaling pathway
gg <- netAnalysis_contribution(cellchat, signaling = pathways.show.all[i])
ggsave(filename=paste0(pathways.show.all[i], "_L-R_contribution.pdf"), plot=gg, width = 3, height = 2, units = 'in', dpi = 300)
}
#----------------------------------------------------------------------------------------------------
# **Visualize cell-cell communication mediated by multiple ligand-receptors or signaling pathways**
#----------------------------------------------------------------------------------------------------
#(A) Bubble plot
# (1) show all the significant interactions (L-R pairs) from some cell groups (defined by 'sources.use') to other cell groups (defined by 'targets.use')
netVisual_bubble(cellchat, sources.use = 4, targets.use = c(5:11), remove.isolate = FALSE)
Comparing communications on a single object

#> Comparing communications on a single object
# (2) show all the significant interactions (L-R pairs) associated with certain signaling pathways
netVisual_bubble(cellchat, sources.use = 4, targets.use = c(5:11), signaling = c("CCL","CXCL"), remove.isolate = FALSE)
Comparing communications on a single object

#> Comparing communications on a single object
# (3) show all the significant interactions (L-R pairs) based on user's input (defined by `pairLR.use`)
pairLR.use <- extractEnrichedLR(cellchat, signaling = c("CCL","CXCL","FGF"))
There is no significant communication of CXCL
There is no significant communication of FGF
netVisual_bubble(cellchat, sources.use = c(3,4), targets.use = c(5:8), pairLR.use = pairLR.use, remove.isolate = TRUE)
Comparing communications on a single object

#> Comparing communications on a single object
# (B) Chord diagram
# show all the significant interactions (L-R pairs) from some cell groups (defined by 'sources.use') to other cell groups (defined by 'targets.use')
# show all the interactions sending from Inflam.FIB
netVisual_chord_gene(cellchat, sources.use = 4, targets.use = c(5:11), lab.cex = 0.5,legend.pos.y = 30)


# show all the interactions received by Inflam.DC
netVisual_chord_gene(cellchat, sources.use = c(1,2,3,4), targets.use = 8, legend.pos.x = 15)


# show all the significant interactions (L-R pairs) associated with certain signaling pathways
netVisual_chord_gene(cellchat, sources.use = c(1,2,3,4), targets.use = c(5:11), signaling = c("CCL","CXCL"),legend.pos.x = 8)


# show all the significant signaling pathways from some cell groups (defined by 'sources.use') to other cell groups (defined by 'targets.use')
netVisual_chord_gene(cellchat, sources.use = c(1,2,3,4), targets.use = c(5:11), slot.name = "netP", legend.pos.x = 10)


#----------------------------------------------------------------------------------------------------
# **Plot the signaling gene expression distribution using violin/dot plot**
#----------------------------------------------------------------------------------------------------
plotGeneExpression(cellchat, signaling = "CXCL", enriched.only = TRUE, type = "violin")
There is no significant communication of CXCL
Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.

plotGeneExpression(cellchat, signaling = "CXCL", enriched.only = FALSE)
Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.Warning: Default search for "data" layer in "RNA" assay yielded no results; utilizing "counts" layer instead.Scale for y is already present.
Adding another scale for y, which will replace the existing scale.

6. Systems analysis of cell-cell communication network
#----------------------------------------------------------------------------------------------------
# **Part IV: Systems analysis of cell-cell communication network**
#----------------------------------------------------------------------------------------------------
# (A) Compute and visualize the network centrality scores
ptm = Sys.time()
# Compute the network centrality scores
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP") # the slot 'netP' means the inferred intercellular communication network of signaling pathways
Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-1’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-2’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-3’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-4’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".
# Visualize the computed centrality scores using heatmap, allowing ready identification of major signaling roles of cell groups
netAnalysis_signalingRole_network(cellchat, signaling = pathways.show, width = 8, height = 2.5, font.size = 10)

#(B) Visualize dominant senders (sources) and receivers (targets) in a 2D space
# Signaling role analysis on the aggregated cell-cell communication network from all signaling pathways
gg1 <- netAnalysis_signalingRole_scatter(cellchat)
Signaling role analysis on the aggregated cell-cell communication network from all signaling pathways
#> Signaling role analysis on the aggregated cell-cell communication network from all signaling pathways
# Signaling role analysis on the cell-cell communication networks of interest
gg2 <- netAnalysis_signalingRole_scatter(cellchat, signaling = c("CXCL", "CCL"))
Signaling role analysis on the cell-cell communication network from user's input
#> Signaling role analysis on the cell-cell communication network from user's input
gg1 + gg2

# (C) Identify signals contributing the most to outgoing or incoming signaling of certain cell groups
# Signaling role analysis on the aggregated cell-cell communication network from all signaling pathways
ht1 <- netAnalysis_signalingRole_heatmap(cellchat, pattern = "outgoing")
ht2 <- netAnalysis_signalingRole_heatmap(cellchat, pattern = "incoming")
ht1 + ht2
Warning: Heatmap/annotation names are duplicated: Relative strength

# Signaling role analysis on the cell-cell communication networks of interest
ht <- netAnalysis_signalingRole_heatmap(cellchat, signaling = c("CXCL", "CCL"))
#---------------------------------------------------------------------------------------------------------------------------
# **Identify global communication patterns to explore how multiple cell types and signaling pathways coordinate together**
#----------------------------------------------------------------------------------------------------------------------------
# (A) Identify and visualize outgoing communication pattern of secreting cells
library(NMF)
#> Loading required package: registry
#> Loading required package: rngtools
#> Loading required package: cluster
#> NMF - BioConductor layer [OK] | Shared memory capabilities [NO: bigmemory] | Cores 2/2
#> To enable shared memory capabilities, try: install.extras('
#> NMF
#> ')
#>
#> Attaching package: 'NMF'
#> The following objects are masked from 'package:igraph':
#>
#> algorithm, compare
library(ggalluvial)
selectK(cellchat, pattern = "outgoing")
Warning: Continuous limits supplied to discrete scale.
ℹ Did you mean `limits = factor(...)` or `scale_*_continuous()`?
gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 8931046 477.0 17088110 912.7 17088110 912.7
Vcells 2255385642 17207.3 3872088100 29541.7 3480046454 26550.7
gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 8930921 477.0 17088110 912.7 17088110 912.7
Vcells 2255385451 17207.3 3872088100 29541.7 3480046454 26550.7
gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 8930921 477.0 17088110 912.7 17088110 912.7
Vcells 2255385451 17207.3 3872088100 29541.7 3480046454 26550.7
gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 8930921 477.0 17088110 912.7 17088110 912.7
Vcells 2255385451 17207.3 3872088100 29541.7 3480046454 26550.7
gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 8930921 477.0 17088110 912.7 17088110 912.7
Vcells 2255385451 17207.3 3872088100 29541.7 3480046454 26550.7
gc()
used (Mb) gc trigger (Mb) max used (Mb)
Ncells 8930921 477.0 17088110 912.7 17088110 912.7
Vcells 2255385451 17207.3 3872088100 29541.7 3480046454 26550.7
nPatterns = 6
cellchat <- identifyCommunicationPatterns(cellchat, pattern = "outgoing", k = nPatterns)
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.

# river plot
netAnalysis_river(cellchat, pattern = "outgoing")
Please make sure you have load `library(ggalluvial)` when running this function

#> Please make sure you have load `library(ggalluvial)` when running this function
# dot plot
netAnalysis_dot(cellchat, pattern = "outgoing")

setwd(".")
# (B) Identify and visualize incoming communication pattern of target cells
selectK(cellchat, pattern = "incoming")
Warning: Continuous limits supplied to discrete scale.
ℹ Did you mean `limits = factor(...)` or `scale_*_continuous()`?
nPatterns = 3
cellchat <- identifyCommunicationPatterns(cellchat, pattern = "incoming", k = nPatterns)
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.
Warning: Recycling array of length 1 in array-vector arithmetic is deprecated.
Use c() or as.vector() instead.

# river plot
netAnalysis_river(cellchat, pattern = "incoming")
Please make sure you have load `library(ggalluvial)` when running this function

#> Please make sure you have load `library(ggalluvial)` when running this function
# dot plot
netAnalysis_dot(cellchat, pattern = "incoming")

#---------------------------------------------------------------------------------------------------------------------------
# **Manifold and classification learning analysis of signaling networks**
#----------------------------------------------------------------------------------------------------------------------------
# Identify signaling groups based on their functional similarity
#8. Identify signaling roles and patterns
cellchat <- computeNetSimilarity(cellchat, type = "functional")
library(uwot)
cellchat <- netEmbedding(cellchat, type = "functional", umap.method = "uwot")
Manifold learning of the signaling networks for a single dataset
options(future.globals.maxSize = 16000 * 1024^2) # Set to 16 GB
cellchat <- netClustering(cellchat, type = "functional", do.parallel = FALSE)
Classification learning of the signaling networks for a single dataset
Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-1’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-2’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-3’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-4’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: all eigenvalues are requested, eigen() is used insteadWarning: all eigenvalues are requested, eigen() is used instead
netVisual_embedding(cellchat, type = "functional", label.size = 3.5)
Warning: Using alpha for a discrete variable is not advised.

# Identify signaling groups based on structure similarity
#install umap-learn before running these commands
#pip install umap-learn
cellchat <- computeNetSimilarity(cellchat, type = "structural")
cellchat <- netEmbedding(cellchat, type = "structural", umap.method = "uwot")
Manifold learning of the signaling networks for a single dataset
#> Manifold learning of the signaling networks for a single dataset
options(future.globals.maxSize = 16000 * 1024^2) # Set to 16 GB
cellchat <- netClustering(cellchat, type = "structural", do.parallel = FALSE)
Classification learning of the signaling networks for a single dataset
Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-1’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-2’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-3’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: UNRELIABLE VALUE: One of the ‘future.apply’ iterations (‘future_sapply-4’) unexpectedly generated random numbers without declaring so. There is a risk that those random numbers are not statistically sound and the overall results might be invalid. To fix this, specify 'future.seed=TRUE'. This ensures that proper, parallel-safe random numbers are produced via the L'Ecuyer-CMRG method. To disable this check, use 'future.seed = NULL', or set option 'future.rng.onMisuse' to "ignore".Warning: all eigenvalues are requested, eigen() is used insteadWarning: all eigenvalues are requested, eigen() is used instead
#> Classification learning of the signaling networks for a single dataset
# Visualization in 2D-space
netVisual_embedding(cellchat, type = "structural", label.size = 3.5)
Warning: Using alpha for a discrete variable is not advised.

netVisual_embeddingZoomIn(cellchat, type = "structural", nCol = 2)

7. Save the CellChat object
save(cellchat, file = "cellCHAT_Analysis_Melange.Robj")
LS0tCnRpdGxlOiAiSW5mZXJlbmNlIGFuZCBhbmFseXNpcyBvZiBjZWxsLWNlbGwgY29tbXVuaWNhdGlvbiB1c2luZyBDZWxsQ2hhdC1NZWxhbmdlIgphdXRob3I6IE5hc2lyIE1haG1vb2QgQWJiYXNpCmRhdGU6ICIyMDIzLTA5LTEyIgpvdXRwdXQ6CiAgaHRtbF9ub3RlYm9vazogCiAgICB0b2M6IHRydWUKICAgIHRvY19mbG9hdDogdHJ1ZQogICAgdG9jX2NvbGxhcHNlZDogdHJ1ZQogICAgdGhlbWU6IGRhcmtseQotLS0KCiMgMS4gbG9hZCBsaWJyYXJpZXMKYGBge3Igc2V0dXAsIGluY2x1ZGU9RkFMU0V9CgpsaWJyYXJ5KFNldXJhdCkKbGlicmFyeShkcGx5cikKbGlicmFyeShDZWxsQ2hhdCkKbGlicmFyeShwYXRjaHdvcmspCm9wdGlvbnMoc3RyaW5nc0FzRmFjdG9ycyA9IEZBTFNFKQojIHJldGljdW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