Workflow: RNA-Seq pipeline single-read strand specific

Fetched 2023-01-03 19:43:43 GMT

Note: should be updated The original [BioWardrobe's](https://biowardrobe.com) [PubMed ID:26248465](https://www.ncbi.nlm.nih.gov/pubmed/26248465) **RNA-Seq** basic analysis for **strand specific single-read** experiment. A corresponded input [FASTQ](http://maq.sourceforge.net/fastq.shtml) file has to be provided. Current workflow should be used only with the single-read RNA-Seq data. It performs the following steps: 1. Use STAR to align reads from input FASTQ file according to the predefined reference indices; generate unsorted BAM file and alignment statistics file 2. Use fastx_quality_stats to analyze input FASTQ file and generate quality statistics file 3. Use samtools sort to generate coordinate sorted BAM(+BAI) file pair from the unsorted BAM file obtained on the step 1 (after running STAR) 5. Generate BigWig file on the base of sorted BAM file 6. Map input FASTQ file to predefined rRNA reference indices using Bowtie to define the level of rRNA contamination; export resulted statistics to file 7. Calculate isoform expression level for the sorted BAM file and GTF/TAB annotation file using GEEP reads-counting utility; export results to file

children parents
Workflow as SVG
  • Selected
  • Default Values
  • Nested Workflows
  • Tools
  • Inputs/Outputs

Inputs

ID Type Title Doc
threads Integer (Optional) Number of threads

Number of threads for those steps that support multithreading

fastq_file File [FASTQ] FASTQ input file

Reads data in a FASTQ format

clip_3p_end Integer (Optional) Clip from 3p end

Number of bases to clip from the 3p end

clip_5p_end Integer (Optional) Clip from 5p end

Number of bases to clip from the 5p end

exclude_chr String (Optional) Chromosome to be excluded in rpkm calculation

Chromosome to be excluded in rpkm calculation

annotation_file File [GTF] Annotation file

GTF or TAB-separated annotation file

chrom_length_file File [Textual format] Chromosome length file

Chromosome length file

star_indices_folder Directory STAR indices folder

Path to STAR generated indices

bowtie_indices_folder Directory BowTie Ribosomal Indices

Path to Bowtie generated indices

Steps

ID Runs Label Doc
get_stat
../tools/collect-statistics-rna-seq.cwl (CommandLineTool)

Tool processes and combines log files generated by Trimgalore, Bowtie, Samtools and MACS2.

`get_output_prefix` function returns output file prefix equal to `output_prefix`+`_collected_statistics_report` (if this input is provided) or generated on the base of bowtie log basename with `_collected_statistics_report` extension.

star_aligner
../tools/star-alignreads.cwl (CommandLineTool)

Tool runs STAR alignReads.

`default_output_name_prefix` function returns output files prefix if `outFileNamePrefix` is not set. By default prefix is equal to basename of `readFilesIn`.

extract_fastq
../tools/extract-fastq.cwl (CommandLineTool)

Tool to decompress input FASTQ file(s). If several FASTQ files are provided, they will be concatenated in the order that corresponds to files in input. Bash script's logic: - disable case sensitive glob check - check if root name of input file already include '.fastq' or '.fq' extension. If yes, set DEFAULT_EXT to \"\", otherwise use '.fastq' - check file type, decompress if needed - return 1, if file type is not recognized This script also works of input file doesn't have any extension at all

bowtie_aligner
../tools/bowtie-alignreads.cwl (CommandLineTool)

Tool maps input raw reads files to reference genome using Bowtie.

`default_output_filename` function returns default name for SAM output and log files. In case when `sam` and `output_filename` inputs are not set, default filename will have `.sam` extension but format may not correspond SAM specification. To set output filename manually use `output_filename` input. Default output filename is based on `output_filename` or basename of `upstream_filelist`, `downstream_filelist` or `crossbow_filelist` file (if array, the first file in array is taken). If function is called without argenments and `output_filename` input is set, it will be returned from the function.

For single-end input data any of the `upstream_filelist` or `downstream_filelist` inputs can be used.

Log filename (`log_file` output) is generated by `default_output_filename` function with ex='.bw'

`indices_folder` defines folder to contain Bowtie indices. Based on the first found file with `rev.1.ebwt` or `rev.1.ebwtl` extension, bowtie index prefix is returned from input's `valueFrom` field.

group_isoforms
../tools/group-isoforms.cwl (CommandLineTool)

Tool runs get_gene_n_tss.R script to group isoforms by gene and common TSS

rpkm_calculation
../tools/geep.cwl (CommandLineTool)
geep

Tool calculates RPKM values grouped by isoforms or genes.

`default_output_prefix` function returns default prefix based on `bam_file` basename, if `output_prefix` is not provided.

Before running `baseCommand` `bam_file` is staged into output directory with write permissions (`\"writable\": true`). This allow to automatically generate index file at the same directory as input `bam_file`. In case when index file is provided in `secondaryFiles` of `bam_file`, it's not generated twice.

get_bam_statistics
../tools/samtools-stats.cwl (CommandLineTool)

Generates statistics for the input BAM file.

fastx_quality_stats
../tools/fastx-quality-stats.cwl (CommandLineTool)

Tool calculates statistics on the base of FASTQ file quality scores. If `output_filename` is not provided call function `default_output_filename` to return default output file name generated as `input_file` basename + `.fastxstat` extension.

samtools_sort_index
../tools/samtools-sort-index.cwl (CommandLineTool)

Tool to sort and index input BAM/SAM/CRAM. If input `trigger` is set to `true` or isn't set at all (`true` is used by default), run `samtools sort` and `samtools index`, return sorted BAM and BAI/CSI index file. If input `trigger` is set to `false`, return unchanged `sort_input` (BAM/SAM/CRAM) and index (BAI/CSI, if provided in `secondaryFiles`) files, previously staged into output directory.

Before execution `baseCommand`, `sort_input` and `secondaryFiles` (if provided) are staged into directory set as docker parameter `--workdir` (tool's output directory), using `InitialWorkDirRequirement`. Setting `writable: true` makes cwl-runner to make copies of the `sort_input` and `secondaryFiles` (if provided) and mount them to docker container with `rw` mode as part of `--workdir` (if set to false, the files staged into output directory will be mounted to docker container separately with `ro` mode). Because both `samtools sort` and `samtools index` can overwrite files with the same names (and in case of `samtools sort` even the input file can be overwritten), we don't need to rename any of the staged files.

Trigger logic is implemented in two bash scripts set by default as `bash_script_sort` and `bash_script_index` inputs. For both of then, if the first argument $0 (which is `trigger` input) is true, run `samtools sort/index` with the rest of the arguments. If $0 is not true, skip `samtools sort/index` and return `sort_input` and `secondaryFiles` (if provided) staged into output directory.

Input `trigger` is Boolean, but returns String, because of `valueFrom` field. The `valueFrom` is used, because if `trigger` is false, cwl-runner doesn't append this argument at all to the the `baseCommand` - new feature of CWL v1.0.2. Alternatively, `prefix` field could be used, but it causes changing in script logic.

If using `sort_output_filename`, the output file extension should be `*.bam`, because `samtools sort` defines the output file format on the base of the file extension. If `*.sam` is sed as output filename, it cannot be usefully indexed by `samtools index`.

`default_bam` function is used to generate output filename for `samtools sort` if input `sort_output_filename` is not set or when `trigger` is false and we need to return `sort_input` and `secondaryFiles` (if provided) files staged into output directory. Output filename is generated on the base of `sort_input` basename with `.bam` extension by default.

`ext` function is used to return the index file extension (BAI/CSI) based on `csi` and `bai` inputs according to the following logic `csi` && `bai` => BAI !`csi` && !`bai ` => BAI `csi` && !`bai ` => CSI

bam_to_bigwig_upstream

Workflow converts input BAM file into bigWig and bedGraph files.

Input BAM file should be sorted by coordinates (required by `bam_to_bedgraph` step).

If `split` input is not provided use true by default. Default logic is implemented in `valueFrom` field of `split` input inside `bam_to_bedgraph` step to avoid possible bug in cwltool with setting default values for workflow inputs.

`scale` has higher priority over the `mapped_reads_number`. The last one is used to calculate `-scale` parameter for `bedtools genomecov` (step `bam_to_bedgraph`) only in a case when input `scale` is not provided. All logic is implemented inside `bedtools-genomecov.cwl`.

`bigwig_filename` defines the output name only for generated bigWig file. `bedgraph_filename` defines the output name for generated bedGraph file and can influence on generated bigWig filename in case when `bigwig_filename` is not provided.

All workflow inputs and outputs don't have `format` field to avoid format incompatibility errors when workflow is used as subworkflow.

bam_to_bigwig_downstream

Workflow converts input BAM file into bigWig and bedGraph files.

Input BAM file should be sorted by coordinates (required by `bam_to_bedgraph` step).

If `split` input is not provided use true by default. Default logic is implemented in `valueFrom` field of `split` input inside `bam_to_bedgraph` step to avoid possible bug in cwltool with setting default values for workflow inputs.

`scale` has higher priority over the `mapped_reads_number`. The last one is used to calculate `-scale` parameter for `bedtools genomecov` (step `bam_to_bedgraph`) only in a case when input `scale` is not provided. All logic is implemented inside `bedtools-genomecov.cwl`.

`bigwig_filename` defines the output name only for generated bigWig file. `bedgraph_filename` defines the output name for generated bedGraph file and can influence on generated bigWig filename in case when `bigwig_filename` is not provided.

All workflow inputs and outputs don't have `format` field to avoid format incompatibility errors when workflow is used as subworkflow.

Outputs

ID Type Label Doc
bowtie_log File [Textual format] Bowtie alignment log

Bowtie alignment log file

rpkm_genes File [TSV] RPKM, grouped by gene name

Calculated rpkm values, grouped by gene name

bambai_pair File [BAM] Coordinate sorted BAM alignment file (+index BAI)

Coordinate sorted BAM file and BAI index file

star_sj_log File (Optional) [Textual format] STAR sj log

STAR SJ.out.tab

get_stat_log File (Optional) [YAML] YAML formatted combined log

YAML formatted combined log

star_out_log File (Optional) [Textual format] STAR log out

STAR Log.out

rpkm_isoforms File [CSV] RPKM, grouped by isoforms

Calculated rpkm values, grouped by isoforms

star_final_log File [Textual format] STAR final log

STAR Log.final.out

bigwig_upstream File [bigWig] BigWig file

Generated BigWig file

rpkm_common_tss File [TSV] RPKM, grouped by common TSS

Calculated rpkm values, grouped by common TSS

star_stdout_log File (Optional) [Textual format] STAR stdout log

STAR Log.std.out

fastx_statistics File [Textual format] FASTQ statistics

fastx_quality_stats generated FASTQ file quality statistics file

bigwig_downstream File [bigWig] BigWig file

Generated BigWig file

get_stat_markdown File (Optional) [TIDE TXT] Markdown formatted combined log

Markdown formatted combined log

star_progress_log File (Optional) [Textual format] STAR progress log

STAR Log.progress.out

get_formatted_stats File (Optional) [Textual format] Bowtie, STAR and GEEP mapping stats

Processed and combined Bowtie & STAR aligner and GEEP logs

bam_statistics_report File [Textual format] BAM statistics report

BAM statistics report (right after alignment and sorting)

Permalink: https://w3id.org/cwl/view/git/4360fb2e778ecee42e5f78f83b78c65ab3a2b1df/workflows/rnaseq-se-dutp.cwl