# How to quantile normalization on RNA seq counts

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)
rownames(data) <- data[,1]
data_mat <- data.matrix(data[,-1])
data_norm <- normalize.quantiles(m, copy = TRUE)

• @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. Jan 23, 2019 at 17:49
• @priya Thanks for including the script. The code seems reasonable. Did it give you an error? For what command? What was the error? Jan 23, 2019 at 18:25
• @burger Thank you for getting back. My output file was showing a result for only 2 columns. Jan 23, 2019 at 21:24

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)


Ma be CQN from Bioconductor will be useful, though it doesn't perform just quantile normalisation.

• Welcome to the site. Could you expand your answer to include why CQN is a good choice? Jan 28, 2019 at 15:53
• Hi, I changed my answer. I realised its not what exactly op wants. Jan 29, 2019 at 4:41

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

• the limma function you mentioned is actually used for microarray datasets not RNAseq ones. Dec 9, 2020 at 10:13