MarioniLab / scran

Clone of the Bioconductor repository for the scran package.
https://bioconductor.org/packages/devel/bioc/html/scran.html
40 stars 22 forks source link

Impossible to use list of matrices as mnnCorrect input #24

Closed u9090 closed 5 years ago

u9090 commented 5 years ago

Hi,

How could one use a list of matrices as mnnCorrect input (more convenient for automation purpose)?

Taking the example provided in scran user manual, this works ok:

B1 <- matrix(rnorm(10000), ncol=50)                     # Batch 1
B2 <- matrix(rnorm(10000), ncol=50)                    # Batch 2
out <- mnnCorrect(B1, B2)                                       # corrected values

But there is an error with the following:

mat_list=list()
mat_list[["Batch_1"]]=B1
mat_list[["Batch_2"]]=B2
str(mat_list)
List of 2
 $ Batch1: num [1:200, 1:50] 1.107 -0.828 1.559 -1.353 0.667 ...
 $ Batch2: num [1:200, 1:50] -0.231 0.894 0.369 1.606 -1.346 ...

out <- mnnCorrect(mat_list)
Error in mnnCorrect(mat_list) : at least two batches must be specified

out <- mnnCorrect(cat(paste(gsub("^","mat_list$",names(mat_list)),collapse=", "))
Error in mnnCorrect(mat_list) : at least two batches must be specified

out <- mnnCorrect(capture.output(cat(paste(gsub("^","mat_list$",names(mat_list)),collapse=", ")))
Error in mnnCorrect(mat_list) : at least two batches must be specified

Is there a way to achieve this?

Thanks !

u9090 commented 5 years ago

Forget it. Following works fine do.call(mnnCorrect, mat_list)