'lapply and 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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source