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

Ordering interactions on liana_dotplot #72

Closed clb94 closed 1 year ago

clb94 commented 1 year ago

Hi there,

Thanks so much for your work on the liana package, it has been a great help to me. I have a question about the liana_dotplot function which I hope will be quick and easy to answer!

Having worked through the tutorial you kindly provided (https://saezlab.github.io/liana/articles/liana_tutorial.html#citation), I prepared a dotplot from my own scRNAseq data using the liana_dotplot function. I did this after filtering the liana_aggregate output for ligand complexes of interest - I just wanted to compare these interactions with each other.

On the tutorial page, it states: "By default, liana_aggregate would order LIANA’s output according to rankaggregate in ascending order." I am assuming here that rank_aggregate is the same as aggregate_rank, which I also note you suggest as a proxy for p-value.

However, on my dotplot I have noticed that the interaction with the lowest aggregate_rank, which I understand should be interpreted as that with the lowest and most significant p-value, is appearing below other interactions with a higher aggregate_rank. I do think however that those shown are the top 25 most significant interactions, as specified, just not listed in order on the figure.

Please could someone confirm what the default ordering system is for the Y-axis of interactions on the liana_dotplot? I also don't think it is the natmi specificity score as the interaction in question also has the highest specificity. Alternatively, if someone could let me know how to reorder these top interactions in ascending aggregate_rank I would really appreciate it!

Thanks a lot, Christina

dbdimitrov commented 1 year ago

Hi Christina,

The plot should indeed be with the top 25 interactions (as ordered in the liana results dataframe that you are passing). What likely happens then is that ggplot attempts to re-order those 25 interactions to e.g. alphabetical order.

I will add a couple of parameters to the dotplot function in next update to make this more explicit and will have a look if I can make it so that they keep their order as in the dataframe passed.

Daniel

enblacar commented 1 year ago

Hi @dbdimitrov,

I can confirm that it is due to the fact that ggplot2 sets the levels of the factors automatically. Once you set them manually to follow the unique values of the interacting pair after subsetting by top_interactions, the resulting plot follows the order of the input matrix.

I will also update SCpubr accordingly. Very nice point the one brought up in this issue!

Best, Enrique

dbdimitrov commented 1 year ago

Hi @clb94,

I have now updated liana, and interactions will be ordered as in the dataframe that is passed to liana's dotplot.

Best, Daniel