Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

Commit

Permalink
Merge pull request #128 from ewels/master
Browse files Browse the repository at this point in the history
Bugfixing params overwriting and fixing --pico
  • Loading branch information
Hammarn authored Jun 13, 2017
2 parents 95c5dcb + 9fdf44f commit 4480545
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 47 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# NGI-RNAseq

## 1.2dev
## 1.2

* MultiQC now runs using `local` instead of `slurm` with default config
* Means that it stands a better chance of getting information from a remote database with plugins
* MultiQC now uses the workflow name for report title and filename if specified
* Fixed error where trimming parameters weren't set properly for `--pico`
* Made pipeline run in forward-stranded mode when using `--pico`


## [1.1](https://github.com/SciLifeLab/NGI-RNAseq/releases/tag/1.1) - 2017-05-23
Expand Down
43 changes: 25 additions & 18 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ Three command line flags / config parameters set the library strandedness for a
* `--reverse_stranded`
* `--unstranded`

If not set, the pipeline will be run as unstranded. The UPPMAX configuration file sets `reverse_stranded` to true by default.
Use `--unstranded` or `--forward_stranded` to overwrite this.
If not set, the pipeline will be run as unstranded. The UPPMAX configuration file sets `reverse_stranded` to true by default. Use `--unstranded` or `--forward_stranded` to overwrite this. Specifying `--pico` makes the pipeline run in `forward_stranded` mode.

These flags affect the commands used for several steps in the pipeline - namely HISAT2, featureCounts, RSeQC (`RPKM_saturation.py`)
and StringTie:
Expand Down Expand Up @@ -145,22 +144,30 @@ If specific additional trimming is required (for example, from additional tags),
you can use any of the following command line parameters. These affect the command
used to launch TrimGalore!

* `--clip_r1 [int]`
* Instructs Trim Galore to remove bp from the 5' end of read 1 (or single-end reads).
* `--clip_r2 [int]`
* Instructs Trim Galore to remove bp from the 5' end of read 2 (paired-end reads only).
* `--three_prime_clip_r1 [int]`
* Instructs Trim Galore to remove bp from the 3' end of read 1 _AFTER_ adapter/quality trimming has been performed.
* `--three_prime_clip_r2 [int]`
* Instructs Trim Galore to re move bp from the 3' end of read 2 _AFTER_ adapter/quality trimming has been performed.

### Trimming Presets
Some command line options are available to automatically set these trimming parameters
for common RNA-seq library preparation kits.

| Parameter | Kit | 5' R1 | 5' R2 | 3' R1 | 3' R2 |
|-----------|-------------------------------------------------|-------|-------|-------|-------|
| `--pico` | SMARTer Stranded Total RNA-Seq Kit - Pico Input | 3 | 0 | 0 | 3 |
### `--clip_r1 [int]`
Instructs Trim Galore to remove bp from the 5' end of read 1 (or single-end reads).

### `--clip_r2 [int]`
Instructs Trim Galore to remove bp from the 5' end of read 2 (paired-end reads only).

### `--three_prime_clip_r1 [int]`
Instructs Trim Galore to remove bp from the 3' end of read 1 _AFTER_ adapter/quality trimming has been performed.

### `--three_prime_clip_r2 [int]`
Instructs Trim Galore to re move bp from the 3' end of read 2 _AFTER_ adapter/quality trimming has been performed.


## Library Prep Presets
Some command line options are available to automatically set parameters for common RNA-seq library preparation kits.

> Note that these presets override other command line arguments. So if you specify `--pico --clip_r1 0`, the `--clip_r1` bit will be ignored.
If you have a kit that you'd like a preset added for, please let us know!

### `--pico`
Sets trimming and standedness settings for the _SMARTer Stranded Total RNA-Seq Kit - Pico Input_ kit.

Equivalent to: `--forward_stranded` `--clip_r1 3` `--three_prime_clip_r2 3`


## Job Resources
Expand Down
70 changes: 42 additions & 28 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ vim: syntax=groovy
*/

// Pipeline version
version = '1.1'
version = '1.2'

// Configurable variables
params.name = false
Expand Down Expand Up @@ -65,13 +65,25 @@ params.clip_r2 = 0
params.three_prime_clip_r1 = 0
params.three_prime_clip_r2 = 0

// Define regular variables so that they can be overwritten
clip_r1 = params.clip_r1
clip_r2 = params.clip_r2
three_prime_clip_r1 = params.three_prime_clip_r1
three_prime_clip_r2 = params.three_prime_clip_r2
forward_stranded = params.forward_stranded
reverse_stranded = params.reverse_stranded
unstranded = params.unstranded

// Preset trimming options
params.pico = false
if (params.pico){
params.clip_r1 = 3
params.clip_r2 = 0
params.three_prime_clip_r1 = 0
params.three_prime_clip_r2 = 3
clip_r1 = 3
clip_r2 = 0
three_prime_clip_r1 = 0
three_prime_clip_r2 = 3
forward_stranded = true
reverse_stranded = false
unstranded = false
}

// Choose aligner
Expand Down Expand Up @@ -148,8 +160,13 @@ def summary = [:]
summary['Run Name'] = custom_runName ?: workflow.runName
summary['Reads'] = params.reads
summary['Data Type'] = params.singleEnd ? 'Single-End' : 'Paired-End'
summary['Strandedness'] = ( params.unstranded ? 'None' : params.forward_stranded ? 'Forward' : params.reverse_stranded ? 'Reverse' : 'None' )
summary['Genome'] = params.genome
if( params.pico ) summary['Library Prep'] = "SMARTer Stranded Total RNA-Seq Kit - Pico Input"
summary['Strandedness'] = ( unstranded ? 'None' : forward_stranded ? 'Forward' : reverse_stranded ? 'Reverse' : 'None' )
summary['Trim R1'] = clip_r1
summary['Trim R2'] = clip_r2
summary["Trim 3' R1"] = three_prime_clip_r1
summary["Trim 3' R2"] = three_prime_clip_r2
if(params.aligner == 'star'){
summary['Aligner'] = "STAR"
if(params.star_index) summary['STAR Index'] = params.star_index
Expand All @@ -166,21 +183,16 @@ if(params.aligner == 'star'){
if(params.gtf) summary['GTF Annotation'] = params.gtf
else if(params.download_gtf) summary['GTF URL'] = params.download_gtf
if(params.bed12) summary['BED Annotation'] = params.bed12
summary['Save Reference'] = params.saveReference
summary['Save Trimmed'] = params.saveTrimmed
summary['Save Intermeds'] = params.saveAlignedIntermediates
summary['Output dir'] = params.outdir
summary['Working dir'] = workflow.workDir
summary['Current home'] = "$HOME"
summary['Current user'] = "$USER"
summary['Current path'] = "$PWD"
summary['Working dir'] = workflow.workDir
summary['Output dir'] = params.outdir
summary['R libraries'] = params.rlocation
summary['Script dir'] = workflow.projectDir
summary['Save Reference'] = params.saveReference
summary['Save Trimmed'] = params.saveTrimmed
summary['Save Intermeds'] = params.saveAlignedIntermediates
if( params.pico ) summary['Trim Profile'] = "SMARTer Stranded Total RNA-Seq Kit - Pico Input"
if( params.clip_r1 > 0) summary['Trim R1'] = params.clip_r1
if( params.clip_r2 > 0) summary['Trim R2'] = params.clip_r2
if( params.three_prime_clip_r1 > 0) summary["Trim 3' R1"] = params.three_prime_clip_r1
if( params.three_prime_clip_r2 > 0) summary["Trim 3' R2"] = params.three_prime_clip_r2
summary['Config Profile'] = (workflow.profile == 'standard' ? 'UPPMAX' : workflow.profile)
if(params.project) summary['UPPMAX Project'] = params.project
if(params.email) summary['E-mail Address'] = params.email
Expand Down Expand Up @@ -415,10 +427,10 @@ process trim_galore {
file "*_fastqc.{zip,html}" into trimgalore_fastqc_reports

script:
c_r1 = params.clip_r1 > 0 ? "--clip_r1 ${params.clip_r1}" : ''
c_r2 = params.clip_r2 > 0 ? "--clip_r2 ${params.clip_r2}" : ''
tpc_r1 = params.three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${params.three_prime_clip_r1}" : ''
tpc_r2 = params.three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${params.three_prime_clip_r2}" : ''
c_r1 = clip_r1 > 0 ? "--clip_r1 ${clip_r1}" : ''
c_r2 = clip_r2 > 0 ? "--clip_r2 ${clip_r2}" : ''
tpc_r1 = three_prime_clip_r1 > 0 ? "--three_prime_clip_r1 ${three_prime_clip_r1}" : ''
tpc_r2 = three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${three_prime_clip_r2}" : ''
if (params.singleEnd) {
"""
trim_galore --fastqc --gzip $c_r1 $tpc_r1 $reads
Expand Down Expand Up @@ -519,9 +531,9 @@ if(params.aligner == 'hisat2'){
index_base = hs2_indices[0].toString() - ~/.\d.ht2/
prefix = reads[0].toString() - ~/(_R1)?(_trimmed)?(_val_1)?(\.fq)?(\.fastq)?(\.gz)?$/
def rnastrandness = ''
if (params.forward_stranded && !params.unstranded){
if (forward_stranded && !unstranded){
rnastrandness = params.singleEnd ? '--rna-strandness F' : '--rna-strandness FR'
} else if (params.reverse_stranded && !params.unstranded){
} else if (reverse_stranded && !unstranded){
rnastrandness = params.singleEnd ? '--rna-strandness R' : '--rna-strandness RF'
}
if (params.singleEnd) {
Expand Down Expand Up @@ -621,9 +633,9 @@ process rseqc {

script:
def strandRule = ''
if (params.forward_stranded && !params.unstranded){
if (forward_stranded && !unstranded){
strandRule = params.singleEnd ? '-d ++,--' : '-d 1++,1--,2+-,2-+'
} else if (params.reverse_stranded && !params.unstranded){
} else if (reverse_stranded && !unstranded){
strandRule = params.singleEnd ? '-d +-,-+' : '-d 1+-,1-+,2++,2--'
}
"""
Expand Down Expand Up @@ -757,9 +769,9 @@ process featureCounts {

script:
def featureCounts_direction = 0
if (params.forward_stranded && !params.unstranded) {
if (forward_stranded && !unstranded) {
featureCounts_direction = 1
} else if (params.reverse_stranded && !params.unstranded){
} else if (reverse_stranded && !unstranded){
featureCounts_direction = 2
}
"""
Expand Down Expand Up @@ -814,9 +826,9 @@ process stringtieFPKM {

script:
def st_direction = ''
if (params.forward_stranded && !params.unstranded){
if (forward_stranded && !unstranded){
st_direction = "--fr"
} else if (params.reverse_stranded && !params.unstranded){
} else if (reverse_stranded && !unstranded){
st_direction = "--rf"
}
"""
Expand Down Expand Up @@ -962,6 +974,7 @@ workflow.onComplete {
// Send the HTML e-mail
if (params.email) {
[ 'mail', '-s', subject, params.email ].execute() << email_html
log.info "[NGI-RNAseq] Sent summary e-mail to $params.email"
}

// Write summary e-mail HTML to a file
Expand All @@ -973,5 +986,6 @@ workflow.onComplete {
output_f.withWriter { w ->
w << email_html
}
log.info "[NGI-RNAseq] Pipeline Complete"

}

0 comments on commit 4480545

Please sign in to comment.