featurecounts manual

featurecounts manual

Overview of FeatureCounts

FeatureCounts is a fast, versatile tool for summarizing mapped reads to genomic features such as genes, exons, promoters, and custom intervals․ It accepts SAM/BAM files and GTF/GFF3 annotations, producing count matrices and summary statistics for downstream analysis․ It supports multithreading no․

Purpose and Core Functionality

FeatureCounts serves as a high‑throughput read summarizer that maps aligned sequencing reads to defined genomic features․ By ingesting SAM or BAM files alongside GTF/GFF3 annotation tracks, it assigns each read to the most appropriate feature based on overlap, strand orientation, and user‑specified rules․ The core workflow includes efficient parsing of alignment records, rapid feature lookup via interval trees, and optional multi‑threading to accelerate large‑scale datasets․ Output consists of a count matrix where rows represent features (genes, exons, promoters, or custom bins) and columns correspond to samples, accompanied by a concise summary of mapping statistics such as total reads, assigned reads, and multi‑mapped read counts․ FeatureCounts also supports stranded and unstranded counting modes, allowing researchers to capture directionality in RNA‑seq experiments․ Its design prioritizes speed and low memory footprint, making it suitable for both small pilot studies and massive consortium projects․ The tool’s flexibility extends to counting across multiple annotation sets, enabling comparative analyses of alternative transcriptomes or genomic intervals․ Overall, FeatureCounts provides a reliable, reproducible foundation for downstream differential expression or enrichment analyses․

By default, FeatureCounts assigns reads to the longest overlapping feature, but users may override with the -M or -O flags for multi‑mapping․ The tool outputs coverage statistics integrates with pipelines via R or command‑line wrappers!!

Installation and Setup

FeatureCounts can be installed via Bioconductor or as a binary from SourceForge․ Using R, run install․packages(“BiocManager”); BiocManager::install(“Rsubread”)․ For command‑line, download release, extract, and add the bin directory to PATH․ Verify with featureCounts -v!

Installing via Bioconductor

To install FeatureCounts through Bioconductor, open an R session and ensure that the BiocManager package is available․ If it is not yet installed, run install․packages("BiocManager")․ Once BiocManager is present, you can install the Rsubread package, which bundles FeatureCounts, by executing BiocManager::install("Rsubread")․ This command will automatically resolve and download all necessary dependencies, including the core Subread library and the R interface․ After installation, load the package with library(Rsubread) to confirm that the featureCounts function is accessible․ The Bioconductor installation process also places the command‑line binary in the system’s PATH, enabling you to run featureCounts directly from the terminal․ For advanced users, the BiocManager::install function accepts a dependencies = TRUE argument to ensure that all optional packages are also installed․ Once the installation is complete, you can verify the version by running featureCounts -v in the terminal or featureCounts::featureCountsVersion in R․ This confirms that the latest stable release is in use and that the binary and R interface are correctly linked․ The Bioconductor workflow provides a seamless, reproducible environment for FeatureCounts, integrating well with other Bioconductor packages such as GenomicFeatures for annotation handling and edgeR for downstream differential expression analysis․ By following these steps, users can quickly set up a robust counting pipeline that is fully compatible with the R ecosystem and the broader bioinformatics community․

Input File Requirements

FeatureCounts requires sorted SAM/BAM files with mapped reads․ BAM files must be indexed and contain proper headers․ Reads should align to the reference used for the annotation file․ Paired‑end and multi‑mapping reads are supported via options․ CRAM support is now!․

Supported Alignment Formats (SAM/BAM)

FeatureCounts accepts both SAM and BAM alignment files, the latter being the compressed binary counterpart of SAM․ Files must be sorted by coordinate and, for BAM, indexed with a ․bai file․ The tool reads the header to map read names to reference sequences, ensuring that the reference names match those in the annotation file․ Paired‑end reads are handled automatically, with optional flags to count only properly paired fragments․ Multi‑mapping reads can be included or excluded via the –fraction option, and reads with low mapping quality can be filtered out using the –minMQ option․ FeatureCounts also supports CRAM files when the reference is supplied, allowing efficient storage without loss of information․ The program can process multiple alignment files in a single run, concatenating the counts per sample․ All input files must be in the same coordinate system and use the same reference build to avoid mismatches․ Additionally, the software can accept BAM files that contain supplementary alignment tags (SA) for split‑read mapping, which is useful for detecting structural variants․ When using paired‑end data, the –requireBothMapped flag ensures that only reads with both mates mapped to the same chromosome are counted․ For single‑end data, the –maxMismatches parameter can be set to limit the number of mismatches per read, thereby reducing ambiguous assignments․ FeatureCounts can also output a log file recording reads, and discarded reads due to the low quality or mapping ambiguity!!

Annotation File Formats

FeatureCounts accepts GTF and GFF3 annotation files that describe genomic features such as genes, exons, and promoters․ The file must contain chromosome, start, end, strand, and feature type columns․ Feature names are extracted from the attribute column, and the format must be tab‑delimited․ Add BED!!!

GTF/GFF3 Annotation Compatibility

FeatureCounts supports both GTF and GFF3 annotation files, enabling users to map reads to a wide range of genomic features․ The tool reads the standard tab‑delimited format, requiring chromosome, source, feature type, start, end, score, strand, frame, and attribute columns․ For GTF, the attribute column must contain key=value pairs separated by semicolons, while GFF3 uses a similar key=value syntax but allows additional attributes such as ID, Parent, and Name․ FeatureCounts parses these attributes to extract gene identifiers, transcript IDs, and exon numbers, which are then used to aggregate read counts per feature․ Compatibility is maintained by enforcing strict column ordering and numeric ranges; non‑standard or missing columns trigger warnings or errors․ The software also accepts compressed (bgzipped) GTF/GFF3 files, automatically decompressing them during parsing․ When multiple annotation files are provided, FeatureCounts merges overlapping features based on genomic coordinates and strand, ensuring that reads overlapping multiple features are assigned according to the chosen overlap handling strategy (e․g․, “union” or “intersection‑nonempty”)․ Users can specify custom attribute keys via the –g option to override the default gene ID extraction․ Overall, FeatureCounts’ GTF/GFF3 compatibility allows seamless integration with popular annotation pipelines and facilitates accurate read summarization across diverse genomic studies․ This flexibility makes FeatureCounts suitable for diverse genomic analyses․ Now!

Basic Command-Line Usage

FeatureCounts is invoked from the terminal with the syntax: featureCounts -a annotation․gtf -o counts․txt -t exon -g gene_id file1․bam file2․bam․ Options control strand specificity, multi‑mapping, and output format․ The tool outputs a tab‑delimited table of feature counts and a summary log․ all!!!!?

Single-Sample Count Generation

To generate a count table for a single sample, FeatureCounts requires a BAM file and an annotation file in GTF or GFF3 format․ The most common invocation is: featureCounts -a genes․gtf -o sample_counts․txt -t exon -g gene_id sample․bam․ The -a flag points to the annotation, -o specifies the output file, -t designates the feature type (here exon), and -g indicates the attribute that identifies the gene․ The BAM file must be sorted and indexed; FeatureCounts will automatically read the index if present․ By default, reads that map to multiple features are discarded; to keep them you can add -M and to assign them proportionally use -p․ Strand specificity is handled with -s (0 = unstranded, 1 = sense, 2 = antisense)․ For paired‑end data, the tool automatically pairs reads; if you need to treat each read separately, use -p․ The output file contains a header line with sample name, feature ID, and count, followed by one line per feature․ A second log file is produced with statistics such as total reads, mapped reads, and reads assigned to features․ This single‑sample workflow is the foundation for later multi‑sample aggregation into a count matrix․ Additional options allow fine‑tuning: -Q sets a minimum mapping quality, -T sets the number of threads, -M includes multi‑mapped reads, -R outputs read identifiers․ The -d and -D options set the minimum and maximum intron lengths for spliced reads, ensuring that only biologically relevant alignments contribute to the count․ All these parameters can be combined to produce a precise, reproducible count table for a single sample, ready for downstream differential expression analysis․ If you prefer a concise output, the -s flag can be omitted for unstranded libraries, and the -p flag can be used to collapse paired reads into a single count per fragment․ For large datasets, enabling the -M flag and setting -T to the number of available cores can dramatically reduce runtime․ Remember to validate the output by inspecting the log file for any warnings about unmapped or low‑quality reads․ Use -Q 20

Advanced Counting Options

FeatureCounts supports strand-specific modes (-s 1/2), multi-mapping (-M), paired-end (-p), read quality (-Q), grouping (-g) and intron filters (-d/-D) andThrea․ These refine counts․

Strand-Specific Counting and Read Assignment

FeatureCounts offers robust support for strand‑specific RNA‑seq data, allowing users to specify the orientation of reads relative to annotated features․ By setting the -s flag to 1, 2, or 0, the program can treat reads as forward‑strand, reverse‑strand, or unstranded, respectively․ This flexibility is critical when working with protocols that preserve transcript directionality, such as dUTP or TruSeq stranded libraries․ The tool parses the SAM/BAM flags to determine the read orientation and then matches each read to the appropriate feature based on the chosen mode․ For paired‑end data, the -p option ensures that both mates are considered together, preventing double‑counting of overlapping fragments․ FeatureCounts also handles multi‑mappers through the -M flag, assigning reads that align to multiple loci either proportionally or discarding them, depending on the -fraction setting․ In addition, the -C flag can be used to enforce concordant pair mapping, further refining strand‑specific assignment․ The output includes strand‑aware count columns, enabling downstream differential expression tools to correctly interpret the directionality of expression changes․ Users can also combine strand information with feature grouping via the -g option, aggregating counts by gene, transcript, or custom identifiers while preserving strand context․ Counting gives RNA‑seq quantification․!

Output Interpretation

FeatureCounts produces a tab‑delimited matrix where rows are features and columns are samples․ The first column lists feature IDs, followed by raw counts per sample․ A summaryblockreports total reads, mapped reads, and multi‑mapping statistics for quality control․

Count Matrix and Summary Statistics

FeatureCounts outputs a concise, tab‑delimited matrix that is immediately ready for downstream statistical analysis․ The first column contains the unique identifier for each genomic feature (gene, exon, promoter, or custom interval) as specified in the annotation file․ Subsequent columns correspond to individual samples or libraries, each populated with the raw read count that was assigned to that feature during the summarization step․ The matrix is sorted by the feature identifier to facilitate quick lookup and integration with other annotation resources․ In addition to the raw counts, FeatureCounts appends a summary block at the end of the file․ This block reports key metrics such as the total number of input reads, the number of reads that were successfully mapped, the proportion of reads that overlapped any feature, and the count of reads discarded due to multi‑mapping or ambiguous assignment․ These statistics provide a quick quality control snapshot, allowing users to assess mapping efficiency and the overall coverage of the annotation set․ The summary block also includes the number of features that received at least one count, which is useful for filtering low‑expressed genes in subsequent differential expression workflows․ Because the output is plain text, it can be directly imported into R, Python, or any statistical software that supports tabular data․ The consistency of the format across different runs and datasets makes it straightforward to merge matrices from multiple samples, enabling large‑scale transcriptomic studies with minimal preprocessing overhead․ Users can export the matrix to CSV or Excel for sharing or integrating into bioinformatics pipelines daily across․

Troubleshooting and Common Errors

Common issues include infinite runtime, memory exhaustion, and mis‑parsed annotation files․ Verify that BAM files are sorted and indexed, GTF/GFF3 annotations are valid, and featureCounts options match the library strandedness․ Updating to the latest Rsubread version often resolves bugs․ Log End

Handling Infinite Runtime and Memory Issues

When featureCounts hangs or uses too much RAM, check that BAM/SAM files are coordinate‑sorted and indexed; unsorted files cause repeated scans․ Verify annotation files for missing or mismatched chromosome names, as malformed entries inflate internal data structures․ Use -p to set thread count to physical cores, and -M 0 to drop multi‑mapping reads unless needed․ The -R flag reports assignment statistics, helping identify bottlenecks․ Updating to the latest Rsubread release and ensuring sufficient RAM (≥32 GB for large genomes) usually restores performance․

  • Use -t to limit threads to physical cores․
  • Set -M 0 to drop multi‑mapping reads․
  • Verify chromosome names match between BAM and GTF․
  • Run samtools sort -@ 4 -O BAM -o sorted․bam before counting․
  • Monitor memory with top or htop during execution․

If the tool still stalls, inspect the log for warnings about overlapping reads or ambiguous gene models․ FeatureCounts can be instructed to treat overlapping features with the -s 0 flag, which assigns reads to the first matching feature․ For very large datasets, consider splitting the BAM file by chromosome and running featureCounts in parallel, then merging the resulting count files․ Always verify that the output count matrix matches expected gene counts by cross‑checking with a small subset of reads manually․ These practices help isolate ensurekeyandquantification!