raivokolde / pheatmap

Pretty heatmaps
225 stars 83 forks source link

Get the after scale matrix #71

Open ShaowenJ opened 4 years ago

ShaowenJ commented 4 years ago

Dear Pheatmap developers:

Thanks for developing this very popular and useful heatmap plot function. Don't know if you guys are still here. Do you know how to get the after scaled matrix from a generated heatmap?

I tried to scale myself and set the scale parameter to none, but can never recapture the same heatmap, still don't know why.

Any helps would be appreciated!

keenhl commented 2 years ago

If you have the original matrix, this should work to get the scaled values.

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

matrix_scaled_by_rows <- scale_by_rows(matrix_original)