Seurat空间转录组分析流程

Load 10X visium data

1
2
3
4
5
6
7
8
9
10
11
12
library(Seurat)
library(ggplot2)
library(patchwork)
# dataDir contains spatial dir and filtered_feature_bc_matrix.h5
# Space Ranger v2.0.1 produced files must process as follow otherwise it doesn't work:
# mv tissue_positions.csv tissue_positions_list.csv
# sed -i '1d' tissue_positions_list.csv
obj <- Load10X_Spatial(data.dir = "/opt/data/out",
filename = "filtered_feature_bc_matrix.h5",
assay = "Spatial",
slice = "slice1",
filter.matrix = TRUE)

Normalization

1
obj <- SCTransform(obj, assay = "Spatial", verbose = FALSE)

Reduction and cluster

1
2
3
4
5
6
7
8
9
obj <- RunPCA(obj, assay = "SCT", verbose = FALSE)
obj <- FindNeighbors(obj, reduction = "pca", dims = 1:30)
obj <- FindClusters(obj, verbose = FALSE)
obj <- RunUMAP(obj, reduction = "pca", dims = 1:30)

p1 <- DimPlot(obj, reduction = "umap", label = TRUE)
p2 <- SpatialDimPlot(obj, label = TRUE, label.size = 1)
p <- wrap_plots(p1, p2)
ggsave("cluster.pdf", p)

Identification of spatially variable features

1
2
3
4
obj <- FindSpatiallyVariableFeatures(obj, assay = "SCT", selection.method = "markvariogram", features = VariableFeatures(obj)[1:1000])
top.features <- head(SpatiallyVariableFeatures(obj, selection.method = "markvariogram"), 6)
p <- SpatialFeaturePlot(obj, features = top.features, ncol = 3, alpha = c(0.1, 1))
ggsave("features.pdf", p)

Reference:
Seurat

Author: Giftbear
Link: https://giftbear.github.io/2023/05/31/Seurat空间转录组分析流程/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.