Entering edit mode
I'm adjusting for batch effects in 450K data using ComBat in the sva package. When I run ComBat, I get the following error:
> batch = factor(pheno$plate)
> modcombat = model.matrix(~1, data=pheno)
> methCombat = ComBat(dat = as.matrix(meth), batch = batch, mod = modcombat)
Found7batches
Adjusting for0covariate(s) or covariate level(s)
Found216170Missing Data Values
Standardizing Data across genes
Error in solve.default(crossprod(des), crossprod(des, y1)) :
Lapack routine dgesv: system is exactly singular: U[4,4] = 0
The error arises due to the treatment of NAs in the methylation dataset when ComBat fits a model in the presence of missing values using the Beta.NA function. Specifically, the error is caused by this part of the ComBat function:
cat("Standardizing Data across genes\n")
if (!NAs) {
B.hat <- solve(crossprod(design), tcrossprod(t(design),
as.matrix(dat)))
} else {
B.hat <- apply(dat, 1, Beta.NA, design)
}
Other users have found this error due to their data structure; however, I do not get the error when running the ComBat after removing incomplete rows from the methylation dataset:
> methComplete = meth[complete.cases(meth),]
> methCombat = ComBat(dat = as.matrix(methComplete), batch = batch, mod = modcombat)
Found7batches
Adjusting for0covariate(s) or covariate level(s)
Standardizing Data across genes
Fitting L/S model and finding priors
Finding parametric adjustments
Adjusting the Data
Any suggestions would be appreciated!