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
195 stars 21 forks source link

Issue with color when specifying sources and targets in RankNet function #117

Open esauras opened 2 months ago

esauras commented 2 months ago

Hi,

Thank you for developing this great package!

I'm using the RankNet function to identify the differential enriched signaling pathways between certain senders (sources.use) and receivers (targets.use) and I'm having some issues with the red/blue color.

As it is specified in the vignette, the color of the signaling pathway is red if contribution.relative < 1-tol & pvalues < cutoff.pvalue and blue if contribution.relative > 1+tol & pvalues < cutoff.pvalue. In my case, both tol and cutoff.pvalue are 0.05. Therefore, I would expect some signaling pathways, such as COMPLEMENT (where contribute.relative = 0 and pvalues = 0.043) to be colored red. However, it appears in black (as shown in the image).

Captura de pantalla 2024-04-04 124719

For example, SPP1 (where contribute.relative = 0 and p.values = 0.003) appears in red as expected. So, I don't know why it only occurs in some of the signaling pathways.

Can anyone help me, please?

Thank you very much! Esther

sqjin commented 2 months ago

@esauras Do you set add.stat = FALSE? When doing statistical test, it is possible to have signaling colored by grey due to its non-significance.

esauras commented 2 months ago

No, I set do.stat = TRUE.

Looking the rankNet function code available in GitHub in more detail, I think that p-values are calculated based on the whole probability matrix, even when sources.use and targets.use are specified. If I am not wrong, prob.list is established before creating the probability matrix with the values only for sources and targets (prob.list[[i]] <- prob), so that, the Wilcoxon test is calculated with the probability values for all the interactions between cell types (nrow = nrow(prob.list[[1]]) * nrow(prob.list[[1]])).

image

Could you check it, please?

sqjin commented 2 months ago

@esauras Thanks for pointing out this issue. It is now fixed.