The current GATK version is 3.7-0
Examples: Monday, today, last week, Mar 26, 3/26/04

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Powered by Vanilla. Made with Bootstrap.
GATK 3.7 is here! Be sure to read the Version Highlights and optionally the full Release Notes.
Register now for the upcoming GATK Best Practices workshop, Feb 20-22 in Leuven, Belgium. Open to all comers! More info and signup at http://bit.ly/2i4mGxz

question about MergeBamAlignment

ZoeChingZoeChing BeijingMember Posts: 1

Hi there,
I am trying to use the pipeline from the best practice to analysis some exome data. But I get confused on the step "MergeBamAlignment".

We used bwa to map the fastq file to the reference and then, generated unmapped bam file using picard. After we merged the aligned bam file (A) and unmapped file (B), we got a merged bam file(C). However, the merge file (C) has a smaller size than both A and B.

7.3G sample.aligned.bam(A)
5.7G sample.raw.bam (B)
4.8G sample.merged.bam(C)
6.3M sample.merged.bai

According to informations from the guidance that MergeBamAlignment takes metadata from a SAM or BAM file of unmapped reads (uBAM) and merges it with a SAM or BAM file containing alignment records for a subset of those reads, i thought the merged file would be the largest file in A, B, and C.(http://gatkforums.broadinstitute.org/gatk/discussion/5969/how-to-generate-a-bam-for-variant-discovery-long#step7)

Why the merged file is smaller than others?

Here is my command:

alignment

$bwa mem -t 12 \
-M \
-R "@RG\tID:ID001\tLB:sample001\tSM:sample001\tPL:ILLUMINA" \
$ref_dir/ucsc.hg19.fasta \
$data_dir/sample001/ID001_1.clean.fq.gz $data_dir/sample001/ID001_2.clean.fq.gz > $sam_dir/ID001.aligned.sam

sort sam

java -jar $picard/SortSam.jar \
INPUT=$sam_dir/ID001.aligned.sam \
OUTPUT=$bam_dir/ID001.aligned.bam \
SORT_ORDER=queryname \
VALIDATION_STRINGENCY=LENIENT \
CREATE_INDEX=true \
TMP_DIR=$tmp_dir

generate unmapped bam file

java -jar $picard/FastqToSam.jar \
FASTQ=$data_dir/sample001/ID001_1.clean.fq.gz \
FASTQ2=$data_dir/sample001/ID001_2.clean.fq.gz \
OUTPUT=$bam_dir/ID001.raw.bam \
READ_GROUP_NAME=ID001 \
SAMPLE_NAME=sample001 \
LIBRARY_NAME=ID001 \
PLATFORM=ILLUMINA \
SORT_ORDER=queryname \
TMP_DIR=$tmp_dir

merge two bam file

java -jar $picard/MergeBamAlignment.jar \
ALIGNED_BAM=$bam_dir/ID001.aligned.bam \
UNMAPPED_BAM=$bam_dir/ID001.raw.bam \
OUTPUT=$bam_dir/ID001.bam \
SORT_ORDER=coordinate \
R=$ref_dir/ucsc.hg19.fasta \
CREATE_INDEX=true \
ADD_MATE_CIGAR=true \
CLIP_ADAPTERS=false \
CLIP_OVERLAPPING_READS=true \
INCLUDE_SECONDARY_ALIGNMENTS=true \
MAX_INSERTIONS_OR_DELETIONS=-1 \
PRIMARY_ALIGNMENT_STRATEGY=MostDistant \
ATTRIBUTES_TO_RETAIN=XS \
PAIRED_RUN=TRUE \
TMP_DIR=$tmp_dir

I would be very grateful of any advice!
Zoe

Issue · Github
by Sheila

Issue Number
1072
State
closed
Last Updated
Assignee
Array
Milestone
Array
Closed By
sooheelee

Answers

  • shleeshlee CambridgeMember, Administrator, Broadie, Moderator, Dev Posts: 422 admin

    Hi @ZoeChing,

    You should check to see if your merged.bam (C) represents all your reads from raw.bam (B). You can do this by counting unique read names from each BAM. These numbers should be identical. Here are the commands I would use:

    samtools view merged.bam | cut -f1 | sort | uniq | wc -l
    samtools view raw.bam | cut -f1 | sort | uniq | wc -l
    
Sign In or Register to comment.