gene length for calculating TPM values
3
3
Entering edit mode
3.7 years ago
DNA2RNA ▴ 130

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
RNA-Seq sequencing TPM genome • 8.6k views
ADD COMMENT
10
Entering edit mode
3.7 years ago
DNA2RNA ▴ 130

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))))
ADD COMMENT
2
Entering edit mode

Attention to function name :

makeTxDbFromGFF

and not

makeTranscriptDbFromGFF

for version 1.40 and older of GenomicFeatures,at least.

ADD REPLY
1
Entering edit mode

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?

ADD REPLY
5
Entering edit mode
3.7 years ago
Ram 43k

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.

ADD COMMENT
2
Entering edit mode
3.7 years ago
geneticatt ▴ 140

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.

ADD COMMENT

Login before adding your answer.

Traffic: 2540 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6