View source: R/seqinfo_from_header.R
| seqinfo_from_header | R Documentation | 
create seqinfo (and thus a standard chromosome filter) from a BAM header
seqinfo_from_header(x, gen = NA, std = FALSE, ret = c("si", "gr"))
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")  | 
Setting std=TRUE on a spike-in BAM will produce an empty result.
Seqinfo object or GRanges (or `as(seqinfo, "GRanges")`)
  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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.