Exclude rows with no variance from batch adjustment#13
Conversation
|
This is a useful contribution. I will check it out! The other related concern is if the variance is zero within a single batch for any gene, ComBat will also fail. So the complete check will need to be at this level as well. However, one alternative though: instead of throwing an error, another more useful approach would be to just remove these rows, note this to the user, do batch correction, and then put the zero variance genes back in.
|
|
Good suggestion - I've also encountered the issue with zero-variance within batches in the past. It seems like more recent versions of ComBat are able to handle those scenarios a bit better - for example, ComBat will now still run even if one of the batches contains only a single replicate. I like the idea of ignoring the adjustment for zero-var genes and adding them back in afterwards. This way the shape of the data isn't changed (no hard filtering), and as long as there aren't too many such genes, the results should still be useful. |
|
Updated PR per your suggestion. It doesn't attempt to deal with within-batch uniformity, but will at least leave out genes with no variance across all samples during batch adjustment. |
Currently ComBat fails when the input data matrix contains rows with no variance. There is likely a better solution for dealing with this, but for now at least, stopping execution with an informative error message may be useful.