#' @title Calculate the length of splices transcripts
#'
#' @description This function takes a dataframe of annotations provided by Gencode as input. It calculates the length of the transcripts considering only the length of their corresponding exons.
#' @usage spliced_trans_length(x)
#' @param x The name of the downloaded gtf file from GENCODE website
#' @export
#' @keywords
#' @seealso
#' @return A dataframe of the transcript ids and their length when spliced
#' examples \dontrun {
#' # You don't have to run this
#' load_gtf("gencode.v27.lncRNAs.gtf")
#' spliced_trans_length(gencode.v27.lncRNAs.gtf)
#’}
spliced_trans_length <- function(x) {
a <- subset(x, x$type=="exon")
b <- subset(a, select = c("transcript_id", "width"))
c <- data.table::setkey(data.table::setDT(b), transcript_id)[, list(width=sum(width)), by=list(transcript_id)]
assign(deparse(substitute(SplicedTranscriptsLength)), c, envir = .GlobalEnv)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.