1. 两两比对

组A vs. 组B。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
pair-wise comparison
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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. 交叉项

pair-wise comparison
1
2
3
4
5
6
7
8
9
10
11
12
13
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与第一个的区别是,考虑了交叉项的影响。如果只是为了两两比对,可以考虑使用第一个例子的处理方法。

参考网址

更新记录

2019年04月15日

Comments