Question: What is pheatmap's scale row?
0
gravatar for agicict
20 months ago by
agicict120
Korea, Republic Of
agicict120 wrote:

Hello.

There is a R package called pheatmap.

one of the pheatmap parameter is scale which normalize numeric values in row-wise or column-wise

I would like to know the formula of normalization process.

Is the Z-score normalization?

R • 2.8k views
ADD COMMENTlink modified 20 months ago by ddiez1.7k • written 20 months ago by agicict120
5
gravatar for ddiez
20 months ago by
ddiez1.7k
Japan
ddiez1.7k wrote:

Not really a bioinformatics question, I think.

I good thing about open source is that you can download the code and check it yourself. I did so and found the following code in pheatmap.r file:

scale_rows = function(x){
    m = apply(x, 1, mean, na.rm = T)
    s = apply(x, 1, sd, na.rm = T)
    return((x - m) / s)
}

scale_mat = function(mat, scale){
    if(!(scale %in% c("none", "row", "column"))){
        stop("scale argument shoud take values: 'none', 'row' or 'column'")
    }
    mat = switch(scale, none = mat, row = scale_rows(mat), column = t(scale_rows(t(mat))))
    return(mat)
}

The second function chooses an action depending on the value of the variable scale. The first function performs row-wise scaling (or col-wise on the transposed matrix). So, scale in this package means removing the mean (centering) and dividing by the standard deviation (scaling). Also, take a look at ?scale for the base function. Why the author didn't use this function is not clear to me.

ADD COMMENTlink modified 19 months ago • written 20 months ago by ddiez1.7k

Don't forget victorization, bro. Shouldn't the return value of scale_rows() be like:

return((x - rep(m, ncol(x)) / rep(s, ncol(x))
ADD REPLYlink written 10 months ago by registerdude0

The original code is vectorized. It will return a matrix of the same dimensions as x.

ADD REPLYlink written 7 months ago by luisvalesilva0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1237 users visited in the last hour