Hi
I think this is correct, but it would be good if some one could just verify this. I am comparing a group of patients before and after vaccination at a number of time points using limma.
PATIENTS <- factor(des$PATIENT_ID) # this is just a list of patient IDs
design <- model.matrix(~0+des$VISIT+PATIENTS) # visit refers to the patient visit number or time point
colnames(design)[1:5] <- c('Visit1', 'Visit2', 'Visit4', 'Visit6', 'Visit8')
matrix <- data.matrix(data3) # this is array data
fit <- lmFit(matrix, design)
contrast.matrix <- makeContrasts(Visit1-Visit2, Visit2-Visit4, Visit4-Visit6, Visit6-Visit8, levels=design)
fit2 <- contrasts.fit(fit, contrast.matrix)
fit2 <- eBayes(fit2)
top2 <- topTable(fit2,coef=1,number=Inf,sort.by="P")
Then I am just varying the coef parameter to select different contrasts.
Thanks,
Chris
Hi Chris,
just as a side note: instead of
you can also specify the name of the contrasts directly like so:
I usually prefer to do it this way, as it avoids mistakes and makes the code more readable.