DESeq2差异表达分析:RNA-seq最小可用流程

402 字
2 分钟
DESeq2差异表达分析:RNA-seq最小可用流程

差异表达分析回答”处理组和对照组哪些基因发生了变化”。从 count 矩阵出发,DESeq2 提供了标准化的差异分析流程。本文聚焦最小可用流程:表达矩阵准备、样本表构建、差异分析、结果提取、火山图,不深入统计原理。

1. 准备数据#

DESeq2 需要两个输入:

# 1. count矩阵(基因×样本,整数)
head(counts)
# control1 control2 control3 treat1 treat2 treat3
# ENSG00001 200 180 190 500 520 480
# ENSG00002 5 8 3 10 12 15
# 2. 样本信息
coldata <- data.frame(
row.names = colnames(counts),
condition = factor(c(rep("Control",3), rep("Treatment",3)))
)

注意:count必须是整数(raw counts),不能用FPKM/TPM。

2. 差异分析#

library(DESeq2)
# 构建对象
dds <- DESeqDataSetFromMatrix(
countData = counts,
colData = coldata,
design = ~ condition
)
# 过滤低表达基因(至少在3个样本中count≥10)
keep <- rowSums(counts(dds) >= 10) >= 3
dds <- dds[keep, ]
# 跑分析
dds <- DESeq(dds)
# 提取结果
res <- results(dds, contrast = c("condition", "Treatment", "Control"),
alpha = 0.05)
summary(res)
# 导出
write.csv(as.data.frame(res), "DEG_results.csv")

3. 筛选差异基因#

res_sig <- as.data.frame(res) %>%
filter(padj < 0.05, abs(log2FoldChange) > 1) %>%
arrange(padj)
阈值含义
padj < 0.05多重检验校正后显著
|log2FC| > 1变化超过2倍

4. 火山图#

library(ggplot2)
ggplot(as.data.frame(res), aes(x = log2FoldChange, y = -log10(padj))) +
geom_point(alpha = 0.3, size = 0.5) +
geom_vline(xintercept = c(-1, 1), linetype = "dashed") +
geom_hline(yintercept = -log10(0.05), linetype = "dashed") +
theme_bw()

5. 踩坑#

坑1:count矩阵有小数——featureCounts 输出有时含浮点数。用 round() 取整。

坑2:样本名不匹配——coldata 的 row.names 必须等于 count 矩阵的 colnames。

坑3:没有生物学重复报错——DESeq2 要求每组≥2个重复。n=1时用 design = ~ 1,但不推荐。


本文于 2025-08-20 实测。

文章分享

如果这篇文章对你有帮助,欢迎分享给更多人!

DESeq2差异表达分析:RNA-seq最小可用流程
https://fg.ink/posts/deseq2-differential-expression-basics/
作者
风观
发布于
2025-10-01
许可协议
CC BY-NC-SA 4.0
Profile Image of the Author
风观
风有来路,观有所思
分类
标签
站点统计
文章
50
分类
1
标签
29
总字数
61,837
运行时长
0
最后活动
0 天前

文章目录