GenomicData: Data on a Genome

Description Accessors Constructor Author(s) Examples

View source: R/ranges.R

Description

The rtracklayer package adds convenience methods on top of GenomicRanges and IntegerRangesList to manipulate data on genomic ranges.

Accessors

In the code snippets below, x is a GenomicRanges or IntegerRangesList object.

chrom(x), chrom(x) <- value: Gets or sets the chromosome names for x. The length of value should equal the length of x.

score(x): Gets the “score” column from the element metadata of a GenomicRanges or GRangesList. Many track formats have a score column, so this is often used during export. The ANY fallback for this method simply returns NULL.

Constructor

GenomicData(ranges, ..., strand = NULL, chrom = NULL, genome = NULL): Constructs a GRanges instance with the given ranges and variables in ... (see the GRanges constructor).

If non-NULL, the strand argument specifies the strand of each range. It should be a character vector or factor of length equal to that of ranges. All values should be either -, +, or *. To get the levels for strand, call levels(strand()).

chrom argument is analogous to seqnames in the GRanges constructor.

The genome argument should be a scalar string. See the examples.

Author(s)

Michael Lawrence and Patrick Aboyoun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
  range1 <- IRanges(c(1,2,3), c(5,2,8))

  ## with some data ##
  filter <- c(1L, 0L, 1L)
  score <- c(10L, 2L, NA)
  strand <- factor(c("+", NA, "-"), levels = levels(strand()))
  ## GRanges instance
  gr <- GenomicData(range1, score, chrom = "chr1", genome = "hg18")
  mcols(gr)[["score"]]
  strand(gr) ## all '*'
  gr <- GenomicData(range1, score, filt = filter, strand = strand,
                    chrom = "chr1")
  mcols(gr)[["filt"]]
  strand(gr) ## equal to 'strand'
  ## coercion from data.frame ##
  df <- as.data.frame(gr)

rtracklayer documentation built on Nov. 8, 2020, 6:50 p.m.