zktuong / ktplots

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

legend for plot_cpdb3 #55

Closed AvitalPo closed 1 year ago

AvitalPo commented 1 year ago

Hi, Thanks a lot for this excellent package!

How can I get or plot only the legend for the circus plot on cpdb3? If I have a lot of interactions, they are overlying the circus plot itself, and adjusting the position is not that good. I wanted to create the legend by myself, and I can understand which colors you use and the names of the interactions, but I'm not sure about their order (it is not just alphabetic or the order in the table).

Maybe you can add an option to get a list of plots when removing the legend, one with the circus and one with the legend (since it is plotted separately using ComplexHeatmaps anyway)?

Or do you have another idea for getting the interactions plotted in the right order?

Thanks! Avital

zktuong commented 1 year ago

hi @AvitalPo, thanks for your interest in this package.

so yes for now it only depends on ComplexHeatmaps like you said:

https://github.com/zktuong/ktplots/blob/9dd9d0b649915dee89001e26d149fdbe8643e240/R/plot_cpdb3.R#L334-L337

so the easiest way forward is to actually provide edge_color so you know what colors are for what.

The actual color step is :

edge_color <- .scPalette(length(unique(tmp_dfx$pair_swap)))

I'm just slightly concern whether there's some randomness from dataframe sorting of the pair_swap column everytime this is created. I think it's also a bit too complicated to simply extract it otherwise at the moment, but i suppose one can add either:

1) like you said, adding a plot_legend_only mode where TRUE/FALSE will return the only the legend. Just need to check if the random sorting affects this... 2) add return_tables mode where TRUE/FALSE will return the underlying dataframe used to construct the diagram, similar to how plot_cpdb currently works. -> i'm not really in favor of this as there's other moving parts that will complicate this.

I'm open to any suggestions though. If you feel like putting a PR to resolve this, i'm happy to review it.

AvitalPo commented 1 year ago

Hi, Thanks for the rapid answer. Maybe just order the interactions alphabetically? That way if one wants to get the interactions plotted by itself it is pretty easy.

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.