R: Get K

getK {ruv} | R Documentation

## Get K

### Description

Finds an often-suitable value of K for use in RUV-4.

### Usage

    getK(Y, X, ctl, Z = 1, eta = NULL, fullW0 = NULL, cutoff = NULL,
         method="select", l=1, inputcheck = TRUE)

### Arguments

`Y` | The data. A m by n matrix, where m is the number of samples and n is the number of features.
`X` | The factor(s) of interest. A m by 1 matrix, where m is the number of samples. Note that X must be a single column.
`ctl` | The negative controls. A logical vector of length n.
`Z` | Any additional covariates to include in the model. Either a m by q matrix of covariates, or simply 1 (the default) for an intercept term.
`eta` | Gene-wise (as oposed to sample-wise) covariates. These covariates are adjusted for by RUV-1 before any further analysis proceeds. A matrix with n columns.
`fullW0` | Can be included to speed up execution.
`cutoff` | Specify an alternative cut-off. Default is the (approximate) 90th percentile of the distribution of the first singular value of an m by n gaussian matrix.
`method` | Can be set to either `leave1out`, `fast`, or `select`. `leave1out` is the preferred method but may be slow, `fast` is an approximate method that is faster but may provide poor results if n_c is not much larger than m, and `select` (the default) tries to choose for you.
`l` | Which column of X to use in the getK algorithm.
`inputcheck` | Perform a basic sanity check on the inputs, and issue a warning if there is a problem.

### Value

A list containing

`k` | the estimated value of k
`cutoff` | The cutoff value used
`sizeratios` | A measure of the relative sizes of the rows of alpha.
`fullW0` | Can be used to speed up future calls of RUV4.

### Warning

This value of K will not be the best choice in all cases. Moreover, it will often be a poor choice of K for use with RUV2. See Gagnon-Bartsch and Speed (2012) for commentary on estimating k.

### Author(s)

Johann Gagnon-Bartsch johanngb@umich.edu

### 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.

### See Also

`RUV4`

### 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 getK
    temp = getK(Y, X, ctl)
    K = temp$k

[Package ruv version 0.9.6 Index]