I have made a heatmap using RPKM values from a RNA-Seq dataset using the pheatmap() function in R. I have log2-transformed the data before performing Z-score standardisation of the data. I have also clustered the rows and columns of the heatmap. I have the following code:
heatmap_data_log2 %>% pheatmap(color = colorRampPalette(c("blue2","white","red"))(100), scale = "column", cluster_cols = T, clustering_method = "ward.D2", angle_col = 45, fontsize_row = 7.5, fontsize_col = 8, border_color = NA, cutree_rows = 4)
I have seen in a video tutorial that the pheatmap() function does the Z-score scaling before doing the clustering of the rows and columns. However, in this online article, it says that "The Z-scores are computed after the clustering, so that it only affects the graphical aesthetics and the color visualization is improved".
As these two sources are giving contradictory information, I was wondering which is better. Should you do Z-score scaling of the gene expression values before doing the clustering or after? Any advice is appreciated.