【发布时间】:2018-11-22 08:12:27
【问题描述】:
我正在尝试使用 R mnnCorrect 函数(来自 scran 包)。它需要至少 2 个输入矩阵才能工作。
# install package
source("https://bioconductor.org/biocLite.R"); biocLite("scran")
# example matrix 1
B1 <- matrix(rnorm(10000), ncol=50)
# example matrix 2
B2 <- matrix(rnorm(10000), ncol=50)
# function below works fine
out <- mnnCorrect(B1, B2)
但是,我正在尝试将这些矩阵作为列表提供(更方便使用可变数量的矩阵自动处理过程):
mat_list=list()
mat_list[["Mat1"]]=B1
mat_list[["Mat2"]]=B2
str(mat_list)
List of 2
$ Mat1: num [1:200, 1:50] 1.107 -0.828 1.559 -1.353 0.667 ...
$ Mat2: num [1:200, 1:50] -0.231 0.894 0.369 1.606 -1.346 ...
# This works fine
out <- mnnCorrect(mat_list$Mat1, mat_list$Mat2)
# These do not work
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
library(dplyr)
cat(paste(gsub("^","mat_list$",names(mat_list)),collapse=", ") %>% mnnCorrect(.)
mat_list$Mat1, mat_list$Mat2Error in mnnCorrect(.) : at least two batches must be specified
有没有办法做到这一点?
【问题讨论】: