seqinfo_from_header {spiky}R Documentation

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

Description

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

Usage

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

Arguments

x

the BAM/CRAM file or its header

gen

genome of the BAM/CRAM 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 CRAM or 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 

  # FIXME: add an example with a CRAM instead 
  sp <- system.file("extdata", "example.spike.bam", package="spiky")
  sp_gr <- seqinfo_from_header(sp, ret="gr")
  sp_gr 


[Package spiky version 0.99.999 Index]