769. 转录组去卷积BisqueRNA¶
一句话概述:从bulk RNA-seq数据中推算各种细胞类型的比例,不需要做单细胞测序就能知道组织样本里各种细胞占多少——就像从一锅混合汤的味道推断出用了多少西红柿、多少洋葱、多少牛肉。
核心知识点速查表¶
| 概念 | 白话解释 | 关键工具 |
|---|---|---|
| 去卷积 | 从混合信号分解出各组分比例 | 解混合 |
| BisqueRNA | 基于参考的bulk RNA去卷积 | R包 |
| CIBERSORTx | 最经典的去卷积工具 | 网页版/Docker |
| MuSiC | 利用scRNA-seq作为参考 | R/Bioconductor |
| 标记基因 | 细胞类型特异的标记基因 | 去卷积的基础 |
| 特征矩阵 | 每种细胞类型的基因表达谱 | Signature matrix |
一、原理(白话版)¶
1.1 为什么需要去卷积?¶
问题场景:
你有一批肿瘤bulk RNA-seq数据
想知道每个样本里免疫细胞占多少比例
但没钱做单细胞测序
去卷积的思路:
已知信息:
① Bulk RNA-seq的基因表达(混合信号)
② 各种细胞类型的特征表达谱(来自scRNA-seq参考数据)
推算过程:
混合表达 ≈ Σ(细胞类型比例 × 细胞类型特征表达)
→ 数学上就是解一个线性方程组
→ 未知数就是各细胞类型的比例
类比:
鸡尾酒的颜色 = 30%红色果汁 + 50%黄色果汁 + 20%蓝色果汁
已知各果汁的颜色和最终颜色 → 反推比例
1.2 主要工具对比¶
| 工具 | 方法 | 参考数据 | 特点 |
|---|---|---|---|
| CIBERSORTx | 支持向量回归 | 内置LM22/自定义 | 最经典,网页版 |
| BisqueRNA | 回归+scRNA参考 | scRNA-seq | 利用单细胞参考 |
| MuSiC | 加权非负最小二乘 | scRNA-seq | 多级别树结构 |
| EPIC | 约束线性回归 | 内置免疫特征 | 肿瘤微环境 |
| xCell | 基因集富集 | 无需参考 | 64种细胞类型 |
二、BisqueRNA分析流程¶
2.1 安装与数据准备¶
# ===== 安装BisqueRNA =====
# install.packages("devtools")
# devtools::install_github("cozygene/bisque")
library(BisqueRNA) # 加载BisqueRNA
library(Biobase) # 加载Biobase(ExpressionSet需要)
# ===== 准备参考scRNA-seq数据 =====
# 需要:count矩阵 + 细胞类型注释
# 读取scRNA-seq参考数据
sc_counts <- read.csv("sc_count_matrix.csv", row.names=1) # 基因×细胞
sc_metadata <- read.csv("sc_metadata.csv", row.names=1) # 细胞元数据
# 创建ExpressionSet对象
sc_eset <- ExpressionSet(
assayData = as.matrix(sc_counts), # 表达矩阵
phenoData = AnnotatedDataFrame(sc_metadata) # 元数据
)
# 确保有cell_type列
print(table(sc_metadata$cell_type))
# T_cell 500
# B_cell 300
# Macrophage 200
# Fibroblast 400
# Epithelial 600
# ===== 准备bulk RNA-seq数据 =====
bulk_counts <- read.csv("bulk_count_matrix.csv", row.names=1) # 基因×样本
bulk_metadata <- data.frame(
row.names = colnames(bulk_counts),
sample_id = colnames(bulk_counts)
)
bulk_eset <- ExpressionSet(
assayData = as.matrix(bulk_counts),
phenoData = AnnotatedDataFrame(bulk_metadata)
)
2.2 基于参考的去卷积¶
# ===== BisqueRNA Reference-Based去卷积 =====
# 使用scRNA-seq作为参考
result <- ReferenceBasedDecomposition(
bulk.eset = bulk_eset, # bulk数据
sc.eset = sc_eset, # scRNA-seq参考
cell.types = "cell_type", # 细胞类型列名
markers = NULL, # 自动选择标记基因
use.overlap = TRUE # 使用重叠基因
)
# 提取细胞类型比例
proportions <- result$bulk.props # 细胞类型比例矩阵
print(head(proportions))
# 输出:
# T_cell B_cell Macrophage Fibroblast Epithelial
# Sample1 0.25 0.10 0.15 0.20 0.30
# Sample2 0.15 0.05 0.30 0.25 0.25
# 保存结果
write.csv(proportions, "cell_type_proportions.csv")
2.3 无参考的去卷积(标记基因方法)¶
# ===== BisqueRNA Marker-Based去卷积 =====
# 不需要scRNA-seq,只需要标记基因列表
# 定义标记基因
markers <- list(
T_cell = c("CD3D", "CD3E", "CD4", "CD8A", "TRAC"), # T细胞标记
B_cell = c("CD19", "MS4A1", "CD79A", "CD79B", "PAX5"), # B细胞标记
Macrophage = c("CD14", "CD68", "CSF1R", "FCGR3A", "MARCO"), # 巨噬细胞
Fibroblast = c("COL1A1", "COL1A2", "ACTA2", "FAP", "VIM"), # 成纤维细胞
Epithelial = c("EPCAM", "KRT18", "KRT19", "CDH1", "MUC1") # 上皮细胞
)
result_marker <- MarkerBasedDecomposition(
bulk.eset = bulk_eset, # bulk数据
markers = markers, # 标记基因列表
weighted = TRUE # 加权估计
)
# 提取结果
proportions_marker <- result_marker$bulk.props
print(head(proportions_marker))
三、CIBERSORTx分析¶
# ===== CIBERSORTx替代方案 =====
# CIBERSORTx网页版: https://cibersortx.stanford.edu/
# R中使用CIBERSORTx的替代:immunedeconv包
# install.packages("immunedeconv")
library(immunedeconv)
# 去卷积(使用内置LM22免疫细胞特征矩阵)
deconv_result <- deconvolute(
gene_expression = as.matrix(bulk_counts), # bulk表达矩阵
method = "cibersort_abs", # 方法(cibersort_abs/epic/quantiseq/mcp_counter/xcell)
tumor = TRUE # 是否含肿瘤细胞
)
print(head(deconv_result))
# cell_type Sample1 Sample2 Sample3
# T cell CD4+ 0.15 0.20 0.10
# T cell CD8+ 0.10 0.15 0.05
# B cell 0.05 0.08 0.12
# Macrophage M1 0.08 0.12 0.18
# 多种方法对比
methods <- c("cibersort_abs", "epic", "quantiseq", "mcp_counter", "xcell")
all_results <- lapply(methods, function(m) {
deconvolute(as.matrix(bulk_counts), method=m, tumor=TRUE)
})
names(all_results) <- methods
四、MuSiC分析¶
# ===== MuSiC去卷积 =====
# BiocManager::install("MuSiC")
library(MuSiC)
# MuSiC使用加权非负最小二乘法
# 特色:多分辨率层级树结构
# 基本去卷积
music_result <- music_prop(
bulk.eset = bulk_eset, # bulk ExpressionSet
sc.eset = sc_eset, # scRNA-seq ExpressionSet
clusters = "cell_type", # 细胞类型列
samples = "sample_id", # 样本ID列(sc中的)
verbose = TRUE
)
# 提取比例
music_props <- music_result$Est.prop.weighted # 加权估计的比例
print(head(music_props))
五、可视化与下游分析¶
# ===== Python可视化去卷积结果 =====
import pandas as pd # 导入pandas
import matplotlib.pyplot as plt # 导入matplotlib
import seaborn as sns # 导入seaborn
# 读取去卷积结果
props = pd.read_csv("cell_type_proportions.csv", index_col=0)
# 堆叠柱状图
fig, ax = plt.subplots(figsize=(12, 6))
props.plot(kind="bar", stacked=True, ax=ax, colormap="Set3")
ax.set_xlabel("Sample")
ax.set_ylabel("Cell Type Proportion")
ax.set_title("Cell Type Composition by Sample")
ax.legend(bbox_to_anchor=(1.05, 1), loc="upper left")
plt.xticks(rotation=45)
plt.tight_layout()
plt.savefig("deconv_barplot.png", dpi=300)
# 热图
fig, ax = plt.subplots(figsize=(10, 8))
sns.heatmap(props, annot=True, fmt=".2f", cmap="YlOrRd", ax=ax)
ax.set_title("Cell Type Proportions Heatmap")
plt.tight_layout()
plt.savefig("deconv_heatmap.png", dpi=300)
# 与临床特征关联
# 例如:免疫细胞比例与生存的关系
# props["immune_score"] = props[["T_cell","B_cell","Macrophage"]].sum(axis=1)
六、常见报错与解决¶
| 报错信息 | 原因 | 解决方案 |
|---|---|---|
Few overlapping genes | bulk和sc参考基因交集少 | 统一基因名格式(symbol) |
Negative proportions | 数学不稳定 | 正常,设为0或换方法 |
All zeros for cell type | 该细胞类型在bulk中不存在 | 检查参考数据是否合适 |
ExpressionSet error | 数据格式不对 | 确保矩阵是数值型 |
Too few markers | 标记基因太少 | 每种细胞至少5个标记基因 |
比例之和≠1 | 某些方法不保证 | 归一化:prop/sum(prop) |
七、面试高频问题¶
Q1: 去卷积和单细胞测序的关系?¶
A: 去卷积是一种"退而求其次"的方法——已有的bulk RNA-seq数据也能估算细胞组成。单细胞测序给出精确的单细胞分辨率,但成本高。去卷积的最佳实践是用同组织的scRNA-seq作为参考(BisqueRNA/MuSiC),如果没有scRNA-seq则用内置特征矩阵(CIBERSORTx LM22)。
Q2: BisqueRNA和CIBERSORTx怎么选?¶
A: BisqueRNA需要自己提供scRNA-seq参考,灵活但需要数据;CIBERSORTx有内置的LM22免疫细胞特征矩阵(22种免疫细胞),开箱即用但限于免疫细胞。如果研究特定组织且有对应的scRNA-seq → BisqueRNA/MuSiC;如果只关注免疫浸润 → CIBERSORTx。
Q3: 如何验证去卷积结果?¶
A: ①免疫组化(IHC):特异抗体染色计数细胞比例;②流式细胞术:精确的细胞比例测量;③scRNA-seq:用真实的单细胞数据验证;④已知混合比例的模拟数据benchmark;⑤多工具交叉验证。
八、速查表¶
# ===== 转录组去卷积速查 =====
# BisqueRNA(有scRNA-seq参考)
library(BisqueRNA)
result <- ReferenceBasedDecomposition(bulk.eset, sc.eset, cell.types="cell_type")
props <- result$bulk.props
# BisqueRNA(标记基因方法)
result <- MarkerBasedDecomposition(bulk.eset, markers=marker_list)
# MuSiC
library(MuSiC)
result <- music_prop(bulk.eset, sc.eset, clusters="cell_type")
# immunedeconv(多方法封装)
library(immunedeconv)
result <- deconvolute(expr_matrix, method="cibersort_abs")
# 工具选择:
# 有scRNA-seq参考 → BisqueRNA / MuSiC
# 只看免疫 → CIBERSORTx(LM22) / EPIC
# 快速概览 → xCell(无需参考)
# 多方法对比 → immunedeconv包