Hi,
I am trying bwa with SOLiD input but encounter a problem with the SAM output. Reads aligned to the - strand are stored in such a way that using them in e.g. samtools pileup or samtools tview does not report the alignment properly.
How to easily reproduce the problem:
#prepare a short reference sequence using the samtools example sequence:
head -3 /usr/local/samtools-0.1.6/examples/ex1.fa > ref.fa
samtools faidx ref.fa
qbwa index -c -p ref -a is ref.fa
#simulate a few SOLiD reads with no mismatches:
wgsim -c -e 0.0 -d 110 -s 0.00001 -N 10 -1 50 -2 50 -r0.0 -R 0.0 ref.fa sim_F3.fq sim_R3.fq
#align:
bwa aln -c ref sim_F3.fq > sim_F3.sai
bwa aln -c ref sim_R3.fq > sim_R3.sai
bwa sampe ref sim_R3.sai sim_F3.sai sim_R3.fq sim_F3.fq > sim.sam
#reformat:
samtools import ref sim.sam sim.unsorted.bam
samtools sort sim.unsorted.bam sim
samtools index sim.bam
#display alignments with tview (and edit, copy and paste output):
samtools tview sim.bam ref.fa
1 11 21 31 41 51
CACTAGTGGCTCATTGTAAATGTGTGGTTTAACTCGTCCATGGCCCAGCATTAGGGAGCT
........A..AACA...ACACACCAAA...A.CA...ACC....C..AATCCCTC
.................................................
.................................................
atcaccgagtaacatttacacaccaaattgagcaggtaccgggtcgtaa
.................................................
accgagtaacatttacacaccaaattgagcaggtaccgggtcgtaatcc
.................................................
.................................................
gagtaacatttacacaccaaattgagcaggtaccgggtcgtaatccctc
gagtaacatttacacaccaaattgagcaggtaccgggtcgtaatccctc
gagtaacatttacacaccaaattgagcaggtaccgggtcgtaatccctc
61 71 81 91 101 111
GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACNNNN
........AC..C..ACC.ACACCCCC..C..CACC.AC.CCCCAC..CTCGGCTC
.................................................
.................................................
acctgggacgtcggaccgacacccccggcgtcaccgactccccacgtct
.................................................
tgggacgtcggaccgacacccccggcgtcaccgactccccacgtctcgg
.................................................
.................................................
gacgtcggaccgacacccccggcgtcaccgactccccacgtctcggctc
gacgtcggaccgacacccccggcgtcaccgactccccacgtctcggctc
gacgtcggaccgacacccccggcgtcaccgactccccacgtctcggctc
#pileup:
samtools pileup -c -f ref.fa sim.bam | head -10
seq1 3 C C 10 0 37 1 ^F. +
seq1 4 T T 8 0 37 3 .^F.^Fa +++
seq1 5 A A 15 0 37 4 ..t^F. ++++
seq1 6 G G 15 0 37 4 ..c. ++++
seq1 7 T T 7 0 37 5 ..a.^Fa +++++
seq1 8 G G 12 0 37 6 ..c.c^F. ++++++
seq1 9 G G 17 0 37 7 ..c.c.^F. +++++++
seq1 10 C C 0 0 37 10 ..g.g..^Fg^Fg^Fg ++++++++++
seq1 11 T A 0 0 37 10 ..a.a..aaa ++++++++++
seq1 12 C C 0 0 37 10 ..g.g..ggg ++++++++++
The above outputs look a bit messy here but it's clear that half of the reads are displayed as not matching the reference sequence, which is not the case. Reads in the SAM file which have a flag field value of 65 or 129 (half of them) have a sequence in the SEQ field that can be found within the + strand of the reference sequence. In contrast the reads in the SAM file that have a flag filed value of 113 or 177 have a sequence which is the complement of part of the reference sequence (but not the reverse complement) e.g.:
seq1_56_114_0:0:0_0:0:0_1 113 seq1 7 37 49M = 65 58 ACCGAGTAACATTTACACACCAAATTGA
GCAGGTACCGGGTCGTAATCC +++++++++++++++++++++++++++++++++++++++++++++++++ XT:A:U CM:i:0 SM:i:37 AM:i:37 X0:i:1 X1:i
(sorry about the wrapping)
This line reports ACCGAG..etc which is actually the complement of part of the reference sequence (GTGGCTCATTGTAAATGTGTGGTTTAACTCGTCCATGGCCCAGCATTAGG). SO there are good alignments but they are not stored correctly in the sam file because the SAM specification say that "All mapped reads are represented on the forward genomic strand."
So am I doing something dumb or is this a problem with the way BWA produces sam format output?
Thanks for any advice or comments.
Mr M
I am trying bwa with SOLiD input but encounter a problem with the SAM output. Reads aligned to the - strand are stored in such a way that using them in e.g. samtools pileup or samtools tview does not report the alignment properly.
How to easily reproduce the problem:
#prepare a short reference sequence using the samtools example sequence:
head -3 /usr/local/samtools-0.1.6/examples/ex1.fa > ref.fa
samtools faidx ref.fa
qbwa index -c -p ref -a is ref.fa
#simulate a few SOLiD reads with no mismatches:
wgsim -c -e 0.0 -d 110 -s 0.00001 -N 10 -1 50 -2 50 -r0.0 -R 0.0 ref.fa sim_F3.fq sim_R3.fq
#align:
bwa aln -c ref sim_F3.fq > sim_F3.sai
bwa aln -c ref sim_R3.fq > sim_R3.sai
bwa sampe ref sim_R3.sai sim_F3.sai sim_R3.fq sim_F3.fq > sim.sam
#reformat:
samtools import ref sim.sam sim.unsorted.bam
samtools sort sim.unsorted.bam sim
samtools index sim.bam
#display alignments with tview (and edit, copy and paste output):
samtools tview sim.bam ref.fa
1 11 21 31 41 51
CACTAGTGGCTCATTGTAAATGTGTGGTTTAACTCGTCCATGGCCCAGCATTAGGGAGCT
........A..AACA...ACACACCAAA...A.CA...ACC....C..AATCCCTC
.................................................
.................................................
atcaccgagtaacatttacacaccaaattgagcaggtaccgggtcgtaa
.................................................
accgagtaacatttacacaccaaattgagcaggtaccgggtcgtaatcc
.................................................
.................................................
gagtaacatttacacaccaaattgagcaggtaccgggtcgtaatccctc
gagtaacatttacacaccaaattgagcaggtaccgggtcgtaatccctc
gagtaacatttacacaccaaattgagcaggtaccgggtcgtaatccctc
61 71 81 91 101 111
GTGGACCCTGCAGCCTGGCTGTGGGGGCCGCAGTGGCTGAGGGGTGCAGAGCCGAGTCACNNNN
........AC..C..ACC.ACACCCCC..C..CACC.AC.CCCCAC..CTCGGCTC
.................................................
.................................................
acctgggacgtcggaccgacacccccggcgtcaccgactccccacgtct
.................................................
tgggacgtcggaccgacacccccggcgtcaccgactccccacgtctcgg
.................................................
.................................................
gacgtcggaccgacacccccggcgtcaccgactccccacgtctcggctc
gacgtcggaccgacacccccggcgtcaccgactccccacgtctcggctc
gacgtcggaccgacacccccggcgtcaccgactccccacgtctcggctc
#pileup:
samtools pileup -c -f ref.fa sim.bam | head -10
seq1 3 C C 10 0 37 1 ^F. +
seq1 4 T T 8 0 37 3 .^F.^Fa +++
seq1 5 A A 15 0 37 4 ..t^F. ++++
seq1 6 G G 15 0 37 4 ..c. ++++
seq1 7 T T 7 0 37 5 ..a.^Fa +++++
seq1 8 G G 12 0 37 6 ..c.c^F. ++++++
seq1 9 G G 17 0 37 7 ..c.c.^F. +++++++
seq1 10 C C 0 0 37 10 ..g.g..^Fg^Fg^Fg ++++++++++
seq1 11 T A 0 0 37 10 ..a.a..aaa ++++++++++
seq1 12 C C 0 0 37 10 ..g.g..ggg ++++++++++
The above outputs look a bit messy here but it's clear that half of the reads are displayed as not matching the reference sequence, which is not the case. Reads in the SAM file which have a flag field value of 65 or 129 (half of them) have a sequence in the SEQ field that can be found within the + strand of the reference sequence. In contrast the reads in the SAM file that have a flag filed value of 113 or 177 have a sequence which is the complement of part of the reference sequence (but not the reverse complement) e.g.:
seq1_56_114_0:0:0_0:0:0_1 113 seq1 7 37 49M = 65 58 ACCGAGTAACATTTACACACCAAATTGA
GCAGGTACCGGGTCGTAATCC +++++++++++++++++++++++++++++++++++++++++++++++++ XT:A:U CM:i:0 SM:i:37 AM:i:37 X0:i:1 X1:i
(sorry about the wrapping)
This line reports ACCGAG..etc which is actually the complement of part of the reference sequence (GTGGCTCATTGTAAATGTGTGGTTTAACTCGTCCATGGCCCAGCATTAGG). SO there are good alignments but they are not stored correctly in the sam file because the SAM specification say that "All mapped reads are represented on the forward genomic strand."
So am I doing something dumb or is this a problem with the way BWA produces sam format output?
Thanks for any advice or comments.
Mr M