GenomicAlignments
Dependencies & Environment
Package-intrinsic requirements from the Bioconductor landing page — reproduce in any R environment.
- Version: 1.48.0 · Bioconductor: 3.23 · R: ≥ 4.6
- Depends: BiocGenerics, S4Vectors, IRanges, Seqinfo, GenomicRanges, SummarizedExperiment, Biostrings, Rsamtools
- Imports: BiocGenerics, S4Vectors, IRanges, GenomicRanges, Biostrings, Rsamtools, BiocParallel, cigarillo
- Install:
BiocManager::install("GenomicAlignments")
When to Use
- Counting aligned reads overlapping genomic features (e.g., exons, genes) for differential expression analysis using
summarizeOverlaps. - Loading and manipulating paired-end alignments from BAM files using
readGAlignmentPairs. - Analyzing splice junctions, insertions, and deletions in RNA-seq reads using the
njunc,cigar, andcigarOpTablefunctions. - Filtering alignments based on mapping quality, duplicates, or specific genomic regions using
ScanBamParamandscanBamFlag.
When NOT to Use
- For ultra-fast, memory-efficient read counting on massive datasets, use
Rsubread::featureCountsbecause it is written in C and optimized for speed. - For low-level BAM file indexing or header manipulation without loading alignments, use
Rsamtoolsbecause it provides direct wrappers to samtools functionality.
Data Requirements
- Input Format: Sorted and indexed BAM files.
- Features: Genomic features provided as
GRangesorGRangesListobjects for overlap counting. - Structure: Alignments are loaded into
GAlignments(single-end) orGAlignmentPairs(paired-end) objects.
Key Parameters
- use.names (TRUE): Logical indicating whether to load query names (QNAME) from the BAM file in
readGAlignments. - param: A
ScanBamParamobject specifying filtering criteria (e.g., flags, genomic regions) when reading alignments. - mode ("Union"): The overlap resolution mode for
summarizeOverlaps(e.g., "Union", "IntersectionStrict", "IntersectionNotEmpty"). - isDuplicate (FALSE): Flag in
scanBamFlagto filter out PCR or optical duplicates. - isNotPassingQualityControls (FALSE): Flag in
scanBamFlagto filter out low-quality reads. - isFirstMateRead (TRUE): Flag in
scanBamFlagto specifically load only the first segment of paired-end reads.
Best Practices
- Use
ScanBamParamwithscanBamFlagto filter out PCR duplicates and reads failing quality controls before loading alignments into memory. - When working with paired-end data, use
readGAlignmentPairsand filter for proper pairs usingisProperPairto ensure high-quality alignments. - Use
summarizeOverlapswith aGRangesList(e.g., exons grouped by transcript or gene) to correctly count reads spanning multiple exons of the same feature.
Common Pitfalls
- Out of memory errors: Running out of memory when loading entire BAM files at once. Fix: Use
ScanBamParamto restrict loading to specific genomic regions (usingwhich) or specific fields (usingwhat). - Incorrect paired-end counting: Counting paired-end reads as independent single-end reads. Fix: Ensure paired-end BAM files are loaded with
readGAlignmentPairsor handled appropriately in counting functions. - Assuming unique read names: Assuming read names are unique in the loaded
GAlignmentsobject, which fails when aligners report multiple alignments per read. Fix: Handle duplicated query names by checkingduplicated(names(gal)).
Alternatives
Rsubread: For extremely fast, multi-threaded read counting (featureCounts) in R.Rsamtools: For low-level BAM/SAM file access, indexing, and manipulation.GenomicRanges: For general genomic interval operations once alignments are converted to ranges.
Citations
- Lawrence, M., Huber, W., Pagès, H., Aboyoun, P., Carlson, M., Gentleman, R., ... & Carey, V. J. (2013). Software for computing and annotating genomic ranges. PLoS Computational Biology, 9(8), e1003118.
References
- Homepage: https://bioconductor.org/packages/GenomicAlignments
- Vignette: vignette_0_5516405c.txt
Run this on BioMate
This skill is the knowledge layer — when, why, and how to use genomicalignments. To run this analysis on your own data with managed compute, automated QC, and reproducible outputs, use BioMate — free to start.