extend_gtf: Extend GTF file with predicted exons

Description Usage Arguments Details Value Examples

View source: R/extend_gtf.R

Description

Add predicted novel exons to the correct transcripts in a GTF annotation.

Usage

1
extend_gtf(gtf, pred, cores = 1)

Arguments

gtf

GTF annotations, either the path to the GTF file as a character string or a GRanges object.

pred

data.frame with predicted novel exons as returned by find_novel_exons().

cores

Integer scalar. Number of cores to use. Default 1.

Details

For each novel exon in pred (as returned by find_novel_exons()), the list of transcripts that contain its up- and/or downstream exons is determined. A random exon from each transcript is copied and the start and end coordinates are exchanged with those of the novel exon. The exon_number and exon_version are set to NA. The new exon_id, transcript_id and transcript_name are the original values with a suffix that identifies the novel exon by its ID: e.g. exon_id_ID or transcript_name_ID.

Value

GRanges object with annotations from the GTF file and extended with the novel xons.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
gtf <- system.file("extdata", "selected.gtf", package = "DISCERNS",
                   mustWork = TRUE)

## Here we artificially create a data.frame with predicted exons.
## In general, the novel exons will be predicted with the function
## find_novel_exons()
novel_exons <- data.frame(seqnames = c("19", "22"),
                          start = c(47228064,41737092),
                          end = c(47228185, 41737150), strand = c("-", "+"),
                          lend = c(47226541, 41736141),
                          rstart = c(47228589, 41738533), ID = c(1, 2))

## add the predicted exons to the GTF file
new_gtf <- extend_gtf(gtf, novel_exons)

## save the new GTF to file with the export() function from rtracklayer
library(rtracklayer)
export(object = new_gtf, con = "extended_annotation.gtf")

khembach/DISCERNS documentation built on June 23, 2020, 3:35 p.m.