forked from nf-core/rnaseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
95 lines (84 loc) · 3.56 KB
/
main.nf
File metadata and controls
95 lines (84 loc) · 3.56 KB
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
86
87
88
89
90
91
92
93
94
95
nextflow.preview.types = true
record DeSeq2Result {
pdf: Path?
rdata: Path?
pca_txt: Path?
pca_multiqc: Path?
dists_txt: Path?
dists_multiqc: Path?
log: Path?
size_factors: Path?
}
process DESEQ2_QC {
label "process_medium"
// (Bio)conda packages have intentionally not been pinned to a specific version
// This was to avoid the pipeline failing due to package conflicts whilst creating the environment when using -profile conda
conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://community-cr-prod.seqera.io/docker/registry/v2/blobs/sha256/1d/1d425b12748ce54c44c01a535a1ef5867a6e16cbf62c43151012e893444b1673/data' :
'community.wave.seqera.io/library/r-base_r-optparse_r-ggplot2_r-rcolorbrewer_pruned:9e75394d0bc21987' }"
input:
counts: Path
pca_header_multiqc: Path
clustering_header_multiqc: Path
output:
record(
pdf: file("*.pdf", optional: true),
rdata: file("*.RData", optional: true),
pca_txt: file("*pca.vals.txt", optional: true),
pca_multiqc: file("*pca.vals_mqc.tsv", optional: true),
dists_txt: file("*sample.dists.txt", optional: true),
dists_multiqc: file("*sample.dists_mqc.tsv", optional: true),
log: file("*.log", optional: true),
size_factors: file("size_factors", optional: true)
)
tuple val("${task.process}"), val('r-base'), eval('echo $(R --version 2>&1) | sed "s/^.*R version //; s/ .*$//"'), topic: versions
tuple val("${task.process}"), val('bioconductor-deseq2'), eval('Rscript -e "library(DESeq2); cat(as.character(packageVersion(\'DESeq2\')))"'), topic: versions
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
def args2 = task.ext.args2 ?: ''
def label_lower = args2.toLowerCase()
def label_upper = args2.toUpperCase()
prefix = task.ext.prefix ?: "deseq2"
"""
deseq2_qc.r \\
--count_file $counts \\
--outdir ./ \\
--cores $task.cpus \\
--outprefix $prefix \\
$args
if [ -f "R_sessionInfo.log" ]; then
# Handle PCA files
sed "s/deseq2_pca/${label_lower}_deseq2_pca/g" <$pca_header_multiqc > pca_header.tmp
sed -i -e "s/DESeq2 PCA/${label_upper} DESeq2 PCA/g" pca_header.tmp
cat pca_header.tmp *.pca.vals.txt > ${label_lower}.pca.vals_mqc.tsv
rm pca_header.tmp
# Handle clustering files
sed "s/deseq2_clustering/${label_lower}_deseq2_clustering/g" <$clustering_header_multiqc > clustering_header.tmp
sed -i -e "s/DESeq2 sample/${label_upper} DESeq2 sample/g" clustering_header.tmp
cat clustering_header.tmp *.sample.dists.txt > ${label_lower}.sample.dists_mqc.tsv
rm clustering_header.tmp
fi
"""
stub:
def args2 = task.ext.args2 ?: ''
def label_lower = args2.toLowerCase()
prefix = task.ext.prefix ?: "deseq2"
"""
touch ${label_lower}.pca.vals_mqc.tsv
touch ${label_lower}.sample.dists_mqc.tsv
touch ${prefix}.dds.RData
touch ${prefix}.pca.vals.txt
touch ${prefix}.plots.pdf
touch ${prefix}.sample.dists.txt
touch R_sessionInfo.log
mkdir size_factors
touch size_factors/${prefix}.size_factors.RData
for i in `head $counts -n 1 | cut -f3-`;
do
touch size_factors/\${i}.size_factors.RData
done
"""
}