Get a genome (or a subset of chromosomes from a genome) as a GRanges object. This can be useful for querying whole-chromosomes at a time.

get_genome(
  keep.chr = paste0("chr", c(seq_len(22), "X", "Y")),
  genome = "hg19",
  sort = TRUE,
  style = "UCSC",
  split_chromosomes = FALSE
)

Arguments

keep.chr

is a character vector stating the names of the chromosomes to keep. Any chromosome not in the vector will be filtered out. If keep.chr is supplied, organism and chr.type are ignored.

genome

The genome object or genome identifier.

sort

Whether to sort the GRanges by chromosomes.

style

Chromosome style, set by seqlevelsStyle.

  • "UCSC" : Uses the chromosome style "chr1".

  • "NCBI" : Uses the chromosome style "1"

split_chromosomes

Whether to split the GRanges by chromosome (as a named list).

Value

GRanges

Examples

gr <- get_genome(keep.chr=1:2)
#> 
#> Attaching package: ‘BiocGenerics’
#> The following objects are masked from ‘package:stats’:
#> 
#>     IQR, mad, sd, var, xtabs
#> The following objects are masked from ‘package:base’:
#> 
#>     Filter, Find, Map, Position, Reduce, anyDuplicated, append,
#>     as.data.frame, basename, cbind, colnames, dirname, do.call,
#>     duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
#>     lapply, mapply, match, mget, order, paste, pmax, pmax.int, pmin,
#>     pmin.int, rank, rbind, rownames, sapply, setdiff, sort, table,
#>     tapply, union, unique, unsplit, which.max, which.min
#> 
#> Attaching package: ‘S4Vectors’
#> The following objects are masked from ‘package:base’:
#> 
#>     I, expand.grid, unname
#> 
#> Attaching package: ‘Biostrings’
#> The following object is masked from ‘package:base’:
#> 
#>     strsplit