**1.4k**wrote:

I have generated 2 heatmaps using heatmap.2 function. Following is my command and it's output. First heatmap contains z-score which is been calculated by heatmap.2 function with parameter "scale=row". While second heatmap I have generated is with values calculated by my own function name "normalisation" which also calculate the Z-score. Surprisingly output is different in both case. I wonder how heatmap.2 calculate the Z-Score. The way I have calculated Z-score is right ? Please help.

Command For First Heatmap --> h1

```
heatmap.2 (
mat ,
col=colorRampPalette(c("blue","white","red"))(dim(mat)[1]*dim(mat)[2]),
density ="none",
Colv = T,
Rowv=T,
trace ="none",
scale="row",
dendrogram = "both",
main = paste("Cg_Pol_2_Top_2k_Highly_Variable"),#,dim(mat)[1],sep =" "),
adjCol = c(1,0),
margins = c(10,4),
lmat = rbind(c(4,3),c(2,1)),
lwid = c(1.5,4),
lhei = c(0.5,5),
labRow=c(""),
keysize=1,
)
```

Command for heatmap 2

```
heatmap.2 (
normalisation(mat),
col=colorRampPalette(c("blue","white","red"))(dim(mat)[1]*dim(mat)[2]),
density ="none",
Colv = T,
Rowv=T,
trace ="none",
scale="none",
dendrogram = "both",
main = paste("Cg_Pol_2_Top_2k_Highly_Variable"),#,dim(mat)[1],sep =" "),
adjCol = c(1,0),
margins = c(10,4),
lmat = rbind(c(4,3),c(2,1)),
lwid = c(1.5,4),
lhei = c(0.5,5),
labRow=c(""),
keysize=1,
)
normalization<-function(x){
dimm=dim(x)
for(i in 1:dimm[1]){
x[i,]=(x[i,]-mean(x[i,]))/sd(x[i,])
}
return(x)
}
```

**45k**• written 3.4 years ago by Chirag Parsania •

**1.4k**

You use

`normalisation(mat)`

and notin your code. Is it a typo or could "normalisation" be a different function than the one written below ?`normaliZation(mat)`

4.6k