R/to_data_frame.R

Defines functions to_data_frame

Documented in to_data_frame

#' Convert bedtools object to dataframe
#' @param obj A bedtools object that points to a file, and should have been generated by the bedtools command
#' @return  A data.frame
#' @export
to_data_frame <- function(obj){
    if(!is.bt_obj(obj)) stop('Can only convert an object to a data frame')
    location <- unclass(obj)
    df <-  suppressMessages(suppressWarnings(fread(file = location, header = F, sep = '\t')))
    if(nrow(df) != 0){ colnames(df) <- paste0('X', 1:ncol(df))}
    return(df)

}
vinay-swamy/RBedtools documentation built on Feb. 19, 2020, 5:15 p.m.