Hey everyone!
I am working with methylation data (Illumina EPIC Methylation array) and I was wondering how I should go about designing my linear model matrix to observe differential methylation in the data.
I am performing a basic Case vs. Control study where I am comparing the control methylation to the case and observing the results.
Currently, I am using this line of code to design the matrix.
status <- factor(targets$Status)
design <- model.matrix(~status, data=targets)
colnames(design) <- c(levels(status))
design
Case Control
1 1 0
2 1 0
3 1 0
4 1 1
5 1 1
attr(,"assign")
[1] 0 1
attr(,"contrasts")
attr(,"contrasts")$status
[1] "contr.treatment"
After this, I create a "contrast matrix" to observe pairwise contrasts in the data set but I am not sure if a contrast matrix is even necessary for this as we are just comparing Case vs. Control.
contMatrix <- makeContrasts(Control - Case,levels=design)
contMatrix
Contrasts
Levels Control - Case
Case -1
Control 1
I would really appreciate it if anyone could point me in the right direction on how I should be going about designing the matrix. I would also appreciate if anyone could help me design the matrix when we have multiple factors like Age, Sex etc. along with the Case - Control status.
Thank you.
Hello, in the case you have only a simple comparison case-control you don't need a constrast matrix indeed. However you need to pay attention to your design matrix as you renamed the intercept column with "Case" and your variable of interest with "Control" and you are confusing the principles of linear regression; Everything about design matrix is very well explained here paragraph 4: https://bioconductor.org/packages/release/workflows/vignettes/RNAseq123/inst/doc/designmatrices.html#design-matrices-with-and-without-intercept-term