CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

Error in using identifyOverExpressedGenes

Open ssruser opened this issue 11 months ago • 4 comments

I have been trying to use the new cellchat v2 to run some analysis but I keep getting the same error when performing the ' identifyOverExpressedGenes' function.

I wanted to use the 'Comparison analysis of multiple datasets using CellChat' tutorial but read you need to first run CellChat on each dataset separately and then merge different CellChat objects together. So I started running the 'Inference and analysis of cell-cell communication using CellChat' tutorial first.

I have a seurat object with a control and a ko conditon so I first split this based on conditon then ran the pipeline on both datasets seperatly. This is the script I used... ##Split harmony.20 dataset into two based on condition (WT/KO) WT.dataset <- subset(x = harmony.20.filt.2.res0.5, subset = Condition == "WT.dataset") KO.dataset <- subset(x = harmony.20.filt.2.res0.5, subset = Condition == "KO.dataset")

##Check the condition label again to check it has been split correctly table(WT.dataset[["Condition"]]) table(KO.dataset[["Condition"]])

##STEP 4 - Preparing to start from a Seurat object - with the split object #for the WT dataset data.input.wt <- WT.dataset[["RNA"]]@data # normalized data matrix #For Seurat version >= “5.0.0”, get the normalized data via seurat_object[["RNA"]]$data labels.wt <- Idents(WT.dataset) meta.wt <- data.frame(labels = labels.wt, row.names = names(labels.wt)) # create a dataframe of the cell labels

cellchat.WT <- createCellChat(object = data.input.wt, group.by = "orig.ident", assay = "RNA")

#for the KO dataset data.input.ko <- KO.dataset[["RNA"]]@data # normalized data matrix #For Seurat version >= “5.0.0”, get the normalized data via seurat_object[["RNA"]]$data labels.ko <- Idents(KO.dataset) meta.ko <- data.frame(labels = labels.ko, row.names = names(labels.ko)) # create a dataframe of the cell labels

cellchat.KO <- createCellChat(object = data.input.ko, group.by = "orig.ident", assay = "RNA")

##STEP 5 - Assigning the reference database to the object CellChatDB <- CellChatDB.mouse showDatabaseCategory(CellChatDB) dplyr::glimpse(CellChatDB$interaction)

#assigning ref database minus non-protein interactions... CellChatDB.use <- subsetDB(CellChatDB) cellchat.WT@DB <- CellChatDB.use cellchat.KO@DB <- CellChatDB.use

##STEP 6 - Preprocessing the cellchat objects ##subset and pre-processing the expression data ##subset the expresion data to use less RAM cellchat.WT <- subsetData(cellchat.WT) cellchat.KO <- subsetData(cellchat.KO)

##pre-processing the expression data cellchat.WT <- identifyOverExpressedGenes(cellchat.WT) cellchat.WT <- identifyOverExpressedInteractions(cellchat.WT)

cellchat.KO <- identifyOverExpressedGenes(cellchat.KO) cellchat.KO <- identifyOverExpressedInteractions(cellchat.KO)

When I run these lines... 'cellchat.WT <- identifyOverExpressedGenes(cellchat.WT) or cellchat.KO <- identifyOverExpressedGenes(cellchat.KO)' I get the following error...

cellchat.WT <- identifyOverExpressedGenes(cellchat.WT) Error in wilcoxauc.default(data.use, labels, groups_use = level.use) : number of columns of X does not match length of y

Can someone help me figure this out? I have used the previous version of cellchat with the same data and used the same rough lines of code but never encountered an error in this line so unsure the cause of this.

Thank you in advance!

ssruser avatar Mar 26 '24 16:03 ssruser

Did you find a solution? I'm currently running into the same issue

martina-morchio avatar Apr 08 '24 14:04 martina-morchio

Please confirm whether you choose the right database. See #15

ZhangMH2000 avatar Apr 24 '24 15:04 ZhangMH2000

Hi Thank you for your response, I believe I did, the tissue I am using is mouse and I have selected for this.

##STEP 5 - Assigning the reference database to the object CellChatDB <- CellChatDB.mouse showDatabaseCategory(CellChatDB) dplyr::glimpse(CellChatDB$interaction)

#assigning ref database minus non-protein interactions... CellChatDB.use <- subsetDB(CellChatDB) cellchat.WT@DB <- CellChatDB.use cellchat.KO@DB <- CellChatDB.use

ssruser avatar Apr 24 '24 15:04 ssruser

Hi Thank you for your response, I believe I did, the tissue I am using is mouse and I have selected for this.

##STEP 5 - Assigning the reference database to the object CellChatDB <- CellChatDB.mouse showDatabaseCategory(CellChatDB) dplyr::glimpse(CellChatDB$interaction)

#assigning ref database minus non-protein interactions... CellChatDB.use <- subsetDB(CellChatDB) cellchat.WT@DB <- CellChatDB.use cellchat.KO@DB <- CellChatDB.use

I hope you have figured this out. For me the problem was with the following step: CellChatDB.use <- subsetDB(CellChatDB) If you want to filter out non-protein interactions, replacing it with the following line would remove the error: CellChatDB.use <- subsetDB(CellChatDB, search =c("Secreted Signaling","ECM-Receptor","Cell-Cell Contact"), key = c("annotation")) Best

ifanirene avatar May 06 '24 03:05 ifanirene