Learn R Programming

humarray (version 1.2)

ranged.to.data.frame: Convert RangedData/GRanges to a data.frame

Description

Convert a RangedData/GRanges object to a data.frame with columns chr, start and end. Default is to only translate the chromosome and position information, which is faster. Using 'include.cols'=TRUE allows all the columns from 'ranged' to be taken across to the resulting data.frame.

Usage

ranged.to.data.frame(ranged, include.cols = FALSE, use.names = TRUE)

Arguments

ranged

A RangedData or GRanges object

include.cols

logical, whether to also bring across non-positional columns to the resulting data.frame

use.names

logical, whether to keep the rownames from the original object for the output. Only has an effect when include.cols=FALSE, otherwise original rownames are always kept.

Value

A data.frame with columns chr, start and end, and depending on chosen parameters, the same rownames as the input, and optionally the same additional columns.

See Also

df.to.ranged, df.to.GRanges

Examples

Run this code
# NOT RUN {
rd <- rranges(9,GRanges=FALSE, fakeids=TRUE)
rd[["fakecol"]] <- sample(nrow(rd))
rd[["rs.id"]] <- paste0("rs",sample(10000,9))
ranged.to.data.frame(rd)
ranged.to.data.frame(rd,,FALSE)
ranged.to.data.frame(rd,TRUE) # keep all the columns
df.to.GRanges(ranged.to.data.frame(rd,TRUE)) # inverse returns original
# }

Run the code above in your browser using DataLab