To celebrate the release of GATK 4.0, we are giving away free credits for running the GATK4 Best Practices pipelines in FireCloud, our secure online analysis portal. It’s first come first serve, so sign up now to claim your free credits worth $250. Sponsored by Google Cloud. Learn more at https://software.broadinstitute.org/firecloud/documentation/freecredits

question about MergeBamAlignment

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, Broadie, Moderator

    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.