This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Failed to convert bamToBed, pair-end

Hello, I know this is kinda question the forum has been tired of. I tried all the ideas suggested by you guys in similar threads, still cannot solved the problem. So I posted here again, hopefully someone can help me to fix it. I tried to convert the bam file of ChIP-seq pair-end to bedpe, but met error: "......is marked as paired, but its mate does not occur next to it in your BAM file. Skipping.". Tried to sort, fixmate, resort, however, still have this error. Here are some command lines:

bamToBed -i test.sorted.bam | head -4

chr2    98507279 98507379       SRR40222.1.1/1        2 -

chr2    98506920 98507016       SRR40222.1.2/2        2 +

chr7    118889021       118889121       SRR40222.7.1/1  24    +

chr7    118889191       118889291       SRR40222.7.2/2  24    -

bamToBed -i test.sorted.bam -bedpe | head -4

*****WARNING: Query SRR40222.1.1 is marked as paired, but its mate does not occur next to it in your BAM file.  Skipping. 

*****WARNING: Query SRR40222.1.2 is marked as paired, but its mate does not occur next to it in your BAM file.  Skipping. 

*****WARNING: Query SRR40222.3.1 is marked as paired, but its mate does not occur next to it in your BAM file.  Skipping. 

*****WARNING: Query SRR40222.3.2 is marked as paired, but its mate does not occur next to it in your BAM file.  Skipping.

It seems the reads are definitely paired, however, the /1 and /2 were ignored.

Thanks, MJ

chip-seq

You should name sort the BAM file.

samtools  sort -n -o sorted.bam your.bam

That will bring mates next to each other on consecutive lines.

Thanks for your reply. The original bam file is already name sorted. I resorted it though, it still says the same error.

 samtools view test.renamesorted.bam | head -4

SRR40222.1.1  83      chr2    98507280        2       100M    =  98506921     -459    TGCACACTGAAGGACCTGGAATATGGCGAGAAAACTGAAAATCACGGAAAATGAGAAATACACACTTTAGGACATGAAATATGGCGAGGAAAACTGAAAN EDDDDDDDEEECAAFFFFFFFHHHHGGGGIJHCCJJIJIJJJIIDIJJIIHIIIIIJIIFDGGCIGIJIJJHEEHGIGJIIIJIIJHGGHFFBDDDD=1#   AS:i:-6 XS:i:-11   XN:i:0       XM:i:2  XO:i:0  XG:i:0  NM:i:2  MD:Z:73G25A0 YS:i:-42     YT:Z:CP

SRR40222.1.2  163     chr2    98506921        2       3M4I93M =  98507280     459     GGGGGGGGGACGTGGCATATGGCAAGAAAACTGAAAATCATGGAAAATGAGAAACATCCACTTGACGACTTGAAAAATGACGAAATCACTAAAAAACGTG CCCF?BDDDDBB9@BDDDCDDC?CCDCCDDDCCDDDDDCCCDDDADDDCCACCDDDDDDDDDDDDDBDDDDDCCCDDDDDDDBDDB>ACCCCDDCDBB?1   AS:i:-42  XS:i:-35 XN:i:0       XM:i:5  XO:i:1  XG:i:4  NM:i:9  MD:Z:1T0A8A4T37T41  YS:i:-6 YT:Z:CP

SRR40222.3.1  77      * 0     0 *     *       0       0 NAACCTTGTCCGCAAGACATATTTGCAAGCCCGGAGACAAGCAACAGACTTCTAATTGGCTTCCTCTACCCCCCTCAGATCGGAAGAGCACACGTCTGAA    #1=DDDEEFHHHFGEGGIIJGIIIEHIIIIJJJGEHGDHIEIHGIHGDEHHIJJIHFEFHGFEEDFECEEEDD;@B<CCCC?B@@BDBDDDCB9??CBC<      YT:Z:UP

SRR40222.3.2  141     * 0     0 *     *       0       0 GAGGGGGGTAGAGGAAGCCAATTAGAAGTCTGTTGCTTGTCTCCGGGCTTGCAAATATGTCTTGCGGACAAGGTTTAGATCGGAAGAGCGTCGTGTAGGG    =+:DDDDB@9@BB?BBBBB8?ABBBBBBBAABBBBBBBBBAB@>@B@BBBBBBBBBBEDD>ABAB;BBB>BBB3:3>@A@A@BBBBB??BBBB958?A@@      YT:Z:UP

Can anyone see anything wrong? Thanks!

1 answer

Your read names for read 1 and read2 do not match perfectly, so the software doesn't think they are pairs.

Log in to answer this question.