text: user8895: Is it okay to use CPM normalization (with/without log transform) after using TMM normalization? Why do we need both?
   library(edgeR)
   library(SummarizedExperiment)
   load(url("http://duffel.rail.bio/recount/SRP049355/rse_gene.Rdata"))
    counts <- assays(rse_gene)$counts
    y <- as.matrix((counts))
   y <- DGEList(counts = y, group=c(1,2,3,4,5,6,7,8,9,10))
    y <- calcNormFactors(y)
   z <- cpm(y, normalized.lib.size=TRUE)
  scaledata <- t(scale(t(z))) # Centers and scales data.
  hc <- hclust(as.dist(1-cor(scaledata, method="spearman")), method="complete") # Clusters columns by Spearman correlation.
   TreeC = as.dendrogram(hc, method="average")
   plot(TreeC,
   main = "Sample Clustering",
   ylab = "Height")
  
  
  user-1: In fact the cpm function will use the size factors (TMM) that were calculated with calcNormFactors. In the absence of the size factors cpm would do a naive per-million scaling so only correct for differences in library size. The power of the size factors is to also correct for library composition. I recommend this video for details. In short: What you do is fine. I would suggest though that you use the log = TRUE option for cpm as one typically performs downstream applications (even when using the Z-score) on the log scale. Or alternatively t(scale(t(log2(z+1)))).
  
original_text: 8895: <p>Is it okay to use CPM normalization (with/without log transform) after using TMM normalization? Why do we <a href="https://2-bitbio.com/2017/10/clustering-rnaseq-data-using-k-means.html" rel="nofollow noreferrer">need both</a>?</p>
  <pre><code> library(edgeR)
   library(SummarizedExperiment)
   load(url(&quot;http://duffel.rail.bio/recount/SRP049355/rse_gene.Rdata&quot;))
    counts &lt;- assays(rse_gene)$counts
    y &lt;- as.matrix((counts))
   y &lt;- DGEList(counts = y, group=c(1,2,3,4,5,6,7,8,9,10))
    y &lt;- calcNormFactors(y)
   z &lt;- cpm(y, normalized.lib.size=TRUE)
  scaledata &lt;- t(scale(t(z))) # Centers and scales data.
  hc &lt;- hclust(as.dist(1-cor(scaledata, method=&quot;spearman&quot;)), method=&quot;complete&quot;) # Clusters columns by Spearman correlation.
   TreeC = as.dendrogram(hc, method=&quot;average&quot;)
   plot(TreeC,
   main = &quot;Sample Clustering&quot;,
   ylab = &quot;Height&quot;)
  </code></pre>
   -1: <p>In fact the <code>cpm</code> function will use the size factors (TMM) that were calculated with <code>calcNormFactors</code>. In the absence of the size factors <code>cpm</code> would do a naive per-million scaling so only correct for differences in library size. The power of the size factors is to also correct for library composition. I recommend <a href="https://www.youtube.com/watch?v=Wdt6jdi-NQo" rel="nofollow noreferrer">this video</a> for details. In short: What you do is fine. I would suggest though that you use the <code>log = TRUE</code> option for <code>cpm</code> as one typically performs downstream applications (even when using the Z-score) on the log scale. Or alternatively <code>t(scale(t(log2(z+1))))</code>.</p>
  