Lapply和无效'描述'争论

发布于 2025-01-18 05:43:04 字数 1501 浏览 1 评论 0原文

我有一个包含 144 个文件的目录 (.bed)。

我想使用 R 包 (ChAseR) 中的函数来分析它们。为了避免 for 循环,我决定使用 lapply 函数。

# Define path

setwd("/home/works/Project/")
netpath="Table"
bedpath="Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files"

# PCHiC contact network data loading and preprocessing
pchic=read.table(paste(netpath, "merged_samples_12Apr2015_full.txt", sep="/"), sep="\t", skip=4, header=T)

pchic[,1]=paste('chr', pchic[,1], sep='')

pchic[,6]=paste('chr', pchic[,6], sep='')

Tcellnaive <- pchic[which(pchic$Naive_CD4>=5),c(1,2,3,6,7,8)]

tnet=chaser::make_chromnet(Tcellnaive)

# Load histone modifications data from Chen et al. 2016 (doi: 10.1016/j.cell.2016.10.026)
files <- list.files(path=bedpath, pattern="*.bed", full.names=TRUE, recursive=FALSE)
tnet2 <- lapply(files, chaser::load_features(tnet, files, type="macs2", missingv=0, featnames="H3K27ac"))

我收到此消息:

 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S01342H2.H3K27ac.ppqt_macs2_wp10.20150819.bed...
 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S0137XH3.H3K27ac.ppqt_macs2_wp10.20150819.bed...
 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S013CNH3.H3K27ac.ppqt_macs2_wp10.20150819.bed...
 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S013DLH2.H3K27ac.ppqt_macs2_wp10.20150819.bed...
Error in file(file, "rt") : invalid 'description' argument

如何解决此错误?也许路径或功能有问题?

I have a directory with 144 files (.bed).

I would like to analyze them with a function from a R package (ChAseR). To avoid a for loop, I decided to use a lapply function.

# Define path

setwd("/home/works/Project/")
netpath="Table"
bedpath="Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files"

# PCHiC contact network data loading and preprocessing
pchic=read.table(paste(netpath, "merged_samples_12Apr2015_full.txt", sep="/"), sep="\t", skip=4, header=T)

pchic[,1]=paste('chr', pchic[,1], sep='')

pchic[,6]=paste('chr', pchic[,6], sep='')

Tcellnaive <- pchic[which(pchic$Naive_CD4>=5),c(1,2,3,6,7,8)]

tnet=chaser::make_chromnet(Tcellnaive)

# Load histone modifications data from Chen et al. 2016 (doi: 10.1016/j.cell.2016.10.026)
files <- list.files(path=bedpath, pattern="*.bed", full.names=TRUE, recursive=FALSE)
tnet2 <- lapply(files, chaser::load_features(tnet, files, type="macs2", missingv=0, featnames="H3K27ac"))

I obtained this message:

 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S01342H2.H3K27ac.ppqt_macs2_wp10.20150819.bed...
 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S0137XH3.H3K27ac.ppqt_macs2_wp10.20150819.bed...
 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S013CNH3.H3K27ac.ppqt_macs2_wp10.20150819.bed...
 reading from file Data/Naive_CD4_positive_T_Cells_BP/H3K27ac/bed_files/S013DLH2.H3K27ac.ppqt_macs2_wp10.20150819.bed...
Error in file(file, "rt") : invalid 'description' argument

How to resolve this error? Maybe a problem with the path or the function?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文