Dr Cheng ZhangDigital Liver Group · translational systems medicine

Bioinformatics, step by step · Workshop

Module 8 · Designs with more than one factor

Video: T10 Designs with more than one factor. Script: scripts/08_multifactor.R (run module 5 first)

Goal. Estimate the effect of MI across both days at once, correcting for day. Learn to read a model matrix. The same approach is used to correct for batch.

meta$MI <- factor(meta$MI); meta$day <- factor(meta$day)   # factors, not numbers
model.matrix(~ day + MI, meta)
dds <- DESeqDataSetFromMatrix(count, meta, design = ~ day + MI)
res_mi <- results(DESeq(dds), name = "MI_1_vs_0")

Q8.1 Write out the model matrix. What does each column mean? For a sample from MI, day 3, what is its log mean in terms of the coefficients?

Q8.2 What happens if MI and day are left as numbers instead of factors? (Try it, and look at model.matrix.) When would it matter?

Q8.3 How many genes are significant for the MI coefficient? Compare with the day 1 and day 3 single-factor results. Why might the multifactor model find genes that neither single-day comparison finds?

Q8.4 Plot the multifactor log fold changes against the day 1 ones. What does the scatter tell you about the assumption that MI has the same effect on both days?

Q8.5 Fit ~ day + MI + day:MI. What does the day3.MI1 coefficient mean? With two replicates per group, how much would you trust it?

Q8.6 (design) You have 12 samples: 6 control and 6 treated. They were sequenced in two batches of 6, and every batch has 3 of each. Write the design formula. What if batch 1 had all 6 controls and batch 2 all 6 treated?