Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bam -> cram in CSV #411

Merged
merged 2 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions subworkflows/local/markduplicates_csv.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

workflow MARKDUPLICATES_CSV {
take:
bam_markduplicates // channel: [mandatory] meta, bam, bai
cram_markduplicates // channel: [mandatory] meta, cram, crai

main:
// Creating csv files to restart from this step
bam_markduplicates.collectFile(storeDir: "${params.outdir}/preprocessing/csv") { meta, bam, bai ->
cram_markduplicates.collectFile(storeDir: "${params.outdir}/preprocessing/csv") { meta, cram, crai ->
patient = meta.patient
sample = meta.sample
gender = meta.gender
status = meta.status
bam = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.bam"
bai = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.bam.bai"
cram = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.cram"
crai = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.cram.crai"
table = "${params.outdir}/preprocessing/${sample}/recal_table/${sample}.recal.table"
["markduplicates_${sample}.csv", "patient,gender,status,sample,bam,bai,table\n${patient},${gender},${status},${sample},${bam},${bai},${table}\n"]
["markduplicates_${sample}.csv", "patient,gender,status,sample,cram,crai,table\n${patient},${gender},${status},${sample},${cram},${crai},${table}\n"]
}.collectFile(name: 'markduplicates.csv', keepHeader: true, skip: 1, sort: true, storeDir: "${params.outdir}/preprocessing/csv")
}
6 changes: 3 additions & 3 deletions subworkflows/local/prepare_recalibration_csv.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ workflow PREPARE_RECALIBRATION_CSV {
sample = meta.sample
gender = meta.gender
status = meta.status
bam = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.bam"
bai = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.bam.bai"
["markduplicates_no_table_${sample}.csv", "patient,gender,status,sample,bam,bai\n${patient},${gender},${status},${sample},${bam},${bai}\n"]
cram = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.cram"
crai = "${params.outdir}/preprocessing/${sample}/markduplicates/${sample}.md.cram.crai"
["markduplicates_no_table_${sample}.csv", "patient,gender,status,sample,cram,crai\n${patient},${gender},${status},${sample},${cram},${crai}\n"]
}.collectFile(name: 'markduplicates_no_table.csv', keepHeader: true, skip: 1, sort: true, storeDir: "${params.outdir}/preprocessing/csv")
}
10 changes: 5 additions & 5 deletions subworkflows/local/recalibrate_csv.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

workflow RECALIBRATE_CSV {
take:
bam_recalibrated_index // channel: [mandatory] meta, bam, bai
cram_recalibrated_index // channel: [mandatory] meta, cram, crai

main:
// Creating csv files to restart from this step
bam_recalibrated_index.collectFile(storeDir: "${params.outdir}/preprocessing/csv") { meta, bam, bai ->
cram_recalibrated_index.collectFile(storeDir: "${params.outdir}/preprocessing/csv") { meta, cram, crai ->
patient = meta.patient
sample = meta.sample
gender = meta.gender
status = meta.status
bam = "${params.outdir}/preprocessing/${sample}/recalibrated/${sample}.recal.bam"
bai = "${params.outdir}/preprocessing/${sample}/recalibrated/${sample}.recal.bam.bai"
["recalibrated_${sample}.csv", "patient,gender,status,sample,bam,bai\n${patient},${gender},${status},${sample},${bam},${bai}\n"]
cram = "${params.outdir}/preprocessing/${sample}/recalibrated/${sample}.recal.cram"
crai = "${params.outdir}/preprocessing/${sample}/recalibrated/${sample}.recal.cram.crai"
["recalibrated_${sample}.csv", "patient,gender,status,sample,cram,crai\n${patient},${gender},${status},${sample},${cram},${crai}\n"]
}.collectFile(name: 'recalibrated.csv', keepHeader: true, skip: 1, sort: true, storeDir: "${params.outdir}/preprocessing/csv")
}
12 changes: 6 additions & 6 deletions tests/test_aligner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
- path: results/preprocessing/1234N/recal_table/1234N.recal.table
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram.crai
# - path: results/preprocessing/csv/markduplicates.csv
# - path: results/preprocessing/csv/markduplicates_1234N.csv
# - path: results/preprocessing/csv/markduplicates_no_table.csv
# - path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
# - path: results/preprocessing/csv/recalibrated.csv
# - path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/preprocessing/csv/markduplicates.csv
- path: results/preprocessing/csv/markduplicates_1234N.csv
- path: results/preprocessing/csv/markduplicates_no_table.csv
- path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
- path: results/preprocessing/csv/recalibrated.csv
- path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/reports/fastqc/1234N-1234N_M1
- path: results/reports/fastqc/1234N-1234N_M2
- path: results/reports/fastqc/1234N-1234N_M4
Expand Down
12 changes: 6 additions & 6 deletions tests/test_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
- path: results/preprocessing/1234N/recal_table/1234N.recal.table
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram.crai
# - path: results/preprocessing/csv/markduplicates.csv
# - path: results/preprocessing/csv/markduplicates_1234N.csv
# - path: results/preprocessing/csv/markduplicates_no_table.csv
# - path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
# - path: results/preprocessing/csv/recalibrated.csv
# - path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/preprocessing/csv/markduplicates.csv
- path: results/preprocessing/csv/markduplicates_1234N.csv
- path: results/preprocessing/csv/markduplicates_no_table.csv
- path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
- path: results/preprocessing/csv/recalibrated.csv
- path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/reports/fastqc/1234N-1234N_M1
- path: results/reports/fastqc/1234N-1234N_M2
- path: results/reports/fastqc/1234N-1234N_M4
Expand Down
12 changes: 6 additions & 6 deletions tests/test_gatk_spark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
- path: results/preprocessing/1234N/recal_table/1234N.recal.table
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram.crai
# - path: results/preprocessing/csv/markduplicates.csv
# - path: results/preprocessing/csv/markduplicates_1234N.csv
# - path: results/preprocessing/csv/markduplicates_no_table.csv
# - path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
# - path: results/preprocessing/csv/recalibrated.csv
# - path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/preprocessing/csv/markduplicates.csv
- path: results/preprocessing/csv/markduplicates_1234N.csv
- path: results/preprocessing/csv/markduplicates_no_table.csv
- path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
- path: results/preprocessing/csv/recalibrated.csv
- path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/reports/fastqc/1234N-1234N_M1
- path: results/reports/fastqc/1234N-1234N_M2
- path: results/reports/fastqc/1234N-1234N_M4
Expand Down
18 changes: 9 additions & 9 deletions tests/test_pair.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
- path: results/preprocessing/9876T/recal_table/9876T.recal.table
- path: results/preprocessing/9876T/recalibrated/9876T.recal.cram
- path: results/preprocessing/9876T/recalibrated/9876T.recal.cram.crai
# - path: results/preprocessing/csv/markduplicates.csv
# - path: results/preprocessing/csv/markduplicates_1234N.csv
# - path: results/preprocessing/csv/markduplicates_9876T.csv
# - path: results/preprocessing/csv/markduplicates_no_table.csv
# - path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
# - path: results/preprocessing/csv/markduplicates_no_table_9876T.csv
# - path: results/preprocessing/csv/recalibrated.csv
# - path: results/preprocessing/csv/recalibrated_1234N.csv
# - path: results/preprocessing/csv/recalibrated_9876T.csv
- path: results/preprocessing/csv/markduplicates.csv
- path: results/preprocessing/csv/markduplicates_1234N.csv
- path: results/preprocessing/csv/markduplicates_9876T.csv
- path: results/preprocessing/csv/markduplicates_no_table.csv
- path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
- path: results/preprocessing/csv/markduplicates_no_table_9876T.csv
- path: results/preprocessing/csv/recalibrated.csv
- path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/preprocessing/csv/recalibrated_9876T.csv
- path: results/reports/fastqc/1234N-1234N_M1
- path: results/reports/fastqc/1234N-1234N_M2
- path: results/reports/fastqc/1234N-1234N_M4
Expand Down
12 changes: 6 additions & 6 deletions tests/test_targeted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
- path: results/preprocessing/1234N/recal_table/1234N.recal.table
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram
- path: results/preprocessing/1234N/recalibrated/1234N.recal.cram.crai
# - path: results/preprocessing/csv/markduplicates.csv
# - path: results/preprocessing/csv/markduplicates_1234N.csv
# - path: results/preprocessing/csv/markduplicates_no_table.csv
# - path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
# - path: results/preprocessing/csv/recalibrated.csv
# - path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/preprocessing/csv/markduplicates.csv
- path: results/preprocessing/csv/markduplicates_1234N.csv
- path: results/preprocessing/csv/markduplicates_no_table.csv
- path: results/preprocessing/csv/markduplicates_no_table_1234N.csv
- path: results/preprocessing/csv/recalibrated.csv
- path: results/preprocessing/csv/recalibrated_1234N.csv
- path: results/reports/fastqc/1234N-1234N_M1
- path: results/reports/fastqc/1234N-1234N_M2
- path: results/reports/fastqc/1234N-1234N_M4
Expand Down
44 changes: 19 additions & 25 deletions workflows/sarek.nf
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,11 @@ workflow SAREK {
'samtools' in params.skip_qc,
target_bed)

// Create CSV to restart from this step
// MARKDUPLICATES_CSV(bam_markduplicates)
//TODO: Check with Maxime and add this
//CRAM_CSV(cram_markduplicates)

cram_markduplicates = QC_MARKDUPLICATES.out.cram

// Create CSV to restart from this step
MARKDUPLICATES_CSV(cram_markduplicates)

qc_reports = qc_reports.mix(QC_MARKDUPLICATES.out.qc)
}

Expand Down Expand Up @@ -469,9 +467,7 @@ workflow SAREK {
}
}

if (step == 'mapping') {
ch_software_versions = ch_software_versions.mix(FASTQC_TRIMGALORE.out.fastqc_version.first().ifEmpty(null))
}
if (step == 'mapping') ch_software_versions = ch_software_versions.mix(FASTQC_TRIMGALORE.out.fastqc_version.first().ifEmpty(null))

ch_software_versions
.map { it -> if (it) [ it.baseName, it ] }
Expand All @@ -491,9 +487,7 @@ workflow SAREK {
ch_multiqc_files = ch_multiqc_files.mix(ch_multiqc_custom_config.collect().ifEmpty([]))
ch_multiqc_files = ch_multiqc_files.mix(ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
ch_multiqc_files = ch_multiqc_files.mix(GET_SOFTWARE_VERSIONS.out.yaml.collect())
if (step == 'mapping') {
ch_multiqc_files = ch_multiqc_files.mix(FASTQC_TRIMGALORE.out.fastqc_zip.collect{it[1]}.ifEmpty([]))
}
if (step == 'mapping') ch_multiqc_files = ch_multiqc_files.mix(FASTQC_TRIMGALORE.out.fastqc_zip.collect{it[1]}.ifEmpty([]))

MULTIQC(ch_multiqc_files.collect())
multiqc_report = MULTIQC.out.report.toList()
Expand All @@ -504,13 +498,13 @@ workflow SAREK {
def extract_csv(csv_file) {
Channel.from(csv_file).splitCsv(header: true)
//Retrieves number of lanes by grouping together by patient and sample and counting how many entries there are for this combination
.map{ row -> [[row.patient.toString(), row.sample.toString()], row]}
.groupTuple()
.map{ meta, rows ->
size = rows.size()
return [rows, size]
}.transpose()
.map{ row, numLanes -> //from here do the usual thing for csv parsing
.map{ row -> [[row.patient.toString(), row.sample.toString()], row]}
.groupTuple()
.map{ meta, rows ->
size = rows.size()
return [rows, size]
}.transpose()
.map{ row, numLanes -> //from here do the usual thing for csv parsing
def meta = [:]

meta.numLanes = numLanes.toInteger()
Expand Down Expand Up @@ -544,16 +538,16 @@ def extract_csv(csv_file) {
} else if (row.table) {
// recalibration
meta.id = meta.sample
def bam = file(row.bam, checkIfExists: true)
def bai = file(row.bai, checkIfExists: true)
def cram = file(row.cram, checkIfExists: true)
def crai = file(row.crai, checkIfExists: true)
def table = file(row.table, checkIfExists: true)
return [meta, bam, bai, table]
} else if (row.bam) {
return [meta, cram, crai, table]
} else if (row.cram) {
// prepare_recalibration or variant_calling
meta.id = meta.sample
def bam = file(row.bam, checkIfExists: true)
def bai = file(row.bai, checkIfExists: true)
return [meta, bam, bai]
def cram = file(row.cram, checkIfExists: true)
def crai = file(row.crai, checkIfExists: true)
return [meta, cram, crai]
} else if (row.vcf) {
// annotation
meta.id = meta.sample
Expand Down