本系列讲解 空间转录组学 (Spatial Transcriptomics) 相关基础知识与数据分析教程[1],持续更新,欢迎关注,转发,文末有交流群!
本文分析一个 10x Genomics Visium
数据集,该数据集包含一个样本(Visium 捕获区域),取自人类背外侧前额叶皮层(DLPFC)区域的死后脑组织。
原始完整数据集总共包含 12 个样本,来自 3 名供体,每名供体有 2 对空间相邻的重复(连续切片)(每名供体 4 个样本)。每个样本在组织切片中跨越多个皮层层次以及白质。本工作流程中的示例使用一个具有代表性的样本,标记为 151673,该样本经常在各种空间组学数据分析方法论文中被展示。
library(SpatialExperiment)
library(STexampleData)
library(ggspavis)
library(patchwork)
library(scater)
library(scran)
library(pheatmap)
从 DLPFC 数据集中加载样本 151673。该样本以 SpatialExperiment
对象的形式提供,来自 STexampleData
包。
# load data
spe <- Visium_humanDLPFC()
class(spe)
## [1] "SpatialExperiment"
## attr(,"package")
## [1] "SpatialExperiment"
dim(spe)
## [1] 33538 4992
作为初始检查,在 x-y 维度上绘制空间坐标(spots),以确认对象已正确加载。我们使用 ggspavis 包中的绘图函数。
我们使用 scater
包计算质量控制(QC)指标,并应用简单的全局阈值法进行质量控制,以识别任何低质量的 spots。
# plot spatial coordinates (spots)
plotCoords(spe)
## [1] 33538 3639
# identify mitochondrial genes
is_mito <- grepl("(^MT-)|(^mt-)", rowData(spe)$gene_name)
table(is_mito)
## is_mito
## FALSE TRUE
## 33525 13
rowData(spe)$gene_name[is_mito]
## [1] "MT-ND1" "MT-ND2" "MT-CO1" "MT-CO2" "MT-ATP8" "MT-ATP6" "MT-CO3"
## [8] "MT-ND3" "MT-ND4L" "MT-ND4" "MT-ND5" "MT-ND6" "MT-CYB"
# calculate per-spot QC metrics and store in colData
spe <- addPerCellQC(spe, subsets = list(mito = is_mito))
head(colData(spe), 3)
通过直方图查看各 QC 指标的分布,以此设定全局过滤阈值。
par(mfrow = c(1, 4))
hist(spe$sum, xlab = "sum", main = "UMIs per spot")
hist(spe$detected, xlab = "detected", main = "Genes per spot")
hist(spe$subsets_mito_percent, xlab = "pct mito", main = "Percent mito UMIs")
hist(spe$cell_count, xlab = "no. cells", main = "No. cells per spot")
# select global QC thresholds
spe$qc_lib_size <- spe$sum < 600
spe$qc_detected <- spe$detected < 400
spe$qc_mito <- spe$subsets_mito_percent > 28
table(spe$qc_lib_size)
##
## FALSE TRUE
## 3631 8
table(spe$qc_detected)
##
## FALSE TRUE
## 3632 7
table(spe$qc_mito)
##
## FALSE TRUE
## 3622 17
绘制潜在低质量 spots 的空间分布图,确认它们没有集中在具有生物学意义的区域(若集中,则提示所选阈值可能过于严格)。
# plot spatial distributions of discarded spots
p1 <- plotObsQC(spe,
plot_type = "spot",
annotate = "qc_lib_size") +
ggtitle("Library size (< threshold)")
p2 <- plotObsQC(spe,
plot_type = "spot",
annotate = "qc_detected") +
ggtitle("Detected genes (< threshold)")
p3 <- plotObsQC(spe,
plot_type = "spot",
annotate = "qc_mito") +
ggtitle("Mito proportion (> threshold)")
# arrange plots using patchwork package
p1 | p2 | p3
将各指标检出的低质量 spots 合并,最终确定要丢弃的 spots 集合。
# number of identifed spots for each metric
apply(cbind(spe$qc_lib_size, spe$qc_detected, spe$qc_mito), 2, sum)
## [1] 8 7 17
# combined set of identified spots
spe$discard <- spe$qc_lib_size | spe$qc_detected | spe$qc_mito
table(spe$discard)
##
## FALSE TRUE
## 3614 25
绘制待丢弃的“已识别低质量 spots”合并集合的空间分布图,再次确认它们并未对应任何明显具有生物学意义的区域,否则将提示我们可能剔除了具有生物学信息的 spots。具体而言,在本数据集中,我们要确保被丢弃的 spots 不会集中于单一皮质层。
# check spatial pattern of discarded spots
plotObsQC(spe, plot_type = "spot", annotate = "discard")
过滤低质量的spots
# filter out low-quality spots
spe <- spe[, !spe$discard]
dim(spe)
## [1] 33538 3614
未完待续,欢迎关注!
Reference
[1]
Ref: https://lmweber.org/OSTA/