# Re: [R] How to do covariate adjustment in R

From: Peter Langfelder <peter.langfelder_at_gmail.com>
Date: Fri, 20 May 2011 16:23:19 -0700

On Thu, May 19, 2011 at 10:58 PM, karena <dr.jzhou_at_gmail.com> wrote:
> Thank you so much for this reply, Peter. It helps.
>
> I know this is one way to adjust for covariates. However, if what I want is
> to get the 'remaining values' after adjustment. For example, say, 'gene
> expression' value is denoted as 'ge', and for each gene,
> ge=a*age+b*sex+c*per_se
>
> My question is: how to get the value of 'per_se' for each gene?

You could use the residuals after regressing the expression on sex and age. I think the call would be

residuals(lm(expression~age+sex))

but try it and see if it makes sense. Just note that the residual depends on how you define sex and and age; for example, if you shift age by 10, the residuals shift by a*age. Similarly, the residuals will depend on whether you use sex values (1,2) or (0,1) or (2,1) etc. for (female, male). Thus you need to be careful when interpreting the residuals. I would suggest standardizing age to mean zero so the residuals have the interpretation of expression at average age. Standardization for sex makes statistical but not biological sense since there are no samples with average sex.

Peter

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 20 May 2011 - 23:25:44 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 21 May 2011 - 00:20:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.