Description

Subsample a BAM/CRAM/SAM file using samtools to a given mean depth

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)?}

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}