4.3 downsample

Downsampling a BAM file by removing reads

downsample creates downsampled BAM files that contain a specified percentage of the original number of reads. More than one percentage/probability can be specified, and thus allows the creation of several downsampled BAM files at a time. In this task, all reads are considered, even those that do not pass the usual SAM flag filters.

4.3.1 Parameters

4.3.1.1 Input

--bam Input_bam_file.bam Input bam file

4.3.1.2 Specific parameters

--prob numeric_value One value or a vector of percentages of reads to be kept in the downsampled BAM files. The numeric value must be between 0 and 1 (inclusive). It is possible to obtain replicates by adding the desired number of replicates in curly brackets {} after the concerned percentage. Incompatible with --depth.
--depth numeric_value One value or a vector of sequencing depths to downsample to. The original depth will be estimated by the task, (unless provided with --averageDepth).
--averageDepth numeric_value When using the --depth parameter to downsample, the original sequencing depth can be provided with --averageDepth (available in BAMDiagnostics outputs). If none given, the average will be computed, increasing the runtime
--separateReads downsample by distributing reads into different output-BAM-files. Sum of probabilities (--prob) cannot exceed 1.
--downsampleBases Will downsample by removing bases (i.e. replacing random bases with Ns).
--downsampleTarget Downsampling to a specific depth at target sites defined in a bed file additionally provided using --bed target.bed. Whenever read data is available, the downsampling depth provided using --depth will be reached at these positions.
--bed file.bed Bed-file to use with --downsampleTarget
--outQual integer_1,integer_2 Constrain the quality scores to the indicated range (inclusive) when writing alignments. Default = uses the full range of quality scores when writing alignments.
--writeBinnedQualities Write Illumina-binned quality scores. Default = writes raw quality scores.
--regions \*.bed Limit analysis to regions defined in BED file. Default = Parse all available positions in .bam
--acceptedDistance integer_value Specify distance up-to which mates will not be considered orphans. Default = 10000 bp.

4.3.2 Output

*_separated_*Prob*.bam or *_downsampled_*Prob*.bam Downsampled BAM files(downsampled by removing reads) or Downsampled BAM files(downsampled by setting bases to N).
*_separated_*Prob*.bam.bai or *_downsampled_*Prob*.bam.bai Index files for downsampled BAM files (downsampled by removing reads) or Index files for downsampled BAM files (downsampled by setting bases to N).

4.3.3 Usage Example

# Simulate a BAM File with depth 15
atlas simulate --depth 15

# downsample to depth 3.14
atlas downsample --bam ATLAS_simulations.bam --depth 3.14

# simplify name of downsampled bam-file
mv ATLAS_simulations_downsample_downsampled_3.14x.bam downsampled.bam
mv ATLAS_simulations_downsample_downsampled_3.14x.bam.bai downsampled.bam.bai

# Calculate depth of downsampled BAM File
atlas BAMDiagnostics --bam downsampled.bam