Modified eBayes function to be used instead of the one in the limma package

eBayes.mod(
  fit,
  VarRubin,
  proportion = 0.01,
  stdev.coef.lim = c(0.1, 4),
  trend = FALSE,
  robust = FALSE,
  winsor.tail.p = c(0.05, 0.1)
)

Arguments

fit

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.

VarRubin

a variance-covariance matrix.

proportion

numeric value between 0 and 1, assumed proportion of genes which are differentially expressed

stdev.coef.lim

numeric vector of length 2, assumed lower and upper limits for the standard deviation of log2-fold-changes for differentially expressed genes

trend

logical, should an intensity-trend be allowed for the prior variance? Default is that the prior variance is constant.

robust

logical, should the estimation of df.prior and var.prior be robustified against outlier sample variances?

winsor.tail.p

numeric vector of length 1 or 2, giving left and right tail proportions of x to Winsorize. Used only when robust=TRUE.

Value

eBayes produces an object of class MArrayLM (see MArrayLM-class) containing everything found in fit plus the following added components:

t

numeric matrix of moderated t-statistics.

p.value

numeric matrix of two-sided p-values corresponding to the t-statistics.

lods

numeric matrix giving the log-odds of differential expression (on the natural log scale).

s2.prior

estimated prior value for sigma^2. A row-wise vector if covariate is non-NULL, otherwise a single value.

df.prior

degrees of freedom associated with s2.prior. A row-wise vector if robust=TRUE, otherwise a single value.

df.total

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.

s2.post

row-wise numeric vector giving the posterior values for sigma^2.

var.prior

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.

F

row-wise numeric vector of moderated F-statistics for testing all contrasts defined by the columns of fit simultaneously equal to zero.

F.p.value

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.

Author

Modified by M. Chion and F. Bertrand. Original by Gordon Smyth and Davis McCarthy

Examples

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) eBayes.mod(fit=fit.model,VarRubin.matrix[[1]])
#> Warning: Zero sample variances detected, have been offset away from zero
#> An object of class "MArrayLM" #> $coefficients #> Intercept Group #> [1,] 99.02599 101.21269 #> [2,] 100.18124 99.27197 #> [3,] 99.62693 100.47686 #> [4,] 100.09296 100.07284 #> [5,] 100.56314 99.11801 #> 195 more rows ... #> #> $rank #> [1] 2 #> #> $assign #> NULL #> #> $qr #> $qr #> Intercept Group #> [1,] -3.1622777 -1.5811388 #> [2,] 0.3162278 1.5811388 #> [3,] 0.3162278 0.2402531 #> [4,] 0.3162278 0.2402531 #> [5,] 0.3162278 0.2402531 #> [6,] 0.3162278 -0.3922025 #> [7,] 0.3162278 -0.3922025 #> [8,] 0.3162278 -0.3922025 #> [9,] 0.3162278 -0.3922025 #> [10,] 0.3162278 -0.3922025 #> #> $qraux #> [1] 1.316228 1.240253 #> #> $pivot #> [1] 1 2 #> #> $tol #> [1] 1e-07 #> #> $rank #> [1] 2 #> #> #> $df.residual #> [1] 8 8 8 8 8 #> 195 more elements ... #> #> $sigma #> [1] 0.9775856 0.7953603 1.1048761 0.8560416 0.8190853 #> 195 more elements ... #> #> $cov.coefficients #> Intercept Group #> Intercept 0.2 -0.2 #> Group -0.2 0.4 #> #> $stdev.unscaled #> Intercept Group #> [1,] 0.4472136 0.6324555 #> [2,] 0.4472136 0.6324555 #> [3,] 0.4472136 0.6324555 #> [4,] 0.4472136 0.6324555 #> [5,] 0.4472136 0.6324555 #> 195 more rows ... #> #> $pivot #> [1] 1 2 #> #> $Amean #> [1] 149.6323 149.8172 149.8654 150.1294 150.1221 #> 195 more elements ... #> #> $method #> [1] "ls" #> #> $design #> Intercept Group #> [1,] 1 0 #> [2,] 1 0 #> [3,] 1 0 #> [4,] 1 0 #> [5,] 1 0 #> [6,] 1 1 #> [7,] 1 1 #> [8,] 1 1 #> [9,] 1 1 #> [10,] 1 1 #> #> $df.prior #> [1] 0.2886034 #> #> $s2.prior #> [1] 4.391122e-07 #> #> $var.prior #> [1] 36437154 36437154 #> #> $proportion #> [1] 0.01 #> #> $s2.post #> [1] 3.526045e-02 1.528958e-08 1.528958e-08 3.526045e-02 NA #> 195 more elements ... #> #> $t #> Intercept Group #> [1,] 1179.208 852.2383 #> [2,] 1811647.135 1269400.9619 #> [3,] 1801623.098 1284808.0990 #> [4,] 1191.913 842.6404 #> [5,] NA NA #> 195 more rows ... #> #> $df.total #> [1] 8.288603 8.288603 8.288603 8.288603 8.288603 #> 195 more elements ... #> #> $p.value #> Intercept Group #> [1,] 5.982632e-23 8.827114e-22 #> [2,] 2.319558e-49 4.423698e-48 #> [3,] 2.428723e-49 4.002744e-48 #> [4,] 5.474126e-23 9.695892e-22 #> [5,] NA NA #> 195 more rows ... #> #> $lods #> Intercept Group #> [1,] 41.76277 39.09288 #> [2,] 74.22959 71.35694 #> [3,] 74.22957 71.35699 #> [4,] 41.86223 38.98778 #> [5,] NA NA #> 195 more rows ... #> #> $F #> [1] 3.538077e+06 8.145720e+12 8.170114e+12 3.551071e+06 NA #> 195 more elements ... #> #> $F.p.value #> [1] 2.623224e-25 1.127503e-51 1.113617e-51 2.583672e-25 NA #> 195 more elements ... #>