svaba {bapred} | R Documentation |
Performs batch effect adjustment using Surrogate Variable Analysis (SVA) and additionally returns information necessary for addon batch effect adjustment with frozen SVA.
svaba(x, y, batch, nbf = NULL, algorithm = "fast")
x |
matrix. The covariate matrix. Observations in rows, variables in columns. |
y |
factor. Binary target variable. Currently has to have levels '1' and '2'. |
batch |
factor. Batch variable. Currently has to have levels: '1', '2', '3' and so on. |
nbf |
integer. Number of latent factors to estimate. |
algorithm |
character. If |
This is essentially a wrapper function of the function sva()
from the Bioconductor package of the same name.
svaba
returns an object of class svatrain
.
An object of class "svatrain
" is a list containing the following components:
xadj |
matrix of adjusted (training) data |
xtrain |
the unadjusted covariate matrix. Used in frozen SVA. |
ytrain |
binary target variable. Used in frozen SVA. |
svobj |
output of the function |
algorithm |
algorithm to use in frozen SVA |
nbatches |
number of batches |
batch |
batch variable |
Roman Hornung
Leek, J. T., Storey, J. D. (2007) Capturing Heterogeneity in Gene Expression Studies by Surrogate Variable Analysis. PLoS Genetics, 3, 1724–1735.
Parker, H. S., Bravo, H. C., Leek, J. T. (2014) Removing batch effects for prediction problems with frozen surrogate variable analysis. PeerJ, 2, e561.
data(autism) # Random subset of 150 variables: set.seed(1234) Xsub <- X[,sample(1:ncol(X), size=150)] # In cases of batches with more than 20 observations # select 20 observations at random: subinds <- unlist(sapply(1:length(levels(batch)), function(x) { indbatch <- which(batch==x) if(length(indbatch) > 20) indbatch <- sort(sample(indbatch, size=20)) indbatch })) Xsub <- Xsub[subinds,] batchsub <- batch[subinds] ysub <- y[subinds] params <- svaba(x=Xsub, y=ysub, batch=batchsub)