CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

Compare the major sources and targets in 2D space not working

Open ozcelikelif opened this issue 2 years ago • 1 comments

Hi, I am trying to get the plots on the tutorial page with the following code:

num.link <- sapply(object.list, function(x) {rowSums(x@net$count) + colSums(x@net$count)-diag(x@net$count)})
weight.MinMax <- c(min(num.link), max(num.link)) # control the dot size in the different datasets
gg <- list()
for (i in 1:length(object.list)) {
  gg[[i]] <- netAnalysis_signalingRole_scatter(object.list[[i]], title = names(object.list)[i], weight.MinMax = weight.MinMax)
}

but its giving the following error

Error in netAnalysis_signalingRole_scatter(object.list[[i]], title = names(object.list)[i],  : 
  Please run `netAnalysis_computeCentrality` to compute the network centrality scores! 

My code before running the plot (after checking out the github page about this error):

Coco <- readRDS("Coco_cellchat_analysis.rds")
Coco <- netAnalysis_computeCentrality(Coco, slot.name = "net", net.name = "Coco", thresh = 0.05)
Coco <- updateCellChat(Coco)

Milk <- readRDS("Milk_cellchat_analysis.rds")
group.new = levels(Coco@idents)
Milk <- liftCellChat(Milk, group.new)
Milk <- netAnalysis_computeCentrality(Milk, slot.name = "net", net.name = "Milk", thresh = 0.05)
Milk <- updateCellChat(Milk)

object.list <- list("Coco" = Coco, "Milk" = Milk)
cellchat <- mergeCellChat(object.list, add.names = names(object.list))

Thank you.

ozcelikelif avatar Sep 12 '23 19:09 ozcelikelif

Hi @elifozcelik

When you ran netAnalysis_computeCentrality(), you've set slot.name = "net", therefore the network centrality scores is performed with the net data instead of the default netP. When you call netAnalysis_signalingRole_scatter(), you'll need to set slot.name = "net" too, or else, the function will look inside netP and found nothing.

ycl6 avatar Sep 28 '23 19:09 ycl6