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!
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!
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.