STEP 13 / 15

多樣本整合與 3D 重建

兩種任務:把多切片放到「同一個表達空間」(batch correction),或把連續切片堆成 3D 結構。

Two tasks: align multiple slices into "one expression space" (batch correction), or stack serial sections into 3D.

一、兩種「整合」

🧹

表達空間整合

不同樣本/批次/條件混在一起做下游分析(spatial domain、deconvolution)時,要先校正 batch effect。Harmony / scVI / Seurat anchors 都可用,但要小心過度校正。

When mixing samples/batches/conditions for downstream analysis (spatial domains, deconvolution), batch effects must be corrected. Harmony / scVI / Seurat anchors all work — beware over-correction.

🧱

物理對位 / 3D

連續切片沿 z 軸對齊,重建 3D 組織。PASTE / STAligner / STAIR 三大主流方法各有強項。

Align serial sections along z to reconstruct 3D tissue. Three mainstream tools: PASTE / STAligner / STAIR, each with different strengths.

互動:兩個切片的 batch correction

左側:兩個切片在 PCA 上明顯分開(受 batch 主導)。拖動「校正強度」觀察兩個 batch 重新混合,並觀察生物 cluster 是否仍可辨識。

Left: two batches separate in PCA (dominated by batch). Slide the strength to mix them — but watch whether the biological clusters remain distinguishable.

圈:細胞;外框 = batch;填色 = cell type

實作

# Seurat v5 多樣本整合
combined <- merge(vis1, y = list(vis2, vis3), add.cell.ids = c("s1","s2","s3"))
combined <- SCTransform(combined, assay = "Spatial") |> RunPCA()
library(harmony)
combined <- RunHarmony(combined, group.by.vars = "sample", reduction = "pca")
combined <- RunUMAP(combined, reduction = "harmony", dims = 1:30)
SpatialDimPlot(combined, label = TRUE)
# scVI multi-batch
import scvi
scvi.model.SCVI.setup_anndata(adata, batch_key="sample")
mod = scvi.model.SCVI(adata); mod.train()
adata.obsm["X_scvi"] = mod.get_latent_representation()

# STAligner (跨切片整合 + alignment)
import STAligner
adata_concat = STAligner.train_STAligner(adata_list=[a1,a2,a3], n_epochs=600)

# PASTE 對位相鄰切片 → 3D
import paste as pst
pis = pst.pairwise_align(a1, a2)        # slice→slice transport
center, slices = pst.center_align([a1,a2,a3])  # 對齊到 center slice

📝 自我檢測

1. PASTE 不適合用在哪一種情境?

1. When is PASTE NOT appropriate?

A. 同一個小鼠的連續腦切片A. Serial brain sections from one mouse
B. 同個樣本相鄰兩切片的 3D 重建B. 3D reconstruction from adjacent slices of one sample
C. 不同個體 / 不同條件 / 幾何不相似的切片C. Different individuals / conditions / geometrically dissimilar slices
D. 取得 transport planD. Computing the transport plan

2. 2025 ST batch correction benchmark 顯示 Harmony 的特徵是?

2. According to the 2025 ST benchmark, Harmony tends to:

A. batch correction 強,但 biology 保留偏弱A. Strong batch correction but weaker biology preservation
B. 兩者都最佳B. Best on both
C. 不能用C. Doesn't work
D. 只能 R 用D. R-only

3. 想要一站式做完「批次校正 + 對位 + 3D」?

3. End-to-end "batch correction + alignment + 3D reconstruction"?

A. PASTEA. PASTE
B. STAIRB. STAIR
C. HarmonyC. Harmony
D. SpatialDED. SpatialDE