About this page
Tutorial- What this page solves
- You have annotated single-cell data and want to know which cell types exchange signals, and through which ligands and receptors. This page uses PBMC 3k to take you from a Seurat object to a cell-cell communication network and pathway plots.
- Who it is for
- Graduate students and researchers who have already annotated single-cell data, can use Seurat objects, and are doing cell communication analysis for the first time.
- What you will have
- After reading, you will have a saved CellChat object, communication tables at the ligand-receptor and pathway levels, and network circle plots, pathway plots and signaling-role plots.
- Covers
- Inferring ligand-receptor communication between cell groups with CellChat v2 from a Seurat v5 object, with the purpose and a check for each step
- How to read network circle plots, pathway plots and signaling-role plots
- How parameter choices and the database subset change results, as branches
- How to compare groups, plus common errors and pitfalls from old tutorials (in the troubleshooting section)
- Does not cover
- Quality control and annotation of single-cell data; see the single-cell workflow page
- Trajectory and pseudotime analysis, which asks a different question
- Detailed communication analysis of spatial transcriptomics; only briefly covered in the tools branch
- Full tutorials for CellPhoneDB, NicheNet or LIANA+
Main steps
Step 1
Why this stepCellChat is only distributed on GitHub, contains C++ code, and needs a compiler. After installing, record the version number, because the GitHub main branch changes between formal releases.
The dependencies most likely to cause trouble are NMF (CRAN, needs Biobase), ComplexHeatmap and BiocNeighbors (Bioconductor), and presto (GitHub).
The method below was tested on macOS arm64: install the other dependencies with conda, then install presto and CellChat from GitHub. Compiling and installing the three packages took 2.5 minutes with no errors.
The minimum configuration given in Nature Protocols is a dual-core CPU and 16 GB of memory. Errors during installation are in the troubleshooting section.
# 方案 A:conda 装依赖(本页实测,macOS arm64,约 4 分钟 + 编译 2.5 分钟)
micromamba create -y -n cellchat -c conda-forge -c bioconda \
r-base=4.5 r-seurat r-remotes r-rcppeigen c-compiler cxx-compiler fortran-compiler make \
r-future r-future.apply r-pbapply r-irlba r-ggalluvial r-svglite r-ggrepel r-circlize \
bioconductor-complexheatmap bioconductor-biocneighbors bioconductor-biobase \
r-rspectra r-reticulate r-sna r-fnn r-shape r-ggpubr r-ggnetwork r-plotly r-shiny r-bslib \
r-collapse r-pkgmaker r-registry r-rngtools r-gridbase r-doparallel r-cowplot r-uwot
micromamba run -n cellchat Rscript -e '
options(repos = c(CRAN = "https://cloud.r-project.org"))
install.packages("NMF") # conda-forge 没有 r-nmf
remotes::install_github("immunogenomics/presto", upgrade = "never")
remotes::install_github("jinworks/CellChat", upgrade = "never")
packageVersion("CellChat")'
# 方案 B:已有 R 4.4 以上
# install.packages(c("BiocManager", "remotes", "NMF"))
# BiocManager::install(c("ComplexHeatmap", "BiocNeighbors", "Biobase"))
# remotes::install_github(c("immunogenomics/presto", "jinworks/CellChat"), upgrade = "never")Step 2
Why this stepCellChat needs two things: the log-normalized expression of each gene in each cell, and a type label for each cell. Both must be taken correctly from the Seurat object.
Use the data layer, which holds log-normalized values, with genes as rows and cells as columns. For multi-sample objects, run JoinLayers first to merge the layers, otherwise only the first layer is read.
Labels are the cell-type name of each cell, and they must follow the rules below. The code below prepares the labels that way. Why normalized data is required is explained in the judgement section.
library(Seurat)
library(CellChat)
seu <- readRDS("pbmc3k_annot.rds") # 已注释的 Seurat v5 对象
seu <- JoinLayers(seu) # 多样本对象先合并 layer,否则只取到第一层
seu$celltype <- droplevels(factor(seu$celltype))
stopifnot(!anyNA(seu$celltype)) # 标签不能有 NA
data.input <- LayerData(seu, assay = "RNA", layer = "data") # log 归一化值,不是 counts
stopifnot(min(data.input) >= 0) # 不能用 scale.data 或 integrated
meta <- data.frame(
labels = seu$celltype,
samples = factor(seu$orig.ident), # v2 需要 samples 列
row.names = colnames(seu)
)
# 数字聚类号要加前缀,CellChat 不接受标签 "0"
# meta$labels <- factor(paste0("C", seu$seurat_clusters))
cellchat <- createCellChat(object = data.input, meta = meta, group.by = "labels")
table(cellchat@idents)- 01
No NA labels
Remove cells whose label is NA.
- 02
Drop unused factor levels
After subsetting, use droplevels to remove types that no longer have cells.
- 03
Labels cannot be the number 0
Seurat cluster numbers used directly as labels cause an error, so add a prefix such as C0 or C1.
- 04
Enough cells per group
Each group should have more than 10 cells.
Step 3
Why this stepThis step estimates which ligand-receptor pairs may be active between each pair of cell groups, then uses a permutation test to decide whether each pair is significant.
The code uses truncatedMean with trim = 0.1, so only groups in which at least 10% of cells express the gene take part in the calculation. The default triMean requires 25%, which gives few results on shallow-sequencing data. The difference between the two is in the parameters branch.
The receptor-ligand database drops Non-protein Signaling (metabolites and neurotransmitters), because these molecules cannot be measured directly in single-cell data. For other database choices, see the database branch.
CellChatDB <- CellChatDB.human # 小鼠用 CellChatDB.mouse
cellchat@DB <- subsetDB(CellChatDB) # 去掉 Non-protein Signaling 的全部蛋白类配受体
# cellchat@DB <- subsetDB(CellChatDB, search = "Secreted Signaling", key = "annotation")
future::plan("sequential") # 小数据集顺序执行更快
cellchat <- subsetData(cellchat)
cellchat <- identifyOverExpressedGenes(cellchat) # 默认用 presto 做 Wilcoxon
cellchat <- identifyOverExpressedInteractions(cellchat)
cellchat <- computeCommunProb(cellchat,
type = "truncatedMean", trim = 0.1, # trim 只在 truncatedMean 下生效
population.size = FALSE) # 未分选样本可设 TRUE
cellchat <- filterCommunication(cellchat, min.cells = 10)
cellchat <- computeCommunProbPathway(cellchat)
cellchat <- aggregateNet(cellchat)
df.net <- subsetCommunication(cellchat) # 配体-受体层面
df.netP <- subsetCommunication(cellchat, slot.name = "netP") # 通路层面
nrow(df.net); cellchat@netP$pathways
saveRDS(cellchat, "cellchat_pbmc3k.rds")- 01
Choose the database
subsetDB removes Non-protein Signaling.
- 02
Find over-expressed signaling genes
identifyOverExpressedGenes and identifyOverExpressedInteractions find the ligands and receptors that are over-expressed in each group.
- 03
Compute communication probabilities
computeCommunProb computes probabilities and gives p values from 100 permutations.
- 04
Filter and summarize by pathway
filterCommunication removes groups with too few cells, and computeCommunProbPathway and aggregateNet summarize the results by pathway and as a whole network.
Step 4
Why this stepThe previous step produces tables. Plots show who sends signals, who receives them, and which pathway is strongest.
aggregateNet produces two matrices: net$count is the number of significant ligand-receptor pairs between two groups, and net$weight is the sum of their communication probabilities. Counts show how many kinds of signals there are, and strengths show the total signal; their rankings often differ.
Look at the global circle plot first, then pick one pathway for detail. If a pathway is not significant, the plotting function reports an error; see troubleshooting. Pattern and signaling-role analyses are in the signaling roles and patterns branch.
groupSize <- as.numeric(table(cellchat@idents))
par(mfrow = c(1, 2), xpd = TRUE)
netVisual_circle(cellchat@net$count, vertex.weight = groupSize, weight.scale = TRUE,
label.edge = FALSE, title.name = "Number of interactions")
netVisual_circle(cellchat@net$weight, vertex.weight = groupSize, weight.scale = TRUE,
label.edge = FALSE, title.name = "Interaction strength")
pathways.show <- "MIF" # 先确认它在 cellchat@netP$pathways 里
netVisual_aggregate(cellchat, signaling = pathways.show, layout = "chord")
netVisual_heatmap(cellchat, signaling = pathways.show, color.heatmap = "Reds")
netVisual_bubble(cellchat, sources.use = c("CD14 Mono", "FCGR3A Mono"),
targets.use = c("CD8 T", "NK", "B"), remove.isolate = FALSE)Choose by your situation
Hand off to an agent
You can describe the analysis in one sentence, and the Scientify science agent will run it in a cloud workstation.
Example instruction: “Run CellChat v2 on data/annotated.rds (Seurat v5, celltype column for annotation, condition column for control and treated, sample column for 6 samples). Run each group separately, remove Non-protein Signaling from the database, compare triMean with truncatedMean 0.1, and set filterCommunication to min.samples = 2. After merging, output the communication count and strength comparison between the two groups, the increased and decreased pathways, and a bubble plot of up-regulated ligand-receptor pairs from macrophages, organized into tables.”
The agent installs CellChat and its dependencies in a cloud workstation and records the versions. It checks whether layers are split, whether labels contain NA or unused levels, and whether the two groups have the same cell types, running liftCellChat when needed. It then runs both parameter sets, lists the communications that appear under only one of them, and outputs circle plots, bubble plots, signaling-role plots and difference tables. The agent also reviews the results adversarially, for example checking whether strength is dominated by a few pathways such as MIF, or whether significant communications come from a single sample. The project keeps the scripts, parameters, logs and rds files, so the run can be reproduced; the task keeps running after your local machine is closed.
You still need to check these yourself: whether the annotation is reliable, whether the database subset matches your research question, whether the candidate ligand-receptor pairs make sense in the literature and tissue context, and which conclusions need experimental validation.
Branch: parameters
Test conditions: CellChat 2.2.0.9001, with 2,638 cells and 9 clusters (13 platelets, 32 DCs) from the official Seurat PBMC 3k workflow, nboot = 100. “Communications” in the table is the number of rows returned by subsetCommunication, that is, the combinations of source group, target group and ligand-receptor pair.
triMean misses known signals in shallow-sequencing data
On PBMC 3k (Cell Ranger 1.1, median 817 genes per cell), the CCL, CXCL and IFN-II pathways are absent with triMean. With trim = 0.1, NK-to-CD14 monocyte, NK-to-FCGR3A monocyte and NK-to-DC communications with IFNG and IFNGR1/IFNGR2 appear, which agrees with the known biology that NK cells secrete IFN-γ. On deeper sequencing data, the gap between the two methods is smaller.
A smaller trim gives more weak signals
With trim = 0.1, the sources of CCL5–CCR1 include B cells and naive CD4 T cells, where only a few cells express CCL5. The significance of the permutation test is relative to randomly shuffled labels, so ligands whose expression just passes the threshold can still be significant. The trim = 0.05 results suit exploration. For conclusions to report in a paper, check that they hold with trim = 0.1 and with triMean.
population.size changes the ranking, not the list
With truncatedMean 0.1, the significant communications are identical row by row for TRUE and FALSE (241), but the total strength drops from 5.71 to 0.058. In the sender-strength ranking, DC is first with FALSE, while with TRUE Memory CD4 T is first and DC drops to seventh. DC has only 32 cells, so this parameter decides whether a strong signal from a small group ranks near the top.
min.cells mainly affects small groups
Platelets have only 13 cells. With min.cells = 10 they are kept, and with trim = 0.05, 45 communications involve platelets. With min.cells = 20 they are all removed. identifyOverExpressedGenes also has a min.cells = 10 parameter, but it only affects the differential test.
| Database | type / trim | Communications | Ligand-receptor pairs | Pathways | Involving platelets (min.cells = 10) | Communications with min.cells = 20 |
|---|---|---|---|---|---|---|
| Secreted | triMean | 152 | 10 | 6 | 1 | 151 |
| Secreted | truncatedMean 0.25 | 151 | 10 | 6 | 3 | 148 |
| Secreted | truncatedMean 0.1 | 241 | 19 | 13 | 13 | 228 |
| Secreted | truncatedMean 0.05 | 402 | 37 | 23 | 45 | 357 |
| Without Non-protein | triMean | 437 | 41 | 14 | 36 | 401 |
| Without Non-protein | truncatedMean 0.1 | 967 | 79 | 34 | 98 | 869 |
| Without Non-protein | truncatedMean 0.05 | 1,375 | 116 | 51 | 186 | 1,189 |
| Full database | truncatedMean 0.05 | 1,527 | 130 | 57 | 203 | 1,324 |
Branch: ligand-receptor database
CellChatDB divides ligand-receptor pairs into four categories. The official tutorial example uses only Secreted Signaling, but that is only an example. The subset choice has a large effect on the number of results.
Pros and cons of using only Secreted Signaling
The advantages are fewer results, clearer plots, and comparability with earlier literature. The cost is that contact-dependent signals that matter most between immune cells (MHC-I/II, CD45, ICAM, SELPLG and others) are all missing. On PBMC 3k, adding Cell-Cell Contact raises the pathways from 13 to 34. For studies of the immune synapse, T cell and APC interactions, or tumor immune checkpoints, use subsetDB(CellChatDB).
Non-protein Signaling is not used by default
The official tutorial states that using the entire CellChatDB directly is not recommended. For this category, ligand amounts are inferred from the genes for synthesis enzymes and transporters, because metabolites themselves cannot be measured in single-cell data. For studies of the nervous system that need neurotransmitter signals, add them separately and interpret them apart from protein-based signals.
Species and gene names
Use CellChatDB.human for human, CellChatDB.mouse for mouse, and CellChatDB.zebrafish is also available. Gene names must be official symbols. For other species, convert homologous genes first. Errors caused by wrong gene names are in the troubleshooting section.
Add custom ligand-receptor pairs
Use updateCellChatDB() to merge your own interaction, complex, cofactor and geneInfo tables; see the official Update-CellChatDB tutorial. New pairs without a pathway assignment are not shown in pathway-level plots.
| Category | Human pairs | Description | Measured on PBMC 3k (triMean / truncatedMean 0.1) |
|---|---|---|---|
| Secreted Signaling | 1,280 | Secreted paracrine and autocrine signals | 152 / 241 communications, 6 / 13 pathways |
| ECM-Receptor | 424 | Extracellular matrix to receptor; important in tissue samples, few in blood samples | — |
| Cell-Cell Contact | 535 | Requires direct cell contact, such as MHC, ICAM and CD86 | The first three categories together (subsetDB(CellChatDB)): 437 / 967 communications, 14 / 34 pathways |
| Non-protein Signaling | 994 | Metabolites and neurotransmitters; ligand amounts inferred from the expression of synthesis enzymes and transporters | Full database: 445 / 1,055 communications, of which Non-protein 8 / 88 |
Branch: multi-group comparison
The comparison method is to run each group separately and merge at the end. The prerequisites are that both groups use the same annotation, the same database subset and the same parameters. If the cell types differ, use liftCellChat to unify the group definitions first.
Run droplevels separately for each group to drop types the group does not have, then use liftCellChat after calculation to align both groups to the same labels. Errors from this order are in the troubleshooting section.
The code below was tested on the Kang 2018 interferon-stimulated PBMC data, with control and stimulated groups.
run_cellchat <- function(obj) {
meta <- data.frame(labels = droplevels(obj$celltype), # 本组没有的类型必须去掉
samples = factor(obj$sample), row.names = colnames(obj))
cc <- createCellChat(LayerData(obj, assay = "RNA", layer = "data"), meta = meta, group.by = "labels")
cc@DB <- subsetDB(CellChatDB.human, search = "Secreted Signaling", key = "annotation")
cc <- subsetData(cc)
cc <- identifyOverExpressedGenes(cc)
cc <- identifyOverExpressedInteractions(cc)
cc <- computeCommunProb(cc, type = "truncatedMean", trim = 0.1) # 两组参数必须相同
cc <- filterCommunication(cc, min.cells = 10)
cc <- computeCommunProbPathway(cc)
cc <- aggregateNet(cc)
netAnalysis_computeCentrality(cc, slot.name = "netP")
}
# 两组使用同一套标签(同一列注释、同样的写法)
seu$celltype <- factor(seu$celltype)
cc.ctrl <- run_cellchat(subset(seu, stim == "CTRL"))
cc.stim <- run_cellchat(subset(seu, stim == "STIM"))
# 某组缺少某个细胞类型时,先补齐到同一组标签
grp <- union(levels(cc.ctrl@idents), levels(cc.stim@idents))
if (!identical(levels(cc.ctrl@idents), levels(cc.stim@idents))) {
cc.ctrl <- liftCellChat(cc.ctrl, group.new = grp)
cc.stim <- liftCellChat(cc.stim, group.new = grp)
}
object.list <- list(CTRL = cc.ctrl, STIM = cc.stim)
cellchat <- mergeCellChat(object.list, add.names = names(object.list))
compareInteractions(cellchat, show.legend = FALSE, group = c(1, 2)) +
compareInteractions(cellchat, show.legend = FALSE, group = c(1, 2), measure = "weight")
netVisual_diffInteraction(cellchat, weight.scale = TRUE, measure = "weight") # 红色 = STIM 增强
rankNet(cellchat, mode = "comparison", measure = "weight", stacked = TRUE, do.stat = TRUE)
netVisual_bubble(cellchat, sources.use = "CD14 Mono", comparison = c(1, 2),
max.dataset = 2, title.name = "Increased in STIM", angle.x = 45, remove.isolate = TRUE)Two-group results measured on this page
For the Kang 2018 data (6,548 CTRL cells and 7,451 STIM cells, 13 types), with Secreted and trim = 0.1: CTRL has 421 communications and 13 pathways, STIM has 542 and 14; total strength ranges from 4.30 to 10.79. The increased ligand-receptor pairs from CD14 monocytes include CXCL10/CXCL11–CXCR3, CCL8–CCR1 and CCL7–CCR1, which matches the expected interferon-induced chemokine response. Each group took 26–43 seconds, and the peak memory of the two-group workflow was 3.3–3.6 GB.
The two kinds of “difference”
netVisual_bubble (with comparison and max.dataset) and rankNet compare communication probabilities. netMappingDEG instead selects ligands or receptors that go up or down between conditions using differential expression. In v2, the logFC computed with presto is smaller than in v1, so the official tutorial changed thresh.fc from 0.1 to 0.05. The same ligand-receptor pair can appear among both up- and down-regulated results, because differential analysis is run within each cell group. To ignore cell groups, set group.DE.combined = TRUE.
The unit of the statistical test
The paired Wilcoxon test in rankNet (do.stat = TRUE) works on pairs of groups and does not account for biological replicates. When each group has only one merged sample, a “significantly up-regulated pathway” only describes differences in this sequencing run. With several samples, filter with min.samples, or add MultiNicheNet or LIANA+, which model samples as the unit.
How to organize multi-sample data
The maintainer sqjin recommends in GitHub #62 that all samples from one condition be merged into one object for the run, which matches the idea of clustering after integration. To reduce communications that appear in only one sample, add a samples column to meta, then use filterCommunication(min.samples = 2) to require that a communication appears in at least 2 samples (available from v2.1.2). A user reported in the same issue that merged runs gave 4–5% more unique communications than sample-by-sample runs.
Datasets with very different composition
For example, embryonic skin and adult wounds differ greatly in cell composition. In this case netVisual_diffInteraction and functional similarity (computeNetSimilarityPairwise(type = "functional")) no longer apply, but structural similarity (type = "structural") and the circle plot of each group still work.
Use a common scale for plots
When drawing circle plots for the two groups separately, use getMaxWeight(object.list, attribute = c("idents", "count")) to get the maximum of the two groups, and pass it to edge.weight.max and vertex.weight.max. Otherwise each plot is normalized separately and the line widths cannot be compared.
Branch: signaling roles and patterns
This step summarizes the pathway-level results further: what role each group plays in each pathway, and which groups and pathways form a pattern together.
netAnalysis_computeCentrality calculates, on the network of each pathway, out-degree (sending), in-degree (receiving), flow betweenness (mediating) and information centrality (influence). In the 2D scatter plot, the x axis is outgoing strength, the y axis is incoming strength, and point size is the number of connections. It is a quick way to say in one sentence which group mainly sends signals.
identifyCommunicationPatterns uses NMF to decompose groups and pathways into k patterns. By default, selectK tries k = 2:10 with 30 runs each, which is slow. When there are very few pathways (fewer than 10), pattern analysis carries little information and can be skipped.
cellchat <- netAnalysis_computeCentrality(cellchat, slot.name = "netP")
netAnalysis_signalingRole_scatter(cellchat)
netAnalysis_signalingRole_heatmap(cellchat, pattern = "outgoing") +
netAnalysis_signalingRole_heatmap(cellchat, pattern = "incoming")
library(NMF); library(ggalluvial)
selectK(cellchat, pattern = "outgoing", k.range = 2:6, nrun = 10) # 默认 2:10、nrun = 30 很慢
cellchat <- identifyCommunicationPatterns(cellchat, pattern = "outgoing", k = 3)
netAnalysis_river(cellchat, pattern = "outgoing")Time cost of selectK and the basis for choosing k
On this page, running selectK with default settings on 13 pathways and 9 groups took 78 seconds; with k = 2:6 and nrun = 5 it took 34 seconds. With 50 or more pathways and 20 or more groups, selectK can take tens of minutes to hours. The official approach is to choose the k just before the Cophenetic and Silhouette values start to drop clearly.
Branch: choosing tools
Dimitrov et al. (Nature Communications 2022) compared 16 databases and 7 methods, and concluded that both the method and the database choice substantially change the predicted results. Liu et al. (Genome Biology 2022) evaluated 16 methods against spatial transcriptomics as a reference; CellChat, CellPhoneDB, NicheNet and ICELLNET performed well overall, and the authors recommend cross-validating with at least two methods.
Spatial data needs extra input
For spatial data, use createCellChat(datatype = "spatial", coordinates = ..., spatial.factors = data.frame(ratio = ..., tol = ...)). coordinates are the pixel coordinates in the full-resolution image; ratio converts pixels to micrometers (65 / spot_diameter_fullres for Visium); tol is half the spot diameter (32.5). In computeCommunProb, Visium uses interaction.range = 250 and contact.range = 100; for single-cell resolution, contact.range is about 10. For spatial data at single-cell resolution, use SpatialCellChat.
| Tool | Language | Question it answers | Suited for | Not suited for |
|---|---|---|---|---|
| CellChat v2 | R | Which ligand-receptor pairs and pathways are significant between groups; network roles and patterns | Seurat users; when many ready-made plots and two-group comparison are needed | Statistical modeling of many samples and conditions |
| CellPhoneDB v5 | Python | Which ligand-receptor pairs are specific to particular group pairs; accounts for multi-subunit complexes | Human data; when you need to connect with the Vento-Tormo lab atlas and spatial microenvironment methods | Mouse data (needs homologous conversion) |
| NicheNet / MultiNicheNet | R | Which ligand can explain downstream gene changes in receiving cells | When you have treated-vs-control differential genes and want to find upstream ligands; MultiNicheNet supports multiple samples and conditions | Exploratory description without a control group |
| LIANA+ | Python (an R version, liana, also exists) | Consensus ranking across methods and databases; multi-sample analysis can use Tensor-cell2cell and MOFA | Scanpy users who want scores from CellChat, CellPhoneDB and other methods at once | When you only need CellChat-style plots |
Concepts and judgment
Judgement
The points below determine how the results should be read.
Why normalized data is required
CellChat first divides the matrix by the global maximum, then applies a Hill function (Kh = 0.5) to compute probabilities. With counts, the maximum is in the hundreds, so after scaling almost all values are close to 0. Measured on this page: counts run without error, but give 170 communications (152 with the correct input), the same pathways, and a total strength about 1/800 of the correct value, so strength comparisons break down.
What triMean means
triMean is the mean of four quantiles: Q1, Q2, Q2 and Q3. When fewer than 25% of cells in a group express the gene, the group mean is 0. Between 25% and 50%, only Q3 and Q4 contribute. The result is fewer, stronger signals.
Whether to use broad types or subtypes as labels
CellChat computes between groups, so heterogeneity within a group is averaged out. Nature Protocols lists this as a limitation and suggests sub-clustering first when needed. The cost is that runtime and plot complexity grow with the number of groups: in GitHub #167, a user with 11,000 cells and 133 groups ran for more than 11 hours. A common approach is to build a global network with broad types first, then split the subtypes of the groups of interest and run them separately. The maintainer did not give a specific recommended number of groups.
Probability values have no absolute meaning
Communication probabilities depend on the global maximum expression, the Hill function parameters and the averaging method. Changing type or trim on the same data shifts all probabilities. Probabilities can only be compared between datasets when parameters and normalization are the same.
Run time and large datasets
Reported timings vary widely. Nature Protocols reports about 15 minutes for inference on a skin atlas of about 300,000 cells, while several GitHub users report hours for tens of thousands of cells. The differences come from the number of groups, the database subset, nboot, the version and the parallel settings. Another user reported that with 90,000 cells, 6 groups and 500 GB of memory on a single node, the steps before computeCommunProb took about 4 hours (GitHub #167). For large data, you can also downsample first: Seurat's subset(obj, downsample = 500), or CellChat's sketchData, samples large groups and keeps small groups entirely. After downsampling, the list of significant communications is usually stable, but the strengths change.
- CellChat results come from mRNA expression and a prior database. They show that the expression conditions for communication are met, not that a protein-level interaction takes place.
- Single-cell data lose spatial position. Two groups expressing a ligand and a receptor does not mean they are adjacent in tissue; spatial data or in situ experiments can fill this gap.
- Ligand-receptor pairs outside the database do not appear in the results, and CellChatDB favors signals that have been studied more in the literature.
- Strength values depend on parameters and normalization, so compare them only under the same parameters. A paper should state the database subset, type, trim, population.size, min.cells and version.
- CellChat's cross-condition analysis is mainly pairwise; analysis of changes across many conditions or over time must be organized separately (a limitation listed in Nature Protocols).
- Follow-up validation often uses RNAscope, immunofluorescence colocalization, receptor blocking, or neutralizing antibody experiments for the ligand or receptor.
Reference and appendix
Reference
The CellChat repository moved from sqjin/CellChat to jinworks/CellChat. The current GitHub main branch is 2.2.0.9001 (last commit 2026-03-04), and the last release tag is v2.1.2. The package labeled “v3” online is a separate SpatialCellChat package for spatial transcriptomics only. Single-cell data continues to use CellChat v2.
When writing the methods section of a paper, record packageVersion("CellChat") and the installation date. The GitHub main branch also changes between releases; for example, PR #438 merged on 2026-02-19 changed the parallel behavior, and rankNet was modified on 2026-03-04.
| Item | v1-era tutorial (2021–2023) | Current v2 | Consequence of copying old code |
|---|---|---|---|
| Database size | CellChatDB.human about 1,939 pairs | 3,233 pairs: 1,920 from v1, and 1,313 new in v2 (994 Non-protein Signaling, 233 Cell-Cell Contact, 83 Secreted); mouse 3,379 | Using the full database mixes metabolite and neurotransmitter signals into the results |
| Over-expressed gene test | Seurat-style Wilcoxon | Calls presto by default with do.fast = TRUE; fails outright if presto is not installed | On the same PBMC 3k data, presto gives 400 over-expressed signaling genes and do.fast = FALSE gives 744, so v1 and v2 results cannot be compared directly |
| PPI smoothing | projectData(cellchat, PPI.human) | Renamed smoothData; adj = PPI.human must be given | Error: is(adj, "matrix") || is(adj, "sparseMatrix") is not TRUE (GitHub #185) |
| Object slot | data.project | data.smooth | Old objects give no slot of name "data.smooth" (GitHub #202) |
| meta | Only a label column is needed | A samples column is also needed; if missing, it is set to sample1 with a warning | After merging multiple samples, min.samples filtering does not work |
| Parallel | plan("multiprocess") | The future package has removed the multiprocess backend | Error: No such backend for futures: 'multiprocess' |
| Spatial transcriptomics | Visium supported from v1.6 | v2 supports several spatial technologies; spatial data at single-cell resolution uses SpatialCellChat (v3) | — |
Reference
| Parameter | Default | Role and basis for the value |
|---|---|---|
| thresh.p in identifyOverExpressedGenes | 0.05 | Uses unadjusted p values to select the signaling genes over-expressed in each group; thresh.fc = 0 and thresh.pc = 0. A pair enters the calculation as long as either its ligand or its receptor is over-expressed |
| type in computeCommunProb | "triMean" | triMean is the mean of the four quantiles Q1, Q2, Q2 and Q3. When fewer than 25% of cells express the gene, the group mean is 0; between 25% and 50%, only Q3 and Q4 remain. Gives fewer, stronger signals |
| trim with type = "truncatedMean" | 0.1 | Removes the trim proportion from each end before averaging; when the expressing proportion is below trim, the group mean is 0. 0.1 corresponds to a 10% threshold and 0.05 to 5%. trim only takes effect with truncatedMean (and with thresholdedMean, which the tutorial does not cover). Nature Protocols suggests: generally use trim = 0.1; lower trim only if a signal that is known to exist in the system does not appear |
| computeAveExpr(features = , type = , trim = ) | — | Check the group averages of the ligands and receptors of interest before setting trim. If a gene is 0 under triMean but not 0 under trim = 0.1, its expressing proportion is between 10% and 25% (the method recommended by Nature Protocols) |
| population.size | FALSE | TRUE multiplies the probabilities by the proportion of cells in the two groups; suited to unsorted samples. Use FALSE for sorted samples or samples enriched for cell types |
| nboot | 100 | Number of permutations; p value precision is 1/nboot. Measured: 20 runs 4.3 seconds, 938 communications; 100 runs 22.6 seconds, 967; 1,000 runs 493 seconds, 972 |
| min.cells in filterCommunication | 10 | Removes groups whose cell count is less than or equal to min.cells (the source uses <=), so a group with exactly 10 cells is also removed |
| raw.use | TRUE | FALSE uses expression smoothed by smoothData, which compensates for missing subunits in shallow-sequencing data, at the cost of possible false positives |
Reference
| Plot | Function | Question it answers | Note |
|---|---|---|---|
| Circle plot (global) | netVisual_circle(net$count or net$weight) | Which groups communicate most, and which group is the main sender | When comparing two datasets, use edge.weight.max to set a common scale |
| Single-pathway circle, chord or hierarchy plot | netVisual_aggregate(signaling = , layout = ) | Who sends and who receives a given pathway | If the pathway is not significant, it reports There is no significant communication of XXX; check cellchat@netP$pathways first |
| Heatmap | netVisual_heatmap(signaling = ) | Strength matrix of one pathway across all group pairs | Colors are scaled within that pathway, so colors cannot be compared across pathways |
| Bubble plot | netVisual_bubble(sources.use, targets.use) | Which specific ligand-receptor pairs, probabilities and p values occur between the specified groups | Best for the main text of a paper; groups can be given by name or index |
| Ligand-receptor chord plot | netVisual_chord_gene | All ligand-receptor pairs sent or received by one group | With too many pairs, labels overlap; adjust small.gap or limit signaling |
| Contribution plot | netAnalysis_contribution | Which ligand-receptor pair contributes most to a pathway | — |
| Signaling roles | netAnalysis_signalingRole_scatter / _heatmap / _network | Whether each group is a sender, receiver, mediator or influencer | Run netAnalysis_computeCentrality first; heatmaps are scaled by row |
Measured on this page
Test environment: macOS arm64 (Apple M2, 8 cores, 16 GB), R 4.5.3, Seurat 5.5.1, CellChat 2.2.0.9001, presto 1.1.0, NMF 0.28, ComplexHeatmap 2.26.1, future 1.76.0. Other tasks were running on the same machine during the tests, so timings only show the order of magnitude.
| Item | PBMC 3k | Kang 2018 two groups |
|---|---|---|
| Cells and clusters | 2,638 cells, 9 clusters | CTRL 6,548 / STIM 7,451 cells, 13 types |
| Default workflow (Secreted, triMean) | 152 communications, 6 pathways; computeCommunProb 9.6 seconds; peak memory 1.28 GB | CTRL 158 / STIM 254 communications |
| truncatedMean 0.1 | 241 communications, 13 pathways | CTRL 421 / STIM 542 communications; 26–43 seconds per group |
| Full workflow in the main code | Without Non-protein + trim 0.1: 967 communications, 34 pathways; 56 seconds including plotting, 1.49 GB | Two-group comparison 73 seconds, 3.30 GB |
| selectK | 78 seconds by default; 34 seconds with k = 2:6 and nrun = 5 | Not run |
- Errors reproduced on this page: labels containing 0, labels containing NA, unused factor levels, split layers, a missing type when two groups have the same factor levels, and plotting after merging without liftCellChat.
- Silent errors: counts as input, scale.data passed as a matrix, and LayerData on split layers returning only the first layer. None of these report an error.
- Spatial transcriptomics (datatype = "spatial", SpatialCellChat), smoothData, CellPhoneDB, NicheNet and LIANA+ were not run on this machine; only the function and parameter names in the documentation were checked.
Experience from China
The items below come from articles reposted on the Tencent Cloud developer community. Only items with the original error text or the author's measurements, and consistent with the official documentation or the measurements on this page, are included.
Cluster number 0 cannot be a label
生信补给站 (November 2023) renamed clusters 0–9 to C0–C9 on Visium data before the run worked. The error reproduced on this page is the original text Cell labels cannot contain `0`!, and the maintainer also mentions in GitHub #16 that labels cannot be "0".
The “unused factor” was actually NA
天意生信云 (March 2025) hit a factor levels error. Checking showed every level had cells; the real cause was NA values in the annotation column, and removing those cells fixed it. On this page, NA and unused levels produce the same error, so check both cases: sum(is.na(meta$labels)) and setdiff(levels(meta$labels), unique(meta$labels)).
Compilation errors on Apple silicon Macs
R小白 (May 2023) hit no member named 'Rlog1p' in namespace 'std' on an M-series Mac, which was resolved by setting export PKG_CPPFLAGS="-DHAVE_WORKING_LOG1P"; CMake was not found on the PATH was fixed with conda install cmake. This page did not encounter these errors when installing with conda compilers and R 4.5.3, but they may still help with older R environments.
Use nboot = 20 for quick checks
The spatial tutorial by 生信技能树 (June 2025) uses nboot = 20 during parameter tuning. On this page, the significant communications with nboot = 20 overlap 96% with those at nboot = 100 (930 / 967), at about one fifth of the time. It suits deciding the database and trim first; use 100 for the final results.
“v3” is a separate spatial package
KS科研 (May 2026) notes that SpatialCellChat is a spatial transcriptomics package split from CellChat, with dependencies MERINGUE, ALRA, BiocNeighbors and RcppML, which matches the official README. Single-cell data continue to use CellChat v2.
Two outdated patterns to update
Several Chinese tutorials still write computeCommunProb(trim = 0.1) without changing type, and use plan("multiprocess") on Windows. The first one leaves trim ineffective; the second reports No such backend for futures: 'multiprocess' in the current future package. Use plan("multisession") instead, or run sequentially.
Troubleshooting
Error messages and pitfalls from old tutorials are collected here. Find the error or symptom you see. Error texts come from reproductions on this page or GitHub issues.
Cell labels cannot contain `0`!
Cause: Seurat cluster numbers were used directly as labels.
Fix: Change the labels to a factor with a prefix, such as C0 to C9.
meta$labels <- factor(paste0("C", seu$seurat_clusters))Please check `unique(object@idents)` and ensure that the factor levels are correct!
Cause: Labels contain NA, or the factor has unused levels. This is most common after subsetting. Some users in China thought it was unused levels, but it was NA values in the annotation column.
Fix: Check both cases first, then handle each: remove NA cells and drop unused levels.
sum(is.na(meta$labels)) # NA 的细胞数
setdiff(levels(meta$labels), unique(meta$labels)) # 未使用的水平
meta <- meta[!is.na(meta$labels), ]
meta$labels <- droplevels(meta$labels)Passing a Seurat object directly gives invalid 'row.names' length. LayerData(layer = "data") only warns and returns only the first layer.
Cause: The layers of the Seurat v5 object are split, for example data.A and data.B.
Fix: Run obj <- JoinLayers(obj) first, then create the CellChat object.
Error in if (sum(P1) == 0) : missing value where TRUE/FALSE needed
Cause: The input contains negative values or NA, such as scale.data, integrated, or a matrix standardized on the Python side (GitHub #79).
Fix: Use the log-normalized data layer instead.
No error, but the number of communications is wrong. When scale.data (2,000 highly variable genes, with negative values) is passed as a matrix, the run finishes with 201 communications.
Cause: When a matrix is passed directly, createCellChat does not check for negative values; it checks only when a Seurat object is passed. An integrated assay has only some genes and is corrected, so CellChat gives a warning. The data layer of an SCT assay is corrected log1p counts and can be used.
Fix: Use only the log-normalized data layer.
Counts as input give no error, but communication probabilities are tiny and strength comparisons break down.
Cause: CellChat's probabilities depend on normalization by the global maximum. The maximum of counts is in the hundreds, so after scaling almost all values are close to 0. Measured on this page: the total strength is about 1/800 of the correct value.
Fix: Use LayerData(layer = "data"). If you only have counts, use CellChat::normalizeData(counts), which gives the same result as Seurat's LogNormalize.
There is no significant communication of XXX
Cause: This pathway is not significant in this dataset.
Fix: Choose a significant pathway from cellchat@netP$pathways.
netVisual_circle: need finite 'xlim' values
Cause: net$count is all 0, meaning there are no significant communications.
Fix: Check the row count of subsetCommunication(cellchat); check the species database, gene names and labels; loosen type or trim.
After aggregateNet on one group, a cluster has no communications at all.
Cause: The cluster has no more than min.cells cells and was filtered, or it truly has no significant signal.
Fix: Check the cell counts with table(cellchat@idents); when comparing, use liftCellChat to keep the groups consistent.
The input `color.use` should be a named vector!
Cause: The custom colors are not named, or their number does not match the groups.
Fix: Create a named color vector with setNames(colors, levels(cellchat@idents)).
netVisual_circle reports Length of new attribute value...
Cause: Compatibility problem with igraph 1.4.0 (Nature Protocols, Table 1).
Fix: Downgrade igraph to 1.3.5, or run updateCellChat(), or reinstall CellChat.
netAnalysis_computeCentrality fails on a merged object.
Cause: The function must run on each individual object (Nature Protocols, Table 1).
Fix: Run netAnalysis_computeCentrality on each object in object.list first, then run mergeCellChat.
After enabling multiple cores, the run is several times slower.
Cause: multisession has inter-process transfer overhead. Versions before 2026-02 only parallelized a small part of the calculation. On 2,638 cells on this page, identifyOverExpressedGenes went from 0.1 to 25.1 seconds, and computeCommunProb from 5.8 to 26.3 seconds. Several users in GitHub #357 reported the same (on Ubuntu, from 0.9 to 368 seconds).
Fix: Use future::plan("sequential") below about 10,000 cells. For large data, first confirm that you have the main branch from 2026-02-19 or later (PR #438 parallelized the permutation loop), then use multisession and set options(future.globals.maxSize = 4e9).
On macOS, installation reports installation of package ... had non-zero exit status.
Cause: The Xcode command-line tools are missing or damaged (two users confirmed this in GitHub #226).
Fix: Reinstall the Xcode command-line tools, or use conda's c-compiler and cxx-compiler.
Skipping 3 packages not available: Biobase, BiocNeighbors, BiocGenerics
Cause: remotes does not install Bioconductor packages automatically.
Fix: Run BiocManager::install(c("Biobase", "BiocNeighbors", "BiocGenerics", "ComplexHeatmap")) first.
Failed to connect to github.com, or the download times out.
Cause: Access to GitHub is unstable in China.
Fix: Install the other dependencies from a conda or Bioconductor mirror, so only the presto and CellChat GitHub packages remain. If it still fails, download the source zip and install it with R CMD INSTALL.
On Apple silicon, compilation reports no member named 'Rlog1p' in namespace 'std'.
Cause: A combination problem between an older R and the compiler (a Chinese experience post, 2023).
Fix: Set export PKG_CPPFLAGS="-DHAVE_WORKING_LOG1P", then reinstall.
export PKG_CPPFLAGS="-DHAVE_WORKING_LOG1P"CMake was not found on the PATH
Cause: A dependency needs CMake.
Fix: Run conda install cmake.
For a faster implementation of the Wilcoxon Test, please install the presto package
Cause: v2 uses presto by default for the over-expression test.
Fix: Run remotes::install_github("immunogenomics/presto"). If it cannot be installed, you can set identifyOverExpressedGenes(do.fast = FALSE), but the results differ from presto's.
Error in integer(n) : invalid 'length' argument
Cause: When v2 before November 2023 used the full database, the LTE4-DPEP1 complex caused this error (GitHub #1). Seurat also has a subsetData function with the same name, which is easy to confuse.
Fix: Update CellChat, and write the call as CellChat::subsetData(cellchat).
The code sets trim = 0.1, but the result equals the default.
Cause: type is still the default triMean, so trim has no effect. Many Chinese tutorials are written this way.
Fix: You must also set type = "truncatedMean".
cellchat <- computeCommunProb(cellchat, type = "truncatedMean", trim = 0.1)No such backend for futures: 'multiprocess'
Cause: The current future package has removed the multiprocess backend.
Fix: Use plan("multisession") instead, or run sequentially.
When computing the two groups separately, computeCommunProb reports a factor levels error.
Cause: The two groups have different sets of cell types but were given the same factor levels.
Fix: Run droplevels separately for each group. After calculation, use liftCellChat(group.new = union(...)) to add the missing types, then run mergeCellChat.
mergeCellChat itself does not fail, but the later netVisual_diffInteraction reports non-conformable arrays.
Cause: The groups were merged without unifying the group definitions with liftCellChat.
Fix: Run liftCellChat on the objects that lack types, then run mergeCellChat.
projectData reports is(adj, "matrix") || is(adj, "sparseMatrix") is not TRUE
Cause: In v2, the v1 projectData was renamed smoothData and must be given the adj argument (GitHub #185).
Fix: Use smoothData(cellchat, adj = PPI.human) instead.
An old object reports no slot of name "data.smooth"
Cause: The slot names of v1 objects differ, and the maintainer has not fixed this (GitHub #202).
Fix: A user's workaround is to add an empty matrix: obj@data.smooth <- matrix(nrow = 0, ncol = 0).
After merging multiple samples, min.samples filtering does not work.
Cause: The meta table has no samples column. If it is missing, v2 sets it to sample1 with a warning.
Fix: Add a samples column to meta; see the input step.
After subsetData there are almost no signaling genes, and downstream steps report errors such as data.use[RsubunitsV, ].
Cause: The gene names are not official symbols, for example Ensembl IDs, or human and mouse gene names are mixed.
Fix: Use official symbols. For other species, convert homologous genes first.
References
- CellChat GitHub (jinworks): README and installation — Current version, dependencies, relation between v2 and v3 (SpatialCellChat)
- CellChat NEWS — Changes in v2.0–v2.1.2: samples column, min.samples, CellChatDB v2
- CellChat single-dataset tutorial (CellChat-vignette) — Four input options, database composition, triMean and population.size, plotting functions
- CellChat tutorial: comparison of multiple datasets — mergeCellChat, rankNet, DEG mapping and thresh.fc = 0.05
- CellChat tutorial: datasets with different cellular compositions — liftCellChat; analyses unavailable for very different compositions
- CellChat source R/modeling.R — Definitions of triMean, truncatedMean and thresholdedMean; the <= test in filterCommunication
- Jin et al. 2024, Nature Protocols: CellChat for systematic analysis of cell–cell communication — CellChat v2 methods and procedures; trim advice, limitations, troubleshooting table, timing
- Jin et al. 2021, Nature Communications: Inference and analysis of cell-cell communication using CellChat — Communication probability model, permutation test, network analysis
- SpatialCellChat(CellChat v3) — Single-cell-resolution spatial transcriptomics
- GitHub issue #357: multisession is slower — Community report: several users find parallel runs slower; downgrading future
- GitHub PR #438: parallel permutation loop in computeCommunProb — Merged February 2026; 40k cells from 46 h to 5.2 h (PR author's data)
- GitHub issue #62: best practice for multiple samples — Maintainer recommends merged runs; origin of min.samples
- GitHub issue #185: projectData renamed smoothData — Community report: adj = PPI.human must be named
- GitHub issue #202: no slot of name data.smooth — Community report: adding an empty matrix to old objects
- GitHub issues #79, #16, #1: computeCommunProb errors — Negative input, NA and 0 labels, early v2 full-database error
- GitHub issue #167: speeding up CellChat — Community report: run time and memory for 90k cells and for 133 groups
- Dimitrov et al. 2022, Nature Communications: Comparison of methods and resources for cell-cell communication inference — Method and resource choices strongly affect results; LIANA
- Liu et al. 2022, Genome Biology: Evaluation of cell-cell interaction methods by integrating single-cell RNA sequencing data with spatial information — Benchmark of 16 methods; recommends cross-checking with at least two
- Kang et al. 2018, Nature Biotechnology (ifnb dataset) — Public data used for the two-group comparison on this page
- CellPhoneDB — Tool choice table
- MultiNicheNet — Ligand activity analysis for multiple samples and conditions
- LIANA+ documentation — Multi-method consensus and multi-sample analysis
- 生信补给站: CellChat v2 spatial transcriptomics communication analysis (Tencent Cloud, 2023-11, Chinese) — Community post: cluster IDs 0 renamed to C0–C9
- 天意生信云: CellChat factor-level error (Tencent Cloud, 2025-03, Chinese) — Community post: the real cause of the error was NA in the annotation column
- R小白: installing CellChat (Tencent Cloud, 2023-05, Chinese) — Community post: Rlog1p compile error on Apple silicon, missing CMake; applies to older R setups
- 生信技能树: CellChat v2 spatial transcriptomics analysis (Tencent Cloud, 2025-06, Chinese) — Community post: nboot = 20 for quick checks, Visium parameters
- KS科研: CellChat v3 spatial communication analysis (Tencent Cloud, 2026-05, Chinese) — Community post: SpatialCellChat dependencies and input