Entering edit mode
2.7 years ago
Omics data mining
▴
260
Hello everyone
I am working on spatial transcriptome 10X visum. In order to check the variance across biological replicates, I used followed steps :
1) Read data1 and remove the mitochondrial percentage in object meta data
library(Seurat)
library(SeuratData)
library(ggplot2)
library(patchwork)
library(dplyr)
data.dir <- "/home/outs"
data1 <- Load10X_Spatial(
data.dir,
filename = "filtered_feature_bc_matrix.h5",
assay = "Spatial",
slice = "C1",
filter.matrix = TRUE,
to.upper = FALSE,
image = NULL,
)
# store mitochondrial percentage in object meta data
ss <- PercentageFeatureSet(data1, pattern = "^MT-", col.name = "percent.mt")
ss = ss[, ss$nFeature_Spatial > 200 & ss$percent.mt < 25]
ss <- SCTransform(ss, assay = "Spatial", verbose = FALSE)
ss <- RunPCA(ss, assay = "SCT", verbose = FALSE)
as_tibble(HVFInfo(ss),rownames = "Gene") -> variance.data
2) extract the variance in data1
variance.data %>% mutate(hypervariable=Gene %in% VariableFeatures(ss)) -> variance.data
############################### data2 #################################
3) Read data2 and remove the mitochondrial percentage in object meta data
library(Seurat)
library(SeuratData)
library(ggplot2)
library(patchwork)
library(dplyr)
data.dir2 <- "/home/outs2"
data2 <- Load10X_Spatial(
data.dir2,
filename = "filtered_feature_bc_matrix.h5",
assay = "Spatial",
slice = "D1",
filter.matrix = TRUE,
to.upper = FALSE,
image = NULL,
)
# store mitochondrial percentage in object meta data
ss2 <- PercentageFeatureSet(data2, pattern = "^MT-", col.name = "percent.mt")
ss2 = ss2[, ss$nFeature_Spatial > 200 & ss$percent.mt < 25]
ss2 <- SCTransform(ss2, assay = "Spatial", verbose = FALSE)
ss2 <- RunPCA(ss2, assay = "SCT", verbose = FALSE)
4) extract the variance in data2
as_tibble(HVFInfo(ss2),rownames = "Gene") -> variance.data2
variance.data2 %>% mutate(hypervariable=Gene %in% VariableFeatures(ss2)) -> variance.data2
############# plot #############################################
5) visualization of the variance in each seurat object
variance.data2$group <- rep("D1", nrow(variance.data2))
variance.data$group <- rep("C1", nrow(variance.data))
dataf <- rbind(variance.data , variance.data2)
enter code here
dataf$group <- as.factor(dataf$group)
p <- ggplot(dataf, aes(x=group, y=residual_variance, color=group, shape=group)) +
geom_jitter(position=position_jitter(0.2))+
labs(title="Plot of residual_varianc by group",x="group", y = "residual_variance")
p+scale_color_brewer(palette="Dark2")
I would like to be sure for the steps that I have followed for the comparison of variance across the samples. I would appreciate all the suggestions.