Dear Gordon 
Thank you for your help.
Following the 3.3.2 section of the user guide:

#set the references
targets$Age <- relevel(targets$Age, ref="Young")
targets$Genotype <- relevel(targets$Genotype, ref="Wt")

#set design1
design1 <- model.matrix(~ Genotype + Genotype:Age, data=targets)
> colnames(design1)
[1] "(Intercept)"           "GenotypeMutant"        "GenotypeWt:AgeOld"     "GenotypeMutant:AgeOld"
#interpretation
"GenotypeWt:AgeOld" (coefficient 3) represents the genes that change with age in Wt.
"GenotypeMutant:AgeOld" (coefficient 4) represents the genes that change with age in Mutant. 

# To test for interaction, I thought I should follow section 3.3.4 of the user guide:
design2 <- model.matrix(~ Genotype * Age, data=targets)
> colnames(design2)
[1] "(Intercept)"           "GenotypeMutant"        "AgeOld"                "GenotypeMutant:AgeOld"

"GenotypeMutant:AgeOld" (coefficient 4) represents represents the interaction of Genotype and Age

I am doing this right?
Thanks
Joseph






On Sunday, January 12, 2014 3:24 PM, Gordon K Smyth <smyth@wehi.EDU.AU> wrote:
 
Dear Joseph,
>
>You have not fitted the right model.  You need
>
>    ~ Genotype + Genotype:Age
>
>instead of
>
>    ~ Age + Age:Genotype
>
>You can follow the section 3.3.2 in the edgeR User's Guide.
>
>Best wishes
>Gordon
>
>> Date: Sat, 11 Jan 2014 12:36:07 -0800 (PST)
>> From: joseph <jdsandjd@yahoo.com>
>> To: "bioconductor@r-project.org" <bioconductor@r-project.org>
>> Subject: [BioC] EdgeR design question?
>>
>> Hi
>> I am using edgeR to analyse an RNA-seq experiment with two factors, age (Young, Old) and genotype (Wt, Mutant).
>>> targets
>>            Age Genotype
>> Sample1  Young       Wt
>> Sample2  Young       Wt
>> Sample3  Young       Wt
>> Sample4  Young   Mutant
>> Sample5  Young   Mutant
>> Sample6  Young   Mutant
>> Sample7    Old       Wt
>> Sample8    Old       Wt
>> Sample9    Old       Wt
>> Sample10   Old   Mutant
>> Sample11   Old   Mutant
>> Sample12   Old   Mutant
>>
>> I know from previous experiments that the age effect is different between Wt and Mutant genotypes.
>> I would like to find:
>> 1. genes that change with age in Wt.
>> 2. genes that change with age in Mutant.
>> 3. genes that change with age differently between the genotypes (interaction).
>>
>> Can the following approach answer these questions?
>>
>> targets$Age <- relevel(targets$Age, ref="Young")
>> targets$Genotype <- relevel(targets$Genotype, ref="Wt")
>> design1 <- model.matrix(~Age + Age:Genotype, data=targets)
>>> design1
>>          (Intercept) AgeOld AgeYoung:GenotypeMutant AgeOld:GenotypeMutant
>> Sample1            1      0                       0                     0
>> Sample2            1      0                       0                     0
>> Sample3            1      0                       0                     0
>> Sample4            1      0                       1                     0
>> Sample5            1      0                       1                     0
>> Sample6            1      0                       1                     0
>> Sample7            1      1                       0                     0
>> Sample8            1      1                       0                     0
>> Sample9            1      1                       0                     0
>> Sample10           1      1                       0                     1
>> Sample11           1      1                       0                     1
>> Sample12           1      1                       0                     1
>> attr(,"assign")
>> [1] 0 1 2 2
>> attr(,"contrasts")
>> attr(,"contrasts")$Age
>> [1] "contr.treatment"
>> attr(,"contrasts")$Genotype
>> [1] "contr.treatment"
>>
>>
>> I think coef=4 in design1 represents the genes that change with age in Mutant; but I don't know what coefficient represents the genes that change with age in Wt.
>>
>> design2 <- model.matrix(~Age*Genotype, data=targets)
>>> design2
>>          (Intercept) AgeOld GenotypeMutant AgeOld:GenotypeMutant
>> Sample1            1      0              0                     0
>> Sample2            1      0              0                     0
>> Sample3            1      0              0                     0
>> Sample4            1      0              1                     0
>> Sample5            1      0              1                     0
>> Sample6            1      0              1                     0
>> Sample7            1      1              0                     0
>> Sample8            1      1              0                     0
>> Sample9            1      1              0                     0
>> Sample10           1      1              1                     1
>> Sample11           1      1              1                     1
>> Sample12           1      1              1                     1
>> attr(,"assign")
>> [1] 0 1 2 3
>> attr(,"contrasts")
>> attr(,"contrasts")$Age
>> [1] "contr.treatment"
>> attr(,"contrasts")$Genotype
>> [1] "contr.treatment"
>>
>> coef=4 in design2 represents the interaction of age and genotype.
>>
>> Thank you for your help
>> Joseph
>>
>>
>>> sessionInfo()
>> R version 3.0.2 Patched (2013-10-28 r64119)
>> Platform: x86_64-apple-darwin10.8.0 (64-bit)
>>
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base    
>>
>> other attached packages:
>> [1] edgeR_3.4.2  limma_3.18.7
>>
>> loaded via a namespace (and not attached):
>> [1] tools_3.0.2
>
>______________________________________________________________________
>The information in this email is confidential and inten...{{dropped:10}}

