Last data update: 2014.03.03

R: getGenome
getGenomeR Documentation

getGenome

Description

Function to obtain a genome

Usage

getGenome(genome)

Arguments

genome

The genome object or genome identifier.

Details

If genome is a BSgenome (from the package BioStrings), it will transform it into a GRanges with chromosomes and chromosome lengths.

If genome is a data.frame with 3 columns, it will transform it into a GRanges.

If genome is a data.frame with 2 columns, it will assume the first is the chromosome, the second is the length of the chromosomes and will add 1 as start.

If genome is a character string uniquely identifying a BSgenome installed in the system (e.g. "hg19", "mm10",... but not "hg"), it will create a genome based on the BSgenome object identified by the character string.

If genome is a GRanges object, it will return it as is.

If genome is non of the above, it will give a warning and try to transform it into a GRanges using toGRanges. This can be helpful if genome is a connection to a file.

Value

A GRanges object with the "genome" data c(Chromosome, Start (by default, 1), Chromosome Length) given a BSgenome, a genome name, a data.frame or a GRanges.

A GRanges representing the genome with one region per chromosome.

Note

This function is memoised (cached) using the memoise package. To empty the cache, use forget(getGenome)

Please note that passing this function the path to a file will not work, since it will assume the character is the identifier of a genome. To read the genome from a file, please use getGenome(toGRanges("path/to/file"))

See Also

getMask, getGenomeAndMask, characterToBSGenome, maskFromBSGenome, emptyCacheRegioneR

Examples

getGenome("hg19")

getGenome(data.frame(c("chrA", "chrB"), c(15000000, 10000000)))
 

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(regioneR)
Loading required package: memoise
Loading required package: GenomicRanges
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
    get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
    match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
    rbind, rownames, sapply, setdiff, sort, table, tapply, union,
    unique, unsplit

Loading required package: S4Vectors
Loading required package: stats4

Attaching package: 'S4Vectors'

The following objects are masked from 'package:base':

    colMeans, colSums, expand.grid, rowMeans, rowSums

Loading required package: IRanges
Loading required package: GenomeInfoDb
Loading required package: BSgenome
Loading required package: Biostrings
Loading required package: XVector
Loading required package: rtracklayer
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/regioneR/getGenome.Rd_%03d_medium.png", width=480, height=480)
> ### Name: getGenome
> ### Title: getGenome
> ### Aliases: getGenome
> 
> ### ** Examples
> 
> getGenome("hg19")
GRanges object with 93 ranges and 0 metadata columns:
             seqnames         ranges strand
                <Rle>      <IRanges>  <Rle>
   [1]           chr1 [1, 249250621]      *
   [2]           chr2 [1, 243199373]      *
   [3]           chr3 [1, 198022430]      *
   [4]           chr4 [1, 191154276]      *
   [5]           chr5 [1, 180915260]      *
   ...            ...            ...    ...
  [89] chrUn_gl000245     [1, 36651]      *
  [90] chrUn_gl000246     [1, 38154]      *
  [91] chrUn_gl000247     [1, 36422]      *
  [92] chrUn_gl000248     [1, 39786]      *
  [93] chrUn_gl000249     [1, 38502]      *
  -------
  seqinfo: 93 sequences from an unspecified genome; no seqlengths
> 
> getGenome(data.frame(c("chrA", "chrB"), c(15000000, 10000000)))
GRanges object with 2 ranges and 0 metadata columns:
      seqnames        ranges strand
         <Rle>     <IRanges>  <Rle>
  [1]     chrA [1, 15000000]      *
  [2]     chrB [1, 10000000]      *
  -------
  seqinfo: 2 sequences from an unspecified genome; no seqlengths
>  
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>