## Example 1: simple two-group comparison
dds <- makeExampleDESeqDataSet(m=4)
dds <- DESeq(dds)
res <- results(dds)
res[ order(res$padj), ]
## Example 2: two conditions, two sets, with interaction term
dds <- makeExampleDESeqDataSet(n=100,m=12)
dds$set <- factor(rep(rep(c("X","Y"),each=3),2))
design(dds) <- ~ set + condition + set:condition
dds <- DESeq(dds)
resultsNames(dds)
# the main condition effect (for set X)
results(dds, contrast=c("condition","B","A"))
# the main set effect (for condition A)
results(dds, contrast=c("set","Y","X"))
# the interaction term (is the condition effect *different* across set?)
results(dds, name="setY.conditionB")
# the condition effect in set Y (add the interaction to the main effect)
results(dds, contrast=list(c("condition_B_vs_A","setY.conditionB")))
## Example 3: two conditions, three sets
# using interaction terms
dds <- makeExampleDESeqDataSet(n=100,m=18)
dds$set <- factor(rep(rep(c("X","Y","Z"),each=3),2))
design(dds) <- ~ set + condition + set:condition
dds <- DESeq(dds)
resultsNames(dds)
# the main effect for condition (for all sets)
results(dds, contrast=c("condition","B","A"))
# which is equivalent to
results(dds, contrast=list("conditionB","conditionA"))
# the interaction term for condition in set Z
# (does set Z have *different* condition effect than the main effect?)
results(dds, contrast=list("setZ.conditionB","setZ.conditionA"))
# the condition effect in set Z
# (the interaction effect added to the main effect)
results(dds, contrast=list(
c("conditionB","setZ.conditionB"),
c("conditionA","setZ.conditionA")))
# the set Z effect compared to the average of set X and Y
# here we use 'listValues' to multiply the effect sizes for
# set X and set Y by -1/2
results(dds, contrast=list("setZ",c("setX","setY")), listValues=c(1,-1/2))
# using a grouping variable.
# this is a useful construction when users just want to compare
# specific groups which are combinations of variables
dds$group <- factor(paste0(dds$set, dds$condition))
design(dds) <- ~ group
dds <- DESeq(dds)
resultsNames(dds)
# the condition B vs A effect for set Z
results(dds, contrast=c("group","ZB","ZA"))
Run the code above in your browser using DataLab