Question: Samtools Select SAM Flag for unpaired uniquely reads
2
1
Entering edit mode
8.2 years ago
lexi ▴ 20

Hi

I have a two alignments of unpaired reads, and I am trying to find out how many reads aligned uniquely from each sample. I keep reading that I should use the command

samtools view -f 0  

But when I look at the out put there is still other SAM FLAGS in the list.

any help would be appreciated but please keep it simple I'm a molecular biologist that's only just started Bioinformatics.

samtools • 3.1k views
ADD COMMENT
1
Entering edit mode

First what aligner you used?

There are two posts first here will discuss what is sam flag meaning

SAM flags meaning

and the second here about filtering sam

How To Filter Mapped Reads With Samtools

SAM and BAM filtering oneliners

It is better to filter based on MAPQ (map quality)

ADD REPLY
1
Entering edit mode
8.2 years ago
lexi ▴ 20

Figures it out

samtools view -F 256 BamFile.bam was what i needed

ADD COMMENT
0
Entering edit mode

You may want to add -F 4 to remove unmapped reads, and -h to keep the headers so that SAM/BAM viewers can read that file. The command I use (removes also reverse complements) is :

samtools view -h -F 4 -F 16 -F 256 alignments.sam | grep -E "@|NM" | grep -v "XS:" > uniq_noRev.sam

However this command screws up a bit, because the lines with "XS" are removed, while their corresponding headers remain on top of the file.

ADD REPLY
0
Entering edit mode
8.2 years ago
lexi ▴ 20

as i said i'm new so i'm not surprised my question doesn't make sense.

i'm trying to find the read that don't align to another place on the genome i am aligning to. I'm doing this by selecting using the SAM flag (https://broadinstitute.github.io/picard/explain-flags.html) and i believe i have worked it out, so that i only want the reads that have a SAM flag of 0 and 16.

But when i try to us the samtools view (on a BAM file) to select for only 0 and 16 using

samtools view -f 16 Alignment.bam

but i see other SAM flags like 272 and 256 in the output text, and i cant figure out why they are included.

ADD COMMENT

Login before adding your answer.

Traffic: 2683 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6