ventolab / CellphoneDB

CellPhoneDB can be used to search for a particular ligand/receptor, or interrogate your own HUMAN single-cell transcriptomics data.
https://www.cellphonedb.org/
MIT License
336 stars 54 forks source link

Means for reciprocal cell type comparisons are different #194

Open manf1984 opened 5 months ago

manf1984 commented 5 months ago

Dear authors of cellphoneDB, first of all, thanks for this very very useful tool! I am using it to evaluate ligand-receptor interactions among different annotated cell type a scRNAseq dataset. I am using cellphonedb 5.0.0 in a python 3.10 dedicated conda environment.

Checking the output files generated I noticed one discrepancy. The means for an interaction (e.g. GENE A - GENE B) are not the same between reciprocal/mirror cell type pairs (e.g. "cell type A | cell type B" and "cell type B | cell type A"). How is this possible?

Code below

from cellphonedb.src.core.methods import cpdb_statistical_analysis_method

cpdb_results = cpdb_statistical_analysis_method.call(
         cpdb_file_path = "/path/to/cellphonedb.zip",
         meta_file_path = "/path/to/Metadata_for_cellphoneDB.csv",
         counts_file_path = "/path/to/AnnData_for_cellphoneDB.h5ad",
         counts_data = 'hgnc_symbol',
         output_path = "/path/to/output")

Then I check the txt output files with "means" and "significant means"

result_file_path = "/path/to/statistical_analysis_means_06_11_2024_124047.txt"
resultsDf = pd.read_csv(result_file_path, sep = "\t", header = 0)

print(resultsDf.loc[288, "Cell type A|Cell type B"]) #mean is 2.279
print(resultsDf.loc[288, "Cell type B|Cell type A"]) #mean is 0.006 

The values are different. But the cells are exactly the same, just the comparison is reciprocal. Why are the values different? Is that expected? Thanks in advance for your help with this!

ktroule commented 5 months ago

Hi.

They are different because you are looking at the same pair of cells and interacting proteins but with the proteins swapped:

manf1984 commented 5 months ago

Ohh I see! That explains it! Thanks very much for your quick reply!