3

以下是我的代码。我正在尝试获取以该函数结尾的所有文件(〜20000)的列表.idat并读取每个文件illuminaio::readIDAT

library(illuminaio)
library(parallel)
library(data.table)

# number of cores to use
ncores = 8

# this gets all the files with .idat extension ~20000 files
files <- list.files(path = './',
                    pattern = "*.idat",
                    full.names = TRUE)

# function to read the idat file and create a data.table of filename, and two more columns
# write out as csv using fwrite
get.chiptype <- function(x)
{
  idat <- readIDAT(x)
  res <- data.table(filename = x, nSNPs = nrow(idat$Quants), Chip = idat$ChipType)
  fwrite(res, file.path = 'output.csv', append = TRUE)
}

# using mclapply call the function get.chiptype on all 20000 files.
# use 8 cores at a time
mclapply(files, FUN = function(x) get.chiptype(x), mc.cores = ncores)

在读取和写入有关 1200 个文件的信息后,我收到以下消息:

Warning message:
In mclapply(files, FUN = function(x) get.chiptype(x), mc.cores = ncores) :
  all scheduled cores encountered errors in user code

我该如何解决?

4

1 回答 1

0

在某些情况下调用mclapply()需要您指定一个允许多个随机数流的随机数生成器。R 版本 2.14.0 实现了 Pierre L'Ecuyer 的多伪随机数生成器。

尝试在调用之前添加以下内容mclapply(),并为 ' ' 预先指定值my.seed

set.seed( my.seed, kind = "L'Ecuyer-CMRG" );
于 2018-03-03T02:06:08.123 回答