I am running an experiment where we have samples from a number of individuals, pre and post treatment. These individuals were then also grouped according to features found in the DNA. So, overall the design looks like this. I named pre treatment "before" so that DESeq2 will automatically take it as the first level in the factor. All three groups are of interest to compare to the other two (none of the 3 is a control).
Sample Patient Treatment Group 1 PatientA-pre PatientA before Group3 2 PatientA-post PatientA post Group3 3 PatientB-pre PatientB before Group3 4 PatientB-post PatientB post Group3 5 PatientC-pre PatientC before Group1 6 PatientC-post PatientC post Group1 7 PatientD-pre PatientD before Group3 8 PatientD-post PatientD post Group3 9 PatientE-pre PatientE before Group1 10 PatientE-post PatientE post Group1 11 PatientF-pre PatientF before Group1 12 PatientF-post PatientF post Group1 13 PatientG-pre PatientG before Group1 14 PatientG-post PatientG post Group1 15 PatientH-pre PatientH before Group3 16 PatientH-post PatientH post Group3 17 PatientI-pre PatientI before Group1 18 PatientI-post PatientI post Group1 19 PatientJ-pre PatientJ before Group1 20 PatientJ-post PatientJ post Group1 21 PatientK-pre PatientK before Group1 22 PatientK-post PatientK post Group1 23 PatientL-pre PatientL before Group2 24 PatientL-post PatientL post Group2 25 PatientM-pre PatientM before Group2 26 PatientM-post PatientM post Group2 27 PatientN-pre PatientN before Group2 28 PatientN-post PatientN post Group2 29 PatientO-pre PatientO before Group2 30 PatientO-post PatientO post Group2 31 PatientP-pre PatientP before Group2 32 PatientP-post PatientP post Group2 33 PatientQ-pre PatientQ before Group1 34 PatientQ-post PatientQ post Group1 35 PatientR-pre PatientR before Group2 36 PatientR-post PatientR post Group2 37 PatientS-pre PatientS before Group3 38 PatientS-post PatientS post Group3
We are interested in determining the interaction between groups and treatment. In other words, do certain genes have a different change between pre and post depending on group?
I know if I did not have to control for individual (Patient), I would run like so (maybe afterward also re-running with group1 not as the first level so can test that):
dds <- DESeq(DESeqDataSetFromMatrix(countData=featureCounts_pairs,colData=design_table,design=~Treatment+Group+Treatment:Group)) results_group2 <- results(dds,name="Treatmentpost.GroupGroup2") results_group3 <- results(dds,name="Treatmentpost.GroupGroup3")
However, I would also like to control for patient differences within each group. So that if a gene goes up or down consistently between pre and post within all patients of one group but not the other, it will show up, even if there is a lot of variability between all "before" or all "post" samples within each group.
Adding "+Patient" to the design above does not solve this issue, as then I get the "model matrix not full rank" error since each of the two samples for the same patient are also in the same group.