2
$\begingroup$

I have RNA-Seq data which is FPKM. In the dataframe df first column is gene_name and the other 100 columns are samples.

Usually if it is counts data I do like following:

df2 <- aggregate(. ~ gene_name, data = df, max)

I'm not sure what do with the FPKM data if there are duplicate genes with different FPKM value for the same sample.

Lets say it looks like this:

gene_name     sample1        sample2        sample3
5S_rRNA      0.3206147    0.3327312      0.377578
5S_rRNA      0.3342000    0.0000000      0.1305166

Any suggestions please.

$\endgroup$
  • $\begingroup$ How were the read mapped? Do you have access to the raw counts data? $\endgroup$ – llrs Oct 25 '18 at 9:16
  • 1
    $\begingroup$ I have downloaded TCGA FPKM data. Would like to use the data for co-expression analysis with cemitool $\endgroup$ – beginner Oct 25 '18 at 9:57
5
$\begingroup$

I assume you're familiar with the various issues surrounding FPKMs, so I'll not expound upon them.

As a general rule, you should be using gene IDs rather than gene names, since the former are unique while the latter are not. If you only have access to data quantified on gene names, then the appropriate way to merge RPKMs is with a weighted sum:

$FPKM_{gene} = \frac{FPKM_{copy1} * Length_{copy1} + FPKM_{copy2} * Length_{copy2}}{Length_{copy1} + Length_{copy2}}$

As an aside, rRNA expression levels will tend to be wrong, since they're normally excluded by either poly-A enrichment or the use of ribo-zero.

$\endgroup$
  • $\begingroup$ Sure I will use gene ids. but lets say I have counts data and before doing differential analysis do you think this is the right to way to filter duplicates; aggregate(. ~ gene_name, data = df, max) $\endgroup$ – beginner Oct 25 '18 at 15:09
  • $\begingroup$ If you have counts then sum them. $\endgroup$ – Devon Ryan Oct 25 '18 at 17:07
  • $\begingroup$ So, if the first column is Ensembl ids and all other columns are samples in a dataframe "df", Is this right way to sum the duplicate Ensembl ids? aggregate(. ~Ensembl_ids, data=df, FUN=sum) $\endgroup$ – beginner Oct 25 '18 at 18:17
  • 2
    $\begingroup$ There should never be duplicate Ensembl IDs, they're unique. You only have issues like this with gene names or UCSC IDs. $\endgroup$ – Devon Ryan Oct 25 '18 at 21:24
  • $\begingroup$ oh yes, so with gene names Is this the way to sum the counts of duplicates aggregate(. ~gene_names, data=df, FUN=sum) $\endgroup$ – beginner Oct 25 '18 at 21:29
3
$\begingroup$

The best way to deal with this is to use unique gene IDs, for example ensembl accession numbers. So use the ensemble gtf annotation when quantifying the read counts and not the gene symbols. Just to illustrate, when I look for "5S_rRNA" in ensembl's annotation, i see 18 different "genes" with that gene symbol. But which 2 you have is unclear now.

grep "5S_rRNA" ensembl_symbol.txt
"ENSG00000252830"       "5S_rRNA"
"ENSG00000276442"       "5S_rRNA"
"ENSG00000274408"       "5S_rRNA"
"ENSG00000274059"       "5S_rRNA"
"ENSG00000276861"       "5S_rRNA"
"ENSG00000274759"       "5S_rRNA"
"ENSG00000280646"       "5S_rRNA"
"ENSG00000277411"       "5S_rRNA"
"ENSG00000201285"       "5S_rRNA"
"ENSG00000212595"       "5S_rRNA"
"ENSG00000277418"       "5S_rRNA"
"ENSG00000277049"       "5S_rRNA"
"ENSG00000274097"       "5S_rRNA"
"ENSG00000277488"       "5S_rRNA"
"ENSG00000274663"       "5S_rRNA"
"ENSG00000283433"       "5S_rRNA"
"ENSG00000275305"       "5S_rRNA"
"ENSG00000278457"       "5S_rRNA"
$\endgroup$
  • $\begingroup$ Yes you are right. But can I take median of those duplicates? something like aggregate(. ~ gene_name, data = df, median) $\endgroup$ – beginner Oct 25 '18 at 9:57
  • $\begingroup$ Expanding this answer, it seems that it was mapped to ensembl ids. So I would recommend to keep them as they are, and only when looking for biological meaning to change to gene symbols (or when talking to others) $\endgroup$ – llrs Oct 25 '18 at 10:03
  • 1
    $\begingroup$ I would strongly advice not to use FPKM at all, it is pretty clear now that they are not the right values to use for any analysis. If you still want to use it, keep your two genes apart like they were. $\endgroup$ – benn Oct 25 '18 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.