Make a GRangesList object from a data.frame or DataFrame
makeGRangesListFromDataFrame
extends the
makeGRangesFromDataFrame functionality from
GenomicRanges
. It can take a data-frame-like object as input
and tries to automatically find the columns that describe the genomic
ranges. It returns a GRangesList object. This is different from the
makeGRangesFromDataFrame
function by requiring a
split.field
. The split.field
acts like the
"f" argument in the split
function. This factor
must be of the same length as the number of rows in the DataFrame
argument. The split.field
may also be a character vector.
makeGRangesListFromDataFrame(df, split.field = NULL, names.field = NULL, ...)
df |
A |
split.field |
A character string of a recognized column name in |
names.field |
An optional single |
... |
Additional arguments passed on to makeGRangesFromDataFrame |
A GRangesList of the same length as the number of levels or
unique character strings in the df
column indicated by
split.field
. When split.field
is not provided the df
is split by row and the resulting GRangesList has the
same length as nrow(df).
Names on the individual ranges are taken from the names.field
argument. Names on the outer list elements of the GRangesList
are propagated from split.field
.
M. Ramos
## --------------------------------------------------------------------- ## BASIC EXAMPLES ## --------------------------------------------------------------------- df <- data.frame(chr="chr1", start=11:15, end=12:16, strand=c("+","-","+","*","."), score=1:5, specimen = c("a", "a", "b", "b", "c"), gene_symbols = paste0("GENE", letters[1:5])) df grl <- makeGRangesListFromDataFrame(df, split.field = "specimen", names.field = "gene_symbols") grl names(grl) ## Keep metadata columns makeGRangesListFromDataFrame(df, split.field = "specimen", keep.extra.columns = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.