Modified eBayes function to be used instead of the one, .ebayes
, implemented in the limma package
an MArrayLM fitted model object produced by lmFit or contrasts.fit. For ebayes only, fit can alternatively be an unclassed list produced by lm.series, gls.series or mrlm containing components coefficients, stdev.unscaled, sigma and df.residual.
a variance-covariance matrix.
TRUE (not used at the moment)
numeric value between 0 and 1, assumed proportion of genes which are differentially expressed
numeric vector of length 2, assumed lower and upper limits for the standard deviation of log2-fold-changes for differentially expressed genes
logical, should an intensity-trend be allowed for the prior variance? Default is that the prior variance is constant.
logical, should the estimation of df.prior and var.prior be robustified against outlier sample variances?
numeric vector of length 1 or 2, giving left and right tail proportions of x to Winsorize. Used only when robust=TRUE.
boolean to stick to former way to squeeze variances. Defaults to TRUE.
eBayes produces an object of class MArrayLM (see MArrayLM-class) containing everything found in fit
plus the following added components:
numeric matrix of moderated t-statistics.
numeric matrix of two-sided p-values corresponding to the t-statistics.
numeric matrix giving the log-odds of differential expression (on the natural log scale).
estimated prior value for sigma^2. A row-wise vector if covariate is non-NULL, otherwise a single value.
degrees of freedom associated with s2.prior. A row-wise vector if robust=TRUE, otherwise a single value.
row-wise numeric vector giving the total degrees of freedom associated with the t-statistics for each gene. Equal to df.prior+df.residual or sum(df.residual), whichever is smaller.
row-wise numeric vector giving the posterior values for sigma^2.
column-wise numeric vector giving estimated prior values for the variance of the log2-fold-changes for differentially expressed gene for each constrast. Used for evaluating lods.
row-wise numeric vector of moderated F-statistics for testing all contrasts defined by the columns of fit simultaneously equal to zero.
row-wise numeric vector giving p-values corresponding to F.
The matrices t, p.value and lods have the same dimensions as the input object fit, with rows corresponding to genes and columns to coefficients or contrasts. The vectors s2.prior, df.prior, df.total, F and F.p.value correspond to rows, with length equal to the number of genes. The vector var.prior corresponds to columns, with length equal to the number of contrasts. If s2.prior or df.prior have length 1, then the same value applies to all genes.
s2.prior, df.prior and var.prior contain empirical Bayes hyperparameters used to obtain df.total, s2.post and lods.
library(mi4p)
data(datasim)
datasim_imp <- multi.impute(data = datasim[,-1], conditions =
attr(datasim,"metadata")$Condition, method = "MLE")
VarRubin.matrix <- rubin2.all(datasim_imp[1:5,,],
attr(datasim,"metadata")$Condition)
set.seed(2016)
sigma2 <- 0.05 / rchisq(100, df=10) * 10
y <- datasim_imp[,,1]
design <- cbind(Intercept=1,Group=as.numeric(
attr(datasim,"metadata")$Condition)-1)
fit.model <- limma::lmFit(y,design)
hid.ebayes(fit=fit.model,VarRubin.matrix[[1]])
#> Error in limma::squeezeVar(sigma^2, df.residual, covariate = covariate, robust = robust, winsor.tail.p = winsor.tail.p, legacy = legacy): unused argument (legacy = legacy)