Skip to contents

Reads a file in BAM format by blocks of lines equal to a yield size, either automatically calculated or specified by the user, and loads it as a GenomicAlignments object.

Usage

tx_load_bam(
  file,
  pairedEnd,
  yieldSize = 1e+05,
  scanFlag = "default",
  loadSeq = FALSE,
  strandMode = 1,
  loadSecondaryAligns = NA,
  verbose = TRUE
)

Arguments

file

character. Path to the file to read

pairedEnd

logical. Set to FALSE if reads in BAM file are single-end, set to TRUE if reads are paired-end.

yieldSize

numeric. Number of reads to be processed at a time

scanFlag

integer. Flag used to filter reads. Built with the scanBamFlag function.

loadSeq

logical. Set to TRUE for loading the sequences contained in the BAM file

strandMode

numeric.

  • 1 (default): Strand of the pair is that of its first alignment: Directional Illumina (Ligation), Standard SOLiD. (Single-end No change in strand)

  • 2: strand of the pair is strand of its last alignment: dUTP, NSR, NNSR, Illumina stranded TruSeq PE protocol. (Single-end: Change to inverse strand)

  • 0: strand of the pair is set to '*' (unspecified). This mode is no longer supported by tx_reads() .

More info: GAlignmentPairs-class.

loadSecondaryAligns

logical. Set to FALSE to discard alignments labeled in the BAM file as secondary and load only primary alignments, set to TRUE to load only secondary alignments, leave as NA to load both primary and secondary alignments.

verbose

logical. Set to FALSE to show less information.

Value

GRanges

Examples

# Loading in-package BAM file
bamFile <- system.file("extdata", "example_hg19.bam", package = "txtools")
hg19_bam <- tx_load_bam(bamFile, pairedEnd = TRUE, loadSeq = TRUE, verbose = TRUE)
#> Reading number of records in file 
#> 5061 number of BAM records 
#> Loading BAM file 
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
#> 0 reads filtered out for empty sequence field 
#> 2530 Reads succesfully loaded 
#> Dumped ambiguous reads: 0 
summary(hg19_bam)
#> [1] "GAlignmentPairs object of length 2530 with 0 metadata columns"