Question: Calculating FPKM after htseq-count
1
19 months ago by
Fill70
Fill70 wrote:

I just want to make it clear.

I need to calculate FPKM. I use this formula: Normalized = [(raw_read_count)(10^9)] / [(gene_length)(XXXX)],

XXXX = the count of all reads that are aligned to protein-coding genes in that alignment.

How should I calculate XXXX? Is it just sum of all raw_read_counts after htseq-count (e.g. in R it will be XXXX <- sum(collumn_with_raw_red_counts)?

Thanks!

rna-seq fpkm htseq • 5.1k views
ADD COMMENTlink
modified 19 months ago • written 19 months ago by Fill70

It's "fragments per kilobase transcript per million reads", so you should divide by million, not multiply.

That said, are you sure FPKMs is something you need? I don't know your application, but for many purposes, there are better normalisation methods.

ADD REPLYlink written 19 months ago by WouterDeCoster32k
1

$formula$ This is formula with effective length, you can see why I multiply by 10^9, not devide.

I am trying to duplicate the results on GDC data portal.

ADD REPLYlink modified 19 months ago • written 19 months ago by Fill70

Ugh, you're totally right. Shame on me!

ADD REPLYlink written 19 months ago by WouterDeCoster32k

Can you clarify `duplicate` part? Unless you are using the exact versions of software/genome build that may not be realistically possible.

ADD REPLYlink written 19 months ago by genomax55k

I am using exact versions software and genome like TCGA. And everything is good (I mean results from TCGA and my results after mRNA pipeline are identic. Except for N value for calculating FPKM (the count of all reads that are aligned to protein-coding genes in that alignment)

ADD REPLYlink written 19 months ago by Fill70

Is it possible that for paired end reads (fragments) they divided total reads by 2 ? (I know it is silly to think like that but can you match your numbers divided by two with TCGA total library sizes)

OR

While calculating FPKM (raw_reads/2) per gene.

ADD REPLYlink modified 19 months ago • written 19 months ago by EagleEye5.6k

Thanks for your guess, but it doesn't work that way. My N values differs by 0.03x - 0.08x (x = TCGA N values).

ADD REPLYlink modified 19 months ago • written 19 months ago by Fill70

Aligners may produce non-deterministic output (unless they are able to accept a seed). Perhaps that is what is causing this difference.

ADD REPLYlink written 19 months ago by genomax55k
6
19 months ago by
Fill70
Fill70 wrote:

I've got answer from GDC portal:

1. Download GTF files used in HTSeq analyses: https://gdc.cancer.gov/about-data/data-harmonization-and-generation/gdc-reference-files (GDC.h38 GENCODE v22 GTF)
2. Extract only protein-coding gene IDs: less gencode.v22.annotation.gtf | grep "\tgene\t" | grep protein_coding | cut -f9 | cut -f2 -d '"' > EnsembleIDsPCG.txt
3. Use resulting list to extract only protein-coding values from counts file: less CountFile.txt | grep -Ff ProteinCodingGeneList.txt > CountOnlyProt.txt
4. Sum the values of "CountOnlyProt.txt" and that will give you your denominator value.

My problem was that I counted reads for all genes, but should only for protein-coding.

P.S. thanks to GDC support team!

ADD COMMENTlink modified 19 months ago • written 19 months ago by Fill70

Hi, I have stumbled upon your post trying to find out why I am not able to obtain the FPKM values provided by the GDC using the same raw count data. After following these steps it does not get any better. Just to be sure, you took the counts from the HTSeq files and the gene lengths from the GDC.h38 GENCODE v22 GTF, right? As for the N in the denominator, as explained above, it should be the sum of all protein coding genes...

ADD REPLYlink written 11 months ago by CuriousGuy20

You're right. Sum of all reads which align protein-coding genes. Gene lengths and counts are for all genes.

ADD REPLYlink written 9 months ago by Fill70
0
19 months ago by
EagleEye5.6k
Sweden
EagleEye5.6k wrote:

Try this solution,

PERL solution:

https://github.com/santhilalsubhash/rpkm_rnaseq_count

R solution:

A: How to normalise read count per gene

ADD COMMENTlink modified 19 months ago • written 19 months ago by EagleEye5.6k

Thanks, but the question is about how to get Total count of all reads. Is it just sum of all counts? I ask it because I am trying to duplicate the results on GDC data portal and I can't do it because their Total count of all reads smaller than mine (which I calculate by sum())

ADD REPLYlink written 19 months ago by Fill70

Yes. Sum of all counts from individual samples (library size).

ADD REPLYlink written 19 months ago by EagleEye5.6k
Please log in to add an answer.

Content
Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1042 users visited in the last hour