Skip to content

Commit

Permalink
Execute subsampling before QC
Browse files Browse the repository at this point in the history
  • Loading branch information
seppinho committed Mar 7, 2024
1 parent 7e79495 commit 4d1e6a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
8 changes: 5 additions & 3 deletions cloudgene.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ workflow:
off: Off

- id: subsampling
description: Subsample to 2000x
description: Coverage Subsampling
type: number
visible: true
default: off
values:
on: On
off: Off
off: No subsampling
on: Subsample to 2000x


- id: myseparator0
type: separator
Expand Down
10 changes: 7 additions & 3 deletions modules/local/subsampling.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@ process SUBSAMPLING {
# convert to integer
mean_cov_int=\$(printf "%.0f" "\$mean_cov")
# set seed to 1 (for reproducbility) and FRAC to coverage/mean_cov (e.g. 1.2)
fraction=\$(echo "scale=4; 1+(${coverage} / \${mean_cov})" | bc)
fraction=\$(echo "scale=4; ${coverage} / \${mean_cov}" | bc)
if [ \${mean_cov_int} -gt ${coverage} ]
then
samtools view -s \$fraction -b -o ${bam_file.baseName}.subsampled.bam ${bam_file}
samtools view \
--subsample-seed 1 \
--subsample \$fraction \
-b \
-o ${bam_file.baseName}.subsampled.bam ${bam_file}
mv ${bam_file.baseName}.subsampled.bam ${bam_file}
fi
"""
Expand Down
2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ params {
alignQ = 30
coverage_estimation = "on"
max_samples = 0
subsampling = "on"
subsampling = "off"
subsampling_coverage = 2000


Expand Down
16 changes: 8 additions & 8 deletions workflows/mtdna_server_2.nf
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ workflow MTDNA_SERVER_2 {
ref_file_mutect2
)

if(params.subsampling.equals("on") ) {
SUBSAMPLING (
bams_ch,
params.subsampling_coverage
)
bams_ch = SUBSAMPLING.out.subsampled_bam_ch
}

CALCULATE_STATISTICS(
bams_ch
)
Expand All @@ -84,14 +92,6 @@ workflow MTDNA_SERVER_2 {

validated_files = INPUT_VALIDATION.out.validated_files.flatten()

if(params.subsampling.equals("on") ) {
SUBSAMPLING (
validated_files,
params.subsampling_coverage
)
validated_files = SUBSAMPLING.out.subsampled_bam_ch
}

if (params.mode == 'mutserve') {

MUTSERVE(
Expand Down

0 comments on commit 4d1e6a4

Please sign in to comment.