to_intron: Convert exon co-ordinates to introns

View source: R/to_intron.R

to_intronR Documentation

Convert exon co-ordinates to introns

Description

Given a set of exons, to_intron() will return the corresponding introns.

Usage

to_intron(exons, group_var = NULL)

Arguments

exons

data.frame() contains exons which can originate from multiple transcripts differentiated by group_var.

group_var

character() if input data originates from more than 1 transcript, group_var must specify the column that differentiates transcripts (e.g. "transcript_id").

Details

It is important to note that, for visualization purposes, to_intron() defines introns precisely as the exon boundaries, rather than the intron start/end being (exon end + 1)/(exon start - 1).

Value

data.frame() contains the intron co-ordinates.

Examples

library(magrittr)
library(ggplot2)

# to illustrate the package's functionality
# ggtranscript includes example transcript annotation
sod1_annotation %>% head()

# extract exons
sod1_exons <- sod1_annotation %>% dplyr::filter(type == "exon")
sod1_exons %>% head()

# to_intron() is a helper function included in ggtranscript
# which is useful for converting exon co-ordinates to introns
sod1_introns <- sod1_exons %>% to_intron(group_var = "transcript_name")
sod1_introns %>% head()

# this can be particular useful when combined with
# geom_range() and geom_intron()
# to visualize the core components of transcript annotation
sod1_exons %>%
    ggplot(aes(
        xstart = start,
        xend = end,
        y = transcript_name
    )) +
    geom_range() +
    geom_intron(
        data = to_intron(sod1_exons, "transcript_name")
    )

dzhang32/ggtranscript documentation built on Aug. 29, 2024, 2:43 a.m.