CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

error when run computeCommunProb function

Open Magetutor opened this issue 3 years ago • 6 comments

Thank you very much for providing cellchat! When I run the function computeCommunProb on my data, I met below error

V59.cellchat <- computeCommunProb(V59.cellchat, raw.use = TRUE)
  |         |   0% Error in if (sum(P1) == 0) { : missing value where TRUE/FALSE needed
In addition: There were 18 warnings (use warnings() to see them)

and my data in [email protected] and [email protected] as below

> str([email protected])
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:2483819] 0 1 2 3 4 5 6 7 8 9 ...
  ..@ p       : int [1:11240] 0 221 442 663 884 1105 1326 1547 1768 1989 ...
  ..@ Dim     : int [1:2] 221 11239
  ..@ Dimnames:List of 2
  .. ..$ : chr [1:221] "Cxcl2" "Ccl5" "Ccl4" "Ccl8" ...
  .. ..$ : chr [1:11239] "V_59_AAACCCAAGAGAGTTT-1" "V_59_AAACCCAAGCACTGGA-1" "V_59_AAACCCACAAGAATAC-1" "V_59_AAACCCACAATAGTAG-1" ...
  ..@ x       : num [1:2483819] -1.681 6.142 -2.049 -1.193 -0.874 ...
  ..@ factors : list()
> str([email protected])
 num [1:221, 1:11239] -1.681 6.142 -2.049 -1.193 -0.874 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:221] "Cxcl2" "Ccl5" "Ccl4" "Ccl8" ...
  ..$ : chr [1:11239] "V_59_AAACCCAAGAGAGTTT-1" "V_59_AAACCCAAGCACTGGA-1" "V_59_AAACCCACAAGAATAC-1" "V_59_AAACCCACAATAGTAG-1" ...

Thanks for your beautiful work! Looking forward for your reply and help!

Magetutor avatar Feb 07 '22 05:02 Magetutor

@Magetutor Your data have negative values. You should use the normalized data without negative values.

sqjin avatar Feb 07 '22 10:02 sqjin

@sqjin Many thanks for your quick reply!I got it!

Magetutor avatar Feb 07 '22 12:02 Magetutor

@Magetutor Would you mind sharing the code you used to select normalized data without negative values if you are using analysis from Seurat?

domjacri avatar May 11 '22 14:05 domjacri

Hello @sqjin! My data were batch-corrected by fastMNN, and therefore contained many negative values. Batch correction is quite important in my case as the two datasets I integrated had very different cell-type compositions.

Can you give me advice on how to make the input matrix suitable for CellChat? Thanks!

RoseString avatar May 19 '22 21:05 RoseString

@RoseString While I have not extensively tested the batch-corrected data, I think people usually set the negative values to zero when using it for downstream analysis such as gene scoring analysis and gene expression analysis. What is your strategy when using these corrected data? I think you can try it in this way.

sqjin avatar May 19 '22 22:05 sqjin

@RoseString You can simply get this normalized data via GetAssayData(object = pbmc_small, slot = "data",assay = "RNA")

sqjin avatar May 19 '22 22:05 sqjin