jinworks / CellChat

R toolkit for inference, visualization and analysis of cell-cell communication from single-cell and spatially resolved transcriptomics
GNU General Public License v3.0
217 stars 30 forks source link

Error when using a custom database #100

Open BenayounLaboratory opened 4 months ago

BenayounLaboratory commented 4 months ago

Hi,

I am trying to run CellChat on a single nuclei RNAseq dataset from the turquoise killifish. I basically followed the steps given in the previous version of CellChat, and generated a "killified" database for use with the package.

However, once I start running the pipeline described in the vignette I get errors that do not make sense (saying I have "NULL" data, when I removed all "NULL" lines).

Specifically: These 3 lines run fine:

cellChat.grz.Y <- createCellChat(object = killi.brain.grz.Y, group.by = "Cell_Identity", assay = "RNA")
cellChat.grz.Y  <- subsetData(cellChat.grz.Y, features = unique(CellChatDB.killi$geneInfo$Symbol)) 
cellChat.grz.Y  <- identifyOverExpressedGenes(cellChat.grz.Y )
cellChat.grz.Y

I get this, showing the object seems ok _

An object of class CellChat created from a single dataset 21160 genes. 18462 cells. CellChat analysis of single cell RNA-seq data!

_

But then, I get errors: cellChat.grz.Y <- identifyOverExpressedInteractions(cellChat.grz.Y , variable.both = F, features = unique(CellChatDB.killi$geneInfo$Symbol)) gives

Error in 1:nrow(complexSubunits) : argument of length 0

If I skip this line, and go to the next step: cellChat.grz.Y <- computeCommunProb(cellChat.grz.Y, type = "triMean")

I get this error:

triMean is used for calculating the average gene expression per cell group. Error in UseMethod("select") : no applicable method for 'select' applied to an object of class "NULL" In addition: Warning message: In asMethod(object) : sparse->dense coercion: allocating vector of size 1.8 GiB

This seems to suggest my database has empty slots but this is not the case:

dim(CellChatDB$interaction) # [1] 3130   28
dim(CellChatDB$complex    ) # [1] 271   5
dim(CellChatDB$cofactor   ) # [1] 33 16
dim(CellChatDB$geneInfo   ) # [1] 21038     8

Any idea what is happening and how to resolve the issue so I can run the algorithm on my data?

Thank you so much in advance for your help!

sqjin commented 4 months ago

@BenayounLaboratory You may not need to add features = unique(CellChatDB.killi$geneInfo$Symbol) when running the function. In addition, you should have a column named "Symbol" in geneInfo.