-
Notifications
You must be signed in to change notification settings - Fork 30
/
main.nf
4670 lines (3583 loc) · 166 KB
/
main.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env nextflow
/*
==========================================
nf-core/dualrnaseq
==========================================
------------------------------------------
Authors: B.Mika-Gospodorz and R.Hayward
Homepage: https://github.com/nf-core/dualrnaseq
------------------------------------------
Brief description:
------------------------------------------
Extract host and pathogen expression using three methods, with options for various statistical outputs.
1) STAR + HTSeq
2) Salmon selective alignment
3) STAR + Salmon - alignment-based mode
*/
def helpMessage() {
log.info nfcoreHeader()
log.info"""
Usage:
The typical command for running the pipeline is as follows:
nextflow run nf-core/dualrnaseq --input '*_R{1,2}.fastq.gz' -profile docker
Mandatory arguments:
--input [file] Path to input data (must be surrounded with quotes)
-profile [str] Configuration profile to use. Can use multiple (comma separated)
Available: conda, docker, singularity, test, podman, awsbatch, <institute> and more
References and annotative files can be specified in the configuration file.
Alternatively, the following params can be edited directly.
Library type and genome files:
--single_end [bool] Specifies that the input is single-end reads (default: false)
--fasta_host [file] Host genome ("folder/file.fa")
--fasta_pathogen [file] Pathogen genome
Annotation files:
--gff_host [file] Host GFF
--gff_pathogen [file] Pathogen GFF
--gff_host_tRNA [file] Host tRNA (optional)
The pipeline will automatically generate transcriptome files for both the host and pathogen.
These parameters should only be used when using custom transcriptome files
Other options:
--outdir [file] The output directory where the results will be saved
--publish_dir_mode, [str] Mode for publishing results in the output directory. Available: symlink, rellink, link, copy, copyNoFollow, move (Default: copy)
--email [email] Set this parameter to your e-mail address to get a summary e-mail with details of the run sent to you when the workflow exits
--email_on_fail [email] Same as --email, except only send mail if the workflow is not successful
--max_multiqc_email_size [str] Threshold size for MultiQC report to be attached in notification email. If file generated by pipeline exceeds the threshold, it will not be attached (Default: 25MB)
-name [str] Name for the pipeline run. If not specified, Nextflow will automatically generate a random mnemonic
Transcriptome files:
--read_transcriptome_fasta_host_from_file [bool] Include custom host transcriptome
(Default: false)
--read_transcriptome_fasta_pathogen_from_file [bool] Include custom pathogen transcriptome
(Default: false)
--transcriptome_host [file] Custom host transcriptome
(Default: "")
--transcriptome_pathogen [file] Custom pathogen transcriptome
(Default: "")
Trimming is performed by either Cutadapt or BBDuk with the following related options
Cutadapt:
--run_cutadapt [bool] To run cutadapt (Default: false)
--a [str] Adapter sequence for single-end reads or first reads of paired-end data
(Default: "AGATCGGAAGAGCACACGTCTGAACTCCAGTCA")
--A [str] Adapter sequence for second reads of paired-end data
(Default: "AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGT")
--quality-cutoff [int] Cutoff to remove low-quality ends of reads. (Default: 10)
A single cutoff value is used to trim the 3’ end of reads.
If two comma-separated cutoffs are defined, the first value reprerents 5’ cutoff,
and the second value defines the 3’ cutoff.
--cutadapt_params [str] Set of additional cutadapt parameters
BBDuk:
--run_bbduk [bool] To run BBDuk (Default: false)
--minlen [int] Reads shorter than this after trimming will be discarded.
Pairs will be discarded if both are shorter.
(Default: 18)
--qtrim [str] To trim read ends to remove bases with quality below trimq.
Possible options:rl (trim both ends), f (neither end), r (right end only),
l (left end only), w (sliding window).
(Default: "r")
--trimq [int] Cutoff to trim regions with average quality BELOW given value.
Option is avaiable if qtrim is set to something other than f.
(Default: 10)
--ktrim [str] To trim reads to remove bases matching reference kmers.
Avaiable options: f (don't trim), r (trim to the right - 3' adapters),
l (trim to the left - 5' adapters).
(Default: "r")
--k [int] Kmer length used for finding contaminants (adapters). Contaminants
shorter than k will not be found. k must be at least 1.
(Default: 17)
--mink [int] Look for shorter kmers at read tips down to this length,
when k-trimming or masking. 0 means disabled. Enabling
this will disable maskmiddle.
(Default: 11)
--hdist [int] Maximum Hamming distance for ref kmers (subs only).
(Default: 1)
--adapters [file] Fasta file with adapter sequences (Default: $projectDir/data/adapters.fa)
--bbduk_params [str] Set of additional BBDuk parameters
Basic quality control is reported through FastQC, which is run on raw reads and trimmed reads.
FastQC:
--skip_fastqc [bool] Option to skip running FastQC
--fastqc_params [str] Set of additional fastqc parameters
The following options are related to the three main methods to extract gene expression:
Salmon:
--libtype [str] To define the type of sequencing library of your data
(Default:'')
--kmer_length [int] To define the k-mer length (-k parameter in Salmon)
(Default: 21)
--writeUnmappedNames [bool] By default the pipeline does not save names of unmapped reads
(Default: false)
--softclipOverhangs [bool] By default, the pipeline does not allow soft-clipping of reads
(Default: false)
--incompatPrior [int] This is set to 0.0, to ensure that only mappings or alignments that
are compatible with the specified library type are considered by Salmon
(Default: 0.0)
--dumpEq [bool] To save the equivalence classes and their counts, change this option to True
(Default: false)
--writeMappings [bool] If set to True, the pipeline will create a files named mapping.sam
containing mapping information
(Default: false)
--keepDuplicates [bool] Option to remove/collapse identical transcripts during the indexing stage
(Default: false)
--generate_salmon_uniq_ambig [bool] Option to extract all of the unique and ambigious reads after quantification
Works for both Selective alignment and alignment-based modes
(Default: false)
Salmon selective alignment:
--run_salmon_selective_alignment [bool] Run this mode
(Default: false)
--gene_attribute_gff_to_create_transcriptome_host [str] Host transcriptome - gene attributes
(Default: transcript_id)
--gene_feature_gff_to_create_transcriptome_host [str] Host transcriptome - gene feature
(Default: ["exon", "tRNA"])
--gene_attribute_gff_to_create_transcriptome_pathogen [str] Pathogen transcriptome - gene attribute
(Default: locus_tag)
--gene_feature_gff_to_create_transcriptome_pathogen [str] Pathogen transcriptome - gene features
(Default: ["gene","sRNA","tRNA","rRNA"] )
--salmon_sa_params_index [str] Set of additional parameters for creating an index with Salmon Selective Alignment
--salmon_sa_params_mapping [str] Set of additional parameters for mapping with Salmon Selective Alignment
STAR - general options available for both modes, genome mapping with HTSeq quantification and salmon - alignment-based mode:
--run_star [bool] Run STAR
(Default: false)
--outSAMunmapped [str] By default, the pipeline saves unmapped reads
within the main BAM file. If you want to switch off this option,
set the --outSAMunmapped flag to None
(Default: Within)
--outSAMattributes [str] To specify the attributes of the output BAm file
(Default: Standard)
--outFilterMultimapNmax [int] To specify the maximum number of loci a read is allowed to map to
(Default: 999)
--outFilterType [str] By default, the pipeline keeps reads containing junctions that
passed filtering into the file SJ.out.tab. This option reduces
the number of ”spurious” junctions
(Default: BySJout)
--alignSJoverhangMin [int] The number of minimum overhang for unannotated junctions
(Default: 8)
--alignSJDBoverhangMin [int] The number of minimum overhang for annotated junctions
(Default: 1)
--outFilterMismatchNmax [int] To define a threshold for the number of mismatches to be allowed.
The pipeline uses a large number to switch this filter off
(Default: 999)
--outFilterMismatchNoverReadLmax [int] Here, you can define a threshold for a ratio of mismatches to
read length. The alignment will be considered if the ratio is
less than or equal to this value. For 2x100b, max number of
mismatches is 0.04x200=8 for paired-end reads
(Default: 1)
--alignIntronMin [int] By default, the nf-core dualrnaseq pipeline uses 20 as a
minimum intron length. If the genomic gap is smaller than this
value, it is considered as a deletion
(Default: 20)
--alignIntronMax [int] The maximum intron length
(Default: 1000000)
--alignMatesGapMax [int] The maximum genomic distance between mates is 1,000,000
(Default: 1000000)
--limitBAMsortRAM [int] Option to limit RAM when sorting BAM file.
If 0, will be set to the genome index size, which can be quite
large when running on a desktop or laptop
(Default: 0)
--winAnchorMultimapNmax [int] By default, the nf-core dualrnaseq pipeline uses 999 as a
maximum number of loci anchors that are allowed to map to
(Default: 999)
--sjdbOverhang [int] To specify the length of the donor/acceptor sequence on each side of the junctions
used in constructing the splice junctions database.
ideally = (mate length - 1)
(Default: 100)
STAR - additional options available only for genome mapping with HTSeq quantification mode
--outWigType [str] Used to generate signal outputs, such as "wiggle" and "bedGraph"
(Default: None)
--outWigStrand [str] Options are Stranded or Unstranded when defining
the strandedness of wiggle/bedGraph output
(Default: Stranded)
--star_index_params [str] Set of additional parameters for creating an index with STAR
--star_alignment_params [str] Set of additional parameters for alignment with STAR
STAR - additional options available only for Salmon - alignment-based mode:
--quantTranscriptomeBan [str] The nf-core/dualrnaseq pipeline runs STAR to generate a
transcriptomic alignments. By default, it allows for insertions,
deletions and soft-clips (Singleend option). To prohibit this
behaviour, specify IndelSoftclipSingleend
(Default: Singleend)
--star_salmon_index_params [str] Set of additional parameters for creating an index with STAR in salmon alignment-based mode
--star_salmon_alignment_params [str] Set of additional parameters for alignment with STAR in salmon alignment-based mode
Salmon - alignment-based mode:
--run_salmon_alignment_based_mode [bool] Option to run Salmn in alignment mode
(Default: false)
-- salmon_alignment_based_params [str] Set of additional parameters for Salmon in alignment-based mode
HTSeq:
--run_htseq_uniquely_mapped [bool] Option to run HTSeq
(Default: false)
--stranded [char] Is library type stranded (yes/no)
(Default: yes)
--max_reads_in_buffer [int] To define the number of maximum reads allowed to
stay in memory until the mates are found
Has an effect for paired-end reads
(Default: 30000000)
--minaqual [int] To specify a threshold for a minimal MAPQ alignment quality.(Default: 10)
Reads with the MAPQ alignment quality below the given number will be removed
(Default: 10)
--htseq_params [str] Set of additional parameters for HTSeq
--gene_feature_gff_to_quantify_host [str] Host - gene features to quantify from GFF
(Default: ["exon","tRNA"] )
--gene_feature_gff_to_quantify_pathogen [str] Pathogen - gene features to quantify from GFF
(Default: ["gene", "sRNA", "tRNA", "rRNA"] )
--host_gff_attribute [str] Host - attribute from GFF
(Default: gene_id )
--pathogen_gff_attribute [str] Pathogen - attribute from GFF
(Default: locus_tag)
RNA mapping statistics:
--mapping_statistics [bool] Option to generate mapping statistics. This will create the following:
- Count the total number of reads before and after trimming
- Scatterplots comparing all replicates (separate for both host and pathogen reads)
- Plots of the % of mapped/quantified reads
- Plots of RNA-class statistics (as many types can be identified,
the parameter below --rna_classes_to_replace_host can help to summarise these)
(Default: false)
--rna_classes_to_replace_host [file] Located within the data/ directory, this tab delimited file contains headers which
groups similar types of RNA classes together. This helps to keep the RNA-class
names simplified for plotting purposes.
(Default: $projectDir/data/RNA_classes_to_replace.tsv)
Report options:
--email [email] Set this parameter to your e-mail address to get a summary e-mail with details of the
run sent to you when the workflow exits
(Default: false)
--email_on_fail [email] Same as --email, except only send mail if the workflow is not successful
(Default: false)
--max_multiqc_email_size [str] Theshold size for MultiQC report to be attached in notification email.
If file generated by pipeline exceeds the threshold, it will not be attached
(Default: 25MB)
--plaintext_email [bool] Set to receive plain-text e-mails instead of HTML formatted
(Default: false)
--monochrome_logs [bool] Set to disable colourful command line output and live life in monochrome
(Default: false)
--multiqc_config [bool] Specify path to a custom MultiQC configuration file.
(Default: false)
AWSBatch options:
--awsqueue [str] The AWSBatch JobQueue that needs to be set when running on AWSBatch
--awsregion [str] The AWS Region for your AWS Batch job to run on
--awscli [str] Path to the AWS CLI tool
""".stripIndent()
}
// Show help message
if (params.help) {
helpMessage()
exit 0
}
/*
--------------------------------------------------------------------
SET UP CONFIGURATIONs AND IDENTIFY USER-SPECIFIED VARIABLES
--------------------------------------------------------------------
*/
//----------
// Check if genomes exists in the config file
//----------
if (params.genomes && params.genome_host && !params.genomes.containsKey(params.genome_host)) {
exit 1, "The provided genome '${params.genome_host}' is not available in the genomes.config file. Currently the available genomes are ${params.genomes.keySet().join(", ")}"
}
if (params.genomes && params.genome_pathogen && !params.genomes.containsKey(params.genome_pathogen)) {
exit 1, "The provided genome '${params.genome_pathogen}' is not available in the genomes.config file. Currently the available genomes are ${params.genomes.keySet().join(", ")}"
}
//----------
// Reference genomes, annotation files and transcriptomes
//----------
params.fasta_host = params.genome_host ? params.genomes[ params.genome_host ].fasta_host ?: false : false
if (params.fasta_host) { ch_fasta_host = file(params.fasta_host, checkIfExists: true) }
params.fasta_pathogen = params.genome_pathogen ? params.genomes[ params.genome_pathogen ].fasta_pathogen ?: false : false
if (params.fasta_pathogen) { ch_fasta_pathogen = file(params.fasta_pathogen, checkIfExists: true) }
params.gff_host_tRNA = params.genome_host ? params.genomes[ params.genome_host ].gff_host_tRNA ?: false : false
if (params.gff_host_tRNA) { ch_gff_host_tRNA = file(params.gff_host_tRNA, checkIfExists: true) }
params.gff_host_genome = params.genome_host ? params.genomes[ params.genome_host ].gff_host ?: false : false
if (params.gff_host_genome) { ch_gff_host_genome = file(params.gff_host_genome, checkIfExists: true) }
params.gff_pathogen = params.genome_pathogen ? params.genomes[ params.genome_pathogen ].gff_pathogen ?: false : false
if (params.gff_pathogen) { ch_gff_pathogen = file(params.gff_pathogen, checkIfExists: true) }
if(params.read_transcriptome_fasta_host_from_file){
params.transcriptome_host = params.genome_host ? params.genomes[ params.genome_host ].transcriptome_host ?: false : false
if (params.transcriptome_host) { ch_transcriptome_host = file(params.transcriptome_host, checkIfExists: true) }
}
if(params.read_transcriptome_fasta_pathogen_from_file){
params.transcriptome_pathogen = params.genome_pathogen ? params.genomes[ params.genome_pathogen ].transcriptome_pathogen ?: false : false
if (params.transcriptome_pathogen) { ch_transcriptome_pathogen = file(params.transcriptome_pathogen, checkIfExists: true) }
}
//----------
// Trimming - check if only one of the trimming tools is set to "true"
//----------
if (params.run_cutadapt & params.run_bbduk) {
exit 1, "Trimming: both --run_cutadapt and --run_bbduk are set to true, please use only one of the adapter trimming tools"
}
//----------
// BBDuk - fasta file of adapters
//----------
if(params.run_bbduk) {
if (params.adapters) { adapter_database = file(params.adapters, checkIfExists: true) }
}
//----------
// Salmon library type
//----------
if (params.run_salmon_selective_alignment | params.run_salmon_alignment_based_mode){
if (!params.libtype){
exit 1, "Salmon: Please specify --libtype"
} else if (params.libtype == 'A'){
// continue
} else if (params.single_end & (params.libtype != 'U' && params.libtype != 'SR' && params.libtype != 'SF')) {
exit 1, "Salmon: Invalid library type --libtype ${params.libtype}! Library types available for single-end reads are:'U', 'SR', 'SF'."
} else if (!params.single_end & (params.libtype != 'IU' && params.libtype != 'ISR' && params.libtype != 'ISF' && params.libtype != 'MU' && params.libtype != 'MSR' && params.libtype != 'MSF' && params.libtype != 'OU' && params.libtype != 'OSR' && params.libtype != 'OSF' )) {
exit 1, "Salmon: Invalid library type --libtype ${params.libtype}! Library types available for paired-end reads are: 'IU', 'ISR', 'ISF', 'MU', 'MSR', 'MSF','OU', 'OSR', 'OSF'."
}
}
//----------
// HTSeq - check if there is an alignment file
//----------
if (params.run_htseq_uniquely_mapped){
if (!params.run_star){
exit 1, "HTSeq: There is no alignment file. Please specify --run_star"
}
}
//----------
// Salmon alignment based mode - check if there is an alignment file
//----------
if (params.run_salmon_alignment_based_mode){
if (!params.run_star){
exit 1, "Salmon: There is no alignment file. Please specify --run_star"
}
}
//----------
// Mapping stats
//----------
if(params.mapping_statistics) {
if (params.rna_classes_to_replace_host) { ch_RNA_classes = file(params.rna_classes_to_replace_host, checkIfExists: true) }
}
//----------
// Has the run name been specified by the user?
// this has the bonus effect of catching both -name and --name
custom_runName = params.name
if (!(workflow.runName ==~ /[a-z]+_[a-z]+/)) {
custom_runName = workflow.runName
}
// Check AWS batch settings
if (workflow.profile.contains('awsbatch')) {
// AWSBatch sanity checking
if (!params.awsqueue || !params.awsregion) exit 1, "Specify correct --awsqueue and --awsregion parameters on AWSBatch!"
// Check outdir paths to be S3 buckets if running on AWSBatch
// related: https://github.com/nextflow-io/nextflow/issues/813
if (!params.outdir.startsWith('s3:')) exit 1, "Outdir not on S3 - specify S3 Bucket to run on AWSBatch!"
// Prevent trace files to be stored on S3 since S3 does not support rolling files.
if (params.tracedir.startsWith('s3:')) exit 1, "Specify a local tracedir or run without trace! S3 cannot be used for tracefiles."
}
//----------
// Stage config files
ch_multiqc_config = file("$workflow.projectDir/assets/multiqc_config.yaml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ? Channel.fromPath(params.multiqc_config, checkIfExists: true) : Channel.empty()
ch_output_docs = file("$workflow.projectDir/docs/output.md", checkIfExists: true)
ch_output_docs_images = file("$workflow.projectDir/docs/images/", checkIfExists: true)
/*
* Create a channel for input read files
*/
if (params.input_paths) {
if (params.single_end) {
Channel
.from(params.input_paths)
.map { row -> [ row[0], [ file(row[1][0], checkIfExists: true) ] ] }
.ifEmpty { exit 1, "params.input_paths was empty - no input files supplied" }
.into { ch_read_files_fastqc; trimming_reads; raw_read_count; scatter_plots_set }
} else {
Channel
.from(params.input_paths)
.map { row -> [ row[0], [ file(row[1][0], checkIfExists: true), file(row[1][1], checkIfExists: true) ] ] }
.ifEmpty { exit 1, "params.input_paths was empty - no input files supplied" }
.into { ch_read_files_fastqc; trimming_reads; raw_read_count;scatter_plots_set }
}
} else {
Channel
.fromFilePairs(params.input, size: params.single_end ? 1 : 2)
.ifEmpty { exit 1, "Cannot find any reads matching: ${params.input}\nNB: Path needs to be enclosed in quotes!\nIf this is single-end data, please specify --single_end on the command line." }
.into { ch_read_files_fastqc; trimming_reads; raw_read_count; scatter_plots_set}
}
//----------
// Channel for host and pathogen fasta files
//----------
Channel
.value( ch_fasta_pathogen)
.collect()
.set { genome_fasta_pathogen_to_unzip}
Channel
.value( ch_fasta_host )
.set { genome_fasta_host_to_unzip}
//----------
// Channel for host GFF and/or tRNA-based files
//----------
if(params.gff_host_tRNA){
Channel
.value(ch_gff_host_tRNA)
.set {host_gff_trna_file_to_unzip}
Channel
.value(ch_gff_host_genome)
.set {host_gff_trna_to_unzip}
}else{
Channel
.value(ch_gff_host_genome)
.set {host_gff_to_unzip}
}
//----------
// Channel for pathogen GFF files
//----------
Channel
.value(ch_gff_pathogen)
.set {pathogen_gff_to_unzip}
//----------
// Channel for host and pathogen transcriptomes
//----------
if(params.read_transcriptome_fasta_host_from_file){
Channel
.value(ch_transcriptome_host)
.into {host_transcriptome_to_combine; transcriptome_host_to_split_q_table_salmon; transcriptome_host_to_split_table_salmon; transcriptome_host_to_split_q_table_salmon_alignment_based; transcriptome_host_to_split_table_salmon_alignment; transcriptome_fasta_host_ref_names}
}
if(params.read_transcriptome_fasta_pathogen_from_file){
Channel
.value(ch_transcriptome_pathogen)
.into {pathogen_transcriptome_to_combine; transcriptome_pathogen_to_split_table_salmon; transcriptome_pathogen_to_split_table_salmon_alignment; transcriptome_pathogen_to_split_q_table_salmon; transcriptome_pathogen_to_split_q_table_salmon_alignment_based;transcriptome_fasta_pathogen_ref_names}
}
//----------
// Channel to capture Cutadapt-based params
//----------
if (params.run_cutadapt){
if(params.single_end){
Channel
.value( params.a )
.set { adapter_sequence_3 }
} else {
Channel
.from (params.a, params.A)
.collect()
.set { adapter_sequence_3 }
}
Channel
.value(params.quality_cutoff)
.set { quality_cutoff}
}
//----------
// Channel to capture BBDuk-based params
//----------
if (params.run_bbduk){
Channel
.value( adapter_database )
.set { adapter_database }
}
//----------
// Channel to capture Salmon-based params
//----------
if (params.run_salmon_selective_alignment){
Channel
.value(params.kmer_length)
.set {kmer_length_salmon_index}
}
if (params.run_salmon_selective_alignment | params.run_salmon_alignment_based_mode) {
Channel
.value(params.gene_attribute_gff_to_create_transcriptome_host)
.into {host_gff_attribute_salmon_alignment_tRNA; gene_attribute_gff_to_create_transcriptome_host_salmon; host_atr_collect_data_salmon; combine_annot_quant_pathogen; combine_annot_quant_host; atr_scatter_plot_pathogen; atr_scatter_plot_host; attribute_quant_stats_salmon; host_annotations_RNA_class_stats_pathogen; attribute_host_RNA_class_stats; host_atr_collect_data_salmon_alignment_mode; combine_annot_quant_pathogen_salmon_alignment_based; combine_annot_quant_host_salmon_alignment_based; atr_scatter_plot_pathogen_alignment; atr_scatter_plot_host_alignment; attribute_quant_stats_salmon_alignment;host_annotations_RNA_class_stats_pathogen_alignment; attribute_host_RNA_class_stats_alignment}
Channel
.value(params.gene_feature_gff_to_create_transcriptome_host)
.collect()
.into { gene_feature_gff_host_salmon_alignment; gene_feature_gff_to_create_transcriptome_host_salmon}
Channel
.value(params.gene_attribute_gff_to_create_transcriptome_pathogen)
.into {pathogen_gff_attribute_salmon_alignment; gene_attribute_gff_to_create_transcriptome_pathogen_salmon}
Channel
.value(params.gene_feature_gff_to_create_transcriptome_pathogen)
.collect()
.into {gene_feature_to_quantify_pathogen_salmon_alignment; gene_feature_to_extract_annotations_pathogen; gene_feature_gff_to_create_transcriptome_pathogen_salmon}
Channel
.value(params.libtype)
.into {libtype_salmon; libtype_salmon_alignment_mode}
}
//----------
// Channel to capture htseq and star-based params
//----------
if(params.run_htseq_uniquely_mapped | params.run_star){
Channel
.value(params.gene_feature_gff_to_quantify_host)
.collect()
.into {gene_feature_to_quantify_host; gene_feature_to_extract_annotations_host_htseq}
Channel
.value(params.gene_feature_gff_to_quantify_pathogen)
.collect()
.into {gene_feature_to_quantify_pathogen; gene_feature_to_extract_annotations_pathongen_htseq}
Channel
.value(params.pathogen_gff_attribute)
.into { pathogen_gff_attribute; pathogen_gff_attribute_to_extract_annotations_htseq}
Channel
.value(params.stranded)
.set { stranded_htseq_unique}
Channel
.value(params.host_gff_attribute)
.into { host_gff_attribute_to_pathogen; host_gff_attribute_htseq; host_gff_attribute_htseq_combine; host_gff_attribute_to_extract_annotations_htseq; host_gff_attribute_mapping_stats_htseq; host_gff_attribute_RNA_class_pathogen_htseq; host_gff_attribute_RNA_class_host_htseq; combine_annot_quant_pathogen_host_gff_attribute; host_gff_attribute_htseq_TPM; atr_scatter_plot_pathogen_htseq_u_m; atr_scatter_plot_host_htseq_u_m}
}
//----------
// Channel to capture mapping statistics-based params
//----------
if(params.mapping_statistics) {
Channel
.value(ch_RNA_classes)
.into { RNA_classes_to_replace; RNA_classes_to_replace_alignment; RNA_classes_to_replace_htseq_uniquely_mapped}
}
/*
--------------------------------------------------------------------
HEADER LOG INFO
--------------------------------------------------------------------
*/
log.info nfcoreHeader()
def summary = [:]
if (workflow.revision) summary['Pipeline Release'] = workflow.revision
summary['Run Name'] = custom_runName ?: workflow.runName
// TODO nf-core: Report custom parameters here
summary['Input'] = params.input
summary['Host Fasta Ref'] = params.fasta_host
summary['Pathogen Fasta Ref'] = params.fasta_pathogen
summary['Host tRNA gff Ref'] = params.gff_host_tRNA
summary['Host genome gff Ref'] = params.gff_host_genome
summary['Pathogen genome gff Ref'] = params.gff_pathogen
summary['Data Type'] = params.single_end ? 'Single-End' : 'Paired-End'
summary['Max Resources'] = "$params.max_memory memory, $params.max_cpus cpus, $params.max_time time per job"
if (workflow.containerEngine) summary['Container'] = "$workflow.containerEngine - $workflow.container"
summary['Output dir'] = params.outdir
summary['Launch dir'] = workflow.launchDir
summary['Working dir'] = workflow.workDir
summary['Script dir'] = workflow.projectDir
summary['User'] = workflow.userName
if (workflow.profile.contains('awsbatch')) {
summary['AWS Region'] = params.awsregion
summary['AWS Queue'] = params.awsqueue
summary['AWS CLI'] = params.awscli
}
summary['Config Profile'] = workflow.profile
if (params.config_profile_description) summary['Config Profile Description'] = params.config_profile_description
if (params.config_profile_contact) summary['Config Profile Contact'] = params.config_profile_contact
if (params.config_profile_url) summary['Config Profile URL'] = params.config_profile_url
summary['Config Files'] = workflow.configFiles.join(', ')
if (params.email || params.email_on_fail) {
summary['E-mail Address'] = params.email
summary['E-mail on failure'] = params.email_on_fail
summary['MultiQC maxsize'] = params.max_multiqc_email_size
}
log.info summary.collect { k,v -> "${k.padRight(18)}: $v" }.join("\n")
log.info "-\033[2m--------------------------------------------------\033[0m-"
// Check the hostnames against configured profiles
checkHostname()
Channel.from(summary.collect{ [it.key, it.value] })
.map { k,v -> "<dt>$k</dt><dd><samp>${v ?: '<span style=\"color:#999999;\">N/A</a>'}</samp></dd>" }
.reduce { a, b -> return [a, b].join("\n ") }
.map { x -> """
id: 'nf-core-dualrnaseq-summary'
description: " - this information is collected when the pipeline is started."
section_name: 'nf-core/dualrnaseq Workflow Summary'
section_href: 'https://github.com/nf-core/dualrnaseq'
plot_type: 'html'
data: |
<dl class=\"dl-horizontal\">
$x
</dl>
""".stripIndent() }
.set { ch_workflow_summary }
/*
--------------------------------------------------------------------
PARSE SOFTWARE VERSION NUMBERS
--------------------------------------------------------------------
*/
process get_software_versions {
publishDir "${params.outdir}/pipeline_info", mode: params.publish_dir_mode,
saveAs: { filename ->
if (filename.indexOf(".csv") > 0) filename
else null
}
output:
file 'software_versions_mqc.yaml' into ch_software_versions_yaml
file "software_versions.csv"
script:
"""
echo $workflow.manifest.version > v_pipeline.txt
echo $workflow.nextflow.version > v_nextflow.txt
python --version > v_python.txt
R --version > v_r.txt
cutadapt --version > v_cutadapt.txt
fastqc --version > v_fastqc.txt
multiqc --version > v_multiqc.txt
STAR --version > v_star.txt
htseq-count . . --version > v_htseq.txt
samtools --version > v_samtools.txt
gffread --version > v_gffread.txt
salmon --version > v_salmon.txt
scrape_software_versions.py &> software_versions_mqc.yaml
"""
}
/*
--------------------------------------------------------------------
Workflow - Processes
--------------------------------------------------------------------
*/
/*
* STEP 1 - Check if there are technical replicates - to plot scatter plots of technical replicates
*/
if(params.mapping_statistics) {
scatter_plots_set
.map { tag, file -> tag }
.set {scatter_plots}
process check_replicates {
tag "check_replicates"
label 'process_high'
input:
val(sample_name) from scatter_plots.collect()
output:
stdout repl_scatter_plots_salmon_pathogen
stdout repl_scatter_plots_salmon_host
stdout repl_scatter_plots_salmon_alignment_host
stdout repl_scatter_plots_salmon_alignment_pathogen
stdout repl_scatter_plots_htseq_pathogen
stdout repl_scatter_plots_htseq_host
shell:
'''
python !{workflow.projectDir}/bin/check_replicates.py -s !{sample_name} 2>&1
'''
}
}
/*
* STEP 2 - Prepare reference files
*/
//Uncompress Pathogen genome
process uncompress_pathogen_fasta_genome {
tag "uncompress_pathogen_genome"
publishDir "${params.outdir}/references", mode: params.publish_dir_mode
label 'process_high'
input:
each file(f_ext) from genome_fasta_pathogen_to_unzip.collect()
output:
file "${base_name_file}.fasta" into genome_fasta_pathogen_to_combine
file "${base_name_file}.fasta" into genome_fasta_pathogen_ref_names
file "${base_name_file}.fasta" into genome_fasta_pathogen_to_transcriptome
shell:
ext_file = f_ext.getExtension()
base_name_file = f_ext.getBaseName()
if (ext_file == "fasta" | ext_file == "fa"){
'''
cp -n !{f_ext} !{base_name_file}.fasta
'''
}else if(ext_file == "zip"){
old_base_name_file = base_name_file
base_name_file = old_base_name_file.replaceAll(/.fasta|.fa/,"")
'''
gunzip -f -S .zip !{f_ext}
cp -n !{old_base_name_file} !{base_name_file}.fasta
'''
}else if(ext_file == "gz"){
old_base_name_file = base_name_file
base_name_file = old_base_name_file.replaceAll(/.fasta|.fa/,"")
'''
gunzip -f !{f_ext}
cp -n !{old_base_name_file} !{base_name_file}.fasta
'''
}else {
'''
echo "Your pathogen genome files appear to have the wrong extension. \n Currently, the pipeline only supports .fasta or .fa, or compressed files with .zip or .gz extensions."
'''
}
}
//Uncompress Host genome
process uncompress_host_fasta_genome {
tag "uncompress_host_genome"
publishDir "${params.outdir}/references", mode: params.publish_dir_mode
label 'process_high'
input:
file(f_ext) from genome_fasta_host_to_unzip
output:
file "${base_name_file}.fasta" into genome_fasta_host_to_combine
file "${base_name_file}.fasta" into genome_fasta_host_to_decoys
file "${base_name_file}.fasta" into genome_fasta_host_ref_names
file "${base_name_file}.fasta" into genome_fasta_host_to_transcriptome
file "${base_name_file}.fasta" into genome_fasta_host_to_transcriptome_tRNA
shell:
//Tests to see if the input files are compressed.
//At this stage, only accepts fasta or .fa files, or .gz or .zip genome files.
ext_file = f_ext.getExtension()
base_name_file = f_ext.getBaseName()
if (ext_file == "fasta" | ext_file == "fa"){
'''
cp -n !{f_ext} !{base_name_file}.fasta
'''
}else if(ext_file == "zip"){
old_base_name_file = base_name_file
base_name_file = old_base_name_file.replaceAll(/.fasta|.fa/,"")
'''
gunzip -f -S .zip !{f_ext}
cp -n !{old_base_name_file} !{base_name_file}.fasta
'''
}else if(ext_file == "gz"){
old_base_name_file = base_name_file
base_name_file = old_base_name_file.replaceAll(/.fasta|.fa/,"")
'''
gunzip -f !{f_ext}
cp -n !{old_base_name_file} !{base_name_file}.fasta
'''
}else {
'''
echo "Your host genome files appear to have the wrong extension. \n Currently, the pipeline only supports .fasta or .fa, or compressed files with .zip or .gz extensions."
'''
}
}
//Uncompress Pathogen GFF
process uncompress_pathogen_gff {
tag "uncompress_pathogen_GFF"
publishDir "${params.outdir}/references", mode: params.publish_dir_mode
label 'process_high'
input:
file(f_ext) from pathogen_gff_to_unzip
output:
file "${base_name_file}.gff3" into gff_feature_quant_pathogen_salmon_alignment
file "${base_name_file}.gff3" into gff_pathogen_create_transcriptome
file "${base_name_file}.gff3" into gff_feature_quant_pathogen_htseq
file "${base_name_file}.gff3" into extract_annotations_pathogen_gff_htseq
shell:
//Tests to see if the input files are compressed.
//At this stage, only accepts .gff or gff3, or .gz or .zip annotation files.
ext_file = f_ext.getExtension()
base_name_file = f_ext.getBaseName()
if (ext_file == "gff" | ext_file == "gff3"){
'''
cp -n !{f_ext} !{base_name_file}.gff3
'''
}else if(ext_file == "zip"){
'''
gunzip -f -S .zip !{f_ext}
cp -n !{base_name_file} !{base_name_file}.gff3
'''
}else if(ext_file == "gz"){
//if gff or gff3, need to save as .gff3
old_base_name_file = base_name_file
base_name_file = old_base_name_file.replaceAll(/.gff|.gff3/,"")
'''
gunzip -f !{f_ext}
cp -n !{old_base_name_file} !{base_name_file}.gff3
'''
}else {
'''
echo "Your pathogen GFF file appears to be in the wrong format or has the wrong extension. \n Currently, the pipeline only supports .gff or .gff3, or compressed files with .zip or .gz extensions."
'''
}
}
//Uncompress host GFF (no tRNA)
process uncompress_host_gff {
tag "uncompress_host_GFF"
publishDir "${params.outdir}/references", mode: params.publish_dir_mode
label 'process_high'
input:
file(f_ext) from host_gff_to_unzip
output:
file "${base_name_file}.gff3" into gff_host_genome_star_salmon_change_atr
file "${base_name_file}.gff3" into gff_host_create_transcriptome
file "${base_name_file}.gff3" into gff_host_genome_htseq
file "${base_name_file}.gff3" into extract_annotations_host_gff_htseq
file "${base_name_file}.gff3" into gff_host_star_alignment_gff
file "${base_name_file}.gff3" into gff_host_star_htseq_alignment_gff
file "${base_name_file}.gff3" into genome_gff_star_index
shell:
//Tests to see if the input files are compressed.
//At this stage, only accepts .gff or gff3, or .gz or .zip annotation files.
ext_file = f_ext.getExtension()
base_name_file = f_ext.getBaseName()
if (ext_file == "gff" | ext_file == "gff3"){
'''
cp -n !{f_ext} !{base_name_file}.gff3
'''
}else if(ext_file == "zip"){
'''
gunzip -f -S .zip !{f_ext}
cp -n !{base_name_file} !{base_name_file}.gff3
'''
}else if(ext_file == "gz"){
//if gff or gff3, need to save as .gff3
old_base_name_file = base_name_file
base_name_file = old_base_name_file.replaceAll(/.gff|.gff3/,"")
'''
gunzip -f !{f_ext}
cp -n !{old_base_name_file} !{base_name_file}.gff3
'''
}else {
'''
echo "Your host GFF file appears to be in the wrong format or has the wrong extension. \n Currently, the pipeline only supports .gff or .gff3, or compressed files with .zip or .gz extensions."
'''
}
}
if(params.gff_host_tRNA){
//Uncompress host GFF (with tRNA)
process uncompress_host_gff_trna {
tag "uncompress_host_GFF_trna"
publishDir "${params.outdir}/references", mode: params.publish_dir_mode
label 'process_high'
input:
file(f_ext) from host_gff_trna_to_unzip
output:
file "${base_name_file}.gff3" into gff_host_genome_star_salmon_change_atr
file "${base_name_file}.gff3" into gff_host_create_transcriptome
file "${base_name_file}.gff3" into combine_gff_host_genome_htseq
file "${base_name_file}.gff3" into gff_host_star_alignment_gff
file "${base_name_file}.gff3" into gff_host_star_htseq_alignment_gff
file "${base_name_file}.gff3" into genome_gff_star_index
shell:
//Tests to see if the input files are compressed.
//At this stage, only accepts .gff or gff3, or .gz or .zip annotation files.