saezlab / liana

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

How to customise the X-axis order in heat_freq and color in chord_freq #151

Open mainharryHR opened 2 months ago

mainharryHR commented 2 months ago

Dear Liana team and users, Thanks for great package for being easy to use. After subsetting the data based on the conditions, I want to plot the heatmap with desired order of X-axis by using this code : TcellNotrunc <- TcellNoAggregate %>% filter(aggregate_rank <= 0.01) TcellNotrunc$target <- factor(TcellNotrunc$target, levels = desired_order_of_categories) heat_freq(TcellNotrunc)

But it is not working. Any suggestions to customised the order of heatmap?

In chord_freq, it seems the colors are assigned differently between three conditions. How should we customise the color?

Many thanks Harry

dbdimitrov commented 2 months ago

Hi @mainharryHR,

Thanks for using it :)

Not 100% sure what your data looks like - is it a filtered dataframe to only one cell type? I assume there might be an issue if you have only one cell type?

Daniel

mainharryHR commented 2 months ago

Hi @mainharryHR,

Thanks for using it :)

Not 100% sure what your data looks like - is it a filtered dataframe to only one cell type? I assume there might be an issue if you have only one cell type?

Daniel

Thank you for the reply. I have many cells types. How should I define the order of cell types on X-axix for heatmap? Cause I am not happy with the current order. Thanks.

Screenshot 2024-05-21 at 12 18 48
dbdimitrov commented 2 months ago

Ahhh, I see. I believe ComplexHeatmap (what I use in the background) shoud allow you to order according to the categories (levels) of your cell types.

This might require that I change the function a bit - I can do that, but it will likely take me some time to get back to it.

Otherwise you could modify the function such that: https://github.com/saezlab/liana/blob/4c323df7f0c24be4401cf6ec7d772eaa34b483b1/R/liana_plot.R#L267

you pass, labels (the preferred order of your cell types) to rowAnnotation and columnAnnotation, according to this issue: https://github.com/jokergoo/ComplexHeatmap/issues/296

mainharryHR commented 2 months ago

Ahhh, I see. I believe ComplexHeatmap (what I use in the background) shoud allow you to order according to the categories (levels) of your cell types.

This might require that I change the function a bit - I can do that, but it will likely take me some time to get back to it.

Otherwise you could modify the function such that:

https://github.com/saezlab/liana/blob/4c323df7f0c24be4401cf6ec7d772eaa34b483b1/R/liana_plot.R#L267

you pass, labels (the preferred order of your cell types) to rowAnnotation and columnAnnotation, according to this issue: jokergoo/ComplexHeatmap#296

Great. Thank you for the advance. It seems several people have same issues. It might be good if you adjust the argument with this function (order of axis), it will be great. I am new for R, I am not very sure I can modify the function. :)

Have great day for the great package.

Best, Harry

mainharryHR commented 2 months ago

Dear Team, I have been struggling again for the order. I am still not able to figure it out. Could someone to modify the following code? Many thanks. `desired_order_of_categories <- c( "B naïve", "B Memory", "IgG", "IgA1", "IgA2","IgA3" )

BcellsCRCtrunc$target <- factor(BcellsCRCtrunc$target, levels = c("desired_order_of_categories"))

BcellsControltrunc <- BcellsControlAggregate %>%

filter(aggregate_rank <= 0.01) # note that these pvals are already corrected

heat_freq(BcellsControltrunc)`