FelixKrueger / Bismark

A tool to map bisulfite converted sequence reads and determine cytosine methylation states
http://felixkrueger.github.io/Bismark/
GNU General Public License v3.0
385 stars 101 forks source link

How to merge PE.bam and re-aligned unmapped SE.bam? #59

Closed zzwch closed 8 years ago

zzwch commented 8 years ago

Hello, @FelixKrueger I am a newbie on analysis of WGBS data. I searched a lot using google, but did not get the answer. So i have to come here to ask for help. The following is my problem.

On the advice of this. I did run PE alignments with --unmapped specified in Bismark, and the resulting unmapped Read 1 and Read 2 files then were aligned in single-end mode. As a result, I got three .bam files:

*_bismark_bt2_pe.bam
*_unmapped_reads_1_bismark_bt2.bam
*_unmapped_reads_2_bismark_bt2.bam

Should I merge these three .bam files before bismark_methylation_extractor and how to merge? or doing the following first and then how to merge the results?

bismark_methylation_extractor -p *_bismark_bt2_pe.bam
bismark_methylation_extractor -s *_unmapped_reads_1_bismark_bt2.bam
bismark_methylation_extractor -s *_unmapped_reads_1_bismark_bt2.bam

Forgive my poor English. Hope you can understand my question...

zzwch commented 8 years ago

Maybe you can add the merge process into Bismark in the future? @FelixKrueger

FelixKrueger commented 8 years ago

Hi there,

I am afraid you can't merge single and paired-end BAM files for the extraction (you could merge the two SE files though if you wanted, e.g. using: samtools cat *_unmapped_reads_1_bismark_bt2.bam *_unmapped_reads_2_bismark_bt2.bam), but you can merge the methylation call results after extracting them individually.

I personally would just run:

bismark_methylation_extractor *.bam

This will auto-detect the file type and do just the right things. Then you can run bismark2bedGraph on the combined methylation calls from both single and paired-end files with a command like:

bismark2bedGraph CpG*

This will yield a single coverage file with all your data in. I hope this helps, Best wishes, Felix

zzwch commented 8 years ago

Great! Thanks very much!