Introduction
library(ggplot2)
library(vctrs)
library(patchwork,lib.loc = "/apps/rocs/2020.08/cascadelake/software/R/4.1.2-foss-2020a/lib64/R/library")
library(Seurat)
library(dplyr)
library(tidyr)
library(readr)
library(stringr)
library(progeny)
library(SingleCellExperiment)
library(BayesSpace)
source(file = "WrapperFunction/SeuratWrappers.R")
data_directory <-
params$data_directory
analysis_name <-
params$analysis_name
# setwd(paste0(data_directory, analysis_name))
input_folder <- "IntermediaryFiles/"
sample <- "SN048_A121573_Rep1"
list_results <- readRDS(paste0(data_directory, analysis_name, input_folder,
"BayesSpaceResults/Pathology_Tumor_Annotations/", sample , ".rds"))
sce_subset <- list_results[[2]]
sce_subset.enhanced <-list_results[[1]]
## There are actually only 3 clusters due to the non matched neighbors.
sce_subset$spatial.cluster[sce_subset$spatial.cluster == 4] <-1
## We convert to a Seurat object
seurat_obj.enhanced <- Seurat::CreateSeuratObject(
counts=SingleCellExperiment::logcounts(sce_subset.enhanced),
assay='Spatial',meta.data=as.data.frame(colData(sce_subset.enhanced)))
seurat_obj.enhanced <- Seurat::SetIdent(seurat_obj.enhanced, value = "spatial.cluster")
seurat_obj.enhanced@assays$Spatial@scale.data <-
seurat_obj.enhanced@assays$Spatial@data %>% as.matrix %>% t %>% scale %>% t
seurat_obj.enhanced <-
progeny(seurat_obj.enhanced, assay_name = "Spatial", top = 500, return_assay = TRUE, scale = FALSE)
DefaultAssay(seurat_obj.enhanced) <- "progeny"
sce_obj <- as.SingleCellExperiment(seurat_obj.enhanced, assay = "progeny")
Results:
Pathway activity at the subspot resolution
all_pathways <- rownames(seurat_obj.enhanced)
for ( current_pathway in all_pathways){
cat( "## Pathway: ", current_pathway , "\n\n")
feature_plot <-
featurePlot(sce_obj, feature=current_pathway, diverging = TRUE,
platform = "Visium",is.enhanced = TRUE, color = NA)
print(feature_plot)
cat( "\n\n")
violin_plots <- Seurat::VlnPlot(object = seurat_obj.enhanced,
features = current_pathway ,group.by = "spatial.cluster")
print(violin_plots)
cat( "\n\n")
}
Pathway:
Androgen


Pathway: EGFR


Pathway:
Estrogen


Pathway: Hypoxia


Pathway:
JAK-STAT


Pathway: MAPK

