Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change order of sender and receiver cell types in frequency Heatmap #126

Open
reneemoerkens opened this issue Sep 28, 2023 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@reneemoerkens
Copy link

reneemoerkens commented Sep 28, 2023

Hello,

Thanks for this very user-friendly package!
I was generating frequency Heatmaps using the heat_freq() function and I noticed that the sender and receiver cell types are ordered alphabetically along the x- and y-axis.
Is there a way to manually change the order in which these cell types are displayed along the axis in the Heatmap?

And one other question: is there a method to link the ligand/receptor genes in the liana_wrap() output file to a pathway (e.g. WNT/BMP/NOTCH)? I have seen something like that in this tutorial: https://saezlab.github.io/liana/articles/liana_intracell.html, using SignalLink and OmniPath. Can this also be done with the other resources, such as CellPhoneDB? Or just in general with the ligand and receptor genes in the liana_wrap() output dataframe?

Thanks!

@dbdimitrov dbdimitrov added the enhancement New feature or request label Sep 29, 2023
@dbdimitrov
Copy link
Collaborator

Hi @reneemoerkens,

Regarding the frequency heatmap, perhaps if the columns with cell types are categorical then the categories order would be kept - I haven't tried it, but might be worth a shot. I can try to find some time soon for this and other plot-related improvements.

Re enrichment: maybe have a look at this part of our more extensive tutorial with Tensor-cell2cell here: https://ccc-protocols.readthedocs.io/en/latest/notebooks/ccc_R/QuickStart.html#Pathway-Enrichment-Analysis:-Interpreting-the-context-driven-communication
Ultimately, an enrichment analysis can be performed also with any of the scores in liana, not just the factor loadings from tensor.

@reneemoerkens
Copy link
Author

Hey @dbdimitrov,

Thanks for the suggestions.
I changed the order of cell types and made the column categorical and that worked! I can now manually change the order in which the sender and receiver cell types are displayed in the Heatmap :).

I also found a way to do the pathway annotation, by using CellChatDB from the cellchat package that includes pathway annotation for ligand and receptor genes. Also indeed pathway enrichment worked using KEGG or other methods.

One other question: When using heat_freq() for data that does not include the same sender and receiver cells an error arises. For some pathways that I would like to plot, the receiver cells are not always also sender cells which causes a different number of receiver and sender cell types and this error:

Error: number of observations in bottom annotation should be as same as ncol of the matrix.

My workaround so far was to manually add a row to my liana output dataframe that includes the missing celltypes. But this is not really desirable as this will be counted as 1 observation for that cell type in the final plot, which should actually be zero.

Is there a way to include these 'missing celltypes' as receiver or sender cell in the heatmap, without having to add them manually as one observed interaction?

@dbdimitrov
Copy link
Collaborator

dbdimitrov commented Oct 6, 2023

Hi @reneemoerkens,

If you could copy your code for the latter comment, I could see what you meant and try to implement it in a subsequent version. :)

Glad to hear that encoding as factor and enrichment worked out.

@ejscience
Copy link

Hey @dbdimitrov,

Thanks for the suggestions. I changed the order of cell types and made the column categorical and that worked! I can now manually change the order in which the sender and receiver cell types are displayed in the Heatmap :).

I also found a way to do the pathway annotation, by using CellChatDB from the cellchat package that includes pathway annotation for ligand and receptor genes. Also indeed pathway enrichment worked using KEGG or other methods.

One other question: When using heat_freq() for data that does not include the same sender and receiver cells an error arises. For some pathways that I would like to plot, the receiver cells are not always also sender cells which causes a different number of receiver and sender cell types and this error:

Error: number of observations in bottom annotation should be as same as ncol of the matrix.

My workaround so far was to manually add a row to my liana output dataframe that includes the missing celltypes. But this is not really desirable as this will be counted as 1 observation for that cell type in the final plot, which should actually be zero.

Is there a way to include these 'missing celltypes' as receiver or sender cell in the heatmap, without having to add them manually as one observed interaction?

Hi @reneemoerkens, would you be able to share your code in which you use the CellChatDB to add pathways to the data from LIANA?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants