Limma-include interaction term
2
1
Entering edit mode
yao chen ▴ 210
@yao-chen-5205
Last seen 10.2 years ago
Dear All, I try to find differential expressed genes between treat and untreated samples, and also I want to include the age effects. The design matrix is like this: treat untreated age 1 0 30 0 1 40 1 0 35 The "treat" is factor, but "age" is continuous. How can I set the "cont.matrix"? Thanks, Jack [[alternative HTML version deleted]]
• 3.3k views
ADD COMMENT
0
Entering edit mode
@james-w-macdonald-5106
Last seen 1 hour ago
United States
Hi Jack, On 6/12/2012 10:10 AM, Yao Chen wrote: > Dear All, > > I try to find differential expressed genes between treat and untreated > samples, and also I want to include the age effects. > > The design matrix is like this: > > treat untreated age > 1 0 30 > 0 1 40 > 1 0 35 > > > The "treat" is factor, but "age" is continuous. How can I set the > "cont.matrix"? Pretty much just like you (or at least I) would expect: contrast <- makeContrasts(treat - untreat, levels = design) But note that the design you are specifying allows different intercepts, but the slope is assumed to be the same for treated and untreated. If you want to allow different slopes as well, you need to introduce an age:treatment interaction term. Here I am assuming you have more than three samples. Best, Jim > > Thanks, > > Jack > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD COMMENT
0
Entering edit mode
Thanks, James How to include "age:treatment" interaction in the design matrix? Jack 2012/6/12 James W. MacDonald <jmacdon@uw.edu> > Hi Jack, > > > On 6/12/2012 10:10 AM, Yao Chen wrote: > >> Dear All, >> >> I try to find differential expressed genes between treat and untreated >> samples, and also I want to include the age effects. >> >> The design matrix is like this: >> >> treat untreated age >> 1 0 30 >> 0 1 40 >> 1 0 35 >> >> >> The "treat" is factor, but "age" is continuous. How can I set the >> "cont.matrix"? >> > > Pretty much just like you (or at least I) would expect: > > contrast <- makeContrasts(treat - untreat, levels = design) > > But note that the design you are specifying allows different intercepts, > but the slope is assumed to be the same for treated and untreated. If you > want to allow different slopes as well, you need to introduce an > age:treatment interaction term. Here I am assuming you have more than three > samples. > > Best, > > Jim > > > >> Thanks, >> >> Jack >> >> [[alternative HTML version deleted]] >> >> ______________________________**_________________ >> Bioconductor mailing list >> Bioconductor@r-project.org >> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https: stat.e="" thz.ch="" mailman="" listinfo="" bioconductor=""> >> Search the archives: http://news.gmane.org/gmane.** >> science.biology.informatics.**conductor<http: news.gmane.org="" gmane="" .science.biology.informatics.conductor=""> >> > > -- > James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > [[alternative HTML version deleted]]
ADD REPLY
0
Entering edit mode
Hi Jack, The conventional method is to use the model.matrix() function. I have no idea what your data look like, so here is a random example: > treat <- factor(rep(0:1, each = 5)) > treat [1] 0 0 0 0 0 1 1 1 1 1 Levels: 0 1 > age <- sample(25:35, 10, TRUE) > age [1] 32 30 32 35 29 26 27 25 33 34 > model.matrix(~treat*age) (Intercept) treat1 age treat1:age 1 1 0 32 0 2 1 0 30 0 3 1 0 32 0 4 1 0 35 0 5 1 0 29 0 6 1 1 26 26 7 1 1 27 27 8 1 1 25 25 9 1 1 33 33 10 1 1 34 34 attr(,"assign") [1] 0 1 2 3 attr(,"contrasts") attr(,"contrasts")$treat [1] "contr.treatment" Note that this uses a different parameterization. In this case the treat1 coefficient is the difference between the treated and untreated samples (so you wouldn't specify a contrasts.matrix, you just do lmFit() and then eBayes()). The treat1:age coefficient captures the difference between the slopes for the treated and untreated samples. So topTable(fit2, coef=2) gives you genes that are differentially expressed between treated and untreated and topTable(fit2, coef=4) gives you genes where the change in expression at different ages varies between treated and untreated subjects. Best, Jim On 6/12/2012 12:57 PM, Yao Chen wrote: > Thanks, James > > How to include "age:treatment" interaction in the design matrix? > > Jack > > 2012/6/12 James W. MacDonald <jmacdon at="" uw.edu="" <mailto:jmacdon="" at="" uw.edu="">> > > Hi Jack, > > > On 6/12/2012 10:10 AM, Yao Chen wrote: > > Dear All, > > I try to find differential expressed genes between treat and > untreated > samples, and also I want to include the age effects. > > The design matrix is like this: > > treat untreated age > 1 0 30 > 0 1 40 > 1 0 35 > > > The "treat" is factor, but "age" is continuous. How can I set the > "cont.matrix"? > > > Pretty much just like you (or at least I) would expect: > > contrast <- makeContrasts(treat - untreat, levels = design) > > But note that the design you are specifying allows different > intercepts, but the slope is assumed to be the same for treated > and untreated. If you want to allow different slopes as well, you > need to introduce an age:treatment interaction term. Here I am > assuming you have more than three samples. > > Best, > > Jim > > > > Thanks, > > Jack > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org <mailto:bioconductor at="" r-project.org=""> > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > > > -- > James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD REPLY
0
Entering edit mode
yao chen ▴ 210
@yao-chen-5205
Last seen 10.2 years ago
I am confused. If I want to get differential expressed genes between treatment and control with age interaction. Which one should I use :topTable (fit2, coef=2) or topTable (fit2, coef=4) . Thanks, Jack 2012/6/12 James W. MacDonald <jmacdon@uw.edu> > Hi Jack, > > > On 6/12/2012 1:54 PM, Yao Chen wrote: > >> Thanks James. That's exactly what I want to know. >> >> But I am not sure I fully understand the differential expressed genes in >> topTable. For (fit2, coef=2), did I get the genes without considering >> treat:age interaction, as my previous design matrix . And (fit2, coef=4) >> gives me the genes considering treat:age interation. >> > > No. When you fit a model with a bunch of coefficients, a given coefficient > measures the marginal effect of the coefficient after accounting for all > other coefficients in the model. > > In conventional linear modeling (where you aren't fitting thousands of > models at once), you would probably fit a model with and without the > interaction term and then test to see if the interaction term is > significant. This is difficult to do in the context of a microarray > analysis, so people generally just throw a bunch of coefficients in a model > and look for significant genes. > > If you then wanted to do some other tests with a subset of your genes I > suppose you could, but people generally pick 'interesting' genes and go to > functional studies. > > Best, > > Jim > > > >> Jack >> >> 2012/6/12 James W. MacDonald <jmacdon@uw.edu <mailto:jmacdon@uw.edu="">> >> >> Hi Jack, >> >> The conventional method is to use the model.matrix() function. I >> have no idea what your data look like, so here is a random example: >> >> > treat <- factor(rep(0:1, each = 5)) >> > treat >> [1] 0 0 0 0 0 1 1 1 1 1 >> Levels: 0 1 >> > age <- sample(25:35, 10, TRUE) >> > age >> [1] 32 30 32 35 29 26 27 25 33 34 >> > model.matrix(~treat*age) >> (Intercept) treat1 age treat1:age >> 1 1 0 32 0 >> 2 1 0 30 0 >> 3 1 0 32 0 >> 4 1 0 35 0 >> 5 1 0 29 0 >> 6 1 1 26 26 >> 7 1 1 27 27 >> 8 1 1 25 25 >> 9 1 1 33 33 >> 10 1 1 34 34 >> attr(,"assign") >> [1] 0 1 2 3 >> attr(,"contrasts") >> attr(,"contrasts")$treat >> [1] "contr.treatment" >> >> Note that this uses a different parameterization. In this case the >> treat1 coefficient is the difference between the treated and >> untreated samples (so you wouldn't specify a contrasts.matrix, you >> just do lmFit() and then eBayes()). The treat1:age coefficient >> captures the difference between the slopes for the treated and >> untreated samples. >> >> So topTable(fit2, coef=2) gives you genes that are differentially >> expressed between treated and untreated and topTable(fit2, coef=4) >> gives you genes where the change in expression at different ages >> varies between treated and untreated subjects. >> >> Best, >> >> Jim >> >> >> >> >> >> On 6/12/2012 12:57 PM, Yao Chen wrote: >> >> Thanks, James >> >> How to include "age:treatment" interaction in the design matrix? >> >> Jack >> >> 2012/6/12 James W. MacDonald <jmacdon@uw.edu>> <mailto:jmacdon@uw.edu> <mailto:jmacdon@uw.edu>> >> <mailto:jmacdon@uw.edu>>> >> >> >> Hi Jack, >> >> >> On 6/12/2012 10:10 AM, Yao Chen wrote: >> >> Dear All, >> >> I try to find differential expressed genes between >> treat and >> untreated >> samples, and also I want to include the age effects. >> >> The design matrix is like this: >> >> treat untreated age >> 1 0 30 >> 0 1 40 >> 1 0 35 >> >> >> The "treat" is factor, but "age" is continuous. How >> can I set the >> "cont.matrix"? >> >> >> Pretty much just like you (or at least I) would expect: >> >> contrast <- makeContrasts(treat - untreat, levels = design) >> >> But note that the design you are specifying allows different >> intercepts, but the slope is assumed to be the same for treated >> and untreated. If you want to allow different slopes as >> well, you >> need to introduce an age:treatment interaction term. Here I am >> assuming you have more than three samples. >> >> Best, >> >> Jim >> >> >> >> Thanks, >> >> Jack >> >> [[alternative HTML version deleted]] >> >> ______________________________**_________________ >> Bioconductor mailing list >> Bioconductor@r-project.org <mailto:bioconductor@r-**project.org<bioconductor@r-project.org> >> > >> <mailto:bioconductor@r-**project.org <bioconductor@r-project.org=""> >> >> <mailto:bioconductor@r-**project.org <bioconductor@r-project.org=""> >> >> >> >> https://stat.ethz.ch/mailman/**listinfo/bioconductor<https: stat.ethz.ch="" mailman="" listinfo="" bioconductor=""> >> Search the archives: >> http://news.gmane.org/gmane.**science.biology.informatics.** >> conductor<http: news.gmane.org="" gmane.science.biology.informatics.c="" onductor=""> >> >> >> -- James W. MacDonald, M.S. >> Biostatistician >> University of Washington >> Environmental and Occupational Health Sciences >> 4225 Roosevelt Way NE, # 100 >> Seattle WA 98105-6099 >> >> >> >> -- James W. MacDonald, M.S. >> Biostatistician >> University of Washington >> Environmental and Occupational Health Sciences >> 4225 Roosevelt Way NE, # 100 >> Seattle WA 98105-6099 >> >> >> > -- > James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > [[alternative HTML version deleted]]
ADD COMMENT
0
Entering edit mode
Hi Jack, On 6/12/2012 2:22 PM, Yao Chen wrote: > I am confused. If I want to get differential expressed genes between > treatment and control with age interaction. Which one should I use > :topTable (fit2, coef=2) or topTable (fit2, coef=4) . I have no idea what you are asking, so I will just try to restate things. If you fit a model with treatment and age, then any genes with a significant treatment - control contrast implies that after adjusting for age of the subjects, there is a difference in expression of that gene between treated and control subjects. One way to conceptualize this model is that you are fitting two lines to your data, one for treated and one for control, but you are constraining these lines to have the same slope (e.g., they are parallel). If you fit a model that includes a treatment:age interaction, you are doing the same exact thing, only now you are fitting two lines and allowing the slopes to vary as well. So the example I gave you, coef 2 tells you which genes are differentially expressed between treatment and control, after adjusting for age of the subjects and allowing the slopes to vary. Coef 4 tells you whether or not the slopes are different for the treated and control subjects. The reason coef 4 might be interesting is because it will allow you to find genes that (as an example) are expressed at the same level in untreated subjects regardless of age, but in treated subjects the expression increases dramatically as a function of age. Best, Jim > > Thanks, > > Jack > > 2012/6/12 James W. MacDonald <jmacdon at="" uw.edu="" <mailto:jmacdon="" at="" uw.edu="">> > > Hi Jack, > > > On 6/12/2012 1:54 PM, Yao Chen wrote: > > Thanks James. That's exactly what I want to know. > > But I am not sure I fully understand the differential > expressed genes in topTable. For (fit2, coef=2), did I get the > genes without considering treat:age interaction, as my > previous design matrix . And (fit2, coef=4) gives me the genes > considering treat:age interation. > > > No. When you fit a model with a bunch of coefficients, a given > coefficient measures the marginal effect of the coefficient after > accounting for all other coefficients in the model. > > In conventional linear modeling (where you aren't fitting > thousands of models at once), you would probably fit a model with > and without the interaction term and then test to see if the > interaction term is significant. This is difficult to do in the > context of a microarray analysis, so people generally just throw a > bunch of coefficients in a model and look for significant genes. > > If you then wanted to do some other tests with a subset of your > genes I suppose you could, but people generally pick 'interesting' > genes and go to functional studies. > > Best, > > Jim > > > > Jack > > 2012/6/12 James W. MacDonald <jmacdon at="" uw.edu=""> <mailto:jmacdon at="" uw.edu=""> <mailto:jmacdon at="" uw.edu=""> <mailto:jmacdon at="" uw.edu="">>> > > Hi Jack, > > The conventional method is to use the model.matrix() > function. I > have no idea what your data look like, so here is a random > example: > > > treat <- factor(rep(0:1, each = 5)) > > treat > [1] 0 0 0 0 0 1 1 1 1 1 > Levels: 0 1 > > age <- sample(25:35, 10, TRUE) > > age > [1] 32 30 32 35 29 26 27 25 33 34 > > model.matrix(~treat*age) > (Intercept) treat1 age treat1:age > 1 1 0 32 0 > 2 1 0 30 0 > 3 1 0 32 0 > 4 1 0 35 0 > 5 1 0 29 0 > 6 1 1 26 26 > 7 1 1 27 27 > 8 1 1 25 25 > 9 1 1 33 33 > 10 1 1 34 34 > attr(,"assign") > [1] 0 1 2 3 > attr(,"contrasts") > attr(,"contrasts")$treat > [1] "contr.treatment" > > Note that this uses a different parameterization. In this > case the > treat1 coefficient is the difference between the treated and > untreated samples (so you wouldn't specify a > contrasts.matrix, you > just do lmFit() and then eBayes()). The treat1:age coefficient > captures the difference between the slopes for the treated and > untreated samples. > > So topTable(fit2, coef=2) gives you genes that are > differentially > expressed between treated and untreated and topTable(fit2, > coef=4) > gives you genes where the change in expression at different > ages > varies between treated and untreated subjects. > > Best, > > Jim > > > > > > On 6/12/2012 12:57 PM, Yao Chen wrote: > > Thanks, James > > How to include "age:treatment" interaction in the > design matrix? > > Jack > > 2012/6/12 James W. MacDonald <jmacdon at="" uw.edu=""> <mailto:jmacdon at="" uw.edu=""> > <mailto:jmacdon at="" uw.edu="" <mailto:jmacdon="" at="" uw.edu="">> > <mailto:jmacdon at="" uw.edu="" <mailto:jmacdon="" at="" uw.edu=""> > > <mailto:jmacdon at="" uw.edu="" <mailto:jmacdon="" at="" uw.edu="">>>> > > > Hi Jack, > > > On 6/12/2012 10:10 AM, Yao Chen wrote: > > Dear All, > > I try to find differential expressed genes between > treat and > untreated > samples, and also I want to include the age effects. > > The design matrix is like this: > > treat untreated age > 1 0 30 > 0 1 40 > 1 0 35 > > > The "treat" is factor, but "age" is continuous. How > can I set the > "cont.matrix"? > > > Pretty much just like you (or at least I) would expect: > > contrast <- makeContrasts(treat - untreat, levels = > design) > > But note that the design you are specifying allows > different > intercepts, but the slope is assumed to be the same > for treated > and untreated. If you want to allow different slopes as > well, you > need to introduce an age:treatment interaction term. > Here I am > assuming you have more than three samples. > > Best, > > Jim > > > > Thanks, > > Jack > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioconductor mailing list > Bioconductor at r-project.org <mailto:bioconductor at="" r-project.org=""> > <mailto:bioconductor at="" r-project.org=""> <mailto:bioconductor at="" r-project.org="">> > <mailto:bioconductor at="" r-project.org=""> <mailto:bioconductor at="" r-project.org=""> > > <mailto:bioconductor at="" r-project.org=""> <mailto:bioconductor at="" r-project.org="">>> > > https://stat.ethz.ch/mailman/listinfo/bioconductor > Search the archives: > http://news.gmane.org/gmane.science.biology.informatics.conductor > > > -- James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > > > -- James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > > > -- > James W. MacDonald, M.S. > Biostatistician > University of Washington > Environmental and Occupational Health Sciences > 4225 Roosevelt Way NE, # 100 > Seattle WA 98105-6099 > > -- James W. MacDonald, M.S. Biostatistician University of Washington Environmental and Occupational Health Sciences 4225 Roosevelt Way NE, # 100 Seattle WA 98105-6099
ADD REPLY

Login before adding your answer.

Traffic: 657 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6