diff --git a/README.md b/README.md index 04275bd..e2e0490 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,13 @@ nextflow run BCCDC-PHL/downsample-reads \ --outdir ``` +### Random Seed + +rasusa allows users to specify a [random seed](https://github.com/mbhall88/rasusa?tab=readme-ov-file#random-seed) to be used +for its random subsampling algorithm. By default, rasusa generates a random seed at runtime using inputs from the operating system. +This pipeline sets the default random seed to `0`, which ensures that the same set of reads will be sampled given the same inputs. +A different random seed can be set using the `--random_seed` flag. + ## Output A pair of fastq.gz files will be produced for each target coverage, for each sample. @@ -220,6 +227,8 @@ In the output directory for each sample, a provenance file will be written with value: 10 - parameter: --genome-size value: 4.4m + - parameter: --seed + value: 0 - filename: NC000962-downsample-10x_R1.fastq.gz file_type: fastq-output sha256: 2fe74753d889d1b6f02832a09b10a1cab51b1fb2e16a2af20577277aded07a83 diff --git a/modules/downsample_reads.nf b/modules/downsample_reads.nf index 29beeeb..1615869 100644 --- a/modules/downsample_reads.nf +++ b/modules/downsample_reads.nf @@ -81,23 +81,26 @@ process downsample { script: """ - printf -- "- process_name: downsample\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " tools:\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " - tool_name: rasusa\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- "- process_name: downsample\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " tools:\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " - tool_name: rasusa\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml printf -- " tool_version: \$(rasusa --version 2>&1 | cut -d ' ' -f 2)\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " parameters:\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " - parameter: --coverage\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " value: ${coverage}\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " - parameter: --genome-size\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml - printf -- " value: ${genome_size}\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " parameters:\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " - parameter: --coverage\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " value: ${coverage}\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " - parameter: --genome-size\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " value: ${genome_size}\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " - parameter: --seed\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml + printf -- " value: ${params.random_seed}\\n" >> ${sample_id}_${coverage}x_downsample_provenance.yml rasusa \ - -i ${reads[0]} \ - -i ${reads[1]} \ - --coverage ${coverage} \ - --genome-size ${genome_size} \ - -o ${sample_id}-downsample-${coverage}x_R1.fastq.gz \ - -o ${sample_id}-downsample-${coverage}x_R2.fastq.gz + --seed ${params.random_seed} \ + -i ${reads[0]} \ + -i ${reads[1]} \ + --coverage ${coverage} \ + --genome-size ${genome_size} \ + -o ${sample_id}-downsample-${coverage}x_R1.fastq.gz \ + -o ${sample_id}-downsample-${coverage}x_R2.fastq.gz """ } diff --git a/nextflow.config b/nextflow.config index 34e1d28..7e2523f 100644 --- a/nextflow.config +++ b/nextflow.config @@ -1,7 +1,7 @@ manifest { author = 'Dan Fornika' name = 'BCCDC-PHL/downsample-reads' - version = '0.1.1' + version = '0.2.0' description = 'Downsample Reads' mainScript = 'main.nf' nextflowVersion = '>=20.01.0' @@ -17,6 +17,7 @@ params { coverages = 'NO_FILE' coverage = 30 genome_size = '5m' + random_seed = 0 enable_quality_trimming = false disable_quality_filtering = false collect_outputs = false