Summary
The plotting helper for ligand activity and ligand-target combinations fails when the input is filtered down to a single ligand. This appears to be an edge case in the plotting code rather than a problem with the downstream analysis itself.
Expected behavior
The plot should render successfully even when the user requests a single ligand for a specific group and receiver combination.
group_oi = "Tumor"
receiver_oi = "CLEC9A"
ligands_oi = c("CSF1") # or alternatively "CSF1"
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
then
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)
Actual behavior
The call fails with:
Error in dimnames(x) <- dn: length of 'dimnames' [1] not equal to array extent
Why this seems to happen
The helper appears to assume a multi-ligand input when it reshapes the ligand-target matrix and assigns row names. When only one ligand is present in the filtered table, that assumption breaks and the matrix dimensions no longer match the expected dimnames assignment.
Notes
- The receiver and group names are valid.
- The filtered table is not empty.
- The failure occurs specifically when the filtered ligand set contains only one unique ligand.
Suggested fix
Handle the single-ligand case explicitly in make_ligand_activity_target_plot, or guard the matrix reshaping / rowname assignment so it works for both one-ligand and multi-ligand inputs.
Summary
The plotting helper for ligand activity and ligand-target combinations fails when the input is filtered down to a single ligand. This appears to be an edge case in the plotting code rather than a problem with the downstream analysis itself.
Expected behavior
The plot should render successfully even when the user requests a single ligand for a specific group and receiver combination.
then
Actual behavior
The call fails with:
Error in dimnames(x) <- dn: length of 'dimnames' [1] not equal to array extentWhy this seems to happen
The helper appears to assume a multi-ligand input when it reshapes the ligand-target matrix and assigns row names. When only one ligand is present in the filtered table, that assumption breaks and the matrix dimensions no longer match the expected dimnames assignment.
Notes
Suggested fix
Handle the single-ligand case explicitly in make_ligand_activity_target_plot, or guard the matrix reshaping / rowname assignment so it works for both one-ligand and multi-ligand inputs.