STEP 12 / 15

空間軌跡:把 pseudotime 推進空間維度

傷口邊緣的細胞「沿著空間漸變狀態」——這是 trajectory 在 ST 上的真實含義。

Cells near a wound margin form continuous state gradients in space — that is what trajectory means in ST.

一、為什麼 ST 的 trajectory 不只是 scRNA pseudotime?

scRNA 的 trajectory(Monocle3、Slingshot、scVelo)是「狀態空間」裡的一條線:把細胞從一個狀態變到另一個狀態的順序排出來。在 ST 上我們有一個天然的物理軸——例如「離血管多遠」、「距腫瘤邊緣多遠」、「沿皮層的深度」。

因此 ST trajectory 有兩個層次:

  • cell-level trajectory:跟 scRNA 一樣的 pseudotime,但事後可以投回空間。
  • niche-level trajectory:把 niche 排序成一條空間連續的「微環境演進」(ONTraC、SpaceFlow)。

scRNA trajectories (Monocle3, Slingshot, scVelo) live in "state space" — order cells from one state to another. ST gives us a natural physical axis: distance from a vessel, distance from a tumor margin, depth across cortical layers.

So ST trajectory has two levels:

  • Cell-level trajectory: like scRNA pseudotime, projected back to space afterwards.
  • Niche-level trajectory: order niches into a spatially-contiguous "microenvironment progression" (ONTraC, SpaceFlow).

互動:沿空間軸的 pseudotime 漸變

下方為模擬「傷口邊緣的修復細胞」場景。中央紅色為傷口;周圍細胞表達會根據與傷口距離形成漸變。切換不同模式觀察 pseudotime 投回空間後的 pattern。

Simulated "wound-margin healing cells" scene. Central red region = wound; surrounding cells express genes graded by distance to the wound. Switch modes to see pseudotime projected back into space.

實作

# 把 ST 物件轉到 cell 層級(image-based 直接;spot-based 先 deconvolution)
library(monocle3)
cds <- new_cell_data_set(counts(spe), cell_metadata = colData(spe))
cds <- preprocess_cds(cds) |> reduce_dimension() |> cluster_cells()
cds <- learn_graph(cds); cds <- order_cells(cds)
spe$pseudotime <- pseudotime(cds)

# 投回空間
SpatialFeaturePlot(as.Seurat(spe), features = "pseudotime")
# SpaceFlow
from SpaceFlow import SpaceFlow
sf = SpaceFlow.SpaceFlow(adata=adata)
sf.preprocessing_data(n_top_genes=3000)
sf.train(spatial_regularization_strength=0.1); sf.segmentation(domain_label_save_filepath="d.tsv")
sf.pseudo_Spatiotemporal_Map()  # pSM array in adata.obs

# ONTraC: niche-level trajectory
# ontrac CLI: ontrac --meta meta.tsv --st st.h5ad --output out/

📝 自我檢測

1. ST trajectory 跟 scRNA pseudotime 最大的不同是?

1. Biggest difference between ST trajectory and scRNA pseudotime?

A. ST 不能算 pseudotimeA. ST cannot compute pseudotime
B. ST 可以對應到實體空間軸(如離傷口距離)B. ST can map to a physical axis (e.g. distance to wound)
C. scRNA 沒有 trajectoryC. scRNA has no trajectory
D. ST 不需要分群D. ST doesn't need clustering

2. ONTraC 的核心特色?

2. Defining feature of ONTraC?

A. 在 niche 層級畫出連續的微環境演進A. Continuous niche-level microenvironment trajectory
B. 取代 deconvolutionB. Replaces deconvolution
C. 取代 segmentationC. Replaces segmentation
D. 取代 PCAD. Replaces PCA

3. SpaceFlow 主要的輸出是?

3. Main output of SpaceFlow?

A. cell type 標籤A. Cell type labels
B. ligand-receptor pairB. Ligand-receptor pairs
C. pseudo-spatiotemporal map (pSM)C. Pseudo-spatiotemporal map (pSM)
D. UMAPD. UMAP