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
287 stars 49 forks source link

Relative information flow using wrong color #87

Open DelongZHOU opened 8 months ago

DelongZHOU commented 8 months ago

Hi,

I find the information flow chat sometimes is using the wrong color for the legend (to indicate which condition has stronger communication)

The code I'm using: rankNet(cellchat, mode = "comparison",comparison = c(1, 2),stacked = T, do.stat = TRUE, color.use = c('#808080','#d8b365'), targets.use = c(5), sources.use =c(5)) And the first few pathways are marked enriched in the second condition despite the bar ratios suggesting otherwise. image

Also when I choose only the colored pathways to replot the same figure some of them become black (not significant). I wonder if there is a way to extract the communication strength value and p val for the comparison as a table so I can choose which ones to plot.

Thank you!

sqjin commented 8 months ago

@DelongZHOU This is unexpected. Can you check the order of the two datasets in the object via names(methods::slot(cellchat, "netP"))

The codes below will return the data gg <- rankNet() df <- gg$data

DelongZHOU commented 8 months ago

@DelongZHOU This is unexpected. Can you check the order of the two datasets in the object via names(methods::slot(cellchat, "netP"))

The codes below will return the data gg <- rankNet() df <- gg$data

Hi, Thank you for the reply. I've checked the order of the datasets - they are as expected.

The $data label works and I'm planning to plot the data differently as I have more than 2 conditions in my data.

However may I suggest reformatting the $data label: currently the same pathways are listed twice, once for each condition; same with p values. The additional index is set to the pathway name for the first condition and with a suffix as they apprear again for the second condition. It'd be easier to read if the contribution of second condition are listed as additional columns instead of additional rows so the shared info (such as name, pvalue, relative contribution etc) would apprear only once.

Thank you!