Skip to contents

Estimates a covariance matrix from a data matrix Y using empirical Bayes matrix factorization (flashier::flash). When the FLASH fit finds no shared factors, the returned covariance is diagonal with entries residuals_sd^2; otherwise the factor contribution is added. FLASH errors are not caught; callers should handle them explicitly or supply a pre-computed prior covariance instead.

Usage

computeCovFlash(Y)

Arguments

Y

Numeric matrix (samples x conditions).

Value

A covariance matrix of dimension ncol(Y) x ncol(Y), rescaled by the column standard deviations of Y.

Examples

data(eqtlRegionExample)
X <- eqtlRegionExample$X[, 1:30]
Y <- matrix(rnorm(nrow(X) * 3), nrow(X), 3)
computeCovFlash(Y = Y)
#>          [,1]     [,2]     [,3]
#> [1,] 1.081561 0.000000 0.000000
#> [2,] 0.000000 1.042385 0.000000
#> [3,] 0.000000 0.000000 1.079302