RangesList-class {IRanges} | R Documentation |
An extension of List that holds only
Ranges objects. Useful for storing ranges over a set
of spaces (e.g. chromosomes), each of which requires a separate
Ranges
object. As a Vector
, RangesList
may be
annotated with its universe identifier (e.g. a genome) in which all of its
spaces exist.
In the code snippets below, x
is a RangesList
object.
All of these accessors collapse over the spaces:
start(x), start(x) <- value
: Get or set the starts of the
ranges. When setting the starts, value
can be an integer vector
of length(sum(elementLengths(x)))
or an IntegerList object of
length length(x)
and names names(x)
.
end(x), end(x) <- value
: Get or set the ends of the
ranges. When setting the starts, value
can be an integer vector
of length(sum(elementLengths(x)))
or an IntegerList object of
length length(x)
and names names(x)
.
width(x), width(x) <- value
: Get or set the widths of the
ranges. When setting the starts, value
can be an integer vector
of length(sum(elementLengths(x)))
or an IntegerList object of
length length(x)
and names names(x)
.
space(x)
: Gets the spaces of the ranges as a
character vector. This is equivalent to names(x)
, except each
name is repeated according to the length of its element.
These accessors are for the universe
identifier:
universe(x)
: gets the name of the universe as a
single string, if one has been specified, NULL
otherwise.
universe(x) <- value
: sets the name of the universe
to value
, a single string or NULL
.
RangesList(..., universe = NULL)
:
Each Ranges
in ...
becomes an element in the new RangesList
, in the same
order. This is analogous to the list
constructor,
except every argument in ...
must be derived from
Ranges
. The universe is specified by the universe
parameter, which should be a single string or NULL, to leave unspecified.
In the code snippets below, x
and from
are a
RangesList
object.
as.data.frame(x, row.names = NULL, optional = FALSE,
..., value.name = "value", use.outer.mcols = FALSE,
group_name.as.factor = FALSE)
:
Coerces x
to a data.frame
. See as.data.frame on the
List
man page for details (?List
).
as(from, "SimpleIRangesList")
: Coerces from
,
to a SimpleIRangesList
, requiring
that all Ranges
elements are coerced to internal
IRanges
elements. This is a convenient way to ensure that all
Ranges
have been imported into R (and that there is no
unwanted overhead when accessing them).
as(from, "CompressedIRangesList")
: Coerces from
,
to a CompressedIRangesList
, requiring
that all Ranges
elements are coerced to internal
IRanges
elements. This is a convenient way to ensure that all
Ranges
have been imported into R (and that there is no
unwanted overhead when accessing them).
as(from, "SimpleNormalIRangesList")
: Coerces from
,
to a SimpleNormalIRangesList
, requiring
that all Ranges
elements are coerced to internal
NormalIRanges
elements.
as(from, "CompressedNormalIRangesList")
: Coerces
from
, to a CompressedNormalIRangesList
,
requiring that all Ranges
elements are coerced to internal
NormalIRanges
elements.
Any arithmetic operation, such as x + y
, x * y
, etc,
where x
is a RangesList
, is performed identically on each
element. Currently, Ranges
supports only the *
operator,
which zooms the ranges by a numeric factor.
Michael Lawrence
List
, the parent of this class, for more
functionality.
## --------------------------------------------------------------------- ## Basic manipulation ## --------------------------------------------------------------------- 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)) named <- RangesList(one = range1, two = range2) length(named) # 2 start(named) # same as start(c(range1, range2)) names(named) # "one" and "two" named[[1]] # range1 unnamed <- RangesList(range1, range2) names(unnamed) # NULL # edit the width of the ranges in the list edited <- named width(edited) <- rep(c(3,2), elementLengths(named)) edited # same as list(range1, range2) as.list(RangesList(range1, range2)) # coerce to data.frame as.data.frame(named) # set the universe universe(named) <- "hg18" universe(named) RangesList(range1, range2, universe = "hg18") ## zoom in 2X collection <- RangesList(one = range1, range2) collection * 2 ## --------------------------------------------------------------------- ## isDisjoint() ## --------------------------------------------------------------------- range3 <- IRanges(start=c(-2, 6, 7), width=c(8, 0, 0)) # with empty ranges collection <- IRangesList(one=range1, range2, range3) isDisjoint(collection)