CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

computeCommunProb subscript out of bounds

Open myushen opened this issue 8 months ago • 1 comments

Hi,

Thanks for the amazing tool.

I followed the vignettes to compute communication probability and encountered the following issue.

library(CellChat)
sce
# A SingleCellExperiment-tibble abstraction: 530 × 34
# Features=53412 | Cells=530 | Assays=X
   .cell         observation_joinid observation_originalid donor_id dataset_id sample_id cell_type
   <chr>         <chr>              <chr>                  <fct>    <fct>      <fct>     <chr>    
 1 WHK030531___… K{unl$Zo1e         WHK030531              MM01     e22482ee-… afc12625… plasma c…
 2 WHK030538___… _-<`Ie%j4}         WHK030538              MM01     e22482ee-… afc12625… plasma c…
 3 WHK030539___… >n#@L!{ko2         WHK030539              MM01     e22482ee-… afc12625… plasma c…
 4 WHK030541___… jGhR7#CO%*         WHK030541              MM01     e22482ee-… afc12625… plasma c…
 5 WHK030543___… y>1>#i%d1y         WHK030543              MM01     e22482ee-… afc12625… plasma c…
 6 WHK030544___… -jy-Nv2L3#         WHK030544              MM01     e22482ee-… afc12625… plasma c…
 7 WHK030546___… _Db<5Ym`I(         WHK030546              MM01     e22482ee-… afc12625… plasma c…
 8 WHK030553___… CRKt_Z|n~4         WHK030553              MM01     e22482ee-… afc12625… plasma c…
 9 WHK030555___… `?aE5*3CN1         WHK030555              MM01     e22482ee-… afc12625… plasma c…
10 WHK030556___… k3Ywhecsnx         WHK030556              MM01     e22482ee-… afc12625… plasma c…
# ℹ 520 more rows
# ℹ 27 more variables: nFeature_RNA <dbl>, empty_droplet <lgl>, alive <lgl>,
#   blueprint_first_labels_fine <chr>, monaco_first_labels_fine <chr>,
#   azimuth_predicted_celltype_l2 <chr>, scores.Macrophages <dbl>, scores.Macrophages.M1 <dbl>,
#   scores.Macrophages.M2 <dbl>, scores.Naive.CD4.T.cells <dbl>,
#   scores.Terminal.effector.CD4.T.cells <dbl>, scores.CD4..T.cells <dbl>, scores.CD4..Tcm <dbl>,
#   scores.CD4..Tem <dbl>, scores.Follicular.helper.T.cells <dbl>, scores.Th1.cells <dbl>, …
# ℹ Use `print(n = ...)` to see more rows

cellchat = createCellChat(object = sce, group.by = "cell_type_unified_ensemble", assay = "X")
CellChatDB = CellChatDB.human
CellChatDB.use = subsetDB(CellChatDB, key = "annotation")
cellchat@DB = CellChatDB.use

cellchat = subsetData(cellchat) 
cellchat = identifyOverExpressedGenes(cellchat)
cellchat = identifyOverExpressedInteractions(cellchat)


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


cellchat = computeCommunProb(cellchat, type = "triMean")
triMean is used for calculating the average gene expression per cell group. 
Error in data.use[RsubunitsV, , drop = FALSE] : subscript out of bounds

I had tried type = "truncatedMean" and trim = 0.1, the same issue occurred.

Am I missing something obvious here?

Thanks in advance.

myushen avatar Apr 23 '25 06:04 myushen

The [email protected] and object@idents look ok to me, but LR is empty

> str([email protected])
Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
  ..@ i       : int [1:11730] 3 30 47 99 212 246 264 336 368 468 ...
  ..@ p       : int [1:531] 0 31 57 75 87 113 138 157 179 211 ...
  ..@ Dim     : int [1:2] 1123 530
  ..@ Dimnames:List of 2
  .. ..$ : chr [1:1123] "SEMA3F" "WNT16" "PLXND1" "CD38" ...
  .. ..$ : chr [1:530] "WHK030531___e22482ee-19e8-40bc-9f6e-541dc3c82c20" "WHK030538___e22482ee-19e8-40bc-9f6e-541dc3c82c20" "WHK030539___e22482ee-19e8-40bc-9f6e-541dc3c82c20" "WHK030541___e22482ee-19e8-40bc-9f6e-541dc3c82c20" ...
  ..@ x       : num [1:11730] 0.0083 0.0083 0.0251 0.0083 0.0167 ...
  ..@ factors : list()

> unique(cellchat@idents)
[1] plasma     progenitor monocytic 
Levels: monocytic plasma progenitor

> cellchat@LR
$LRsig
 [1] interaction_name         pathway_name             ligand                   receptor                
 [5] agonist                  antagonist               co_A_receptor            co_I_receptor           
 [9] evidence                 annotation               interaction_name_2       is_neurotransmitter     
[13] ligand.symbol            ligand.family            ligand.location          ligand.keyword          
[17] ligand.secreted_type     ligand.transmembrane     receptor.symbol          receptor.family         
[21] receptor.location        receptor.keyword         receptor.surfaceome_main receptor.surfaceome_sub 
[25] receptor.adhesome        receptor.secreted_type   receptor.transmembrane   version                 
<0 rows> (or 0-length row.names)

myushen avatar Apr 24 '25 01:04 myushen