YMa-lab / CARD

GNU General Public License v3.0
81 stars 20 forks source link

Visualization of two cell types together #25

Closed nsauerwald closed 1 year ago

nsauerwald commented 1 year ago

Hi, thank you so much for this package, I found it very easy to use! This is not an issue but a suggestion - I was wondering if you have a way to visualize the distributions of two cell types on the same plot. Essentially I would love a function like visualize.prop() that takes in 2 cell types and shows the co-localization (or lack of) between the two on the tissue slice. I know we can see the correlation value from the visualize.Cor() function, but I'd like to be able to see the spatial relationship directly. Thanks again for your work on this!

YingMa0107 commented 1 year ago

Hi @nsauerwald,

Sorry about the late reply. First, thank you very much for your interest in our package, and also thank you so much for your wonderful suggestion. I like this idea!

So, I try my best to follow your suggestion to create a function 'CARD.visualize.prop.2CT' to visualize the two cell types on the same plot. The code scripts are stored in the R/visualization.R function. Specifically, I use two different symbols (circle and square) to represent two cell types. The usage of this function is:

#### using the PDAC data in the tutorial as an example, after CARD deconvolution
p = CARD.visualize.prop.2CT(
proportion = CARD_obj@Proportion_CARD,                             ### Cell type proportion estimated by CARD
spatial_location = CARD_obj@spatial_location,                      ### spatial location information
ct2.visualize = c("Cancer_clone_A","Cancer_clone_B"),              ### two cell types you want to visualize
colors = list(c("lightblue","lightyellow","red"),c("lightblue","lightyellow","black")))       ### two color scales                             
print(p)

Here is the output of the figure which plots the distribution of two cell types in one plot. As showing in the figure, the darker the square points are, the higher proportion of cell type B is, while the more red of the circle points are, the higher proportion of the cell type A is. And you can choose your own color scales to represent these two cell types.

Does this make sense to you? Please feel free to share your thoughts or suggestions on this.

Example_analysis_visualizeProp_2CT

Best, Ying

nsauerwald commented 1 year ago

I forgot to thank you for this by the way! It works really nicely, I appreciate the addition!

YingMa0107 commented 1 year ago

Hi @nsauerwald,

Thank you for your kind feedback! I'm glad to hear that the newly added visualization code works well in your case. I will also add this to the GitHub tutorial. Happy to help if you have any further questions.

Best, Ying