saeyslab / multinichenetr

MultiNicheNet: a flexible framework for differential cell-cell communication analysis from multi-sample multi-condition single-cell transcriptomics data
GNU General Public License v3.0
107 stars 14 forks source link

Sample Prioritizations are there, but not getting group prioritizations #49

Closed pdimitron closed 8 months ago

pdimitron commented 8 months ago

Hello,

I love the new MultiNichetNet Package and have been using it for some time now. I'm running into a challenge that I'm unsure how to fix. Everything is running smoothly up until the _generate_prioritizationtables step. It appears that my prioritization table by group is empty, although my prioritization table by sample is populated.

prioritization_tables$group_prioritization_tbl %>% head(20)
# A tibble: 0 × 59
# ℹ 59 variables: contrast <chr>, group <chr>, sender <chr>, receiver <chr>,
#   ligand <chr>, receptor <chr>, lfc_ligand <dbl>, lfc_receptor <dbl>,
#   ligand_receptor_lfc_avg <dbl>, p_val_ligand <dbl>, p_adj_ligand <dbl>,
#   p_val_receptor <dbl>, p_adj_receptor <dbl>, activity <dbl>,
#   direction_regulation <fct>, activity_scaled <dbl>, lr_interaction <chr>,
#   id <chr>, avg_ligand_group <dbl>, avg_receptor_group <dbl>,
#   ligand_receptor_prod_group <dbl>, fraction_ligand_group <dbl>, …
prioritization_tables$sample_prioritization_tbl %>% head(20)
# A tibble: 20 × 26
   sample     sender     receiver ligand receptor avg_ligand avg_receptor
   <chr>      <chr>      <chr>    <chr>  <chr>         <dbl>        <dbl>
 1 LCH_Liver1 Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.63         2.69
 2 WT_Lung3   Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.47         2.69
 3 LCH_Liver1 MoMac      moLCH    Lyz2   Itgal          5.43         2.69
 4 LCH_Lung1  Neutro     Neutro   Il1b   Il1r2          4.99         2.84
 5 WT_Lung8   Neutro     Neutro   Il1b   Il1r2          5.21         2.69
 6 LCH_Lung9  DC1        DC1      H2.DMa Cd74           2.60         5.34
 7 WT_Lung8   Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.39         2.58
 8 WT_Liver3  Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.66         2.37
 9 WT_Liver8  Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.55         2.40
10 WT_Lung3   MoMac      moLCH    Lyz2   Itgal          4.91         2.69
11 WT_Liver3  MoMac      moLCH    Lyz2   Itgal          5.57         2.37
12 WT_Lung8   Neutro     Mast     S100a8 Cd69           5.78         2.27
13 WT_Lung8   DC1        DC1      H2.DMa Cd74           2.54         5.16
14 WT_Lung8   MoMac      moLCH    Lyz2   Itgal          5.05         2.58
15 LCH_Lung1  Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.30         2.45
16 LCH_Liver1 RTM        moLCH    Lyz2   Itgal          4.80         2.69
17 LCH_Lung9  RTM        MoMac    Apoe   Trem2          5.63         2.28
18 LCH_Lung1  MoMac      moLCH    Lyz2   Itgal          5.23         2.45
19 LCH_Liver9 Ly6c_hi_Mo moLCH    Lyz2   Itgal          5.16         2.47
20 LCH_Lung9  DC1        DC2      H2.DMa Cd74           2.60         4.89
# ℹ 19 more variables: ligand_receptor_prod <dbl>, fraction_ligand <dbl>,
#   fraction_receptor <dbl>, ligand_receptor_fraction_prod <dbl>,
#   pb_ligand <dbl>, pb_receptor <dbl>, ligand_receptor_pb_prod <dbl>,
#   group <chr>, prioritization_score <dbl>, lr_interaction <chr>, id <chr>,
#   scaled_LR_prod <dbl>, scaled_LR_frac <dbl>, scaled_LR_pb_prod <dbl>,
#   n_cells_receiver <dbl>, keep_receiver <dbl>, n_cells_sender <dbl>,
#   keep_sender <dbl>, keep_sender_receiver <fct>

I was looking back at different objects and the grouping table seems fine, but I can't tell if anything else is amiss. Do you have any suggestions? Is there a threshold that I might need to play with?

browaeysrobin commented 8 months ago

Hi @pdimitron

To help pinpoint the exact issue, it would be helpful if you could: 1) run an analysis based on a vignette showcasing the wrapper function. 2) try the "basic_analysis_steps_MISC.Rmd" vignette by using the dev-branch version of this package for now on (https://github.com/saeyslab/multinichenetr/blob/dev-branch/vignettes/basic_analysis_steps_MISC.Rmd).

Do you run into troubles for one of those as well?

pdimitron commented 8 months ago

Hi @browaeysrobin, when I ran it with the wrapper function all was well and it actually pointed me to the source of the issue.

When setting up the contrasts, I followed the notation carefully when putting in my own variables, but then I realized the contrasts argument in contrasts_tbl has a slightly difference format. I was able to fix the issue.

Thank you for responding!