利用DESeq2进行多组分析(终于找到教程了)
2022-11-01 本文已影响0人
夏大希
###对大麦相同时期的不同部位进行多组比较分析差异基因
# https://www.biostars.org/p/357464/
library(DESeq2)
BiocManager::install("apeglm")
library(apeglm)
x <- round(matrix(rexp(480 * 10, rate=.1), ncol=12), 0)
rownames(x) <- paste("gene", 1:nrow(x))
colnames(x) <- paste("sample", 1:ncol(x))
coldata <- data.frame(
condition = factor(c(
rep("ctl", 3),
rep("A", 3),
rep("B", 3),
rep("C", 3))))
coldata$condition <- relevel(coldata$condition, ref = "ctl")
dds <- DESeqDataSetFromMatrix(
countData = x,
colData = coldata,
design= ~ condition)
dds <- DESeq(dds, betaPrior = FALSE)
resultsNames(dds)
# generate results table for A vs ctl
res <- results(dds, name="condition_A_vs_ctl")
# same as above but with lfc shrinkage
res <- lfcShrink(dds, coef = 'condition_A_vs_ctl', type = 'apeglm', res = res)
res
##or useing next
results(dds, c("condition", "A", "C"))