我编写了一个代码,它应该通过组合输入文件中的第二列将多个文件合并到一个文件中。第一列在输入文件中类似。但是,它给出了一个我无法理解的错误。
files <- list.files(path = "/Rfam/",pattern='\\.sam')
我的代码
lst <- lapply(files, function(x) read.csv(x,header=TRUE))
setNames(Reduce(function(...) merge(..., by='V1'),
lst),c('ID', paste0('file',seq_along(files))) )
错误
> lst <- lapply(files, function(x) read.csv(x,header=TRUE))
Show Traceback
Rerun with Debug
Error in file(file, "rt") : cannot open the connection In addition: Warning message:
In file(file, "rt") :
cannot open file 'Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput100G.sam': No such file or directory
我的档案:
> head(files)
[1] "Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput100G.sam"
[2] "Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput100R.sam"
[3] "Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput106G.sam"
[4] "Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput106R.sam"
[5] "Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput122G.sam"
[6] "Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput122R.sam"
> length(files)
[1] 96
输入示例
DMED7013:Rfam robinm$ head Rfam_Counts_combined_SplitRfam_Counts_combinedhtseq_Rfamoutput402R.sam
Seq_../trimmed/402R.tally.fasta __not_aligned
__too_low_aQual 3
mir-10 5
Y_RNA 4
__too_low_aQual 0
__too_low_aQual 0
__not_aligned 1
mir-8 2
mir-671 3
mir-671 16