Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

NetP empty after running computeCommunProb #736

Open
Dena2021 opened this issue Dec 19, 2023 · 1 comment
Open

NetP empty after running computeCommunProb #736

Dena2021 opened this issue Dec 19, 2023 · 1 comment

Comments

@Dena2021
Copy link

Hi Sqjin,
Thanks for providing this package.
I am trying to compare two scRNA samples that were analysed together in Seurat and then separated by subset to extract each sample and analyse it separately with cellchat, and then compare between them.
The exact pipeline works fine with one sample, but with the other the sample, the netP is empty after running computeCommunProb.
Interestingly, the command subsetCommunication(cellchat_c,slot.name = "netP") works fine (see outputs)
Yet command computeCommunProbPathway gives an error.

Any advise?

See code-

data.input <- GetAssayData(seurat_object_con, assay = "RNA", slot = "data") # normalized data matrix
labels <- Idents(seurat_object_con)
meta <- data.frame(group = labels, row.names = names(labels)) # create a dataframe of the cell labels

CellChatDB <- CellChatDB.mouse # use CellChatDB.mouse if running on mouse data
showDatabaseCategory(CellChatDB)

Show the structure of the database

dplyr::glimpse(CellChatDB$interaction)

use a subset of CellChatDB for cell-cell communication analysis

CellChatDB.use <- subsetDB(CellChatDB, search = "Secreted Signaling", key = "annotation") # use Secreted Signaling

cellchat_c <- createCellChat(object = data.input, meta = meta, group.by = "group")
cellchat_c <- addMeta(cellchat_c, meta = meta)
cellchat_c <- setIdent(cellchat_c, ident.use = "group") # set "group" as default cell identity
levels(cellchat_c@idents) # show factor levels of the cell labels
groupSize <- as.numeric(table(cellchat_c@idents)) # number of cells in each cell group
cellchat_c@DB <- CellChatDB.use

subset the expression data of signaling genes for saving computation cost

cellchat_c <- subsetData(cellchat_c)
cellchat_c <- identifyOverExpressedGenes(cellchat_c)
cellchat_c <- identifyOverExpressedInteractions(cellchat_c)

cellchat_c <- computeCommunProb(cellchat_c)

Filter out the cell-cell communication if there are only few number of cells in certain cell groups

cellchat_c <- filterCommunication(cellchat_c, min.cells = 20)

c.df.net <- subsetCommunication(cellchat_c) #returns a data frame consisting of all the inferred cell-cell communications at the level of ligands/receptors. Set slot.name = "netP" to access the the inferred communications at the level of signaling pathways

c.df.net.np <- subsetCommunication(cellchat_c,slot.name = "netP")

rio::export(c.df.net, file = "Con_Inferred_cell_cell_comm.xlsx", sep = "\t", rowNames = TRUE, colNames=TRUE)
rio::export(c.df.net.np, file = "Con_Inferred_sign_pthways_comm.xlsx", sep = "\t", rowNames = TRUE, colNames=TRUE)

cellchat_c <- computeCommunProbPathway(cellchat_c)
Error in prob.pathways[, , pathways.sig, drop = FALSE] :
subscript out of bounds

Con_Inferred_sign_pthways_comm.xlsx
Con_Inferred_cell_cell_comm.xlsx
sessioninfo.txt
str_cellchat_c.txt

@sqjin
Copy link
Owner

sqjin commented Dec 29, 2023

@Dena2021 Two issues were observed: 1) You should use the normalized data, which should be not the count data. In your seurat object, the data slot is the same as the count slot. If you use the sctransform, you can set data.input <- GetAssayData(seurat_object_con, assay = "SCT", slot = "data")

  1. You cell group label include 0, which is not allowed in CellChat.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants