I have the following code:
fit <- lmFit(
intmat
,
designMatrix
)
tmpfit <- fit[,-1]
lmfit.cont <- contrasts.fit(fit[,-1], cont[-1,2])
lmfitebayes <- eBayes(lmfit.cont)
topTable(lmfitebayes, coef=name, number=Inf)
Which fails when executing topTable sometimes. Thats because contrast.fit
in some cases prefers not to give a name to the coefficients (see below). It does not give the name if only a single contrast is being computed. If I than want to execute topTable and specify the name of the contrast "A - B" although usually it works. Still, it would be nice to have the name because: being explicit somehow is more explicit than implicit, and being consistent is more consistent compared to having names once and not having them other times.
> head(lmfit.cont$coefficients)
[,1]
A0A075B6P5 -0.6597603
A0A075B6S5 -0.3231210
A0A087WSY6 -0.1133279
A0A0B4J1V0 -0.1568641
A0A0B4J1V6 0.3889539
A0A0B4J2D9 -1.6330590
Thank you!
[ ] default behaviour strikes again!
"Omitting
drop = FALSE
when subsetting matrices and data frames is one of the most common sources of programming errors. (It will work for your test cases, but then someone will pass in a single column data frame and it will fail in an unexpected and unclear way.) " http://adv-r.had.co.nz/Subsetting.html