Skip to content

Calculate Intron Positions Based on Exons ​

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 ​

r
get_introns(data)

Arguments ​

ArgumentDescription
dataA 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. An intron has the values of the columns that are the same for all exons and UTRs of its transcript (e.g. its gene or group), and NA in the columns that differ between them (e.g. the name of an exon).

Examples ​

r
exons <- data.frame(
  transcript = "tx1",
  type = "exon",
  start = c(100, 400, 900),
  end = c(250, 600, 1100),
  strand = "forward"
)
get_introns(exons)