首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >空间转录组: Visium HD 数据集分析 (3)

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

作者头像
数据科学工厂
发布2025-11-29 17:38:07
发布2025-11-29 17:38:07
2290
举报

引言

本系列讲解 空间转录组学 (Spatial Transcriptomics) 相关基础知识与数据分析教程[1]

反卷积分析

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

加载单细胞参考数据

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

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

代码语言:javascript
复制
# 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”(对单细胞为最可能的细胞类型,对双细胞为最主要类型)合并为更低分辨率:

代码语言:javascript
复制
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 是单态:

代码语言:javascript
复制
round(100*mean(vhd8$DeconClass == "singlet"), 2)

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

代码语言:javascript
复制
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 的比例会更小。

代码语言:javascript
复制
# 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):

代码语言:javascript
复制
# 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), ]

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

代码语言:javascript
复制
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 类别:

代码语言:javascript
复制
# 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 分箱的反卷积结果:

代码语言:javascript
复制
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 分辨率能更精细地捕捉结构,例如内皮细胞和成纤维细胞呈“细线状”伸入左上角肿瘤区域的分箱。

未完待续,欢迎关注!

Reference

[1] Ref: https://lmweber.org/OSTA/

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2025-11-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 冷冻工厂 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 引言
  • 反卷积分析
  • 加载单细胞参考数据
  • 简化 8 µm 注释
  • 在 16 µm 分箱上运行 RCTD
  • 不同分辨率下的反卷积结果
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档