How to use Combat in R??
I'm trying to use combat to correct for batch effect in our dataset. The sample csv files contains genes in rows, and samples in columns, and expression value are from different microarray. We have in total 6 batches, and the sif file contains 3 columns arrays, samples, batch (as per the manual). R generates an error message when running combat.. I'm not sure what to do from here. Am I using combat the wrong way?
library(sva)
dat = read.csv("Combat_matrix_input.csv");
sif = read.csv("sif.csv");
modcombat = model.matrix(~1, data=dat)
newdata = ComBat(dat=dat, batch=sif$Batch, par.prior = TRUE, mod = modcombat)
Found 6 batches
Error in cbind(batchmod, mod) :
number of rows of matrices must match (see arg 2)
• 16,195 views
•
link
1 answer
It would be helpful if you could show some data in the input files - sif.csv & combat_matrix_input.csv. But just by looking at the code I think the problem lies in the model.matrix step. While generating the model, use the phenotype file and not the expression file:
mod = model.matrix(~1, data = sif)
• 0 views
•
link
Log in to answer this question.