Hi,
I am trying to realign some of the bam files (paired end) using the following command. But I am getting error:
[fread] Unexpected end of file
bam.files <- list.files(pattern = ".bam$", full.names=T)
for( I in 1:length(bam.files)){
system(paste("bwa aln -t 22 ref.fa -b1 ", bam.files[i], ">", gsub(".bam", "_1.sai", bam.files[i])))
system(paste("bwa aln -t 22 ref.fa -b2 ", bam.files[i], ">", gsub(".bam", "_2.sai", bam.files[i])))
# For 2 .sai files (Paired-end)
sai.files <- list.files(pattern = ".sai$")
system(paste("bwa sampe", ref, sai.files[2 * I - 1], sai.files[2 * i], bam.files[i], bam.files[i], ">", gsub(".bam", ".sam", sai.files[2 * I - 1])))
}
Agreed! Pick your smallest file, run it in the bash terminal and if you are getting the same error post your command and the error here and we may be able to help you debug. One thing to check along the way is to ensure it is a BAM file and not a SAM file. Sometimes I get similar errors if I forget to convert SAM to BAM in a previous step but keep the BAM extension. You know it is SAM if you can read it in a text editor.