<p>On google there are many tutorials about quantile normalzation, for example <a href="https://davetang.org/muse/2014/07/07/quantile-normalisation-in-r/" rel="nofollow noreferrer">here</a>. In that tutorial they made a function to calculate quantile normalization. Here an example with that function on your small data set.</p>

<pre><code>data
          gene_id SRR896664 SRR896663 SRR896665
1 ENSG00000000003     46106     36353     40614
2 ENSG00000000005       198       399      1200
3 ENSG00000000419     40364     37769     40849
4 ENSG00000000457     18924     16211     16057
5 ENSG00000000460     31040     28888     29901
6 ENSG00000000938       200         0       394
7 ENSG00000000971     14935     14353     12522

rownames(data) &lt;- data$gene_id

quantile_normalisation &lt;- function(df){
  df_rank &lt;- apply(df,2,rank,ties.method="min")
  df_sorted &lt;- data.frame(apply(df, 2, sort))
  df_mean &lt;- apply(df_sorted, 1, mean)

  index_to_mean &lt;- function(my_index, my_mean){
    return(my_mean[my_index])
  }

  df_final &lt;- apply(df_rank, 2, index_to_mean, my_mean=df_mean)
  rownames(df_final) &lt;- rownames(df)
  return(df_final)
}

new_data &lt;- quantile_normalisation(data[,2:4])
new_data
                 SRR896664  SRR896663  SRR896665
ENSG00000000003 41574.6667 39110.3333 39110.3333
ENSG00000000005   197.3333   599.6667   599.6667
ENSG00000000419 39110.3333 41574.6667 41574.6667
ENSG00000000457 17064.0000 17064.0000 17064.0000
ENSG00000000460 29943.0000 29943.0000 29943.0000
ENSG00000000938   599.6667   197.3333   197.3333
ENSG00000000971 13936.6667 13936.6667 13936.6667

boxplot(data[,2:4])
</code></pre>

<p><a href="https://i.sstatic.net/CtN0l.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/CtN0l.jpg" alt="enter image description here"></a></p>

<pre><code>boxplot(new_data)
</code></pre>

<p><a href="https://i.sstatic.net/dTUfu.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/dTUfu.jpg" alt="enter image description here"></a></p>

CC BY-SA 4.0
2019-01-23T19:11:33.150Z
2019-01-23T19:21:37.007Z
2019-01-23T19:21:37.007Z
benn
<p>Ma be <a href="http://bioconductor.org/packages/release/bioc/html/cqn.html" rel="nofollow noreferrer">CQN</a> from Bioconductor will be useful, though it doesn't perform just quantile normalisation. </p>

CC BY-SA 4.0
2019-01-28T15:53:39.070Z
Welcome to the site.  Could you expand your answer to include why CQN is a good choice?
Bioathlete
CC BY-SA 4.0
2019-01-29T04:41:41.533Z
Hi, I changed my answer. I realised its not what exactly op wants.
geek_y
CC BY-SA 4.0
2019-01-27T05:20:47.037Z
2019-01-29T04:43:27.153Z
2019-01-29T04:43:27.153Z
geek_y
<blockquote>
  <p><a href="https://www.rdocumentation.org/packages/limma/versions/3.28.14/topics/normalizeQuantiles" rel="nofollow noreferrer">https://www.rdocumentation.org/packages/limma/versions/3.28.14/topics/normalizeQuantiles</a></p>
</blockquote>

<p>is a possibility.</p>

<p>Another popular method is <a href="https://www.rdocumentation.org/packages/preprocessCore/versions/1.34.0/topics/normalize.quantiles" rel="nofollow noreferrer">https://www.rdocumentation.org/packages/preprocessCore/versions/1.34.0/topics/normalize.quantiles</a>.</p>

<pre><code>library(preprocessCore)
normalize.quantiles
</code></pre>

CC BY-SA 4.0
2020-12-09T10:13:52.107Z
the limma function you mentioned is actually used for microarray datasets not RNAseq ones.
Zahra Elahi
CC BY-SA 4.0
2019-01-25T03:52:39.400Z
2019-01-25T03:52:39.400Z
SmallChess
<p>I have a read count data (RNAseq) and want to perform quantile normalization. Could you please help me how to do it. I tried some scripts in R but it didn't work. I want the result output in matrix form.</p>

<pre><code>  gene_id   SRR896664   SRR896663   SRR896665
  ENSG00000000003   46106   36353   40614
  ENSG00000000005   198 399 1200
  ENSG00000000419   40364   37769   40849
  ENSG00000000457   18924   16211   16057
  ENSG00000000460   31040   28888   29901
  ENSG00000000938   200 0   394
  ENSG00000000971   14935   14353   12522
</code></pre>

<p>The script which i tried is</p>

<pre><code>  data &lt;- read.csv("testquantile.csv",header=T)
  head(data)
  rownames(data) &lt;- data[,1]
  data_mat &lt;- data.matrix(data[,-1]) 
  head(data_mat)
  data_norm &lt;- normalize.quantiles(m, copy = TRUE)
</code></pre>

CC BY-SA 4.0
2019-01-23T17:49:58.147Z
@swbarnes2 You can simply suggest to include the script, rather than giving a moral lecture. It is Bioinformatics forum, not a platform to taunt anyone.
Priya
CC BY-SA 4.0
2019-01-23T18:25:51.150Z
@priya Thanks for including the script. The code seems reasonable. Did it give you an error? For what command? What was the error?
burger
CC BY-SA 4.0
2019-01-23T21:24:52.357Z
@burger Thank you for getting back. My output file was showing a result for only 2 columns.
Priya
<rna-seq><gene><normalization><gene-expression>
How to quantile normalization on RNA seq counts
# How to quantile normalization on RNA seq counts

(Asked by: username_0 on 2019-01-23)

I have a read count data (RNAseq) and want to perform quantile normalization. Could you please help me how to do it. I tried some scripts in R but it didn't work. I want the result output in matrix form.
  gene_id   SRR896664   SRR896663   SRR896665
  ENSG00000000003   46106   36353   40614
  ENSG00000000005   198 399 1200
  ENSG00000000419   40364   37769   40849
  ENSG00000000457   18924   16211   16057
  ENSG00000000460   31040   28888   29901
  ENSG00000000938   200 0   394
  ENSG00000000971   14935   14353   12522

The script which i tried is
  data <- read.csv("testquantile.csv",header=T)
  head(data)
  rownames(data) <- data[,1]
  data_mat <- data.matrix(data[,-1]) 
  head(data_mat)
  data_norm <- normalize.quantiles(m, copy = TRUE)

**Tags:** rna-seq, gene, normalization, gene-expression
> **Comments:**
> **username_0**: @swbarnes2 You can simply suggest to include the script, rather than giving a moral lecture. It is Bioinformatics forum, not a platform to taunt anyone.  
> **username_1**: @priya Thanks for including the script. The code seems reasonable. Did it give you an error? For what command? What was the error?  
> **username_0**: @burger Thank you for getting back. My output file was showing a result for only 2 columns.  

---

## 3 answers

### Answer by username_2 on 2019-01-23. Score: 4 | Accepted answer

On google there are many tutorials about quantile normalzation, for example here. In that tutorial they made a function to calculate quantile normalization. Here an example with that function on your small data set.
data
          gene_id SRR896664 SRR896663 SRR896665
1 ENSG00000000003     46106     36353     40614
2 ENSG00000000005       198       399      1200
3 ENSG00000000419     40364     37769     40849
4 ENSG00000000457     18924     16211     16057
5 ENSG00000000460     31040     28888     29901
6 ENSG00000000938       200         0       394
7 ENSG00000000971     14935     14353     12522

rownames(data) <- data$gene_id

quantile_normalisation <- function(df){
  df_rank <- apply(df,2,rank,ties.method="min")
  df_sorted <- data.frame(apply(df, 2, sort))
  df_mean <- apply(df_sorted, 1, mean)

  index_to_mean <- function(my_index, my_mean){
    return(my_mean[my_index])
  }

  df_final <- apply(df_rank, 2, index_to_mean, my_mean=df_mean)
  rownames(df_final) <- rownames(df)
  return(df_final)
}

new_data <- quantile_normalisation(data[,2:4])
new_data
                 SRR896664  SRR896663  SRR896665
ENSG00000000003 41574.6667 39110.3333 39110.3333
ENSG00000000005   197.3333   599.6667   599.6667
ENSG00000000419 39110.3333 41574.6667 41574.6667
ENSG00000000457 17064.0000 17064.0000 17064.0000
ENSG00000000460 29943.0000 29943.0000 29943.0000
ENSG00000000938   599.6667   197.3333   197.3333
ENSG00000000971 13936.6667 13936.6667 13936.6667

boxplot(data[,2:4])


boxplot(new_data)


---

### Answer by username_3 on 2019-01-27. Score: 3

Ma be [CQN](http://bioconductor.org/packages/release/bioc/html/cqn.html) from Bioconductor will be useful, though it doesn't perform just quantile normalisation.

> **Comments:**
> **username_4**: Welcome to the site.  Could you expand your answer to include why CQN is a good choice?  
> **username_3**: Hi, I changed my answer. I realised its not what exactly op wants.  

---

### Answer by username_5 on 2019-01-25. Score: 1

https://www.rdocumentation.org/packages/limma/versions/3.28.14/topics/normalizeQuantiles

is a possibility.
Another popular method is https://www.rdocumentation.org/packages/preprocessCore/versions/1.34.0/topics/normalize.quantiles.
library(preprocessCore)
normalize.quantiles

> **Comments:**
> **username_6**: the limma function you mentioned is actually used for microarray datasets not RNAseq ones.  

---

