Description

Subsample a BAM/CRAM/SAM file using samtools to a given mean depth. “region”, “subsample_fraction”, “mean_depth” and “depth” keys will be added to the meta map to distinguish the different file generated and therefore shouldn’t be used. The depth key will be added to the meta map of the output channel.

Input

name
description
pattern

ch_bam

The input channel containing the BAM/CRAM/SAM files and their indexes.
Structure: [ val(meta), path(bam), path(bai) ]

*.{bam,cram,sam}

ch_depth

Target depth to downsample each input of ch_bam to.
Structure: [ val(meta), val(depth) ]
The meta map will be combined to the meta map of the ch_bam channel.

ch_fasta

The reference genome channel containing the fasta files and its index
Structure: [ val(meta), path(fasta), path(fai) ]

*.{fa(sta)?}

ch_region

An optional channel containing the different regions to consider
for the coverage calculation and downsampling.
Structure: [ val(meta), path(region) ]

*.bed

Output

name
description
pattern

bam_subsampled

Channel containing subsampled BAM/CRAM/SAM files and their indexes.
depth and subsample_fraction parameter will be added to the meta map.
The later will be used to set the --subsample parameter in SAMTOOLS/VIEW command.
Structure: [ val(meta), path(bam), path(csi) ]

*.{bam,cram,sam}