Thanks a lot..! What exactly the sweep function is doing? Also, is there a possibility instead of using the mean of the whole row to get only the mean of a group of the row values? So the values in the matrix (heat map) used in the comparison are z-scores and not the intensities of the gene expressions, right?
Also, as I can understand from the code, heatmap is using distfun function for the clusering. Can I use pearson correlation for the clustering? My main object of using the heatmap is to examine the expression levels of the marker genes and to confirm that the marker genes are clearly differentially expressed in the two subtypes of the disease that I examine. Many thanks, Chrysanthi. 2009/7/8 James W. MacDonald <jmac...@med.umich.edu> > 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 > [[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.