Answers.Body: <p>Yes, this is a standard way of obtaining RPKM/FPKM/CPM values for plotting. Not that you do not need to use a <code>for</code> loop for any of the computations in R. You have a matrix of normalized values and things like transcript length are constant across samples (at least unless you're using something like salmon...although then you'd have TPMs to begin with).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-16T14:48:44.830Z
Answers.Text: Thanks @devon that I understand (R and loops) but I am not able to confirm if assessing FPKM from normalized read counts make sense.
Answers.UserDisplayName: Rajinder
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-16T15:02:09.287Z
Answers.Text: It makes more sense then using straight FPKMs. Inputting normalized values helps to negate the otherwise intrinsic issues with FPKMs (namely, that they're heavily affected by outlier genes).
Answers.UserDisplayName: Devon Ryan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-17T10:52:45.477Z
Answers.Text: To expand on what @DevonRyan is saying, if you calculate FPKM neat (without sizefactor adjustment), you are normalizing by library size. If you use DESeq2 to normalize, it is median normalization. You have to choose one of these, depending on what makes sense. Then using the normalized counts, you divide by transcript length etc, same value across all samples to get the final normalized values. You don't need to loop.
Answers.UserDisplayName: StupidWolf
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-17T13:33:10.140Z
Answers.Text: Thanks
  So then if I apply these two normalization approaches in this order- median normalization using DESeq2 and then on normalized read counts library size normalization using FPKM; it is okay to do so
Answers.UserDisplayName: Rajinder
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-16T14:16:20.810Z
Answers.LastActivityDate: 2019-09-16T14:16:20.810Z
Answers.UserDisplayName: Devon Ryan
Answers.Body: <p>You might want to check the <a href="http://bioconductor.org/packages/release/bioc/vignettes/EDASeq/inst/doc/EDASeq.html" rel="nofollow noreferrer">EDASeq()</a> package, which attempts to address both gene-specific and sample-specific effects (I believe this is what you are trying to achieve). From their vignette:</p>
  
  <blockquote>
    <p>Following (Risso et al. 2011), we consider two main types of effects
    on gene-level counts: (1) within-lane gene-specific (and possibly
    lane-specific) effects, e.g., related to gene length or GC-content,
    and (2) effects related to between-lane distributional differences,
    e.g., sequencing depth. Accordingly, withinLaneNormalization and
    betweenLaneNormalization adjust for the first and second type of
    effects, respectively. <strong>We recommend to normalize for within-lane
    effects prior to between-lane normalization</strong>.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-16T12:18:40.090Z
Answers.Text: Thanks @haci
  But this is not what I am looking for. I have now added more information to my question.
Answers.UserDisplayName: Rajinder
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-16T12:05:39.250Z
Answers.LastActivityDate: 2019-09-16T12:05:39.250Z
Answers.UserDisplayName: haci
Body: <p>I want to get the expression data that is <strong><em>in-sample normalized</em></strong> like FPKM and also <strong><em>across samples normalized</em></strong> as obtained using DESeq2 or else.</p>
  
  <p>What I am currently doing is that I first normalize the data across samples (using DESeq) and from the resultant expression I calculate the FPKM. Does it make sense or am I missing something here?</p>
  
  <p>This is how I am doing (not the exact code but the idea)</p>
  
  <pre><code>dds &lt;- DESeqDataSetFromMatrix(countData, DataFrame(condition), ~ condition)
  dds &lt;- estimateSizeFactors(dds)
  norm_data &lt;- counts(dds, normalized=TRUE)
  
  foreach sample
  {
      foreach transcript
      {
          FPKM = (Normalized read count * 10^9) / (transcript length * total mapped normalized read count)
      }
  
  }
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-09-16T09:12:16.893Z
Comments.Text: Welcome to the site! Could you please post the code on how are you doing this ? (This could clarify things about the order and if it is correctly done)
Comments.UserDisplayName: llrs
Tags: <rna-seq><normalization><reads><fpkm>
Title: In-sample and across samples normalized expression
ThreadText: # In-sample and across samples normalized expression
  
  (Asked by: username_0 on 2019-09-16)
  
  I want to get the expression data that is ***in-sample normalized*** like FPKM and also ***across samples normalized*** as obtained using DESeq2 or else.
  
  What I am currently doing is that I first normalize the data across samples (using DESeq) and from the resultant expression I calculate the FPKM. Does it make sense or am I missing something here?
  
  This is how I am doing (not the exact code but the idea)
  
  ```
  dds <- DESeqDataSetFromMatrix(countData, DataFrame(condition), ~ condition)
  dds <- estimateSizeFactors(dds)
  norm_data <- counts(dds, normalized=TRUE)
  
  foreach sample
  {
      foreach transcript
      {
          FPKM = (Normalized read count * 10^9) / (transcript length * total mapped normalized read count)
      }
  
  }
  
  ```
  
  **Tags:** rna-seq, normalization, reads, fpkm
  
  > **Comments:**
  > **username_1**: Welcome to the site! Could you please post the code on how are you doing this ? (This could clarify things about the order and if it is correctly done)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-09-16. Score: 1
  
  Yes, this is a standard way of obtaining RPKM/FPKM/CPM values for plotting. Not that you do not need to use a `for` loop for any of the computations in R. You have a matrix of normalized values and things like transcript length are constant across samples (at least unless you're using something like salmon...although then you'd have TPMs to begin with).
  
  > **Comments:**
  > **username_0**: Thanks @username_2 that I understand (R and loops) but I am not able to confirm if assessing FPKM from normalized read counts make sense.  
  > **username_2**: It makes more sense then using straight FPKMs. Inputting normalized values helps to negate the otherwise intrinsic issues with FPKMs (namely, that they're heavily affected by outlier genes).  
  > **username_3**: To expand on what @username_2 is saying, if you calculate FPKM neat (without sizefactor adjustment), you are normalizing by library size. If you use DESeq2 to normalize, it is median normalization. You have to choose one of these, depending on what makes sense. Then using the normalized counts, you divide by transcript length etc, same value across all samples to get the final normalized values. You don't need to loop.  
  > **username_0**: Thanks So then if I apply these two normalization approaches in this order- median normalization using DESeq2 and then on normalized read counts library size normalization using FPKM; it is okay to do so  
  
  ---
  
  ### Answer by username_4 on 2019-09-16. Score: 0
  
  You might want to check the [EDASeq()](http://bioconductor.org/packages/release/bioc/vignettes/EDASeq/inst/doc/EDASeq.html) package, which attempts to address both gene-specific and sample-specific effects (I believe this is what you are trying to achieve). From their vignette:
  
  > Following (Risso et al. 2011), we consider two main types of effects
  > on gene-level counts: (1) within-lane gene-specific (and possibly
  > lane-specific) effects, e.g., related to gene length or GC-content,
  > and (2) effects related to between-lane distributional differences,
  > e.g., sequencing depth. Accordingly, withinLaneNormalization and
  > betweenLaneNormalization adjust for the first and second type of
  > effects, respectively. **We recommend to normalize for within-lane
  > effects prior to between-lane normalization**.
  
  > **Comments:**
  > **username_0**: Thanks @username_4 But this is not what I am looking for. I have now added more information to my question.  
  
  ---
  
  