brentp / combat.py

python / numpy / pandas / patsy version of ComBat for removing batch effects.
MIT License
100 stars 43 forks source link

Getting all NaN if some rows have zero expression #11

Open wdecoster opened 6 years ago

wdecoster commented 6 years ago

It took me a while to figure it out (although in hindsight it seems obvious) but when the dat DataFrame contains rows which are entirely zero the result returned by combat() will contain all NaNs.

Perhaps it's worth to a) specify that in the manual or b) check for that and drop those rows (with a warning) while running the function. If you think b) makes sense I would be happy to add that and open a PR.

Unrelated, it seems that ComBat() in R has changed, the line cdata = ComBat(dat=edata, batch=as.factor(pheno$batch), mod=mod, numCov=match("age", colnames(mod))) returns Error in ComBat(dat = edata, batch = as.factor(pheno$batch), mod = mod, : unused argument (numCov = match("age", colnames(mod))) Execution halted

Cheers,
Wouter