Answers.Body: <p>The effective length is $\tilde{l}_i = l_i - \mu + 1$ (note the R code at the bottom of Harold's blog post), which in the case of $\mu &lt; l_i$ should be 1. Ideally, you'd use the mean fragment length mapped to the particular feature, rather than a global $\mu$, but that's a lot more work for likely 0 benefit.</p>
  
  <p>Regarding choosing a particular transcript, ideally one would use a method like salmon or kallisto (or RSEM if you have time to kill). Otherwise, your options are (A) choose the major isoform (if it's known in your tissue and condition) or (B) use a "union gene model" (sum the non-redundant exon lengths) or (C) take the median transcript length. None of those three options make much of a difference if you're comparing between samples, though they're all inferior to a salmon/kallisto/etc. metric.</p>
  
  <p>Why are salmon et al. better methods? They don't use arbitrary metrics that will be the same across samples to determine the feature length. Instead, they use expectation maximization (or similarish, since at least salmon doesn't actually use EM) to quantify individual isoform usage. The effective gene length in a sample is then the average of the transcript lengths after weighting for their relative expression (yes, one should remove $\mu$ in there). This can then vary between samples, which is quite useful if you have isoform switching between samples/groups in such a way that methods A-C above would miss (think of cases where the switch is to a smaller transcript with higher coverage over it...resulting in the coverage/length in methods A-C to be tamped down).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-01T21:43:44.207Z
Answers.Text: But `\tilde{l}` is a denominator. Setting it to 1 would dramatically increase the value for short transcripts. This sounds dangerous to me... Also, could you clarify what is the advantage of salmon/kallisto over A/B/C? Thanks.
Answers.UserDisplayName: user172818
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-01T21:45:17.637Z
Answers.Text: Short transcripts do have absurdly high FPKMs, it's one of the useless things about FPKMs. I'll update the question regarding salmon/kallisto/etc.
Answers.UserDisplayName: Devon Ryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-01T20:03:41.287Z
Answers.LastActivityDate: 2017-07-26T16:04:12.083Z
Answers.LastEditDate: 2017-07-26T16:04:12.083Z
Answers.UserDisplayName: Devon Ryan
Answers.Body: <p>For the effective length part please see to Devons answer. I just have a small addition: Kallisto/Salmon/RSEM incorporate all bias estimates into the effective length meaning the effective length not only represent the length bias if you take the values from those tools (given that they were run with the bias algorithms enabled naturally).</p>
  
  <p>With regards to getting gene level estimates you should not choose a specific transcript. Instead you should extract/calculate the RPKM/FPKM/TxPM (transcript per million that Kallisto/Salmon/RSEM outputs) for each transcript and sum them up to get the gene level estimate.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-16T11:01:15.400Z
Answers.LastActivityDate: 2017-06-16T11:01:15.400Z
Answers.UserDisplayName: Kristoffer Vitting-Seerup
Answers.Body: <p>I have a <a href="http://robpatro.com/blog/?p=235" rel="noreferrer">blog post</a> that describes the effective length (as well as these different relative abundance units).  The short explanation is that what people refer to as the "effective length" is actually the <em>expected</em> effective length (i.e., the expectation, in a statistical sense, of the effective length).  The notion of effective length is actually a property of a transcript, fragment pair, and is equal to the number of potential starting locations for a fragment of this length on the given transcript.  If you take the average, over all fragments mapping to a transcript (potentially weighted by the conditional probability of this mapping), this quantity is the expected effective length of the transcript.  This is often approximated as simply $l_i - \mu$, or $l_i - \mu_{l_i}$ --- where $\mu_{l_i}$ is the mean of the <em>conditional</em> fragment length distribution (conditioned on the fragment length being &lt; $l_i$ to account for exactly the issue that you raise).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-18T18:04:09.980Z
Answers.LastActivityDate: 2017-07-26T16:15:39.647Z
Answers.LastEditDate: 2017-07-26T16:15:39.647Z
Answers.UserDisplayName: nomad
Body: <p>According to <a href="https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/" rel="noreferrer">this famous blog post</a>, the effective transcript length is:</p>
  
  <p>$\tilde{l}_i = l_i - \mu$</p>
  
  <p>where $l_i$ is the length of transcript and $\mu$ is the average fragment length. However, typically fragment length is about 300bp. What if when the transcript $l_i$ is smaller than 300? How do you compute the effective length in this case?</p>
  
  <p>A related question: when computing the FPKM of a gene, how to choose a transcript? Do we choose a "canonical" transcript (how?) or combine the signals from all transcripts to a gene-level FPKM?</p>
  
Tags: <rna-seq>
Title: How exactly is "effective length" used in FPKM calculated?
ThreadText: # How exactly is "effective length" used in FPKM calculated?
  
  (Asked by: username_0 on 2017-06-01)
  
  According to [this famous blog post](https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/), the effective transcript length is:
  
  $\tilde{l}\_i = l\_i - \mu$
  
  where $l\_i$ is the length of transcript and $\mu$ is the average fragment length. However, typically fragment length is about 300bp. What if when the transcript $l\_i$ is smaller than 300? How do you compute the effective length in this case?
  
  A related question: when computing the FPKM of a gene, how to choose a transcript? Do we choose a "canonical" transcript (how?) or combine the signals from all transcripts to a gene-level FPKM?
  
  **Tags:** rna-seq
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_3 on 2017-06-18. Score: 12 | Accepted answer
  
  I have a [blog post](http://robpatro.com/blog/?p=235) that describes the effective length (as well as these different relative abundance units). The short explanation is that what people refer to as the "effective length" is actually the *expected* effective length (i.e., the expectation, in a statistical sense, of the effective length). The notion of effective length is actually a property of a transcript, fragment pair, and is equal to the number of potential starting locations for a fragment of this length on the given transcript. If you take the average, over all fragments mapping to a transcript (potentially weighted by the conditional probability of this mapping), this quantity is the expected effective length of the transcript. This is often approximated as simply $l\_i - \mu$, or $l\_i - \mu\_{l\_i}$ --- where $\mu\_{l\_i}$ is the mean of the *conditional* fragment length distribution (conditioned on the fragment length being < $l\_i$ to account for exactly the issue that you raise).
  
  
  ---
  
  ### Answer by username_1 on 2017-06-01. Score: 15
  
  The effective length is $\tilde{l}\_i = l\_i - \mu + 1$ (note the R code at the bottom of Harold's blog post), which in the case of $\mu < l\_i$ should be 1. Ideally, you'd use the mean fragment length mapped to the particular feature, rather than a global $\mu$, but that's a lot more work for likely 0 benefit.
  
  Regarding choosing a particular transcript, ideally one would use a method like salmon or kallisto (or RSEM if you have time to kill). Otherwise, your options are (A) choose the major isoform (if it's known in your tissue and condition) or (B) use a "union gene model" (sum the non-redundant exon lengths) or (C) take the median transcript length. None of those three options make much of a difference if you're comparing between samples, though they're all inferior to a salmon/kallisto/etc. metric.
  
  Why are salmon et al. better methods? They don't use arbitrary metrics that will be the same across samples to determine the feature length. Instead, they use expectation maximization (or similarish, since at least salmon doesn't actually use EM) to quantify individual isoform usage. The effective gene length in a sample is then the average of the transcript lengths after weighting for their relative expression (yes, one should remove $\mu$ in there). This can then vary between samples, which is quite useful if you have isoform switching between samples/groups in such a way that methods A-C above would miss (think of cases where the switch is to a smaller transcript with higher coverage over it...resulting in the coverage/length in methods A-C to be tamped down).
  
  > **Comments:**
  > **username_0**: But `\tilde{l}` is a denominator. Setting it to 1 would dramatically increase the value for short transcripts. This sounds dangerous to me... Also, could you clarify what is the advantage of salmon/kallisto over A/B/C? Thanks.  
  > **username_1**: Short transcripts do have absurdly high FPKMs, it's one of the useless things about FPKMs. I'll update the question regarding salmon/kallisto/etc.  
  
  ---
  
  ### Answer by username_2 on 2017-06-16. Score: 4
  
  For the effective length part please see to Devons answer. I just have a small addition: Kallisto/Salmon/RSEM incorporate all bias estimates into the effective length meaning the effective length not only represent the length bias if you take the values from those tools (given that they were run with the bias algorithms enabled naturally).
  
  With regards to getting gene level estimates you should not choose a specific transcript. Instead you should extract/calculate the RPKM/FPKM/TxPM (transcript per million that Kallisto/Salmon/RSEM outputs) for each transcript and sum them up to get the gene level estimate.
  
  
  ---
  
  