R: Adjust Estimated Variances

variance_adjust {ruv} | R Documentation

## Adjust Estimated Variances

### Description

Calculate rescaled variances, empirical variances, etc. For use with RUV model fits.

### Usage

    variance_adjust(fit, ebayes = TRUE, evar = TRUE, rsvar = TRUE,
                    bin = 10, rescaleconst = NULL)

### Arguments

`fit` | A RUV model fit (a list), as returned by RUV2 / RUV4 / RUVinv / RUVrinv
`ebayes` | A logical variable. Should empirical bayes estimates be calculated?
`evar` | A logical variable. Should empirical variance estimates be calculated?
`rsvar` | A logical variable. Should rescaled variance estimates be calculated?
`bin` | The bin size to use when calculating empirical variances.
`rescaleconst` | Can be used to speed up execution. See `get_empirical_variances`.

### Value

An RUV model fit (a list). In addition to the elements of the list returned by RUV2 / RUV4 / RUVinv / RUVrinv, the list will now contain:

`sigma2.ebayes` | Estimates of sigma^2 using the empirical bayes shrinkage method of Smyth (2004)
`df.ebayes` | Estimate of degrees of freedom using the empirical bayes shrinkage method of Smyth (2004)
`varbetahat` | "Standard" estimate of the variance of `betahat`
`varbetahat.rsvar` | "Rescaled Variances" estimate of the variance of `betahat`
`varbetahat.evar` | "Empirical Variances" estimate of the variance of `betahat`
`varbetahat.ebayes` | "Empirical Bayes" estimate of the variance of `betahat`
`varbetahat.rsvar.ebayes` | "Rescaled Empirical Bayes" estimate of the variance of `betahat`
`p.rsvar` | P-values, after applying the method of rescaled variances
`p.evar` | P-values, after applying the method of empirical variances
`p.ebayes` | P-values, after applying the empirical bayes method of Smyth (2004)
`p.rsvar.ebayes` | P-values, after applying the empirical bayes method of Smyth (2004) and the method of rescaled variances
`p.BH` | FDR-adjusted p-values
`p.rsvar.BH` | FDR-adjusted p-values, after applying the method of rescaled variances
`p.evar.BH` | FDR-adjusted p-values, after applying the method of empirical variances
`p.ebayes.BH` | FDR-adjusted p-values, after applying the empirical bayes method of Smyth (2004)
`p.rsvar.ebayes.BH` | FDR-adjusted p-values, after applying the empirical bayes method of Smyth (2004) and the method of rescaled variances

### Author(s)

Johann Gagnon-Bartsch

### References

Using control genes to correct for unwanted variation in microarray data. Gagnon-Bartsch and Speed, 2012. Available at: http://biostatistics.oxfordjournals.org/content/13/3/539.full.

Removing Unwanted Variation from High Dimensional Data with Negative Controls. Gagnon-Bartsch, Jacob, and Speed, 2013. Available at: http://statistics.berkeley.edu/tech-reports/820.

Linear models and empirical bayes methods for assessing differential expression in microarray experiments. Smyth, 2004.

### See Also

`RUV2`, `RUV4`, `RUVinv`, `RUVrinv`, `get_empirical_variances`, `sigmashrink`

### Examples

    ## Create some simulated data
    m = 50
    n = 10000
    nc = 1000
    p = 1
    k = 20
    ctl = rep(FALSE, n)
    ctl[1:nc] = TRUE
    X = matrix(c(rep(0,floor(m/2)), rep(1,ceiling(m/2))), m, p)
    beta = matrix(rnorm(p*n), p, n)
    beta[,ctl] = 0
    W = matrix(rnorm(m*k),m,k)
    alpha = matrix(rnorm(k*n),k,n)
    epsilon = matrix(rnorm(m*n),m,n)
    Y = X%*%beta + W%*%alpha + epsilon

    ## Run RUV-inv
    fit = RUVinv(Y, X, ctl)

    ## Get adjusted variances and p-values
    fit = variance_adjust(fit)

[Package ruv version 0.9.6 Index]