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

Error in Interpretable bubble plots #72

Closed Chenium123 closed 2 months ago

Chenium123 commented 2 months ago

I encountered the following error while generating interpretable bubble plots:

plot_oi = make_sample_lr_prod_activity_plots_Omnipath(

  • multinichenet_output$prioritization_tables,
  • prioritized_tbl_oi_M_50 %>% inner_join(lr_network)
  • ) Joining with by = join_by(ligand, receptor) Error in UseMethod("mutate") : no applicable method for 'mutate' applied to an object of class "NULL"

Two weeks ago, I had no issues running the same code and using the same output files. I haven’t updated your package during this period, which makes me very puzzled.

image image image

maartenciers commented 2 months ago

Can you make sure the variables ligand and receptor aren't NULL or empty? You can do this with is.null(ligand) or is.null(receptor).

Chenium123 commented 2 months ago

Can you make sure the variables ligand and receptor aren't NULL or empty? You can do this with is.null(ligand) or is.null(receptor).

I have just made sure they are all not NULL. If you have recently been using this package, you can try running this step in your environment. I have contacted several friends, and they all encountered the same error and issue. It seems to have appeared only recently.

Chenium123 commented 2 months ago
rlang::last_trace()
<error/dplyr:::mutate_error>
Error in `mutate()`:
ℹ In argument: `ligand = convert_alias_to_symbols(ligand, organism = organism)`.
Caused by error in `convert_alias_to_symbols()`:
! could not find function "convert_alias_to_symbols"
---
Backtrace:
    ▆
 1. ├─... %>% ...
 2. ├─dplyr::mutate(...)
 3. └─dplyr:::mutate.data.frame(...)
 4.   └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
 5.     ├─base::withCallingHandlers(...)
 6.     └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
 7.       └─mask$eval_all_mutate(quo)
 8.         └─dplyr (local) eval()
Run rlang::last_trace(drop = FALSE) to see 3 hidden frames.
maartenciers commented 2 months ago

The function comes from the nichenetr package can you make sure to also install and load the nichenetr package using library(nichenetr) or with nichenetr::convert_alias_to_symbols(ligand, organism = organism)? This should resolve the error you encounter.

maartenciers commented 2 months ago

Additionally, make sure you read each step in the vignettes thoroughly, especially read this as it gives a detailed explanation on all steps needed to run multinichenetr. Following packages are needed for the analysis:

library(SingleCellExperiment)
library(dplyr)
library(ggplot2)
library(nichenetr)
library(multinichenetr)
Chenium123 commented 2 months ago

The function comes from the nichenetr package can you make sure to also install and load the nichenetr package using library(nichenetr) or with nichenetr::convert_alias_to_symbols(ligand, organism = organism)? This should resolve the error you encounter.

Thank you for your response. Before loading the multinichenetr package, I updated and loaded the nichenetr package. However, the same error still occurred at this step. Therefore, I checked and ran the source code:

>   group_data = prioritization_tables$group_prioritization_table_source  %>% dplyr::mutate(sender_receiver = paste(sender, receiver, sep = " --> "), lr_interaction = paste(ligand, receptor, sep = " - "))  %>% dplyr::distinct(id, sender, receiver, sender_receiver, lr_interaction, group, activity, activity_scaled, direction_regulation, prioritization_score) %>% dplyr::filter(id %in% sample_data$id) %>%  dplyr::arrange(receiver) %>% dplyr::group_by(receiver) %>%  dplyr::arrange(sender, .by_group = TRUE)
Error in UseMethod("mutate") : 
  no applicable method for 'mutate' applied to an object of class "NULL"
> rlang::last_trace()
<error/rlang_error>
Error in `dplyr::filter()`:
ℹ In argument: `id %in% prioritized_tbl_oi$id`.
Caused by error in `h()`:
! error in evaluating the argument 'table' in selecting a method for function '%in%': object 'prioritized_tbl_oi' not found
---
Backtrace:
     ▆
  1. ├─... %>% dplyr::arrange(sender, .by_group = TRUE)
  2. ├─dplyr::arrange(., sender, .by_group = TRUE)
  3. ├─dplyr::group_by(., receiver)
  4. ├─dplyr::arrange(., receiver)
  5. ├─dplyr::mutate(...)
  6. ├─dplyr::filter(., id %in% prioritized_tbl_oi$id)
  7. ├─dplyr:::filter.data.frame(., id %in% prioritized_tbl_oi$id)
  8. │ └─dplyr:::filter_rows(.data, dots, by)
  9. │   └─dplyr:::filter_eval(...)
 10. │     ├─base::withCallingHandlers(...)
 11. │     └─mask$eval_all_filter(dots, env_filter)
 12. │       └─dplyr (local) eval()
 13. ├─id %in% prioritized_tbl_oi$id
 14. └─base::.handleSimpleError(...)
 15.   └─base (local) h(simpleError(msg, call))
Run rlang::last_trace(drop = FALSE) to see 3 hidden frames.

Based on the error message, I checked the prioritized_tbl_oi file. As shown in the figure, it exists in the environment, and the data appears to be normal. image

Thank you again!

Chenium123 commented 2 months ago

After comparing the parameters with the source code, I found that the issue arises from some parameters in the new visualization code being incompatible with the multinichenet output file generated by version 1.0.3. It is necessary to run the full version 2.0.0 program. However, while running version 2.0.0, I encountered an issue consistent with issue #70. The developer needs to fix this. Thank you!

browaeysrobin commented 2 months ago

Hi @Chenium123 The issue is indeed this: Some visualization options of multinichenetr version >= 2.0.0. are only compatible with MultiNicheNet output object generated by version multinichenetr version >= 2.0.0. This is now added to the Readme of this package.