第一个报错: > data.input <- GetAssayData(seurat_sample, slot = "data", assay = "SCT") 警告信息: The `slot` argument of `GetAssayData()` is deprecated as of SeuratObject 5.0.0. ℹ Please use the `layer` argument instead. This warning is displayed once every 8 hours. Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated.
这个应该改为:
data.input <- GetAssayData(seurat_sample, layer = "data", assay = "SCT")
第二个报错:
> cellchat <- CellChat::computeCommunProb( + cellchat, + type = "truncatedMean", + trim = 1, + distance.use = TRUE, + scale.distance = 0 + ) truncatedMean is used for calculating the average gene expression per cell group. 错误: 函数‘queryKNN’标签‘X = "data.frame"’找不到继承方法
这个应该改为:
cellchat <- createCellChat(
object = data.input,
meta = meta,
group.by = "labels",
datatype = "spatial",
coordinates = data.matrix(spatial.locs),
scale.factors = scale.factors # 添加 scale.factors 参数
)
第三个报错:
> cellchat <- computeCommunProb( + cellchat, + type = "truncatedMean", + trim = 1, + distance.use = TRUE, + scale.distance = 1 + ) truncatedMean is used for calculating the average gene expression per cell group. [1] ">>> Run CellChat on spatial imaging data using distances as constraints <<< [2025-03-08 15:43:35.765162]" The suggested minimum value of scaled distances is in [1,2], and the calculated value here is 0.2828427 错误于computeCommunProb(cellchat, type = "truncatedMean", trim = 1, : Please increase the value of `scale.distance` and check the suggested values in the parameter description (e.g., 1, 0.1, 0.01, 0.001, 0.11, 0.011)
这个scale.distance的参数其实要远大点,我选了132
cellchat <- computeCommunProb(cellchat, type = "truncatedMean", trim = 0.1,
distance.use = TRUE, interaction.length = 200, scale.distance = 132)