-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All inputs and outputs of exported functions are Ranges objects now.
- Loading branch information
1 parent
6d9ea5d
commit 94b397f
Showing
34 changed files
with
641 additions
and
786 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#' @title Convert data.table to GRanges object | ||
#' | ||
#' @description Convert \code{gtf}, \code{gff}, \code{bed}, \code{bam} | ||
#' or a valid \code{data.table} to a GRanges object. | ||
#' | ||
#' @param x An object of class \code{gtf}, \code{gff}, \code{bed} or | ||
#' \code{bam} or a valid \code{data.table} object. | ||
#' @param ignore_strand Logical argument to pass to \code{GRanges} function. | ||
#' Indicates whether \code{strand} should be ignored when constructing | ||
#' \code{GRanges} object or not. Default is \code{FALSE}. | ||
#' @return A \code{GRanges} object. | ||
#' @aliases as_granges | ||
#' @examples | ||
#' path <- system.file("tests", package="gread") | ||
#' gff_file <- file.path(path, "sample.gff") | ||
#' gtf_file <- file.path(path, "sample.gtf") | ||
#' bed_file <- file.path(path, "sample.bed") | ||
#' bam_file <- file.path(path, "sample.bam") | ||
#' | ||
#' gff <- read_format(gff_file) | ||
#' gtf <- read_format(gtf_file) | ||
#' bed <- read_format(bed_file) | ||
#' bam <- read_format(bam_file) | ||
#' | ||
#' as_granges(gff) | ||
#' as_granges(gtf) | ||
#' as_granges(bed) | ||
#' as_granges(bam) | ||
#' | ||
#' as_granges(gff, ignore_strand=FALSE) | ||
#' as_granges(gtf, ignore_strand=FALSE) | ||
#' as_granges(bed, ignore_strand=FALSE) | ||
#' as_granges(bam, ignore_strand=FALSE) | ||
#' @seealso \code{\link{read_format}} \code{\link{extract}} | ||
#' \code{\link{construct_introns}} | ||
as_granges <- function(x, ignore_strand=FALSE) { | ||
|
||
stopifnot(is.gtf(x)||is.gff(x)||is.bed(x)||is.bam(x)||is.data.table(x)) | ||
x = shallow(x) | ||
if (ignore_strand) x[, "strand" := NULL] | ||
as(setDF(x), "GRanges") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.