axelalmet / flowsig

Python package to find communication-driven intercellular flows from single-cell RNA-sequencing and spatial transcriptomics data.
MIT License
56 stars 0 forks source link

How to plot differentially flowing signals? #8

Open changqinglu opened 2 months ago

changqinglu commented 2 months ago

Dear Author,

I have used your example dataset, burkhardt21, for analysis, and I performed variable filtering with the following code: fs.pp.determine_informative_variables(adata,
flowsig_expr_key = 'X_flow', flowsig_network_key = 'flowsig_network', spatial = False, condition_key = condition_key, control_key = 'Ctrl', qval_threshold = 0.05, logfc_threshold = 0.5)

After the analysis, I visualized the results with the following: fs.pl.plot_differentially_flowing_signals( adata = adata, condition_key = 'Condition', pert_key = 'IFNg', var_type = 'inflow', flowsig_expr_key = 'X_flow', flowsig_network_key = 'flowsig_network', qval_threshold = 0.05, logfc_threshold = 0.5, label_lowqval = True ) image image

My question is: does this visualization show only the filtered differential variables, excluding the ones below the thresholds? In your paper, Fig. 4b and Fig. 4c included data below the threshold values. How did you keep those data? Also, why are the differential inflow and outflow signal results in my analysis quite different from yours? I am looking forward to your response! Thank you!

axelalmet commented 2 months ago

Hi changqiuliu,

This is a really good question! What's happened is that actually, after running fs.pp.determine_informative_variables, FlowSig has already removed the non-differentially flowing variables that will be considered for analysis. If you want to plot the differentially flowing variables and the non-significant variables originally constructed, try running something like:

fs.pl.plot_differentially_flowing_signals(
adata = adata,
condition_key = 'Condition',
pert_key = 'IFNg',
var_type = 'inflow',
flowsig_expr_key = 'X_flow',
flowsig_network_key = 'flowsig_network_orig',
qval_threshold = 0.05,
logfc_threshold = 0.5,
label_lowqval = True
)

That is, all of the preliminary variables are stored in adata.uns['flowsig_network_orig'].

However, while I do expect the logQ values to change (as the number of comparisons has changed), it's a little weird that the log fold changes seem to change as well. I'll look into this...

To give context, the code is really based on the volcano plot found here.

Hope that helps, Axel.