JEFworks-Lab / STdeconvolve

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

STdeconvolve on multiple sections at the same time #20

Closed JoyOtten closed 2 years ago

JoyOtten commented 2 years ago

Dear Team,

Thank you for your amazing package!

I wanted to ask you if it's possible to run STdeconvolve on multiple sections at the same time (I have done this by following the instructions from breast cancer sections. I have in total 16 similar sections obtained from 10x Visium that I put through. However, I'm trying to plot the topics on the ST data by the following code:

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")

However, this results into 1 plot for all 16 samples. Is there a possibility to plot all 16 samples separately?

With kind regards, Joy Otten

JoyOtten commented 2 years ago

I already have it, sorry for the comment.

My solution is as follows: Whereas c selects the samples

pdf("/PHShome/je637/deconvolution_plot.pdf") for(c in sample_name){ x <- grep(c, rownames(deconProp)) test <- deconProp[x,] x <- grep(c, rownames(pos)) test_1 <- pos[x,]

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

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()
) +

ggplot2::guides(colour = "none")

plot(plt) } dev.off()