Skip to content

Latest commit

 

History

History
282 lines (263 loc) · 9.53 KB

exploring_design_matrices.md

File metadata and controls

282 lines (263 loc) · 9.53 KB

Exploring design matrices

There are 8 Ptids and 2 Visits per Ptid (Enrollment and Visit2)

Here is what the design matrix looks like for the design with no interecept,

~0 + Visit + Ptid

Why are there only 7 Ptids shown? I think because the first level of each parameter is absorbed into the intercept and the because I am using an additive model, the coefficients for the Visits are assuming that the effect is the same for all patients. See here: According to http://genomicsclass.github.io/book/pages/expressing_design_formula.html, and replace "Visit" with "Diet" and "Ptid" for "Sex"

Rows 15 and 16 have zeros in all columns except for the first two, which I assume means that they are representing the average of the expression for all Ptids for those visits??

Because there is information on both Visits and I want to compare the average results from the two visits, I will make a contrasts matrix:

contrasts <- makeContrasts(Visit2vsEnrollment = VisitVisit2-VisitEnrollment, levels = no_int_design)

and then fit the model to the contrast matrix.

##    VisitEnrollment VisitVisit2 PtidCM2299 PtidDA2301 PtidJC2300 PtidJM2297
## 1                1           0          0          0          0          1
## 2                0           1          0          0          0          1
## 3                1           0          0          0          0          0
## 4                0           1          0          0          0          0
## 5                1           0          1          0          0          0
## 6                0           1          1          0          0          0
## 7                1           0          0          0          1          0
## 8                0           1          0          0          1          0
## 9                1           0          0          1          0          0
## 10               0           1          0          1          0          0
## 11               1           0          0          0          0          0
## 12               0           1          0          0          0          0
## 13               1           0          0          0          0          0
## 14               0           1          0          0          0          0
## 15               1           0          0          0          0          0
## 16               0           1          0          0          0          0
##    PtidLS2298 PtidRC2302 PtidSN2303
## 1           0          0          0
## 2           0          0          0
## 3           1          0          0
## 4           1          0          0
## 5           0          0          0
## 6           0          0          0
## 7           0          0          0
## 8           0          0          0
## 9           0          0          0
## 10          0          0          0
## 11          0          1          0
## 12          0          1          0
## 13          0          0          1
## 14          0          0          1
## 15          0          0          0
## 16          0          0          0
## attr(,"assign")
## [1] 1 1 2 2 2 2 2 2 2
## attr(,"contrasts")
## attr(,"contrasts")$Visit
## [1] "contr.treatment"
## 
## attr(,"contrasts")$Ptid
## [1] "contr.treatment"

There are 8 Ptids and 2 Visits per Ptid (Enrollment and Visit2)

Here is what the design matrix looks like for the design with intercept, ~Visit + Ptid

I think the intercept here represents the average of Enrollment and the coefficent "VisitVisit2" represents the increase in the average of Visit2 over Enrollment. Because this comparison is already made with this design, I don't need to do a contrast matrix.

##    (Intercept) VisitVisit2 PtidCM2299 PtidDA2301 PtidJC2300 PtidJM2297
## 1            1           0          0          0          0          1
## 2            1           1          0          0          0          1
## 3            1           0          0          0          0          0
## 4            1           1          0          0          0          0
## 5            1           0          1          0          0          0
## 6            1           1          1          0          0          0
## 7            1           0          0          0          1          0
## 8            1           1          0          0          1          0
## 9            1           0          0          1          0          0
## 10           1           1          0          1          0          0
## 11           1           0          0          0          0          0
## 12           1           1          0          0          0          0
## 13           1           0          0          0          0          0
## 14           1           1          0          0          0          0
## 15           1           0          0          0          0          0
## 16           1           1          0          0          0          0
##    PtidLS2298 PtidRC2302 PtidSN2303
## 1           0          0          0
## 2           0          0          0
## 3           1          0          0
## 4           1          0          0
## 5           0          0          0
## 6           0          0          0
## 7           0          0          0
## 8           0          0          0
## 9           0          0          0
## 10          0          0          0
## 11          0          1          0
## 12          0          1          0
## 13          0          0          1
## 14          0          0          1
## 15          0          0          0
## 16          0          0          0
## attr(,"assign")
## [1] 0 1 2 2 2 2 2 2 2
## attr(,"contrasts")
## attr(,"contrasts")$Visit
## [1] "contr.treatment"
## 
## attr(,"contrasts")$Ptid
## [1] "contr.treatment"

Here are results from fitting the model using decideTests(method = "global") vs decideTests(method = "separate") for the design without an intercept.

variable down up
Visit2vsEnrollment 70 11
variable down up
Visit2vsEnrollment 70 11

Here are results from fitting the model using decideTests(method = "global") vs decideTests(method = "separate") for the design with an intercept.

variable down up
(Intercept) 0 20505
VisitVisit2 70 11
PtidCM2299 281 218
PtidDA2301 27 26
PtidJC2300 65 59
PtidJM2297 41 24
PtidLS2298 153 141
PtidRC2302 41 37
PtidSN2303 22 14
variable down up
(Intercept) 0 20505
VisitVisit2 121 55
PtidCM2299 593 463
PtidDA2301 141 96
PtidJC2300 292 204
PtidJM2297 258 213
PtidLS2298 404 421
PtidRC2302 216 224
PtidSN2303 174 195