RNA-seq Data Preprocessing in R: Using Rsubread and edgeR for Alignment and Quantification

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

RNA-seq Data Preprocessing in R: Using Rsubread and edgeR for Alignment and Quantification

Key Takeaways

  • This workflow consolidates RNA-seq alignment and quantification within R using Rsubread and edgeR, moving from raw FASTQ files to a filtered count matrix for differential expression analysis, thereby reducing the need for external command-line tools and enhancing reproducibility.
  • Rsubread's buildindex function requires a reference genome (FASTA) and gene annotation (GTF/GFF) to create an index for splice-aware alignment (type = "rna") via the align function, with alignment quality assessed by uniquely mapped read percentages (typically >70-80%).
  • featureCounts quantifies gene expression by mapping reads to annotated features, producing a count matrix; strand-specific counting (strandSpecific parameter) is critical and must match the library preparation protocol to avoid significant count reduction.
  • edgeR's DGEList object is constructed from the count matrix and sample metadata, followed by quality filtering of low-expression genes (e.g., >1 CPM in the smallest group size) and normalization (e.g., TMM) to adjust for library size and composition differences.
  • Multidimensional scaling (MDS) plots are essential for visualizing sample relationships and identifying outliers or batch effects, while dispersion estimation (estimateDisp) and subsequent differential expression testing (glmQLFit, glmQLFTest) using empirical Bayes methods are crucial for robust statistical inference.

RNA sequencing analysis in R provides a unified environment for processing raw sequencing data through to differential expression testing. This workflow demonstrates how to use Rsubread for read alignment and feature counting, followed by edgeR for creating a DGEList object and performing quality filtering. The approach addresses the practical problem of researchers who prefer to conduct their entire RNA-seq analysis within the R ecosystem instead of switching between command-line tools and R. The complete workflow moves from raw FASTQ files to a filtered count matrix ready for differential expression analysis, with clear decision points for quality control at each stage.

Understanding the RNA-seq Analysis Pipeline

RNA-seq analysis follows a sequence of distinct stages, each with specific computational requirements and quality considerations. The complete workflow begins with raw sequencing reads in FASTQ format and proceeds through quality assessment, read alignment to a reference genome or transcriptome, quantification of expression levels, and finally statistical analysis to identify differentially expressed genes. Each software module typically targets a specific step within the analysis pipeline, making it necessary to join several tools to create a single cohesive workflow. The ARMOR workflow demonstrates this modular approach, implementing an end-to-end RNA-seq data analysis from raw read files through quality checks, alignment, quantification, differential expression testing, geneset analysis, and browser-based exploration of the data. ARMOR uses the Snakemake workflow management system and leverages conda environments, with Bioconductor objects generated to facilitate downstream analysis and ensure seamless integration with many R packages. The workflow is implemented by cloning the GitHub repository, replacing the supplied input and reference files, and editing a configuration file, with the modular setup allowing alternative tools to be easily integrated.

The R-based approach using Rsubread and edgeR consolidates several of these steps into a single programming environment. This consolidation reduces the need to transfer data between different software platforms and allows researchers to maintain a complete record of their analysis in R scripts. The Bioconductor project provides official documentation and package repositories for these tools, supporting reproducible genomic analysis workflows. Bioconductor serves as a central repository for R packages designed specifically for genomic data analysis, with rigorous version control and dependency management that ensures compatibility across the package ecosystem.

Why Choose R for RNA-seq Processing

R provides several advantages for RNA-seq analysis. The statistical analysis of count data benefits from the extensive collection of Bioconductor packages designed specifically for genomic data. R scripts serve as executable documentation of the analysis, which supports reproducibility when the scripts are shared with collaborators or included in publications. The interactive nature of R allows researchers to examine intermediate results and make informed decisions at each step.

The preprocessing stage of RNA-seq analysis has become the most time-demanding step in the entire workflow. Many researchers chain different tools together to accomplish quality control and filtering, but a comprehensive and flexible software solution has been historically missing. FastqPuri was developed to address this gap, providing sequence quality reports on the sample and dataset level with new plots that facilitate decision making for subsequent quality filtering. The tool efficiently removes adapter sequences and sequences from biological contamination, accepts both single-end and paired-end data in uncompressed or compressed fastq files, and can be run stand-alone or within pipelines. While FastqPuri operates outside R, the same principle applies within R: having alignment and quantification available through Rsubread eliminates the need to leave the R environment.

Scope of This Workflow

This workflow covers the following stages:

  1. Installing and loading Rsubread and edgeR
  2. Building a reference index for alignment
  3. Aligning raw reads to the reference genome
  4. Quantifying gene expression with featureCounts
  5. Creating a DGEList object in edgeR
  6. Filtering low-expression genes
  7. Normalizing the count data
  8. Preparing data for downstream differential expression analysis

The workflow assumes paired-end or single-end FASTQ files from a standard bulk RNA-seq experiment. The same principles apply to data from different sequencing platforms, though specific parameters may require adjustment based on read length and library preparation method. For researchers working with single-cell RNA-seq data, additional preprocessing considerations apply, including cell filtering, doublet removal, and specialized normalization approaches that extend beyond the bulk RNA-seq workflow described here.

Installing and Loading Required R Packages

Rsubread and edgeR are both available through Bioconductor, which provides official package repositories and documentation for reproducible genomic analysis. The Bioconductor project maintains these packages and ensures their compatibility with current R versions. The installation system handles dependency management automatically, ensuring that all required supporting packages are installed. This approach is preferable to installing from CRAN directly because Bioconductor packages often depend on other Bioconductor packages that are not available through CRAN.

Installation Commands

To install Bioconductor packages, first ensure that the BiocManager package is installed:

if (!require("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

Then install the required packages:

BiocManager::install("Rsubread")
BiocManager::install("edgeR")

After installation, load both packages in your R session:

library(Rsubread)
library(edgeR)

The Bioconductor installation system handles dependency management automatically, ensuring that all required supporting packages are installed. This approach is preferable to installing from CRAN directly because Bioconductor packages often depend on other Bioconductor packages that are not available through CRAN.

Verifying Package Versions

Record the versions of R, Rsubread, and edgeR at the start of your analysis. This information is essential for reproducibility because package updates can change default parameters or introduce new functionality. The session information can be saved using:

sessionInfo()

This command displays the R version, platform details, and versions of all loaded packages. Including this output in your analysis records allows other researchers to replicate your exact computational environment. The Carpentries lessons provide foundational training on reproducible computing practices, including version control and project organization, which complement the technical aspects of RNA-seq analysis.

Building a Reference Index with Rsubread

The alignment step requires a reference genome or transcriptome to map reads against. Rsubread uses its own indexing system, which must be created before the first alignment. The reference files are typically obtained from public databases such as those maintained by the National Center for Biotechnology Information (NCBI). NCBI provides official descriptions of their databases, search systems, sequence resources, and analysis services, making it a reliable source for reference genome files. The NCBI resources include comprehensive genome assemblies, annotation data, and sequence databases that support a wide range of genomic analyses.

Obtaining Reference Files

For most organisms, you will need two files:

  1. A reference genome in FASTA format
  2. A gene annotation file in GTF or GFF format

The FASTA file contains the nucleotide sequence of the genome, while the annotation file contains the coordinates of genes, exons, and transcripts. Both files must correspond to the same genome build for the alignment and quantification steps to work correctly. Mismatches between the genome build and annotation version are a common source of errors in the quantification step, so verify that both files are derived from the same assembly before proceeding.

Creating the Index

The buildindex function in Rsubread creates the index required for alignment:

buildindex(basename = "mm10_index", reference = "mm10.fa")

The basename argument specifies the prefix for the index files that will be created, and the reference argument specifies the path to the FASTA file. The indexing process can take considerable time and memory for large genomes such as human or mouse. Plan to run this step once per reference genome and reuse the index for all samples in your study.

Index Parameters and Considerations

Rsubread's index building supports several parameters that affect memory usage and alignment speed. The default parameters work well for most applications, but you may need to adjust them for very large genomes or limited computational resources. The Bioconductor documentation for Rsubread provides detailed descriptions of all available parameters and their recommended settings. For organisms with well-annotated genomes, the standard index is sufficient. For less-characterized organisms, you may need to verify that the annotation file is compatible with the genome assembly.

Aligning Reads with Rsubread

The align function performs the read alignment against the reference index. This step maps each sequencing read to its most likely genomic location, accounting for splice junctions in RNA-seq data. The alignment algorithm in Rsubread is designed specifically for RNA-seq data and can handle reads that span exon-exon junctions.

Basic Alignment Command

align(index = "mm10_index",
      readfile1 = "sample1_R1.fastq.gz",
      readfile2 = "sample1_R2.fastq.gz",
      output_file = "sample1.bam",
      type = "rna")

For paired-end data, readfile1 and readfile2 specify the forward and reverse read files. For single-end data, only readfile1 is required. The type = "rna" argument enables splice-aware alignment, which is essential for RNA-seq data because reads spanning exon-exon junctions will not align to the genome without this option.

Alignment Output

The alignment produces a BAM file containing the aligned reads. This file format is the standard for storing alignment information and can be used for visualization in genome browsers or for downstream analysis tools. The BAM file also contains information about mapping quality, which can be used to filter poorly aligned reads in subsequent steps.

Monitoring Alignment Quality

After alignment, examine the alignment summary statistics that Rsubread reports. Key metrics include:

  • Total number of reads processed
  • Number and percentage of uniquely mapped reads
  • Number and percentage of multimapping reads
  • Number and percentage of unmapped reads

A study of chicken RNA-seq data reported uniquely mapped read percentages ranging from 78.07% to 87.74% and mismatch rates per base varying between 0.77% and 1.45%. These values provide a practical reference range for typical bulk RNA-seq experiments. If your alignment rates fall substantially below this range, investigate potential causes such as adapter contamination, poor RNA quality, or reference genome mismatches.

Handling Multiple Samples

For experiments with multiple samples, run the alignment for each sample individually. The alignment step is computationally intensive and can be parallelized across samples if you have access to multiple CPU cores. Rsubread supports multithreading through the nthreads parameter:

align(index = "mm10_index",
      readfile1 = "sample1_R1.fastq.gz",
      readfile2 = "sample1_R2.fastq.gz",
      output_file = "sample1.bam",
      type = "rna",
      nthreads = 8)

The optimal number of threads depends on your hardware configuration. Using more threads than available CPU cores can decrease performance due to context switching overhead. For large experiments with many samples, consider using a computing cluster or cloud-based resources to parallelize the alignment step across multiple nodes.

Quantifying Gene Expression with featureCounts

The featureCounts function in Rsubread quantifies gene expression by counting the number of reads that overlap with annotated genomic features. This step produces the count matrix that serves as input for edgeR. The quantification step is critical because the accuracy of abundance estimates directly affects downstream analysis results. A study comparing quantification tools for RNA velocity analysis found substantial differences between the quantifications obtained from different tools and identified typical genes for which such discrepancies are observed. These abundance differences propagate to downstream analysis and can have a large effect on estimated velocities as well as biological interpretation. The study highlighted that abundance quantification is a crucial aspect of the workflow and that both the definition of the genomic features of interest and the quantification algorithm itself require careful consideration.

Basic featureCounts Command

counts <- featureCounts(files = c("sample1.bam", "sample2.bam", "sample3.bam"),
                        annot.ext = "mm10.gtf",
                        isGTFAnnotationFile = TRUE,
                        isPairedEnd = TRUE,
                        strandSpecific = 0)

The files argument accepts a character vector of BAM file paths. The annot.ext argument specifies the annotation file, and isGTFAnnotationFile indicates that the annotation is in GTF format. For paired-end data, set isPairedEnd = TRUE so that read pairs are counted as a single fragment instead of two independent reads.

Understanding featureCounts Output

The featureCounts function returns a list containing several components:

  • counts: the matrix of read counts with genes as rows and samples as columns
  • annotation: the gene annotation information
  • stat: summary statistics for the counting process

The stat component provides valuable quality information, including the number of reads assigned to features, the number of unassigned reads, and the reasons for non-assignment. Review these statistics for each sample to identify potential problems. The chicken RNA-seq study provides a practical example of this workflow, where reads were aligned to the chicken reference genome using STAR software and gene expression was quantified using HTSeq-Count, followed by differential gene expression analysis using the edgeR package in R. The study identified 2,213 and 1,165 genes exhibiting significant differential expression compared to the control group on day 24 and 40 post-infection, respectively, with gene ontology enrichment and pathway analysis revealing candidate genes associated with the immune response.

Strand-Specific Counting

The strandSpecific parameter controls how strand information is used during counting:

  • 0: unstranded, reads are counted regardless of strand
  • 1: stranded, reads must match the annotated strand
  • 2: reversely stranded, reads must match the opposite of the annotated strand

The correct setting depends on the library preparation protocol used. Using the wrong strand setting will result in substantially reduced counts for most genes. Check the documentation for your library preparation kit to determine the appropriate setting.

Multi-Mapping Reads

By default, featureCounts assigns multi-mapping reads to features but reports them separately. The countMultiMappingReads parameter controls whether these reads are included in the count matrix. For most differential expression analyses, it is advisable to exclude multi-mapping reads because their assignment to specific genes is uncertain. The default behavior of featureCounts is to count only uniquely mapped reads, which is appropriate for standard analyses.

Creating a DGEList Object in edgeR

The edgeR package provides statistical methods for differential expression analysis of count data. The first step in edgeR analysis is creating a DGEList object, which stores the count matrix along with sample information and library sizes. The DGEList object serves as the central data structure for all subsequent edgeR operations, including filtering, normalization, dispersion estimation, and differential expression testing.

Constructing the DGEList

dge <- DGEList(counts = counts$counts,
               group = c("control", "control", "treatment"))

The counts argument accepts the count matrix from featureCounts. The group argument specifies the experimental groups for each sample. The order of group labels must match the order of samples in the count matrix columns.

Adding Sample Information

The DGEList object can store additional sample information in the samples data frame:

dge$samples$condition <- c("control", "control", "treatment")
dge$samples$batch <- c("batch1", "batch2", "batch1")

Including batch information is important when samples were processed in different batches or on different sequencing runs. The transcriptomic meta-analysis literature emphasizes that differences in experimental design, sequencing platforms, and sample composition introduce substantial heterogeneity that limits direct comparability between studies. Technical and biological heterogeneity must be explicitly considered to avoid misleading conclusions, and the limits of reproducibility and interpretation in cross-study analyses are defined by this heterogeneity.

Library Size Calculation

The DGEList automatically calculates library sizes as the total number of counts for each sample. These library sizes are used in subsequent normalization steps. Examine the library sizes to identify samples with unusually low total counts, which may indicate failed library preparation or sequencing problems.

Quality Filtering of Low-Expression Genes

Before differential expression analysis, filter out genes with very low expression across all samples. These genes provide little statistical power and increase the multiple testing burden. The filtering step is a critical preprocessing decision that affects the sensitivity and specificity of downstream differential expression analysis.

Filtering Criteria

The standard filtering approach retains genes that have a minimum number of counts per million (CPM) in a minimum number of samples. A common threshold is to require at least 1 CPM in at least the number of samples corresponding to the smallest group size:

keep <- rowSums(cpm(dge) > 1) >= min(table(dge$samples$group))
dge <- dge[keep, , keep.lib.sizes = FALSE]

The keep.lib.sizes = FALSE argument recalculates library sizes after filtering, which is important because the total counts will decrease after removing low-expression genes.

Justification for Filtering

Filtering serves two purposes. First, it removes genes for which the count data are too sparse to support reliable statistical inference. Second, it reduces the number of statistical tests performed, which decreases the severity of the multiple testing correction. The NOISeq package documentation emphasizes the importance of quality control and proper preprocessing decisions for accurate count data analysis. NOISeq provides diagnostic tools that can be used to monitor quality issues, make preprocessing decisions, and improve analysis, with the non-parametric NOISeqBIO method efficiently controlling false discoveries in experiments with biological replication.

Checking Filtering Results

After filtering, examine how many genes were retained:

dim(dge)

The number of retained genes will vary depending on the organism and tissue type. For mammalian genomes, typical RNA-seq experiments retain between 12,000 and 20,000 genes after filtering. If substantially fewer genes are retained, investigate whether the annotation file is appropriate for your organism or whether the sequencing depth was sufficient.

Normalization of Count Data

Normalization adjusts for differences in library size and composition between samples. edgeR provides several normalization methods, with TMM (trimmed mean of M-values) being the default and most commonly used. The choice of normalization method can affect downstream results, and the normalization literature notes that different methods can produce different results depending on data characteristics.

TMM Normalization

dge <- calcNormFactors(dge, method = "TMM")

The TMM method computes scaling factors that adjust for differences in library composition. This approach assumes that most genes are not differentially expressed between samples, which is a reasonable assumption for most experiments.

Examining Normalization Factors

After normalization, examine the computed scaling factors:

dge$samples$norm.factors

Normalization factors close to 1 indicate that samples have similar library compositions. Factors substantially different from 1 may indicate samples with unusual gene expression profiles or technical problems. A comparison of normalization methods for targeted RNA-seq data found that Upper Quartile normalization performed best for maintaining fold change levels, while simpler methods such as counts per million also provided reasonable results at absolute fold changes of 2.0 or greater. The study noted that despite having an assumption of the majority of genes being unchanged, the DESeq2 scaling factors normalization method performed reasonably well, as did simple normalization procedures including counts per million and total counts.

Alternative Normalization Methods

edgeR supports several normalization methods:

  • TMM: trimmed mean of M-values, the default
  • RLE: relative log expression, similar to DESeq2's method
  • upperquartile: upper quartile normalization

The choice of normalization method can affect downstream results. For most experiments, TMM provides reliable results, but it is worth comparing results from different methods to ensure that conclusions are robust to the normalization choice. The normalization literature also highlights that shared-reference transformations can introduce structural dependencies that inflate correlation estimates. Even when two variables are independent, subtracting a shared reference induces nonzero covariance and yields an expected correlation that increases with the variance of the reference. This artifact is systematic, strengthens as the reference becomes more variable, and does not disappear with increasing sample size. These findings highlight shared-reference preprocessing as a potential source of artificial dependence that should be explicitly considered when interpreting correlation-based findings.

Exploring Data Quality with MDS Plots

Multidimensional scaling (MDS) plots provide a visual representation of sample relationships. These plots are useful for identifying outliers and confirming that samples cluster by experimental group. The preprocessing literature emphasizes that technical artifacts and noise can affect downstream analysis if not properly identified and removed.

Creating an MDS Plot

plotMDS(dge, col = as.numeric(dge$samples$group))

The MDS plot projects the high-dimensional count data into two dimensions, allowing you to visualize the distances between samples. Samples from the same experimental group should cluster together, while samples from different groups should be separated.

Interpreting MDS Results

If samples do not cluster as expected, investigate potential causes:

  • Sample mislabeling during library preparation
  • Batch effects from processing samples at different times
  • RNA quality differences between samples
  • Contamination during library preparation

The popsicleR package was developed specifically to guide users through quality control and preprocessing of single-cell RNA-seq data, highlighting the importance of systematic quality assessment. The package integrates methods derived from widely used pipelines for the estimation of quality-control metrics, filtering of low-quality cells, data normalization, removal of technical and biological biases, and for cell clustering and annotation. While designed for single-cell data, the underlying principles of systematic quality assessment apply equally to bulk RNA-seq analysis.

Using MDS Plots for Outlier Detection

Samples that fall far from their expected group cluster may be outliers that should be excluded from the analysis. Before excluding any sample, verify that the sample was processed correctly and that the data quality metrics do not indicate a technical problem. Document any sample exclusions in your analysis records.

Estimating Dispersion

The dispersion parameter measures the variability of gene expression between biological replicates. edgeR uses an empirical Bayes approach to estimate dispersion, which borrows information across genes to improve estimates for genes with few replicates. Accurate dispersion estimation is essential for reliable differential expression testing.

Estimating Common and Tagwise Dispersion

dge <- estimateDisp(dge)

This function estimates the common dispersion, trended dispersion, and tagwise dispersion. The common dispersion represents the overall variability across all genes, while the tagwise dispersion provides gene-specific estimates that are shrunk toward the trend.

Examining Dispersion Estimates

plotBCV(dge)

The biological coefficient of variation (BCV) plot shows the relationship between dispersion and expression level. The BCV is the square root of the dispersion and represents the coefficient of variation between biological replicates. Well-behaved data typically show decreasing dispersion with increasing expression level, reflecting the greater reliability of counts for highly expressed genes.

Dispersion and Experimental Design

The dispersion estimates depend on the number of biological replicates. Experiments with more replicates provide more reliable dispersion estimates and greater statistical power. The NOISeq package documentation notes that non-parametric methods can efficiently control false discoveries in experiments with biological replication. For experiments with limited replication, the empirical Bayes approach in edgeR provides a compromise between gene-specific and pooled dispersion estimates.

Differential Expression Testing with edgeR

After dispersion estimation, the data are ready for differential expression testing. edgeR fits a negative binomial model to the count data and performs likelihood ratio tests or quasi-likelihood F-tests to identify differentially expressed genes. The choice of testing approach depends on the experimental design and the number of replicates available.

Fitting the Model

design <- model.matrix(~ group, data = dge$samples)
fit <- glmQLFit(dge, design)

The design matrix specifies the experimental model. For simple two-group comparisons, the design matrix contains an intercept and a group indicator. For more complex designs with multiple factors, include all relevant terms in the design matrix.

Testing for Differential Expression

qlf <- glmQLFTest(fit, coef = 2)
topTags(qlf, n = 20)

The glmQLFTest function tests for differential expression between groups. The coef = 2 argument specifies that the second coefficient in the design matrix corresponds to the group difference. The topTags function displays the top differentially expressed genes ranked by p-value.

Multiple Testing Correction

edgeR applies the Benjamini-Hochberg method to control the false discovery rate (FDR). The FDR-adjusted p-values are reported in the FDR column of the test results. Use the FDR values instead of raw p-values when identifying significant genes.

Extracting Results

results <- topTags(qlf, n = nrow(dge))
significant <- results$table[results$table$FDR < 0.05, ]

This code extracts all genes with FDR-adjusted p-values below 0.05. The choice of significance threshold depends on the experimental context and the balance between sensitivity and specificity that is appropriate for your research question.

At a Glance: Complete Workflow Summary

StepFunctionInputOutputKey Decision Point
Index buildingbuildindexReference FASTAIndex filesVerify genome build matches annotation
Read alignmentalignFASTQ filesBAM filesCheck uniquely mapped read percentage
QuantificationfeatureCountsBAM files, GTF annotationCount matrixSet correct strand-specific parameter
DGEList creationDGEListCount matrixDGEList objectConfirm sample order matches group labels
Gene filteringrowSums(cpm(dge) > 1)DGEListFiltered DGEListAdjust CPM threshold for sequencing depth
NormalizationcalcNormFactorsFiltered DGEListNormalized DGEListCompare TMM factors across samples
Dispersion estimationestimateDispNormalized DGEListDGEList with dispersionsExamine BCV plot for unusual patterns
Differential testingglmQLFTestDGEList, design matrixTest resultsUse FDR-adjusted p-values for significance

Practical Implementation Steps

Step 1: Organize Your Data

Create a project directory with subdirectories for raw data, reference files, and analysis outputs. A consistent directory structure makes it easier to track files and share analyses with collaborators. The Carpentries lessons provide foundational training on project organization and reproducible computing practices, including shell navigation, version control with Git, and programming fundamentals that support efficient bioinformatics work.

Step 2: Document Your Environment

Record the versions of R, Rsubread, and edgeR used for the analysis. Save the output of sessionInfo() to a text file in your project directory. This information is essential for reproducing the analysis at a later time or on a different computer. The nf-core documentation provides standards for reproducible workflow usage and configuration that can inform your own data management practices, emphasizing the importance of version control, containerization, and parameter documentation.

Step 3: Run Alignment for All Samples

Process all samples through the alignment step before proceeding to quantification. This approach allows you to identify problematic samples early and address issues before spending time on downstream analysis. The Galaxy Training Network provides accessible workflow training and analysis tutorials that emphasize reproducibility, offering practical guidance on running alignment and quantification steps in a reproducible manner.

Step 4: Review Alignment Statistics

For each sample, record the total number of reads, the number of uniquely mapped reads, and the percentage of reads assigned to genes. Compare these metrics across samples to identify any that deviate substantially from the group. The chicken RNA-seq study provides reference values for alignment quality, with uniquely mapped read percentages ranging from 78.07% to 87.74% and mismatch rates per base between 0.77% and 1.45%.

Step 5: Create and Filter the DGEList

Construct the DGEList object and apply the filtering criteria. Document the number of genes before and after filtering, along with the filtering threshold used. The filtering decision should be based on the sequencing depth and the number of samples in each group.

Step 6: Assess Sample Relationships

Generate MDS plots before and after normalization to confirm that samples cluster as expected. Investigate any samples that appear as outliers. The preprocessing choices made during analysis can affect downstream results, so careful assessment at this stage is important.

Step 7: Perform Differential Expression Analysis

Fit the model and test for differential expression. Save the complete results table for downstream analysis and reporting. The edgeR workflow supports a range of experimental designs, from simple two-group comparisons to complex multifactorial designs.

Records and Measurements for Quality Assurance

Maintaining detailed records of the analysis process is essential for reproducibility and for troubleshooting problems that may arise. The transcriptomic meta-analysis literature emphasizes that dataset selection, preprocessing, normalization, batch-effect correction, and statistical integration are key methodological steps that influence the reliability of cross-study analyses.

Essential Records

Record TypeContentPurpose
Sample metadataSample names, group assignments, batch informationEnsures correct group comparisons
Alignment statisticsTotal reads, mapped reads, unique mapping percentageIdentifies problematic samples
Filtering summaryGenes before and after filtering, threshold usedDocuments data reduction decisions
Normalization factorsTMM scaling factors for each sampleConfirms samples are comparable
Dispersion estimatesCommon and tagwise dispersion valuesAssesses biological variability
Session informationR version, package versionsEnables exact reproduction
Analysis scriptComplete R code with commentsProvides executable documentation

Measurements to Monitor

Track the following metrics for each sample throughout the analysis:

  • Total read count
  • Percentage of reads aligned to the reference genome
  • Percentage of reads assigned to annotated genes
  • Library size after filtering
  • Normalization factor

The chicken RNA-seq study provides reference values for alignment quality, with uniquely mapped read percentages ranging from 78.07% to 87.74% and mismatch rates per base between 0.77% and 1.45%. These values offer a practical benchmark for evaluating your own alignment results.

Common Failure Patterns and Troubleshooting

Low Alignment Rates

If fewer than 70% of reads align to the reference genome, investigate potential causes:

  • Adapter contamination in the raw reads
  • Reference genome mismatches with the sample species or strain
  • RNA quality issues leading to degraded fragments
  • Contamination with non-target species RNA

Adapter contamination can be addressed by trimming adapters before alignment. FastqPuri was designed to efficiently remove adapter sequences and biological contamination from sequencing data, providing sequence quality reports on the sample and dataset level with new plots that facilitate decision making for subsequent quality filtering. While FastqPuri operates outside R, the same preprocessing principles apply.

Unexpected Sample Clustering

If MDS plots show samples clustering by batch instead of by experimental group, batch effects may be present. Options for addressing batch effects include:

  • Including batch as a covariate in the design matrix
  • Using batch correction methods during normalization
  • Excluding problematic samples if the batch effect is severe

The transcriptomic meta-analysis literature emphasizes that technical and biological heterogeneity must be explicitly considered to avoid misleading conclusions. Batch-effect correction is a key methodological step in integrating data across experiments and conditions.

Excessive Dispersion

If dispersion estimates are unusually high, this may indicate:

  • Hidden batch effects
  • Sample mislabeling
  • Biological heterogeneity within groups
  • Technical variability from library preparation

The preprocessing choices made during analysis can affect downstream results. A study of RNA velocity analysis found that abundance quantification is a crucial aspect of the workflow and that both the definition of genomic features and the quantification algorithm require careful consideration. The study systematically compared five widely used quantification tools, in total yielding thirteen different quantification approaches, and found substantial differences between the quantifications obtained from different tools.

Zero Counts for Known Expressed Genes

If genes that should be expressed in your tissue or cell type show zero counts across all samples, verify:

  • The annotation file matches the genome build
  • The strand-specific parameter is set correctly
  • The reference genome is appropriate for your species

Limitations of the Rsubread and edgeR Workflow

Computational Requirements

Alignment with Rsubread requires substantial memory for index building, particularly for large genomes. The index for the human genome requires several gigabytes of RAM. For laboratories with limited computational resources, consider using a computing cluster or cloud-based resources. The nf-core documentation provides guidance on configuring workflows for different computing environments, including high-performance computing clusters and cloud platforms.

Reference Dependence

This workflow requires a well-annotated reference genome. For organisms without high-quality annotations, alignment-based quantification may miss novel transcripts or incorrectly assign reads to genes. Alternative approaches such as transcript quantification without alignment may be more appropriate in these cases. The EMBL-EBI Training program provides learning pathways for bioinformatics data resources and practical analysis education, including guidance on working with reference genomes and annotations.

Single-Cell RNA-seq Considerations

The workflow described here is designed for bulk RNA-seq data. Single-cell RNA-seq data require additional preprocessing steps, including cell filtering, doublet removal, and specialized normalization. The popsicleR package provides an interactive approach to preprocessing and quality control for single-cell data, integrating methods derived from widely used pipelines for the estimation of quality-control metrics, filtering of low-quality cells, data normalization, removal of technical and biological biases, and for cell clustering and annotation. Similarly, the scUmaper framework addresses doublet removal and cell-type annotation in single-cell transcriptomics, integrating quality control, biologically grounded doublet filtering, and marker-library-based cell-type annotation. The scUmaper workflow codifies lineage-marker incompatibility rules and applies global clustering followed by within-lineage re-clustering to reveal anomalous subclusters with implausible cross-lineage co-expression.

Normalization Assumptions

The TMM normalization method assumes that most genes are not differentially expressed between samples. This assumption may be violated in experiments with large-scale transcriptional changes, such as comparing different cell types or tissues. In such cases, alternative normalization approaches may be more appropriate. The normalization literature notes that shared-reference transformations can introduce structural dependencies that inflate correlation estimates, and that sequential shared transformations can become unstable when denominators fluctuate or approach zero, producing highly dispersed correlations consistent with heavy-tailed ratio effects.

Safety and Reproducibility Context

Data Management

RNA-seq data files are large, often exceeding several gigabytes per sample. Implement a data management plan that includes:

  • Regular backups of raw data and analysis outputs
  • Version control for analysis scripts
  • Documentation of file locations and naming conventions

The nf-core documentation provides standards for reproducible workflow usage and configuration that can inform your own data management practices. Community pipeline standards emphasize the importance of version control, containerization, and parameter documentation for ensuring reproducibility across different computing environments.

Reproducibility Standards

The Galaxy Training Network provides accessible workflow training and analysis tutorials that emphasize reproducibility. Adopting similar practices in your R workflow, such as using scripts instead of interactive commands and documenting all parameter choices, supports reproducibility. The EMBL-EBI Training program provides learning pathways for bioinformatics data resources and practical analysis education, helping researchers build the skills needed to conduct reproducible analyses.

Professional Escalation Criteria

Seek assistance from a bioinformatics specialist or core facility when:

  • Alignment rates fall below 70% and troubleshooting does not resolve the issue
  • MDS plots show unexpected sample clustering that cannot be explained by experimental factors
  • Dispersion estimates are extreme and suggest technical problems
  • You need to analyze data from non-model organisms without established reference genomes
  • The experimental design requires advanced statistical methods beyond standard group comparisons

The EMBL-EBI Training program provides learning pathways for bioinformatics data resources and practical analysis education. These resources can help researchers build the skills needed to troubleshoot analysis problems independently.

Frequently Asked Questions

What is the difference between Rsubread and other alignment tools like STAR or HISAT2?

Rsubread provides alignment functionality within the R environment, eliminating the need to switch between command-line tools and R. STAR and HISAT2 are standalone tools that may offer faster alignment speeds or different features, but they require separate installation and data transfer between environments. The choice between these tools depends on your preference for working within R and the specific requirements of your analysis. The chicken RNA-seq study provides an example of using STAR for alignment followed by HTSeq-Count for quantification and edgeR for differential expression analysis, demonstrating that multiple tool combinations can produce valid results.

How do I choose between paired-end and single-end sequencing for my experiment?

Paired-end sequencing provides additional information about fragment structure that can improve alignment accuracy, particularly for reads spanning splice junctions. Single-end sequencing is less expensive and may be sufficient for standard gene expression quantification. The choice depends on your research question, budget, and the complexity of your transcriptome. For organisms with complex splicing patterns or for detecting novel isoforms, paired-end sequencing provides advantages.

What is the minimum number of biological replicates needed for differential expression analysis?

The number of biological replicates affects statistical power and the reliability of dispersion estimates. More replicates provide greater power to detect differentially expressed genes and more accurate estimates of biological variability. The NOISeq package documentation notes that non-parametric methods efficiently control false discoveries in experiments with biological replication. For most experiments, at least three biological replicates per group are recommended, with more replicates providing additional power.

How should I handle samples with very low sequencing depth?

Samples with substantially lower total read counts than others may need to be excluded from the analysis or analyzed with appropriate statistical methods that account for differences in library size. Examine the library sizes in your DGEList object and compare them across samples. If one sample has dramatically fewer reads, investigate whether this reflects a technical problem with library preparation or sequencing.

Can I use this workflow for non-model organisms without a reference genome?

The Rsubread alignment approach requires a reference genome. For non-model organisms without a reference genome, alternative approaches such as de novo transcriptome assembly followed by quantification may be more appropriate. These approaches have different computational requirements and analytical considerations. The NCBI provides sequence resources and analysis services that can support work with non-model organisms.

How do I incorporate batch information into my edgeR analysis?

Include batch as a covariate in the design matrix when fitting the model. For example, if samples were processed in two batches, the design matrix would include both the group and batch variables. This approach adjusts for systematic differences between batches while testing for group differences. The transcriptomic meta-analysis literature emphasizes that batch-effect correction is a key methodological step that must be explicitly considered to avoid misleading conclusions.

What is the appropriate significance threshold for identifying differentially expressed genes?

The choice of significance threshold depends on the balance between sensitivity and specificity appropriate for your research question. A common threshold is an FDR-adjusted p-value below 0.05, but more stringent thresholds may be appropriate for experiments with many genes or when false positives are particularly costly. The edgeR documentation provides guidance on interpreting FDR-adjusted p-values.

How do I know if my normalization method is appropriate for my data?

Examine the normalization factors and MDS plots to assess whether samples are comparable after normalization. If samples from the same group do not cluster together, the normalization may not be adequately adjusting for technical variation. Consider trying alternative normalization methods and comparing the results to determine which approach is most appropriate for your data. A comparison of normalization methods for targeted RNA-seq data found that Upper Quartile normalization performed best for maintaining fold change levels, while simpler methods such as counts per million also provided reasonable results at absolute fold changes of 2.0 or greater.

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.