Skip to content

Make ST Blend Plot

simoncmo edited this page Sep 1, 2022 · 1 revision

Use STBlendPlot to make blending of 2 features expression plots from Spatial Transcriptomics Seurat object

Parameters

function STBlendPlot
- st = Spatial Transcriptomics Seurat Object
- feature_pairs = list of *pairs of features* to plot e.g. list(c('EGFR','EPCAM'), c('CD8A','CD4'))
- images=1: index or image name name to plot (Use 'Images(obj)' to check image names)
- show_histology=F : Show histology image
- show_blend_only = F : Show individual genes or just blended image
- wrap_slices = T : Output as a single patchwork plot or individual images
- flip_x_images, flip_y_images, # Name of the slice to flip image (Use 'Images(obj)' to check image names. 
-- e.g. flip_x_images = c('Slice1', 'Slice2')
- feature_colors =c("#ff0000", "#00ff00"): colors of 2 genes (try feature_colors =c("blue", "yellow") )
- negative_color = 'gray10': color of background (try negative_color = 'gray80')
- show_blend_legend =T : whether show the color legend for the blending 
- scale_x = 1, scale_y = 1: when the ggplot output not matching histology, try modify these 2 numbers to rescale the plot

Demo workflow

  • First load function in the folder
library(tidyverse)
library(Seurat)
function_folder_path = '/diskmnt/Datasets/Spatial_Transcriptomics/Analysis/Shared_resource/script_git/STPlot/'
list.files(full.names = T) %>% walk(function(path) source(path))
  • Load and process ST
st_path = '/diskmnt/Datasets/Spatial_Transcriptomics/outputs_FFPE/HT264P1/H2/HT264P1-S1H2Fs1U1Bp1/outs/'
st_seurat = Load10X_Spatial(st_path)
st_seurat = SCTransform(st_seurat, assay = 'Spatial')
  • Blend Plot
STBlendPlot(st_seurat, feature_pairs = list(c('EPCAM','KRTCAP2')), assay = 'Spatial', wrap_slices = T, pt.size.factor = 1.9, show_blend_only = T) | 
STBlendPlot(st_seurat, feature_pairs = list(c('EPCAM','KRTCAP2')), assay = 'SCT', wrap_slices = T, pt.size.factor = 1.9, show_blend_only = T)

image

  • Add histology
STBlendPlot(st_seurat, feature_pairs = list(c('EPCAM','KRTCAP2')), assay = 'Spatial', pt.size.factor = 1.4, show_blend_only = T, show_histology=T) | 
STBlendPlot(st_seurat, feature_pairs = list(c('EPCAM','KRTCAP2')), assay = 'SCT',pt.size.factor = 1.4, show_blend_only = T, show_histology=T)

image

Rescale

# Left original, Right rescaled on y

STBlendPlot(st_seurat, feature_pairs = list(c('EPCAM','KRTCAP2')), assay = 'Spatial', pt.size.factor = 2.8, show_blend_only = T, show_histology=T, show_blend_legend = F,
               flip_y_images = 'slice1', scale_y = 1, feature_colors =c("blue", "yellow"), negative_color = 'gray80') |
STBlendPlot(st_seurat, feature_pairs = list(c('EPCAM','KRTCAP2')), assay = 'Spatial', pt.size.factor = 2.8, show_blend_only = T, show_histology=T, show_blend_legend = F,
               flip_y_images = 'slice1', scale_y = 0.85, feature_colors =c("blue", "yellow"), negative_color = 'gray80')

image