zktuong / ktplots

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

the parameter keep_significant_only in plot_cpbd.R is not work #84

Closed snow55 closed 8 months ago

snow55 commented 9 months ago

Hi, thank you for your beautiful work.

I'm trying to set keep_significant_only = TRUE when runing plot_cpdb function and setting degs_analysis=TRUE in R, but I found that it can not plot the significant L-R pairs.

Here are my codes:

pvals = read.delim(paste0(dir_out, 'degs_analysis_relevant_interactions_result.txt'), check.names = FALSE) tmp = pvals[ grep("^CXC|CCL|CCR|CX3|XCL|XCR",pvals$interacting_pair),c('interacting_pair','Macrophage|DC','DC|Macrophage')] tmp = tmp[tmp$Macrophage|DC==1 | tmp$DC|Macrophage==1,] #print significant L-R pairs print(tmp)

A data.frame: 6 × 3 interacting_pair Macrophage|DC DC|Macrophage

25 CCL3_CCR1 1 1 26 CCL3L1_CCR1 1 1 28 CCL19_CCRL2 0 1 30 CCL20_CCR6 1 0 68 CXCL9_CXCR3 1 0 69 CXCL10_CXCR3 1 0 >plot_cpdb( scdata = sce_obj, cell_type1 = "Macrophage", cell_type2 = "DC", celltype_key = "Tcelltype", means = means, pvals = pvals, keep_significant_only=TRUE, degs_analysis=TRUE, # genes = c('CXCL10') gene_family = "chemokines" ) Error in plot_cpdb(scdata = sce_obj, cell_type1 = "Macrophage", cell_type2 = "DC", : No significant genes found and plotting will not proceed. Traceback: 1. plot_cpdb(scdata = sce_obj, cell_type1 = "Macrophage", cell_type2 = "DC", . celltype_key = "Tcelltype", means = means, pvals = pvals, . keep_significant_only = TRUE, degs_analysis = TRUE, gene_family = "chemokines") 2. stop("No significant genes found and plotting will not proceed.") Besides, I found that the default setting of keep_significant_only is TRUE which is not consistent with the description. #' @param keep_significant_only logical. **Default is FALSE**. Switch to TRUE if you only want to plot the significant hits from cpdb. plot_cpdb <- function(scdata, cell_type1, cell_type2, celltype_key, means, pvals, interaction_scores = NULL, cellsign = NULL, max_size = 8, **keep_significant_only = TRUE,** splitby_key = NULL, gene_family = NULL, custom_gene_family = NULL, genes = NULL, standard_scale = TRUE, cluster_rows = TRUE, col_option = viridis::viridis(50), default_style = TRUE, highlight_col = "red", highlight_size = NULL, max_highlight_size = 2, special_character_regex_pattern = NULL, degs_analysis = FALSE, return_table = FALSE, exclude_interactions = NULL, min_interaction_score = 0, scale_alpha_by_interaction_scores = FALSE, scale_alpha_by_cellsign = FALSE, filter_by_cellsign = FALSE, title = "", ...) I am wondering whether you could check it and fix these questions. Another question is how we can only plot significant L-R pairs with no other noise L-R pairs? Thank you very much!
zktuong commented 9 months ago

thanks @snow55. would you be able to send to me these files so that can do some more testing?

snow55 commented 9 months ago

thanks @snow55. would you be able to send to me these files so that can do some more testing?↳

I'm sorry. Since plot_cpdb function need the sce_object which contains large data, maybe I cannot sent you these files. But what I just do is using cpdb_degs_analysis_method.call() function in python script to get the degs_analysis_relevant_interactions_result.txt. I am wondering whether you can give us a degs analysis tutorial in https://zktuong.github.io/ktplots/articles/vignette.html, rather than mentioned it in a sentence. Thank you very much! image

zktuong commented 8 months ago

hi sorry for the delay. ok looks like this is an issue with the documentation. does this behaviour still persist at the python version? in that it's not plotting despite degs_analysis=TRUE ?

zktuong commented 8 months ago

ok i found a bug specifically to do with degs_analysis specifically at

https://github.com/zktuong/ktplots/blob/b70d98bafeb5e202415f3c829ac22da94e97983a/R/plot_cpdb.R#L172-L174

it returns an empty table at the moment, which isn't correct. i will try and see what's going wrong

zktuong commented 8 months ago

it's likely because the new cellphonedb outputs don't have the same dimensions as it used to.

zktuong commented 8 months ago

hi @snow55, can you reinstall ktplots and see if the function works for you now? feel free to reopen if it still doesn't work.

snow55 commented 7 months ago

hi @snow55, can you reinstall ktplots and see if the function works for you now? feel free to reopen if it still doesn't work.↳

Sorry for late reply. I have reinstalled the ktplots and it works well now. Thank you very much!