[BioC] how to design matrix by edgeR

Gordon K Smyth smyth at wehi.EDU.AU
Tue May 22 06:41:29 CEST 2012


Dear Shan Gao,

I always advise people to create a "targets file", laying out the 
treatments associated with each sample, rather than trying to create 
factors on the fly in R.  This can often avoid problems that might 
otherwise not be noticed.

For example, the factors you've created below are of different lengths, 
and I suspect you mean "0h" rather than "oh".

Assuming you fix this, a quick way to create a design matrix would be:

   time <- factor(time, levels=c("0h","6h","12h","18h","24h","36h","48h"))
   design <- model.matrix(~time+time:treatment)

This will create a design matrix with 14 columns.  Coefficients 8-14 test 
for treatment effects at each time.

   y <- estimateGLMCommonDisp(y, design)
   y <- estimateGLMTrendedDisp(y, design)
   y <- estimateGLMTagwiseDisp(y, design)
   fit <- glmFit(y, design)

To test for treatment effect at time 0:

   lrt0 <- glmLRT(y,fit,coef=8)
   topTags(lrt0)

To test for treatment effect at time 1:

   lrt1 <- glmLRT(y,fit,coef=9)
   topTags(lrt1)

and so on.

I don't know of a good reference on using model.matrix(), except perhaps 
for the limma User's Guide.  A very brief introduction to using model 
formula in R is given in Section 11 of the manual "An Introduction to R" 
that comes with R.

Best wishes
Gordon

---------------------------------------------
Professor Gordon K Smyth,
Bioinformatics Division,
Walter and Eliza Hall Institute of Medical Research,
1G Royal Parade, Parkville, Vic 3052, Australia.
Tel: (03) 9345 2326, Fax (03) 9347 0852,
smyth at wehi.edu.au
http://www.wehi.edu.au
http://www.statsci.org/smyth

On Sun, 20 May 2012, wang peter wrote:

> Dear Gordon,
> thank you very much. i want to find genes are DE at
> each time vs 0h, adjusting for control differences?
>
>
> i know i should do such work:
> treatment=factor(c(rep('treated',24),rep('control',11)))
> time=factor( c('oh','oh','oh','6h','6h','6h','6h','12h',
> '12h','12h','12h','18h','18h','18h','18h','24h','24h','24h','36h','36h','36h','48h','48h','48h','oh',
>         'oh','oh','6h','12h','18h','24h','36h','48h'))
>
> but i donot understand how to design the matrix?
> design <- model.matrix(~treatment+tissue)?
> design <- model.matrix(~treatment*tissue)
>
> do you have some reference to tell me how to use the model.matrix function
>
> thank you very much
>
>
> -- 
> shan gao
> Room 231(Dr.Fei lab)
> Boyce Thompson Institute
> Cornell University
> Tower Road, Ithaca, NY 14853-1801
> Office phone: 1-607-254-1267(day)
> Official email:sg839 at cornell.edu
> Facebook:http://www.facebook.com/profile.php?id=100001986532253
>

______________________________________________________________________
The information in this email is confidential and intend...{{dropped:4}}



More information about the Bioconductor mailing list