I have .sam files from RNAseq alignment. the alignment was done using Tophat.
now, I am trying to split the forward and reverse strands and make two sam files for forward and reverse strands separately. in my sam file I found 4 numbers (codes) to identify strands. the numbers are 0, 16, 272, 256.
I used the following link to see which strand they are representing:
https://broadinstitute.github.io/picard/explain-flags.html
I realized that 272 represents reverse strand but for the other 3 codes I got bit confused. can you help me to understand every number represents which strand?
2 answers
To be clear, you should perform a bitwise AND operation on any given number from the flag field so if your flag field is 272, then you say
272 AND 16 which is in binary
0100010000
& 0000010000
= 0000010000
which is "true", and in this case, means the read is reverse strand. if it was positive strand it might have flag value of say 256 and then the bitwise operation is
0100000000
& 0000010000
= 0000000000
and that is "false", so this read is not reverse strand
Also note that the strand that a given RNA-seq read does not necessarily indicate that it came from a transcript of that strand (unless you have a stranded rna-seq protocol, in which case it does, but even then if you have a stranded paired-end sequencing protocol, then the mate pair is flipped relative to the actual strand orientation)
Have you googled "explain sam flags"?
Since these is RNAseq, are you sure that knowing the orientation on the genome is really that important?
Log in to answer this question.
the sam flag is a bit array : https://en.wikipedia.org/wiki/Bit_array packed in an integer (4 bytes)