saeyslab / nichenetr

NicheNet: predict active ligand-target links between interacting cells
452 stars 113 forks source link

How exactly the ligand activity were calculate? #260

Closed iceautumn closed 1 month ago

iceautumn commented 2 months ago

Thank you for developing these tools, which are incredibly beneficial for analyzing cell-cell communication. As I was examining the regulatory heatmap, I noticed that some ligands, such as EFNA1, target only a few genes. Despite that, EFNA1's rank seems more optimized than CDH1, which targets a much larger number of genes. This observation puzzled me, so I decided to investigate how ranks are calculated, which led me to the predict_ligand_activities function. Upon reviewing the function's code on rdrr.io, I found that get_single_ligand_importances plays a crucial role within it. In turn, the critical function for that one is evaluate_target_prediction. Yet, it seems this isn't the final function responsible for calculating metrics like AUPR, etc. My search ultimately led me to focus on the evaluate_target_prediction_strict function, which is nested within evaluate_target_prediction. However, I haven't been able to locate the detailed code for this function, and my attempts to Google it turned up no useful results. I’m wondering if evaluate_target_prediction_strict is indeed the key function for calculating metrics such as "auroc", "aupr", "aupr_corrected", and "pearson", and if so, where could I access these detailed codes? test_heatmap

Eisuan commented 2 months ago

Thank you for your enquiry. To compute the prediction values, the function evaluate_target_prediction_strictcalls classification_evaluation_continuous_pred using the response and prediction vectors as inputs.

Inside classification_evaluation_continuous_pred you will find all the functions that are called to compute the AUPR and correlation scores. In this way, you should be able to reconstruct all the steps and inputs used to prioritize EFNA1 and CDH1.