Closed MrModenait closed 9 months ago
Having the exact same issue...
Having the exact same issue... Hi @krasole: are you also using CellChat to analyse GeoMx data?
Ok, I think i found some way to avoid this error after wasting a day's worth of time.
At least for me, this error
Error in if (sum(P1_Pspatial) == 0) { : missing value where TRUE/FALSE needed
was caused by the function
res <- computeRegionDistance(coordinates = cellchat@images$coordinates, meta = cellchat@meta, trim = 0.1, interaction.range = 250, ratio = cellchat@images$scale.factors$tol, tol = cellchat@images$scale.factors$tol, k.min = 10, contact.knn = T, contact.knn.k = 6)
which inside of function
computeCommunProb()
cause it return adj.contact.knn matrix contains NaN which gives error at
Error in if (sum(P1_Pspatial) == 0) { : missing value where TRUE/FALSE needed
by making P.spatial to NaN matrix
P.spatial <- P.spatial * adj.contact.knn
in this step
after i changed some code such as
group <- meta$group
to
group <- meta$labels
in the function of 'computeRegionDistance'
after this modification, it doesn't throw any error So i think it just error caused by declaring the vector 'group' from 'meta$group' which is normally 'NULL' for common users (Because the tutorial guides doing like that.)
cheers -Han-
Hello @leehs96, thank you for your suggestion. To my astonishing surprise, changing slices
in my metadata table from a character vector to a factor was able to solve the problem, and I could run computeCommunProb
loaded from CellChat 2.1.0 without any issues (labels
was already a factor since before). It was really that simple. I'm curious as to how you managed to get the source for the function though.
Unfortunately, it seems my attempt to analyse GeoMx data with CellChat was not very fruitful, as computeCommunProb
returns hardly any significant pathways. The inferred communication probabilities are all zero:
summary(cellchat@net$prob)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0 0 0 0 0 0
The p-values are all 1:
summary(cellchat@net$pval)
Min. 1st Qu. Median Mean 3rd Qu. Max.
1 1 1 1 1 1
And I get an error when trying to view all the inferred cell-to-cell communications.
subsetCommunication(cellchat)
Error in subsetCommunication_internal(net, LR, cells.level, slot.name = slot.name, :
No significant signaling interactions are inferred based on the input!
I think the cause of this may be my low number of regions per interest:
Var1 Freq
1 TC 37
2 TI-Unknown 13
3 I-Exhausted CD8+ T/Myeloid cells/Plasma cells 9
4 I-Follicular B cells/Exhausted CD8+ T/NK cells 8
5 I-FB-like cells/Myeloid cells/Pericytes 5
6 I-Exhausted CD8+ T/Pericytes/Plasma cells 4
7 TBV 4
8 TI-Exhausted CD8+ T/Myeloid cells/Plasma cells 4
9 TI-Follicular B cells/Exhausted CD8+ T/NK cells 4
10 I-Myeloid cells 3
11 TI-FB-like cells/Myeloid cells/Pericytes 3
12 TI-Myeloid cells 3
13 TI-FB-like cells/Myeloid cells/Pericytes & Exhausted CD8+ T/Myeloid cells/Plasma cells 2
14 TI-Exhausted CD8+ T/Pericytes/Plasma cells 1
When grouped by microscope slide, the number of interactions in each group is even lower.
slices
labels 16PL-27370 01-01 18PL-20291 01-02 19PL-12941 01-02 19PL-27147 01-03
I-Exhausted CD8+ T/Myeloid cells/Plasma cells 0 1 8 0
I-Exhausted CD8+ T/Pericytes/Plasma cells 2 0 2 0
I-FB-like cells/Myeloid cells/Pericytes 0 3 0 2
I-Follicular B cells/Exhausted CD8+ T/NK cells 6 0 2 0
I-Myeloid cells 0 0 0 3
TBV 0 0 0 4
TC 10 9 8 10
TI-Exhausted CD8+ T/Myeloid cells/Plasma cells 0 0 4 0
TI-Exhausted CD8+ T/Pericytes/Plasma cells 0 0 1 0
TI-FB-like cells/Myeloid cells/Pericytes 0 2 0 1
TI-FB-like cells/Myeloid cells/Pericytes & Exhausted CD8+ T/Myeloid cells/Plasma cells 0 2 0 0
TI-Follicular B cells/Exhausted CD8+ T/NK cells 3 0 1 0
TI-Myeloid cells 0 0 0 3
TI-Unknown 3 2 4 4
Unless my 0s and 1s are caused by an error, I fear this is the end of my venture into CellChat!
@MrModenait In your case, I do not think you need to run filterCommunication
as this is use for filtering out the cell groups with few number of cells.
我也遇到相同的报错,但和meta中的group或labels的类型无关,而是和seurat v5(多样本)的数据结构有关,在提取表达矩阵之前需要用JoinLayers函数对数据进行预处理,无需对metadata进行改动,然后运行computeCommunProb就不再报错了,希望对大家有帮助。 代码: data <- readRDS('saves2/pbmc_final_with_sample.rds') data.MMM <- subset(data,condition=='MMM') data.MMM <- JoinLayers(data.MMM[['RNA']]) data.input <- data.MMM$data.MMM …………
Hello @znxfdd, thanks for your reply. I presume you're working with a scRNA-seq dataset. My question is an unconventional one as I am trying to apply CellChat on a GeoMx spatial experiment.
I am following the vignette titled CellChat analysis of multiple spatial transcriptomics datasets, but I am having an issue with
computeCommunProb
. The issue is reminiscent of #245 (July 2021, last updated September 2022) and #300 (October 2021, last updated July 2023). Briefly, I am trying to use CellChat to analyse some data that has been collcted with the NanoString GeoMx machine. The data I have consists of 100 polygons across four different slides, each polygon having transcriptomic data for 9390 genes and associated x- and y-coordinates for that slide. I am trying to apply CellChat to this dataset despite it not being a 10X Visium dataset (each polygon contains between 70 and 330 nuclei, and the distance between polygons varies from 33.5 to 11205.4 micrometers). However, I am trying to input the data in the correct format nevertheless in the hope of obtaining some results.When running the
computeCommunProb
, I get an error:The problem also persists if I run the command without any additional arguments.
Following issue #300, I have checked that I have no negative values in my gene expression data. The row names are gene names whereas the column names are the names of my one-hundred segments, also known as regions of interest (ROIs).
The metadata contains the column names as row names, in the same order, and with twenty-seven metadata labels including a
slices
column.The same row names are found in the
coordinates
data frame, which is read successfully when runningcreateCellChat
:Finally, I have specified
ratio
andtol
in aratio_tol_df
data frame, with slide names as my rownames. Ratio has been found from reading the images in QuPath while tol was calculating as taking half the distance between the two closest ROIs.The cellchat object was correctly constructed and I used "Secreted Signaling" as my subset from
CellChatDB
.As you can see, the
Idents
taken fromlabels
are quite long, ranging from 2 to 86 characters.I have also dug into the source for this function, presumerably for an older version of CellChat, to find out what the
P1_Pspatial
vector is. It is the product ofP1
andP.spatial
,P1
being equal todataLR^n/(Kh^n + dataLR^n)
andP.spatial
being equal to1/d.spatial
(itself a result of running computeRegionDistance earlier in the code). I tried to run the code I found line by line but this was not possible due to the many errors I got, mainly because the source code dates from an older version of CellChat. The source refers tospot.size
andspot.size.fullres
but these seem to be replaced byratio
andtol
in the version of the function that I have installed.To address this, I downloaded CellChat 1.6.1 in a separate library and was able to get it to successfully run. I tried to run the
computeCommunProb
from this older package, but got a different error message:Oddly enough, I can get
computeRegionDistance
to run separately when I am offered the opportunity to specifygroup
.It seems I can't find a solution when running the older package. With this said, what could be the cause of my problem? For the record: