Skip to contents

This function takes a dataset containing transcript information and calculates the start and end positions of introns based on the positions of exons. It generates a combined dataframe including both the original exons and the calculated introns. Overlapping, nested, and adjacent exon/UTR intervals are treated as a continuous covered region; only positive gaps become introns.

Usage

get_introns(data)

Arguments

data

A dataframe containing start and end positions of transcripts. Optional columns are type (exon or UTR), transcript (containing unique transcript IDs), and strand (indicating the direction, forward or reverse, of each transcript).

Value

A dataframe with the original exons and the calculated introns, sorted by transcript and start position. Each row includes the start, end, type (exon, UTR or intron), transcript, and strand for each segment.

Examples

exons <- data.frame(
  transcript = "tx1",
  type = "exon",
  start = c(100, 400, 900),
  end = c(250, 600, 1100),
  strand = "forward"
)
get_introns(exons)
#>   transcript   type start  end  strand
#> 1        tx1   exon   100  250 forward
#> 2        tx1 intron   251  399 forward
#> 3        tx1   exon   400  600 forward
#> 4        tx1 intron   601  899 forward
#> 5        tx1   exon   900 1100 forward