zktuong / ktplots

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

desiredInteractions shuffling node labels? #68

Closed zktuong closed 1 year ago

zktuong commented 1 year ago

Hmm seems like the issue here is related to the node names being shuffled.

Discussed in https://github.com/zktuong/ktplots/discussions/66

Originally posted by **XiaoyuLi-smu** March 19, 2023 ktplots version 1.2.3 When I ran the code in the vignette, I found a bug that really confused me. Here are the problems. The results of the following code had no problem with the color of edges, but the width of one of the edges was wrong (KLRB1 from CD4T cell to CLEC2D of B cell). library(ktplots) data(kidneyimmune) data(cpdb_output2) p <- plot_cpdb2(cell_type1 = 'B cell', cell_type2 = 'CD4T cell', scdata = kidneyimmune, idents = 'celltype', # column name where the cell ids are located in the metadata means = means2, pvals = pvals2, deconvoluted = decon2, # new options from here on specific to plot_cpdb2 desiredInteractions = list( c('CD4T cell', 'B cell'), c('B cell', 'CD4T cell')), interaction_grouping = interaction_annotation, edge_group_colors = c( "Activating" = "#e15759", "Chemotaxis" = "#59a14f", "Inhibitory" = "#4e79a7", "Intracellular trafficking" = "#9c755f", "DC_development" = "#B07aa1", "Unknown" = "#e7e7e7" ), node_group_colors = c( "CD4T cell" = "red", "B cell" = "blue"), keep_significant_only = TRUE, standard_scale = TRUE, remove_self = TRUE ) p duplicated As I thought that the imput for the parameter desiredInteractions (desiredInteractions = list(c('CD4T cell', 'B cell'), c('B cell', 'CD4T cell'))) was duplicted and changed it to desiredInteractions = list(c('B cell', 'CD4T cell')) or desiredInteractions = list( c(''CD4T cell', 'B cell')), the edge color in the result was wrong but the edge width was ok. For example the edge between CD22 and PTPRC should be blue (inhibitory). But the result was red (activating). It might be involved with the use of function geom_conn_bundle in the code of funciton plot_cpdb2. single Could anyone explain my questions? Thanks!
zktuong commented 1 year ago

oof. it's more complex than it looks.

Not quite sure what's the problem but the input data just before ggraph step looks correct at the moment

image

zktuong commented 1 year ago

@XiaoyuLi-smu

Sorry just keeping track of the issue here. At the moment i'm not sure what's going wrong when specifying only celltypeA->celltypeB as the input graph information looks correct. Perhaps you are right that something goes wrong in geom_conn_bundle.

It looks like specifying both directions is giving the correct results thouhg, so perhaps go with that ... or use plot_cpdb3 /4 going forward (the code is less messy for the other 2).

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

fentouxungui commented 7 months ago

I guess this issue is related to the ggraph package, what is the version of your ggraph package, Please try install the latest ggraph package (version 2.2.0) .