zktuong / ktplots

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

split.by parameter in plot_cpdb #73

Closed zzzsssyyy1995 closed 1 year ago

zzzsssyyy1995 commented 1 year ago
# pvals <- read.delim("pvalues.txt", check.names = FALSE)
# means <- read.delim("means.txt", check.names = FALSE)

# I've provided an example dataset
data(cpdb_output)
plot_cpdb(cell_type1 = 'B cell', cell_type2 = 'CD4T cell', scdata = kidneyimmune,
    idents = 'celltype', # column name where the cell ids are located in the metadata
    #split.by = 'Experiment', # column name where the grouping column is. Optional.
    means = means, pvals = pvals,
    genes = c("XCR1", "CXCL10", "CCL5")) +
small_axis(fontsize = 3) + small_grid() + small_guide() + small_legend(fontsize = 2) # some helper functions included in ktplots to help with the plotting

When I comment out the optional split.by parameter, it throws an error

Error in plot_cpdb(cell_type1 = "B cell", cell_type2 = "CD4T cell", scdata = kidneyimmune,  : 
  Please check your options for split.by and your celltypes.
zktuong commented 1 year ago

hi @zzzsssyyy1995, that's by design.

> head(colnames(means), 20)
 [1] "id_cp_interaction"                   "interacting_pair"                   
 [3] "partner_a"                           "partner_b"                          
 [5] "gene_a"                              "gene_b"                             
 [7] "secreted"                            "receptor_a"                         
 [9] "receptor_b"                          "annotation_strategy"                
[11] "is_integrin"                         "PapRCC_MNPb(mono)|PapRCC_MNPb(mono)"
[13] "PapRCC_MNPb(mono)|PapRCC_NK cell"    "PapRCC_MNPb(mono)|RCC1_CD4T cell"   
[15] "PapRCC_MNPb(mono)|RCC1_CD8T cell"    "PapRCC_MNPb(mono)|RCC1_MNPa(mono)"  
[17] "PapRCC_MNPb(mono)|RCC1_MNPb(mono)"   "PapRCC_MNPb(mono)|RCC1_MNPc(DC)"    
[19] "PapRCC_MNPb(mono)|RCC1_MNPd(Mac)"    "PapRCC_MNPb(mono)|RCC1_Mast cell" 

it should work if you use means2 and pvals2:

> head(colnames(means2), 20)
 [1] "id_cp_interaction"   "interacting_pair"    "partner_a"          
 [4] "partner_b"           "gene_a"              "gene_b"             
 [7] "secreted"            "receptor_a"          "receptor_b"         
[10] "annotation_strategy" "is_integrin"         "B cell|B cell"      
[13] "B cell|CD4T cell"    "B cell|CD8T cell"    "B cell|MNPa(mono)"  
[16] "B cell|MNPb(mono)"   "B cell|MNPc(DC)"     "B cell|MNPd(Mac)"   
[19] "B cell|Mast cell"    "B cell|NK cell" 
zzzsssyyy1995 commented 1 year ago

@zktuong Thank you, that solved my confusion.