**900**wrote:

I'm trying to convert a bam file with paired end read alignments to bed format, which is required by the F-Seq peak calling program. The bedtools bamToBed program is complaining that reads are marked as paired, but their mate doesn't appear next to it in the bam file. This is after running "samtools sort -n" on the bam file, which is what bedtools says to do to fix this. The first 10 lines from the bam are below.

HISEQ-2500-1:79:C62NNANXX:4:1101:1216:7741 163 gi|358485510|ref|NC_006089.3| 88359766 60 36M = 88359773 43 AGTTGAAAAAATGTGCTCAGGCTTCCTATTGGTTAA BBBBBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1216:7741 83 gi|358485510|ref|NC_006089.3| 88359773 60 36M = 88359766 -43 AAAATGTGCTCAGGCTTCCTATTGGTTAAGTGAAAC FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBBBBB X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1216:12449 163 gi|358485505|ref|NC_006094.3| 33794145 60 36M = 33794149 40 CAAATGGCTTTGGACTGCTTCTGCCAAATCCCAAGC BBBBBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1216:12449 83 gi|358485505|ref|NC_006094.3| 33794149 60 36M = 33794145 -40 TGGCTTTGGACTGCTTCTGCCAAATCCCAAGCCCAG FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBBBBB X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1216:21049 99 gi|358485510|ref|NC_006089.3| 145399305 60 36M = 145399308 39 CCACTGATATTTACTCTTCCTAAGCTCTAACTACAG BBBBBFBFFFFFFFFFFFFFFF<FFFFFBFFFFFFF X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1216:21049 147 gi|358485510|ref|NC_006089.3| 145399308 60 36M = 145399305 -39 CTGATATTTACTCTTCCTAAGCTCTAACTACAGCTG FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBBBBB X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1217:14270 163 gi|358485497|ref|NC_006102.3| 9271537 60 36M = 9271612 110 GGTTTGGACCACTGCTTTGGTTGTTTATGAGCAGAG <<BBBFFFFFFFFFFFFFBFFFFFFFFFFFFFFFFF X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1217:14270 83 gi|358485497|ref|NC_006102.3| 9271612 60 1S35M = 9271537 -110 CCAATGCCACAGAAAGGAACGTTCCTGTTTTGCCTA #FFFFF/FBFB<FFFFFFFFFFB<FFFFFFF<//BB X0:i:1 X1:i:0 XC:i:35 MD:Z:35 PG:Z:MarkDuplicates XG:i:0 AM:i:37 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1217:18107 99 gi|358485509|ref|NC_006090.3| 33014530 60 36M = 33014585 91 TAATTGAAAGTCTCAAATAGTATGTGACATGCCGTT BBBBBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF X0:i:1 X1:i:0 MD:Z:36 PG:Z:MarkDuplicates XG:i:0 AM:i:25 NM:i:0 SM:i:37 XM:i:0 XO:i:0 XT:A:U HISEQ-2500-1:79:C62NNANXX:4:1101:1217:18107 147 gi|358485509|ref|NC_006090.3| 33014585 60 36M = 33014530 -91 CTGATGTATGGTGGCTGCTGAAACTGCTTGCAAAAG FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBBBBB X0:i:1 X1:i:0 MD:Z:28C0T6 PG:Z:MarkDuplicates XG:i:0 AM:i:25 NM:i:2 SM:i:25 XM:i:2 XO:i:0 XT:A:U

**0**• written 4.9 years ago by colin.kern •

**900**

What is the output of

29k900Well, according to samtools, most of your reads are properly paired. Maybe bamToBed needs all reads to be properly paired (I never used it)? You may try to filter only properly paired reads and pipe them to bamToBed.

29k