以下是我的代码。我正在尝试获取以结尾的所有文件(~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
我该如何解决?
Calling mclapply()
在某些情况下,需要您指定一个允许多个随机数流的随机数生成器。
R 版本 2.14.0 具有 Pierre L'Ecuyer 的多重伪随机数生成器的实现。
尝试在之前添加以下内容mclapply()
调用,带有预先指定的值 'my.seed
':
set.seed( my.seed, kind = "L'Ecuyer-CMRG" );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)