How to add a flag to a sam/bam file
0
0
Entering edit mode
4.2 years ago
nanoide ▴ 120

Hi there. So I'm working with paired sam/bam files, filtering and subsetting them. I have noticed in some step of the filtering I have lost the flag "properly paired" when checking with samtools flagstat. And apparently a software (danpos) is requiring this field in samtools flagstat to be filled.

Is there any way to manually add it? Made a quick look but didn't find anything. I know that they are properly paired because they are coming from a a larger bam file with all properly paired-reads... So I'm getting this from samtools flagstat:

7261380 + 0 in total (QC-passed reads + QC-failed reads)
0 + 0 secondary
0 + 0 supplementary
0 + 0 duplicates
7261380 + 0 mapped (100.00% : N/A)
7261380 + 0 paired in sequencing
3630690 + 0 read1
3630690 + 0 read2
0 + 0 properly paired (0.00% : N/A)
7261380 + 0 with itself and mate mapped
0 + 0 singletons (0.00% : N/A)
0 + 0 with mate mapped to a different chr
0 + 0 with mate mapped to a different chr (mapQ>=5)

And I would like to get also 7261380 as properly paired.

Thanks for your feedback!

ATAC-seq samtools flag filtering • 1.3k views
ADD COMMENT
1
Entering edit mode

How did you do the filtering? Please add all code to reproduce. In general samtools fixmate can set paired-end flags.

ADD REPLY
0
Entering edit mode

Thanks for your answer. I don't have the code for the creation of this file, but I believe the function splitBam in the ATACSeqQC Bioconductor package was used, to get mononucleosome bam files from the whole file. I think it's probably an issue of the tags provided to that function. I have tried samtools fixmate with default parameters but the output is the same, it's not filling the "properly paired" field. Any other suggestion? Thanks for your help

ADD REPLY
1
Entering edit mode

Any other suggestion?

Yes, find out how the file was produced and then check the documentation of the underlying tool/function towards altering flags.

ADD REPLY

Login before adding your answer.

Traffic: 1983 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