seqinfo_from_header: create seqinfo (and thus a standard chromosome filter) from a...

View source: R/seqinfo_from_header.R

seqinfo_from_headerR Documentation

create seqinfo (and thus a standard chromosome filter) from a BAM header

Description

create seqinfo (and thus a standard chromosome filter) from a BAM header

Usage

seqinfo_from_header(x, gen = NA, std = FALSE, ret = c("si", "gr"))

Arguments

x

the BAM file or its header

gen

genome of the BAM file, if known (NULL; autodetect)

std

standard chromosomes only? (FALSE; will be empty if spikes)

ret

return Seqinfo ("si", the default) or GRanges ("gr")? ("si")

Details

Setting std=TRUE on a spike-in BAM will produce an empty result.

Value

   Seqinfo object or GRanges (or `as(seqinfo, "GRanges")`)

Examples


  library(Rsamtools)
  fl <- system.file("extdata", "ex1.bam", package="Rsamtools", mustWork=TRUE)

  hdr <- scanBamHeader(BamFile(fl))
  si <- seqinfo_from_header(hdr)
  gr <- seqinfo_from_header(fl, ret="gr")
  stopifnot(identical(gr, as(si, "GRanges")))

  std_si <- seqinfo_from_header(fl, std=TRUE)
  seqlevels(std_si)

  # for comparison with below
  data(spike, package="spiky")
  spike

  sp <- system.file("extdata", "example.spike.bam", package="spiky")
  sp_gr <- seqinfo_from_header(sp, ret="gr")
  sp_gr


trichelab/spiky documentation built on Sept. 17, 2022, 8:44 a.m.