114 | | * **Remove batch effects** |
115 | | * With [[http://www.bioconductor.org/packages/release/bioc/html/edgeR.html|edgeR]], the treatments can be adjusted for differences between the batch with addictive model formula by design = model.matrix( ~Batch+Treatment). For example, with target.txt like this: |
| 114 | * **Accounting for a batch effect in a differential expression model** |
| 115 | * With [[http://www.bioconductor.org/packages/release/bioc/html/edgeR.html|edgeR]], the comparison can be adjusted for differences between batches (such as date of sample preparation) with an addictive model formula using the equation |
| 116 | |
| 117 | '''design = model.matrix(~Batch+Treatment)'''. |
| 118 | |
| 119 | For example, with a targets file (target.txt) like this: |
130 | | target <- read.delim("target.txt", header=T) |
131 | | genotype <- factor(target$genotype, levels=c("WT", "KO")) |
132 | | mydate <- factor(target$date, levels=c("old", "new")) |
133 | | Design <-model.matrix(~mydate+genotype) |
134 | | colnames(Design) |
135 | | # [1] "(Intercept)" "mydatenew" "genotypeKO" |
| 132 | target <- read.delim("target.txt", header=T) |
| 133 | genotype <- factor(target$genotype, levels=c("WT", "KO")) |
| 134 | mydate <- factor(target$date, levels=c("old", "new")) |
| 135 | Design <- model.matrix(~mydate+genotype) |
| 136 | colnames(Design) |
| 137 | # [1] "(Intercept)" "mydatenew" "genotypeKO" |
137 | | Y2 <- calcNormFactors(Y) # Y is the DGEList |
138 | | Y2 <- estimateGLMCommonDisp(Y2, Design, verbose=TRUE) |
139 | | Y2 <- estimateGLMTrendedDisp(Y2, Design) |
140 | | Y2 <- estimateGLMTagwiseDisp(Y2, Design) |
141 | | Fit <- glmFit(Y2, Design) |
142 | | Lrt <- glmLRT(Fit, coef="genotypeKO") # coef is pointed to the column name in Design |
| 139 | Y2 <- calcNormFactors(Y) # Y is the DGEList |
| 140 | Y2 <- estimateGLMCommonDisp(Y2, Design, verbose=TRUE) |
| 141 | Y2 <- estimateGLMTrendedDisp(Y2, Design) |
| 142 | Y2 <- estimateGLMTagwiseDisp(Y2, Design) |
| 143 | Fit <- glmFit(Y2, Design) |
| 144 | Lrt <- glmLRT(Fit, coef="genotypeKO") # where 'coef' points to the column name in 'Design' |