Dear all,
I completed an alignment of two groups of fastq files to a reference. To re-align the bam files to another reference I did the following:
# align
bwa mem -R <read_group1> <ref.fa> <file1_1.fq> <file1_2.fq> -o <file1_aln.sam>
bwa mem -R <read_group2> <ref.fa> <file2_1.fq> <file2_2.fq> -o <file2_aln.sam>
# convert
samtools view -Sb <file1_aln.sam> > <file1_aln.bam>
samtools view -Sb <file2_aln.sam> > <file2_aln.bam>
# sort
samtools sort <file1_aln.bam> -o <file1_alnSRT.bam>
samtools sort <file2_aln.bam> -o <file2_alnSRT.bam>
# merge
samtools merge <file_alnSRT.bam> <file1_aln.bam> <file2_aln.bam>
# select mapped
samtools view -h -F 4 <file_alnSRT.bam> -o <file_alnMAP.bam>
# convert to fastq
samtools fastq -1 <filemap_1.fq.gz> -2 <filemap_1.fq.gz> <file_alnMAP.bam>
# re-align
bwa mem -R <read_group> <ref2.fa> <filemap_1.fq.gz> <filemap_1.fq.gz> | samtools sort -o <file_realign.bam>
but I got this error at the last step:
[M::bwa_idx_load_from_disk] read 0 ALT contigs
[M::process] read 831790 sequences (80000139 bp)...
[M::process] read 872512 sequences (80000021 bp)...
[M::mem_pestat] # candidate unique pairs for (FF, FR, RF, RR): (1981, 3107, 95, 1551)
[M::mem_pestat] analyzing insert size distribution for orientation FF...
[M::mem_pestat] (25, 50, 75) percentile: (7, 14, 27)
[M::mem_pestat] low and high boundaries for computing mean and std.dev: (1, 67)
[M::mem_pestat] mean and std.dev: (16.00, 12.21)
[M::mem_pestat] low and high boundaries for proper pairs: (1, 87)
[M::mem_pestat] analyzing insert size distribution for orientation FR...
[M::mem_pestat] (25, 50, 75) percentile: (42, 47, 60)
[M::mem_pestat] low and high boundaries for computing mean and std.dev: (6, 96)
[M::mem_pestat] mean and std.dev: (52.98, 15.79)
[M::mem_pestat] low and high boundaries for proper pairs: (1, 116)
[M::mem_pestat] analyzing insert size distribution for orientation RF...
[M::mem_pestat] (25, 50, 75) percentile: (5897, 5897, 5897)
[M::mem_pestat] low and high boundaries for computing mean and std.dev: (5897, 5897)
[M::mem_pestat] mean and std.dev: (5897.00, 0.00)
[M::mem_pestat] low and high boundaries for proper pairs: (5897, 5897)
[M::mem_pestat] analyzing insert size distribution for orientation RR...
[M::mem_pestat] (25, 50, 75) percentile: (6, 17, 31)
[M::mem_pestat] low and high boundaries for computing mean and std.dev: (1, 81)
[M::mem_pestat] mean and std.dev: (19.94, 15.35)
[M::mem_pestat] low and high boundaries for proper pairs: (1, 106)
[M::mem_pestat] skip orientation RF
[mem_sam_pe] paired reads have different names: "HISEQ:90:C3UNJACXX:1:1107:16388:61141", "HISEQ:90:C3UNJACXX:3:1303:2008:58095"
[mem_sam_pe] [mem_sam_pe] paired reads have different names: "HWI-ST1437:64:C3UM1ACXX:4:1214:3833:62731", "HWI-ST1437:64:C3UM1ACXX:4:1202:18519:45906"
[mem_sam_pe] paired reads have different names: "HISEQ:90:C3UNJACXX:1:2111:17172:73588", "DHGDKXP1:247:C3MF6ACXX:2:1304:11299:10212"
[mem_sam_pe] @HD VN:1.3 SO:coordinate
@SQ SN:V LN:348678459
@PG ID:bwa PN:bwa VN:0.7.15-r1140 CL:bwa mem -t 8 [...]
Apparently, the two read groups have given the problem.
How can I solve it?
Thank you
While I've never used
samtools fastq
before, my impression is that it will simply output reads in the same order as they are found in the bam file. The error suggests you need to sort your bam file byname
before converting it to fastq.are you using a latest version?
i am using Version: 1.7
Newer versions of samtools sort will sort sam files, so you can skip the samtools view step.
Also, why are you filtering away unmapped reads if you are aligning to a different reference? How can you be sure those reads won't align to your new reference?
Your alignment to the new reference is obliterating read groups from the old files. If you don't care about read groups, you could just cat the initial files together, so you don't have to run everything twice and then merge.
dear drkennetz, see comment below. the goal i would like to achieve is filtering stuff out...