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

Plotting the Ligand-Activity plot for a ligand of interest #53

Closed pdimitron closed 3 months ago

pdimitron commented 7 months ago

Hello and Happy New Year!

Once again, thanks for such a great tool. I wanted to ask a quick question because I couldn't find it in the couple vignettes I was working through. I was wondering if you there is a way to generate ligand-activity plots for specific ligands of interest. I tried various ways of subsetting the tables but keep running into the following error:

combined_plot_select = make_ligand_activity_target_plot(group_oi, receiver_oi, prioritized_tbl_oi_select, multinichenet_output_select$prioritization_tables, multinichenet_output_select$ligand_activities_targets_DEgenes, contrast_tbl, multinichenet_output_select$grouping_tbl, multinichenet_output_select$celltype_info, ligand_target_matrix, plot_legend = FALSE)
Joining with `by = join_by(contrast)`

Error in dimnames(x) <- dn :
  length of 'dimnames' [1] not equal to array extent

Just thought I'd ask if I might be over thinking this before I provide a reproducible example.

browaeysrobin commented 7 months ago

Hi @pdimitron

This is indeed not so elegant to do for the moment. You can try this workaround as a (temporary) solution:

```{r}
ligands_oi = c("IFNG","IL15")
prioritized_tbl_ligands_oi = get_top_n_lr_pairs(multinichenet_output$prioritization_tables, 10000, groups_oi = group_oi, receivers_oi = receiver_oi) %>% filter(ligand %in% ligands_oi) # ligands should still be in the output tables of course

combined_plot = make_ligand_activity_target_plot(group_oi, receiver_oi, prioritized_tbl_ligands_oi, multinichenet_output$prioritization_tables, multinichenet_output$ligand_activities_targets_DEgenes, contrast_tbl, multinichenet_output$grouping_tbl, multinichenet_output$celltype_info, ligand_target_matrix, plot_legend = FALSE)
combined_plot

This will only for ligands that are in the output tables though.

pdimitron commented 7 months ago

Thanks so much, I'll give it a try!

browaeysrobin commented 3 months ago

This code is now demonstrated in the comprehensive tutorial vignette of multinichenetr 2.0.0