Hi Chrysanthi,

Chrysanthi A. wrote:
Hi,

I am analysing gene expression data using the heatmap.2 function in R and I
was wondering what is the formula of the "raw z-score" bar which shows the
colors for each pixel.
According to that post:
https://mailman.stat.ethz.ch/pipermail/r-help/2006-September/113598.html, it
is the

(actual value - mean of the group) / standard deviation.

But, mean of which group? Mean of the gene vector? And actual value of that
gene on a sample?  I would be grateful if you could give me some more
details about it or even if there is a book/manual that I could address
to..

How about looking at the code?

    if (scale == "row") {
        retval$rowMeans <- rm <- rowMeans(x, na.rm = na.rm)
        x <- sweep(x, 1, rm)
        retval$rowSDs <- sx <- apply(x, 1, sd, na.rm = na.rm)
        x <- sweep(x, 1, sx, "/")
    }
    else if (scale == "column") {
        retval$colMeans <- rm <- colMeans(x, na.rm = na.rm)
        x <- sweep(x, 2, rm)
        retval$colSDs <- sx <- apply(x, 2, sd, na.rm = na.rm)
        x <- sweep(x, 2, sx, "/")
    }

So the z-score is calculated on either the row or column (or the default of "none").

I don't see how you can get something saying 'raw z-score'. I get either 'Row Z-Score' or 'Column Z-Score'. So assuming you meant Row Z-Score, then the rows are centered and scaled by subtracting the mean of the row from every value and then dividing the resulting values by the standard deviation of the row.

Best,

Jim



Thanks a lot,

Chrysanthi.

*
*

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

--
James W. MacDonald, M.S.
Biostatistician
Douglas Lab
University of Michigan
Department of Human Genetics
5912 Buhl
1241 E. Catherine St.
Ann Arbor MI 48109-5618
734-615-7826

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to