jtleek / sva-devel

28 stars 45 forks source link

ComBat fails with updated ComBat.R #24

Open cafletezbrant opened 7 years ago

cafletezbrant commented 7 years ago

band191_log_libsize.txt

Using the data I attached (band191_log_libsize.txt), ComBat crashes on the following code:

b191 <- read.table("band191_log_libsize.txt") batches <- c(rep.int(1, times=12), 2, 2, 2, 2)
batches <- c(rep.int(1, 12), 2, 2, 2, 2)

## remove known issue-causing rows
bad <-  c(8,   15,   24,   25,   26,   85,  211,  216,  217,  229,  232,  417,  626, 1381, 1389, 1397,
1399, 1410, 1415, 1435, 1450, 1458, 1482, 1628, 1650, 1665, 1674, 1692, 1967, 1976, 1986, 1987,
1988, 1989, 1990, 1991, 1994, 1995, 1998, 1999, 2018,  102)
b191 <- b191[-bad,]
ComBat(b191, batches)

With the following message:

Found2batches Adjusting for0covariate(s) or covariate level(s) 
Standardizing Data across genes 
Error in crossprod(design, as.matrix(dat)) : non-conformable arguments
kasperdanielhansen commented 7 years ago

I'll look into this; I think it is my recent pull request which created this issue

jtleek commented 7 years ago

@kasperdanielhansen any word on this?

xiaohk commented 5 years ago

Similar problem. Cant figure out how to use ComBat()

kasperdanielhansen commented 5 years ago

Wait a minute. I have been tagged in an issue from May 2017. Well, that's a failure.

I looked into @cafletezbrant issue. It is caused because the input data is a data.frame and not a matrix. Look at the code of ComBat() there is a fair amount of matrix algebra involving the dat argument, so I think the silent assumption is that dat is a matrix. That is also true for sva(), although what happens for several of these matrix algebra functions is that dat silent gets transformed from a data.frame into a matrix.

This can be solved two ways 1) explicitly coercing dat into a matrix, which should probably happen at the start of the function. 2) testing whether dat is a matrix and failing if it is not.

What does the maintainer @jtleek say?