saezlab / liana

LIANA: a LIgand-receptor ANalysis frAmework
https://saezlab.github.io/liana/
GNU General Public License v3.0
169 stars 30 forks source link

Custom Visualizations #105

Open RMOsborn012 opened 1 year ago

RMOsborn012 commented 1 year ago

First, I want to thank you all for making such a useful package and creating informative tutorials to use with other methods for cell-cell communication (NicheNet and Tensor cell2cell).

Unless I missed it, there isn't an option for changing the color scheme for many of the plot functions, and the default color scheme (ggplot2) is not colorblind-friendly.

I would like to change the colors to be consistent with other plots that I have created when analyzing my data (for presentations and manuscripts). I have already done this by changing the cell_anno parameter in the R/liana_plots.R source code, but the changes in R/liana_tensor.R took far longer than I care to admit. It would be great if there were an argument for defining custom color schemes in your plotting functions. I think this package is incredibly useful and look forward to any new updates.

dbdimitrov commented 1 year ago

Hi @RMOsborn012,

Most of liana's plots return ggplot/patchwork objects and these can be modified to other colours. Also, for ComplexHeatmap I allow kwargs to be passed so one can adjust the colour scheme.

Either way, I'm happy to change the pallettes in a subsequent update. Feel free to suggest a colour-blind palette (e.g. cividis?).

Hope this helps. Daniel

RMOsborn012 commented 1 year ago

@dbdimitrov I think the more complicated plots were giving me issues, and I couldn't directly change the colors and themes with typical ggplot2 commands. Specifically, the plot_c2c_overview and plot_context_boxplot functions.

For example, when using the plot_c2c_overview function, if I use standard ggplot2 functions to change the colors, it will only change colors in the last plot.

> tensor_colors Basal Cells Club Cells FOXJ1high Ciliated Cells FOXJ1low Ciliated Cells "#CCBB44" "#EE6677" "#228833" "#4477AA" Ionocytes Multiciliated Precursors CTRL SARS-CoV-2 "#AA3377" "#66CCEE" "#AA4499" "#999933" Adult Pediatric "#009988" "#BBBBBB"

> plot_c2c_overview(sce, group_col="age", sample_col="orig.ident") + scale_fill_manual(values = tensor_colors)

Resulting plot: Test c2c overview.pdf

Concerning the color palettes, Khroma is an excellent package for color palettes (https://packages.tesselle.org/khroma/).

From the github: "This R package provides an implementation of Okabe and Ito (2008), Tol (2021) and Crameri (2018) colour schemes. These schemes are ready for each type of data (qualitative, diverging or sequential), with colours that are distinct for all people, including colour-blind readers. "

dbdimitrov commented 1 year ago

Hi @RMOsborn012,

Yeah, I assume patchwork is making it too complicated. I will try to think how to enable palettes to be passed to the more complicated plots.

Thanks for the feedback!

Daniel