library('corpcor',lib.loc="R")
library('mgcv',lib.loc="R")
library('sva',lib.loc="R")

library('R.methodsS3',lib.loc="R")
library('R.oo',lib.loc="R")
library('R.matlab',lib.loc="R")
mat_input <- readMat("input_for_R.mat")
mat_input$batchIdx<-as.vector(mat_input$batchIdx)

combat_res = ComBat(dat=mat_input$dataForCombat, batch=mat_input$batchIdx, mod=NULL)

writeMat("data_after_combat.mat",combat_res=combat_res)