about SVA: matrix of corrected expression values
Entering edit mode
Bogdan ▴ 640
Last seen 2 days ago
Palo Alto, CA, USA

Dear all,

I would need a bit of help please on SVA package for batch correction :


Assuming I have a matrix (let's call it DATA) of gene expression having 3 treatments (lets's say, CTRL, TREAT1, TREAT2), after correcting for batch effects in SVA, how could I obtain the matrix of CORRECTED VALUES ?

A piece of R code is :

DATA= as.matrix(gene.expression) ### here is the MATRIX DATA ;)

group = as.factor(rep(c("CTRL", "TREAT1", "TREAT2"), each=3))

mod1 = model.matrix(~group)
mod0 = cbind(mod1[,1])

svseq = svaseq(DATA, mod1, mod0, n.sv=1) 

and I would need to obtain the matrix of CORRECTED_DATA ? thanks !

SVA COMBAT • 2.7k views
Entering edit mode
paul.alto ▴ 50
Last seen 2.6 years ago

I once found the function below to do what you want:

  # function from Back-estimating batch variables from SVA for ComBat?
  cleaningY = function(y, mod, svaobj) {
         X = cbind(mod, svaobj$sv)
           Hat = solve(t(X)%*%X)%*%t(X)
           beta = (Hat%*%t(y))
           P = ncol(mod)
           cleany = y-t(as.matrix(X[,-c(1:P)])%*%beta[-c(1:P),])

You can also use the removeBatchEffect() function from the limma package and give the SVs as covariates:

svseq <- svaseq(counts_input, mod, mod0, n.sv=nsv) 

cov = cbind(svseq$sv[,1:nsv])

counts_deseq_sva <- removeBatchEffect(counts_input, covariates = cov)

I notice, however, that the results do differ between the two methods (the function and removeBatchEffect()). The function seems to work almost miraculously, but I think it makes sense, since you are directly regressing the SVs. removeBatchEffect() doesn't always give the best results in terms of "fixing" clustering issues.


See also this post DESeq2 - Acquiring batch-corrected values for PCA and hierarchical clustering about using rlog or vst transformed data as input to your batch effect removal.

Entering edit mode
Jeff Leek ▴ 610
Last seen 14 months ago
United States


You would need to do this by performing a regression analysis on the svs estimated from svaseq and getting the residuals. If your downstream goal involves any type of significance test (differential analysis between groups for example) then we _do not_ recommend cleaning your data and then performing analysis on that cleaned data. This will cause problems with the calculation of the degrees of freeom for the statistical test. 

Instead we suggest incorporating the estimated surrogate variables as covariates in your analyses with limma, egdeR or DESeq after performing your svaseq analysis. 





Entering edit mode
Bogdan ▴ 640
Last seen 2 days ago
Palo Alto, CA, USA

Thank you gentlemen, very helpful !


Login before adding your answer.

Traffic: 414 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6