空间转录组: Visium HD 数据集分析 (3)

简介: 空间转录组: Visium HD 数据集分析 (3)

引言

本系列讲解 空间转录组学 (Spatial Transcriptomics) 相关基础知识与数据分析教程,持续更新,欢迎关注,转发,文末有交流群

反卷积分析

接下来,我们将对以 16 µm 为单位的 Visium HD 空间转录组数据进行反卷积分析。

加载单细胞参考数据

首先,我们加载与之匹配的 Chromium 单细胞 RNA 测序(scRNA-seq)数据,该数据提供了两种细胞注释分辨率:低分辨率(Level1)将细胞分为 9 类,高分辨率(Level2)则进一步细分为 31 类。

为了确保参考数据与 Visium 数据在转录特征上保持一致,我们仅保留来自 patient 2 的细胞作为参考集。

# retrieve dataset from OSF repository
id <- "Chromium_HumanColon_Oliveira"
pa <- OSTA.data_load(id)
dir.create(td <- tempfile())
unzip(pa, exdir=td)

# read into `SingleCellExperiment`
fs <- list.files(td, full.names=TRUE)
h5 <- grep("h5$", fs, value=TRUE)
sce <- read10xCounts(h5, col.names=TRUE)

# add cell metadata
csv <- grep("csv$", fs, value=TRUE)
cd <- read.csv(csv, row.names=1)
colData(sce)[names(cd)] <- cd[colnames(sce), ]

# use gene symbols as feature names
gs <- rowData(sce)$Symbol
rownames(sce) <- make.unique(gs)

# exclude cells deemed to be of low-quality
sce <- sce[, sce$QCFilter == "Keep"]

# subset cells from same patient
sce <- sce[, grepl("P2", sce$Patient)]
sce

简化 8 µm 注释

我们可以利用单细胞参考注释,将已有的反卷积标注 “DeconLabel1”(对单细胞为最可能的细胞类型,对双细胞为最主要类型)合并为更低分辨率:

i <- match(vhd8$DeconLabel1, sce$Level2)
j <- match(vhd8$DeconLabel2, sce$Level2)
vhd8$.DeconLabel1 <- sce$Level1[i]
vhd8$.DeconLabel2 <- sce$Level1[j]
vhd8 <- vhd8[, !is.na(vhd8$.DeconLabel1)]
table(vhd8$.DeconLabel1)

根据 RCTD,大约 75% 的 8 µm bin 是单态:

round(100*mean(vhd8$DeconClass == "singlet"), 2)

让我们根据“doublet_certain”类检查前 5 个常见双峰对:

dbl <- vhd8$DeconClass == "doublet_certain"
lab <- c(".DeconLabel1", ".DeconLabel2")
df <- data.frame(colData(vhd8)[dbl, lab])

# sort as to ignore order
df <- apply(df, 1, sort)
df <- do.call(rbind, df)
names(df) <- lab

# count unique pairs
ij <- paste(df[, 1], df[, 2], sep=";")
head(sort(table(ij), decreasing=TRUE), 5)

我们可以看到,髓系细胞通常与肿瘤细胞和成纤维细胞共定位;大多数 doublets 是同型的,即它们(主要)由一种低分辨率类型组成。

在 16 µm 分箱上运行 RCTD

我们同样假设每个 16 µm 分箱中最多存在两种细胞类型,如同在 8 µm 中一样,因此预计 singlets 的比例会更小。

# downsample to at most 4,000 cells per cluster for 'sce'
# (this is done only to keep runtime/memory low)
cs <- split(seq_len(ncol(sce)), sce$Level1)
cs <- lapply(cs, \(.) sample(., min(length(.), 4e3)))
ncol(.sce <- sce[, unlist(cs)])
rctd_data <- createRctd(.vhd16, .sce, cell_type_col="Level1")
(res <- runRctd(rctd_data, max_cores=4, rctd_mode="doublet"))

RCTD 推断出的 weight 对应细胞类型的比例,使得对于给定观测它们总和为 1(被排除的观测除外,其总和为 0):

# counts rejected observations
ws <- assay(res, "weights")
table(colSums(ws) == 0)

# add proportion estimates as metadata
ws <- data.frame(t(as.matrix(ws)))
colData(.vhd16)[names(ws)] <- ws[colnames(.vhd16), ]

接下来,我们可以在空间上可视化反卷积比例估计:

lapply(names(ws), \(.) 
    plotCoords(.vhd16, annotate=., point_size=0.3, point_shape=15)) |>
    wrap_plots(nrow=2, guides="collect") & theme(
    legend.key.width=unit(0.5, "lines"),
    legend.key.height=unit(1, "lines")) &
    scale_color_gradientn(colors=rev(hcl.colors(9, "Rocket")))

我们也可以为 16 µm 分箱获得 majority vote 类别:

# derive majority vote labels
ids <- names(ws)[apply(ws, 1, which.max)]
ids <- gsub("\\.([A-z])", " \\1", ids)
idx <- match(colnames(.vhd16), rownames(ws))
table(.vhd16$.DeconLabel1 <- factor(ids[idx]))

不同分辨率下的反卷积结果

让我们在放大区域可视化 8 µm 和 16 µm 分箱的反卷积结果:

plotVisium(.vhd8, 
    annotate=".DeconLabel1", zoom=TRUE, 
    point_size=0.8, point_shape=22) + 
    ggtitle("8 µm") + 
plot_spacer() +
plotVisium(.vhd16, 
    annotate=".DeconLabel1", zoom=TRUE, 
    point_size=1.6, point_shape=22) + 
    ggtitle("16 µm") +
plot_layout(nrow=1, guides="collect", widths=c(1, 0.05, 1)) &
    guides(col=guide_legend(override.aes=list(size=2))) &
    scale_fill_manual(values=unname(pals::trubetskoy())) & 
    facet_null() & theme(
        plot.title=element_text(hjust=0.5),
        legend.key.size=unit(0, "lines"))

我们观察到,在 8 µm 和 16 µm 两种分辨率下,反卷积结果高度一致;然而,8 µm 分辨率能更精细地捕捉结构,例如内皮细胞和成纤维细胞呈“细线状”伸入左上角肿瘤区域的分箱。

相关文章
|
4月前
|
编解码 数据可视化 数据挖掘
空间转录组: Visium HD 数据集分析 (1)
空间转录组: Visium HD 数据集分析 (1)
312 27
空间转录组: Visium HD 数据集分析 (1)
|
6月前
|
数据采集 数据挖掘 Serverless
空间转录组学: 质控处理(1)
空间转录组学: 质控处理(1)
空间转录组学: 质控处理(1)
|
4月前
|
算法 数据可视化 数据挖掘
空间转录组: Visium CRC 数据集分析
空间转录组: Visium CRC 数据集分析
512 42
空间转录组: Visium CRC 数据集分析
|
5月前
|
机器学习/深度学习 编解码 算法
空间转录组: 反卷积
空间转录组: 反卷积
空间转录组:  反卷积
|
6月前
|
存储 数据可视化
单细胞分析: Scanpy 核心绘图 (3)
单细胞分析: Scanpy 核心绘图 (3)
单细胞分析: Scanpy 核心绘图 (3)
|
SQL 自然语言处理 NoSQL
LangChain之链的认识(上)
Chain是LangChain中非常重要的一个组件,可以帮助我们更好地组织和管理应用程序的各个功能模块,提高开发效率和应用程序的复杂性。
412 3
|
Java 应用服务中间件 网络安全
Spring Boot中的嵌入式服务器配置
Spring Boot中的嵌入式服务器配置
|
存储 Kubernetes 对象存储
Velero 系列文章(一):基础
Velero 系列文章(一):基础
Velero 系列文章(一):基础
|
机器学习/深度学习 存储 人工智能
极智AI | 一文看懂Google TPU脉动阵列加速卷积计算原理
本教程详细解释了 Google TPU 脉动阵列加速卷积计算原理。
2985 0
|
人工智能 数据可视化
跟SCI学umap图| ggplot2 绘制umap图,坐标位置 ,颜色 ,大小还不是你说了算
跟SCI学umap图| ggplot2 绘制umap图,坐标位置 ,颜色 ,大小还不是你说了算
2038 1