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!

Did you remember to?


1. Search using the upper-right search box, e.g. using the error message.
2. Try the latest version of tools.
3. Include tool and Java versions.
4. Tell us whether you are following GATK Best Practices.
5. Include relevant details, e.g. platform, DNA- or RNA-Seq, WES (+capture kit) or WGS (PCR-free or PCR+), paired- or single-end, read length, expected average coverage, somatic data, etc.
6. For tool errors, include the error stacktrace as well as the exact command.
7. For format issues, include the result of running ValidateSamFile for BAMs or ValidateVariants for VCFs.
8. For weird results, include an illustrative example, e.g. attach IGV screenshots according to Article#5484.
9. For a seeming variant that is uncalled, include results of following Article#1235.

Did we ask for a bug report?


Then follow instructions in Article#1894.

Formatting tip!


Surround blocks of code, error messages and BAM/VCF snippets--especially content with hashes (#)--with lines with three backticks ( ``` ) each to make a code block.
Powered by Vanilla. Made with Bootstrap.
Picard 2.9.0 is now available. Download and read release notes here.
GATK 3.7 is here! Be sure to read the Version Highlights and optionally the full Release Notes.

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, Broadie, Moderator Posts: 505 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.