How to Build a Reproducible RNA-seq Analysis Pipeline with Snakemake: A Step-by-Step Guide

By Dr. Zubair Khalid, DVM, MS, PhD ·

How to Build a Reproducible RNA-seq Analysis Pipeline with Snakemake: A Step-by-Step Guide

Key Takeaways

  • Reproducible RNA-seq analysis pipelines are built using workflow management systems like Snakemake, which automate the connection between analysis steps (quality control, alignment, quantification, differential expression) and meticulously document each execution.
  • Key principles for reproducibility include strict version control of all software and reference data (e.g., genome assemblies, annotation files), explicit definition of configuration parameters in separate files, and consistent management of the execution environment.
  • Pipeline structure involves organizing sample metadata, preparing reference data once, defining quality control rules (e.g., FastQC, MultiQC) to assess raw and processed reads, and implementing alignment (e.g., STAR, HISAT2) and quantification (e.g., featureCounts, RSEM) rules.
  • Differential expression analysis, typically performed with tools like DESeq2 or edgeR, requires a clearly defined experimental design matrix and contrast, with results being gene-level count tables and associated statistical measures.
  • Effective troubleshooting involves examining pipeline logs, verifying reference index integrity, confirming library strandedness, managing memory allocation for resource-intensive tools, and ensuring consistent sample naming conventions.
  • Comprehensive reporting of RNA-seq results necessitates documenting pipeline logs, software versions, quality metrics (e.g., read counts, alignment rates), and a snapshot of the configuration file to enable full re-analysis.

RNA sequencing has become a standard method for measuring RNA abundance across tissues, cell types, and experimental conditions, but the computational steps that convert raw sequencing files into interpretable results require careful organization. A Snakemake-based pipeline gives researchers a structured way to manage quality control, alignment, quantification, and differential expression analysis while keeping every step documented and repeatable. This guide explains how to build such a pipeline for bulk RNA-seq data, with concrete decisions about workflow structure, rule definitions, configuration files, and execution strategies.

Why Snakemake for RNA-seq Analysis

The volume of RNA-seq data generated each year continues to grow, and this increase creates a practical need for pipelines that process data consistently across experiments. Workflow management systems address this need by automating the connections between analysis steps and by recording exactly what was done. Snakemake is one such system that has been adopted across many published RNA-seq pipelines because it combines Python-based rule definitions with dependency tracking and parallel execution.

Several published pipelines demonstrate the range of what Snakemake can handle in RNA-seq analysis. The VIPER pipeline combines popular tools to take RNA-seq data from raw reads through alignment, quality control, differential expression, and pathway analysis in a modular design that allows new tools to be added. The hppRNA pipeline embeds six independent core workflows in Snakemake, covering tools such as STAR-RSEM-EBSeq, kallisto-sleuth, and HISAT-StringTie-Ballgown, and is designed for processing large numbers of samples on local servers. The AutoRNAseq pipeline provides an end-to-end workflow that automates data retrieval, reference preparation, quality control, alignment, and quantification with minimal user intervention. These examples show that Snakemake scales from small pilot studies to systematic analyses of many samples.

For researchers who need to process RNA-seq data reproducibly, Snakemake offers three practical advantages. First, each rule declares its inputs and outputs explicitly, so the pipeline knows what must run before what. Second, Snakemake tracks file timestamps and checksums, so rerunning the pipeline only executes steps whose inputs changed. Third, the workflow definition itself is a text file that can be version-controlled with Git, which means the exact analysis logic is preserved alongside the data.

Core Principles of Reproducible Workflows

Reproducibility in RNA-seq analysis means that the same raw data and the same pipeline version produce the same results every time the pipeline runs. This goal requires attention to four areas: software versions, reference data, configuration parameters, and execution environment.

Software versions matter because alignment tools and quantification methods change over time, and these changes can alter results. A reproducible pipeline should record the version of every tool it uses. Snakemake supports this through containerization, where each rule runs inside a Docker or Singularity container that pins the exact software environment. The nf-core documentation describes community standards for pipeline configuration and usage that emphasize containerized execution and version tracking. Even without containers, a pipeline can record tool versions by writing them to a log file during execution.

Reference data must be versioned and stored in a known location. Genome assemblies, gene annotation files, and transcript references all affect alignment and quantification results. The NCBI provides official descriptions of sequence databases and search systems that researchers use to obtain reference data. A reproducible pipeline should record which reference version was used and where it was downloaded from. Some pipelines include a separate workflow that downloads and prepares reference databases, which makes updates easier while preserving the ability to reproduce older analyses. The miND pipeline follows this pattern by separating reference database preparation from the main analysis workflow.

Configuration parameters such as read length, strandedness, and quality thresholds must be explicit. These parameters belong in a configuration file that the pipeline reads at runtime, not buried in individual rule definitions. This separation lets a researcher rerun the same pipeline with different parameters without editing code.

The execution environment includes the operating system, the version of Python, and the installed dependencies. The Carpentries lessons provide foundational training in computing, shell, and Git that helps researchers understand how to manage these environments. A pipeline that runs on one machine may fail on another if dependencies differ, so documenting the environment is as important as documenting the code.

At a Glance

Pipeline ComponentWhat It DoesKey DecisionCommon Tool Choice
Quality controlAssesses raw read quality and removes low-quality bases or adapter contaminationChoose trimming parameters based on sequencing platform and library preparationFastQC, MultiQC, Trimmomatic, cutadapt
AlignmentMaps reads to a reference genome or transcriptomeDecide between splice-aware genomic alignment and pseudoalignment based on downstream needsSTAR, HISAT2, Salmon, kallisto
QuantificationCounts reads per gene or transcriptChoose gene-level counts for differential expression or transcript-level estimates for isoform analysisfeatureCounts, RSEM, Salmon
Differential expressionIdentifies genes with changed expression between conditionsSpecify the experimental design and contrast of interestDESeq2, edgeR, limma
ReportingSummarizes quality metrics and results for interpretationGenerate a single report that combines all outputsMultiQC, custom R Markdown reports

Planning the Pipeline Structure

A Snakemake pipeline for RNA-seq follows a logical sequence of steps, and each step becomes one or more rules in the workflow file. The typical structure moves from raw FASTQ files through quality control, alignment, quantification, and differential expression. The exact structure depends on the experimental design and the biological questions being asked.

Input Data and Sample Organization

The first decision is how to organize sample metadata. A samples table that lists each sample ID, the path to its FASTQ files, and any experimental conditions is the foundation of the pipeline. This table drives the pipeline through wildcards, which are placeholders that Snakemake replaces with actual sample names. For example, a rule that aligns reads might use the wildcard {sample} to process each sample independently.

Paired-end and single-end data require different handling. Paired-end data has two FASTQ files per sample, and the pipeline must keep the read pairs together through trimming and alignment. The samples table should record whether each sample is single-end or paired-end, and the pipeline rules should branch accordingly.

Strandedness is another critical input decision. Library preparation kits produce either unstranded, stranded, or reverse-stranded data, and this choice affects how reads are counted. The quantification step must know the strandedness to assign reads to the correct strand. This information belongs in the configuration file, not in individual rule definitions.

Reference Data Preparation

Before alignment can run, the pipeline needs a reference genome and an annotation file. The reference preparation step downloads these files, indexes them for the chosen aligner, and stores them in a dedicated directory. This step runs once per reference version, not once per sample.

The NCBI provides official access to genome assemblies and annotation resources that researchers commonly use for reference data. The exact choice of reference version should be recorded in the configuration file so that the pipeline can be rerun with the same reference later.

Some pipelines separate reference preparation from the main analysis workflow. The miND pipeline includes a separate workflow that downloads, prepares, and builds reference databases, which allows updates to the most recent version while preserving the ability to reproduce older analyses. This separation is a useful pattern because reference preparation can be time-consuming and does not need to run for every sample.

Quality Control Rules

Quality control runs early in the pipeline and produces metrics that determine whether downstream analysis is trustworthy. The first quality control step assesses raw reads before any trimming. This assessment identifies adapter contamination, low-quality bases, and other sequencing artifacts.

The second quality control step runs after trimming and alignment to confirm that the data improved and that no new problems were introduced. Alignment statistics such as the percentage of reads that map to the reference genome provide a key quality indicator. Low mapping rates can indicate contamination, adapter problems, or a mismatch between the sample species and the reference genome.

MultiQC aggregates quality metrics from multiple samples into a single report, which is especially useful for large experiments. Instead of opening dozens of individual reports, a researcher can scan one summary to identify samples that fall outside expected ranges.

Alignment Rules

The alignment step maps reads to the reference genome or transcriptome. The choice of aligner depends on the downstream analysis. Splice-aware aligners such as STAR and HISAT2 map reads across exon junctions and produce BAM files that can be used for variant calling or visualization. Pseudoaligners such as Salmon and kallisto quantify transcript abundance directly without producing full alignments, which makes them faster and less memory-intensive.

The hppRNA pipeline demonstrates that both approaches can be embedded in a single Snakemake workflow, with separate core workflows for different tool combinations. This modularity lets a researcher choose the alignment strategy that fits their computational resources and analysis goals.

Alignment parameters matter for reproducibility. The same raw data aligned with different parameters can produce different counts, so the parameters must be recorded. Snakemake rules should specify alignment parameters in the configuration file, and the pipeline should log the parameters used for each run.

Quantification Rules

Quantification converts aligned reads or pseudoalignments into a count matrix with genes or transcripts as rows and samples as columns. Gene-level counts are the standard input for differential expression analysis with tools such as DESeq2 and edgeR. Transcript-level estimates are needed for isoform-level analysis.

The choice between gene-level and transcript-level quantification affects the entire downstream analysis. Gene-level counts are more robust and easier to interpret for most biological questions. Transcript-level estimates provide more resolution but require more sophisticated statistical methods to account for the uncertainty in assigning reads to isoforms.

The quantification rule must know the strandedness of the library and the annotation format. These parameters come from the configuration file. The output of the quantification step is a count matrix that the differential expression step consumes.

Differential Expression Rules

Differential expression analysis identifies genes whose expression changes between experimental conditions. This step requires a design matrix that describes the experimental groups and the comparison of interest. The design matrix is specified in the configuration file or in a separate metadata file.

DESeq2, edgeR, and limma are the most commonly used tools for differential expression analysis. Each tool has its own assumptions and normalization methods, and the choice of tool can affect the results. The pipeline should record which tool was used and which version, along with the design formula.

The output of the differential expression step is a table of genes with log fold changes, p-values, and adjusted p-values. This table is the primary result that biologists interpret, so it should include enough annotation information to identify genes and link them to biological functions.

Writing Snakemake Rules

A Snakemake workflow is defined in a file called Snakefile, which contains rules that describe how to produce output files from input files. Each rule has a name, input files, output files, and a shell command or Python code that performs the actual computation.

Rule Structure and Syntax

The basic structure of a Snakemake rule looks like this:

rule fastqc:
    input:
        "data/raw/{sample}_R1.fastq.gz"
    output:
        "results/fastqc/{sample}_R1_fastqc.html"
    shell:
        "fastqc {input} -o results/fastqc/"

This rule runs FastQC on a raw FASTQ file and produces an HTML report. The {sample} wildcard lets the rule process any sample by substituting the sample name.

Rules can have multiple inputs and outputs, and they can specify parameters, log files, and resources such as memory and CPU. The params directive passes additional arguments to the shell command, and the log directive captures standard output and error messages.

Wildcards and Target Files

Snakemake determines what to run by working backward from a target file. If the target is a final count matrix, Snakemake looks for a rule that produces that file, then looks for rules that produce the inputs to that rule, and so on until it reaches the raw data.

This backward chaining means that the pipeline does not need to specify the order of steps explicitly. The dependencies between rules define the order. A researcher can request any intermediate output as a target, and Snakemake will run only the steps needed to produce it.

Wildcards must be consistent across a rule. If a rule uses {sample} in its input and output, Snakemake will match the same sample name in both. This consistency is what allows the pipeline to process many samples with a single rule definition.

Handling Paired-End Data

Paired-end data requires special handling in Snakemake rules. A rule that trims paired-end reads needs both read files as inputs and produces two trimmed files as outputs. The rule definition must specify both files explicitly:

rule trim_pe:
    input:
        r1="data/raw/{sample}_R1.fastq.gz",
        r2="data/raw/{sample}_R2.fastq.gz"
    output:
        r1="results/trimmed/{sample}_R1.fastq.gz",
        r2="results/trimmed/{sample}_R2.fastq.gz"
    shell:
        "trimmomatic PE {input.r1} {input.r2} {output.r1} {output.r2} ..."

Named inputs and outputs make the rule more readable and reduce the risk of mixing up the two read files.

Using Configuration Files

A configuration file in YAML or JSON format stores parameters that the pipeline reads at runtime. The Snakefile loads this file and makes the values available to rules. Common configuration values include:

  • Paths to reference genome and annotation files
  • Read length and strandedness
  • Quality trimming thresholds
  • Aligner-specific parameters
  • Differential expression design formula

The configuration file should be version-controlled alongside the Snakefile. This practice ensures that the exact parameters used for an analysis are preserved and can be retrieved later.

Building the Pipeline Step by Step

The following sections describe how to build each part of a Snakemake pipeline for bulk RNA-seq analysis. The pipeline assumes paired-end reads, a reference genome, and a two-group comparison for differential expression.

Step 1: Set Up the Project Directory

A well-organized project directory separates raw data, intermediate files, results, and code. A typical structure looks like this:

project/
├── Snakefile
├── config/
│   └── config.yaml
├── data/
│   └── raw/
│       ├── sample1_R1.fastq.gz
│       ├── sample1_R2.fastq.gz
│       ├── sample2_R1.fastq.gz
│       └── sample2_R2.fastq.gz
├── refs/
│   ├── genome.fa
│   └── annotation.gtf
├── results/
│   ├── fastqc/
│   ├── trimmed/
│   ├── aligned/
│   ├── counts/
│   └── differential/
└── logs/

This structure keeps raw data separate from derived data, which reduces the risk of accidentally overwriting inputs. The results directory is organized by analysis step, and the logs directory captures standard output and error messages from each rule.

Step 2: Create the Configuration File

The configuration file defines the parameters that the pipeline uses. A minimal configuration for a paired-end RNA-seq experiment looks like this:

samples: "config/samples.tsv"
reference:
  genome: "refs/genome.fa"
  annotation: "refs/annotation.gtf"
  star_index: "refs/star_index/"
parameters:
  trim_quality: 20
  trim_length: 36
  strandedness: "reverse"
design:
  formula: "~condition"
  contrast: ["condition", "treated", "control"]

The samples file is a tab-separated table with columns for sample ID, paths to read files, and experimental conditions. The reference section points to the genome and annotation files. The parameters section stores trimming and alignment settings. The design section specifies the differential expression model.

Step 3: Define the Quality Control Rules

The first rules in the pipeline assess raw read quality. FastQC generates per-sample quality reports, and MultiQC aggregates them into a single summary. The FastQC rule processes each sample independently:

rule fastqc:
    input:
        "data/raw/{sample}_R1.fastq.gz",
        "data/raw/{sample}_R2.fastq.gz"
    output:
        "results/fastqc/{sample}_R1_fastqc.html",
        "results/fastqc/{sample}_R2_fastqc.html"
    log:
        "logs/fastqc/{sample}.log"
    shell:
        "fastqc {input} -o results/fastqc/ 2> {log}"

The MultiQC rule runs after all FastQC reports are generated and produces a single summary report:

rule multiqc:
    input:
        expand("results/fastqc/{sample}_R1_fastqc.html", sample=samples)
    output:
        "results/fastqc/multiqc_report.html"
    shell:
        "multiqc results/fastqc/ -o results/fastqc/"

The expand function creates a list of all expected input files by substituting each sample name into the pattern. This function is how Snakemake knows that the MultiQC rule depends on all FastQC reports.

Step 4: Define the Trimming Rule

Trimming removes low-quality bases and adapter sequences from raw reads. The trimming rule takes the raw FASTQ files as input and produces trimmed files as output. The parameters for trimming come from the configuration file:

rule trim:
    input:
        r1="data/raw/{sample}_R1.fastq.gz",
        r2="data/raw/{sample}_R2.fastq.gz"
    output:
        r1="results/trimmed/{sample}_R1.fastq.gz",
        r2="results/trimmed/{sample}_R2.fastq.gz"
    params:
        quality=config["parameters"]["trim_quality"],
        length=config["parameters"]["trim_length"]
    log:
        "logs/trim/{sample}.log"
    shell:
        "trimmomatic PE {input.r1} {input.r2} {output.r1} {output.r2} "
        "ILLUMINACLIP:adapters.fa:2:30:10 "
        "LEADING:{params.quality} TRAILING:{params.quality} "
        "SLIDINGWINDOW:4:{params.quality} MINLEN:{params.length} 2> {log}"

The trimming parameters determine how aggressively low-quality bases are removed. A sliding window of four bases with a quality threshold of 20 is a common starting point, but the optimal settings depend on the sequencing platform and the library preparation method.

Step 5: Define the Alignment Rule

The alignment rule maps trimmed reads to the reference genome. STAR is a splice-aware aligner that is widely used for RNA-seq data. The rule requires a STAR index, which is built from the reference genome and annotation in a separate rule:

rule star_index:
    input:
        genome=config["reference"]["genome"],
        annotation=config["reference"]["annotation"]
    output:
        directory("refs/star_index/")
    log:
        "logs/star_index.log"
    shell:
        "STAR --runMode genomeGenerate "
        "--genomeDir refs/star_index/ "
        "--genomeFastaFiles {input.genome} "
        "--sjdbGTFfile {input.annotation} "
        "--runThreadN 8 2> {log}"

The alignment rule uses the STAR index and the trimmed reads to produce a BAM file for each sample:

rule star_align:
    input:
        r1="results/trimmed/{sample}_R1.fastq.gz",
        r2="results/trimmed/{sample}_R2.fastq.gz",
        index=config["reference"]["star_index"]
    output:
        "results/aligned/{sample}.bam"
    log:
        "logs/star/{sample}.log"
    shell:
        "STAR --genomeDir {input.index} "
        "--readFilesIn {input.r1} {input.r2} "
        "--readFilesCommand zcat "
        "--outSAMtype BAM SortedByCoordinate "
        "--outFileNamePrefix results/aligned/{wildcards.sample}_ "
        "--runThreadN 8 2> {log} && "
        "mv results/aligned/{wildcards.sample}_Aligned.sortedByCoord.out.bam {output}"

The alignment rule produces a sorted BAM file that is ready for quantification. The wildcards object gives access to the sample name within the shell command.

Step 6: Define the Quantification Rule

The quantification rule counts reads that overlap each gene in the annotation. featureCounts is a commonly used tool for this step:

rule featurecounts:
    input:
        bams=expand("results/aligned/{sample}.bam", sample=samples),
        annotation=config["reference"]["annotation"]
    output:
        counts="results/counts/counts.txt",
        summary="results/counts/counts.summary"
    params:
        strandedness=config["parameters"]["strandedness"]
    log:
        "logs/featurecounts.log"
    shell:
        "featureCounts -a {input.annotation} "
        "-o {output.counts} "
        "-s {params.strandedness} "
        "-T 8 "
        "{input.bams} 2> {log}"

The strandedness parameter tells featureCounts whether the library is unstranded, stranded, or reverse-stranded. Using the wrong value can result in counting reads on the wrong strand and producing incorrect counts.

Step 7: Define the Differential Expression Rule

The differential expression rule runs an R script that uses DESeq2 to identify differentially expressed genes. The rule takes the count matrix and the sample metadata as input and produces a results table:

rule deseq2:
    input:
        counts="results/counts/counts.txt",
        samples=config["samples"]
    output:
        "results/differential/deseq2_results.csv"
    log:
        "logs/deseq2.log"
    shell:
        "Rscript scripts/run_deseq2.R "
        "--counts {input.counts} "
        "--samples {input.samples} "
        "--output {output} 2> {log}"

The R script reads the count matrix, constructs the DESeq2 dataset from the sample metadata, fits the model specified in the configuration file, and writes the results table. The results table includes log fold changes, p-values, and adjusted p-values for every gene.

Executing the Pipeline

Once the Snakefile and configuration file are complete, the pipeline runs with a single command. The most common execution modes are a dry run, a local run, and a cluster run.

Dry Run

A dry run shows what the pipeline would do without actually executing any steps:

snakemake -n

The dry run prints the list of rules that would run and the files they would produce. This step is essential for catching errors in the workflow definition before spending computational time on a full run.

Local Execution

A local run executes the pipeline on the current machine:

snakemake --cores 8

The --cores option specifies how many CPU cores the pipeline can use. Snakemake schedules rules in parallel when their inputs are available and when resources permit.

Cluster Execution

For large datasets, the pipeline can run on a cluster or cloud infrastructure. Snakemake supports cluster execution through profiles that define how to submit jobs to the scheduler:

snakemake --profile cluster_profile

The cluster profile specifies the scheduler type, the resources requested for each job, and the maximum number of concurrent jobs. The nf-core documentation describes community standards for pipeline configuration that include cluster execution patterns.

Resuming Interrupted Runs

If a run fails or is interrupted, Snakemake can resume from the last completed step. The pipeline tracks which outputs exist and which are up to date, so rerunning the same command only executes the steps that did not complete:

snakemake --cores 8 --rerun-incomplete

The --rerun-incomplete flag tells Snakemake to rerun any rules whose outputs are incomplete or corrupted.

Common Failure Patterns and Troubleshooting

RNA-seq pipelines fail in predictable ways, and recognizing these patterns speeds up troubleshooting.

Reference Index Mismatches

A common failure occurs when the reference index does not match the reference genome or annotation. If the genome file changes but the index is not rebuilt, alignment will fail or produce incorrect results. The pipeline should include a rule that rebuilds the index whenever the reference files change, and the index should be stored in a separate directory that can be deleted and rebuilt.

Strandedness Errors

Using the wrong strandedness setting in the quantification step produces counts that are systematically wrong. The strandedness of a library is determined by the library preparation kit, and this information should be recorded when the samples are submitted for sequencing. If the strandedness is unknown, a small test alignment can determine it by checking whether reads map to the sense or antisense strand of known genes.

Memory Exhaustion

Alignment tools such as STAR require substantial memory, especially for large genomes. If a rule fails with an out-of-memory error, the rule needs a higher memory allocation. Snakemake rules can specify memory requirements, and the cluster profile can map these requirements to scheduler options.

Sample Name Collisions

Sample names must be unique and must not contain characters that interfere with file paths. Spaces, slashes, and special characters in sample names cause errors in shell commands. The samples table should be checked for naming consistency before the pipeline runs.

Version Drift

If the pipeline runs on different machines or at different times, software versions may differ. A pipeline that works on one machine may fail on another because a tool was updated. Containerization solves this problem by pinning the exact software environment for each rule.

Records and Measurements

A reproducible pipeline generates records that document what was done and what was found. These records serve two purposes: they allow the analysis to be reproduced, and they provide evidence for the quality of the results.

Pipeline Logs

Each rule should write a log file that captures standard output and error messages. These logs are the first place to look when a rule fails. The logs should be stored in a dedicated directory and named by sample and rule so that they can be matched to the corresponding outputs.

Version Records

The pipeline should record the version of every tool it uses. This record can be generated by a rule that runs each tool with its version flag and writes the output to a file. The version record should be stored with the results so that anyone who receives the results can see exactly which software versions produced them.

Quality Metrics

Quality metrics from FastQC, alignment statistics, and featureCounts summaries should be preserved as part of the results. These metrics provide evidence that the data quality was acceptable and that the analysis was performed correctly. The MultiQC report is a convenient way to aggregate these metrics into a single document.

Configuration Snapshot

The configuration file used for a run should be copied into the results directory. This snapshot ensures that the exact parameters are preserved even if the configuration file is later edited. Some pipelines generate a run summary that includes the configuration, the tool versions, and the quality metrics in a single report.

Limitations and Interpretation

RNA-seq analysis pipelines produce results that require careful interpretation. The pipeline automates the computational steps, but it does not remove the need for biological judgment.

Quality Thresholds Are Context Dependent

Quality control thresholds that work for one experiment may not work for another. The optimal trimming parameters depend on the sequencing platform, the library preparation method, and the downstream analysis. A pipeline should use reasonable defaults, but the researcher must inspect the quality reports and adjust parameters when the data warrant it.

Alignment Is Not Perfect

No aligner maps every read correctly. Multi-mapping reads, reads that span complex structural variants, and reads from repetitive regions are difficult to assign to a single genomic location. The quantification step must handle these ambiguities, and the choice of method affects the results. The TE-Seq pipeline demonstrates that repetitive elements require specialized analysis methods because standard pipelines often ignore or misassign reads from these regions.

Differential Expression Depends on Experimental Design

The results of differential expression analysis depend on the experimental design and the statistical model. A poorly designed experiment cannot be fixed by the analysis pipeline. The design formula must reflect the actual experimental structure, including batch effects and other sources of variation.

Reference Choice Affects Results

The choice of reference genome and annotation affects the results. Different versions of the same genome can produce different counts, and the choice between a comprehensive annotation and a conservative one changes which genes are quantified. The reference version should be reported with the results.

Quality Control and Reporting Standards

The quality of RNA-seq data varies between laboratories and between sequencing runs, and there is no common minimal standard for reporting quality aspects. The miND pipeline addresses this gap by generating a comprehensive report that contains all essential qualitative and quantitative results that should be reported. This pattern is worth following for any RNA-seq pipeline.

Minimum Quality Metrics

At a minimum, a quality report should include the number of raw reads per sample, the number of reads that pass quality filtering, the alignment rate, and the number of genes detected. These metrics give a quick overview of data quality and allow comparisons between samples and experiments.

Sample-Level Quality Checks

Each sample should be checked for anomalies before it is included in downstream analysis. Samples with very low read counts, very low alignment rates, or unusual GC content may indicate problems with library preparation or sequencing. These samples should be flagged for review instead of silently included in the analysis.

Batch Effects

Samples processed in different batches can show systematic differences that are unrelated to the biological conditions being studied. The pipeline should record batch information in the sample metadata, and the differential expression model should include batch as a covariate when appropriate.

Professional Escalation Criteria

Some problems require consultation with a bioinformatics specialist or a statistician. The following situations warrant escalation:

Persistent Pipeline Failures

If a pipeline fails repeatedly and the cause is not clear from the logs, a specialist should review the workflow definition and the error messages. Repeated failures often indicate a fundamental issue with the data or the reference that requires expert judgment.

Unexpected Quality Patterns

If quality metrics show patterns that are difficult to explain, such as a subset of samples with systematically lower quality, a specialist should review the data. These patterns may indicate contamination, sample mix-ups, or problems with the sequencing run.

Discrepant Results

If the results of differential expression analysis contradict known biology or previous experiments, the analysis should be reviewed before drawing conclusions. Discrepant results may indicate a problem with the experimental design, the reference, or the statistical model.

Complex Experimental Designs

Experiments with multiple factors, repeated measures, or confounding variables require statistical expertise to analyze correctly. The pipeline can produce results for these designs, but the interpretation requires careful statistical review.

Establishing a Decision Framework for Tool Selection

Choosing between alignment and pseudoalignment, or between gene-level and transcript-level quantification, is not a one-time decision that applies to every experiment. The published Snakemake pipelines for RNA-seq take different approaches, and the differences reflect real tradeoffs in speed, memory, and biological resolution. The hppRNA pipeline embeds six independent core workflows covering STAR-RSEM-EBSeq, kallisto-sleuth, HISAT-StringTie-Ballgown, and other combinations, which shows that no single tool chain dominates all use cases. instead of defaulting to one combination, a reproducible pipeline should encode a decision framework that maps experimental goals to specific tool choices.

Defining the Analysis Objective First

The first decision point is the primary analysis objective. A pipeline designed for differential expression between two conditions has different requirements than one designed for isoform discovery or variant detection. The VIPER pipeline combines alignment, quality control, differential expression, and pathway analysis in a modular design, which suits experiments where the full standard analysis is needed. The transXpress pipeline targets de novo transcriptome assembly for non-model organisms, where no reference genome exists and the analysis must reconstruct transcripts from scratch. These two pipelines serve different objectives, and a researcher should decide which objective matches their experiment before selecting tools.

For experiments with a well-annotated reference genome and a straightforward two-group comparison, a splice-aware aligner followed by gene-level counting is the conventional path. For experiments that only need relative expression changes and have limited computational resources, pseudoalignment with Salmon or kallisto provides faster results with lower memory requirements. For experiments investigating transposable elements or other repetitive regions, standard alignment and quantification tools are insufficient. The TE-Seq pipeline implements computational methods tailored for repetitive sequences and produces expression analysis at both the individual element level and the clade level, which standard pipelines cannot provide.

Scoring Tool Choices Against Constraints

A practical decision framework scores each candidate tool combination against four constraints: reference availability, computational resources, required output types, and analysis timeline. Reference availability is the first filter. If no reference genome exists for the study organism, de novo assembly tools such as Trinity or rnaSPAdes are required, and the transXpress pipeline demonstrates how to structure these tools in a Snakemake workflow. If a reference exists but is poorly annotated, alignment followed by transcript assembly may be more appropriate than direct quantification against an incomplete annotation.

Computational resources impose the second filter. STAR alignment for a mammalian genome typically requires substantial memory, often exceeding 30 GB, while pseudoalignment tools run comfortably on standard workstations. The pipeline should record the memory and CPU requirements for each rule so that a researcher can determine whether their infrastructure can support the chosen tools. The hppRNA pipeline was specifically designed for researchers deploying pipelines on local servers with large sample sets, which requires attention to resource efficiency.

Required output types form the third filter. If the downstream analysis needs BAM files for visualization in a genome browser, splice junction information, or variant calls, full alignment is necessary. If the analysis only needs a count matrix for differential expression, pseudoalignment suffices. The IntegrateALL pipeline demonstrates that some applications require additional outputs beyond standard counts, including gene fusion calls and virtual karyotyping, which imposes specific tool requirements.

Analysis timeline is the fourth filter. Pseudoalignment is substantially faster than full alignment, and for large cohorts or time-sensitive analyses, this speed difference can determine whether a pipeline completes in days or weeks. The decision framework should make this tradeoff explicit instead of implicit.

Recording the Decision Rationale

A reproducible pipeline should record also which tools were chosen but also why they were chosen. This rationale belongs in a decision log that is version-controlled alongside the Snakefile and configuration file. The decision log should state the analysis objective, the constraints that were considered, the alternatives that were rejected, and the reason for rejection. This record is valuable when the pipeline is revisited months later or when results are questioned by collaborators or reviewers.

The nf-core documentation describes community standards for pipeline configuration that emphasize documenting the reasoning behind pipeline choices. Following this pattern, the decision log should be structured as a table with columns for the decision point, the options considered, the selected option, and the justification. This table becomes part of the pipeline documentation and is included in the run report.

Implementing a Structured Rule Selection System

Once the tool choices are made, the pipeline needs a mechanism to select the appropriate rules at runtime. Snakemake supports this through configuration-driven rule selection, where the configuration file specifies which analysis mode to use and the Snakefile defines rules conditionally.

Configuration-Driven Mode Selection

The configuration file can include an analysis mode parameter that selects between tool chains. For example, a configuration might specify mode: "alignment" or mode: "pseudoalignment", and the Snakefile uses this value to determine which rules are active. This approach keeps a single Snakefile that can serve multiple analysis strategies without duplicating code.

The hppRNA pipeline demonstrates this pattern by providing six independent core workflows within a single Snakemake framework. Each core workflow is a complete tool chain, and the researcher selects the appropriate one based on their data and analysis goals. This modularity is a practical model for a decision framework because it makes the alternatives explicit and selectable.

Rule Selection Based on Data Properties

Some rule selections depend on properties of the data instead of the analysis objective. Strandedness is the clearest example. The quantification rule must know whether the library is unstranded, stranded, or reverse-stranded, and this value comes from the configuration file. The pipeline should validate that the strandedness value is one of the supported options and fail with a clear error message if it is not.

Read length and read type also affect rule selection. Paired-end data requires rules that handle two read files per sample, while single-end data uses simpler rules. The samples table should record the read type for each sample, and the pipeline should branch accordingly. Some pipelines assume a uniform read type across all samples, which is simpler but less flexible.

Validation Rules for Early Error Detection

A decision framework should include validation rules that run early in the pipeline and check that the configuration is internally consistent. These rules catch errors before expensive alignment or quantification steps run. Validation checks include:

  • The reference genome file exists and is non-empty
  • The annotation file exists and is in the expected format
  • The strandedness value is one of the supported options
  • The samples table has all required columns and no duplicate sample IDs
  • The design formula references columns that exist in the samples table

These validation rules are cheap to run and prevent wasted computation on misconfigured pipelines. They also serve as documentation of the assumptions the pipeline makes about its inputs.

Building a Comparison Matrix for Pipeline Evaluation

When evaluating whether an existing pipeline meets the needs of a new experiment, a comparison matrix provides a structured way to assess options. The matrix scores each candidate pipeline against criteria that matter for the specific experiment.

Evaluation Criteria

The primary criteria for evaluating an RNA-seq pipeline are:

  • Supported input formats and read types
  • Reference requirements and preparation steps
  • Quality control coverage and reporting
  • Alignment and quantification methods available
  • Differential expression and downstream analysis options
  • Computational resource requirements
  • Documentation quality and community support
  • License and availability of source code

The VIPER pipeline is packaged so that minimal computational skills are required to install and run it, which is a significant advantage for researchers without dedicated bioinformatics support. The AutoRNAseq pipeline automates data retrieval and reference preparation, reducing the manual coordination that other workflows require. The bollito pipeline integrates more than 30 tools for single-cell analysis, which is relevant for experiments that extend beyond bulk RNA-seq.

Scoring and Weighting

Each criterion should be scored on a simple scale, such as 1 to 5, and the scores should be weighted according to the priorities of the experiment. A researcher with limited computational resources would weight resource requirements more heavily than a researcher with access to a large cluster. The weighted scores provide a quantitative basis for comparing pipelines, but the final decision should also consider qualitative factors such as familiarity with the tools and the availability of local support.

Documenting the Comparison

The comparison matrix should be saved with the pipeline documentation. This record explains why a particular pipeline was adopted and provides a reference point for future evaluations. When a new pipeline becomes available or when the experimental requirements change, the matrix can be updated and the decision revisited.

Implementing a Record System for Pipeline Runs

A reproducible pipeline generates records that document what was done and what was found. These records serve two purposes: they allow the analysis to be reproduced, and they provide evidence for the quality of the results.

Run Manifest

A run manifest is a file that records the essential facts about a pipeline execution. The manifest includes the pipeline version, the configuration file contents, the tool versions, the reference versions, and the date and time of the run. This manifest is generated automatically by the pipeline and stored with the results.

The miND pipeline generates a comprehensive report that contains all essential qualitative and quantitative results that should be reported for small RNA-seq data. This pattern extends to bulk RNA-seq: a run manifest that captures the pipeline state at execution time is the foundation of reproducibility.

Sample Tracking Table

A sample tracking table records the status of each sample through the pipeline. The table includes columns for the sample ID, the input files, the quality control metrics, the alignment rate, the number of genes detected, and the final analysis status. This table is updated as the pipeline runs and provides a quick overview of which samples passed and which were flagged for review.

Version Control Integration

The Snakefile, configuration file, samples table, and decision log should be under version control with Git. The Carpentries lessons provide foundational training in Git that covers the skills needed to manage these files. Each pipeline run should be associated with a specific commit of the workflow files, so that the exact code that produced a given result can be retrieved.

Archiving Results

The results directory should include the run manifest, the configuration snapshot, the tool version record, and the quality metrics. This archive is what allows another researcher to understand what was done without needing to rerun the pipeline. The archive should be stored in a location that is backed up and accessible to collaborators.

Troubleshooting Method for Tool Selection Failures

When a pipeline fails, the troubleshooting method should follow a structured path that isolates the cause. The most common failures in RNA-seq pipelines fall into distinct categories, and recognizing the category speeds up diagnosis.

Configuration Errors

Configuration errors are the easiest to diagnose because they produce clear error messages. A missing file path, an invalid strandedness value, or a design formula that references a nonexistent column all produce errors that point directly to the configuration. The validation rules described earlier catch many of these errors before the pipeline runs.

Reference Errors

Reference errors occur when the reference genome, annotation, or index does not match what the pipeline expects. A common failure is using an index built from a different genome version than the reference files. The pipeline should record the reference versions in the run manifest so that mismatches can be identified.

Resource Errors

Resource errors occur when a rule requires more memory, CPU, or disk space than is available. These errors typically appear as out-of-memory messages or killed jobs. The pipeline should specify resource requirements for each rule, and the cluster profile should map these requirements to scheduler options.

Data Errors

Data errors occur when the input files do not match the pipeline's expectations. A corrupted FASTQ file, a sample with zero reads, or a sample name that contains special characters can all cause failures. The quality control rules should catch these issues early, but some errors only appear at later steps.

Systematic Troubleshooting Steps

When a failure occurs, the first step is to read the log file for the failed rule. The log file usually contains the error message that identifies the cause. The second step is to check whether the failure is isolated to one sample or affects all samples. An isolated failure suggests a data problem with that sample, while a widespread failure suggests a configuration or reference problem. The third step is to verify that the inputs to the failed rule exist and are valid. The fourth step is to check whether the rule worked in a previous run, which would indicate that something changed in the environment or the inputs.

Professional Escalation Criteria for Tool Selection

Some tool selection decisions require consultation with a bioinformatics specialist. The following situations warrant escalation:

Unfamiliar Data Types

If the experiment uses a less common RNA-seq variant, such as nucleotide recoding RNA-seq or small RNA-seq, the standard pipeline may not apply. The EZbakR suite provides a Snakemake pipeline for preprocessing nucleotide recoding RNA-seq datasets, and the miND pipeline targets small RNA-seq. A specialist should review the data type and recommend the appropriate tools.

Non-Model Organisms

If the study organism lacks a well-annotated reference genome, the pipeline must handle de novo assembly or cross-species alignment. The transXpress pipeline demonstrates de novo transcriptome assembly and annotation for non-model organisms, but the choice of assembly parameters and the interpretation of results require specialist input.

Complex Experimental Designs

Experiments with multiple factors, batch effects, or confounding variables require statistical expertise to analyze correctly. The pipeline can produce results for these designs, but the interpretation requires careful statistical review. A specialist should review the design formula and the differential expression model before the analysis is finalized.

Persistent Failures After Troubleshooting

If the pipeline fails repeatedly and the cause is not clear from the logs, a specialist should review the workflow definition and the error messages. Repeated failures often indicate a fundamental issue with the data or the reference that requires expert judgment.

Frequently Asked Questions

What is the difference between Snakemake and other workflow managers?

Snakemake is a workflow management system that uses Python-based rule definitions and automatic dependency tracking. It is one of several options for reproducible bioinformatics analysis. The nf-core documentation describes an alternative community-driven framework that uses Nextflow. Both systems solve the same core problem of organizing and reproducing analysis steps, and the choice between them often comes down to personal preference and community support.

Do I need to know Python to use Snakemake?

Basic familiarity with Python helps, but the core workflow definition uses a simple rule syntax that is accessible to researchers with limited programming experience. The Carpentries lessons provide foundational programming training that covers the skills needed to work with Snakemake. More advanced features such as custom Python functions for input handling require deeper Python knowledge.

How much computational resources does an RNA-seq pipeline need?

The resource requirements depend on the number of samples and the tools used. Alignment tools such as STAR require substantial memory, often 30 GB or more for mammalian genomes. Pseudoalignment tools such as Salmon and kallisto are much less memory-intensive. The pipeline can run on a laptop for small datasets, but large experiments benefit from a server or cluster.

How do I choose between alignment and pseudoalignment?

Alignment produces BAM files that can be used for visualization, variant calling, and other analyses beyond quantification. Pseudoalignment is faster and requires less memory but does not produce full alignments. If the analysis only needs gene-level counts for differential expression, pseudoalignment is often sufficient. If the analysis needs splice junctions, novel transcripts, or variant information, full alignment is necessary.

How do I handle samples with very low read counts?

Samples with very low read counts should be flagged during quality control and reviewed before inclusion in downstream analysis. The threshold for acceptable read counts depends on the experimental context and the depth needed for the biological question. A specialist should review samples that fall well below the expected range.

How do I make my pipeline available to other researchers?

A reproducible pipeline should be shared with the source code, the configuration file, and documentation. The source code can be hosted on a public repository such as GitHub, and the documentation should describe how to install dependencies and run the pipeline. Several published pipelines, including VIPER, hppRNA, and TE-Seq, provide their source code publicly, which serves as a model for sharing.

What should I do if my results do not match a previous analysis?

Differences between analyses can arise from changes in software versions, reference versions, or analysis parameters. The first step is to compare the configuration and tool versions between the two analyses. If the differences persist, a specialist should review both analyses to identify the source of the discrepancy.

How do I cite a Snakemake pipeline in my publication?

Published pipelines should be cited by their original publication. The citation should include the pipeline name, the authors, the journal, and the year of publication. The pipeline documentation usually provides the preferred citation format.

Related Bioinformatics Guides

Related Clinical & Scientific Guides

References and Further Reading

This article is educational and does not replace validated analysis plans, institutional policy, clinical interpretation, or specialist review.