I want to calculate the total length of genes (including introns) from the start codon to the stop codon. I have loaded a GFF file into R using the GenomicFeatures package. Using genes(txdb) I get the output below that shows the positions of the first nucleotide of the start codon and the last nucleotide of the stop codon. Is there a function in GenomicFeatures that will give the gene size/length using this information? Or is there a way to get the absolute value of subtracting the last from the first nucleotide?
> genes(txdb)
GRanges object with 3 ranges and 1 metadata column:
seqnames ranges strand | gene_id
<Rle> <IRanges> <Rle> | <character>
CG32006-RA Chr4 [1703212, 1705370] + | CG32006-RA
CG33978-RE Chr4 [1640671, 1653615] + | CG33978-RE
mav-RA Chr4 [1708086, 1710381] - | mav-RA
-------
seqinfo: 1 sequence from an unspecified genome; no seqlengths
Looks good. Thank you!