R/to_VRanges.R

Defines functions to_vranges

Documented in to_vranges

#' Convert to \code{VRanges}
#'
#' @param sumstats_dt data table obj of the summary statistics 
#' file for the GWAS.
#' @return \code{VRanges} object
#' @keywords internal
#' @importFrom GenomicRanges makeGRangesFromDataFrame
#' @importFrom VariantAnnotation makeVRangesFromGRanges
to_vranges <- function(sumstats_dt) {
    gr <- to_granges(sumstats_dt)
    message("Converting summary statistics to VRanges.")
    gr$dummy <- "GWAS"
    vr <- VariantAnnotation::makeVRangesFromGRanges(gr,
                                                    ref.field = "A1", 
                                                    alt.field = "A2",
                                                    keep.extra.columns = TRUE,
                                                    sampleNames.field = "dummy"
    )
    return(vr)
}
neurogenomics/MungeSumstats documentation built on Aug. 10, 2024, 5:59 a.m.