lmFit, continuous exposure, adjustment covariates
1
0
Entering edit mode
AyHi • 0
@3decdc93
Last seen 22 months ago
Sweden

Hi, I am using lmFit in R. I am very new to R and limma, so I highly appreciate your input. (I have another post previously by "lmFit, number of proteins", and the current question is part of the same study but different analysis.)

The study concerns which of 15 proteins show show association with a continuous exposure variable. Also, we would like to adjust for age in the model. The exposure variable and age are continuous variables. The exposure has a value between 0 and 1, and age is with integer, ranged between 15 and 25.

The data are comprised as: 500 rows for 500 unique individuals, and 17 columns - 15 proteins, the exposure and age.

With my limited experience, I have used the following code. I used Stata OLS regression to check similarity of results. The estimates (coefficient, CIs, t and p-values) showed reasonably similar results.

But since I am not used to limma and R, I would like to ask if I have done correctly. Although it seemed working, 'makeContrast' was challenging as I had only an example for a categorical (2 group) exposure variable.


  design <- model.matrix(~exposure + age, data=dat)
  dim(design)
  design

  colnames(design) <-c("intercept", "exposure", "age")
  contrast <- makeContrasts(exposure, levels=design)
  print(head(contrast))

  fit <- lmFit(t(dat[43:ncol(dat)]), design=design, method="robust", maxit=1000)
  fit

  contrast_fit<-contrasts.fit(fit,contrast)
  ebays_fit<-eBayes(contrast_fit)
  print(summary(decideTests(ebays_fit)))
  DE_results <- topTable(ebays_fit,n=ncol(dat), adjust.method="fdr", confint=TRUE)
  DE_results

Thank you so much for your help, in advance!

lmFit • 1.2k views
ADD COMMENT
2
Entering edit mode
@gordon-smyth
Last seen 15 minutes ago
WEHI, Melbourne, Australia

There's no need for makeContrasts. Also, there's also no argument called maxit and the subsetting of dat in your code doesn't seem right. Simply:

design <- model.matrix(~exposure + age, data=dat)
fit <- lmFit(y, design)
fit <- eBayes(fit)
DE_results <- topTable(fit, coef="exposure", confint=TRUE, n=Inf)

where y is the matrix of expression values would give what you want.

ADD COMMENT
0
Entering edit mode

Dear Gordon, Thank you so much for your reply. It worked well! I just changed y to t because the protein values were included in dat in my case after column 43, so I seem to need t().

Thank you!

ADD REPLY
0
Entering edit mode

Your code t(dat[43:ncol(dat)] is not even syntactically correct. It could not possibly run in R.

You need to create an expression matrix properly in the first place, otherwise nothing else you do will make any sense. You should store the expression matrix in a new object and check it before you go any further in the analysis.

ADD REPLY

Login before adding your answer.

Traffic: 719 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