Yulong Niu

个人博客

DESeq2包的对比组设计

Posted at — Apr 15, 2019

1. 两两比对

DataFrame with 12 rows and 2 columns
         condition genotype
          <factor> <factor>
sample1          A        I
sample2          A        I
sample3          A        I
sample4          A       II
sample5          A       II
...            ...      ...
sample8          B        I
sample9          B        I
sample10         B       II
sample11         B       II
sample12         B       II

组A vs. 组B。

dds <- makeExampleDESeqDataSet(n = 100, m = 12)
dds$genotype <- factor(rep(rep(c('I', 'II'), each=3), 2))

## condition: A vs. B
design(dds) <- ~ condition
ddres <- DESeq(dds)
res <- results(ddres, contrast = c('condition', 'B', 'A'))

## genotype I vs. II
design(dds) <- ~ genotype
ddres <- DESeq(dds)
res <- results(ddres, contrast = c('genotype', 'I', 'II'))

## A vs. B at genotype II
dds$group <- factor(paste0(dds$genotype, dds$condition))
design(dds) <- ~ group
ddres <- DESeq(dds)
results(ddres, contrast = c('group', 'IIB', 'IIA'))

2. 交叉项

dds <- makeExampleDESeqDataSet(n = 100, m = 12)
dds$genotype <- factor(rep(rep(c('I', 'II'), each=3), 2))
design(dds) <- ~ genotype + condition + genotype:condition
ddres <- DESeq(dds) 

## A vs. B at genotype I
res <- results(ddres, contrast = c('condition', 'B', 'A'))

## A vs. B at genotype II
res <- results(ddres, list(c('condition_B_vs_A', 'genotypeII.conditionB')))

## condition effect *different* across genotypes
res <- results(ddres, name = 'genotypeII.conditionB') 

其中,第二例子中的A vs. B at genotype II与第一个的区别是,考虑了交叉项的影响。如果只是为了两两比对,可以考虑使用第一个例子的处理方法。

补充技巧

## 查看设计
colData(dds)

## 查看对比
resultsName(dds)

参考网址

更新记录

2019年04月15日