That's the sum of all the exons for that genes in your gtf. What if in your sample, all the reads are coming from a transcript which is half that length?
I want to convert count to TPM similar to this post Calculating TPM Values . However my question is can we use the width column from the GTF file as gene length for TPM calculation?
library("GenomicFeatures")
gtf_txdb <- makeTxDbFromGFF("gencode.v33.annotation.gtf.gz")
gene_list <- genes(gtf_txdb)
gene_list <- as.data.frame(gene_list)
gene_list[1:3, 1:4]
seqnames start end width
ENSG00000000003.15 chrX 100627108 100639991 12884
ENSG00000000005.6 chrX 100584936 100599885 14950
ENSG00000000419.12 chr20 50934867 50958555 23689
3 answers
For future reference the answere is at Extract Total Non-Overlapping Exon Length Per Gene With Bioconductor
library(GenomicFeatures)
txdb <- makeTranscriptDbFromGFF("yourFile.gtf",format="gtf")
exons.list.per.gene <- exonsBy(txdb,by="gene")
exonic.gene.sizes <- as.data.frame(sum(width(reduce(exons.list.per.gene))))
Attention to function name :
makeTxDbFromGFF
and not
makeTranscriptDbFromGFF
for version 1.40 and older of GenomicFeatures,at least.
The width is calculated in IRanges as start-end, which gives you the whole length of the gene. I think TPM would depend on total CDS/exon length, not total gene length - intron lengths should not be accounted for. After all, transcripts don't have introns.
Here the width column includes any existing introns, so you can't use the width from this particular table to calculate TPM. The gencode.v33.annotation.gtf likely has the intron ranges, which you can use for your calculation.
Log in to answer this question.