Error in heatmap.2 (gplots)

前端 未结 3 2015
一整个雨季
一整个雨季 2020-12-18 07:34

Ive moved on to a new server and Installed R version 3.0 on it. (gplots library was no longer available for 2.14)

Using a script that worked for version 2.14 I now e

3条回答
  •  有刺的猬
    2020-12-18 08:17

    This problem ("node stack overflow" error while using heatmap.2 function) occurs due to too many identical values in a specific column in your matrix, which causes recursion issue on R producing the error.

    What I can suggest (which at least how I solved my very exact problem for my data) is to produce random numbers around the identical numbers and replace them with the original numbers in the matrix:

    for (i in 1:nrow(my_matrix)) {
       if (my_matrix[i,my_column]=="100") { # assume i have too many 100 in my_column
          my_matrix[i,my_column]=runif(1,99,101) # replace 100 with nearby values randomly
        }
    }
    

    In this way, the heatmap is created without any issue since there are not too many identical numbers anymore, and also it virtually doesn't affect your matrix since you can choose a very small interval for random number generation around your identical value which will still reflect the original values with invisible color changes on the heatmap.

提交回复
热议问题