Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmhadi committed Jan 9, 2025
2 parents 7f29e26 + a778eff commit 20d07e7
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 94 deletions.
168 changes: 101 additions & 67 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions conf/base.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ process {
// See https://www.nextflow.io/docs/latest/config.html#config-process-selectors
withLabel:process_single {
cpus = { check_max( 1 , 'cpus' ) }
memory = { check_max( 6.GB * task.attempt, 'memory' ) }
memory = { check_max( 18.GB * task.attempt, 'memory' ) }
time = { check_max( 4.h * task.attempt, 'time' ) }
}
withLabel:process_low {
Expand Down Expand Up @@ -65,9 +65,9 @@ process {
cpus = { check_max( 12 * task.attempt, 'cpus' ) }
memory = { check_max( 4.GB * task.attempt, 'memory' ) }
}
withName: 'BWAMEM1_MEM|BWAMEM2_MEM' {
withName: 'BWAMEM2_MEM|BWAMEM2_MEM' {
cpus = { check_max( 24 * task.attempt, 'cpus' ) }
memory = { check_max( 30.GB * task.attempt, 'memory' ) }
memory = { check_max( 72.GB * task.attempt, 'memory' ) }
}
withName: 'PARABRICKS_FQ2BAM' {
cpus = { check_max( 24 * task.attempt, 'cpus' ) }
Expand Down
10 changes: 10 additions & 0 deletions conf/modules/aligner.config
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ process {
withName: 'MERGE_BAM' {
ext.prefix = { "${meta.id}.sorted" }
}


withName: 'CRAM_TO_BAM_FINAL' {
publishDir = [
mode: params.publish_dir_mode,
path: { "${params.outdir}/alignment/final/${meta.id}/" },
pattern: "*{bam,bai}",
]
}
}

8 changes: 4 additions & 4 deletions conf/modules/recalibrate.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ process {
withName: 'GATK4_APPLYBQSR|GATK4_APPLYBQSR_SPARK' {
ext.prefix = { meta.num_intervals <= 1 ? "${meta.id}.recal" : "${meta.id}_${intervals.simpleName}.recal" }
publishDir = [
enabled: !params.save_output_as_bam,
enabled: params.save_mapped,
mode: params.publish_dir_mode,
path: { "${params.outdir}/alignment/" },
pattern: "*cram",
Expand All @@ -30,7 +30,7 @@ process {
ext.prefix = { "${meta.id}.recal" }

publishDir = [
enabled: !params.save_output_as_bam,
enabled: params.save_mapped,
mode: params.publish_dir_mode,
path: { "${params.outdir}/alignment/recalibrated/${meta.id}/" },
pattern: "*cram"
Expand All @@ -39,7 +39,7 @@ process {

withName: 'MSKILABORG_NFJABBA:NFJABBA:(BAM_APPLYBQSR|BAM_APPLYBQSR_SPARK):CRAM_MERGE_INDEX_SAMTOOLS:INDEX_CRAM' {
publishDir = [
enabled: !params.save_output_as_bam,
enabled: params.save_mapped,
mode: params.publish_dir_mode,
path: { "${params.outdir}/alignment/recalibrated/${meta.id}/" },
pattern: "*{recal.cram,recal.cram.crai}"
Expand All @@ -50,7 +50,7 @@ process {
ext.prefix = { "${meta.id}.recal" }

publishDir = [
enabled: params.save_output_as_bam,
enabled: params.save_mapped,
mode: params.publish_dir_mode,
path: { "${params.outdir}/alignment/recalibrated/${meta.id}/" },
pattern: "*{recal.bam,recal.bam.bai}"
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/bwamem2/index/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ params {
fq2bam_mark_duplicates = true // Whether fq2bam should mark duplicates, set false if not using fq2bam
fq2bam_low_memory = false // Set to true if using fq2bam with gpus that have <24GB memory
optical_duplicate_pixel_distance = 2500 // For computing optical duplicates, 2500 for NovaSeqX+
save_mapped = true // Mapped BAMs are saved
save_mapped = false // Mapped BAMs are saved
save_output_as_bam = true // Output files from alignment are saved as bam by default and not as cram files
seq_center = null // No sequencing center to be written in read group CN field by aligner
seq_platform = null // Default platform written in read group PL field by aligner, null by default.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_runs/full_test/params.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"bwa": "/gpfs/commons/home/sdider/DB/GATK/bwa/",
"outdir": "./results",
"pon_dryclean": "/gpfs/commons/home/tdey/data/dryclean/MONSTER_PON_RAW/MONSTER_PON_RAW_SORTED/fixed.detergent.rds",
"tools": "fusions",
"tools": "bamqc",
"field_dryclean": "reads",
"genome": "GATK.GRCh37",
"email": "[email protected]"
Expand Down
49 changes: 32 additions & 17 deletions workflows/nfcasereports.nf
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ inputs = inputs

ch_items.meta = ch_items.meta - ch_items.meta.subMap('lane') + [num_lanes: num_lanes.toInteger(), read_group: read_group.toString(), size: 1]

} else if (ch_items.fastq_2) {
ch_items.meta = ch_items.meta + [id: ch_items.meta.sample.toString()]
def CN = params.seq_center ? "CN:${params.seq_center}\\t" : ''

def flowcell = flowcellLaneFromFastq(ch_items.fastq_1)
def read_group = "\"@RG\\tID:${flowcell}.${ch_items.meta.sample}\\t${CN}PU:${ch_items.meta.sample}\\tSM:${ch_items.meta.patient}_${ch_items.meta.sample}\\tLB:${ch_items.meta.sample}\\tDS:${params.fasta}\\tPL:${params.seq_platform}\""

ch_items.meta = ch_items.meta + [num_lanes: num_lanes.toInteger(), read_group: read_group.toString(), size: 1]
} else if (ch_items.meta.lane && ch_items.bam) {
ch_items.meta = ch_items.meta + [id: "${ch_items.meta.sample}-${ch_items.meta.lane}".toString()]
def CN = params.seq_center ? "CN:${params.seq_center}\\t" : ''
Expand Down Expand Up @@ -1066,6 +1074,8 @@ workflow NFCASEREPORTS {
normal_frag_cov = Channel.empty()
.mix(NORMAL_FRAGCOUNTER.out.fragcounter_cov)
.mix(fragcounter_existing_outputs.normal)

normal_frag_cov_for_merge = normal_frag_cov.map { meta, frag_cov -> [ meta.sample, meta, frag_cov ] }
}

TUMOR_FRAGCOUNTER(bam_fragcounter_status.tumor)
Expand All @@ -1074,6 +1084,8 @@ workflow NFCASEREPORTS {
.mix(TUMOR_FRAGCOUNTER.out.fragcounter_cov)
.mix(fragcounter_existing_outputs.tumor)

tumor_frag_cov_for_merge = tumor_frag_cov.map { meta, frag_cov -> [ meta.sample, meta, frag_cov ] }

// Only need one versions because its just one program (fragcounter)
versions = versions.mix(TUMOR_FRAGCOUNTER.out.versions)
}
Expand All @@ -1083,15 +1095,15 @@ workflow NFCASEREPORTS {
if (tools_used.contains("all") || tools_used.contains("dryclean")) {
cov_dryclean_inputs = inputs
.filter { it.dryclean_cov.isEmpty() }
.map { it -> [it.meta] }
.map { it -> [it.meta.sample, it.meta] }
.branch{
normal: it[0].status == 0
tumor: it[0].status == 1
normal: it[1].status == 0
tumor: it[1].status == 1
}

cov_dryclean_tumor_input = tumor_frag_cov
cov_dryclean_tumor_input = tumor_frag_cov_for_merge
.join(cov_dryclean_inputs.tumor)
.map{ it -> [ it[0], it[1] ] } // meta, frag_cov
.map{ it -> [ it[1], it[2] ] } // meta, frag_cov

dryclean_existing_outputs = inputs
.map { it -> [it.meta, it.dryclean_cov] }
Expand All @@ -1114,15 +1126,18 @@ workflow NFCASEREPORTS {
versions = versions.mix(TUMOR_DRYCLEAN.out.versions)

if (!params.tumor_only) {
cov_dryclean_normal_input = normal_frag_cov
cov_dryclean_normal_input = normal_frag_cov_for_merge
.join(cov_dryclean_inputs.normal)
.map{ it -> [ it[0], it[1] ] } // meta, frag_cov
.map{ it -> [ it[1], it[2] ] } // meta, frag_cov

NORMAL_DRYCLEAN(cov_dryclean_normal_input)

dryclean_normal_cov = Channel.empty()
.mix(NORMAL_DRYCLEAN.out.dryclean_cov)
.mix(dryclean_existing_outputs.normal)

dryclean_normal_cov_for_merge = dryclean_normal_cov
.map { it -> [ it[0].patient, it[1] ] } // meta.patient, dryclean_cov
}
}

Expand All @@ -1131,22 +1146,22 @@ workflow NFCASEREPORTS {
if (tools_used.contains("all") || tools_used.contains("cbs")) {
cbs_inputs = inputs
.filter { it.seg.isEmpty() || it.nseg.isEmpty() }
.map { it -> [it.meta] }
.map { it -> [it.meta.patient, it.meta] }
.branch{
normal: it[0].status == 0
tumor: it[0].status == 1
normal: it[1].status == 0
tumor: it[1].status == 1
}

cbs_tumor_input = dryclean_tumor_cov
.join(cbs_inputs.tumor)
.map{ it -> [ it[0].patient, it[0], it[1] ] } // meta.patient, meta, dryclean tumor cov
cbs_tumor_input = cbs_inputs.tumor
.join(dryclean_tumor_cov_for_merge)
.map{ it -> [ it[0], it[1], it[2] ] } // meta.patient, meta, dryclean tumor cov

if (params.tumor_only) {
cov_cbs = cbs_tumor_input.map { patient, meta, tumor_cov -> [ meta, tumor_cov, [] ] }
} else {
cbs_normal_input = dryclean_normal_cov
.join(cbs_inputs.normal)
.map{ it -> [ it[0].patient, it[0], it[1] ] } // meta.patient, meta, dryclean normal cov
cbs_normal_input = cbs_inputs.normal
.join(dryclean_normal_cov_for_merge)
.map{ it -> [ it[0], it[1], it[2] ] } // meta.patient, meta, dryclean normal cov

cov_cbs = cbs_tumor_input.cross(cbs_normal_input)
.map { tumor, normal ->
Expand Down Expand Up @@ -1623,7 +1638,7 @@ workflow NFCASEREPORTS {
if (tools_used.contains("all") || tools_used.contains("fusions")) {
fusions_inputs = inputs.filter { it.fusions.isEmpty() }.map { it -> [it.meta.patient, it.meta] }

if (tools_used.contains("non_integer_balance")) {
if (tools_used.contains("non_integer_balance") || tools_used.contains("all")) {
fusions_input_non_integer_balance = non_integer_balance_balanced_gg_for_merge
.join(fusions_inputs)
.map { it -> [ it[0], it[1] ] } // meta.patient, balanced_gg
Expand Down

0 comments on commit 20d07e7

Please sign in to comment.