jinworks/CellChat

computeCommunProb Inconsistent Slot to createCellChat

DarioS opened this issue · 2 comments

computeCommunProb fails with aggregate error.

> cellChatData
An object of class CellChat created from a single dataset 
 21473 genes.
 101722 cells. 
CellChat analysis of single cell RNA-seq data! 
> cellChatData <- computeCommunProb(cellChatData)
triMean is used for calculating the average gene expression per cell group. 
Error in aggregate.data.frame(as.data.frame(x), ...) : 
  no rows to aggregate
In addition: Warning message:
In max(data) : no non-missing arguments to max; returning -Inf

The input data has no negative values.

> class(assay(allHuman, "merged"))
  "dgCMatrix"
> sum(assay(allHuman, "merged") < 0)
  0

It looks like it expects to find RNA abundance matrix in a different slot.

if (raw.use) {
        data <- as.matrix(object@data.signaling)
    }
    else {
        data <- object@data.project
    }

> str(cellChatData) # But it is in data slot.
Formal class 'CellChat' [package "CellChat"] with 15 slots
  ..@ data.raw      : num[0 , 0 ] 
  ..@ data          :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  .. .. ..@ i       : int [1:1366909514] 1 7 8 11 12 13 14 15 16 17 ...
  .. .. ..@ p       : int [1:101723] 0 15202 28539 41479 54546 68718 83648 96258 112230 128208 ...
  .. .. ..@ Dim     : int [1:2] 21473 101722
  .. .. ..@ Dimnames:List of 2
  .. .. .. ..$ : chr [1:21473] "AL627309.1" "AL627309.5" "AP006222.2" "LINC01409" ...
  .. .. .. ..$ : chr [1:101722] "DANFRO_CUL1HNP3_AAACCTGAGGACAGAA-1" "DANFRO_CUL1HNP3_AAACCTGGTGCGAAAC-1" "DANFRO_CUL1HNP3_AAACCTGTCATTCACT-1" "DANFRO_CUL1HNP3_AAACGGGTCGTAGGTT-1" ...
  .. .. ..@ x       : num [1:1366909514] 0.01213 0.07797 0.00399 1.01789 0.01951 ...
  .. .. ..@ factors : list()
  ..@ data.signaling: num[0 , 0 ] 
  ..@ data.scale    : num[0 , 0 ] 
  ..@ data.project  : num[0 , 0 ] 

@DarioS You have to run the subsetData function even if no signaling genes are filtered.

Ah, I see now. Perhaps a more informative error message handling this user mistake would be beneficial to end-users.