zktuong / ktplots

Some tools for plotting single-cell data
https://zktuong.github.io/ktplots/
MIT License
162 stars 31 forks source link

plot_cpdb() error #110

Open rosanababu opened 4 months ago

rosanababu commented 4 months ago

Hi,

Many thanks for the amazing tool. I'm using ktplots and cellphoneDB for the first time. I've used cpdb_statistical_analysis_method from latest cellphoneDB v5 to run statistical analysis. plot_cpdb_heatmap() works fine on the results, unfortunately dot plot plot_cpdb() is showing error. Please could you help to solve the following error from plot_cpdb().

Dot plot

plot_cpdb(

  • scdata=sce,
  • cell_type1="Pericyte",
  • cell_type2=".",
  • celltype_key="Cell_type",
  • means=means_stat,
  • pvals=pvals_stat,
  • genes=c("TNFRSF13B", "STAT5A"),
  • title="interacting interactions!",
  • ) Error in dplyr::left_join(): ! Can't join x$Var2 with y$Var2 due to incompatible types. ℹ x$Var2 is a . ℹ y$Var2 is a <factor<4887b>>. Run rlang::last_trace() to see where the error occurred. rlang::last_trace() <error/dplyr_error_join_incompatible_type> Error in dplyr::left_join(): ! Can't join x$Var2 with y$Var2 due to incompatible types. ℹ x$Var2 is a . ℹ y$Var2 is a <factor<4887b>>.

    Backtrace: ▆

    1. └─ktplots::plot_cpdb(...)
    2. ├─dplyr::left_join(df_means, df_pvals, by = c("Var1", "Var2"))
    3. └─dplyr:::left_join.data.frame(df_means, df_pvals, by = c("Var1", "Var2")) Run rlang::last_trace(drop = FALSE) to see 22 hidden frames. rlang::last_trace(drop = FALSE) <error/dplyr_error_join_incompatible_type> Error in dplyr::left_join(): ! Can't join x$Var2 with y$Var2 due to incompatible types. ℹ x$Var2 is a . ℹ y$Var2 is a <factor<4887b>>.

      Backtrace: ▆

    4. ├─ktplots::plot_cpdb(...)
    5. │ ├─dplyr::left_join(df_means, df_pvals, by = c("Var1", "Var2"))
    6. │ └─dplyr:::left_join.data.frame(df_means, df_pvals, by = c("Var1", "Var2"))
    7. │ └─dplyr:::join_mutate(...)
    8. │ └─dplyr:::join_cast_common(x_key, y_key, vars, error_call = error_call)
    9. │ ├─rlang::try_fetch(...)
    10. │ │ └─base::withCallingHandlers(...)
    11. │ └─vctrs::vec_ptype2(x, y, x_arg = "", y_arg = "", call = error_call)
    12. ├─vctrs (local) <fn>()
    13. │ └─vctrs::vec_default_ptype2(...)
    14. │ ├─base::withRestarts(...)
    15. │ │ └─base (local) withOneRestart(expr, restarts[[1L]])
    16. │ │ └─base (local) doWithOneRestart(return(expr), restart)
    17. │ └─vctrs::stop_incompatible_type(...)
    18. │ └─vctrs:::stop_incompatible(...)
    19. │ └─vctrs:::stop_vctrs(...)
    20. │ └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)
    21. │ └─rlang:::signal_abort(cnd, .file)
    22. │ └─base::signalCondition(cnd)
    23. └─rlang (local) <fn>(<vctrs__2>)
    24. └─handlers[1L]
    25. └─dplyr:::rethrow_error_join_incompatible_type(cnd, vars, error_call)
    26. └─dplyr:::stop_join(...)
    27. └─dplyr:::stop_dplyr(...)
    28. └─rlang::abort(...)

Kind regards, RB

zktuong commented 4 months ago

hi @rosanababu , can i ask you to check if the column names for both your means_stat and pvals_stat are similar?

Also are the dimensions the same/similar?

biobirds9 commented 4 months ago

hi @rosanababu , can i ask you to check if the column names for both your and are similar?means_stat``pvals_stat

Also are the dimensions the same/similar?

Hi, I have also encountered this problem and I have confirmed that the column names of both files are exactly the same, how can I fix this error?

zktuong commented 4 months ago

what if you remove the genes option?

rosanababu commented 4 months ago

hi @rosanababu , can i ask you to check if the column names for both your means_stat and pvals_stat are similar?

Also are the dimensions the same/similar?

Hi, Thanks for your reply. Yes, the dimension and the column names for both means_stat and ovals_stat are similar. I could run it without any errors when I filtered out cells that has no UMIs using: seurat_subset <- subset(seurat, nCount_RNA > 10). Then, I created the metadata and counts matrices from seurat_subset to input CellPhoneDB. Now the outputs of CellphoneDB pvals_stat and means_stat is working fine even when I set splitkey for conditions. Thank you