sva-devel icon indicating copy to clipboard operation
sva-devel copied to clipboard

ComBat doesn't work when data matrix contains only 1 variable

Open lashmore opened this issue 3 years ago • 0 comments

Any normalization method should work when there are multiple variables (p>1), as well as when there is only 1 variable (p=1) over N observations (samples).

Code that breaks because current implementation assumes a matrix with more than 1 variable:

library(bladderbatch)
data(bladderdata)
dat = bladderEset[1,]   **#### <- Here, isntead of first 50 variables, I just subset the data to the first variable ####**

pheno = pData(dat)
edata = exprs(dat)
batch = pheno$batch
mod = model.matrix(~as.factor(cancer), data=pheno)

# parametric adjustment
combat_edata1 = ComBat(dat=edata, batch=batch, mod=NULL, par.prior=TRUE, prior.plots=FALSE)

Error:

Error in apply(dat[, batch == batch_level], 1, function(x) { : 
  dim(X) must have a positive length

lashmore avatar Mar 10 '21 19:03 lashmore