-
Notifications
You must be signed in to change notification settings - Fork 2
/
qc-report.nf
85 lines (76 loc) · 3.5 KB
/
qc-report.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// generate QC report from unfiltered and filtered SCE.rds files using scpcaTools
process sce_qc_report {
container params.SCPCATOOLS_CONTAINER
label 'mem_16'
tag "${meta.library_id}"
publishDir "${params.results_dir}/${meta.project_id}/${meta.sample_id}", mode: 'copy'
input:
tuple val(meta), path(unfiltered_rds), path(filtered_rds), path(processed_rds)
tuple path(template_dir), val(template_file), val(celltype_template_file)
output:
tuple val(meta), path(unfiltered_out), path(filtered_out), path(processed_out), path(metadata_json), emit: data
path qc_report, emit: report
path celltype_report, emit: celltype_report, optional: true
script:
qc_report = "${meta.library_id}_qc.html"
template_path = "${template_dir}/${template_file}"
metadata_json = "${meta.library_id}_metadata.json"
workflow_url = workflow.repository ?: workflow.manifest.homePage
workflow_version = workflow.revision ?: workflow.manifest.version
// names for final output files
unfiltered_out = "${meta.library_id}_unfiltered.rds"
filtered_out = "${meta.library_id}_filtered.rds"
processed_out = "${meta.library_id}_processed.rds"
// check for cell types
// only provide report template if cell typing was performed and either singler or cellassign was used
has_celltypes = params.perform_celltyping && (meta.singler_model_file || meta.cellassign_reference_file)
celltype_report = "${meta.library_id}_celltype-report.html" // rendered HTML
celltype_template_path = "${template_dir}/${celltype_template_file}" // template input
"""
# move files for output
if [ "${unfiltered_rds}" != "${unfiltered_out}" ]; then
mv "${unfiltered_rds}" "${unfiltered_out}"
fi
if [ "${filtered_rds}" != "${filtered_out}" ]; then
mv "${filtered_rds}" "${filtered_out}"
fi
if [ "${processed_rds}" != "${processed_out}" ]; then
mv "${processed_rds}" "${processed_out}"
fi
# generate report and supplemental cell type report, if applicable
sce_qc_report.R \
--report_template "${template_path}" \
--library_id "${meta.library_id}" \
--sample_id "${meta.sample_id}" \
--unfiltered_sce ${unfiltered_out} \
--filtered_sce ${filtered_out} \
--processed_sce ${processed_out} \
--qc_report_file ${qc_report} \
--celltype_report_template "${celltype_template_path}" \
${has_celltypes ? "--celltype_report_file ${celltype_report}" : ""} \
--metadata_json ${metadata_json} \
--technology "${meta.technology}" \
--seq_unit "${meta.seq_unit}" \
--genome_assembly "${meta.ref_assembly}" \
--workflow_url "${workflow_url}" \
--workflow_version "${workflow_version}" \
--workflow_commit "${workflow.commitId}" \
--seed "${params.seed}"
"""
stub:
unfiltered_out = "${meta.library_id}_unfiltered.rds"
filtered_out = "${meta.library_id}_filtered.rds"
processed_out = "${meta.library_id}_processed.rds"
qc_report = "${meta.library_id}_qc.html"
metadata_json = "${meta.library_id}_metadata.json"
has_celltypes = params.perform_celltyping && (meta.singler_model_file || meta.cellassign_reference_file)
celltype_report = "${meta.library_id}_celltype-report.html" // rendered HTML
"""
touch ${unfiltered_out}
touch ${filtered_out}
touch ${processed_out}
touch ${qc_report}
${has_celltypes ? "touch ${celltype_report}" : ""}
echo '{"unfiltered_cells": 10, "filtered_cells": 10, "processed_cells": 10}' > ${metadata_json}
"""
}