4.7 mergeOverlappingReads

Merging paired-end reads in BAM file

mergeOverlappingReads detects overlapping bases between paired‑end reads and soft‑clips all bases in the overlap. This ensures that no base is counted twice when both mates cover the same genomic position. By soft-clipping instead of removing the bases, they are ignored by downstream analyses while preserving the original read structure. It is advisable to run this task before any consecutive variant discovery or population genetic tool if reads weren’t merged yet.

4.7.1 Input

Required inputs :

--bam Input_bam_file.bam Input BAM file.

Optional inputs :

--recal OR --RGInfo sample_RGInfo.json Quality score recalibration file (see estimateErrors for further information).
--pmd OR --RGInfo sample_RGInfo.json Post-mortem damage parameters (see estimateErrors for further information).

Specific Parameters :

--mergingMethod method_to_be_used_for_merging To specify the method to be used for merging. Options: middle, keepFirst, keepSecond, keepFwd, keepRev, random. Default = middle. See the merging methods table for additional information on all available merging methods.
--outQual integer_1,integer_2 To constrain the quality scores to the indicated range when writing alignments. Default = Will use the full range of quality scores when writing alignments.
--writeBinnedQualities To write Illumina-binned quality scores. Default = Writes raw quality scores.
--keepOrphans To keep orphaned reads. Default = Will filter out orphaned reads.
--acceptedDistance integer_value To specify distance up-to which mates will not be considered orphans. Default = 2000 bp.
--removeSoftClippedBases Remove all softclipped bases. Default = Will not remove softclipped bases.
--filterFragmentMismatches [float_value1,float_value2] Remove all fragments whose ratio of number of mismatches to the combined mapped length outside of the specified range. Default = Don’t remove any reads regardless of number of mismatches.

Engine parameters that are common to all tasks can be found here.

4.7.2 Output

*_merged.bam A BAM file with merged reads.
*_merged.bam.bai Index files for merged BAM files.
*_filterSummary.txt A text file with filter summary.

4.7.3 Usage Example

#! /bin/bash

# Set atlas path
atlas=$(dirname "$0")/../build/atlas

# Simulate a BAM File with paired end reads
$atlas simulate --seqType "paired"

# Merge reads
$atlas mergeOverlappingReads --bam ATLAS_simulations.bam --fasta ATLAS_simulations.fasta

4.7.4 Merging Methods

middle Will keep half of the overlapping positions of each mate.
keepFirst Will keep read of first mate at overlapping positions
keepSecond Will keep read of second mate at overlapping positions.
keepFwd Will keep read of forward strand at overlapping positions.
keepRev Will keep read of reversed strand at overlapping positions.
random Will keep random read for all overlapping positions.