Convert a BAM file to any format supported by rtracklayer::export.

bam_to(
  bam_files,
  formats = c("bedGraph", "bigWig"),
  width = 150,
  outdir = NULL,
  verbose = TRUE,
  ...
)

Arguments

bam_files

One or more BAM files.

formats

A character vector of one or more formats for export file to.

width

Width to extend reads to (in base pairs).

outdir

Directory to save results to.

verbose

Print messages.

...

Additional arguments passed to rtracklayer::export.

Value

Converted file paths.

Examples

bam_files <- c(f1=system.file("extdata","querybins.bam",package="Rsamtools"),
               f2=system.file("extdata","revbins.bam",package="Rsamtools"))
converted_files <- bam_to(bam_files = bam_files)               
#> Processing: /__w/_temp/Library/Rsamtools/extdata/querybins.bam
#> Extending reads.
#> Warning: GRanges object contains 2 out-of-bound ranges located on sequence sim. Note
#>   that ranges located on a sequence whose length is unknown (NA) or on a
#>   circular sequence are not considered out-of-bound (use seqlengths() and
#>   isCircular() to get the lengths and circularity flags of the underlying
#>   sequences). You can use trim() to trim these ranges. See
#>   ?`trim,GenomicRanges-method` for more information.
#> Computing coverage.
#> Exporting to 'bedGraph': /__w/_temp/Library/Rsamtools/extdata/querybins.bedGraph
#> Conversion to 'bedgraph' done in 0 min
#> Exporting to 'bigWig': /__w/_temp/Library/Rsamtools/extdata/querybins.bigWig
#> Conversion to 'bigwig' done in 0 min
#> Processing: /__w/_temp/Library/Rsamtools/extdata/revbins.bam
#> Extending reads.
#> Warning: GRanges object contains 19 out-of-bound ranges located on sequences simple,
#>   bistag, tristag, inf, and diffstr. Note that ranges located on a sequence
#>   whose length is unknown (NA) or on a circular sequence are not considered
#>   out-of-bound (use seqlengths() and isCircular() to get the lengths and
#>   circularity flags of the underlying sequences). You can use trim() to trim
#>   these ranges. See ?`trim,GenomicRanges-method` for more information.
#> Computing coverage.
#> Exporting to 'bedGraph': /__w/_temp/Library/Rsamtools/extdata/revbins.bedGraph
#> Conversion to 'bedgraph' done in 0 min
#> Exporting to 'bigWig': /__w/_temp/Library/Rsamtools/extdata/revbins.bigWig
#> Conversion to 'bigwig' done in 0 min