Hello, community
I have a design initially designed to make comparisons both within (before, during, after treatment) subjects and between subjects (disease, control) possible. However, due to difficulties in obtaining high quality samples, the dataset is now more limiting.
Q: Can I perform within-subjects and then between subjects analyses separately, by fitting two different models with two distinct design matrices?
I mean, to get between-subject comparisons:
model.matrix(~Period+libSize+Sex+Class)
where Class = {control, disease}
and treating Period = {Before, During, After}
as block (individuals repeat across Periods because of repeated measures in 3 occasions).
And for within-subject comparisons:
model.matrix(~Patient+libSize+Sex+Period)
where Patient = {1 ... n}
factor specifying individuals.
I managed to do it on DESEq2, limma-voom and edgeR, but I'm not sure if this is allowed, since ideally I'd fit a model to allow both within and between subjects at once by treating Patient as random effect variable (duplicateCorrelation()
in limma).
Patient Period Class Sex Batch run libSize
<fct> <fct> <fct> <fct> <fct> <fct> <fct>
1 5129 Before LL M 08.03.2018am 17 upto17
2 5129 During LL M 09.03.2018am 13 upto17
3 5129 During LL M 08.03.2018am 12 upto17
4 5129 Finished LL M 09.03.2018am 17 upto32
5 5129 Finished LL M 08.03.2018pm 15 upto32
6 5130 Before BT F 08.03.2018am 12 upto17
7 5130 During BT F 08.03.2018pm 16 upto17
8 5130 Finished BT F 08.03.2018am_pm 15 upto17
9 5139 Before LL M 08.03.2018am 16 upto32
10 5139 Finished LL M 09.03.2018am 12 upto32
11 5139 Finished LL M 08.03.2018pm 2 upto17
12 5140 Before BT M 08.03.2018am 18 upto17
13 5140 During BT M 08.03.2018pm 18 upto32
14 5140 Finished BT M 09.03.2018am 18 upto32
15 5141 Before BT F 09.03.2018am 18 upto32
16 5141 During BT F 09.03.2018am 17 upto17
17 5141 Finished BT F 09.03.2018am 11 upto32
18 5148 Before BT F 08.03.2018am 14 upto32
19 5148 Finished BT F 08.03.2018pm 18 upto17
20 5151 Finished BT F 08.03.2018pm 14 upto17
21 5160 Before LL M 08.03.2018am 1 upto17
22 5160 During LL M 08.03.2018pm 17 upto17
23 5160 Finished LL M 08.03.2018pm 16 upto17
24 5160 Finished LL M 09.03.2018am 2 upto32
25 5162 Before BT M 08.03.2018am 4 upto32
26 5162 Finished BT M 09.03.2018am 18 upto32
27 5164 Before LL M 08.03.2018am 13 upto17
28 5164 Finished LL M 08.03.2018pm 10 upto17
29 5164 During LL M 09.03.2018am 18 upto17
30 5164 Finished LL M 08.03.2018pm 17 upto32
31 5168 Before LL M 09.03.2018am 18 upto17
32 5168 During LL M 09.03.2018am 13 upto32
33 5168 Finished LL M 09.03.2018am 18 upto17
34 5170 Before LL M 08.03.2018am 12 upto17
35 5170 During LL M 09.03.2018am 15 upto17
36 5170 Finished LL M 08.03.2018pm 6 upto32
37 5170 Finished LL M 08.03.2018pm 5 upto17
38 5188 Before BT F 08.03.2018pm 16 upto32
39 5188 During BT F 09.03.2018am 17 upto32
40 5188 Finished BT F 09.03.2018am 18 upto17
41 5194 Before BT M 08.03.2018pm 7 upto32
42 5194 During BT M 09.03.2018am 9 upto32
43 5194 Finished BT M 08.03.2018pm 8 upto17
44 5195 Before BT M 08.03.2018am 17 upto17
45 5195 During BT M 09.03.2018am 18 upto17
46 5195 Finished BT M 09.03.2018am 17 upto17
47 5203 Before BT M 08.03.2018am 17 upto32
48 5203 Finished BT M 09.03.2018am 18 upto17
49 5204 Before BT F 08.03.2018am 1 upto17
50 5204 Finished BT F 08.03.2018am 18 upto17
51 5208 Before BT M 09.03.2018am 18 upto32
52 5208 During BT M 09.03.2018am 15 upto32
53 5208 Finished BT M 08.03.2018pm 8 upto17
54 5213 Before BT M 08.03.2018am 17 upto32
55 5213 During BT M 09.03.2018am 15 upto17
56 5213 Finished BT M 08.03.2018pm 11 upto32
57 5215 Before BT F 08.03.2018am 17 upto17
58 5215 During BT F 09.03.2018am 18 upto17
59 5219 Before BT F 08.03.2018am 17 upto32
60 5219 During BT F 09.03.2018am 14 upto32
61 5219 Finished BT F 08.03.2018pm 18 upto17
Thank you, Gordon. There was a mistake in the code for within subject analysis. I fixed it.
Ignoring Class differences, is there a problem in doing the within subjects analysis only? To get DEG for treatment stages only?
You can certainly do a within subjects analysis if you wish.