| makeIRangesFromDataFrame {IRanges} | R Documentation |
Make a IRanges object from a data.frame or DataFrame
Description
makeIRangesFromDataFrame takes a data-frame-like object as input
and try to automatically find the columns that describe integer ranges.
If successful, it returns them in an object.
The function is also the workhorse behind the coercion method from data.frame (or DataFrame) to IRanges.
Usage
makeIRangesFromDataFrame(df, keep.extra.columns=FALSE,
start.field="start",
end.field=c("end", "stop"),
starts.in.df.are.0based=FALSE,
na.rm=FALSE)
Arguments
df |
A data.frame or DataFrame object. If not, then
the function first tries to turn |
keep.extra.columns |
Note that if |
start.field |
A character vector of recognized names for the column in |
end.field |
A character vector of recognized names for the column in |
starts.in.df.are.0based |
|
na.rm |
If |
Value
An IRanges object.
If na.rm is set to FALSE (the default), then the
returned object is guaranteed to have one element per row in the input.
However, if na.rm is set to TRUE, then the length of the
returned object can be less than nrow(df).
If df has non-automatic row names (i.e. rownames(df) is
not NULL and is not seq_len(nrow(df))), then they will be
used to set names on the returned IRanges object.
Note
Coercing a data.frame or DataFrame df
to IRanges (with as(df, "IRanges")), or calling
IRanges(df), are both equivalent to calling
makeIRangesFromDataFrame(df, keep.extra.columns=TRUE).
Author(s)
H. Pagès
See Also
-
makeGRangesFromDataFramein the GenomicRanges package to make a GRanges object from a data.frame or DataFrame. -
IRanges objects.
-
DataFrame objects in the S4Vectors package.
Examples
df <- data.frame(ID=letters[1:5],
locus_stART=11:15,
locus_STop=12:16,
score=1:5)
## makeIRangesFromDataFrame() tries hard to figure out what columns
## to use for the start and end values of the ranges.
makeIRangesFromDataFrame(df)
makeIRangesFromDataFrame(df, keep.extra.columns=TRUE)
as(df, "IRanges") # equivalent to the above