Search
Question: removeBatchEffect and random effect
0
4.3 years ago by
Rao,Xiayu530
United States
Rao,Xiayu530 wrote:
Hi, Ryan and other Limma experts I do need confirmation of the use of removeBatchEffect. I have the design and linear model fitting like the following. Chip is my batch effect, and subject is the random effect. design <- model.matrix(~type+chip) corfit <- duplicateCorrelation(y,design,block=targets$subject) corfit$consensus fit <- lmFit(y,design,block=targets$subject,correlation=corfit$consensus) With Ryan's help, I set up the removeBatchEffect command as below. My question is, should I use the same corfit$consensus value here as that I put in the lmFit command, or should I estimate new corfit$consensus value through corfit <- duplicateCorrelation(y,design2,block=targets$subject) and put it here since I changed the design matrix ??? design2 <- model.matrix(~type) y_exp <- y$E y_expB <- removeBatchEffect(y_exp, batch=targets$chip, covariates=NULL, design=design2, block=targets$subject, correlation=corfit$consensus) Thank you very much! Best regards, Xiayu -----Original Message----- From: Ryan [mailto:rct@thompsonclan.org] Sent: Wednesday, August 06, 2014 11:45 AM To: Rao,Xiayu Cc: bioconductor at r-project.org Subject: Re: [BioC] removeBatchEffect options: design and covariates Well, I'm not as familiar with random effects analysis, but the normal way to use duplicateCorrelation is to pass corfit$consensus as the correlation argument to lmFit. The help page for removeBatchEffect states that any additional arguments are passed to lmFit, so I think I would simply do likewise and pass the same correlation argument to removeBatchEffect. On Wed Aug 6 08:19:33 2014, Rao,Xiayu wrote: > Hi, Ryan > > Thank you for your input! One more quick follow-up question, considering your example of specifying design=model.matrix(~Condition), and batch=Batch, what if I also have a random effect in my limma design? do I need to put that variable(subject as below) anywhere in the removeBatchEffect command or just ignore it? > > design <- model.matrix(~Condition + Batch) > duplicateCorrelation(y,design,block=targets$subject) > > Thanks, > Xiayu > > > > -----Original Message----- > From: Ryan C. Thompson [mailto:rct at thompsonclan.org] > Sent: Tuesday, August 05, 2014 5:18 PM > To: Rao,Xiayu > Cc: bioconductor at r-project.org > Subject: Re: [BioC] removeBatchEffect options: design and covariates > > Hello, > > When calling removeBatchEffect, you should use the same design that you used for limma, but with with batch effect term removed from the design. Then you would pass the batch effect factor as the batch argument instead. So, if the design matrix that you used for limma was constructed as: > > model.matrix(~Condition + Batch), > > then for removeBatchEffect, you would use design=model.matrix(~Condition), and batch=Batch. In other words, you take the batch effect out of your model design and pass it as the batch argument instead. > > -Ryan > > On Tue 05 Aug 2014 03:12:26 PM PDT, Rao,Xiayu wrote: >> Hello, >> >> I want to use removeBatchEffect() on the expression data (Elist) prior to drawing a heatmap based on the expression of sig diff genes. Those sig diff genes were generated from limma linear modelling, with the batch factor already included in the linear model. >> >> I saw people use removeBatchEffect(y, batch=batch) and removeBatchEffect(y, batch=batch, design=design). I would very much like to know in what condition I should include the design matrix, and when to also include covariates ??? Any comments would be very appreciated. Thank you in advance! >> >> removeBatchEffect(x, batch=NULL, covariates=NULL, >> design=matrix(1,ncol(x),1), ...) >> >> >> Thanks, >> Xiayu >> >> [[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 ADD COMMENTlink modified 4.3 years ago by Gordon Smyth35k • written 4.3 years ago by Rao,Xiayu530 0 4.3 years ago by Gordon Smyth35k Walter and Eliza Hall Institute of Medical Research, Melbourne, Australia Gordon Smyth35k wrote: Keep the same correlation as you used for lmFit. The design matrix hasn't really changed, it has just been split into two parts (the batch factor and the rest). Internally removeBatchEffect does the same fit as lmFit. Best wishes Gordon > Date: Thu, 4 Sep 2014 16:10:23 +0000 > From: "Rao,Xiayu" <xrao at="" mdanderson.org=""> > To: "'Ryan'" <rct at="" thompsonclan.org=""> > Cc: "bioconductor at r-project.org" <bioconductor at="" r-project.org=""> > Subject: [BioC] removeBatchEffect and random effect > > Hi, Ryan and other Limma experts > > I do need confirmation of the use of removeBatchEffect. > > I have the design and linear model fitting like the following. Chip is my batch effect, and subject is the random effect. > design <- model.matrix(~type+chip) > corfit <- duplicateCorrelation(y,design,block=targets$subject) > corfit$consensus > fit <- lmFit(y,design,block=targets$subject,correlation=corfit$consensus) > > With Ryan's help, I set up the removeBatchEffect command as below. My > question is, should I use the same corfit$consensus value here as that I > put in the lmFit command, or should I estimate new corfit$consensus > value through corfit <- > duplicateCorrelation(y,design2,block=targets$subject) and put it here > since I changed the design matrix ??? > design2 <- model.matrix(~type) > y_exp <- y$E > y_expB <- removeBatchEffect(y_exp, batch=targets$chip, covariates=NULL, design=design2, block=targets$subject, correlation=corfit$consensus) > > Thank you very much! > > Best regards, > Xiayu > > > -----Original Message----- > From: Ryan [mailto:rct at thompsonclan.org] > Sent: Wednesday, August 06, 2014 11:45 AM > To: Rao,Xiayu > Cc: bioconductor at r-project.org > Subject: Re: [BioC] removeBatchEffect options: design and covariates > > Well, I'm not as familiar with random effects analysis, but the normal way to use duplicateCorrelation is to pass corfit$consensus as the correlation argument to lmFit. The help page for removeBatchEffect states that any additional arguments are passed to lmFit, so I think I would simply do likewise and pass the same correlation argument to removeBatchEffect. > > On Wed Aug 6 08:19:33 2014, Rao,Xiayu wrote: >> Hi, Ryan >> >> Thank you for your input! One more quick follow-up question, considering your example of specifying design=model.matrix(~Condition), and batch=Batch, what if I also have a random effect in my limma design? do I need to put that variable(subject as below) anywhere in the removeBatchEffect command or just ignore it? >> >> design <- model.matrix(~Condition + Batch) >> duplicateCorrelation(y,design,block=targets$subject) >> >> Thanks, >> Xiayu >> >> >> >> -----Original Message----- >> From: Ryan C. Thompson [mailto:rct at thompsonclan.org] >> Sent: Tuesday, August 05, 2014 5:18 PM >> To: Rao,Xiayu >> Cc: bioconductor at r-project.org >> Subject: Re: [BioC] removeBatchEffect options: design and covariates >> >> Hello, >> >> When calling removeBatchEffect, you should use the same design that you used for limma, but with with batch effect term removed from the design. Then you would pass the batch effect factor as the batch argument instead. So, if the design matrix that you used for limma was constructed as: >> >> model.matrix(~Condition + Batch), >> >> then for removeBatchEffect, you would use design=model.matrix(~Condition), and batch=Batch. In other words, you take the batch effect out of your model design and pass it as the batch argument instead. >> >> -Ryan >> >> On Tue 05 Aug 2014 03:12:26 PM PDT, Rao,Xiayu wrote: >>> Hello, >>> >>> I want to use removeBatchEffect() on the expression data (Elist) prior to drawing a heatmap based on the expression of sig diff genes. Those sig diff genes were generated from limma linear modelling, with the batch factor already included in the linear model. >>> >>> I saw people use removeBatchEffect(y, batch=batch) and removeBatchEffect(y, batch=batch, design=design). I would very much like to know in what condition I should include the design matrix, and when to also include covariates ??? Any comments would be very appreciated. Thank you in advance! >>> >>> removeBatchEffect(x, batch=NULL, covariates=NULL, >>> design=matrix(1,ncol(x),1), ...) >>> >>> >>> Thanks, >>> Xiayu ______________________________________________________________________ The information in this email is confidential and intend...{{dropped:4}}