gpt4 book ai didi

r - mcapply : all scheduled cores encountered errors in user code

转载 作者:行者123 更新时间:2023-12-02 04:38:47 28 4
gpt4 key购买 nike

以下是我的代码。我正在尝试获取以 .idat 结尾的所有文件(~20000)的列表,并使用函数 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

如何解决?

最佳答案

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

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

set.seed( my.seed, kind = "L'Ecuyer-CMRG" );

关于r - mcapply : all scheduled cores encountered errors in user code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39280009/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com