Plot Arrangement of Cell2Location results
We first load the libraries and set the paths to the raw data.
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(readr)
library(stringr)
library(RColorBrewer)
library(cowplot)
data_directory <- params$data_directory
analysis_name <- params$analysis_name
input_folder_seurat <- "ST_LiverMetastases_pub/IntermediaryFiles/"
input_names_seurat <- "SeuratList_Clusters_Res05.rds"
files_to_read_seurat <-
paste0(data_directory, analysis_name,input_folder_seurat,input_names_seurat)
input_folder_C2L <-
"Cell2Location/results/LocationModelLinearDependentWMultiExperiment_8experiments_36clusters_31296locations_4188genesLiverMetastasis/"
input_file_C2L <- "W_cell_density_q05.csv"
files_to_read_C2L <-
paste0(data_directory, analysis_name,input_folder_C2L,input_file_C2L)
We load Seurat objects
seurat_objects <- readRDS(files_to_read_seurat)
We Load Cell2Location results
results_STLiver_Korean <- read_csv(files_to_read_C2L)
colnames(results_STLiver_Korean) <-
str_replace(colnames(results_STLiver_Korean),
pattern = "q05_spot_factors", replacement = "")
results_STLiver_Korean <- results_STLiver_Korean %>%
dplyr::mutate(sample = str_extract(.$spot_id, pattern =".*_")) %>%
dplyr::mutate(sample = str_remove(.$sample, pattern = "_")) %>%
dplyr::mutate(spot_id = str_remove(.$spot_id, pattern =".*_"))
current_sample <- "ST-colon1"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STcolon1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STcolon1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STcolon1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STcolon1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STcolon1 + plot_CMS2_STcolon1 +
plot_CMS3_STcolon1 + plot_CMS4_STcolon1
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
plot_CMS1_STcolon1
current_sample <- "ST-colon2"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STcolon2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STcolon2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STcolon2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STcolon2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STcolon2 + plot_CMS2_STcolon2 +
plot_CMS3_STcolon2 + plot_CMS4_STcolon2
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_sample <- "ST-colon3"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STcolon3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STcolon3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STcolon3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STcolon3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STcolon3 + plot_CMS2_STcolon3 +
plot_CMS3_STcolon3 + plot_CMS4_STcolon3
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_sample <- "ST-colon4"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STcolon4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STcolon4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STcolon4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STcolon4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STcolon4 + plot_CMS2_STcolon4 +
plot_CMS3_STcolon4 + plot_CMS4_STcolon4
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_sample <- "ST-liver1"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STliver1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STliver1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STliver1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STliver1 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STliver1 + plot_CMS2_STliver1 +
plot_CMS3_STliver1 + plot_CMS4_STliver1
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_sample <- "ST-liver2"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STliver2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STliver2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STliver2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STliver2 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STliver2 + plot_CMS2_STliver2 +
plot_CMS3_STliver2 + plot_CMS4_STliver2
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_sample <- "ST-liver3"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STliver3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STliver3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STliver3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STliver3 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STliver3 + plot_CMS2_STliver3 +
plot_CMS3_STliver3 + plot_CMS4_STliver3
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_sample <- "ST-liver4"
seurat <- seurat_objects[[current_sample]]
results_C2L_sample <- results_STLiver_Korean %>%
dplyr::filter(sample == current_sample)
seurat@meta.data <-
seurat@meta.data %>%
tibble::rownames_to_column("spot_id") %>%
dplyr::left_join(results_C2L_sample, by = "spot_id") %>%
tibble::column_to_rownames("spot_id")
current_cell_type <- "CMS1"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS1_STliver4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS2"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS2_STliver4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS3"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS3_STliver4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
current_cell_type <- "CMS4"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_CMS4_STliver4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_CMS1_STliver4 + plot_CMS2_STliver4 +
plot_CMS3_STliver4 + plot_CMS4_STliver4
plot_layout(widths = c(1,1), heights = c(1,1), ncol = 2, nrow = 2)
## $ncol
## [1] 2
##
## $nrow
## [1] 2
##
## $byrow
## NULL
##
## $widths
## [1] 1 1
##
## $heights
## [1] 1 1
##
## $guides
## NULL
##
## $tag_level
## NULL
##
## $design
## NULL
##
## attr(,"class")
## [1] "plot_layout"
current_cell_type <- "SPP1+"
breaks_vec <-
round(seq(0, max(pull(seurat@meta.data,current_cell_type)), length.out= 5),1)
plot_SPP1_STliver4 <-
Seurat::SpatialFeaturePlot(
object = seurat,
features = c(current_cell_type), alpha = c(0,1),
image.alpha = 0.6, pt.size.factor = 2, stroke = 1) +
ggtitle(current_cell_type) +
scale_fill_gradient2(high = "#67000D", mid = "#FC9272", low = "white",
breaks=breaks_vec,name=NULL ) +
theme(legend.position="right", legend.key.height = unit(0.75, 'cm'),
legend.text = element_text(size=10, face="bold"),
legend.title = element_text(NULL),
plot.title = element_text(face = "bold", size= 14, hjust = 0.5)) +
theme(plot.margin = unit(c(0, 0, 0, 0), "cm"))
plot_SPP1_STliver4
## R version 4.1.2 (2021-11-01)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Fedora 33 (Container Image)
##
## Matrix products: default
## BLAS/LAPACK: /apps/rocs/2020.08/cascadelake/software/OpenBLAS/0.3.9-GCC-9.3.0/lib/libopenblas_skylakexp-r0.3.9.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] cowplot_1.1.1 RColorBrewer_1.1-3 stringr_1.4.0
## [4] readr_2.1.2 dplyr_1.0.9 sp_1.5-0
## [7] SeuratObject_4.1.0 Seurat_4.1.0 patchwork_1.1.1
## [10] vctrs_0.4.1 ggplot2_3.3.6 BiocManager_1.30.18
##
## loaded via a namespace (and not attached):
## [1] Rtsne_0.16 colorspace_2.1-0 deldir_1.0-6
## [4] ellipsis_0.3.2 ggridges_0.5.3 rstudioapi_0.13
## [7] spatstat.data_2.2-0 farver_2.1.0 leiden_0.4.2
## [10] listenv_0.8.0 bit64_4.0.5 ggrepel_0.9.1
## [13] fansi_1.0.3 codetools_0.2-18 splines_4.1.2
## [16] knitr_1.39 polyclip_1.10-0 jsonlite_1.8.0
## [19] ica_1.0-2 cluster_2.1.3 png_0.1-7
## [22] rgeos_0.5-10 uwot_0.1.11 shiny_1.7.1
## [25] sctransform_0.3.3 spatstat.sparse_2.1-1 compiler_4.1.2
## [28] httr_1.4.3 assertthat_0.2.1 Matrix_1.4-2
## [31] fastmap_1.1.0 lazyeval_0.2.2 cli_3.3.0
## [34] later_1.3.0 htmltools_0.5.2 tools_4.1.2
## [37] igraph_1.3.2 gtable_0.3.0 glue_1.6.2
## [40] RANN_2.6.1 reshape2_1.4.4 Rcpp_1.0.8.3
## [43] scattermore_0.8 jquerylib_0.1.4 nlme_3.1-158
## [46] progressr_0.10.1 lmtest_0.9-40 spatstat.random_2.2-0
## [49] xfun_0.31 globals_0.15.0 mime_0.12
## [52] miniUI_0.1.1.1 lifecycle_1.0.1 irlba_2.3.5
## [55] goftest_1.2-3 future_1.26.1 MASS_7.3-57
## [58] zoo_1.8-10 scales_1.2.0 vroom_1.5.7
## [61] spatstat.core_2.4-4 hms_1.1.1 promises_1.2.0.1
## [64] spatstat.utils_2.3-1 parallel_4.1.2 yaml_2.3.5
## [67] reticulate_1.25 pbapply_1.5-0 gridExtra_2.3
## [70] sass_0.4.1 rpart_4.1.16 stringi_1.7.6
## [73] highr_0.9 rlang_1.0.2 pkgconfig_2.0.3
## [76] matrixStats_0.62.0 evaluate_0.15 lattice_0.20-45
## [79] tensor_1.5 ROCR_1.0-11 purrr_0.3.4
## [82] labeling_0.4.2 htmlwidgets_1.5.4 bit_4.0.4
## [85] tidyselect_1.1.2 parallelly_1.32.0 RcppAnnoy_0.0.19
## [88] plyr_1.8.7 magrittr_2.0.3 R6_2.5.1
## [91] generics_0.1.2 DBI_1.1.3 mgcv_1.8-40
## [94] pillar_1.7.0 withr_2.5.0 fitdistrplus_1.1-8
## [97] survival_3.3-1 abind_1.4-7 tibble_3.1.7
## [100] future.apply_1.9.0 crayon_1.5.1 KernSmooth_2.23-20
## [103] utf8_1.2.2 spatstat.geom_2.4-0 plotly_4.10.0
## [106] tzdb_0.3.0 rmarkdown_2.14 grid_4.1.2
## [109] data.table_1.14.2 digest_0.6.29 xtable_1.8-6
## [112] tidyr_1.2.0 httpuv_1.6.5 munsell_0.5.0
## [115] viridisLite_0.4.0 bslib_0.3.1