Entering edit mode
8.2 years ago
alexvpickering
▴
60
I have a design similar to this:
Sample Diet Tissue Scan Date Individual
1 AL liver a 1
2 AL liver b 2
3 CR liver a 3
4 CR liver b 4
5 AL heart a 2
6 AL heart b 1
7 CR heart a 4
8 CR heart b 3
I want to perform the following contrasts:
CR.liver - AL.liver
, CR.heart - AL.heart
I want to correct (block) for Scan and Individual if possible. How do I approach this?
I found a similar example here that I have tried to adjust to my case. This has let me to make the following design matrix:
AL.heart AL.liver CR.heart CR.liver dateb ind2 ind3 ind4
1 0 1 0 0 0 0 0 0
2 0 1 0 0 1 1 0 0
3 0 0 0 1 0 0 1 0
4 0 0 0 1 1 0 0 1
5 1 0 0 0 0 1 0 0
6 1 0 0 0 1 0 0 0
7 0 0 1 0 0 0 0 1
8 0 0 1 0 1 0 1 0
and this contrast matrix:
CR.liver - AL.liver CR.heart - AL.heart
AL.heart 0 -1
AL.liver -1 0
CR.heart 0 1
CR.liver 1 0
dateb 0 0
ind2 0 0
ind3 0 0
ind4 0 0
then run the fit:
fit <- contrasts.fit (lmFit(exprs(eset), model), contrast_matrix)
I'm unclear if the above approach correctly blocks for scan-date/individual? Suggestions?
You can't block for scan and individual at the same time, they're confounded.
good catch: edited to fix
Can you show us the code you used to create your
model.matrix
?Sure:
Edited to produce above output (also edited from original)
What "doesn't work"? Without hearing your answer, it appears that you do not have enough samples to perform your analysis. As specified, you have no replication (no residual degrees-of-freedom).
The above is an example (not real data) that I am using in order to learn how to specify a design matrix and contrast matrix in order to perform the desired contrasts while controlling for batch/individual effects (the limma guide doesn't cover this setup).
It looks like that matrix is still rank deficient. I don't think you have enough patients to do the blocking and still have residual degrees of freedom. If you want to, you could post this on cross validated and see if someone can come up with a full rank model matrix for you. Your contrast is fine otherwise.
Data is an example. Imagine that there are 30 more samples.
Ah, as long as it's not rank deficient then that sort of setup looks fine.