Is It Possible To Split And Merge Bam To Pileup Conversion Process?
2
1
Entering edit mode
12.7 years ago
Prateek ★ 1.0k

I want to convert bam file to pileup format. Is there a way to split into smaller jobs (by chromosomes for example) and re-merge to get the consolidated pileup file?

right now I am using "Pileup" tool from GATK but can use samtools too.

java -Xmx4g -jar ~/software/gatk/GenomeAnalysisTK/GenomeAnalysisTK.jar -I $bam -R $ref -T Pileup
samtools gatk pileup bam • 5.3k views
ADD COMMENT
0
Entering edit mode

Yes, you can split into smaller jobs using the 'bamtools split' command. In my case, I was using samtools mpileup. I found that for big jobs, such as those on multiple large bam files from many samples splitting is much faster. I think you could probably consolidate the resulting pileups with a short ad-hoc script. However, in my case, I further processed the pileups separately using variant calling software (VarScan) and then consolidated the smaller output files from that sofrtware and then removed the pileups.

ADD REPLY
3
Entering edit mode
12.7 years ago
Swbarnes2 ★ 1.6k

Both samtools view and samtools pileup can take a region as input in the command line, and will only output the region specified. Personally, I think the pileup from samtools looks nicer than the one from GATK. It's apparent immediately when the reads don't match the consensus. And samtools includes where reads start and stop, and which direction reads were going, and puts the coverage right there, so you don't have to count.

ADD COMMENT
1
Entering edit mode

perfect - thanks. The -l option of samtools mpileup takes BED file to output specified regions.

ADD REPLY
1
Entering edit mode

another option is to use -r REGION_STR

ADD REPLY
1
Entering edit mode
12.7 years ago
Vitis ★ 2.5k

You may use simple command-line tools like 'awk' to split the sam alignments before converting to bam files. There is no real utilities to split bam, but you may write your own scripts using Bio::DB::Sam modules to access the bam files and grab the part of data you want.

ADD COMMENT

Login before adding your answer.

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