AnnotatedList-class {IRanges} | R Documentation

## Annotated Lists

### Description

The class `AnnotatedList` extends `TypedList` to contain two optional metadata elements: a list with arbitrary annotations, and a data frame with local metadata on each element.

### Details

Data analysis should not occur in a vacuum: every dataset floats in a sea of metadata, describing the observed features, as well as the experimental design and methodology. Some metadata is local to an experiment, such as its design, while other information, such as the layout of a microarray chip, transcends individual experiments.

The list structure is fundamental to computationally representing datasets. For example, the `data.frame` is a list of column vectors. The `AnnotatedList` is a list that additionally aims to store local metadata and reference global annotation resources.

This is implemented by adding two optional components on top of the underlying `TypedList`:

metadata
  A list, possibly empty, containing arbitrary annotations. For example, the name of the genome might be stored in a character vector as an element named "genome".
elementMetadata
  A data frame of class `XDataFrame` (or `NULL`) with a row for each element and a column for each metadata variable. This is for storing metadata local to the experiment, such as experimental design, or chromosome-wide statistics for datasets of genomic features.

### Accessors

In the following code snippets, `x` is a `TypedList` object.

  `metadata(x)`, `metadata(x) <- value`: Get or set the list holding arbitary R objects as annotations. May be, and often is, empty.
  `elementMetadata(x), elementMetadata(x) <- value`: Get or set the `XDataFrame` holding local metadata on each element. The rows are named according to the names of the elements. Optional, may be `NULL`.

### Constructor

  `AnnotatedList(elements = list(), metadata = NULL, elementMetadata = NULL)`: Constructs an instance of an `AnnotatedList` containing the elements in the ordinary list `elements`. The parameters `metadata` and `elementMetadata` correspond to the components described above.

### Author(s)

Michael Lawrence

### See Also

`RangesList` and `XDataFrame` both extend this class.

### Examples

      ## demonstrated on RangesList objects, a subtype of AnnotatedList

      range1 <- IRanges(start=c(1,2,3), end=c(5,2,8))
      range2 <- IRanges(start=c(15,45,20,1), end=c(15,100,80,5))
      collection <- RangesList(range1, range2)

      ## access 'metadata' component
      metadata(collection)$genome <- "hg18"
      metadata(collection)

      ## set some element metadata
      elementMetadata(collection) <- XDataFrame(chrom = c("chr1", "chr2"))
      elementMetadata(collection)

[Package IRanges version 1.2.3 Index]