nf-core/rnaseq

repository·master·Indexed 23 days ago

https://github.com/nf-core/rnaseq

A standardized bioinformatics pipeline for RNA-seq data analysis of organisms with a reference genome and annotation. It provides quality control, trimming, and (pseudo-)alignment using tools such as STAR, Salmon, RSEM, and HiSAT2 to produce gene expression matrices and QC reports. The pipeline supports FASTQ or pre-aligned BAM files as input and includes utility scripts for samplesheet generation, DESeq2-based QC analysis, and feature percentage calculation.

Tokens
27.9K
Snippets
60
Records
150
Agent score
77%

What's inside nf-core/rnaseq

  1. Overview of nf-core/rnaseq

    master

    What is nf-core/rnaseq?

    nf-core/rnaseq is a bioinformatics pipeline for analyzing RNA sequencing data from organisms with a reference genome and annotation.

    Key Capabilities:

    • Takes FASTQ files or pre-aligned BAM files as input.
    • Performs Quality Control (QC), trimming, and (pseudo-)alignment.
    • Produces a gene expression matrix and extensive QC reports.
    • Supports multiple alignment and quantification routes (e.g., STAR -> Salmon, STAR -> RSEM, or HiSAT2).

    Important Notes:

    • SRA Downloads: SRA download functionality is no longer part of this pipeline (since version 3.2). Use nf-core/fetchngs instead. You can pass --nf_core_pipeline rnaseq to nf-core/fetchngs to automatically create a compatible samplesheet.
    • HISAT2 Limitation: If using --aligner hisat2, quantification is not performed because accurate expression estimates cannot be calculated from HISAT2 genomic alignments. This mode is intended for alignment and QC only.
  2. Handle snapshots and `.nftignore` in tests

    master

    When writing tests, follow these snapshotting conventions:

    • Non-deterministic outputs (e.g., STAR, Salmon, Kallisto, RSEM, HISAT2 indices; qualimap reports): Snapshot by file-name-only using getSnapshot() filtering.
    • Deterministic text outputs: Snapshot using md5.
    • Verbose JSON test output: Snapshot the .md5() of the result rather than inlining the JSON.
    • Avoid: Do not snapshot timestamps or paths containing hash directories.

    If a pipeline-level snapshot is unstable (e.g., due to timestamps, varying log order, or multiqc_data paths), add the file glob patterns to tests/.nftignore (or tests/.nftignore_rustqc for the RustQC variant) to exclude them from nf-test snapshots.

  3. Manage reference indices for efficiency

    master

    Generating indices (STAR, Salmon, etc.) is computationally expensive. To avoid redundant computation across runs:

    1. Use --save_reference to retain generated indices.
    2. Store these indices in a central location.
    3. Reuse them in subsequent runs by specifying the path directly (e.g., --star_index '/path/to/STAR/index/') or by including them in a custom --genome catalogue.
  4. Understand the DESeq2 Analysis Workflow

    master

    The DESeq() function is a wrapper that automates the differential expression pipeline. It performs the following core steps:

    1. Normalisation: Uses the median ratio method to calculate size factors, accounting for sequencing depth and RNA composition.
      • Warning: Always use raw integer counts as input for DESeq(). Do not use normalised counts.
    2. Dispersion Estimation: Estimates how much variance deviates from the mean. DESeq2 uses a negative binomial distribution to account for overdispersion (where variance > mean).
      • It calculates a common dispersion for the whole dataset.
      • It calculates gene-wise dispersion for each individual gene.
    3. Dispersion Fitting: Models the relationship between mean expression and dispersion (the mean-dispersion relationship) using a fitted curve.
    4. Dispersion Shrinkage: Refines gene-wise estimates by shrinking them towards the fitted curve to prevent overfitting. High-dispersion genes are typically not shrunk to avoid false positives.
    5. Model Fitting and Hypothesis Testing: Fits a Generalised Linear Model (GLM) and performs statistical testing to determine if the log2 fold change is significantly different from zero.
  5. Identify technical duplication with dupRadar

    master

    dupRadar relates duplication rates to gene expression levels to identify technical duplication.

    • Good Sample: High duplication should only occur for highly expressed genes.
    • Bad Sample: High duplication occurs across all genes, regardless of transcription level.
  6. Perform Over Representation Analysis (ORA) for biological significance

    master

    Once differentially expressed genes are identified, use Over Representation Analysis (ORA) to assign biological meaning to the results.

    ORA identifies biological pathways, molecular functions, or cellular processes that are enriched within your DE gene list, typically using the Gene Ontology (GO) database. The output is often visualized as an enrichment plot showing terms like 'clathrin-coated pit' or 'endoplasmic reticulum lumen', which helps link gene-level changes to specific cellular structures or biological processes.

  7. Configure StringTie assembly and quantification workflows

    master

    StringTie assembles RNA-Seq alignments into transcripts. The pipeline supports two modes:

    1. Reference-guided (Default): Performs a single pass of quantification against the provided GTF.
    2. De novo workflow: Triggered by setting --stringtie_ignore_gtf. This follows a three-stage process:
      • Per-sample de novo assembly (<SAMPLE>.denovo.transcripts.gtf).
      • Merging per-sample assemblies into a unified annotation (stringtie_merge.gtf).
      • Re-quantifying all samples against the merged annotation. This mode is recommended to ensure expression values are directly comparable across samples.
  8. Understand nf-core/rnaseq output and downstream analysis

    master

    The pipeline quantifies RNA-sequenced reads relative to genes/transcripts in the genome and normalizes the data.

    Important Limitations:

    • The pipeline does not perform statistical comparisons between samples (it does not calculate FDR or P-values).

    Downstream Usage:

    • The output files (gene expression matrices, etc.) are designed to be used in statistical environments like R or Julia.
    • For differential abundance testing, it is recommended to use the nf-core/differentialabundance pipeline.
  9. Choose between Wald Test and Likelihood Ratio Test (LRT) in DESeq2

    master

    The choice of statistical test depends on your experimental design:

    • Wald Test: Best for simple, two-condition comparisons (e.g., treated vs. untreated). It calculates a z-statistic by dividing the log2 fold change by its standard error and evaluates it against a standard normal distribution.
    • Likelihood Ratio Test (LRT): Best for complex, multi-factor designs. It compares a 'full model' (including the factor of interest) against a 'reduced model' (excluding it). This is used to identify genes that change in any direction across multiple sample classes.
  10. Choose quantification and alignment methods

    master

    The pipeline supports several quantification strategies depending on your choice of aligner:

    • STAR + Salmon/RSEM: Use --aligner star_salmon or --aligner star_rsem for standard genomic alignment and quantification.
    • Pseudo-alignment: For faster quantification without full alignment, use --pseudo_aligner salmon or --pseudo_aligner kallisto.

    Note: Quantification is not performed when using --aligner hisat2 because it lacks an appropriate option for accurate expression estimates in this pipeline. HISAT2 is available for users who prefer its specific alignment and QC outputs.

  11. Configure contamination screening with Sylph or Kraken2

    master

    The pipeline can scan reads for contamination from other species using either Sylph or Kraken2 (with optional Bracken refinement).

    • Default behavior: Screening runs on aligner-unmapped reads (reads rejected by STAR or HISAT2).
    • Custom input: To inspect reads entering the alignment stage (e.g., to evaluate BBSplit filtering), set --contaminant_screening_input trimmed.
    • Sylph: Faster and more memory-efficient with lower false-positive rates, but only provides overall abundance estimates and cannot assign a specific percentage of reads as unclassified.
    • Kraken2: Highly dependent on the database used. It is crucial to ensure the host genome/transcriptome is included in the database to avoid false positives. It is recommended to always use Bracken alongside Kraken2 to refine abundance estimates.
  12. Analyze genomic feature distribution with RSeQC read_distribution

    master

    The read_distribution.py script calculates how mapped reads are distributed across genomic features (e.g., CDS exon, 5’UTR exon, 3’ UTR exon, Intron, Intergenic).

    For standard RNA-seq, you typically expect a high proportion of exonic reads (CDS_Exons). A high proportion of intronic reads may indicate DNA contamination, though it can be expected in total RNA preparations.