#' @title Extract elements on the plus strand from a gtf file.
#'
#' @description This function takes a gtf file from GENCODE or a dataframe of extracted introns. It returns as a dataframe a specified element; i.e gene, transcript, exon or intron; that are on the reverse strand
#' @usage extract_plus(data1, type)
#' @param data1 The name of the downloaded gtf file from GENCODE website
#' @param type A string that specifies the type of element to be reported
#' @export
#' @keywords
#' @seealso
#' @return A dataframe of elements on the plus strand
#' examples \dontrun {
#' # You don't have to run this
#' load_gtf("gencode.v27.lncRNAs.gtf")
#' data1 <- gencode.v27.lncRNAs.gtf
#' extract_plus(data1, "gene")
#' extract_plus(data1, "transcript")
#' extract_plus(data1, "exon")
#' extract_plus(data1, "intron")
#’}
extract_plus <- function(data1, type) {
if (type=="gene") {
a <- subset(data1, data1$type=="gene")
b <- subset(a, a$strand=="+")
c <- nrow(b)
print(c)
assign(deparse(substitute(genes_plus)), b, envir = .GlobalEnv)
} else if (type=="transcript") {
a <- subset(data1, data1$type=="transcript")
b <- subset(a, a$strand=="+")
c <- nrow(b)
print(c)
assign(deparse(substitute(transcripts_plus)), b, envir = .GlobalEnv)
} else if (type=="exon") {
a <- subset(data1, data1$type=="exon")
b <- subset(a, a$strand=="+")
c <- nrow(b)
print(c)
assign(deparse(substitute(exons_plus)), b, envir = .GlobalEnv)
} else if (type=="intron") {
a <- subset(data1, data1$type=="intron")
b <- subset(a, a$strand=="+")
c <- nrow(b)
print(c)
assign(deparse(substitute(introns_plus)), b, envir = .GlobalEnv)
} else {
print("Error: operation could not be performed - check the help page for examples")
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.