JEFworks-Lab / STdeconvolve

Reference-free cell-type deconvolution of multi-cellular spatially resolved transcriptomics data
http://jef.works/STdeconvolve/
112 stars 13 forks source link

How to add cell types to deconvoluted 10x Visium data? #57

Open 532at opened 5 months ago

532at commented 5 months ago

Hi,

I went through the whole tutorial (https://github.com/JEFworks-Lab/STdeconvolve/blob/devel/docs/visium_10x.md) with my data. Was wondering how to add these pixel groups of certain cell types as below:

Zrzut ekranu 2024-06-5 o 13 42 00

This part is not covered in the tutorial, but is I think the most important for the results.

Best, Adrian

bmill3r commented 5 months ago

Hi @532at,

If I understand correctly, you would like to better visualize which pixels belong the 5 different cell type groups? Actually, these are already visualized in the plot. The groups color the boundaries/lines of the scatter pies, whereas the topic colors fill the scatter pies. The plotting function is essentially a wrapper around ggplot2. You can add another layer to the plot to change the sizes of the scatter pie lines if they are too small for your liking.

Hope this helps, Brendan

532at commented 5 months ago

Hi @bmill3r,

not really, I put this image as an example what I would like to have after following your tutorial for Visium 10x Genomics (https://github.com/JEFworks-Lab/STdeconvolve/blob/devel/docs/visium_10x.md). If you click this link you will see that it creates different figure (below), without cell type groups. My question is how I can add these cell types groups to that pipeline.

Zrzut ekranu 2024-06-10 o 09 28 01

Thanks, Adrian

bmill3r commented 5 months ago

Hi @532at ,

If you look at the code chunk to generate that figure about:

plt <- vizAllTopics(theta = deconProp,
                   pos = pos,
                   r = 45,
                   lwd = 0,
                   showLegend = TRUE,
                   plotTitle = NA) +
  ggplot2::guides(fill=ggplot2::guide_legend(ncol=2)) +

  ## outer border
  ggplot2::geom_rect(data = data.frame(pos),
            ggplot2::aes(xmin = min(x)-90, xmax = max(x)+90,
                         ymin = min(y)-90, ymax = max(y)+90),
            fill = NA, color = "black", linetype = "solid", size = 0.5) +

  ggplot2::theme(
    plot.background = ggplot2::element_blank()
  ) +

  ## remove the pixel "groups", which is the color aesthetic for the pixel borders
  ggplot2::guides(colour = "none")

you'll see the last line:

 ## remove the pixel "groups", which is the color aesthetic for the pixel borders
  ggplot2::guides(colour = "none")

This is added on in this particular tutorial to remove the cell type groups. Just run the code but do not use this line and vizAllTopics should plot both the Topics and cell type Groups.

Hope this helps, Brendan